2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlib/pci/pci.h>
22 #include <vpp/api/types.h>
23 #include <vppinfra/socket.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip/ip_neighbor.h>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/l2/l2_input.h>
30 #include <vnet/l2tp/l2tp.h>
31 #include <vnet/vxlan/vxlan.h>
32 #include <vnet/geneve/geneve.h>
33 #include <vnet/gre/gre.h>
34 #include <vnet/vxlan-gpe/vxlan_gpe.h>
35 #include <vnet/lisp-gpe/lisp_gpe.h>
37 #include <vpp/api/vpe_msg_enum.h>
38 #include <vnet/l2/l2_classify.h>
39 #include <vnet/l2/l2_vtr.h>
40 #include <vnet/classify/in_out_acl.h>
41 #include <vnet/classify/policer_classify.h>
42 #include <vnet/classify/flow_classify.h>
43 #include <vnet/mpls/mpls.h>
44 #include <vnet/ipsec/ipsec.h>
46 #include <vnet/cop/cop.h>
47 #include <vnet/ip/ip6_hop_by_hop.h>
48 #include <vnet/ip/ip_source_and_port_range_check.h>
49 #include <vnet/policer/xlate.h>
50 #include <vnet/span/span.h>
51 #include <vnet/policer/policer.h>
52 #include <vnet/policer/police.h>
53 #include <vnet/mfib/mfib_types.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include <vnet/ethernet/ethernet_types_api.h>
57 #include <vnet/ip/ip_types_api.h>
58 #include "vat/json_format.h"
59 #include <vnet/ip/ip_types_api.h>
60 #include <vnet/ethernet/ethernet_types_api.h>
65 #define vl_typedefs /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* declare message handlers for each api */
71 #define vl_endianfun /* define message structures */
72 #include <vpp/api/vpe_all_api_h.h>
75 /* instantiate all the print functions we know about */
76 #if VPP_API_TEST_BUILTIN == 0
77 #define vl_print(handle, ...)
79 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
82 #include <vpp/api/vpe_all_api_h.h>
85 #define __plugin_msg_base 0
86 #include <vlibapi/vat_helper_macros.h>
88 #include <vnet/format_fns.h>
90 void vl_api_set_elog_main (elog_main_t * m);
91 int vl_api_set_elog_trace_api_messages (int enable);
93 #if VPP_API_TEST_BUILTIN == 0
103 vat_socket_connect (vat_main_t * vam)
106 vam->socket_client_main = &socket_client_main;
107 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
109 0 /* default socket rx, tx buffer */ )))
111 /* vpp expects the client index in network order */
112 vam->my_client_index = htonl (socket_client_main.client_index);
115 #else /* vpp built-in case, we don't do sockets... */
117 vat_socket_connect (vat_main_t * vam)
123 vl_socket_client_read (int wait)
129 vl_socket_client_write ()
135 vl_socket_client_msg_alloc (int nbytes)
143 vat_time_now (vat_main_t * vam)
145 #if VPP_API_TEST_BUILTIN
146 return vlib_time_now (vam->vlib_main);
148 return clib_time_now (&vam->clib_time);
153 errmsg (char *fmt, ...)
155 vat_main_t *vam = &vat_main;
160 s = va_format (0, fmt, &va);
165 #if VPP_API_TEST_BUILTIN
166 vlib_cli_output (vam->vlib_main, (char *) s);
169 if (vam->ifp != stdin)
170 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
171 vam->input_line_number);
173 fformat (vam->ofp, "%s\n", (char *) s);
181 #if VPP_API_TEST_BUILTIN == 0
183 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
185 vat_main_t *vam = va_arg (*args, vat_main_t *);
186 u32 *result = va_arg (*args, u32 *);
190 if (!unformat (input, "%s", &if_name))
193 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
201 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
206 /* Parse an IP4 address %d.%d.%d.%d. */
208 unformat_ip4_address (unformat_input_t * input, va_list * args)
210 u8 *result = va_arg (*args, u8 *);
213 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
216 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
228 unformat_ethernet_address (unformat_input_t * input, va_list * args)
230 u8 *result = va_arg (*args, u8 *);
233 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
234 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
238 for (i = 0; i < 6; i++)
239 if (a[i] >= (1 << 8))
242 for (i = 0; i < 6; i++)
248 /* Returns ethernet type as an int in host byte order. */
250 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
253 u16 *result = va_arg (*args, u16 *);
257 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
259 if (type >= (1 << 16))
267 /* Parse an IP6 address. */
269 unformat_ip6_address (unformat_input_t * input, va_list * args)
271 ip6_address_t *result = va_arg (*args, ip6_address_t *);
273 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
274 uword c, n_colon, double_colon_index;
276 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
277 double_colon_index = ARRAY_LEN (hex_quads);
278 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
281 if (c >= '0' && c <= '9')
283 else if (c >= 'a' && c <= 'f')
284 hex_digit = c + 10 - 'a';
285 else if (c >= 'A' && c <= 'F')
286 hex_digit = c + 10 - 'A';
287 else if (c == ':' && n_colon < 2)
291 unformat_put_input (input);
295 /* Too many hex quads. */
296 if (n_hex_quads >= ARRAY_LEN (hex_quads))
301 hex_quad = (hex_quad << 4) | hex_digit;
303 /* Hex quad must fit in 16 bits. */
304 if (n_hex_digits >= 4)
311 /* Save position of :: */
314 /* More than one :: ? */
315 if (double_colon_index < ARRAY_LEN (hex_quads))
317 double_colon_index = n_hex_quads;
320 if (n_colon > 0 && n_hex_digits > 0)
322 hex_quads[n_hex_quads++] = hex_quad;
328 if (n_hex_digits > 0)
329 hex_quads[n_hex_quads++] = hex_quad;
334 /* Expand :: to appropriate number of zero hex quads. */
335 if (double_colon_index < ARRAY_LEN (hex_quads))
337 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
339 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
340 hex_quads[n_zero + i] = hex_quads[i];
342 for (i = 0; i < n_zero; i++)
343 hex_quads[double_colon_index + i] = 0;
345 n_hex_quads = ARRAY_LEN (hex_quads);
348 /* Too few hex quads given. */
349 if (n_hex_quads < ARRAY_LEN (hex_quads))
352 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
353 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
360 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
362 u32 *r = va_arg (*args, u32 *);
365 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
366 foreach_ipsec_policy_action
374 format_ipsec_crypto_alg (u8 * s, va_list * args)
376 u32 i = va_arg (*args, u32);
381 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
382 foreach_ipsec_crypto_alg
385 return format (s, "unknown");
387 return format (s, "%s", t);
391 format_ipsec_integ_alg (u8 * s, va_list * args)
393 u32 i = va_arg (*args, u32);
398 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
399 foreach_ipsec_integ_alg
402 return format (s, "unknown");
404 return format (s, "%s", t);
407 #else /* VPP_API_TEST_BUILTIN == 1 */
409 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
411 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
412 vnet_main_t *vnm = vnet_get_main ();
413 u32 *result = va_arg (*args, u32 *);
415 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
419 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
421 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
422 vnet_main_t *vnm = vnet_get_main ();
423 u32 *result = va_arg (*args, u32 *);
425 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
428 #endif /* VPP_API_TEST_BUILTIN */
431 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
433 u32 *r = va_arg (*args, u32 *);
436 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
437 foreach_ipsec_crypto_alg
445 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
447 u32 *r = va_arg (*args, u32 *);
450 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
451 foreach_ipsec_integ_alg
459 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
461 u8 *r = va_arg (*args, u8 *);
463 if (unformat (input, "kbps"))
464 *r = SSE2_QOS_RATE_KBPS;
465 else if (unformat (input, "pps"))
466 *r = SSE2_QOS_RATE_PPS;
473 unformat_policer_round_type (unformat_input_t * input, va_list * args)
475 u8 *r = va_arg (*args, u8 *);
477 if (unformat (input, "closest"))
478 *r = SSE2_QOS_ROUND_TO_CLOSEST;
479 else if (unformat (input, "up"))
480 *r = SSE2_QOS_ROUND_TO_UP;
481 else if (unformat (input, "down"))
482 *r = SSE2_QOS_ROUND_TO_DOWN;
489 unformat_policer_type (unformat_input_t * input, va_list * args)
491 u8 *r = va_arg (*args, u8 *);
493 if (unformat (input, "1r2c"))
494 *r = SSE2_QOS_POLICER_TYPE_1R2C;
495 else if (unformat (input, "1r3c"))
496 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
497 else if (unformat (input, "2r3c-2698"))
498 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
499 else if (unformat (input, "2r3c-4115"))
500 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
501 else if (unformat (input, "2r3c-mef5cf1"))
502 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
509 unformat_dscp (unformat_input_t * input, va_list * va)
511 u8 *r = va_arg (*va, u8 *);
514 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
523 unformat_policer_action_type (unformat_input_t * input, va_list * va)
525 sse2_qos_pol_action_params_st *a
526 = va_arg (*va, sse2_qos_pol_action_params_st *);
528 if (unformat (input, "drop"))
529 a->action_type = SSE2_QOS_ACTION_DROP;
530 else if (unformat (input, "transmit"))
531 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
532 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
533 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
540 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
542 u32 *r = va_arg (*va, u32 *);
545 if (unformat (input, "ip4"))
546 tid = POLICER_CLASSIFY_TABLE_IP4;
547 else if (unformat (input, "ip6"))
548 tid = POLICER_CLASSIFY_TABLE_IP6;
549 else if (unformat (input, "l2"))
550 tid = POLICER_CLASSIFY_TABLE_L2;
559 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
561 u32 *r = va_arg (*va, u32 *);
564 if (unformat (input, "ip4"))
565 tid = FLOW_CLASSIFY_TABLE_IP4;
566 else if (unformat (input, "ip6"))
567 tid = FLOW_CLASSIFY_TABLE_IP6;
575 #if (VPP_API_TEST_BUILTIN==0)
577 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
578 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
579 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
580 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
583 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
585 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
586 mfib_itf_attribute_t attr;
589 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
591 if (unformat (input, mfib_itf_flag_long_names[attr]))
592 *iflags |= (1 << attr);
594 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
596 if (unformat (input, mfib_itf_flag_names[attr]))
597 *iflags |= (1 << attr);
600 return (old == *iflags ? 0 : 1);
604 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
606 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
607 mfib_entry_attribute_t attr;
610 FOR_EACH_MFIB_ATTRIBUTE (attr)
612 if (unformat (input, mfib_flag_long_names[attr]))
613 *eflags |= (1 << attr);
615 FOR_EACH_MFIB_ATTRIBUTE (attr)
617 if (unformat (input, mfib_flag_names[attr]))
618 *eflags |= (1 << attr);
621 return (old == *eflags ? 0 : 1);
625 format_ip4_address (u8 * s, va_list * args)
627 u8 *a = va_arg (*args, u8 *);
628 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
632 format_ip6_address (u8 * s, va_list * args)
634 ip6_address_t *a = va_arg (*args, ip6_address_t *);
635 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
637 i_max_n_zero = ARRAY_LEN (a->as_u16);
639 i_first_zero = i_max_n_zero;
641 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
643 u32 is_zero = a->as_u16[i] == 0;
644 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
650 if ((!is_zero && n_zeros > max_n_zeros)
651 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
653 i_max_n_zero = i_first_zero;
654 max_n_zeros = n_zeros;
655 i_first_zero = ARRAY_LEN (a->as_u16);
660 last_double_colon = 0;
661 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
663 if (i == i_max_n_zero && max_n_zeros > 1)
665 s = format (s, "::");
666 i += max_n_zeros - 1;
667 last_double_colon = 1;
671 s = format (s, "%s%x",
672 (last_double_colon || i == 0) ? "" : ":",
673 clib_net_to_host_u16 (a->as_u16[i]));
674 last_double_colon = 0;
681 /* Format an IP46 address. */
683 format_ip46_address (u8 * s, va_list * args)
685 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
686 ip46_type_t type = va_arg (*args, ip46_type_t);
692 is_ip4 = ip46_address_is_ip4 (ip46);
703 format (s, "%U", format_ip4_address, &ip46->ip4) :
704 format (s, "%U", format_ip6_address, &ip46->ip6);
708 format_ethernet_address (u8 * s, va_list * args)
710 u8 *a = va_arg (*args, u8 *);
712 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
713 a[0], a[1], a[2], a[3], a[4], a[5]);
718 increment_v4_address (vl_api_ip4_address_t * i)
720 ip4_address_t *a = (ip4_address_t *) i;
723 v = ntohl (a->as_u32) + 1;
724 a->as_u32 = ntohl (v);
728 increment_v6_address (vl_api_ip6_address_t * i)
730 ip6_address_t *a = (ip6_address_t *) i;
733 v0 = clib_net_to_host_u64 (a->as_u64[0]);
734 v1 = clib_net_to_host_u64 (a->as_u64[1]);
739 a->as_u64[0] = clib_net_to_host_u64 (v0);
740 a->as_u64[1] = clib_net_to_host_u64 (v1);
744 increment_address (vl_api_address_t * a)
746 if (clib_net_to_host_u32 (a->af) == ADDRESS_IP4)
747 increment_v4_address (&a->un.ip4);
748 else if (clib_net_to_host_u32 (a->af) == ADDRESS_IP6)
749 increment_v6_address (&a->un.ip6);
753 set_ip4_address (vl_api_address_t * a, u32 v)
755 if (a->af == ADDRESS_IP4)
757 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
763 increment_mac_address (u8 * mac)
765 u64 tmp = *((u64 *) mac);
766 tmp = clib_net_to_host_u64 (tmp);
767 tmp += 1 << 16; /* skip unused (least significant) octets */
768 tmp = clib_host_to_net_u64 (tmp);
770 clib_memcpy (mac, &tmp, 6);
774 vat_json_object_add_address (vat_json_node_t * node,
775 const char *str, const vl_api_address_t * addr)
777 if (ADDRESS_IP6 == addr->af)
781 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
782 vat_json_object_add_ip6 (node, str, ip6);
788 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
789 vat_json_object_add_ip4 (node, str, ip4);
794 vat_json_object_add_prefix (vat_json_node_t * node,
795 const vl_api_prefix_t * prefix)
797 vat_json_object_add_uint (node, "len", prefix->len);
798 vat_json_object_add_address (node, "address", &prefix->address);
801 static void vl_api_create_loopback_reply_t_handler
802 (vl_api_create_loopback_reply_t * mp)
804 vat_main_t *vam = &vat_main;
805 i32 retval = ntohl (mp->retval);
807 vam->retval = retval;
808 vam->regenerate_interface_table = 1;
809 vam->sw_if_index = ntohl (mp->sw_if_index);
810 vam->result_ready = 1;
813 static void vl_api_create_loopback_reply_t_handler_json
814 (vl_api_create_loopback_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 vat_json_node_t node;
819 vat_json_init_object (&node);
820 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
821 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
823 vat_json_print (vam->ofp, &node);
824 vat_json_free (&node);
825 vam->retval = ntohl (mp->retval);
826 vam->result_ready = 1;
829 static void vl_api_create_loopback_instance_reply_t_handler
830 (vl_api_create_loopback_instance_reply_t * mp)
832 vat_main_t *vam = &vat_main;
833 i32 retval = ntohl (mp->retval);
835 vam->retval = retval;
836 vam->regenerate_interface_table = 1;
837 vam->sw_if_index = ntohl (mp->sw_if_index);
838 vam->result_ready = 1;
841 static void vl_api_create_loopback_instance_reply_t_handler_json
842 (vl_api_create_loopback_instance_reply_t * mp)
844 vat_main_t *vam = &vat_main;
845 vat_json_node_t node;
847 vat_json_init_object (&node);
848 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
849 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
851 vat_json_print (vam->ofp, &node);
852 vat_json_free (&node);
853 vam->retval = ntohl (mp->retval);
854 vam->result_ready = 1;
857 static void vl_api_af_packet_create_reply_t_handler
858 (vl_api_af_packet_create_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 i32 retval = ntohl (mp->retval);
863 vam->retval = retval;
864 vam->regenerate_interface_table = 1;
865 vam->sw_if_index = ntohl (mp->sw_if_index);
866 vam->result_ready = 1;
869 static void vl_api_af_packet_create_reply_t_handler_json
870 (vl_api_af_packet_create_reply_t * mp)
872 vat_main_t *vam = &vat_main;
873 vat_json_node_t node;
875 vat_json_init_object (&node);
876 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
877 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
879 vat_json_print (vam->ofp, &node);
880 vat_json_free (&node);
882 vam->retval = ntohl (mp->retval);
883 vam->result_ready = 1;
886 static void vl_api_create_vlan_subif_reply_t_handler
887 (vl_api_create_vlan_subif_reply_t * mp)
889 vat_main_t *vam = &vat_main;
890 i32 retval = ntohl (mp->retval);
892 vam->retval = retval;
893 vam->regenerate_interface_table = 1;
894 vam->sw_if_index = ntohl (mp->sw_if_index);
895 vam->result_ready = 1;
898 static void vl_api_create_vlan_subif_reply_t_handler_json
899 (vl_api_create_vlan_subif_reply_t * mp)
901 vat_main_t *vam = &vat_main;
902 vat_json_node_t node;
904 vat_json_init_object (&node);
905 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
906 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
908 vat_json_print (vam->ofp, &node);
909 vat_json_free (&node);
911 vam->retval = ntohl (mp->retval);
912 vam->result_ready = 1;
915 static void vl_api_create_subif_reply_t_handler
916 (vl_api_create_subif_reply_t * mp)
918 vat_main_t *vam = &vat_main;
919 i32 retval = ntohl (mp->retval);
921 vam->retval = retval;
922 vam->regenerate_interface_table = 1;
923 vam->sw_if_index = ntohl (mp->sw_if_index);
924 vam->result_ready = 1;
927 static void vl_api_create_subif_reply_t_handler_json
928 (vl_api_create_subif_reply_t * mp)
930 vat_main_t *vam = &vat_main;
931 vat_json_node_t node;
933 vat_json_init_object (&node);
934 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
935 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
937 vat_json_print (vam->ofp, &node);
938 vat_json_free (&node);
940 vam->retval = ntohl (mp->retval);
941 vam->result_ready = 1;
944 static void vl_api_interface_name_renumber_reply_t_handler
945 (vl_api_interface_name_renumber_reply_t * mp)
947 vat_main_t *vam = &vat_main;
948 i32 retval = ntohl (mp->retval);
950 vam->retval = retval;
951 vam->regenerate_interface_table = 1;
952 vam->result_ready = 1;
955 static void vl_api_interface_name_renumber_reply_t_handler_json
956 (vl_api_interface_name_renumber_reply_t * mp)
958 vat_main_t *vam = &vat_main;
959 vat_json_node_t node;
961 vat_json_init_object (&node);
962 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
964 vat_json_print (vam->ofp, &node);
965 vat_json_free (&node);
967 vam->retval = ntohl (mp->retval);
968 vam->result_ready = 1;
972 * Special-case: build the interface table, maintain
973 * the next loopback sw_if_index vbl.
975 static void vl_api_sw_interface_details_t_handler
976 (vl_api_sw_interface_details_t * mp)
978 vat_main_t *vam = &vat_main;
979 u8 *s = format (0, "%s%c", mp->interface_name, 0);
981 hash_set_mem (vam->sw_if_index_by_interface_name, s,
982 ntohl (mp->sw_if_index));
984 /* In sub interface case, fill the sub interface table entry */
985 if (mp->sw_if_index != mp->sup_sw_if_index)
987 sw_interface_subif_t *sub = NULL;
989 vec_add2 (vam->sw_if_subif_table, sub, 1);
991 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
992 strncpy ((char *) sub->interface_name, (char *) s,
993 vec_len (sub->interface_name));
994 sub->sw_if_index = ntohl (mp->sw_if_index);
995 sub->sub_id = ntohl (mp->sub_id);
997 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
999 sub->sub_number_of_tags = mp->sub_number_of_tags;
1000 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1001 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1003 /* vlan tag rewrite */
1004 sub->vtr_op = ntohl (mp->vtr_op);
1005 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1006 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1007 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1011 static void vl_api_sw_interface_details_t_handler_json
1012 (vl_api_sw_interface_details_t * mp)
1014 vat_main_t *vam = &vat_main;
1015 vat_json_node_t *node = NULL;
1017 if (VAT_JSON_ARRAY != vam->json_tree.type)
1019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1020 vat_json_init_array (&vam->json_tree);
1022 node = vat_json_array_add (&vam->json_tree);
1024 vat_json_init_object (node);
1025 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1026 vat_json_object_add_uint (node, "sup_sw_if_index",
1027 ntohl (mp->sup_sw_if_index));
1028 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1029 sizeof (mp->l2_address));
1030 vat_json_object_add_string_copy (node, "interface_name",
1031 mp->interface_name);
1032 vat_json_object_add_string_copy (node, "interface_dev_type",
1033 mp->interface_dev_type);
1034 vat_json_object_add_uint (node, "flags", mp->flags);
1035 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1036 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1037 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1038 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1039 vat_json_object_add_uint (node, "sub_number_of_tags",
1040 mp->sub_number_of_tags);
1041 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1042 ntohs (mp->sub_outer_vlan_id));
1043 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1044 ntohs (mp->sub_inner_vlan_id));
1045 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1046 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1047 vat_json_object_add_uint (node, "vtr_push_dot1q",
1048 ntohl (mp->vtr_push_dot1q));
1049 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1050 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1051 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1053 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1055 format_ethernet_address,
1057 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1059 format_ethernet_address,
1061 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1062 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1066 #if VPP_API_TEST_BUILTIN == 0
1067 static void vl_api_sw_interface_event_t_handler
1068 (vl_api_sw_interface_event_t * mp)
1070 vat_main_t *vam = &vat_main;
1071 if (vam->interface_event_display)
1072 errmsg ("interface flags: sw_if_index %d %s %s",
1073 ntohl (mp->sw_if_index),
1074 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1075 "admin-up" : "admin-down",
1076 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1077 "link-up" : "link-down");
1081 __clib_unused static void
1082 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1084 /* JSON output not supported */
1088 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1090 vat_main_t *vam = &vat_main;
1091 i32 retval = ntohl (mp->retval);
1093 vam->retval = retval;
1094 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1095 vam->result_ready = 1;
1099 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1101 vat_main_t *vam = &vat_main;
1102 vat_json_node_t node;
1103 api_main_t *am = &api_main;
1107 vat_json_init_object (&node);
1108 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1109 vat_json_object_add_uint (&node, "reply_in_shmem",
1110 ntohl (mp->reply_in_shmem));
1111 /* Toss the shared-memory original... */
1112 pthread_mutex_lock (&am->vlib_rp->mutex);
1113 oldheap = svm_push_data_heap (am->vlib_rp);
1115 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1118 svm_pop_heap (oldheap);
1119 pthread_mutex_unlock (&am->vlib_rp->mutex);
1121 vat_json_print (vam->ofp, &node);
1122 vat_json_free (&node);
1124 vam->retval = ntohl (mp->retval);
1125 vam->result_ready = 1;
1129 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1131 vat_main_t *vam = &vat_main;
1132 i32 retval = ntohl (mp->retval);
1133 u32 length = vl_api_string_len (&mp->reply);
1135 vec_reset_length (vam->cmd_reply);
1137 vam->retval = retval;
1140 vec_validate (vam->cmd_reply, length);
1141 clib_memcpy ((char *) (vam->cmd_reply),
1142 vl_api_from_api_string (&mp->reply), length);
1143 vam->cmd_reply[length] = 0;
1145 vam->result_ready = 1;
1149 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1151 vat_main_t *vam = &vat_main;
1152 vat_json_node_t node;
1154 vec_reset_length (vam->cmd_reply);
1156 vat_json_init_object (&node);
1157 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1158 vat_json_object_add_string_copy (&node, "reply",
1159 vl_api_from_api_string (&mp->reply));
1161 vat_json_print (vam->ofp, &node);
1162 vat_json_free (&node);
1164 vam->retval = ntohl (mp->retval);
1165 vam->result_ready = 1;
1168 static void vl_api_classify_add_del_table_reply_t_handler
1169 (vl_api_classify_add_del_table_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 i32 retval = ntohl (mp->retval);
1173 if (vam->async_mode)
1175 vam->async_errors += (retval < 0);
1179 vam->retval = retval;
1181 ((mp->new_table_index != 0xFFFFFFFF) ||
1182 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1183 (mp->match_n_vectors != 0xFFFFFFFF)))
1185 * Note: this is just barely thread-safe, depends on
1186 * the main thread spinning waiting for an answer...
1188 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1189 ntohl (mp->new_table_index),
1190 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1191 vam->result_ready = 1;
1195 static void vl_api_classify_add_del_table_reply_t_handler_json
1196 (vl_api_classify_add_del_table_reply_t * mp)
1198 vat_main_t *vam = &vat_main;
1199 vat_json_node_t node;
1201 vat_json_init_object (&node);
1202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1203 vat_json_object_add_uint (&node, "new_table_index",
1204 ntohl (mp->new_table_index));
1205 vat_json_object_add_uint (&node, "skip_n_vectors",
1206 ntohl (mp->skip_n_vectors));
1207 vat_json_object_add_uint (&node, "match_n_vectors",
1208 ntohl (mp->match_n_vectors));
1210 vat_json_print (vam->ofp, &node);
1211 vat_json_free (&node);
1213 vam->retval = ntohl (mp->retval);
1214 vam->result_ready = 1;
1217 static void vl_api_get_node_index_reply_t_handler
1218 (vl_api_get_node_index_reply_t * mp)
1220 vat_main_t *vam = &vat_main;
1221 i32 retval = ntohl (mp->retval);
1222 if (vam->async_mode)
1224 vam->async_errors += (retval < 0);
1228 vam->retval = retval;
1230 errmsg ("node index %d", ntohl (mp->node_index));
1231 vam->result_ready = 1;
1235 static void vl_api_get_node_index_reply_t_handler_json
1236 (vl_api_get_node_index_reply_t * mp)
1238 vat_main_t *vam = &vat_main;
1239 vat_json_node_t node;
1241 vat_json_init_object (&node);
1242 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1243 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1245 vat_json_print (vam->ofp, &node);
1246 vat_json_free (&node);
1248 vam->retval = ntohl (mp->retval);
1249 vam->result_ready = 1;
1252 static void vl_api_get_next_index_reply_t_handler
1253 (vl_api_get_next_index_reply_t * mp)
1255 vat_main_t *vam = &vat_main;
1256 i32 retval = ntohl (mp->retval);
1257 if (vam->async_mode)
1259 vam->async_errors += (retval < 0);
1263 vam->retval = retval;
1265 errmsg ("next node index %d", ntohl (mp->next_index));
1266 vam->result_ready = 1;
1270 static void vl_api_get_next_index_reply_t_handler_json
1271 (vl_api_get_next_index_reply_t * mp)
1273 vat_main_t *vam = &vat_main;
1274 vat_json_node_t node;
1276 vat_json_init_object (&node);
1277 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1278 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1280 vat_json_print (vam->ofp, &node);
1281 vat_json_free (&node);
1283 vam->retval = ntohl (mp->retval);
1284 vam->result_ready = 1;
1287 static void vl_api_add_node_next_reply_t_handler
1288 (vl_api_add_node_next_reply_t * mp)
1290 vat_main_t *vam = &vat_main;
1291 i32 retval = ntohl (mp->retval);
1292 if (vam->async_mode)
1294 vam->async_errors += (retval < 0);
1298 vam->retval = retval;
1300 errmsg ("next index %d", ntohl (mp->next_index));
1301 vam->result_ready = 1;
1305 static void vl_api_add_node_next_reply_t_handler_json
1306 (vl_api_add_node_next_reply_t * mp)
1308 vat_main_t *vam = &vat_main;
1309 vat_json_node_t node;
1311 vat_json_init_object (&node);
1312 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1313 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1315 vat_json_print (vam->ofp, &node);
1316 vat_json_free (&node);
1318 vam->retval = ntohl (mp->retval);
1319 vam->result_ready = 1;
1322 static void vl_api_show_version_reply_t_handler
1323 (vl_api_show_version_reply_t * mp)
1325 vat_main_t *vam = &vat_main;
1326 i32 retval = ntohl (mp->retval);
1330 errmsg (" program: %s", mp->program);
1331 errmsg (" version: %s", mp->version);
1332 errmsg (" build date: %s", mp->build_date);
1333 errmsg ("build directory: %s", mp->build_directory);
1335 vam->retval = retval;
1336 vam->result_ready = 1;
1339 static void vl_api_show_version_reply_t_handler_json
1340 (vl_api_show_version_reply_t * mp)
1342 vat_main_t *vam = &vat_main;
1343 vat_json_node_t node;
1345 vat_json_init_object (&node);
1346 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1347 vat_json_object_add_string_copy (&node, "program", mp->program);
1348 vat_json_object_add_string_copy (&node, "version", mp->version);
1349 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1350 vat_json_object_add_string_copy (&node, "build_directory",
1351 mp->build_directory);
1353 vat_json_print (vam->ofp, &node);
1354 vat_json_free (&node);
1356 vam->retval = ntohl (mp->retval);
1357 vam->result_ready = 1;
1360 static void vl_api_show_threads_reply_t_handler
1361 (vl_api_show_threads_reply_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 i32 retval = ntohl (mp->retval);
1368 count = ntohl (mp->count);
1370 for (i = 0; i < count; i++)
1372 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1373 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1374 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1375 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1376 ntohl (mp->thread_data[i].cpu_socket));
1378 vam->retval = retval;
1379 vam->result_ready = 1;
1382 static void vl_api_show_threads_reply_t_handler_json
1383 (vl_api_show_threads_reply_t * mp)
1385 vat_main_t *vam = &vat_main;
1386 vat_json_node_t node;
1387 vl_api_thread_data_t *td;
1388 i32 retval = ntohl (mp->retval);
1392 count = ntohl (mp->count);
1394 vat_json_init_object (&node);
1395 vat_json_object_add_int (&node, "retval", retval);
1396 vat_json_object_add_uint (&node, "count", count);
1398 for (i = 0; i < count; i++)
1400 td = &mp->thread_data[i];
1401 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1402 vat_json_object_add_string_copy (&node, "name", td->name);
1403 vat_json_object_add_string_copy (&node, "type", td->type);
1404 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1405 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1406 vat_json_object_add_int (&node, "core", ntohl (td->id));
1407 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1410 vat_json_print (vam->ofp, &node);
1411 vat_json_free (&node);
1413 vam->retval = retval;
1414 vam->result_ready = 1;
1418 api_show_threads (vat_main_t * vam)
1420 vl_api_show_threads_t *mp;
1424 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1425 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1427 M (SHOW_THREADS, mp);
1435 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1437 u32 sw_if_index = ntohl (mp->sw_if_index);
1438 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1439 mp->mac_ip ? "mac/ip binding" : "address resolution",
1440 ntohl (mp->pid), format_ip4_address, mp->ip,
1441 format_vl_api_mac_address, &mp->mac, sw_if_index);
1445 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1447 /* JSON output not supported */
1451 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1453 u32 sw_if_index = ntohl (mp->sw_if_index);
1454 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1455 mp->mac_ip ? "mac/ip binding" : "address resolution",
1456 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1457 format_vl_api_mac_address, mp->mac, sw_if_index);
1461 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1463 /* JSON output not supported */
1467 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1469 u32 n_macs = ntohl (mp->n_macs);
1470 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1471 ntohl (mp->pid), mp->client_index, n_macs);
1473 for (i = 0; i < n_macs; i++)
1475 vl_api_mac_entry_t *mac = &mp->mac[i];
1476 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1477 i + 1, ntohl (mac->sw_if_index),
1478 format_ethernet_address, mac->mac_addr, mac->action);
1485 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1487 /* JSON output not supported */
1490 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1491 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1494 * Special-case: build the bridge domain table, maintain
1495 * the next bd id vbl.
1497 static void vl_api_bridge_domain_details_t_handler
1498 (vl_api_bridge_domain_details_t * mp)
1500 vat_main_t *vam = &vat_main;
1501 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1504 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1505 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1507 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1508 ntohl (mp->bd_id), mp->learn, mp->forward,
1509 mp->flood, ntohl (mp->bvi_sw_if_index),
1510 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1514 vl_api_bridge_domain_sw_if_t *sw_ifs;
1515 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1518 sw_ifs = mp->sw_if_details;
1519 for (i = 0; i < n_sw_ifs; i++)
1525 sw_if_index = ntohl (sw_ifs->sw_if_index);
1528 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1530 if ((u32) p->value[0] == sw_if_index)
1532 sw_if_name = (u8 *)(p->key);
1537 print (vam->ofp, "%7d %3d %s", sw_if_index,
1538 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1539 "sw_if_index not found!");
1546 static void vl_api_bridge_domain_details_t_handler_json
1547 (vl_api_bridge_domain_details_t * mp)
1549 vat_main_t *vam = &vat_main;
1550 vat_json_node_t *node, *array = NULL;
1551 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1553 if (VAT_JSON_ARRAY != vam->json_tree.type)
1555 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1556 vat_json_init_array (&vam->json_tree);
1558 node = vat_json_array_add (&vam->json_tree);
1560 vat_json_init_object (node);
1561 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1562 vat_json_object_add_uint (node, "flood", mp->flood);
1563 vat_json_object_add_uint (node, "forward", mp->forward);
1564 vat_json_object_add_uint (node, "learn", mp->learn);
1565 vat_json_object_add_uint (node, "bvi_sw_if_index",
1566 ntohl (mp->bvi_sw_if_index));
1567 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1568 array = vat_json_object_add (node, "sw_if");
1569 vat_json_init_array (array);
1575 vl_api_bridge_domain_sw_if_t *sw_ifs;
1578 sw_ifs = mp->sw_if_details;
1579 for (i = 0; i < n_sw_ifs; i++)
1581 node = vat_json_array_add (array);
1582 vat_json_init_object (node);
1583 vat_json_object_add_uint (node, "sw_if_index",
1584 ntohl (sw_ifs->sw_if_index));
1585 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1591 static void vl_api_control_ping_reply_t_handler
1592 (vl_api_control_ping_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1605 if (vam->socket_client_main)
1606 vam->socket_client_main->control_pings_outstanding--;
1609 static void vl_api_control_ping_reply_t_handler_json
1610 (vl_api_control_ping_reply_t * mp)
1612 vat_main_t *vam = &vat_main;
1613 i32 retval = ntohl (mp->retval);
1615 if (VAT_JSON_NONE != vam->json_tree.type)
1617 vat_json_print (vam->ofp, &vam->json_tree);
1618 vat_json_free (&vam->json_tree);
1619 vam->json_tree.type = VAT_JSON_NONE;
1624 vat_json_init_array (&vam->json_tree);
1625 vat_json_print (vam->ofp, &vam->json_tree);
1626 vam->json_tree.type = VAT_JSON_NONE;
1629 vam->retval = retval;
1630 vam->result_ready = 1;
1634 vl_api_bridge_domain_set_mac_age_reply_t_handler
1635 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1637 vat_main_t *vam = &vat_main;
1638 i32 retval = ntohl (mp->retval);
1639 if (vam->async_mode)
1641 vam->async_errors += (retval < 0);
1645 vam->retval = retval;
1646 vam->result_ready = 1;
1650 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1651 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1653 vat_main_t *vam = &vat_main;
1654 vat_json_node_t node;
1656 vat_json_init_object (&node);
1657 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1659 vat_json_print (vam->ofp, &node);
1660 vat_json_free (&node);
1662 vam->retval = ntohl (mp->retval);
1663 vam->result_ready = 1;
1667 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1669 vat_main_t *vam = &vat_main;
1670 i32 retval = ntohl (mp->retval);
1671 if (vam->async_mode)
1673 vam->async_errors += (retval < 0);
1677 vam->retval = retval;
1678 vam->result_ready = 1;
1682 static void vl_api_l2_flags_reply_t_handler_json
1683 (vl_api_l2_flags_reply_t * mp)
1685 vat_main_t *vam = &vat_main;
1686 vat_json_node_t node;
1688 vat_json_init_object (&node);
1689 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1690 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1691 ntohl (mp->resulting_feature_bitmap));
1693 vat_json_print (vam->ofp, &node);
1694 vat_json_free (&node);
1696 vam->retval = ntohl (mp->retval);
1697 vam->result_ready = 1;
1700 static void vl_api_bridge_flags_reply_t_handler
1701 (vl_api_bridge_flags_reply_t * mp)
1703 vat_main_t *vam = &vat_main;
1704 i32 retval = ntohl (mp->retval);
1705 if (vam->async_mode)
1707 vam->async_errors += (retval < 0);
1711 vam->retval = retval;
1712 vam->result_ready = 1;
1716 static void vl_api_bridge_flags_reply_t_handler_json
1717 (vl_api_bridge_flags_reply_t * mp)
1719 vat_main_t *vam = &vat_main;
1720 vat_json_node_t node;
1722 vat_json_init_object (&node);
1723 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1724 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1725 ntohl (mp->resulting_feature_bitmap));
1727 vat_json_print (vam->ofp, &node);
1728 vat_json_free (&node);
1730 vam->retval = ntohl (mp->retval);
1731 vam->result_ready = 1;
1735 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1737 vat_main_t *vam = &vat_main;
1738 i32 retval = ntohl (mp->retval);
1739 if (vam->async_mode)
1741 vam->async_errors += (retval < 0);
1745 vam->retval = retval;
1746 vam->sw_if_index = ntohl (mp->sw_if_index);
1747 vam->result_ready = 1;
1752 static void vl_api_tap_create_v2_reply_t_handler_json
1753 (vl_api_tap_create_v2_reply_t * mp)
1755 vat_main_t *vam = &vat_main;
1756 vat_json_node_t node;
1758 vat_json_init_object (&node);
1759 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1760 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1762 vat_json_print (vam->ofp, &node);
1763 vat_json_free (&node);
1765 vam->retval = ntohl (mp->retval);
1766 vam->result_ready = 1;
1771 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1773 vat_main_t *vam = &vat_main;
1774 i32 retval = ntohl (mp->retval);
1775 if (vam->async_mode)
1777 vam->async_errors += (retval < 0);
1781 vam->retval = retval;
1782 vam->result_ready = 1;
1786 static void vl_api_tap_delete_v2_reply_t_handler_json
1787 (vl_api_tap_delete_v2_reply_t * mp)
1789 vat_main_t *vam = &vat_main;
1790 vat_json_node_t node;
1792 vat_json_init_object (&node);
1793 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1795 vat_json_print (vam->ofp, &node);
1796 vat_json_free (&node);
1798 vam->retval = ntohl (mp->retval);
1799 vam->result_ready = 1;
1803 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1806 vat_main_t *vam = &vat_main;
1807 i32 retval = ntohl (mp->retval);
1808 if (vam->async_mode)
1810 vam->async_errors += (retval < 0);
1814 vam->retval = retval;
1815 vam->sw_if_index = ntohl (mp->sw_if_index);
1816 vam->result_ready = 1;
1820 static void vl_api_virtio_pci_create_reply_t_handler_json
1821 (vl_api_virtio_pci_create_reply_t * mp)
1823 vat_main_t *vam = &vat_main;
1824 vat_json_node_t node;
1826 vat_json_init_object (&node);
1827 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1828 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1830 vat_json_print (vam->ofp, &node);
1831 vat_json_free (&node);
1833 vam->retval = ntohl (mp->retval);
1834 vam->result_ready = 1;
1839 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1842 vat_main_t *vam = &vat_main;
1843 i32 retval = ntohl (mp->retval);
1844 if (vam->async_mode)
1846 vam->async_errors += (retval < 0);
1850 vam->retval = retval;
1851 vam->result_ready = 1;
1855 static void vl_api_virtio_pci_delete_reply_t_handler_json
1856 (vl_api_virtio_pci_delete_reply_t * mp)
1858 vat_main_t *vam = &vat_main;
1859 vat_json_node_t node;
1861 vat_json_init_object (&node);
1862 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1864 vat_json_print (vam->ofp, &node);
1865 vat_json_free (&node);
1867 vam->retval = ntohl (mp->retval);
1868 vam->result_ready = 1;
1872 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1874 vat_main_t *vam = &vat_main;
1875 i32 retval = ntohl (mp->retval);
1877 if (vam->async_mode)
1879 vam->async_errors += (retval < 0);
1883 vam->retval = retval;
1884 vam->sw_if_index = ntohl (mp->sw_if_index);
1885 vam->result_ready = 1;
1889 static void vl_api_bond_create_reply_t_handler_json
1890 (vl_api_bond_create_reply_t * mp)
1892 vat_main_t *vam = &vat_main;
1893 vat_json_node_t node;
1895 vat_json_init_object (&node);
1896 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1897 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1899 vat_json_print (vam->ofp, &node);
1900 vat_json_free (&node);
1902 vam->retval = ntohl (mp->retval);
1903 vam->result_ready = 1;
1907 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1909 vat_main_t *vam = &vat_main;
1910 i32 retval = ntohl (mp->retval);
1912 if (vam->async_mode)
1914 vam->async_errors += (retval < 0);
1918 vam->retval = retval;
1919 vam->result_ready = 1;
1923 static void vl_api_bond_delete_reply_t_handler_json
1924 (vl_api_bond_delete_reply_t * mp)
1926 vat_main_t *vam = &vat_main;
1927 vat_json_node_t node;
1929 vat_json_init_object (&node);
1930 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1932 vat_json_print (vam->ofp, &node);
1933 vat_json_free (&node);
1935 vam->retval = ntohl (mp->retval);
1936 vam->result_ready = 1;
1940 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1942 vat_main_t *vam = &vat_main;
1943 i32 retval = ntohl (mp->retval);
1945 if (vam->async_mode)
1947 vam->async_errors += (retval < 0);
1951 vam->retval = retval;
1952 vam->result_ready = 1;
1956 static void vl_api_bond_enslave_reply_t_handler_json
1957 (vl_api_bond_enslave_reply_t * mp)
1959 vat_main_t *vam = &vat_main;
1960 vat_json_node_t node;
1962 vat_json_init_object (&node);
1963 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1965 vat_json_print (vam->ofp, &node);
1966 vat_json_free (&node);
1968 vam->retval = ntohl (mp->retval);
1969 vam->result_ready = 1;
1973 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1976 vat_main_t *vam = &vat_main;
1977 i32 retval = ntohl (mp->retval);
1979 if (vam->async_mode)
1981 vam->async_errors += (retval < 0);
1985 vam->retval = retval;
1986 vam->result_ready = 1;
1990 static void vl_api_bond_detach_slave_reply_t_handler_json
1991 (vl_api_bond_detach_slave_reply_t * mp)
1993 vat_main_t *vam = &vat_main;
1994 vat_json_node_t node;
1996 vat_json_init_object (&node);
1997 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1999 vat_json_print (vam->ofp, &node);
2000 vat_json_free (&node);
2002 vam->retval = ntohl (mp->retval);
2003 vam->result_ready = 1;
2007 api_sw_interface_set_bond_weight (vat_main_t * vam)
2009 unformat_input_t *i = vam->input;
2010 vl_api_sw_interface_set_bond_weight_t *mp;
2011 u32 sw_if_index = ~0;
2013 u8 weight_enter = 0;
2016 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2022 else if (unformat (i, "weight %u", &weight))
2028 if (sw_if_index == ~0)
2030 errmsg ("missing interface name or sw_if_index");
2033 if (weight_enter == 0)
2035 errmsg ("missing valid weight");
2039 /* Construct the API message */
2040 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2041 mp->sw_if_index = ntohl (sw_if_index);
2042 mp->weight = ntohl (weight);
2049 static void vl_api_sw_interface_bond_details_t_handler
2050 (vl_api_sw_interface_bond_details_t * mp)
2052 vat_main_t *vam = &vat_main;
2055 "%-16s %-12d %-12U %-13U %-14u %-14u",
2056 mp->interface_name, ntohl (mp->sw_if_index),
2057 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2058 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2061 static void vl_api_sw_interface_bond_details_t_handler_json
2062 (vl_api_sw_interface_bond_details_t * mp)
2064 vat_main_t *vam = &vat_main;
2065 vat_json_node_t *node = NULL;
2067 if (VAT_JSON_ARRAY != vam->json_tree.type)
2069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2070 vat_json_init_array (&vam->json_tree);
2072 node = vat_json_array_add (&vam->json_tree);
2074 vat_json_init_object (node);
2075 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2076 vat_json_object_add_string_copy (node, "interface_name",
2077 mp->interface_name);
2078 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2079 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2080 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2081 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2085 api_sw_interface_bond_dump (vat_main_t * vam)
2087 vl_api_sw_interface_bond_dump_t *mp;
2088 vl_api_control_ping_t *mp_ping;
2092 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2093 "interface name", "sw_if_index", "mode", "load balance",
2094 "active slaves", "slaves");
2096 /* Get list of bond interfaces */
2097 M (SW_INTERFACE_BOND_DUMP, mp);
2100 /* Use a control ping for synchronization */
2101 MPING (CONTROL_PING, mp_ping);
2108 static void vl_api_sw_interface_slave_details_t_handler
2109 (vl_api_sw_interface_slave_details_t * mp)
2111 vat_main_t *vam = &vat_main;
2114 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2115 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2116 ntohl (mp->weight), mp->is_local_numa);
2119 static void vl_api_sw_interface_slave_details_t_handler_json
2120 (vl_api_sw_interface_slave_details_t * mp)
2122 vat_main_t *vam = &vat_main;
2123 vat_json_node_t *node = NULL;
2125 if (VAT_JSON_ARRAY != vam->json_tree.type)
2127 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2128 vat_json_init_array (&vam->json_tree);
2130 node = vat_json_array_add (&vam->json_tree);
2132 vat_json_init_object (node);
2133 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2134 vat_json_object_add_string_copy (node, "interface_name",
2135 mp->interface_name);
2136 vat_json_object_add_uint (node, "passive", mp->is_passive);
2137 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2138 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2139 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2143 api_sw_interface_slave_dump (vat_main_t * vam)
2145 unformat_input_t *i = vam->input;
2146 vl_api_sw_interface_slave_dump_t *mp;
2147 vl_api_control_ping_t *mp_ping;
2148 u32 sw_if_index = ~0;
2149 u8 sw_if_index_set = 0;
2152 /* Parse args required to build the message */
2153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2155 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2156 sw_if_index_set = 1;
2157 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2158 sw_if_index_set = 1;
2163 if (sw_if_index_set == 0)
2165 errmsg ("missing vpp interface name. ");
2170 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2171 "slave interface name", "sw_if_index", "passive", "long_timeout",
2172 "weight", "local numa");
2174 /* Get list of bond interfaces */
2175 M (SW_INTERFACE_SLAVE_DUMP, mp);
2176 mp->sw_if_index = ntohl (sw_if_index);
2179 /* Use a control ping for synchronization */
2180 MPING (CONTROL_PING, mp_ping);
2187 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2188 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2190 vat_main_t *vam = &vat_main;
2191 i32 retval = ntohl (mp->retval);
2192 if (vam->async_mode)
2194 vam->async_errors += (retval < 0);
2198 vam->retval = retval;
2199 vam->sw_if_index = ntohl (mp->sw_if_index);
2200 vam->result_ready = 1;
2202 vam->regenerate_interface_table = 1;
2205 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2206 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2208 vat_main_t *vam = &vat_main;
2209 vat_json_node_t node;
2211 vat_json_init_object (&node);
2212 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2213 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2214 ntohl (mp->sw_if_index));
2216 vat_json_print (vam->ofp, &node);
2217 vat_json_free (&node);
2219 vam->retval = ntohl (mp->retval);
2220 vam->result_ready = 1;
2223 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2224 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2226 vat_main_t *vam = &vat_main;
2227 i32 retval = ntohl (mp->retval);
2228 if (vam->async_mode)
2230 vam->async_errors += (retval < 0);
2234 vam->retval = retval;
2235 vam->sw_if_index = ntohl (mp->sw_if_index);
2236 vam->result_ready = 1;
2240 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2241 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vat_json_node_t node;
2246 vat_json_init_object (&node);
2247 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2248 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2250 vat_json_print (vam->ofp, &node);
2251 vat_json_free (&node);
2253 vam->retval = ntohl (mp->retval);
2254 vam->result_ready = 1;
2257 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2258 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2260 vat_main_t *vam = &vat_main;
2261 i32 retval = ntohl (mp->retval);
2262 if (vam->async_mode)
2264 vam->async_errors += (retval < 0);
2268 vam->retval = retval;
2269 vam->result_ready = 1;
2273 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2274 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2276 vat_main_t *vam = &vat_main;
2277 vat_json_node_t node;
2279 vat_json_init_object (&node);
2280 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2281 vat_json_object_add_uint (&node, "fwd_entry_index",
2282 clib_net_to_host_u32 (mp->fwd_entry_index));
2284 vat_json_print (vam->ofp, &node);
2285 vat_json_free (&node);
2287 vam->retval = ntohl (mp->retval);
2288 vam->result_ready = 1;
2292 format_lisp_transport_protocol (u8 * s, va_list * args)
2294 u32 proto = va_arg (*args, u32);
2299 return format (s, "udp");
2301 return format (s, "api");
2308 static void vl_api_one_get_transport_protocol_reply_t_handler
2309 (vl_api_one_get_transport_protocol_reply_t * mp)
2311 vat_main_t *vam = &vat_main;
2312 i32 retval = ntohl (mp->retval);
2313 if (vam->async_mode)
2315 vam->async_errors += (retval < 0);
2319 u32 proto = mp->protocol;
2320 print (vam->ofp, "Transport protocol: %U",
2321 format_lisp_transport_protocol, proto);
2322 vam->retval = retval;
2323 vam->result_ready = 1;
2327 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2328 (vl_api_one_get_transport_protocol_reply_t * mp)
2330 vat_main_t *vam = &vat_main;
2331 vat_json_node_t node;
2334 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2337 vat_json_init_object (&node);
2338 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2339 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2342 vat_json_print (vam->ofp, &node);
2343 vat_json_free (&node);
2345 vam->retval = ntohl (mp->retval);
2346 vam->result_ready = 1;
2349 static void vl_api_one_add_del_locator_set_reply_t_handler
2350 (vl_api_one_add_del_locator_set_reply_t * mp)
2352 vat_main_t *vam = &vat_main;
2353 i32 retval = ntohl (mp->retval);
2354 if (vam->async_mode)
2356 vam->async_errors += (retval < 0);
2360 vam->retval = retval;
2361 vam->result_ready = 1;
2365 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2366 (vl_api_one_add_del_locator_set_reply_t * mp)
2368 vat_main_t *vam = &vat_main;
2369 vat_json_node_t node;
2371 vat_json_init_object (&node);
2372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2373 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2375 vat_json_print (vam->ofp, &node);
2376 vat_json_free (&node);
2378 vam->retval = ntohl (mp->retval);
2379 vam->result_ready = 1;
2382 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2383 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2385 vat_main_t *vam = &vat_main;
2386 i32 retval = ntohl (mp->retval);
2387 if (vam->async_mode)
2389 vam->async_errors += (retval < 0);
2393 vam->retval = retval;
2394 vam->sw_if_index = ntohl (mp->sw_if_index);
2395 vam->result_ready = 1;
2397 vam->regenerate_interface_table = 1;
2400 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2401 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2403 vat_main_t *vam = &vat_main;
2404 vat_json_node_t node;
2406 vat_json_init_object (&node);
2407 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2408 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2410 vat_json_print (vam->ofp, &node);
2411 vat_json_free (&node);
2413 vam->retval = ntohl (mp->retval);
2414 vam->result_ready = 1;
2417 static void vl_api_vxlan_offload_rx_reply_t_handler
2418 (vl_api_vxlan_offload_rx_reply_t * mp)
2420 vat_main_t *vam = &vat_main;
2421 i32 retval = ntohl (mp->retval);
2422 if (vam->async_mode)
2424 vam->async_errors += (retval < 0);
2428 vam->retval = retval;
2429 vam->result_ready = 1;
2433 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2434 (vl_api_vxlan_offload_rx_reply_t * mp)
2436 vat_main_t *vam = &vat_main;
2437 vat_json_node_t node;
2439 vat_json_init_object (&node);
2440 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2442 vat_json_print (vam->ofp, &node);
2443 vat_json_free (&node);
2445 vam->retval = ntohl (mp->retval);
2446 vam->result_ready = 1;
2449 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2450 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2452 vat_main_t *vam = &vat_main;
2453 i32 retval = ntohl (mp->retval);
2454 if (vam->async_mode)
2456 vam->async_errors += (retval < 0);
2460 vam->retval = retval;
2461 vam->sw_if_index = ntohl (mp->sw_if_index);
2462 vam->result_ready = 1;
2466 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2467 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2469 vat_main_t *vam = &vat_main;
2470 vat_json_node_t node;
2472 vat_json_init_object (&node);
2473 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2474 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2476 vat_json_print (vam->ofp, &node);
2477 vat_json_free (&node);
2479 vam->retval = ntohl (mp->retval);
2480 vam->result_ready = 1;
2483 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2484 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2486 vat_main_t *vam = &vat_main;
2487 i32 retval = ntohl (mp->retval);
2488 if (vam->async_mode)
2490 vam->async_errors += (retval < 0);
2494 vam->retval = retval;
2495 vam->sw_if_index = ntohl (mp->sw_if_index);
2496 vam->result_ready = 1;
2498 vam->regenerate_interface_table = 1;
2501 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2502 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2504 vat_main_t *vam = &vat_main;
2505 vat_json_node_t node;
2507 vat_json_init_object (&node);
2508 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2509 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2511 vat_json_print (vam->ofp, &node);
2512 vat_json_free (&node);
2514 vam->retval = ntohl (mp->retval);
2515 vam->result_ready = 1;
2518 static void vl_api_gre_tunnel_add_del_reply_t_handler
2519 (vl_api_gre_tunnel_add_del_reply_t * mp)
2521 vat_main_t *vam = &vat_main;
2522 i32 retval = ntohl (mp->retval);
2523 if (vam->async_mode)
2525 vam->async_errors += (retval < 0);
2529 vam->retval = retval;
2530 vam->sw_if_index = ntohl (mp->sw_if_index);
2531 vam->result_ready = 1;
2535 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2536 (vl_api_gre_tunnel_add_del_reply_t * mp)
2538 vat_main_t *vam = &vat_main;
2539 vat_json_node_t node;
2541 vat_json_init_object (&node);
2542 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2543 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2545 vat_json_print (vam->ofp, &node);
2546 vat_json_free (&node);
2548 vam->retval = ntohl (mp->retval);
2549 vam->result_ready = 1;
2552 static void vl_api_create_vhost_user_if_reply_t_handler
2553 (vl_api_create_vhost_user_if_reply_t * mp)
2555 vat_main_t *vam = &vat_main;
2556 i32 retval = ntohl (mp->retval);
2557 if (vam->async_mode)
2559 vam->async_errors += (retval < 0);
2563 vam->retval = retval;
2564 vam->sw_if_index = ntohl (mp->sw_if_index);
2565 vam->result_ready = 1;
2567 vam->regenerate_interface_table = 1;
2570 static void vl_api_create_vhost_user_if_reply_t_handler_json
2571 (vl_api_create_vhost_user_if_reply_t * mp)
2573 vat_main_t *vam = &vat_main;
2574 vat_json_node_t node;
2576 vat_json_init_object (&node);
2577 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2578 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2580 vat_json_print (vam->ofp, &node);
2581 vat_json_free (&node);
2583 vam->retval = ntohl (mp->retval);
2584 vam->result_ready = 1;
2587 static void vl_api_ip_address_details_t_handler
2588 (vl_api_ip_address_details_t * mp)
2590 vat_main_t *vam = &vat_main;
2591 static ip_address_details_t empty_ip_address_details = { {0} };
2592 ip_address_details_t *address = NULL;
2593 ip_details_t *current_ip_details = NULL;
2594 ip_details_t *details = NULL;
2596 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2598 if (!details || vam->current_sw_if_index >= vec_len (details)
2599 || !details[vam->current_sw_if_index].present)
2601 errmsg ("ip address details arrived but not stored");
2602 errmsg ("ip_dump should be called first");
2606 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2608 #define addresses (current_ip_details->addr)
2610 vec_validate_init_empty (addresses, vec_len (addresses),
2611 empty_ip_address_details);
2613 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2615 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2616 address->prefix_length = mp->prefix.len;
2620 static void vl_api_ip_address_details_t_handler_json
2621 (vl_api_ip_address_details_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = NULL;
2626 if (VAT_JSON_ARRAY != vam->json_tree.type)
2628 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2629 vat_json_init_array (&vam->json_tree);
2631 node = vat_json_array_add (&vam->json_tree);
2633 vat_json_init_object (node);
2634 vat_json_object_add_prefix (node, &mp->prefix);
2638 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2640 vat_main_t *vam = &vat_main;
2641 static ip_details_t empty_ip_details = { 0 };
2642 ip_details_t *ip = NULL;
2643 u32 sw_if_index = ~0;
2645 sw_if_index = ntohl (mp->sw_if_index);
2647 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2648 sw_if_index, empty_ip_details);
2650 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2657 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2659 vat_main_t *vam = &vat_main;
2661 if (VAT_JSON_ARRAY != vam->json_tree.type)
2663 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2664 vat_json_init_array (&vam->json_tree);
2666 vat_json_array_add_uint (&vam->json_tree,
2667 clib_net_to_host_u32 (mp->sw_if_index));
2670 static void vl_api_get_first_msg_id_reply_t_handler
2671 (vl_api_get_first_msg_id_reply_t * mp)
2673 vat_main_t *vam = &vat_main;
2674 i32 retval = ntohl (mp->retval);
2676 if (vam->async_mode)
2678 vam->async_errors += (retval < 0);
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2691 static void vl_api_get_first_msg_id_reply_t_handler_json
2692 (vl_api_get_first_msg_id_reply_t * mp)
2694 vat_main_t *vam = &vat_main;
2695 vat_json_node_t node;
2697 vat_json_init_object (&node);
2698 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2699 vat_json_object_add_uint (&node, "first_msg_id",
2700 (uint) ntohs (mp->first_msg_id));
2702 vat_json_print (vam->ofp, &node);
2703 vat_json_free (&node);
2705 vam->retval = ntohl (mp->retval);
2706 vam->result_ready = 1;
2709 static void vl_api_get_node_graph_reply_t_handler
2710 (vl_api_get_node_graph_reply_t * mp)
2712 vat_main_t *vam = &vat_main;
2713 api_main_t *am = &api_main;
2714 i32 retval = ntohl (mp->retval);
2715 u8 *pvt_copy, *reply;
2720 if (vam->async_mode)
2722 vam->async_errors += (retval < 0);
2726 vam->retval = retval;
2727 vam->result_ready = 1;
2730 /* "Should never happen..." */
2734 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2735 pvt_copy = vec_dup (reply);
2737 /* Toss the shared-memory original... */
2738 pthread_mutex_lock (&am->vlib_rp->mutex);
2739 oldheap = svm_push_data_heap (am->vlib_rp);
2743 svm_pop_heap (oldheap);
2744 pthread_mutex_unlock (&am->vlib_rp->mutex);
2746 if (vam->graph_nodes)
2748 hash_free (vam->graph_node_index_by_name);
2750 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2752 node = vam->graph_nodes[0][i];
2753 vec_free (node->name);
2754 vec_free (node->next_nodes);
2757 vec_free (vam->graph_nodes[0]);
2758 vec_free (vam->graph_nodes);
2761 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2762 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2763 vec_free (pvt_copy);
2765 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2767 node = vam->graph_nodes[0][i];
2768 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2772 static void vl_api_get_node_graph_reply_t_handler_json
2773 (vl_api_get_node_graph_reply_t * mp)
2775 vat_main_t *vam = &vat_main;
2776 api_main_t *am = &api_main;
2778 vat_json_node_t node;
2781 /* $$$$ make this real? */
2782 vat_json_init_object (&node);
2783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2784 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2786 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2788 /* Toss the shared-memory original... */
2789 pthread_mutex_lock (&am->vlib_rp->mutex);
2790 oldheap = svm_push_data_heap (am->vlib_rp);
2794 svm_pop_heap (oldheap);
2795 pthread_mutex_unlock (&am->vlib_rp->mutex);
2797 vat_json_print (vam->ofp, &node);
2798 vat_json_free (&node);
2800 vam->retval = ntohl (mp->retval);
2801 vam->result_ready = 1;
2805 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2807 vat_main_t *vam = &vat_main;
2812 s = format (s, "%=16d%=16d%=16d",
2813 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2817 s = format (s, "%=16U%=16d%=16d",
2818 mp->is_ipv6 ? format_ip6_address :
2820 mp->ip_address, mp->priority, mp->weight);
2823 print (vam->ofp, "%v", s);
2828 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2830 vat_main_t *vam = &vat_main;
2831 vat_json_node_t *node = NULL;
2832 struct in6_addr ip6;
2835 if (VAT_JSON_ARRAY != vam->json_tree.type)
2837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2838 vat_json_init_array (&vam->json_tree);
2840 node = vat_json_array_add (&vam->json_tree);
2841 vat_json_init_object (node);
2843 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2844 vat_json_object_add_uint (node, "priority", mp->priority);
2845 vat_json_object_add_uint (node, "weight", mp->weight);
2848 vat_json_object_add_uint (node, "sw_if_index",
2849 clib_net_to_host_u32 (mp->sw_if_index));
2854 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2855 vat_json_object_add_ip6 (node, "address", ip6);
2859 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2860 vat_json_object_add_ip4 (node, "address", ip4);
2866 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2869 vat_main_t *vam = &vat_main;
2872 ls_name = format (0, "%s", mp->ls_name);
2874 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2880 vl_api_one_locator_set_details_t_handler_json
2881 (vl_api_one_locator_set_details_t * mp)
2883 vat_main_t *vam = &vat_main;
2884 vat_json_node_t *node = 0;
2887 ls_name = format (0, "%s", mp->ls_name);
2888 vec_add1 (ls_name, 0);
2890 if (VAT_JSON_ARRAY != vam->json_tree.type)
2892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2893 vat_json_init_array (&vam->json_tree);
2895 node = vat_json_array_add (&vam->json_tree);
2897 vat_json_init_object (node);
2898 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2899 vat_json_object_add_uint (node, "ls_index",
2900 clib_net_to_host_u32 (mp->ls_index));
2908 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2911 unformat_nsh_address (unformat_input_t * input, va_list * args)
2913 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2914 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2918 format_nsh_address_vat (u8 * s, va_list * args)
2920 nsh_t *a = va_arg (*args, nsh_t *);
2921 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2925 format_lisp_flat_eid (u8 * s, va_list * args)
2927 u32 type = va_arg (*args, u32);
2928 u8 *eid = va_arg (*args, u8 *);
2929 u32 eid_len = va_arg (*args, u32);
2934 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2936 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2938 return format (s, "%U", format_ethernet_address, eid);
2940 return format (s, "%U", format_nsh_address_vat, eid);
2946 format_lisp_eid_vat (u8 * s, va_list * args)
2948 u32 type = va_arg (*args, u32);
2949 u8 *eid = va_arg (*args, u8 *);
2950 u32 eid_len = va_arg (*args, u32);
2951 u8 *seid = va_arg (*args, u8 *);
2952 u32 seid_len = va_arg (*args, u32);
2953 u32 is_src_dst = va_arg (*args, u32);
2956 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2958 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2964 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2966 vat_main_t *vam = &vat_main;
2967 u8 *s = 0, *eid = 0;
2969 if (~0 == mp->locator_set_index)
2970 s = format (0, "action: %d", mp->action);
2972 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2974 eid = format (0, "%U", format_lisp_eid_vat,
2978 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2981 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2982 clib_net_to_host_u32 (mp->vni),
2984 mp->is_local ? "local" : "remote",
2985 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2986 clib_net_to_host_u16 (mp->key_id), mp->key);
2993 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2996 vat_main_t *vam = &vat_main;
2997 vat_json_node_t *node = 0;
3000 if (VAT_JSON_ARRAY != vam->json_tree.type)
3002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3003 vat_json_init_array (&vam->json_tree);
3005 node = vat_json_array_add (&vam->json_tree);
3007 vat_json_init_object (node);
3008 if (~0 == mp->locator_set_index)
3009 vat_json_object_add_uint (node, "action", mp->action);
3011 vat_json_object_add_uint (node, "locator_set_index",
3012 clib_net_to_host_u32 (mp->locator_set_index));
3014 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3015 if (mp->eid_type == 3)
3017 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3018 vat_json_init_object (nsh_json);
3019 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3020 vat_json_object_add_uint (nsh_json, "spi",
3021 clib_net_to_host_u32 (nsh->spi));
3022 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3026 eid = format (0, "%U", format_lisp_eid_vat,
3030 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3032 vat_json_object_add_string_copy (node, "eid", eid);
3035 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3036 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3037 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3041 vat_json_object_add_uint (node, "key_id",
3042 clib_net_to_host_u16 (mp->key_id));
3043 vat_json_object_add_string_copy (node, "key", mp->key);
3048 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3050 vat_main_t *vam = &vat_main;
3051 u8 *seid = 0, *deid = 0;
3052 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3054 deid = format (0, "%U", format_lisp_eid_vat,
3055 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3057 seid = format (0, "%U", format_lisp_eid_vat,
3058 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3064 format_ip_address_fcn = format_ip4_address;
3066 format_ip_address_fcn = format_ip6_address;
3069 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3070 clib_net_to_host_u32 (mp->vni),
3072 format_ip_address_fcn, mp->lloc,
3073 format_ip_address_fcn, mp->rloc,
3074 clib_net_to_host_u32 (mp->pkt_count),
3075 clib_net_to_host_u32 (mp->bytes));
3082 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3084 struct in6_addr ip6;
3086 vat_main_t *vam = &vat_main;
3087 vat_json_node_t *node = 0;
3088 u8 *deid = 0, *seid = 0;
3090 if (VAT_JSON_ARRAY != vam->json_tree.type)
3092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3093 vat_json_init_array (&vam->json_tree);
3095 node = vat_json_array_add (&vam->json_tree);
3097 vat_json_init_object (node);
3098 deid = format (0, "%U", format_lisp_eid_vat,
3099 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3101 seid = format (0, "%U", format_lisp_eid_vat,
3102 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3107 vat_json_object_add_string_copy (node, "seid", seid);
3108 vat_json_object_add_string_copy (node, "deid", deid);
3109 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3113 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3114 vat_json_object_add_ip4 (node, "lloc", ip4);
3115 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3116 vat_json_object_add_ip4 (node, "rloc", ip4);
3120 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3121 vat_json_object_add_ip6 (node, "lloc", ip6);
3122 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3123 vat_json_object_add_ip6 (node, "rloc", ip6);
3125 vat_json_object_add_uint (node, "pkt_count",
3126 clib_net_to_host_u32 (mp->pkt_count));
3127 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3134 vl_api_one_eid_table_map_details_t_handler
3135 (vl_api_one_eid_table_map_details_t * mp)
3137 vat_main_t *vam = &vat_main;
3139 u8 *line = format (0, "%=10d%=10d",
3140 clib_net_to_host_u32 (mp->vni),
3141 clib_net_to_host_u32 (mp->dp_table));
3142 print (vam->ofp, "%v", line);
3147 vl_api_one_eid_table_map_details_t_handler_json
3148 (vl_api_one_eid_table_map_details_t * mp)
3150 vat_main_t *vam = &vat_main;
3151 vat_json_node_t *node = NULL;
3153 if (VAT_JSON_ARRAY != vam->json_tree.type)
3155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3156 vat_json_init_array (&vam->json_tree);
3158 node = vat_json_array_add (&vam->json_tree);
3159 vat_json_init_object (node);
3160 vat_json_object_add_uint (node, "dp_table",
3161 clib_net_to_host_u32 (mp->dp_table));
3162 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3166 vl_api_one_eid_table_vni_details_t_handler
3167 (vl_api_one_eid_table_vni_details_t * mp)
3169 vat_main_t *vam = &vat_main;
3171 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3172 print (vam->ofp, "%v", line);
3177 vl_api_one_eid_table_vni_details_t_handler_json
3178 (vl_api_one_eid_table_vni_details_t * mp)
3180 vat_main_t *vam = &vat_main;
3181 vat_json_node_t *node = NULL;
3183 if (VAT_JSON_ARRAY != vam->json_tree.type)
3185 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3186 vat_json_init_array (&vam->json_tree);
3188 node = vat_json_array_add (&vam->json_tree);
3189 vat_json_init_object (node);
3190 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3194 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3195 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3197 vat_main_t *vam = &vat_main;
3198 int retval = clib_net_to_host_u32 (mp->retval);
3200 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3201 print (vam->ofp, "fallback threshold value: %d", mp->value);
3203 vam->retval = retval;
3204 vam->result_ready = 1;
3208 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3209 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3211 vat_main_t *vam = &vat_main;
3212 vat_json_node_t _node, *node = &_node;
3213 int retval = clib_net_to_host_u32 (mp->retval);
3215 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3216 vat_json_init_object (node);
3217 vat_json_object_add_uint (node, "value", mp->value);
3219 vat_json_print (vam->ofp, node);
3220 vat_json_free (node);
3222 vam->retval = retval;
3223 vam->result_ready = 1;
3227 vl_api_show_one_map_register_state_reply_t_handler
3228 (vl_api_show_one_map_register_state_reply_t * mp)
3230 vat_main_t *vam = &vat_main;
3231 int retval = clib_net_to_host_u32 (mp->retval);
3233 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3235 vam->retval = retval;
3236 vam->result_ready = 1;
3240 vl_api_show_one_map_register_state_reply_t_handler_json
3241 (vl_api_show_one_map_register_state_reply_t * mp)
3243 vat_main_t *vam = &vat_main;
3244 vat_json_node_t _node, *node = &_node;
3245 int retval = clib_net_to_host_u32 (mp->retval);
3247 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3249 vat_json_init_object (node);
3250 vat_json_object_add_string_copy (node, "state", s);
3252 vat_json_print (vam->ofp, node);
3253 vat_json_free (node);
3255 vam->retval = retval;
3256 vam->result_ready = 1;
3261 vl_api_show_one_rloc_probe_state_reply_t_handler
3262 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3264 vat_main_t *vam = &vat_main;
3265 int retval = clib_net_to_host_u32 (mp->retval);
3270 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3272 vam->retval = retval;
3273 vam->result_ready = 1;
3277 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3278 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3280 vat_main_t *vam = &vat_main;
3281 vat_json_node_t _node, *node = &_node;
3282 int retval = clib_net_to_host_u32 (mp->retval);
3284 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3285 vat_json_init_object (node);
3286 vat_json_object_add_string_copy (node, "state", s);
3288 vat_json_print (vam->ofp, node);
3289 vat_json_free (node);
3291 vam->retval = retval;
3292 vam->result_ready = 1;
3297 vl_api_show_one_stats_enable_disable_reply_t_handler
3298 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3300 vat_main_t *vam = &vat_main;
3301 int retval = clib_net_to_host_u32 (mp->retval);
3306 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3308 vam->retval = retval;
3309 vam->result_ready = 1;
3313 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3314 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3316 vat_main_t *vam = &vat_main;
3317 vat_json_node_t _node, *node = &_node;
3318 int retval = clib_net_to_host_u32 (mp->retval);
3320 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3321 vat_json_init_object (node);
3322 vat_json_object_add_string_copy (node, "state", s);
3324 vat_json_print (vam->ofp, node);
3325 vat_json_free (node);
3327 vam->retval = retval;
3328 vam->result_ready = 1;
3333 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3335 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3336 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3337 e->vni = clib_net_to_host_u32 (e->vni);
3341 gpe_fwd_entries_get_reply_t_net_to_host
3342 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3346 mp->count = clib_net_to_host_u32 (mp->count);
3347 for (i = 0; i < mp->count; i++)
3349 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3354 format_gpe_encap_mode (u8 * s, va_list * args)
3356 u32 mode = va_arg (*args, u32);
3361 return format (s, "lisp");
3363 return format (s, "vxlan");
3369 vl_api_gpe_get_encap_mode_reply_t_handler
3370 (vl_api_gpe_get_encap_mode_reply_t * mp)
3372 vat_main_t *vam = &vat_main;
3374 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3375 vam->retval = ntohl (mp->retval);
3376 vam->result_ready = 1;
3380 vl_api_gpe_get_encap_mode_reply_t_handler_json
3381 (vl_api_gpe_get_encap_mode_reply_t * mp)
3383 vat_main_t *vam = &vat_main;
3384 vat_json_node_t node;
3386 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3387 vec_add1 (encap_mode, 0);
3389 vat_json_init_object (&node);
3390 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3392 vec_free (encap_mode);
3393 vat_json_print (vam->ofp, &node);
3394 vat_json_free (&node);
3396 vam->retval = ntohl (mp->retval);
3397 vam->result_ready = 1;
3401 vl_api_gpe_fwd_entry_path_details_t_handler
3402 (vl_api_gpe_fwd_entry_path_details_t * mp)
3404 vat_main_t *vam = &vat_main;
3405 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3407 if (mp->lcl_loc.is_ip4)
3408 format_ip_address_fcn = format_ip4_address;
3410 format_ip_address_fcn = format_ip6_address;
3412 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3413 format_ip_address_fcn, &mp->lcl_loc,
3414 format_ip_address_fcn, &mp->rmt_loc);
3418 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3420 struct in6_addr ip6;
3425 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3426 vat_json_object_add_ip4 (n, "address", ip4);
3430 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3431 vat_json_object_add_ip6 (n, "address", ip6);
3433 vat_json_object_add_uint (n, "weight", loc->weight);
3437 vl_api_gpe_fwd_entry_path_details_t_handler_json
3438 (vl_api_gpe_fwd_entry_path_details_t * mp)
3440 vat_main_t *vam = &vat_main;
3441 vat_json_node_t *node = NULL;
3442 vat_json_node_t *loc_node;
3444 if (VAT_JSON_ARRAY != vam->json_tree.type)
3446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3447 vat_json_init_array (&vam->json_tree);
3449 node = vat_json_array_add (&vam->json_tree);
3450 vat_json_init_object (node);
3452 loc_node = vat_json_object_add (node, "local_locator");
3453 vat_json_init_object (loc_node);
3454 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3456 loc_node = vat_json_object_add (node, "remote_locator");
3457 vat_json_init_object (loc_node);
3458 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3462 vl_api_gpe_fwd_entries_get_reply_t_handler
3463 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3465 vat_main_t *vam = &vat_main;
3467 int retval = clib_net_to_host_u32 (mp->retval);
3468 vl_api_gpe_fwd_entry_t *e;
3473 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3475 for (i = 0; i < mp->count; i++)
3477 e = &mp->entries[i];
3478 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3479 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3480 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3484 vam->retval = retval;
3485 vam->result_ready = 1;
3489 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3490 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3493 vat_main_t *vam = &vat_main;
3494 vat_json_node_t *e = 0, root;
3496 int retval = clib_net_to_host_u32 (mp->retval);
3497 vl_api_gpe_fwd_entry_t *fwd;
3502 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3503 vat_json_init_array (&root);
3505 for (i = 0; i < mp->count; i++)
3507 e = vat_json_array_add (&root);
3508 fwd = &mp->entries[i];
3510 vat_json_init_object (e);
3511 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3512 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3513 vat_json_object_add_int (e, "vni", fwd->vni);
3514 vat_json_object_add_int (e, "action", fwd->action);
3516 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3517 fwd->leid_prefix_len);
3519 vat_json_object_add_string_copy (e, "leid", s);
3522 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3523 fwd->reid_prefix_len);
3525 vat_json_object_add_string_copy (e, "reid", s);
3529 vat_json_print (vam->ofp, &root);
3530 vat_json_free (&root);
3533 vam->retval = retval;
3534 vam->result_ready = 1;
3538 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3539 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3541 vat_main_t *vam = &vat_main;
3543 int retval = clib_net_to_host_u32 (mp->retval);
3544 vl_api_gpe_native_fwd_rpath_t *r;
3549 n = clib_net_to_host_u32 (mp->count);
3551 for (i = 0; i < n; i++)
3553 r = &mp->entries[i];
3554 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3555 clib_net_to_host_u32 (r->fib_index),
3556 clib_net_to_host_u32 (r->nh_sw_if_index),
3557 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3561 vam->retval = retval;
3562 vam->result_ready = 1;
3566 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3567 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3569 vat_main_t *vam = &vat_main;
3570 vat_json_node_t root, *e;
3572 int retval = clib_net_to_host_u32 (mp->retval);
3573 vl_api_gpe_native_fwd_rpath_t *r;
3579 n = clib_net_to_host_u32 (mp->count);
3580 vat_json_init_array (&root);
3582 for (i = 0; i < n; i++)
3584 e = vat_json_array_add (&root);
3585 vat_json_init_object (e);
3586 r = &mp->entries[i];
3588 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3591 vat_json_object_add_string_copy (e, "ip4", s);
3594 vat_json_object_add_uint (e, "fib_index",
3595 clib_net_to_host_u32 (r->fib_index));
3596 vat_json_object_add_uint (e, "nh_sw_if_index",
3597 clib_net_to_host_u32 (r->nh_sw_if_index));
3600 vat_json_print (vam->ofp, &root);
3601 vat_json_free (&root);
3604 vam->retval = retval;
3605 vam->result_ready = 1;
3609 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3610 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3612 vat_main_t *vam = &vat_main;
3614 int retval = clib_net_to_host_u32 (mp->retval);
3619 n = clib_net_to_host_u32 (mp->count);
3621 for (i = 0; i < n; i++)
3622 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3625 vam->retval = retval;
3626 vam->result_ready = 1;
3630 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3631 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3633 vat_main_t *vam = &vat_main;
3634 vat_json_node_t root;
3636 int retval = clib_net_to_host_u32 (mp->retval);
3641 n = clib_net_to_host_u32 (mp->count);
3642 vat_json_init_array (&root);
3644 for (i = 0; i < n; i++)
3645 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3647 vat_json_print (vam->ofp, &root);
3648 vat_json_free (&root);
3651 vam->retval = retval;
3652 vam->result_ready = 1;
3656 vl_api_one_ndp_entries_get_reply_t_handler
3657 (vl_api_one_ndp_entries_get_reply_t * mp)
3659 vat_main_t *vam = &vat_main;
3661 int retval = clib_net_to_host_u32 (mp->retval);
3666 n = clib_net_to_host_u32 (mp->count);
3668 for (i = 0; i < n; i++)
3669 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3670 format_ethernet_address, mp->entries[i].mac);
3673 vam->retval = retval;
3674 vam->result_ready = 1;
3678 vl_api_one_ndp_entries_get_reply_t_handler_json
3679 (vl_api_one_ndp_entries_get_reply_t * mp)
3682 vat_main_t *vam = &vat_main;
3683 vat_json_node_t *e = 0, root;
3685 int retval = clib_net_to_host_u32 (mp->retval);
3686 vl_api_one_ndp_entry_t *arp_entry;
3691 n = clib_net_to_host_u32 (mp->count);
3692 vat_json_init_array (&root);
3694 for (i = 0; i < n; i++)
3696 e = vat_json_array_add (&root);
3697 arp_entry = &mp->entries[i];
3699 vat_json_init_object (e);
3700 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3703 vat_json_object_add_string_copy (e, "mac", s);
3706 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3708 vat_json_object_add_string_copy (e, "ip6", s);
3712 vat_json_print (vam->ofp, &root);
3713 vat_json_free (&root);
3716 vam->retval = retval;
3717 vam->result_ready = 1;
3721 vl_api_one_l2_arp_entries_get_reply_t_handler
3722 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3724 vat_main_t *vam = &vat_main;
3726 int retval = clib_net_to_host_u32 (mp->retval);
3731 n = clib_net_to_host_u32 (mp->count);
3733 for (i = 0; i < n; i++)
3734 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3735 format_ethernet_address, mp->entries[i].mac);
3738 vam->retval = retval;
3739 vam->result_ready = 1;
3743 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3744 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3747 vat_main_t *vam = &vat_main;
3748 vat_json_node_t *e = 0, root;
3750 int retval = clib_net_to_host_u32 (mp->retval);
3751 vl_api_one_l2_arp_entry_t *arp_entry;
3756 n = clib_net_to_host_u32 (mp->count);
3757 vat_json_init_array (&root);
3759 for (i = 0; i < n; i++)
3761 e = vat_json_array_add (&root);
3762 arp_entry = &mp->entries[i];
3764 vat_json_init_object (e);
3765 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3768 vat_json_object_add_string_copy (e, "mac", s);
3771 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3773 vat_json_object_add_string_copy (e, "ip4", s);
3777 vat_json_print (vam->ofp, &root);
3778 vat_json_free (&root);
3781 vam->retval = retval;
3782 vam->result_ready = 1;
3786 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3788 vat_main_t *vam = &vat_main;
3790 int retval = clib_net_to_host_u32 (mp->retval);
3795 n = clib_net_to_host_u32 (mp->count);
3797 for (i = 0; i < n; i++)
3799 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3803 vam->retval = retval;
3804 vam->result_ready = 1;
3808 vl_api_one_ndp_bd_get_reply_t_handler_json
3809 (vl_api_one_ndp_bd_get_reply_t * mp)
3811 vat_main_t *vam = &vat_main;
3812 vat_json_node_t root;
3814 int retval = clib_net_to_host_u32 (mp->retval);
3819 n = clib_net_to_host_u32 (mp->count);
3820 vat_json_init_array (&root);
3822 for (i = 0; i < n; i++)
3824 vat_json_array_add_uint (&root,
3825 clib_net_to_host_u32 (mp->bridge_domains[i]));
3828 vat_json_print (vam->ofp, &root);
3829 vat_json_free (&root);
3832 vam->retval = retval;
3833 vam->result_ready = 1;
3837 vl_api_one_l2_arp_bd_get_reply_t_handler
3838 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3840 vat_main_t *vam = &vat_main;
3842 int retval = clib_net_to_host_u32 (mp->retval);
3847 n = clib_net_to_host_u32 (mp->count);
3849 for (i = 0; i < n; i++)
3851 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3855 vam->retval = retval;
3856 vam->result_ready = 1;
3860 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3861 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3863 vat_main_t *vam = &vat_main;
3864 vat_json_node_t root;
3866 int retval = clib_net_to_host_u32 (mp->retval);
3871 n = clib_net_to_host_u32 (mp->count);
3872 vat_json_init_array (&root);
3874 for (i = 0; i < n; i++)
3876 vat_json_array_add_uint (&root,
3877 clib_net_to_host_u32 (mp->bridge_domains[i]));
3880 vat_json_print (vam->ofp, &root);
3881 vat_json_free (&root);
3884 vam->retval = retval;
3885 vam->result_ready = 1;
3889 vl_api_one_adjacencies_get_reply_t_handler
3890 (vl_api_one_adjacencies_get_reply_t * mp)
3892 vat_main_t *vam = &vat_main;
3894 int retval = clib_net_to_host_u32 (mp->retval);
3895 vl_api_one_adjacency_t *a;
3900 n = clib_net_to_host_u32 (mp->count);
3902 for (i = 0; i < n; i++)
3904 a = &mp->adjacencies[i];
3905 print (vam->ofp, "%U %40U",
3906 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3907 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3911 vam->retval = retval;
3912 vam->result_ready = 1;
3916 vl_api_one_adjacencies_get_reply_t_handler_json
3917 (vl_api_one_adjacencies_get_reply_t * mp)
3920 vat_main_t *vam = &vat_main;
3921 vat_json_node_t *e = 0, root;
3923 int retval = clib_net_to_host_u32 (mp->retval);
3924 vl_api_one_adjacency_t *a;
3929 n = clib_net_to_host_u32 (mp->count);
3930 vat_json_init_array (&root);
3932 for (i = 0; i < n; i++)
3934 e = vat_json_array_add (&root);
3935 a = &mp->adjacencies[i];
3937 vat_json_init_object (e);
3938 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3939 a->leid_prefix_len);
3941 vat_json_object_add_string_copy (e, "leid", s);
3944 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3945 a->reid_prefix_len);
3947 vat_json_object_add_string_copy (e, "reid", s);
3951 vat_json_print (vam->ofp, &root);
3952 vat_json_free (&root);
3955 vam->retval = retval;
3956 vam->result_ready = 1;
3960 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3962 vat_main_t *vam = &vat_main;
3964 print (vam->ofp, "%=20U",
3965 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3970 vl_api_one_map_server_details_t_handler_json
3971 (vl_api_one_map_server_details_t * mp)
3973 vat_main_t *vam = &vat_main;
3974 vat_json_node_t *node = NULL;
3975 struct in6_addr ip6;
3978 if (VAT_JSON_ARRAY != vam->json_tree.type)
3980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3981 vat_json_init_array (&vam->json_tree);
3983 node = vat_json_array_add (&vam->json_tree);
3985 vat_json_init_object (node);
3988 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3989 vat_json_object_add_ip6 (node, "map-server", ip6);
3993 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3994 vat_json_object_add_ip4 (node, "map-server", ip4);
3999 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4002 vat_main_t *vam = &vat_main;
4004 print (vam->ofp, "%=20U",
4005 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4010 vl_api_one_map_resolver_details_t_handler_json
4011 (vl_api_one_map_resolver_details_t * mp)
4013 vat_main_t *vam = &vat_main;
4014 vat_json_node_t *node = NULL;
4015 struct in6_addr ip6;
4018 if (VAT_JSON_ARRAY != vam->json_tree.type)
4020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4021 vat_json_init_array (&vam->json_tree);
4023 node = vat_json_array_add (&vam->json_tree);
4025 vat_json_init_object (node);
4028 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4029 vat_json_object_add_ip6 (node, "map resolver", ip6);
4033 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4034 vat_json_object_add_ip4 (node, "map resolver", ip4);
4039 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4041 vat_main_t *vam = &vat_main;
4042 i32 retval = ntohl (mp->retval);
4046 print (vam->ofp, "feature: %s\ngpe: %s",
4047 mp->feature_status ? "enabled" : "disabled",
4048 mp->gpe_status ? "enabled" : "disabled");
4051 vam->retval = retval;
4052 vam->result_ready = 1;
4056 vl_api_show_one_status_reply_t_handler_json
4057 (vl_api_show_one_status_reply_t * mp)
4059 vat_main_t *vam = &vat_main;
4060 vat_json_node_t node;
4061 u8 *gpe_status = NULL;
4062 u8 *feature_status = NULL;
4064 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4065 feature_status = format (0, "%s",
4066 mp->feature_status ? "enabled" : "disabled");
4067 vec_add1 (gpe_status, 0);
4068 vec_add1 (feature_status, 0);
4070 vat_json_init_object (&node);
4071 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4072 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4074 vec_free (gpe_status);
4075 vec_free (feature_status);
4077 vat_json_print (vam->ofp, &node);
4078 vat_json_free (&node);
4080 vam->retval = ntohl (mp->retval);
4081 vam->result_ready = 1;
4085 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4086 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4088 vat_main_t *vam = &vat_main;
4089 i32 retval = ntohl (mp->retval);
4093 print (vam->ofp, "%=20s", mp->locator_set_name);
4096 vam->retval = retval;
4097 vam->result_ready = 1;
4101 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4102 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4104 vat_main_t *vam = &vat_main;
4105 vat_json_node_t *node = NULL;
4107 if (VAT_JSON_ARRAY != vam->json_tree.type)
4109 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4110 vat_json_init_array (&vam->json_tree);
4112 node = vat_json_array_add (&vam->json_tree);
4114 vat_json_init_object (node);
4115 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4117 vat_json_print (vam->ofp, node);
4118 vat_json_free (node);
4120 vam->retval = ntohl (mp->retval);
4121 vam->result_ready = 1;
4125 format_lisp_map_request_mode (u8 * s, va_list * args)
4127 u32 mode = va_arg (*args, u32);
4132 return format (0, "dst-only");
4134 return format (0, "src-dst");
4140 vl_api_show_one_map_request_mode_reply_t_handler
4141 (vl_api_show_one_map_request_mode_reply_t * mp)
4143 vat_main_t *vam = &vat_main;
4144 i32 retval = ntohl (mp->retval);
4148 u32 mode = mp->mode;
4149 print (vam->ofp, "map_request_mode: %U",
4150 format_lisp_map_request_mode, mode);
4153 vam->retval = retval;
4154 vam->result_ready = 1;
4158 vl_api_show_one_map_request_mode_reply_t_handler_json
4159 (vl_api_show_one_map_request_mode_reply_t * mp)
4161 vat_main_t *vam = &vat_main;
4162 vat_json_node_t node;
4167 s = format (0, "%U", format_lisp_map_request_mode, mode);
4170 vat_json_init_object (&node);
4171 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4172 vat_json_print (vam->ofp, &node);
4173 vat_json_free (&node);
4176 vam->retval = ntohl (mp->retval);
4177 vam->result_ready = 1;
4181 vl_api_one_show_xtr_mode_reply_t_handler
4182 (vl_api_one_show_xtr_mode_reply_t * mp)
4184 vat_main_t *vam = &vat_main;
4185 i32 retval = ntohl (mp->retval);
4189 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4192 vam->retval = retval;
4193 vam->result_ready = 1;
4197 vl_api_one_show_xtr_mode_reply_t_handler_json
4198 (vl_api_one_show_xtr_mode_reply_t * mp)
4200 vat_main_t *vam = &vat_main;
4201 vat_json_node_t node;
4204 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4205 vec_add1 (status, 0);
4207 vat_json_init_object (&node);
4208 vat_json_object_add_string_copy (&node, "status", status);
4212 vat_json_print (vam->ofp, &node);
4213 vat_json_free (&node);
4215 vam->retval = ntohl (mp->retval);
4216 vam->result_ready = 1;
4220 vl_api_one_show_pitr_mode_reply_t_handler
4221 (vl_api_one_show_pitr_mode_reply_t * mp)
4223 vat_main_t *vam = &vat_main;
4224 i32 retval = ntohl (mp->retval);
4228 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4231 vam->retval = retval;
4232 vam->result_ready = 1;
4236 vl_api_one_show_pitr_mode_reply_t_handler_json
4237 (vl_api_one_show_pitr_mode_reply_t * mp)
4239 vat_main_t *vam = &vat_main;
4240 vat_json_node_t node;
4243 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4244 vec_add1 (status, 0);
4246 vat_json_init_object (&node);
4247 vat_json_object_add_string_copy (&node, "status", status);
4251 vat_json_print (vam->ofp, &node);
4252 vat_json_free (&node);
4254 vam->retval = ntohl (mp->retval);
4255 vam->result_ready = 1;
4259 vl_api_one_show_petr_mode_reply_t_handler
4260 (vl_api_one_show_petr_mode_reply_t * mp)
4262 vat_main_t *vam = &vat_main;
4263 i32 retval = ntohl (mp->retval);
4267 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4270 vam->retval = retval;
4271 vam->result_ready = 1;
4275 vl_api_one_show_petr_mode_reply_t_handler_json
4276 (vl_api_one_show_petr_mode_reply_t * mp)
4278 vat_main_t *vam = &vat_main;
4279 vat_json_node_t node;
4282 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4283 vec_add1 (status, 0);
4285 vat_json_init_object (&node);
4286 vat_json_object_add_string_copy (&node, "status", status);
4290 vat_json_print (vam->ofp, &node);
4291 vat_json_free (&node);
4293 vam->retval = ntohl (mp->retval);
4294 vam->result_ready = 1;
4298 vl_api_show_one_use_petr_reply_t_handler
4299 (vl_api_show_one_use_petr_reply_t * mp)
4301 vat_main_t *vam = &vat_main;
4302 i32 retval = ntohl (mp->retval);
4306 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4309 print (vam->ofp, "Proxy-ETR address; %U",
4310 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4315 vam->retval = retval;
4316 vam->result_ready = 1;
4320 vl_api_show_one_use_petr_reply_t_handler_json
4321 (vl_api_show_one_use_petr_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 vat_json_node_t node;
4327 struct in6_addr ip6;
4329 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4330 vec_add1 (status, 0);
4332 vat_json_init_object (&node);
4333 vat_json_object_add_string_copy (&node, "status", status);
4338 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4339 vat_json_object_add_ip6 (&node, "address", ip6);
4343 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4344 vat_json_object_add_ip4 (&node, "address", ip4);
4350 vat_json_print (vam->ofp, &node);
4351 vat_json_free (&node);
4353 vam->retval = ntohl (mp->retval);
4354 vam->result_ready = 1;
4358 vl_api_show_one_nsh_mapping_reply_t_handler
4359 (vl_api_show_one_nsh_mapping_reply_t * mp)
4361 vat_main_t *vam = &vat_main;
4362 i32 retval = ntohl (mp->retval);
4366 print (vam->ofp, "%-20s%-16s",
4367 mp->is_set ? "set" : "not-set",
4368 mp->is_set ? (char *) mp->locator_set_name : "");
4371 vam->retval = retval;
4372 vam->result_ready = 1;
4376 vl_api_show_one_nsh_mapping_reply_t_handler_json
4377 (vl_api_show_one_nsh_mapping_reply_t * mp)
4379 vat_main_t *vam = &vat_main;
4380 vat_json_node_t node;
4383 status = format (0, "%s", mp->is_set ? "yes" : "no");
4384 vec_add1 (status, 0);
4386 vat_json_init_object (&node);
4387 vat_json_object_add_string_copy (&node, "is_set", status);
4390 vat_json_object_add_string_copy (&node, "locator_set",
4391 mp->locator_set_name);
4396 vat_json_print (vam->ofp, &node);
4397 vat_json_free (&node);
4399 vam->retval = ntohl (mp->retval);
4400 vam->result_ready = 1;
4404 vl_api_show_one_map_register_ttl_reply_t_handler
4405 (vl_api_show_one_map_register_ttl_reply_t * mp)
4407 vat_main_t *vam = &vat_main;
4408 i32 retval = ntohl (mp->retval);
4410 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4414 print (vam->ofp, "ttl: %u", mp->ttl);
4417 vam->retval = retval;
4418 vam->result_ready = 1;
4422 vl_api_show_one_map_register_ttl_reply_t_handler_json
4423 (vl_api_show_one_map_register_ttl_reply_t * mp)
4425 vat_main_t *vam = &vat_main;
4426 vat_json_node_t node;
4428 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4429 vat_json_init_object (&node);
4430 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4432 vat_json_print (vam->ofp, &node);
4433 vat_json_free (&node);
4435 vam->retval = ntohl (mp->retval);
4436 vam->result_ready = 1;
4440 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4442 vat_main_t *vam = &vat_main;
4443 i32 retval = ntohl (mp->retval);
4447 print (vam->ofp, "%-20s%-16s",
4448 mp->status ? "enabled" : "disabled",
4449 mp->status ? (char *) mp->locator_set_name : "");
4452 vam->retval = retval;
4453 vam->result_ready = 1;
4457 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4459 vat_main_t *vam = &vat_main;
4460 vat_json_node_t node;
4463 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4464 vec_add1 (status, 0);
4466 vat_json_init_object (&node);
4467 vat_json_object_add_string_copy (&node, "status", status);
4470 vat_json_object_add_string_copy (&node, "locator_set",
4471 mp->locator_set_name);
4476 vat_json_print (vam->ofp, &node);
4477 vat_json_free (&node);
4479 vam->retval = ntohl (mp->retval);
4480 vam->result_ready = 1;
4484 format_policer_type (u8 * s, va_list * va)
4486 u32 i = va_arg (*va, u32);
4488 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4489 s = format (s, "1r2c");
4490 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4491 s = format (s, "1r3c");
4492 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4493 s = format (s, "2r3c-2698");
4494 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4495 s = format (s, "2r3c-4115");
4496 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4497 s = format (s, "2r3c-mef5cf1");
4499 s = format (s, "ILLEGAL");
4504 format_policer_rate_type (u8 * s, va_list * va)
4506 u32 i = va_arg (*va, u32);
4508 if (i == SSE2_QOS_RATE_KBPS)
4509 s = format (s, "kbps");
4510 else if (i == SSE2_QOS_RATE_PPS)
4511 s = format (s, "pps");
4513 s = format (s, "ILLEGAL");
4518 format_policer_round_type (u8 * s, va_list * va)
4520 u32 i = va_arg (*va, u32);
4522 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4523 s = format (s, "closest");
4524 else if (i == SSE2_QOS_ROUND_TO_UP)
4525 s = format (s, "up");
4526 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4527 s = format (s, "down");
4529 s = format (s, "ILLEGAL");
4534 format_policer_action_type (u8 * s, va_list * va)
4536 u32 i = va_arg (*va, u32);
4538 if (i == SSE2_QOS_ACTION_DROP)
4539 s = format (s, "drop");
4540 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4541 s = format (s, "transmit");
4542 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4543 s = format (s, "mark-and-transmit");
4545 s = format (s, "ILLEGAL");
4550 format_dscp (u8 * s, va_list * va)
4552 u32 i = va_arg (*va, u32);
4557 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4561 return format (s, "ILLEGAL");
4563 s = format (s, "%s", t);
4568 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4570 vat_main_t *vam = &vat_main;
4571 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4573 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4574 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4576 conform_dscp_str = format (0, "");
4578 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4579 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4581 exceed_dscp_str = format (0, "");
4583 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4584 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4586 violate_dscp_str = format (0, "");
4588 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4589 "rate type %U, round type %U, %s rate, %s color-aware, "
4590 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4591 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4592 "conform action %U%s, exceed action %U%s, violate action %U%s",
4594 format_policer_type, mp->type,
4597 clib_net_to_host_u64 (mp->cb),
4598 clib_net_to_host_u64 (mp->eb),
4599 format_policer_rate_type, mp->rate_type,
4600 format_policer_round_type, mp->round_type,
4601 mp->single_rate ? "single" : "dual",
4602 mp->color_aware ? "is" : "not",
4603 ntohl (mp->cir_tokens_per_period),
4604 ntohl (mp->pir_tokens_per_period),
4606 ntohl (mp->current_limit),
4607 ntohl (mp->current_bucket),
4608 ntohl (mp->extended_limit),
4609 ntohl (mp->extended_bucket),
4610 clib_net_to_host_u64 (mp->last_update_time),
4611 format_policer_action_type, mp->conform_action_type,
4613 format_policer_action_type, mp->exceed_action_type,
4615 format_policer_action_type, mp->violate_action_type,
4618 vec_free (conform_dscp_str);
4619 vec_free (exceed_dscp_str);
4620 vec_free (violate_dscp_str);
4623 static void vl_api_policer_details_t_handler_json
4624 (vl_api_policer_details_t * mp)
4626 vat_main_t *vam = &vat_main;
4627 vat_json_node_t *node;
4628 u8 *rate_type_str, *round_type_str, *type_str;
4629 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4631 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4633 format (0, "%U", format_policer_round_type, mp->round_type);
4634 type_str = format (0, "%U", format_policer_type, mp->type);
4635 conform_action_str = format (0, "%U", format_policer_action_type,
4636 mp->conform_action_type);
4637 exceed_action_str = format (0, "%U", format_policer_action_type,
4638 mp->exceed_action_type);
4639 violate_action_str = format (0, "%U", format_policer_action_type,
4640 mp->violate_action_type);
4642 if (VAT_JSON_ARRAY != vam->json_tree.type)
4644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4645 vat_json_init_array (&vam->json_tree);
4647 node = vat_json_array_add (&vam->json_tree);
4649 vat_json_init_object (node);
4650 vat_json_object_add_string_copy (node, "name", mp->name);
4651 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4652 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4653 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4654 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4655 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4656 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4657 vat_json_object_add_string_copy (node, "type", type_str);
4658 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4659 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4660 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4661 vat_json_object_add_uint (node, "cir_tokens_per_period",
4662 ntohl (mp->cir_tokens_per_period));
4663 vat_json_object_add_uint (node, "eir_tokens_per_period",
4664 ntohl (mp->pir_tokens_per_period));
4665 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4666 vat_json_object_add_uint (node, "current_bucket",
4667 ntohl (mp->current_bucket));
4668 vat_json_object_add_uint (node, "extended_limit",
4669 ntohl (mp->extended_limit));
4670 vat_json_object_add_uint (node, "extended_bucket",
4671 ntohl (mp->extended_bucket));
4672 vat_json_object_add_uint (node, "last_update_time",
4673 ntohl (mp->last_update_time));
4674 vat_json_object_add_string_copy (node, "conform_action",
4675 conform_action_str);
4676 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4678 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4679 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4680 vec_free (dscp_str);
4682 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4683 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4685 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4686 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4687 vec_free (dscp_str);
4689 vat_json_object_add_string_copy (node, "violate_action",
4690 violate_action_str);
4691 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4693 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4694 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4695 vec_free (dscp_str);
4698 vec_free (rate_type_str);
4699 vec_free (round_type_str);
4700 vec_free (type_str);
4701 vec_free (conform_action_str);
4702 vec_free (exceed_action_str);
4703 vec_free (violate_action_str);
4707 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4710 vat_main_t *vam = &vat_main;
4711 int i, count = ntohl (mp->count);
4714 print (vam->ofp, "classify table ids (%d) : ", count);
4715 for (i = 0; i < count; i++)
4717 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4718 print (vam->ofp, (i < count - 1) ? "," : "");
4720 vam->retval = ntohl (mp->retval);
4721 vam->result_ready = 1;
4725 vl_api_classify_table_ids_reply_t_handler_json
4726 (vl_api_classify_table_ids_reply_t * mp)
4728 vat_main_t *vam = &vat_main;
4729 int i, count = ntohl (mp->count);
4733 vat_json_node_t node;
4735 vat_json_init_object (&node);
4736 for (i = 0; i < count; i++)
4738 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4740 vat_json_print (vam->ofp, &node);
4741 vat_json_free (&node);
4743 vam->retval = ntohl (mp->retval);
4744 vam->result_ready = 1;
4748 vl_api_classify_table_by_interface_reply_t_handler
4749 (vl_api_classify_table_by_interface_reply_t * mp)
4751 vat_main_t *vam = &vat_main;
4754 table_id = ntohl (mp->l2_table_id);
4756 print (vam->ofp, "l2 table id : %d", table_id);
4758 print (vam->ofp, "l2 table id : No input ACL tables configured");
4759 table_id = ntohl (mp->ip4_table_id);
4761 print (vam->ofp, "ip4 table id : %d", table_id);
4763 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4764 table_id = ntohl (mp->ip6_table_id);
4766 print (vam->ofp, "ip6 table id : %d", table_id);
4768 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4769 vam->retval = ntohl (mp->retval);
4770 vam->result_ready = 1;
4774 vl_api_classify_table_by_interface_reply_t_handler_json
4775 (vl_api_classify_table_by_interface_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4778 vat_json_node_t node;
4780 vat_json_init_object (&node);
4782 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4783 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4784 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4786 vat_json_print (vam->ofp, &node);
4787 vat_json_free (&node);
4789 vam->retval = ntohl (mp->retval);
4790 vam->result_ready = 1;
4793 static void vl_api_policer_add_del_reply_t_handler
4794 (vl_api_policer_add_del_reply_t * mp)
4796 vat_main_t *vam = &vat_main;
4797 i32 retval = ntohl (mp->retval);
4798 if (vam->async_mode)
4800 vam->async_errors += (retval < 0);
4804 vam->retval = retval;
4805 vam->result_ready = 1;
4806 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4808 * Note: this is just barely thread-safe, depends on
4809 * the main thread spinning waiting for an answer...
4811 errmsg ("policer index %d", ntohl (mp->policer_index));
4815 static void vl_api_policer_add_del_reply_t_handler_json
4816 (vl_api_policer_add_del_reply_t * mp)
4818 vat_main_t *vam = &vat_main;
4819 vat_json_node_t node;
4821 vat_json_init_object (&node);
4822 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4823 vat_json_object_add_uint (&node, "policer_index",
4824 ntohl (mp->policer_index));
4826 vat_json_print (vam->ofp, &node);
4827 vat_json_free (&node);
4829 vam->retval = ntohl (mp->retval);
4830 vam->result_ready = 1;
4833 /* Format hex dump. */
4835 format_hex_bytes (u8 * s, va_list * va)
4837 u8 *bytes = va_arg (*va, u8 *);
4838 int n_bytes = va_arg (*va, int);
4841 /* Print short or long form depending on byte count. */
4842 uword short_form = n_bytes <= 32;
4843 u32 indent = format_get_indent (s);
4848 for (i = 0; i < n_bytes; i++)
4850 if (!short_form && (i % 32) == 0)
4851 s = format (s, "%08x: ", i);
4852 s = format (s, "%02x", bytes[i]);
4853 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4854 s = format (s, "\n%U", format_white_space, indent);
4861 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4864 vat_main_t *vam = &vat_main;
4865 i32 retval = ntohl (mp->retval);
4868 print (vam->ofp, "classify table info :");
4869 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4870 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4871 ntohl (mp->miss_next_index));
4872 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4873 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4874 ntohl (mp->match_n_vectors));
4875 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4876 ntohl (mp->mask_length));
4878 vam->retval = retval;
4879 vam->result_ready = 1;
4883 vl_api_classify_table_info_reply_t_handler_json
4884 (vl_api_classify_table_info_reply_t * mp)
4886 vat_main_t *vam = &vat_main;
4887 vat_json_node_t node;
4889 i32 retval = ntohl (mp->retval);
4892 vat_json_init_object (&node);
4894 vat_json_object_add_int (&node, "sessions",
4895 ntohl (mp->active_sessions));
4896 vat_json_object_add_int (&node, "nexttbl",
4897 ntohl (mp->next_table_index));
4898 vat_json_object_add_int (&node, "nextnode",
4899 ntohl (mp->miss_next_index));
4900 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4901 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4902 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4903 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4904 ntohl (mp->mask_length), 0);
4905 vat_json_object_add_string_copy (&node, "mask", s);
4907 vat_json_print (vam->ofp, &node);
4908 vat_json_free (&node);
4910 vam->retval = ntohl (mp->retval);
4911 vam->result_ready = 1;
4915 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4918 vat_main_t *vam = &vat_main;
4920 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4921 ntohl (mp->hit_next_index), ntohl (mp->advance),
4922 ntohl (mp->opaque_index));
4923 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4924 ntohl (mp->match_length));
4928 vl_api_classify_session_details_t_handler_json
4929 (vl_api_classify_session_details_t * mp)
4931 vat_main_t *vam = &vat_main;
4932 vat_json_node_t *node = NULL;
4934 if (VAT_JSON_ARRAY != vam->json_tree.type)
4936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4937 vat_json_init_array (&vam->json_tree);
4939 node = vat_json_array_add (&vam->json_tree);
4941 vat_json_init_object (node);
4942 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4943 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4944 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4946 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4948 vat_json_object_add_string_copy (node, "match", s);
4951 static void vl_api_pg_create_interface_reply_t_handler
4952 (vl_api_pg_create_interface_reply_t * mp)
4954 vat_main_t *vam = &vat_main;
4956 vam->retval = ntohl (mp->retval);
4957 vam->result_ready = 1;
4960 static void vl_api_pg_create_interface_reply_t_handler_json
4961 (vl_api_pg_create_interface_reply_t * mp)
4963 vat_main_t *vam = &vat_main;
4964 vat_json_node_t node;
4966 i32 retval = ntohl (mp->retval);
4969 vat_json_init_object (&node);
4971 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4973 vat_json_print (vam->ofp, &node);
4974 vat_json_free (&node);
4976 vam->retval = ntohl (mp->retval);
4977 vam->result_ready = 1;
4980 static void vl_api_policer_classify_details_t_handler
4981 (vl_api_policer_classify_details_t * mp)
4983 vat_main_t *vam = &vat_main;
4985 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4986 ntohl (mp->table_index));
4989 static void vl_api_policer_classify_details_t_handler_json
4990 (vl_api_policer_classify_details_t * mp)
4992 vat_main_t *vam = &vat_main;
4993 vat_json_node_t *node;
4995 if (VAT_JSON_ARRAY != vam->json_tree.type)
4997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4998 vat_json_init_array (&vam->json_tree);
5000 node = vat_json_array_add (&vam->json_tree);
5002 vat_json_init_object (node);
5003 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5004 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5007 static void vl_api_flow_classify_details_t_handler
5008 (vl_api_flow_classify_details_t * mp)
5010 vat_main_t *vam = &vat_main;
5012 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5013 ntohl (mp->table_index));
5016 static void vl_api_flow_classify_details_t_handler_json
5017 (vl_api_flow_classify_details_t * mp)
5019 vat_main_t *vam = &vat_main;
5020 vat_json_node_t *node;
5022 if (VAT_JSON_ARRAY != vam->json_tree.type)
5024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5025 vat_json_init_array (&vam->json_tree);
5027 node = vat_json_array_add (&vam->json_tree);
5029 vat_json_init_object (node);
5030 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5031 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5034 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5035 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5036 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5037 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5038 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5039 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5040 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5041 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5042 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5043 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5046 * Generate boilerplate reply handlers, which
5047 * dig the return value out of the xxx_reply_t API message,
5048 * stick it into vam->retval, and set vam->result_ready
5050 * Could also do this by pointing N message decode slots at
5051 * a single function, but that could break in subtle ways.
5054 #define foreach_standard_reply_retval_handler \
5055 _(sw_interface_set_flags_reply) \
5056 _(sw_interface_add_del_address_reply) \
5057 _(sw_interface_set_rx_mode_reply) \
5058 _(sw_interface_set_rx_placement_reply) \
5059 _(sw_interface_set_table_reply) \
5060 _(sw_interface_set_mpls_enable_reply) \
5061 _(sw_interface_set_vpath_reply) \
5062 _(sw_interface_set_vxlan_bypass_reply) \
5063 _(sw_interface_set_geneve_bypass_reply) \
5064 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5065 _(sw_interface_set_l2_bridge_reply) \
5066 _(sw_interface_set_bond_weight_reply) \
5067 _(bridge_domain_add_del_reply) \
5068 _(sw_interface_set_l2_xconnect_reply) \
5069 _(l2fib_add_del_reply) \
5070 _(l2fib_flush_int_reply) \
5071 _(l2fib_flush_bd_reply) \
5072 _(ip_route_add_del_reply) \
5073 _(ip_table_add_del_reply) \
5074 _(ip_mroute_add_del_reply) \
5075 _(mpls_route_add_del_reply) \
5076 _(mpls_table_add_del_reply) \
5077 _(mpls_ip_bind_unbind_reply) \
5078 _(bier_route_add_del_reply) \
5079 _(bier_table_add_del_reply) \
5080 _(proxy_arp_add_del_reply) \
5081 _(proxy_arp_intfc_enable_disable_reply) \
5082 _(sw_interface_set_unnumbered_reply) \
5083 _(ip_neighbor_add_del_reply) \
5084 _(reset_fib_reply) \
5085 _(set_ip_flow_hash_reply) \
5086 _(sw_interface_ip6_enable_disable_reply) \
5087 _(ip6nd_proxy_add_del_reply) \
5088 _(sw_interface_ip6nd_ra_prefix_reply) \
5089 _(sw_interface_ip6nd_ra_config_reply) \
5090 _(set_arp_neighbor_limit_reply) \
5091 _(l2_patch_add_del_reply) \
5092 _(sr_mpls_policy_add_reply) \
5093 _(sr_mpls_policy_mod_reply) \
5094 _(sr_mpls_policy_del_reply) \
5095 _(sr_policy_add_reply) \
5096 _(sr_policy_mod_reply) \
5097 _(sr_policy_del_reply) \
5098 _(sr_localsid_add_del_reply) \
5099 _(sr_steering_add_del_reply) \
5100 _(classify_add_del_session_reply) \
5101 _(classify_set_interface_ip_table_reply) \
5102 _(classify_set_interface_l2_tables_reply) \
5103 _(l2tpv3_set_tunnel_cookies_reply) \
5104 _(l2tpv3_interface_enable_disable_reply) \
5105 _(l2tpv3_set_lookup_key_reply) \
5106 _(l2_fib_clear_table_reply) \
5107 _(l2_interface_efp_filter_reply) \
5108 _(l2_interface_vlan_tag_rewrite_reply) \
5109 _(modify_vhost_user_if_reply) \
5110 _(delete_vhost_user_if_reply) \
5111 _(ip_probe_neighbor_reply) \
5112 _(ip_scan_neighbor_enable_disable_reply) \
5113 _(want_ip4_arp_events_reply) \
5114 _(want_ip6_nd_events_reply) \
5115 _(want_l2_macs_events_reply) \
5116 _(input_acl_set_interface_reply) \
5117 _(ipsec_spd_add_del_reply) \
5118 _(ipsec_interface_add_del_spd_reply) \
5119 _(ipsec_spd_entry_add_del_reply) \
5120 _(ipsec_sad_entry_add_del_reply) \
5121 _(ipsec_tunnel_if_add_del_reply) \
5122 _(ipsec_tunnel_if_set_sa_reply) \
5123 _(delete_loopback_reply) \
5124 _(bd_ip_mac_add_del_reply) \
5125 _(bd_ip_mac_flush_reply) \
5126 _(want_interface_events_reply) \
5127 _(cop_interface_enable_disable_reply) \
5128 _(cop_whitelist_enable_disable_reply) \
5129 _(sw_interface_clear_stats_reply) \
5130 _(ioam_enable_reply) \
5131 _(ioam_disable_reply) \
5132 _(one_add_del_locator_reply) \
5133 _(one_add_del_local_eid_reply) \
5134 _(one_add_del_remote_mapping_reply) \
5135 _(one_add_del_adjacency_reply) \
5136 _(one_add_del_map_resolver_reply) \
5137 _(one_add_del_map_server_reply) \
5138 _(one_enable_disable_reply) \
5139 _(one_rloc_probe_enable_disable_reply) \
5140 _(one_map_register_enable_disable_reply) \
5141 _(one_map_register_set_ttl_reply) \
5142 _(one_set_transport_protocol_reply) \
5143 _(one_map_register_fallback_threshold_reply) \
5144 _(one_pitr_set_locator_set_reply) \
5145 _(one_map_request_mode_reply) \
5146 _(one_add_del_map_request_itr_rlocs_reply) \
5147 _(one_eid_table_add_del_map_reply) \
5148 _(one_use_petr_reply) \
5149 _(one_stats_enable_disable_reply) \
5150 _(one_add_del_l2_arp_entry_reply) \
5151 _(one_add_del_ndp_entry_reply) \
5152 _(one_stats_flush_reply) \
5153 _(one_enable_disable_xtr_mode_reply) \
5154 _(one_enable_disable_pitr_mode_reply) \
5155 _(one_enable_disable_petr_mode_reply) \
5156 _(gpe_enable_disable_reply) \
5157 _(gpe_set_encap_mode_reply) \
5158 _(gpe_add_del_iface_reply) \
5159 _(gpe_add_del_native_fwd_rpath_reply) \
5160 _(af_packet_delete_reply) \
5161 _(policer_classify_set_interface_reply) \
5162 _(netmap_create_reply) \
5163 _(netmap_delete_reply) \
5164 _(set_ipfix_exporter_reply) \
5165 _(set_ipfix_classify_stream_reply) \
5166 _(ipfix_classify_table_add_del_reply) \
5167 _(flow_classify_set_interface_reply) \
5168 _(sw_interface_span_enable_disable_reply) \
5169 _(pg_capture_reply) \
5170 _(pg_enable_disable_reply) \
5171 _(ip_source_and_port_range_check_add_del_reply) \
5172 _(ip_source_and_port_range_check_interface_add_del_reply)\
5173 _(delete_subif_reply) \
5174 _(l2_interface_pbb_tag_rewrite_reply) \
5176 _(feature_enable_disable_reply) \
5177 _(sw_interface_tag_add_del_reply) \
5178 _(sw_interface_add_del_mac_address_reply) \
5179 _(hw_interface_set_mtu_reply) \
5180 _(p2p_ethernet_add_reply) \
5181 _(p2p_ethernet_del_reply) \
5182 _(lldp_config_reply) \
5183 _(sw_interface_set_lldp_reply) \
5184 _(tcp_configure_src_addresses_reply) \
5185 _(session_rule_add_del_reply) \
5186 _(ip_container_proxy_add_del_reply) \
5187 _(output_acl_set_interface_reply) \
5188 _(qos_record_enable_disable_reply)
5191 static void vl_api_##n##_t_handler \
5192 (vl_api_##n##_t * mp) \
5194 vat_main_t * vam = &vat_main; \
5195 i32 retval = ntohl(mp->retval); \
5196 if (vam->async_mode) { \
5197 vam->async_errors += (retval < 0); \
5199 vam->retval = retval; \
5200 vam->result_ready = 1; \
5203 foreach_standard_reply_retval_handler;
5207 static void vl_api_##n##_t_handler_json \
5208 (vl_api_##n##_t * mp) \
5210 vat_main_t * vam = &vat_main; \
5211 vat_json_node_t node; \
5212 vat_json_init_object(&node); \
5213 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5214 vat_json_print(vam->ofp, &node); \
5215 vam->retval = ntohl(mp->retval); \
5216 vam->result_ready = 1; \
5218 foreach_standard_reply_retval_handler;
5222 * Table of message reply handlers, must include boilerplate handlers
5226 #define foreach_vpe_api_reply_msg \
5227 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5228 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5229 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5230 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5231 _(CONTROL_PING_REPLY, control_ping_reply) \
5232 _(CLI_REPLY, cli_reply) \
5233 _(CLI_INBAND_REPLY, cli_inband_reply) \
5234 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5235 sw_interface_add_del_address_reply) \
5236 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5237 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5238 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5239 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5240 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5241 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5242 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5243 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5244 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5245 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5246 sw_interface_set_l2_xconnect_reply) \
5247 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5248 sw_interface_set_l2_bridge_reply) \
5249 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5250 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5251 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5252 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5253 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5254 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5255 _(L2_FLAGS_REPLY, l2_flags_reply) \
5256 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5257 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5258 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5259 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5260 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5261 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5262 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5263 _(BOND_CREATE_REPLY, bond_create_reply) \
5264 _(BOND_DELETE_REPLY, bond_delete_reply) \
5265 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5266 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5267 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5268 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5269 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5270 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5271 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5272 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5273 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5274 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5275 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5276 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5277 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5278 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5279 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5280 proxy_arp_intfc_enable_disable_reply) \
5281 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5282 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5283 sw_interface_set_unnumbered_reply) \
5284 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5285 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5286 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5287 _(RESET_FIB_REPLY, reset_fib_reply) \
5288 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5289 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5290 sw_interface_ip6_enable_disable_reply) \
5291 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5292 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5293 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5294 sw_interface_ip6nd_ra_prefix_reply) \
5295 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5296 sw_interface_ip6nd_ra_config_reply) \
5297 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5298 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5299 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5300 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5301 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5302 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5303 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5304 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5305 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5306 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5307 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5308 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5309 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5310 classify_set_interface_ip_table_reply) \
5311 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5312 classify_set_interface_l2_tables_reply) \
5313 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5314 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5315 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5316 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5317 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5318 l2tpv3_interface_enable_disable_reply) \
5319 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5320 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5321 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5322 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5323 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5324 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5325 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5326 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5327 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5328 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5329 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5330 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5331 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5332 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5333 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5334 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5335 _(SHOW_VERSION_REPLY, show_version_reply) \
5336 _(SHOW_THREADS_REPLY, show_threads_reply) \
5337 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5338 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5339 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5340 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5341 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5342 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5343 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5344 _(IP4_ARP_EVENT, ip4_arp_event) \
5345 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5346 _(IP6_ND_EVENT, ip6_nd_event) \
5347 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5348 _(L2_MACS_EVENT, l2_macs_event) \
5349 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5350 _(IP_ADDRESS_DETAILS, ip_address_details) \
5351 _(IP_DETAILS, ip_details) \
5352 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5353 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5354 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5355 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5356 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5357 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5358 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5359 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5360 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5361 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5362 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5363 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5364 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5365 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5366 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5367 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5368 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5369 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5370 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5371 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5372 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5373 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5374 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5375 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5376 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5377 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5378 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5379 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5380 one_map_register_enable_disable_reply) \
5381 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5382 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5383 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5384 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5385 one_map_register_fallback_threshold_reply) \
5386 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5387 one_rloc_probe_enable_disable_reply) \
5388 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5389 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5390 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5391 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5392 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5393 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5394 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5395 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5396 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5397 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5398 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5399 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5400 _(ONE_STATS_DETAILS, one_stats_details) \
5401 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5402 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5403 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5404 show_one_stats_enable_disable_reply) \
5405 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5406 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5407 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5408 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5409 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5410 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5411 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5412 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5413 one_enable_disable_pitr_mode_reply) \
5414 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5415 one_enable_disable_petr_mode_reply) \
5416 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5417 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5418 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5419 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5420 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5421 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5422 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5423 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5424 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5425 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5426 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5427 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5428 gpe_add_del_native_fwd_rpath_reply) \
5429 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5430 gpe_fwd_entry_path_details) \
5431 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5432 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5433 one_add_del_map_request_itr_rlocs_reply) \
5434 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5435 one_get_map_request_itr_rlocs_reply) \
5436 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5437 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5438 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5439 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5440 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5441 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5442 show_one_map_register_state_reply) \
5443 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5444 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5445 show_one_map_register_fallback_threshold_reply) \
5446 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5447 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5448 _(AF_PACKET_DETAILS, af_packet_details) \
5449 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5450 _(POLICER_DETAILS, policer_details) \
5451 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5452 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5453 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5454 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5455 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5456 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5457 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5458 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5459 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5460 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5461 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5462 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5463 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5464 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5465 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5466 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5467 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5468 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5469 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5470 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5471 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5472 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5473 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5474 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5475 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5476 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5477 ip_source_and_port_range_check_add_del_reply) \
5478 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5479 ip_source_and_port_range_check_interface_add_del_reply) \
5480 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5481 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5482 _(SET_PUNT_REPLY, set_punt_reply) \
5483 _(IP_TABLE_DETAILS, ip_table_details) \
5484 _(IP_ROUTE_DETAILS, ip_route_details) \
5485 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5486 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5487 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5488 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5489 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5490 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5491 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5492 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5493 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5494 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5495 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5496 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5497 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5498 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5499 _(SESSION_RULES_DETAILS, session_rules_details) \
5500 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5501 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5502 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5504 #define foreach_standalone_reply_msg \
5505 _(SW_INTERFACE_EVENT, sw_interface_event)
5513 #define STR_VTR_OP_CASE(op) \
5514 case L2_VTR_ ## op: \
5518 str_vtr_op (u32 vtr_op)
5522 STR_VTR_OP_CASE (DISABLED);
5523 STR_VTR_OP_CASE (PUSH_1);
5524 STR_VTR_OP_CASE (PUSH_2);
5525 STR_VTR_OP_CASE (POP_1);
5526 STR_VTR_OP_CASE (POP_2);
5527 STR_VTR_OP_CASE (TRANSLATE_1_1);
5528 STR_VTR_OP_CASE (TRANSLATE_1_2);
5529 STR_VTR_OP_CASE (TRANSLATE_2_1);
5530 STR_VTR_OP_CASE (TRANSLATE_2_2);
5537 dump_sub_interface_table (vat_main_t * vam)
5539 const sw_interface_subif_t *sub = NULL;
5541 if (vam->json_output)
5544 ("JSON output supported only for VPE API calls and dump_stats_table");
5549 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5550 "Interface", "sw_if_index",
5551 "sub id", "dot1ad", "tags", "outer id",
5552 "inner id", "exact", "default", "outer any", "inner any");
5554 vec_foreach (sub, vam->sw_if_subif_table)
5557 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5558 sub->interface_name,
5560 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5561 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5562 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5563 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5564 if (sub->vtr_op != L2_VTR_DISABLED)
5567 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5568 "tag1: %d tag2: %d ]",
5569 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5570 sub->vtr_tag1, sub->vtr_tag2);
5578 name_sort_cmp (void *a1, void *a2)
5580 name_sort_t *n1 = a1;
5581 name_sort_t *n2 = a2;
5583 return strcmp ((char *) n1->name, (char *) n2->name);
5587 dump_interface_table (vat_main_t * vam)
5590 name_sort_t *nses = 0, *ns;
5592 if (vam->json_output)
5595 ("JSON output supported only for VPE API calls and dump_stats_table");
5600 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5602 vec_add2 (nses, ns, 1);
5603 ns->name = (u8 *)(p->key);
5604 ns->value = (u32) p->value[0];
5608 vec_sort_with_function (nses, name_sort_cmp);
5610 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5611 vec_foreach (ns, nses)
5613 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5620 dump_ip_table (vat_main_t * vam, int is_ipv6)
5622 const ip_details_t *det = NULL;
5623 const ip_address_details_t *address = NULL;
5626 print (vam->ofp, "%-12s", "sw_if_index");
5628 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5635 print (vam->ofp, "%-12d", i);
5636 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5641 vec_foreach (address, det->addr)
5645 is_ipv6 ? format_ip6_address : format_ip4_address,
5646 address->ip, address->prefix_length);
5654 dump_ipv4_table (vat_main_t * vam)
5656 if (vam->json_output)
5659 ("JSON output supported only for VPE API calls and dump_stats_table");
5663 return dump_ip_table (vam, 0);
5667 dump_ipv6_table (vat_main_t * vam)
5669 if (vam->json_output)
5672 ("JSON output supported only for VPE API calls and dump_stats_table");
5676 return dump_ip_table (vam, 1);
5680 * Pass CLI buffers directly in the CLI_INBAND API message,
5681 * instead of an additional shared memory area.
5684 exec_inband (vat_main_t * vam)
5686 vl_api_cli_inband_t *mp;
5687 unformat_input_t *i = vam->input;
5690 if (vec_len (i->buffer) == 0)
5693 if (vam->exec_mode == 0 && unformat (i, "mode"))
5698 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5705 * In order for the CLI command to work, it
5706 * must be a vector ending in \n, not a C-string ending
5709 u32 len = vec_len (vam->input->buffer);
5710 M2 (CLI_INBAND, mp, len);
5711 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5715 /* json responses may or may not include a useful reply... */
5716 if (vec_len (vam->cmd_reply))
5717 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5722 exec (vat_main_t * vam)
5724 return exec_inband (vam);
5728 api_create_loopback (vat_main_t * vam)
5730 unformat_input_t *i = vam->input;
5731 vl_api_create_loopback_t *mp;
5732 vl_api_create_loopback_instance_t *mp_lbi;
5735 u8 is_specified = 0;
5736 u32 user_instance = 0;
5739 clib_memset (mac_address, 0, sizeof (mac_address));
5741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5743 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5745 if (unformat (i, "instance %d", &user_instance))
5753 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5754 mp_lbi->is_specified = is_specified;
5756 mp_lbi->user_instance = htonl (user_instance);
5758 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5763 /* Construct the API message */
5764 M (CREATE_LOOPBACK, mp);
5766 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5775 api_delete_loopback (vat_main_t * vam)
5777 unformat_input_t *i = vam->input;
5778 vl_api_delete_loopback_t *mp;
5779 u32 sw_if_index = ~0;
5782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5784 if (unformat (i, "sw_if_index %d", &sw_if_index))
5790 if (sw_if_index == ~0)
5792 errmsg ("missing sw_if_index");
5796 /* Construct the API message */
5797 M (DELETE_LOOPBACK, mp);
5798 mp->sw_if_index = ntohl (sw_if_index);
5806 api_want_interface_events (vat_main_t * vam)
5808 unformat_input_t *i = vam->input;
5809 vl_api_want_interface_events_t *mp;
5813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5815 if (unformat (i, "enable"))
5817 else if (unformat (i, "disable"))
5825 errmsg ("missing enable|disable");
5829 M (WANT_INTERFACE_EVENTS, mp);
5830 mp->enable_disable = enable;
5832 vam->interface_event_display = enable;
5840 /* Note: non-static, called once to set up the initial intfc table */
5842 api_sw_interface_dump (vat_main_t * vam)
5844 vl_api_sw_interface_dump_t *mp;
5845 vl_api_control_ping_t *mp_ping;
5847 name_sort_t *nses = 0, *ns;
5848 sw_interface_subif_t *sub = NULL;
5851 /* Toss the old name table */
5853 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5855 vec_add2 (nses, ns, 1);
5856 ns->name = (u8 *)(p->key);
5857 ns->value = (u32) p->value[0];
5861 hash_free (vam->sw_if_index_by_interface_name);
5863 vec_foreach (ns, nses) vec_free (ns->name);
5867 vec_foreach (sub, vam->sw_if_subif_table)
5869 vec_free (sub->interface_name);
5871 vec_free (vam->sw_if_subif_table);
5873 /* recreate the interface name hash table */
5874 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5877 * Ask for all interface names. Otherwise, the epic catalog of
5878 * name filters becomes ridiculously long, and vat ends up needing
5879 * to be taught about new interface types.
5881 M (SW_INTERFACE_DUMP, mp);
5884 /* Use a control ping for synchronization */
5885 MPING (CONTROL_PING, mp_ping);
5893 api_sw_interface_set_flags (vat_main_t * vam)
5895 unformat_input_t *i = vam->input;
5896 vl_api_sw_interface_set_flags_t *mp;
5898 u8 sw_if_index_set = 0;
5902 /* Parse args required to build the message */
5903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5905 if (unformat (i, "admin-up"))
5907 else if (unformat (i, "admin-down"))
5910 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5911 sw_if_index_set = 1;
5912 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5913 sw_if_index_set = 1;
5918 if (sw_if_index_set == 0)
5920 errmsg ("missing interface name or sw_if_index");
5924 /* Construct the API message */
5925 M (SW_INTERFACE_SET_FLAGS, mp);
5926 mp->sw_if_index = ntohl (sw_if_index);
5927 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5932 /* Wait for a reply, return the good/bad news... */
5938 api_sw_interface_set_rx_mode (vat_main_t * vam)
5940 unformat_input_t *i = vam->input;
5941 vl_api_sw_interface_set_rx_mode_t *mp;
5943 u8 sw_if_index_set = 0;
5945 u8 queue_id_valid = 0;
5947 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5949 /* Parse args required to build the message */
5950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5952 if (unformat (i, "queue %d", &queue_id))
5954 else if (unformat (i, "polling"))
5955 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5956 else if (unformat (i, "interrupt"))
5957 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5958 else if (unformat (i, "adaptive"))
5959 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5962 sw_if_index_set = 1;
5963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5964 sw_if_index_set = 1;
5969 if (sw_if_index_set == 0)
5971 errmsg ("missing interface name or sw_if_index");
5974 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5976 errmsg ("missing rx-mode");
5980 /* Construct the API message */
5981 M (SW_INTERFACE_SET_RX_MODE, mp);
5982 mp->sw_if_index = ntohl (sw_if_index);
5983 mp->mode = (vl_api_rx_mode_t) mode;
5984 mp->queue_id_valid = queue_id_valid;
5985 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5990 /* Wait for a reply, return the good/bad news... */
5996 api_sw_interface_set_rx_placement (vat_main_t * vam)
5998 unformat_input_t *i = vam->input;
5999 vl_api_sw_interface_set_rx_placement_t *mp;
6001 u8 sw_if_index_set = 0;
6004 u32 queue_id, thread_index;
6006 /* Parse args required to build the message */
6007 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6009 if (unformat (i, "queue %d", &queue_id))
6011 else if (unformat (i, "main"))
6013 else if (unformat (i, "worker %d", &thread_index))
6016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6017 sw_if_index_set = 1;
6018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6019 sw_if_index_set = 1;
6024 if (sw_if_index_set == 0)
6026 errmsg ("missing interface name or sw_if_index");
6032 /* Construct the API message */
6033 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6034 mp->sw_if_index = ntohl (sw_if_index);
6035 mp->worker_id = ntohl (thread_index);
6036 mp->queue_id = ntohl (queue_id);
6037 mp->is_main = is_main;
6041 /* Wait for a reply, return the good/bad news... */
6046 static void vl_api_sw_interface_rx_placement_details_t_handler
6047 (vl_api_sw_interface_rx_placement_details_t * mp)
6049 vat_main_t *vam = &vat_main;
6050 u32 worker_id = ntohl (mp->worker_id);
6053 "\n%-11d %-11s %-6d %-5d %-9s",
6054 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6055 worker_id, ntohl (mp->queue_id),
6057 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6060 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6061 (vl_api_sw_interface_rx_placement_details_t * mp)
6063 vat_main_t *vam = &vat_main;
6064 vat_json_node_t *node = NULL;
6066 if (VAT_JSON_ARRAY != vam->json_tree.type)
6068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6069 vat_json_init_array (&vam->json_tree);
6071 node = vat_json_array_add (&vam->json_tree);
6073 vat_json_init_object (node);
6074 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6075 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6076 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6077 vat_json_object_add_uint (node, "mode", mp->mode);
6081 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6083 unformat_input_t *i = vam->input;
6084 vl_api_sw_interface_rx_placement_dump_t *mp;
6085 vl_api_control_ping_t *mp_ping;
6088 u8 sw_if_index_set = 0;
6090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6101 "\n%-11s %-11s %-6s %-5s %-4s",
6102 "sw_if_index", "main/worker", "thread", "queue", "mode");
6104 /* Dump Interface rx placement */
6105 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6107 if (sw_if_index_set)
6108 mp->sw_if_index = htonl (sw_if_index);
6110 mp->sw_if_index = ~0;
6114 /* Use a control ping for synchronization */
6115 MPING (CONTROL_PING, mp_ping);
6123 api_sw_interface_clear_stats (vat_main_t * vam)
6125 unformat_input_t *i = vam->input;
6126 vl_api_sw_interface_clear_stats_t *mp;
6128 u8 sw_if_index_set = 0;
6131 /* Parse args required to build the message */
6132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6134 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6135 sw_if_index_set = 1;
6136 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6137 sw_if_index_set = 1;
6142 /* Construct the API message */
6143 M (SW_INTERFACE_CLEAR_STATS, mp);
6145 if (sw_if_index_set == 1)
6146 mp->sw_if_index = ntohl (sw_if_index);
6148 mp->sw_if_index = ~0;
6153 /* Wait for a reply, return the good/bad news... */
6159 api_sw_interface_add_del_address (vat_main_t * vam)
6161 unformat_input_t *i = vam->input;
6162 vl_api_sw_interface_add_del_address_t *mp;
6164 u8 sw_if_index_set = 0;
6165 u8 is_add = 1, del_all = 0;
6166 u32 address_length = 0;
6167 u8 v4_address_set = 0;
6168 u8 v6_address_set = 0;
6169 ip4_address_t v4address;
6170 ip6_address_t v6address;
6173 /* Parse args required to build the message */
6174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6176 if (unformat (i, "del-all"))
6178 else if (unformat (i, "del"))
6181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6182 sw_if_index_set = 1;
6183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6184 sw_if_index_set = 1;
6185 else if (unformat (i, "%U/%d",
6186 unformat_ip4_address, &v4address, &address_length))
6188 else if (unformat (i, "%U/%d",
6189 unformat_ip6_address, &v6address, &address_length))
6195 if (sw_if_index_set == 0)
6197 errmsg ("missing interface name or sw_if_index");
6200 if (v4_address_set && v6_address_set)
6202 errmsg ("both v4 and v6 addresses set");
6205 if (!v4_address_set && !v6_address_set && !del_all)
6207 errmsg ("no addresses set");
6211 /* Construct the API message */
6212 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6214 mp->sw_if_index = ntohl (sw_if_index);
6215 mp->is_add = is_add;
6216 mp->del_all = del_all;
6219 mp->prefix.address.af = ADDRESS_IP6;
6220 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6224 mp->prefix.address.af = ADDRESS_IP4;
6225 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6227 mp->prefix.len = address_length;
6232 /* Wait for a reply, return good/bad news */
6238 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6240 unformat_input_t *i = vam->input;
6241 vl_api_sw_interface_set_mpls_enable_t *mp;
6243 u8 sw_if_index_set = 0;
6247 /* Parse args required to build the message */
6248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6250 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6251 sw_if_index_set = 1;
6252 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6253 sw_if_index_set = 1;
6254 else if (unformat (i, "disable"))
6256 else if (unformat (i, "dis"))
6262 if (sw_if_index_set == 0)
6264 errmsg ("missing interface name or sw_if_index");
6268 /* Construct the API message */
6269 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6271 mp->sw_if_index = ntohl (sw_if_index);
6272 mp->enable = enable;
6277 /* Wait for a reply... */
6283 api_sw_interface_set_table (vat_main_t * vam)
6285 unformat_input_t *i = vam->input;
6286 vl_api_sw_interface_set_table_t *mp;
6287 u32 sw_if_index, vrf_id = 0;
6288 u8 sw_if_index_set = 0;
6292 /* Parse args required to build the message */
6293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6295 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6296 sw_if_index_set = 1;
6297 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6298 sw_if_index_set = 1;
6299 else if (unformat (i, "vrf %d", &vrf_id))
6301 else if (unformat (i, "ipv6"))
6307 if (sw_if_index_set == 0)
6309 errmsg ("missing interface name or sw_if_index");
6313 /* Construct the API message */
6314 M (SW_INTERFACE_SET_TABLE, mp);
6316 mp->sw_if_index = ntohl (sw_if_index);
6317 mp->is_ipv6 = is_ipv6;
6318 mp->vrf_id = ntohl (vrf_id);
6323 /* Wait for a reply... */
6328 static void vl_api_sw_interface_get_table_reply_t_handler
6329 (vl_api_sw_interface_get_table_reply_t * mp)
6331 vat_main_t *vam = &vat_main;
6333 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6335 vam->retval = ntohl (mp->retval);
6336 vam->result_ready = 1;
6340 static void vl_api_sw_interface_get_table_reply_t_handler_json
6341 (vl_api_sw_interface_get_table_reply_t * mp)
6343 vat_main_t *vam = &vat_main;
6344 vat_json_node_t node;
6346 vat_json_init_object (&node);
6347 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6348 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6350 vat_json_print (vam->ofp, &node);
6351 vat_json_free (&node);
6353 vam->retval = ntohl (mp->retval);
6354 vam->result_ready = 1;
6358 api_sw_interface_get_table (vat_main_t * vam)
6360 unformat_input_t *i = vam->input;
6361 vl_api_sw_interface_get_table_t *mp;
6363 u8 sw_if_index_set = 0;
6367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6369 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6370 sw_if_index_set = 1;
6371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6372 sw_if_index_set = 1;
6373 else if (unformat (i, "ipv6"))
6379 if (sw_if_index_set == 0)
6381 errmsg ("missing interface name or sw_if_index");
6385 M (SW_INTERFACE_GET_TABLE, mp);
6386 mp->sw_if_index = htonl (sw_if_index);
6387 mp->is_ipv6 = is_ipv6;
6395 api_sw_interface_set_vpath (vat_main_t * vam)
6397 unformat_input_t *i = vam->input;
6398 vl_api_sw_interface_set_vpath_t *mp;
6399 u32 sw_if_index = 0;
6400 u8 sw_if_index_set = 0;
6404 /* Parse args required to build the message */
6405 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6407 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6408 sw_if_index_set = 1;
6409 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6410 sw_if_index_set = 1;
6411 else if (unformat (i, "enable"))
6413 else if (unformat (i, "disable"))
6419 if (sw_if_index_set == 0)
6421 errmsg ("missing interface name or sw_if_index");
6425 /* Construct the API message */
6426 M (SW_INTERFACE_SET_VPATH, mp);
6428 mp->sw_if_index = ntohl (sw_if_index);
6429 mp->enable = is_enable;
6434 /* Wait for a reply... */
6440 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6442 unformat_input_t *i = vam->input;
6443 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6444 u32 sw_if_index = 0;
6445 u8 sw_if_index_set = 0;
6450 /* Parse args required to build the message */
6451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6453 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6454 sw_if_index_set = 1;
6455 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6456 sw_if_index_set = 1;
6457 else if (unformat (i, "enable"))
6459 else if (unformat (i, "disable"))
6461 else if (unformat (i, "ip4"))
6463 else if (unformat (i, "ip6"))
6469 if (sw_if_index_set == 0)
6471 errmsg ("missing interface name or sw_if_index");
6475 /* Construct the API message */
6476 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6478 mp->sw_if_index = ntohl (sw_if_index);
6479 mp->enable = is_enable;
6480 mp->is_ipv6 = is_ipv6;
6485 /* Wait for a reply... */
6491 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6493 unformat_input_t *i = vam->input;
6494 vl_api_sw_interface_set_geneve_bypass_t *mp;
6495 u32 sw_if_index = 0;
6496 u8 sw_if_index_set = 0;
6501 /* Parse args required to build the message */
6502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6505 sw_if_index_set = 1;
6506 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6507 sw_if_index_set = 1;
6508 else if (unformat (i, "enable"))
6510 else if (unformat (i, "disable"))
6512 else if (unformat (i, "ip4"))
6514 else if (unformat (i, "ip6"))
6520 if (sw_if_index_set == 0)
6522 errmsg ("missing interface name or sw_if_index");
6526 /* Construct the API message */
6527 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6529 mp->sw_if_index = ntohl (sw_if_index);
6530 mp->enable = is_enable;
6531 mp->is_ipv6 = is_ipv6;
6536 /* Wait for a reply... */
6542 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6544 unformat_input_t *i = vam->input;
6545 vl_api_sw_interface_set_l2_xconnect_t *mp;
6547 u8 rx_sw_if_index_set = 0;
6549 u8 tx_sw_if_index_set = 0;
6553 /* Parse args required to build the message */
6554 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6556 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6557 rx_sw_if_index_set = 1;
6558 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6559 tx_sw_if_index_set = 1;
6560 else if (unformat (i, "rx"))
6562 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6564 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6566 rx_sw_if_index_set = 1;
6571 else if (unformat (i, "tx"))
6573 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6575 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6577 tx_sw_if_index_set = 1;
6582 else if (unformat (i, "enable"))
6584 else if (unformat (i, "disable"))
6590 if (rx_sw_if_index_set == 0)
6592 errmsg ("missing rx interface name or rx_sw_if_index");
6596 if (enable && (tx_sw_if_index_set == 0))
6598 errmsg ("missing tx interface name or tx_sw_if_index");
6602 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6604 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6605 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6606 mp->enable = enable;
6614 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6616 unformat_input_t *i = vam->input;
6617 vl_api_sw_interface_set_l2_bridge_t *mp;
6618 vl_api_l2_port_type_t port_type;
6620 u8 rx_sw_if_index_set = 0;
6627 port_type = L2_API_PORT_TYPE_NORMAL;
6629 /* Parse args required to build the message */
6630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6633 rx_sw_if_index_set = 1;
6634 else if (unformat (i, "bd_id %d", &bd_id))
6638 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6639 rx_sw_if_index_set = 1;
6640 else if (unformat (i, "shg %d", &shg))
6642 else if (unformat (i, "bvi"))
6643 port_type = L2_API_PORT_TYPE_BVI;
6644 else if (unformat (i, "uu-fwd"))
6645 port_type = L2_API_PORT_TYPE_UU_FWD;
6646 else if (unformat (i, "enable"))
6648 else if (unformat (i, "disable"))
6654 if (rx_sw_if_index_set == 0)
6656 errmsg ("missing rx interface name or sw_if_index");
6660 if (enable && (bd_id_set == 0))
6662 errmsg ("missing bridge domain");
6666 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6668 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6669 mp->bd_id = ntohl (bd_id);
6671 mp->port_type = ntohl (port_type);
6672 mp->enable = enable;
6680 api_bridge_domain_dump (vat_main_t * vam)
6682 unformat_input_t *i = vam->input;
6683 vl_api_bridge_domain_dump_t *mp;
6684 vl_api_control_ping_t *mp_ping;
6688 /* Parse args required to build the message */
6689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6691 if (unformat (i, "bd_id %d", &bd_id))
6697 M (BRIDGE_DOMAIN_DUMP, mp);
6698 mp->bd_id = ntohl (bd_id);
6701 /* Use a control ping for synchronization */
6702 MPING (CONTROL_PING, mp_ping);
6710 api_bridge_domain_add_del (vat_main_t * vam)
6712 unformat_input_t *i = vam->input;
6713 vl_api_bridge_domain_add_del_t *mp;
6716 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6721 /* Parse args required to build the message */
6722 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6724 if (unformat (i, "bd_id %d", &bd_id))
6726 else if (unformat (i, "flood %d", &flood))
6728 else if (unformat (i, "uu-flood %d", &uu_flood))
6730 else if (unformat (i, "forward %d", &forward))
6732 else if (unformat (i, "learn %d", &learn))
6734 else if (unformat (i, "arp-term %d", &arp_term))
6736 else if (unformat (i, "mac-age %d", &mac_age))
6738 else if (unformat (i, "bd-tag %s", &bd_tag))
6740 else if (unformat (i, "del"))
6743 flood = uu_flood = forward = learn = 0;
6751 errmsg ("missing bridge domain");
6758 errmsg ("mac age must be less than 256 ");
6763 if ((bd_tag) && (vec_len (bd_tag) > 63))
6765 errmsg ("bd-tag cannot be longer than 63");
6770 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6772 mp->bd_id = ntohl (bd_id);
6774 mp->uu_flood = uu_flood;
6775 mp->forward = forward;
6777 mp->arp_term = arp_term;
6778 mp->is_add = is_add;
6779 mp->mac_age = (u8) mac_age;
6782 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6783 mp->bd_tag[vec_len (bd_tag)] = 0;
6794 api_l2fib_flush_bd (vat_main_t * vam)
6796 unformat_input_t *i = vam->input;
6797 vl_api_l2fib_flush_bd_t *mp;
6801 /* Parse args required to build the message */
6802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6804 if (unformat (i, "bd_id %d", &bd_id));
6811 errmsg ("missing bridge domain");
6815 M (L2FIB_FLUSH_BD, mp);
6817 mp->bd_id = htonl (bd_id);
6825 api_l2fib_flush_int (vat_main_t * vam)
6827 unformat_input_t *i = vam->input;
6828 vl_api_l2fib_flush_int_t *mp;
6829 u32 sw_if_index = ~0;
6832 /* Parse args required to build the message */
6833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6835 if (unformat (i, "sw_if_index %d", &sw_if_index));
6837 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6842 if (sw_if_index == ~0)
6844 errmsg ("missing interface name or sw_if_index");
6848 M (L2FIB_FLUSH_INT, mp);
6850 mp->sw_if_index = ntohl (sw_if_index);
6858 api_l2fib_add_del (vat_main_t * vam)
6860 unformat_input_t *i = vam->input;
6861 vl_api_l2fib_add_del_t *mp;
6867 u32 sw_if_index = 0;
6868 u8 sw_if_index_set = 0;
6877 /* Parse args required to build the message */
6878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6880 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6882 else if (unformat (i, "bd_id %d", &bd_id))
6884 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6885 sw_if_index_set = 1;
6886 else if (unformat (i, "sw_if"))
6888 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6891 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6892 sw_if_index_set = 1;
6897 else if (unformat (i, "static"))
6899 else if (unformat (i, "filter"))
6904 else if (unformat (i, "bvi"))
6909 else if (unformat (i, "del"))
6911 else if (unformat (i, "count %d", &count))
6919 errmsg ("missing mac address");
6925 errmsg ("missing bridge domain");
6929 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6931 errmsg ("missing interface name or sw_if_index");
6937 /* Turn on async mode */
6938 vam->async_mode = 1;
6939 vam->async_errors = 0;
6940 before = vat_time_now (vam);
6943 for (j = 0; j < count; j++)
6945 M (L2FIB_ADD_DEL, mp);
6947 clib_memcpy (mp->mac, mac, 6);
6948 mp->bd_id = ntohl (bd_id);
6949 mp->is_add = is_add;
6950 mp->sw_if_index = ntohl (sw_if_index);
6954 mp->static_mac = static_mac;
6955 mp->filter_mac = filter_mac;
6956 mp->bvi_mac = bvi_mac;
6958 increment_mac_address (mac);
6965 vl_api_control_ping_t *mp_ping;
6968 /* Shut off async mode */
6969 vam->async_mode = 0;
6971 MPING (CONTROL_PING, mp_ping);
6974 timeout = vat_time_now (vam) + 1.0;
6975 while (vat_time_now (vam) < timeout)
6976 if (vam->result_ready == 1)
6981 if (vam->retval == -99)
6984 if (vam->async_errors > 0)
6986 errmsg ("%d asynchronous errors", vam->async_errors);
6989 vam->async_errors = 0;
6990 after = vat_time_now (vam);
6992 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6993 count, after - before, count / (after - before));
6999 /* Wait for a reply... */
7003 /* Return the good/bad news */
7004 return (vam->retval);
7008 api_bridge_domain_set_mac_age (vat_main_t * vam)
7010 unformat_input_t *i = vam->input;
7011 vl_api_bridge_domain_set_mac_age_t *mp;
7016 /* Parse args required to build the message */
7017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7019 if (unformat (i, "bd_id %d", &bd_id));
7020 else if (unformat (i, "mac-age %d", &mac_age));
7027 errmsg ("missing bridge domain");
7033 errmsg ("mac age must be less than 256 ");
7037 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7039 mp->bd_id = htonl (bd_id);
7040 mp->mac_age = (u8) mac_age;
7048 api_l2_flags (vat_main_t * vam)
7050 unformat_input_t *i = vam->input;
7051 vl_api_l2_flags_t *mp;
7054 u8 sw_if_index_set = 0;
7058 /* Parse args required to build the message */
7059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7061 if (unformat (i, "sw_if_index %d", &sw_if_index))
7062 sw_if_index_set = 1;
7063 else if (unformat (i, "sw_if"))
7065 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7068 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7069 sw_if_index_set = 1;
7074 else if (unformat (i, "learn"))
7076 else if (unformat (i, "forward"))
7078 else if (unformat (i, "flood"))
7080 else if (unformat (i, "uu-flood"))
7081 flags |= L2_UU_FLOOD;
7082 else if (unformat (i, "arp-term"))
7083 flags |= L2_ARP_TERM;
7084 else if (unformat (i, "off"))
7086 else if (unformat (i, "disable"))
7092 if (sw_if_index_set == 0)
7094 errmsg ("missing interface name or sw_if_index");
7100 mp->sw_if_index = ntohl (sw_if_index);
7101 mp->feature_bitmap = ntohl (flags);
7102 mp->is_set = is_set;
7110 api_bridge_flags (vat_main_t * vam)
7112 unformat_input_t *i = vam->input;
7113 vl_api_bridge_flags_t *mp;
7117 bd_flags_t flags = 0;
7120 /* Parse args required to build the message */
7121 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7123 if (unformat (i, "bd_id %d", &bd_id))
7125 else if (unformat (i, "learn"))
7126 flags |= BRIDGE_API_FLAG_LEARN;
7127 else if (unformat (i, "forward"))
7128 flags |= BRIDGE_API_FLAG_FWD;
7129 else if (unformat (i, "flood"))
7130 flags |= BRIDGE_API_FLAG_FLOOD;
7131 else if (unformat (i, "uu-flood"))
7132 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7133 else if (unformat (i, "arp-term"))
7134 flags |= BRIDGE_API_FLAG_ARP_TERM;
7135 else if (unformat (i, "off"))
7137 else if (unformat (i, "disable"))
7145 errmsg ("missing bridge domain");
7149 M (BRIDGE_FLAGS, mp);
7151 mp->bd_id = ntohl (bd_id);
7152 mp->flags = ntohl (flags);
7153 mp->is_set = is_set;
7161 api_bd_ip_mac_add_del (vat_main_t * vam)
7163 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7164 vl_api_mac_address_t mac = { 0 };
7165 unformat_input_t *i = vam->input;
7166 vl_api_bd_ip_mac_add_del_t *mp;
7175 /* Parse args required to build the message */
7176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7178 if (unformat (i, "bd_id %d", &bd_id))
7182 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7186 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7190 else if (unformat (i, "del"))
7198 errmsg ("missing bridge domain");
7201 else if (ip_set == 0)
7203 errmsg ("missing IP address");
7206 else if (mac_set == 0)
7208 errmsg ("missing MAC address");
7212 M (BD_IP_MAC_ADD_DEL, mp);
7214 mp->entry.bd_id = ntohl (bd_id);
7215 mp->is_add = is_add;
7217 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7218 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7226 api_bd_ip_mac_flush (vat_main_t * vam)
7228 unformat_input_t *i = vam->input;
7229 vl_api_bd_ip_mac_flush_t *mp;
7234 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7236 if (unformat (i, "bd_id %d", &bd_id))
7246 errmsg ("missing bridge domain");
7250 M (BD_IP_MAC_FLUSH, mp);
7252 mp->bd_id = ntohl (bd_id);
7259 static void vl_api_bd_ip_mac_details_t_handler
7260 (vl_api_bd_ip_mac_details_t * mp)
7262 vat_main_t *vam = &vat_main;
7266 ntohl (mp->entry.bd_id),
7267 format_vl_api_mac_address, mp->entry.mac,
7268 format_vl_api_address, &mp->entry.ip);
7271 static void vl_api_bd_ip_mac_details_t_handler_json
7272 (vl_api_bd_ip_mac_details_t * mp)
7274 vat_main_t *vam = &vat_main;
7275 vat_json_node_t *node = NULL;
7277 if (VAT_JSON_ARRAY != vam->json_tree.type)
7279 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7280 vat_json_init_array (&vam->json_tree);
7282 node = vat_json_array_add (&vam->json_tree);
7284 vat_json_init_object (node);
7285 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7286 vat_json_object_add_string_copy (node, "mac_address",
7287 format (0, "%U", format_vl_api_mac_address,
7291 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7292 vat_json_object_add_string_copy (node, "ip_address", ip);
7297 api_bd_ip_mac_dump (vat_main_t * vam)
7299 unformat_input_t *i = vam->input;
7300 vl_api_bd_ip_mac_dump_t *mp;
7301 vl_api_control_ping_t *mp_ping;
7306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7308 if (unformat (i, "bd_id %d", &bd_id))
7317 "\n%-5s %-7s %-20s %-30s",
7318 "bd_id", "is_ipv6", "mac_address", "ip_address");
7320 /* Dump Bridge Domain Ip to Mac entries */
7321 M (BD_IP_MAC_DUMP, mp);
7324 mp->bd_id = htonl (bd_id);
7330 /* Use a control ping for synchronization */
7331 MPING (CONTROL_PING, mp_ping);
7339 api_tap_create_v2 (vat_main_t * vam)
7341 unformat_input_t *i = vam->input;
7342 vl_api_tap_create_v2_t *mp;
7343 #define TAP_FLAG_GSO (1 << 0)
7347 u8 *host_if_name = 0;
7349 u8 host_mac_addr[6];
7350 u8 host_mac_addr_set = 0;
7351 u8 *host_bridge = 0;
7352 ip4_address_t host_ip4_addr;
7353 ip4_address_t host_ip4_gw;
7354 u8 host_ip4_gw_set = 0;
7355 u32 host_ip4_prefix_len = 0;
7356 ip6_address_t host_ip6_addr;
7357 ip6_address_t host_ip6_gw;
7358 u8 host_ip6_gw_set = 0;
7359 u32 host_ip6_prefix_len = 0;
7360 u8 host_mtu_set = 0;
7361 u32 host_mtu_size = 0;
7364 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7366 clib_memset (mac_address, 0, sizeof (mac_address));
7368 /* Parse args required to build the message */
7369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7371 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7375 else if (unformat (i, "id %u", &id))
7377 else if (unformat (i, "host-if-name %s", &host_if_name))
7379 else if (unformat (i, "host-ns %s", &host_ns))
7381 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7383 host_mac_addr_set = 1;
7384 else if (unformat (i, "host-bridge %s", &host_bridge))
7386 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7387 &host_ip4_addr, &host_ip4_prefix_len))
7389 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7390 &host_ip6_addr, &host_ip6_prefix_len))
7392 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7394 host_ip4_gw_set = 1;
7395 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7397 host_ip6_gw_set = 1;
7398 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7400 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7402 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7404 else if (unformat (i, "no-gso"))
7405 tap_flags &= ~TAP_FLAG_GSO;
7406 else if (unformat (i, "gso"))
7407 tap_flags |= TAP_FLAG_GSO;
7412 if (vec_len (host_if_name) > 63)
7414 errmsg ("tap name too long. ");
7417 if (vec_len (host_ns) > 63)
7419 errmsg ("host name space too long. ");
7422 if (vec_len (host_bridge) > 63)
7424 errmsg ("host bridge name too long. ");
7427 if (host_ip4_prefix_len > 32)
7429 errmsg ("host ip4 prefix length not valid. ");
7432 if (host_ip6_prefix_len > 128)
7434 errmsg ("host ip6 prefix length not valid. ");
7437 if (!is_pow2 (rx_ring_sz))
7439 errmsg ("rx ring size must be power of 2. ");
7442 if (rx_ring_sz > 32768)
7444 errmsg ("rx ring size must be 32768 or lower. ");
7447 if (!is_pow2 (tx_ring_sz))
7449 errmsg ("tx ring size must be power of 2. ");
7452 if (tx_ring_sz > 32768)
7454 errmsg ("tx ring size must be 32768 or lower. ");
7457 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7459 errmsg ("host MTU size must be in between 64 and 65355. ");
7463 /* Construct the API message */
7464 M (TAP_CREATE_V2, mp);
7466 mp->use_random_mac = random_mac;
7468 mp->id = ntohl (id);
7469 mp->host_namespace_set = host_ns != 0;
7470 mp->host_bridge_set = host_bridge != 0;
7471 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7472 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7473 mp->rx_ring_sz = ntohs (rx_ring_sz);
7474 mp->tx_ring_sz = ntohs (tx_ring_sz);
7475 mp->host_mtu_set = host_mtu_set;
7476 mp->host_mtu_size = ntohl (host_mtu_size);
7477 mp->tap_flags = ntohl (tap_flags);
7479 if (random_mac == 0)
7480 clib_memcpy (mp->mac_address, mac_address, 6);
7481 if (host_mac_addr_set)
7482 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7484 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7486 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7488 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7489 if (host_ip4_prefix_len)
7490 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7491 if (host_ip6_prefix_len)
7492 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7493 if (host_ip4_gw_set)
7494 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7495 if (host_ip6_gw_set)
7496 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7499 vec_free (host_if_name);
7500 vec_free (host_bridge);
7505 /* Wait for a reply... */
7511 api_tap_delete_v2 (vat_main_t * vam)
7513 unformat_input_t *i = vam->input;
7514 vl_api_tap_delete_v2_t *mp;
7515 u32 sw_if_index = ~0;
7516 u8 sw_if_index_set = 0;
7519 /* Parse args required to build the message */
7520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7522 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7523 sw_if_index_set = 1;
7524 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7525 sw_if_index_set = 1;
7530 if (sw_if_index_set == 0)
7532 errmsg ("missing vpp interface name. ");
7536 /* Construct the API message */
7537 M (TAP_DELETE_V2, mp);
7539 mp->sw_if_index = ntohl (sw_if_index);
7544 /* Wait for a reply... */
7550 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7552 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7555 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7558 addr->domain = x[0];
7561 addr->function = x[3];
7567 api_virtio_pci_create (vat_main_t * vam)
7569 unformat_input_t *i = vam->input;
7570 vl_api_virtio_pci_create_t *mp;
7575 u64 features = (u64) ~ (0ULL);
7578 clib_memset (mac_address, 0, sizeof (mac_address));
7580 /* Parse args required to build the message */
7581 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7583 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7587 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7589 else if (unformat (i, "features 0x%llx", &features))
7591 else if (unformat (i, "gso-enabled"))
7599 errmsg ("pci address must be non zero. ");
7603 /* Construct the API message */
7604 M (VIRTIO_PCI_CREATE, mp);
7606 mp->use_random_mac = random_mac;
7608 mp->pci_addr = htonl (pci_addr);
7609 mp->features = clib_host_to_net_u64 (features);
7610 mp->gso_enabled = gso_enabled;
7612 if (random_mac == 0)
7613 clib_memcpy (mp->mac_address, mac_address, 6);
7618 /* Wait for a reply... */
7624 api_virtio_pci_delete (vat_main_t * vam)
7626 unformat_input_t *i = vam->input;
7627 vl_api_virtio_pci_delete_t *mp;
7628 u32 sw_if_index = ~0;
7629 u8 sw_if_index_set = 0;
7632 /* Parse args required to build the message */
7633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7636 sw_if_index_set = 1;
7637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7638 sw_if_index_set = 1;
7643 if (sw_if_index_set == 0)
7645 errmsg ("missing vpp interface name. ");
7649 /* Construct the API message */
7650 M (VIRTIO_PCI_DELETE, mp);
7652 mp->sw_if_index = htonl (sw_if_index);
7657 /* Wait for a reply... */
7663 api_bond_create (vat_main_t * vam)
7665 unformat_input_t *i = vam->input;
7666 vl_api_bond_create_t *mp;
7676 clib_memset (mac_address, 0, sizeof (mac_address));
7679 /* Parse args required to build the message */
7680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7682 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7684 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7685 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7687 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7690 else if (unformat (i, "numa-only"))
7692 else if (unformat (i, "id %u", &id))
7698 if (mode_is_set == 0)
7700 errmsg ("Missing bond mode. ");
7704 /* Construct the API message */
7705 M (BOND_CREATE, mp);
7707 mp->use_custom_mac = custom_mac;
7709 mp->mode = htonl (mode);
7710 mp->lb = htonl (lb);
7711 mp->id = htonl (id);
7712 mp->numa_only = numa_only;
7715 clib_memcpy (mp->mac_address, mac_address, 6);
7720 /* Wait for a reply... */
7726 api_bond_delete (vat_main_t * vam)
7728 unformat_input_t *i = vam->input;
7729 vl_api_bond_delete_t *mp;
7730 u32 sw_if_index = ~0;
7731 u8 sw_if_index_set = 0;
7734 /* Parse args required to build the message */
7735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7737 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7738 sw_if_index_set = 1;
7739 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7740 sw_if_index_set = 1;
7745 if (sw_if_index_set == 0)
7747 errmsg ("missing vpp interface name. ");
7751 /* Construct the API message */
7752 M (BOND_DELETE, mp);
7754 mp->sw_if_index = ntohl (sw_if_index);
7759 /* Wait for a reply... */
7765 api_bond_enslave (vat_main_t * vam)
7767 unformat_input_t *i = vam->input;
7768 vl_api_bond_enslave_t *mp;
7769 u32 bond_sw_if_index;
7773 u32 bond_sw_if_index_is_set = 0;
7775 u8 sw_if_index_is_set = 0;
7777 /* Parse args required to build the message */
7778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7780 if (unformat (i, "sw_if_index %d", &sw_if_index))
7781 sw_if_index_is_set = 1;
7782 else if (unformat (i, "bond %u", &bond_sw_if_index))
7783 bond_sw_if_index_is_set = 1;
7784 else if (unformat (i, "passive %d", &is_passive))
7786 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7792 if (bond_sw_if_index_is_set == 0)
7794 errmsg ("Missing bond sw_if_index. ");
7797 if (sw_if_index_is_set == 0)
7799 errmsg ("Missing slave sw_if_index. ");
7803 /* Construct the API message */
7804 M (BOND_ENSLAVE, mp);
7806 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7807 mp->sw_if_index = ntohl (sw_if_index);
7808 mp->is_long_timeout = is_long_timeout;
7809 mp->is_passive = is_passive;
7814 /* Wait for a reply... */
7820 api_bond_detach_slave (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_bond_detach_slave_t *mp;
7824 u32 sw_if_index = ~0;
7825 u8 sw_if_index_set = 0;
7828 /* Parse args required to build the message */
7829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7832 sw_if_index_set = 1;
7833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7834 sw_if_index_set = 1;
7839 if (sw_if_index_set == 0)
7841 errmsg ("missing vpp interface name. ");
7845 /* Construct the API message */
7846 M (BOND_DETACH_SLAVE, mp);
7848 mp->sw_if_index = ntohl (sw_if_index);
7853 /* Wait for a reply... */
7859 api_ip_table_add_del (vat_main_t * vam)
7861 unformat_input_t *i = vam->input;
7862 vl_api_ip_table_add_del_t *mp;
7868 /* Parse args required to build the message */
7869 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7871 if (unformat (i, "ipv6"))
7873 else if (unformat (i, "del"))
7875 else if (unformat (i, "add"))
7877 else if (unformat (i, "table %d", &table_id))
7881 clib_warning ("parse error '%U'", format_unformat_error, i);
7888 errmsg ("missing table-ID");
7892 /* Construct the API message */
7893 M (IP_TABLE_ADD_DEL, mp);
7895 mp->table.table_id = ntohl (table_id);
7896 mp->table.is_ip6 = is_ipv6;
7897 mp->is_add = is_add;
7902 /* Wait for a reply... */
7909 unformat_fib_path (unformat_input_t * input, va_list * args)
7911 vat_main_t *vam = va_arg (*args, vat_main_t *);
7912 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7913 u32 weight, preference;
7914 mpls_label_t out_label;
7916 clib_memset (path, 0, sizeof (*path));
7918 path->sw_if_index = ~0;
7922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7924 if (unformat (input, "%U %U",
7925 unformat_vl_api_ip4_address,
7926 &path->nh.address.ip4,
7927 api_unformat_sw_if_index, vam, &path->sw_if_index))
7929 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7931 else if (unformat (input, "%U %U",
7932 unformat_vl_api_ip6_address,
7933 &path->nh.address.ip6,
7934 api_unformat_sw_if_index, vam, &path->sw_if_index))
7936 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7938 else if (unformat (input, "weight %u", &weight))
7940 path->weight = weight;
7942 else if (unformat (input, "preference %u", &preference))
7944 path->preference = preference;
7946 else if (unformat (input, "%U next-hop-table %d",
7947 unformat_vl_api_ip4_address,
7948 &path->nh.address.ip4, &path->table_id))
7950 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7952 else if (unformat (input, "%U next-hop-table %d",
7953 unformat_vl_api_ip6_address,
7954 &path->nh.address.ip6, &path->table_id))
7956 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7958 else if (unformat (input, "%U",
7959 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7962 * the recursive next-hops are by default in the default table
7965 path->sw_if_index = ~0;
7966 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7968 else if (unformat (input, "%U",
7969 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7972 * the recursive next-hops are by default in the default table
7975 path->sw_if_index = ~0;
7976 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7978 else if (unformat (input, "resolve-via-host"))
7980 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7982 else if (unformat (input, "resolve-via-attached"))
7984 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7986 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7988 path->type = FIB_API_PATH_TYPE_LOCAL;
7989 path->sw_if_index = ~0;
7990 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7992 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7994 path->type = FIB_API_PATH_TYPE_LOCAL;
7995 path->sw_if_index = ~0;
7996 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7998 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8000 else if (unformat (input, "via-label %d", &path->nh.via_label))
8002 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8003 path->sw_if_index = ~0;
8005 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8007 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8008 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8010 else if (unformat (input, "local"))
8012 path->type = FIB_API_PATH_TYPE_LOCAL;
8014 else if (unformat (input, "out-labels"))
8016 while (unformat (input, "%d", &out_label))
8018 path->label_stack[path->n_labels].label = out_label;
8019 path->label_stack[path->n_labels].is_uniform = 0;
8020 path->label_stack[path->n_labels].ttl = 64;
8024 else if (unformat (input, "via"))
8026 /* new path, back up and return */
8027 unformat_put_input (input);
8028 unformat_put_input (input);
8029 unformat_put_input (input);
8030 unformat_put_input (input);
8039 path->proto = ntohl (path->proto);
8040 path->type = ntohl (path->type);
8041 path->flags = ntohl (path->flags);
8042 path->table_id = ntohl (path->table_id);
8043 path->sw_if_index = ntohl (path->sw_if_index);
8049 api_ip_route_add_del (vat_main_t * vam)
8051 unformat_input_t *i = vam->input;
8052 vl_api_ip_route_add_del_t *mp;
8055 u8 is_multipath = 0;
8058 vl_api_prefix_t pfx = { };
8059 vl_api_fib_path_t paths[8];
8063 u32 random_add_del = 0;
8064 u32 *random_vector = 0;
8065 u32 random_seed = 0xdeaddabe;
8067 /* Parse args required to build the message */
8068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8070 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8072 else if (unformat (i, "del"))
8074 else if (unformat (i, "add"))
8076 else if (unformat (i, "vrf %d", &vrf_id))
8078 else if (unformat (i, "count %d", &count))
8080 else if (unformat (i, "random"))
8082 else if (unformat (i, "multipath"))
8084 else if (unformat (i, "seed %d", &random_seed))
8088 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8091 if (8 == path_count)
8093 errmsg ("max 8 paths");
8099 clib_warning ("parse error '%U'", format_unformat_error, i);
8106 errmsg ("specify a path; via ...");
8109 if (prefix_set == 0)
8111 errmsg ("missing prefix");
8115 /* Generate a pile of unique, random routes */
8118 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8119 u32 this_random_address;
8122 random_hash = hash_create (count, sizeof (uword));
8124 hash_set (random_hash, i->as_u32, 1);
8125 for (j = 0; j <= count; j++)
8129 this_random_address = random_u32 (&random_seed);
8130 this_random_address =
8131 clib_host_to_net_u32 (this_random_address);
8133 while (hash_get (random_hash, this_random_address));
8134 vec_add1 (random_vector, this_random_address);
8135 hash_set (random_hash, this_random_address, 1);
8137 hash_free (random_hash);
8138 set_ip4_address (&pfx.address, random_vector[0]);
8143 /* Turn on async mode */
8144 vam->async_mode = 1;
8145 vam->async_errors = 0;
8146 before = vat_time_now (vam);
8149 for (j = 0; j < count; j++)
8151 /* Construct the API message */
8152 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8154 mp->is_add = is_add;
8155 mp->is_multipath = is_multipath;
8157 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8158 mp->route.table_id = ntohl (vrf_id);
8159 mp->route.n_paths = path_count;
8161 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8164 set_ip4_address (&pfx.address, random_vector[j + 1]);
8166 increment_address (&pfx.address);
8169 /* If we receive SIGTERM, stop now... */
8174 /* When testing multiple add/del ops, use a control-ping to sync */
8177 vl_api_control_ping_t *mp_ping;
8181 /* Shut off async mode */
8182 vam->async_mode = 0;
8184 MPING (CONTROL_PING, mp_ping);
8187 timeout = vat_time_now (vam) + 1.0;
8188 while (vat_time_now (vam) < timeout)
8189 if (vam->result_ready == 1)
8194 if (vam->retval == -99)
8197 if (vam->async_errors > 0)
8199 errmsg ("%d asynchronous errors", vam->async_errors);
8202 vam->async_errors = 0;
8203 after = vat_time_now (vam);
8205 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8209 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8210 count, after - before, count / (after - before));
8216 /* Wait for a reply... */
8221 /* Return the good/bad news */
8222 return (vam->retval);
8226 api_ip_mroute_add_del (vat_main_t * vam)
8228 unformat_input_t *i = vam->input;
8229 u8 path_set = 0, prefix_set = 0, is_add = 1;
8230 vl_api_ip_mroute_add_del_t *mp;
8231 mfib_entry_flags_t eflags = 0;
8232 vl_api_mfib_path_t path;
8233 vl_api_mprefix_t pfx = { };
8237 /* Parse args required to build the message */
8238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8240 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8243 pfx.grp_address_length = htons (pfx.grp_address_length);
8245 else if (unformat (i, "del"))
8247 else if (unformat (i, "add"))
8249 else if (unformat (i, "vrf %d", &vrf_id))
8251 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8252 path.itf_flags = htonl (path.itf_flags);
8253 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8255 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8259 clib_warning ("parse error '%U'", format_unformat_error, i);
8264 if (prefix_set == 0)
8266 errmsg ("missing addresses\n");
8271 errmsg ("missing path\n");
8275 /* Construct the API message */
8276 M (IP_MROUTE_ADD_DEL, mp);
8278 mp->is_add = is_add;
8279 mp->is_multipath = 1;
8281 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8282 mp->route.table_id = htonl (vrf_id);
8283 mp->route.n_paths = 1;
8284 mp->route.entry_flags = htonl (eflags);
8286 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8290 /* Wait for a reply... */
8296 api_mpls_table_add_del (vat_main_t * vam)
8298 unformat_input_t *i = vam->input;
8299 vl_api_mpls_table_add_del_t *mp;
8304 /* Parse args required to build the message */
8305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8307 if (unformat (i, "table %d", &table_id))
8309 else if (unformat (i, "del"))
8311 else if (unformat (i, "add"))
8315 clib_warning ("parse error '%U'", format_unformat_error, i);
8322 errmsg ("missing table-ID");
8326 /* Construct the API message */
8327 M (MPLS_TABLE_ADD_DEL, mp);
8329 mp->mt_table.mt_table_id = ntohl (table_id);
8330 mp->mt_is_add = is_add;
8335 /* Wait for a reply... */
8342 api_mpls_route_add_del (vat_main_t * vam)
8344 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8345 mpls_label_t local_label = MPLS_LABEL_INVALID;
8346 unformat_input_t *i = vam->input;
8347 vl_api_mpls_route_add_del_t *mp;
8348 vl_api_fib_path_t paths[8];
8352 /* Parse args required to build the message */
8353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8355 if (unformat (i, "%d", &local_label))
8357 else if (unformat (i, "eos"))
8359 else if (unformat (i, "non-eos"))
8361 else if (unformat (i, "del"))
8363 else if (unformat (i, "add"))
8365 else if (unformat (i, "multipath"))
8367 else if (unformat (i, "count %d", &count))
8371 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8374 if (8 == path_count)
8376 errmsg ("max 8 paths");
8382 clib_warning ("parse error '%U'", format_unformat_error, i);
8389 errmsg ("specify a path; via ...");
8393 if (MPLS_LABEL_INVALID == local_label)
8395 errmsg ("missing label");
8401 /* Turn on async mode */
8402 vam->async_mode = 1;
8403 vam->async_errors = 0;
8404 before = vat_time_now (vam);
8407 for (j = 0; j < count; j++)
8409 /* Construct the API message */
8410 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8412 mp->mr_is_add = is_add;
8413 mp->mr_is_multipath = is_multipath;
8415 mp->mr_route.mr_label = local_label;
8416 mp->mr_route.mr_eos = is_eos;
8417 mp->mr_route.mr_table_id = 0;
8418 mp->mr_route.mr_n_paths = path_count;
8420 clib_memcpy (&mp->mr_route.mr_paths, paths,
8421 sizeof (paths[0]) * path_count);
8427 /* If we receive SIGTERM, stop now... */
8432 /* When testing multiple add/del ops, use a control-ping to sync */
8435 vl_api_control_ping_t *mp_ping;
8439 /* Shut off async mode */
8440 vam->async_mode = 0;
8442 MPING (CONTROL_PING, mp_ping);
8445 timeout = vat_time_now (vam) + 1.0;
8446 while (vat_time_now (vam) < timeout)
8447 if (vam->result_ready == 1)
8452 if (vam->retval == -99)
8455 if (vam->async_errors > 0)
8457 errmsg ("%d asynchronous errors", vam->async_errors);
8460 vam->async_errors = 0;
8461 after = vat_time_now (vam);
8463 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8467 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8468 count, after - before, count / (after - before));
8474 /* Wait for a reply... */
8479 /* Return the good/bad news */
8480 return (vam->retval);
8485 api_mpls_ip_bind_unbind (vat_main_t * vam)
8487 unformat_input_t *i = vam->input;
8488 vl_api_mpls_ip_bind_unbind_t *mp;
8489 u32 ip_table_id = 0;
8491 vl_api_prefix_t pfx;
8493 mpls_label_t local_label = MPLS_LABEL_INVALID;
8496 /* Parse args required to build the message */
8497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8499 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8501 else if (unformat (i, "%d", &local_label))
8503 else if (unformat (i, "table-id %d", &ip_table_id))
8505 else if (unformat (i, "unbind"))
8507 else if (unformat (i, "bind"))
8511 clib_warning ("parse error '%U'", format_unformat_error, i);
8518 errmsg ("IP prefix not set");
8522 if (MPLS_LABEL_INVALID == local_label)
8524 errmsg ("missing label");
8528 /* Construct the API message */
8529 M (MPLS_IP_BIND_UNBIND, mp);
8531 mp->mb_is_bind = is_bind;
8532 mp->mb_ip_table_id = ntohl (ip_table_id);
8533 mp->mb_mpls_table_id = 0;
8534 mp->mb_label = ntohl (local_label);
8535 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8540 /* Wait for a reply... */
8547 api_sr_mpls_policy_add (vat_main_t * vam)
8549 unformat_input_t *i = vam->input;
8550 vl_api_sr_mpls_policy_add_t *mp;
8556 u32 *segments = NULL;
8559 /* Parse args required to build the message */
8560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8562 if (unformat (i, "bsid %d", &bsid))
8564 else if (unformat (i, "weight %d", &weight))
8566 else if (unformat (i, "spray"))
8568 else if (unformat (i, "next %d", &sid))
8571 vec_add1 (segments, htonl (sid));
8575 clib_warning ("parse error '%U'", format_unformat_error, i);
8582 errmsg ("bsid not set");
8586 if (n_segments == 0)
8588 errmsg ("no sid in segment stack");
8592 /* Construct the API message */
8593 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8595 mp->bsid = htonl (bsid);
8596 mp->weight = htonl (weight);
8598 mp->n_segments = n_segments;
8599 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8600 vec_free (segments);
8605 /* Wait for a reply... */
8611 api_sr_mpls_policy_del (vat_main_t * vam)
8613 unformat_input_t *i = vam->input;
8614 vl_api_sr_mpls_policy_del_t *mp;
8618 /* Parse args required to build the message */
8619 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8621 if (unformat (i, "bsid %d", &bsid))
8625 clib_warning ("parse error '%U'", format_unformat_error, i);
8632 errmsg ("bsid not set");
8636 /* Construct the API message */
8637 M (SR_MPLS_POLICY_DEL, mp);
8639 mp->bsid = htonl (bsid);
8644 /* Wait for a reply... */
8650 api_bier_table_add_del (vat_main_t * vam)
8652 unformat_input_t *i = vam->input;
8653 vl_api_bier_table_add_del_t *mp;
8655 u32 set = 0, sub_domain = 0, hdr_len = 3;
8656 mpls_label_t local_label = MPLS_LABEL_INVALID;
8659 /* Parse args required to build the message */
8660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8662 if (unformat (i, "sub-domain %d", &sub_domain))
8664 else if (unformat (i, "set %d", &set))
8666 else if (unformat (i, "label %d", &local_label))
8668 else if (unformat (i, "hdr-len %d", &hdr_len))
8670 else if (unformat (i, "add"))
8672 else if (unformat (i, "del"))
8676 clib_warning ("parse error '%U'", format_unformat_error, i);
8681 if (MPLS_LABEL_INVALID == local_label)
8683 errmsg ("missing label\n");
8687 /* Construct the API message */
8688 M (BIER_TABLE_ADD_DEL, mp);
8690 mp->bt_is_add = is_add;
8691 mp->bt_label = ntohl (local_label);
8692 mp->bt_tbl_id.bt_set = set;
8693 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8694 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8699 /* Wait for a reply... */
8706 api_bier_route_add_del (vat_main_t * vam)
8708 unformat_input_t *i = vam->input;
8709 vl_api_bier_route_add_del_t *mp;
8711 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8712 ip4_address_t v4_next_hop_address;
8713 ip6_address_t v6_next_hop_address;
8714 u8 next_hop_set = 0;
8715 u8 next_hop_proto_is_ip4 = 1;
8716 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8719 /* Parse args required to build the message */
8720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8722 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8724 next_hop_proto_is_ip4 = 1;
8727 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8729 next_hop_proto_is_ip4 = 0;
8732 if (unformat (i, "sub-domain %d", &sub_domain))
8734 else if (unformat (i, "set %d", &set))
8736 else if (unformat (i, "hdr-len %d", &hdr_len))
8738 else if (unformat (i, "bp %d", &bp))
8740 else if (unformat (i, "add"))
8742 else if (unformat (i, "del"))
8744 else if (unformat (i, "out-label %d", &next_hop_out_label))
8748 clib_warning ("parse error '%U'", format_unformat_error, i);
8753 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8755 errmsg ("next hop / label set\n");
8760 errmsg ("bit=position not set\n");
8764 /* Construct the API message */
8765 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8767 mp->br_is_add = is_add;
8768 mp->br_route.br_tbl_id.bt_set = set;
8769 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8770 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8771 mp->br_route.br_bp = ntohs (bp);
8772 mp->br_route.br_n_paths = 1;
8773 mp->br_route.br_paths[0].n_labels = 1;
8774 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8775 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8776 FIB_API_PATH_NH_PROTO_IP4 :
8777 FIB_API_PATH_NH_PROTO_IP6);
8779 if (next_hop_proto_is_ip4)
8781 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8782 &v4_next_hop_address, sizeof (v4_next_hop_address));
8786 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8787 &v6_next_hop_address, sizeof (v6_next_hop_address));
8793 /* Wait for a reply... */
8800 api_proxy_arp_add_del (vat_main_t * vam)
8802 unformat_input_t *i = vam->input;
8803 vl_api_proxy_arp_add_del_t *mp;
8806 vl_api_ip4_address_t lo, hi;
8810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8812 if (unformat (i, "vrf %d", &vrf_id))
8814 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8815 unformat_vl_api_ip4_address, &hi))
8817 else if (unformat (i, "del"))
8821 clib_warning ("parse error '%U'", format_unformat_error, i);
8828 errmsg ("address range not set");
8832 M (PROXY_ARP_ADD_DEL, mp);
8834 mp->proxy.table_id = ntohl (vrf_id);
8835 mp->is_add = is_add;
8836 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8837 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8845 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8847 unformat_input_t *i = vam->input;
8848 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8851 u8 sw_if_index_set = 0;
8854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8857 sw_if_index_set = 1;
8858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8859 sw_if_index_set = 1;
8860 else if (unformat (i, "enable"))
8862 else if (unformat (i, "disable"))
8866 clib_warning ("parse error '%U'", format_unformat_error, i);
8871 if (sw_if_index_set == 0)
8873 errmsg ("missing interface name or sw_if_index");
8877 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8879 mp->sw_if_index = ntohl (sw_if_index);
8880 mp->enable_disable = enable;
8888 api_mpls_tunnel_add_del (vat_main_t * vam)
8890 unformat_input_t *i = vam->input;
8891 vl_api_mpls_tunnel_add_del_t *mp;
8893 vl_api_fib_path_t paths[8];
8894 u32 sw_if_index = ~0;
8900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8902 if (unformat (i, "add"))
8906 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8908 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8910 else if (unformat (i, "l2-only"))
8914 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8917 if (8 == path_count)
8919 errmsg ("max 8 paths");
8925 clib_warning ("parse error '%U'", format_unformat_error, i);
8930 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8932 mp->mt_is_add = is_add;
8933 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8934 mp->mt_tunnel.mt_l2_only = l2_only;
8935 mp->mt_tunnel.mt_is_multicast = 0;
8936 mp->mt_tunnel.mt_n_paths = path_count;
8938 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8939 sizeof (paths[0]) * path_count);
8947 api_sw_interface_set_unnumbered (vat_main_t * vam)
8949 unformat_input_t *i = vam->input;
8950 vl_api_sw_interface_set_unnumbered_t *mp;
8952 u32 unnum_sw_index = ~0;
8954 u8 sw_if_index_set = 0;
8957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8960 sw_if_index_set = 1;
8961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8962 sw_if_index_set = 1;
8963 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8965 else if (unformat (i, "del"))
8969 clib_warning ("parse error '%U'", format_unformat_error, i);
8974 if (sw_if_index_set == 0)
8976 errmsg ("missing interface name or sw_if_index");
8980 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8982 mp->sw_if_index = ntohl (sw_if_index);
8983 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8984 mp->is_add = is_add;
8992 api_ip_neighbor_add_del (vat_main_t * vam)
8994 vl_api_mac_address_t mac_address;
8995 unformat_input_t *i = vam->input;
8996 vl_api_ip_neighbor_add_del_t *mp;
8997 vl_api_address_t ip_address;
8999 u8 sw_if_index_set = 0;
9004 ip_neighbor_flags_t flags;
9006 flags = IP_NEIGHBOR_FLAG_NONE;
9007 clib_memset (&ip_address, 0, sizeof (ip_address));
9008 clib_memset (&mac_address, 0, sizeof (mac_address));
9010 /* Parse args required to build the message */
9011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9013 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9017 else if (unformat (i, "del"))
9020 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9021 sw_if_index_set = 1;
9022 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9023 sw_if_index_set = 1;
9024 else if (unformat (i, "static"))
9025 flags |= IP_NEIGHBOR_FLAG_STATIC;
9026 else if (unformat (i, "no-fib-entry"))
9027 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9028 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9032 clib_warning ("parse error '%U'", format_unformat_error, i);
9037 if (sw_if_index_set == 0)
9039 errmsg ("missing interface name or sw_if_index");
9044 errmsg ("no address set");
9048 /* Construct the API message */
9049 M (IP_NEIGHBOR_ADD_DEL, mp);
9051 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9052 mp->is_add = is_add;
9053 mp->neighbor.flags = htonl (flags);
9055 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9056 sizeof (mac_address));
9058 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9063 /* Wait for a reply, return good/bad news */
9069 api_create_vlan_subif (vat_main_t * vam)
9071 unformat_input_t *i = vam->input;
9072 vl_api_create_vlan_subif_t *mp;
9074 u8 sw_if_index_set = 0;
9079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9081 if (unformat (i, "sw_if_index %d", &sw_if_index))
9082 sw_if_index_set = 1;
9084 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9085 sw_if_index_set = 1;
9086 else if (unformat (i, "vlan %d", &vlan_id))
9090 clib_warning ("parse error '%U'", format_unformat_error, i);
9095 if (sw_if_index_set == 0)
9097 errmsg ("missing interface name or sw_if_index");
9101 if (vlan_id_set == 0)
9103 errmsg ("missing vlan_id");
9106 M (CREATE_VLAN_SUBIF, mp);
9108 mp->sw_if_index = ntohl (sw_if_index);
9109 mp->vlan_id = ntohl (vlan_id);
9116 #define foreach_create_subif_bit \
9123 _(outer_vlan_id_any) \
9124 _(inner_vlan_id_any)
9126 #define foreach_create_subif_flag \
9131 _(4, "exact_match") \
9132 _(5, "default_sub") \
9133 _(6, "outer_vlan_id_any") \
9134 _(7, "inner_vlan_id_any")
9137 api_create_subif (vat_main_t * vam)
9139 unformat_input_t *i = vam->input;
9140 vl_api_create_subif_t *mp;
9142 u8 sw_if_index_set = 0;
9145 u32 __attribute__ ((unused)) no_tags = 0;
9146 u32 __attribute__ ((unused)) one_tag = 0;
9147 u32 __attribute__ ((unused)) two_tags = 0;
9148 u32 __attribute__ ((unused)) dot1ad = 0;
9149 u32 __attribute__ ((unused)) exact_match = 0;
9150 u32 __attribute__ ((unused)) default_sub = 0;
9151 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9152 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9154 u16 outer_vlan_id = 0;
9155 u16 inner_vlan_id = 0;
9158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9160 if (unformat (i, "sw_if_index %d", &sw_if_index))
9161 sw_if_index_set = 1;
9163 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9164 sw_if_index_set = 1;
9165 else if (unformat (i, "sub_id %d", &sub_id))
9167 else if (unformat (i, "outer_vlan_id %d", &tmp))
9168 outer_vlan_id = tmp;
9169 else if (unformat (i, "inner_vlan_id %d", &tmp))
9170 inner_vlan_id = tmp;
9172 #define _(a) else if (unformat (i, #a)) a = 1 ;
9173 foreach_create_subif_bit
9177 clib_warning ("parse error '%U'", format_unformat_error, i);
9182 if (sw_if_index_set == 0)
9184 errmsg ("missing interface name or sw_if_index");
9188 if (sub_id_set == 0)
9190 errmsg ("missing sub_id");
9193 M (CREATE_SUBIF, mp);
9195 mp->sw_if_index = ntohl (sw_if_index);
9196 mp->sub_id = ntohl (sub_id);
9198 #define _(a,b) mp->sub_if_flags |= (1 << a);
9199 foreach_create_subif_flag;
9202 mp->outer_vlan_id = ntohs (outer_vlan_id);
9203 mp->inner_vlan_id = ntohs (inner_vlan_id);
9211 api_reset_fib (vat_main_t * vam)
9213 unformat_input_t *i = vam->input;
9214 vl_api_reset_fib_t *mp;
9220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9222 if (unformat (i, "vrf %d", &vrf_id))
9224 else if (unformat (i, "ipv6"))
9228 clib_warning ("parse error '%U'", format_unformat_error, i);
9233 if (vrf_id_set == 0)
9235 errmsg ("missing vrf id");
9241 mp->vrf_id = ntohl (vrf_id);
9242 mp->is_ipv6 = is_ipv6;
9250 api_set_ip_flow_hash (vat_main_t * vam)
9252 unformat_input_t *i = vam->input;
9253 vl_api_set_ip_flow_hash_t *mp;
9265 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9267 if (unformat (i, "vrf %d", &vrf_id))
9269 else if (unformat (i, "ipv6"))
9271 else if (unformat (i, "src"))
9273 else if (unformat (i, "dst"))
9275 else if (unformat (i, "sport"))
9277 else if (unformat (i, "dport"))
9279 else if (unformat (i, "proto"))
9281 else if (unformat (i, "reverse"))
9286 clib_warning ("parse error '%U'", format_unformat_error, i);
9291 if (vrf_id_set == 0)
9293 errmsg ("missing vrf id");
9297 M (SET_IP_FLOW_HASH, mp);
9303 mp->reverse = reverse;
9304 mp->vrf_id = ntohl (vrf_id);
9305 mp->is_ipv6 = is_ipv6;
9313 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9315 unformat_input_t *i = vam->input;
9316 vl_api_sw_interface_ip6_enable_disable_t *mp;
9318 u8 sw_if_index_set = 0;
9322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9327 sw_if_index_set = 1;
9328 else if (unformat (i, "enable"))
9330 else if (unformat (i, "disable"))
9334 clib_warning ("parse error '%U'", format_unformat_error, i);
9339 if (sw_if_index_set == 0)
9341 errmsg ("missing interface name or sw_if_index");
9345 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9347 mp->sw_if_index = ntohl (sw_if_index);
9348 mp->enable = enable;
9356 api_ip6nd_proxy_add_del (vat_main_t * vam)
9358 unformat_input_t *i = vam->input;
9359 vl_api_ip6nd_proxy_add_del_t *mp;
9360 u32 sw_if_index = ~0;
9361 u8 v6_address_set = 0;
9362 vl_api_ip6_address_t v6address;
9366 /* Parse args required to build the message */
9367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9369 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9371 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9373 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9375 if (unformat (i, "del"))
9379 clib_warning ("parse error '%U'", format_unformat_error, i);
9384 if (sw_if_index == ~0)
9386 errmsg ("missing interface name or sw_if_index");
9389 if (!v6_address_set)
9391 errmsg ("no address set");
9395 /* Construct the API message */
9396 M (IP6ND_PROXY_ADD_DEL, mp);
9398 mp->is_del = is_del;
9399 mp->sw_if_index = ntohl (sw_if_index);
9400 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9405 /* Wait for a reply, return good/bad news */
9411 api_ip6nd_proxy_dump (vat_main_t * vam)
9413 vl_api_ip6nd_proxy_dump_t *mp;
9414 vl_api_control_ping_t *mp_ping;
9417 M (IP6ND_PROXY_DUMP, mp);
9421 /* Use a control ping for synchronization */
9422 MPING (CONTROL_PING, mp_ping);
9429 static void vl_api_ip6nd_proxy_details_t_handler
9430 (vl_api_ip6nd_proxy_details_t * mp)
9432 vat_main_t *vam = &vat_main;
9434 print (vam->ofp, "host %U sw_if_index %d",
9435 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9438 static void vl_api_ip6nd_proxy_details_t_handler_json
9439 (vl_api_ip6nd_proxy_details_t * mp)
9441 vat_main_t *vam = &vat_main;
9442 struct in6_addr ip6;
9443 vat_json_node_t *node = NULL;
9445 if (VAT_JSON_ARRAY != vam->json_tree.type)
9447 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9448 vat_json_init_array (&vam->json_tree);
9450 node = vat_json_array_add (&vam->json_tree);
9452 vat_json_init_object (node);
9453 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9455 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9456 vat_json_object_add_ip6 (node, "host", ip6);
9460 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9462 unformat_input_t *i = vam->input;
9463 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9465 u8 sw_if_index_set = 0;
9466 u8 v6_address_set = 0;
9467 vl_api_prefix_t pfx;
9469 u8 no_advertise = 0;
9471 u8 no_autoconfig = 0;
9474 u32 val_lifetime = 0;
9475 u32 pref_lifetime = 0;
9478 /* Parse args required to build the message */
9479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9481 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9482 sw_if_index_set = 1;
9483 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9484 sw_if_index_set = 1;
9485 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9487 else if (unformat (i, "val_life %d", &val_lifetime))
9489 else if (unformat (i, "pref_life %d", &pref_lifetime))
9491 else if (unformat (i, "def"))
9493 else if (unformat (i, "noadv"))
9495 else if (unformat (i, "offl"))
9497 else if (unformat (i, "noauto"))
9499 else if (unformat (i, "nolink"))
9501 else if (unformat (i, "isno"))
9505 clib_warning ("parse error '%U'", format_unformat_error, i);
9510 if (sw_if_index_set == 0)
9512 errmsg ("missing interface name or sw_if_index");
9515 if (!v6_address_set)
9517 errmsg ("no address set");
9521 /* Construct the API message */
9522 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9524 mp->sw_if_index = ntohl (sw_if_index);
9525 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9526 mp->use_default = use_default;
9527 mp->no_advertise = no_advertise;
9528 mp->off_link = off_link;
9529 mp->no_autoconfig = no_autoconfig;
9530 mp->no_onlink = no_onlink;
9532 mp->val_lifetime = ntohl (val_lifetime);
9533 mp->pref_lifetime = ntohl (pref_lifetime);
9538 /* Wait for a reply, return good/bad news */
9544 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9546 unformat_input_t *i = vam->input;
9547 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9549 u8 sw_if_index_set = 0;
9554 u8 send_unicast = 0;
9557 u8 default_router = 0;
9558 u32 max_interval = 0;
9559 u32 min_interval = 0;
9561 u32 initial_count = 0;
9562 u32 initial_interval = 0;
9566 /* Parse args required to build the message */
9567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9570 sw_if_index_set = 1;
9571 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9572 sw_if_index_set = 1;
9573 else if (unformat (i, "maxint %d", &max_interval))
9575 else if (unformat (i, "minint %d", &min_interval))
9577 else if (unformat (i, "life %d", &lifetime))
9579 else if (unformat (i, "count %d", &initial_count))
9581 else if (unformat (i, "interval %d", &initial_interval))
9583 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9585 else if (unformat (i, "managed"))
9587 else if (unformat (i, "other"))
9589 else if (unformat (i, "ll"))
9591 else if (unformat (i, "send"))
9593 else if (unformat (i, "cease"))
9595 else if (unformat (i, "isno"))
9597 else if (unformat (i, "def"))
9601 clib_warning ("parse error '%U'", format_unformat_error, i);
9606 if (sw_if_index_set == 0)
9608 errmsg ("missing interface name or sw_if_index");
9612 /* Construct the API message */
9613 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9615 mp->sw_if_index = ntohl (sw_if_index);
9616 mp->max_interval = ntohl (max_interval);
9617 mp->min_interval = ntohl (min_interval);
9618 mp->lifetime = ntohl (lifetime);
9619 mp->initial_count = ntohl (initial_count);
9620 mp->initial_interval = ntohl (initial_interval);
9621 mp->suppress = suppress;
9622 mp->managed = managed;
9624 mp->ll_option = ll_option;
9625 mp->send_unicast = send_unicast;
9628 mp->default_router = default_router;
9633 /* Wait for a reply, return good/bad news */
9639 api_set_arp_neighbor_limit (vat_main_t * vam)
9641 unformat_input_t *i = vam->input;
9642 vl_api_set_arp_neighbor_limit_t *mp;
9648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9652 else if (unformat (i, "ipv6"))
9656 clib_warning ("parse error '%U'", format_unformat_error, i);
9663 errmsg ("missing limit value");
9667 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9669 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9670 mp->is_ipv6 = is_ipv6;
9678 api_l2_patch_add_del (vat_main_t * vam)
9680 unformat_input_t *i = vam->input;
9681 vl_api_l2_patch_add_del_t *mp;
9683 u8 rx_sw_if_index_set = 0;
9685 u8 tx_sw_if_index_set = 0;
9689 /* Parse args required to build the message */
9690 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9692 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9693 rx_sw_if_index_set = 1;
9694 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9695 tx_sw_if_index_set = 1;
9696 else if (unformat (i, "rx"))
9698 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9700 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9702 rx_sw_if_index_set = 1;
9707 else if (unformat (i, "tx"))
9709 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9711 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9713 tx_sw_if_index_set = 1;
9718 else if (unformat (i, "del"))
9724 if (rx_sw_if_index_set == 0)
9726 errmsg ("missing rx interface name or rx_sw_if_index");
9730 if (tx_sw_if_index_set == 0)
9732 errmsg ("missing tx interface name or tx_sw_if_index");
9736 M (L2_PATCH_ADD_DEL, mp);
9738 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9739 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9740 mp->is_add = is_add;
9748 u8 localsid_addr[16];
9757 api_sr_localsid_add_del (vat_main_t * vam)
9759 unformat_input_t *i = vam->input;
9760 vl_api_sr_localsid_add_del_t *mp;
9763 ip6_address_t localsid;
9767 u32 fib_table = ~(u32) 0;
9768 ip6_address_t nh_addr6;
9769 ip4_address_t nh_addr4;
9770 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
9771 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
9773 bool nexthop_set = 0;
9777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9779 if (unformat (i, "del"))
9781 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9782 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
9784 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
9786 else if (unformat (i, "behavior %u", &behavior));
9787 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9788 else if (unformat (i, "fib-table %u", &fib_table));
9789 else if (unformat (i, "end.psp %u", &behavior));
9794 M (SR_LOCALSID_ADD_DEL, mp);
9796 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
9799 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
9800 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
9802 mp->behavior = behavior;
9803 mp->sw_if_index = ntohl (sw_if_index);
9804 mp->fib_table = ntohl (fib_table);
9805 mp->end_psp = end_psp;
9806 mp->is_del = is_del;
9814 api_ioam_enable (vat_main_t * vam)
9816 unformat_input_t *input = vam->input;
9817 vl_api_ioam_enable_t *mp;
9819 int has_trace_option = 0;
9820 int has_pot_option = 0;
9821 int has_seqno_option = 0;
9822 int has_analyse_option = 0;
9825 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9827 if (unformat (input, "trace"))
9828 has_trace_option = 1;
9829 else if (unformat (input, "pot"))
9831 else if (unformat (input, "seqno"))
9832 has_seqno_option = 1;
9833 else if (unformat (input, "analyse"))
9834 has_analyse_option = 1;
9838 M (IOAM_ENABLE, mp);
9839 mp->id = htons (id);
9840 mp->seqno = has_seqno_option;
9841 mp->analyse = has_analyse_option;
9842 mp->pot_enable = has_pot_option;
9843 mp->trace_enable = has_trace_option;
9852 api_ioam_disable (vat_main_t * vam)
9854 vl_api_ioam_disable_t *mp;
9857 M (IOAM_DISABLE, mp);
9863 #define foreach_tcp_proto_field \
9867 #define foreach_udp_proto_field \
9871 #define foreach_ip4_proto_field \
9883 u16 src_port, dst_port;
9886 #if VPP_API_TEST_BUILTIN == 0
9888 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9890 u8 **maskp = va_arg (*args, u8 **);
9892 u8 found_something = 0;
9895 #define _(a) u8 a=0;
9896 foreach_tcp_proto_field;
9899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9902 #define _(a) else if (unformat (input, #a)) a=1;
9903 foreach_tcp_proto_field
9909 #define _(a) found_something += a;
9910 foreach_tcp_proto_field;
9913 if (found_something == 0)
9916 vec_validate (mask, sizeof (*tcp) - 1);
9918 tcp = (tcp_header_t *) mask;
9920 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9921 foreach_tcp_proto_field;
9929 unformat_udp_mask (unformat_input_t * input, va_list * args)
9931 u8 **maskp = va_arg (*args, u8 **);
9933 u8 found_something = 0;
9936 #define _(a) u8 a=0;
9937 foreach_udp_proto_field;
9940 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9943 #define _(a) else if (unformat (input, #a)) a=1;
9944 foreach_udp_proto_field
9950 #define _(a) found_something += a;
9951 foreach_udp_proto_field;
9954 if (found_something == 0)
9957 vec_validate (mask, sizeof (*udp) - 1);
9959 udp = (udp_header_t *) mask;
9961 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9962 foreach_udp_proto_field;
9970 unformat_l4_mask (unformat_input_t * input, va_list * args)
9972 u8 **maskp = va_arg (*args, u8 **);
9973 u16 src_port = 0, dst_port = 0;
9974 tcpudp_header_t *tcpudp;
9976 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9978 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9980 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9982 else if (unformat (input, "src_port"))
9984 else if (unformat (input, "dst_port"))
9990 if (!src_port && !dst_port)
9994 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9996 tcpudp = (tcpudp_header_t *) mask;
9997 tcpudp->src_port = src_port;
9998 tcpudp->dst_port = dst_port;
10006 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10008 u8 **maskp = va_arg (*args, u8 **);
10010 u8 found_something = 0;
10013 #define _(a) u8 a=0;
10014 foreach_ip4_proto_field;
10020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10022 if (unformat (input, "version"))
10024 else if (unformat (input, "hdr_length"))
10026 else if (unformat (input, "src"))
10028 else if (unformat (input, "dst"))
10030 else if (unformat (input, "proto"))
10033 #define _(a) else if (unformat (input, #a)) a=1;
10034 foreach_ip4_proto_field
10040 #define _(a) found_something += a;
10041 foreach_ip4_proto_field;
10044 if (found_something == 0)
10047 vec_validate (mask, sizeof (*ip) - 1);
10049 ip = (ip4_header_t *) mask;
10051 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10052 foreach_ip4_proto_field;
10055 ip->ip_version_and_header_length = 0;
10058 ip->ip_version_and_header_length |= 0xF0;
10061 ip->ip_version_and_header_length |= 0x0F;
10067 #define foreach_ip6_proto_field \
10070 _(payload_length) \
10075 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10077 u8 **maskp = va_arg (*args, u8 **);
10079 u8 found_something = 0;
10081 u32 ip_version_traffic_class_and_flow_label;
10083 #define _(a) u8 a=0;
10084 foreach_ip6_proto_field;
10087 u8 traffic_class = 0;
10090 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10092 if (unformat (input, "version"))
10094 else if (unformat (input, "traffic-class"))
10096 else if (unformat (input, "flow-label"))
10098 else if (unformat (input, "src"))
10100 else if (unformat (input, "dst"))
10102 else if (unformat (input, "proto"))
10105 #define _(a) else if (unformat (input, #a)) a=1;
10106 foreach_ip6_proto_field
10112 #define _(a) found_something += a;
10113 foreach_ip6_proto_field;
10116 if (found_something == 0)
10119 vec_validate (mask, sizeof (*ip) - 1);
10121 ip = (ip6_header_t *) mask;
10123 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10124 foreach_ip6_proto_field;
10127 ip_version_traffic_class_and_flow_label = 0;
10130 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10133 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10136 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10138 ip->ip_version_traffic_class_and_flow_label =
10139 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10146 unformat_l3_mask (unformat_input_t * input, va_list * args)
10148 u8 **maskp = va_arg (*args, u8 **);
10150 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10152 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10154 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10163 unformat_l2_mask (unformat_input_t * input, va_list * args)
10165 u8 **maskp = va_arg (*args, u8 **);
10172 u8 ignore_tag1 = 0;
10173 u8 ignore_tag2 = 0;
10180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10182 if (unformat (input, "src"))
10184 else if (unformat (input, "dst"))
10186 else if (unformat (input, "proto"))
10188 else if (unformat (input, "tag1"))
10190 else if (unformat (input, "tag2"))
10192 else if (unformat (input, "ignore-tag1"))
10194 else if (unformat (input, "ignore-tag2"))
10196 else if (unformat (input, "cos1"))
10198 else if (unformat (input, "cos2"))
10200 else if (unformat (input, "dot1q"))
10202 else if (unformat (input, "dot1ad"))
10207 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10208 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10211 if (tag1 || ignore_tag1 || cos1 || dot1q)
10213 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10216 vec_validate (mask, len - 1);
10219 clib_memset (mask, 0xff, 6);
10222 clib_memset (mask + 6, 0xff, 6);
10224 if (tag2 || dot1ad)
10226 /* inner vlan tag */
10235 mask[21] = mask[20] = 0xff;
10256 mask[16] = mask[17] = 0xff;
10266 mask[12] = mask[13] = 0xff;
10273 unformat_classify_mask (unformat_input_t * input, va_list * args)
10275 u8 **maskp = va_arg (*args, u8 **);
10276 u32 *skipp = va_arg (*args, u32 *);
10277 u32 *matchp = va_arg (*args, u32 *);
10285 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10287 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10289 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10291 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10293 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10307 if (mask || l2 || l3 || l4)
10309 if (l2 || l3 || l4)
10311 /* "With a free Ethernet header in every package" */
10313 vec_validate (l2, 13);
10317 vec_append (mask, l3);
10322 vec_append (mask, l4);
10327 /* Scan forward looking for the first significant mask octet */
10328 for (i = 0; i < vec_len (mask); i++)
10332 /* compute (skip, match) params */
10333 *skipp = i / sizeof (u32x4);
10334 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10336 /* Pad mask to an even multiple of the vector size */
10337 while (vec_len (mask) % sizeof (u32x4))
10338 vec_add1 (mask, 0);
10340 match = vec_len (mask) / sizeof (u32x4);
10342 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10344 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10345 if (*tmp || *(tmp + 1))
10350 clib_warning ("BUG: match 0");
10352 _vec_len (mask) = match * sizeof (u32x4);
10362 #endif /* VPP_API_TEST_BUILTIN */
10364 #define foreach_l2_next \
10366 _(ethernet, ETHERNET_INPUT) \
10367 _(ip4, IP4_INPUT) \
10371 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10373 u32 *miss_next_indexp = va_arg (*args, u32 *);
10374 u32 next_index = 0;
10378 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10382 if (unformat (input, "%d", &tmp))
10391 *miss_next_indexp = next_index;
10395 #define foreach_ip_next \
10398 _(rewrite, REWRITE)
10401 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10403 u32 *miss_next_indexp = va_arg (*args, u32 *);
10404 u32 next_index = 0;
10408 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10412 if (unformat (input, "%d", &tmp))
10421 *miss_next_indexp = next_index;
10425 #define foreach_acl_next \
10429 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10431 u32 *miss_next_indexp = va_arg (*args, u32 *);
10432 u32 next_index = 0;
10436 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10440 if (unformat (input, "permit"))
10445 else if (unformat (input, "%d", &tmp))
10454 *miss_next_indexp = next_index;
10459 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10461 u32 *r = va_arg (*args, u32 *);
10463 if (unformat (input, "conform-color"))
10464 *r = POLICE_CONFORM;
10465 else if (unformat (input, "exceed-color"))
10466 *r = POLICE_EXCEED;
10474 api_classify_add_del_table (vat_main_t * vam)
10476 unformat_input_t *i = vam->input;
10477 vl_api_classify_add_del_table_t *mp;
10484 u32 table_index = ~0;
10485 u32 next_table_index = ~0;
10486 u32 miss_next_index = ~0;
10487 u32 memory_size = 32 << 20;
10489 u32 current_data_flag = 0;
10490 int current_data_offset = 0;
10493 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10495 if (unformat (i, "del"))
10497 else if (unformat (i, "del-chain"))
10502 else if (unformat (i, "buckets %d", &nbuckets))
10504 else if (unformat (i, "memory_size %d", &memory_size))
10506 else if (unformat (i, "skip %d", &skip))
10508 else if (unformat (i, "match %d", &match))
10510 else if (unformat (i, "table %d", &table_index))
10512 else if (unformat (i, "mask %U", unformat_classify_mask,
10513 &mask, &skip, &match))
10515 else if (unformat (i, "next-table %d", &next_table_index))
10517 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10520 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10523 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10526 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10528 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10534 if (is_add && mask == 0)
10536 errmsg ("Mask required");
10540 if (is_add && skip == ~0)
10542 errmsg ("skip count required");
10546 if (is_add && match == ~0)
10548 errmsg ("match count required");
10552 if (!is_add && table_index == ~0)
10554 errmsg ("table index required for delete");
10558 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10560 mp->is_add = is_add;
10561 mp->del_chain = del_chain;
10562 mp->table_index = ntohl (table_index);
10563 mp->nbuckets = ntohl (nbuckets);
10564 mp->memory_size = ntohl (memory_size);
10565 mp->skip_n_vectors = ntohl (skip);
10566 mp->match_n_vectors = ntohl (match);
10567 mp->next_table_index = ntohl (next_table_index);
10568 mp->miss_next_index = ntohl (miss_next_index);
10569 mp->current_data_flag = ntohl (current_data_flag);
10570 mp->current_data_offset = ntohl (current_data_offset);
10571 mp->mask_len = ntohl (vec_len (mask));
10572 clib_memcpy (mp->mask, mask, vec_len (mask));
10581 #if VPP_API_TEST_BUILTIN == 0
10583 unformat_l4_match (unformat_input_t * input, va_list * args)
10585 u8 **matchp = va_arg (*args, u8 **);
10587 u8 *proto_header = 0;
10593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10595 if (unformat (input, "src_port %d", &src_port))
10597 else if (unformat (input, "dst_port %d", &dst_port))
10603 h.src_port = clib_host_to_net_u16 (src_port);
10604 h.dst_port = clib_host_to_net_u16 (dst_port);
10605 vec_validate (proto_header, sizeof (h) - 1);
10606 memcpy (proto_header, &h, sizeof (h));
10608 *matchp = proto_header;
10614 unformat_ip4_match (unformat_input_t * input, va_list * args)
10616 u8 **matchp = va_arg (*args, u8 **);
10621 int hdr_length = 0;
10622 u32 hdr_length_val;
10623 int src = 0, dst = 0;
10624 ip4_address_t src_val, dst_val;
10631 int fragment_id = 0;
10632 u32 fragment_id_val;
10638 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10640 if (unformat (input, "version %d", &version_val))
10642 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10644 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10646 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10648 else if (unformat (input, "proto %d", &proto_val))
10650 else if (unformat (input, "tos %d", &tos_val))
10652 else if (unformat (input, "length %d", &length_val))
10654 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10656 else if (unformat (input, "ttl %d", &ttl_val))
10658 else if (unformat (input, "checksum %d", &checksum_val))
10664 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10665 + ttl + checksum == 0)
10669 * Aligned because we use the real comparison functions
10671 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10673 ip = (ip4_header_t *) match;
10675 /* These are realistically matched in practice */
10677 ip->src_address.as_u32 = src_val.as_u32;
10680 ip->dst_address.as_u32 = dst_val.as_u32;
10683 ip->protocol = proto_val;
10686 /* These are not, but they're included for completeness */
10688 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10691 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10697 ip->length = clib_host_to_net_u16 (length_val);
10703 ip->checksum = clib_host_to_net_u16 (checksum_val);
10710 unformat_ip6_match (unformat_input_t * input, va_list * args)
10712 u8 **matchp = va_arg (*args, u8 **);
10717 u8 traffic_class = 0;
10718 u32 traffic_class_val = 0;
10721 int src = 0, dst = 0;
10722 ip6_address_t src_val, dst_val;
10725 int payload_length = 0;
10726 u32 payload_length_val;
10729 u32 ip_version_traffic_class_and_flow_label;
10731 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10733 if (unformat (input, "version %d", &version_val))
10735 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10737 else if (unformat (input, "flow_label %d", &flow_label_val))
10739 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10741 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10743 else if (unformat (input, "proto %d", &proto_val))
10745 else if (unformat (input, "payload_length %d", &payload_length_val))
10746 payload_length = 1;
10747 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10753 if (version + traffic_class + flow_label + src + dst + proto +
10754 payload_length + hop_limit == 0)
10758 * Aligned because we use the real comparison functions
10760 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10762 ip = (ip6_header_t *) match;
10765 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10768 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10771 ip->protocol = proto_val;
10773 ip_version_traffic_class_and_flow_label = 0;
10776 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10779 ip_version_traffic_class_and_flow_label |=
10780 (traffic_class_val & 0xFF) << 20;
10783 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10785 ip->ip_version_traffic_class_and_flow_label =
10786 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10788 if (payload_length)
10789 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10792 ip->hop_limit = hop_limit_val;
10799 unformat_l3_match (unformat_input_t * input, va_list * args)
10801 u8 **matchp = va_arg (*args, u8 **);
10803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10805 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10807 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10816 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10818 u8 *tagp = va_arg (*args, u8 *);
10821 if (unformat (input, "%d", &tag))
10823 tagp[0] = (tag >> 8) & 0x0F;
10824 tagp[1] = tag & 0xFF;
10832 unformat_l2_match (unformat_input_t * input, va_list * args)
10834 u8 **matchp = va_arg (*args, u8 **);
10847 u8 ignore_tag1 = 0;
10848 u8 ignore_tag2 = 0;
10854 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10856 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10859 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10861 else if (unformat (input, "proto %U",
10862 unformat_ethernet_type_host_byte_order, &proto_val))
10864 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10866 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10868 else if (unformat (input, "ignore-tag1"))
10870 else if (unformat (input, "ignore-tag2"))
10872 else if (unformat (input, "cos1 %d", &cos1_val))
10874 else if (unformat (input, "cos2 %d", &cos2_val))
10879 if ((src + dst + proto + tag1 + tag2 +
10880 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10883 if (tag1 || ignore_tag1 || cos1)
10885 if (tag2 || ignore_tag2 || cos2)
10888 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10891 clib_memcpy (match, dst_val, 6);
10894 clib_memcpy (match + 6, src_val, 6);
10898 /* inner vlan tag */
10899 match[19] = tag2_val[1];
10900 match[18] = tag2_val[0];
10902 match[18] |= (cos2_val & 0x7) << 5;
10905 match[21] = proto_val & 0xff;
10906 match[20] = proto_val >> 8;
10910 match[15] = tag1_val[1];
10911 match[14] = tag1_val[0];
10914 match[14] |= (cos1_val & 0x7) << 5;
10920 match[15] = tag1_val[1];
10921 match[14] = tag1_val[0];
10924 match[17] = proto_val & 0xff;
10925 match[16] = proto_val >> 8;
10928 match[14] |= (cos1_val & 0x7) << 5;
10934 match[18] |= (cos2_val & 0x7) << 5;
10936 match[14] |= (cos1_val & 0x7) << 5;
10939 match[13] = proto_val & 0xff;
10940 match[12] = proto_val >> 8;
10948 unformat_qos_source (unformat_input_t * input, va_list * args)
10950 int *qs = va_arg (*args, int *);
10952 if (unformat (input, "ip"))
10953 *qs = QOS_SOURCE_IP;
10954 else if (unformat (input, "mpls"))
10955 *qs = QOS_SOURCE_MPLS;
10956 else if (unformat (input, "ext"))
10957 *qs = QOS_SOURCE_EXT;
10958 else if (unformat (input, "vlan"))
10959 *qs = QOS_SOURCE_VLAN;
10968 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10970 u8 **matchp = va_arg (*args, u8 **);
10971 u32 skip_n_vectors = va_arg (*args, u32);
10972 u32 match_n_vectors = va_arg (*args, u32);
10979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10981 if (unformat (input, "hex %U", unformat_hex_string, &match))
10983 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10985 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10987 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11001 if (match || l2 || l3 || l4)
11003 if (l2 || l3 || l4)
11005 /* "Win a free Ethernet header in every packet" */
11007 vec_validate_aligned (l2, 13, sizeof (u32x4));
11011 vec_append_aligned (match, l3, sizeof (u32x4));
11016 vec_append_aligned (match, l4, sizeof (u32x4));
11021 /* Make sure the vector is big enough even if key is all 0's */
11022 vec_validate_aligned
11023 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11026 /* Set size, include skipped vectors */
11027 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11038 api_classify_add_del_session (vat_main_t * vam)
11040 unformat_input_t *i = vam->input;
11041 vl_api_classify_add_del_session_t *mp;
11043 u32 table_index = ~0;
11044 u32 hit_next_index = ~0;
11045 u32 opaque_index = ~0;
11048 u32 skip_n_vectors = 0;
11049 u32 match_n_vectors = 0;
11055 * Warning: you have to supply skip_n and match_n
11056 * because the API client cant simply look at the classify
11060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11062 if (unformat (i, "del"))
11064 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11067 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11070 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11073 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11075 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11077 else if (unformat (i, "opaque-index %d", &opaque_index))
11079 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11081 else if (unformat (i, "match_n %d", &match_n_vectors))
11083 else if (unformat (i, "match %U", api_unformat_classify_match,
11084 &match, skip_n_vectors, match_n_vectors))
11086 else if (unformat (i, "advance %d", &advance))
11088 else if (unformat (i, "table-index %d", &table_index))
11090 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11092 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11094 else if (unformat (i, "action %d", &action))
11096 else if (unformat (i, "metadata %d", &metadata))
11102 if (table_index == ~0)
11104 errmsg ("Table index required");
11108 if (is_add && match == 0)
11110 errmsg ("Match value required");
11114 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11116 mp->is_add = is_add;
11117 mp->table_index = ntohl (table_index);
11118 mp->hit_next_index = ntohl (hit_next_index);
11119 mp->opaque_index = ntohl (opaque_index);
11120 mp->advance = ntohl (advance);
11121 mp->action = action;
11122 mp->metadata = ntohl (metadata);
11123 mp->match_len = ntohl (vec_len (match));
11124 clib_memcpy (mp->match, match, vec_len (match));
11133 api_classify_set_interface_ip_table (vat_main_t * vam)
11135 unformat_input_t *i = vam->input;
11136 vl_api_classify_set_interface_ip_table_t *mp;
11138 int sw_if_index_set;
11139 u32 table_index = ~0;
11143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11146 sw_if_index_set = 1;
11147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11148 sw_if_index_set = 1;
11149 else if (unformat (i, "table %d", &table_index))
11153 clib_warning ("parse error '%U'", format_unformat_error, i);
11158 if (sw_if_index_set == 0)
11160 errmsg ("missing interface name or sw_if_index");
11165 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11167 mp->sw_if_index = ntohl (sw_if_index);
11168 mp->table_index = ntohl (table_index);
11169 mp->is_ipv6 = is_ipv6;
11177 api_classify_set_interface_l2_tables (vat_main_t * vam)
11179 unformat_input_t *i = vam->input;
11180 vl_api_classify_set_interface_l2_tables_t *mp;
11182 int sw_if_index_set;
11183 u32 ip4_table_index = ~0;
11184 u32 ip6_table_index = ~0;
11185 u32 other_table_index = ~0;
11189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11194 sw_if_index_set = 1;
11195 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11197 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11199 else if (unformat (i, "other-table %d", &other_table_index))
11201 else if (unformat (i, "is-input %d", &is_input))
11205 clib_warning ("parse error '%U'", format_unformat_error, i);
11210 if (sw_if_index_set == 0)
11212 errmsg ("missing interface name or sw_if_index");
11217 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11219 mp->sw_if_index = ntohl (sw_if_index);
11220 mp->ip4_table_index = ntohl (ip4_table_index);
11221 mp->ip6_table_index = ntohl (ip6_table_index);
11222 mp->other_table_index = ntohl (other_table_index);
11223 mp->is_input = (u8) is_input;
11231 api_set_ipfix_exporter (vat_main_t * vam)
11233 unformat_input_t *i = vam->input;
11234 vl_api_set_ipfix_exporter_t *mp;
11235 ip4_address_t collector_address;
11236 u8 collector_address_set = 0;
11237 u32 collector_port = ~0;
11238 ip4_address_t src_address;
11239 u8 src_address_set = 0;
11242 u32 template_interval = ~0;
11243 u8 udp_checksum = 0;
11246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11248 if (unformat (i, "collector_address %U", unformat_ip4_address,
11249 &collector_address))
11250 collector_address_set = 1;
11251 else if (unformat (i, "collector_port %d", &collector_port))
11253 else if (unformat (i, "src_address %U", unformat_ip4_address,
11255 src_address_set = 1;
11256 else if (unformat (i, "vrf_id %d", &vrf_id))
11258 else if (unformat (i, "path_mtu %d", &path_mtu))
11260 else if (unformat (i, "template_interval %d", &template_interval))
11262 else if (unformat (i, "udp_checksum"))
11268 if (collector_address_set == 0)
11270 errmsg ("collector_address required");
11274 if (src_address_set == 0)
11276 errmsg ("src_address required");
11280 M (SET_IPFIX_EXPORTER, mp);
11282 memcpy (mp->collector_address, collector_address.data,
11283 sizeof (collector_address.data));
11284 mp->collector_port = htons ((u16) collector_port);
11285 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11286 mp->vrf_id = htonl (vrf_id);
11287 mp->path_mtu = htonl (path_mtu);
11288 mp->template_interval = htonl (template_interval);
11289 mp->udp_checksum = udp_checksum;
11297 api_set_ipfix_classify_stream (vat_main_t * vam)
11299 unformat_input_t *i = vam->input;
11300 vl_api_set_ipfix_classify_stream_t *mp;
11302 u32 src_port = UDP_DST_PORT_ipfix;
11305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11307 if (unformat (i, "domain %d", &domain_id))
11309 else if (unformat (i, "src_port %d", &src_port))
11313 errmsg ("unknown input `%U'", format_unformat_error, i);
11318 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11320 mp->domain_id = htonl (domain_id);
11321 mp->src_port = htons ((u16) src_port);
11329 api_ipfix_classify_table_add_del (vat_main_t * vam)
11331 unformat_input_t *i = vam->input;
11332 vl_api_ipfix_classify_table_add_del_t *mp;
11334 u32 classify_table_index = ~0;
11336 u8 transport_protocol = 255;
11339 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11341 if (unformat (i, "add"))
11343 else if (unformat (i, "del"))
11345 else if (unformat (i, "table %d", &classify_table_index))
11347 else if (unformat (i, "ip4"))
11349 else if (unformat (i, "ip6"))
11351 else if (unformat (i, "tcp"))
11352 transport_protocol = 6;
11353 else if (unformat (i, "udp"))
11354 transport_protocol = 17;
11357 errmsg ("unknown input `%U'", format_unformat_error, i);
11364 errmsg ("expecting: add|del");
11367 if (classify_table_index == ~0)
11369 errmsg ("classifier table not specified");
11372 if (ip_version == 0)
11374 errmsg ("IP version not specified");
11378 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11380 mp->is_add = is_add;
11381 mp->table_id = htonl (classify_table_index);
11382 mp->ip_version = ip_version;
11383 mp->transport_protocol = transport_protocol;
11391 api_get_node_index (vat_main_t * vam)
11393 unformat_input_t *i = vam->input;
11394 vl_api_get_node_index_t *mp;
11398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11400 if (unformat (i, "node %s", &name))
11407 errmsg ("node name required");
11410 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11412 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11416 M (GET_NODE_INDEX, mp);
11417 clib_memcpy (mp->node_name, name, vec_len (name));
11426 api_get_next_index (vat_main_t * vam)
11428 unformat_input_t *i = vam->input;
11429 vl_api_get_next_index_t *mp;
11430 u8 *node_name = 0, *next_node_name = 0;
11433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11435 if (unformat (i, "node-name %s", &node_name))
11437 else if (unformat (i, "next-node-name %s", &next_node_name))
11441 if (node_name == 0)
11443 errmsg ("node name required");
11446 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11448 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11452 if (next_node_name == 0)
11454 errmsg ("next node name required");
11457 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11459 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11463 M (GET_NEXT_INDEX, mp);
11464 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11465 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11466 vec_free (node_name);
11467 vec_free (next_node_name);
11475 api_add_node_next (vat_main_t * vam)
11477 unformat_input_t *i = vam->input;
11478 vl_api_add_node_next_t *mp;
11483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11485 if (unformat (i, "node %s", &name))
11487 else if (unformat (i, "next %s", &next))
11494 errmsg ("node name required");
11497 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11499 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11504 errmsg ("next node required");
11507 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11509 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11513 M (ADD_NODE_NEXT, mp);
11514 clib_memcpy (mp->node_name, name, vec_len (name));
11515 clib_memcpy (mp->next_name, next, vec_len (next));
11525 api_l2tpv3_create_tunnel (vat_main_t * vam)
11527 unformat_input_t *i = vam->input;
11528 ip6_address_t client_address, our_address;
11529 int client_address_set = 0;
11530 int our_address_set = 0;
11531 u32 local_session_id = 0;
11532 u32 remote_session_id = 0;
11533 u64 local_cookie = 0;
11534 u64 remote_cookie = 0;
11535 u8 l2_sublayer_present = 0;
11536 vl_api_l2tpv3_create_tunnel_t *mp;
11539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11541 if (unformat (i, "client_address %U", unformat_ip6_address,
11543 client_address_set = 1;
11544 else if (unformat (i, "our_address %U", unformat_ip6_address,
11546 our_address_set = 1;
11547 else if (unformat (i, "local_session_id %d", &local_session_id))
11549 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11551 else if (unformat (i, "local_cookie %lld", &local_cookie))
11553 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11555 else if (unformat (i, "l2-sublayer-present"))
11556 l2_sublayer_present = 1;
11561 if (client_address_set == 0)
11563 errmsg ("client_address required");
11567 if (our_address_set == 0)
11569 errmsg ("our_address required");
11573 M (L2TPV3_CREATE_TUNNEL, mp);
11575 clib_memcpy (mp->client_address, client_address.as_u8,
11576 sizeof (mp->client_address));
11578 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11580 mp->local_session_id = ntohl (local_session_id);
11581 mp->remote_session_id = ntohl (remote_session_id);
11582 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11583 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11584 mp->l2_sublayer_present = l2_sublayer_present;
11593 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11595 unformat_input_t *i = vam->input;
11597 u8 sw_if_index_set = 0;
11598 u64 new_local_cookie = 0;
11599 u64 new_remote_cookie = 0;
11600 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11603 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11605 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11606 sw_if_index_set = 1;
11607 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11608 sw_if_index_set = 1;
11609 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11611 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11617 if (sw_if_index_set == 0)
11619 errmsg ("missing interface name or sw_if_index");
11623 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11625 mp->sw_if_index = ntohl (sw_if_index);
11626 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11627 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11635 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11637 unformat_input_t *i = vam->input;
11638 vl_api_l2tpv3_interface_enable_disable_t *mp;
11640 u8 sw_if_index_set = 0;
11641 u8 enable_disable = 1;
11644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11646 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11647 sw_if_index_set = 1;
11648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11649 sw_if_index_set = 1;
11650 else if (unformat (i, "enable"))
11651 enable_disable = 1;
11652 else if (unformat (i, "disable"))
11653 enable_disable = 0;
11658 if (sw_if_index_set == 0)
11660 errmsg ("missing interface name or sw_if_index");
11664 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11666 mp->sw_if_index = ntohl (sw_if_index);
11667 mp->enable_disable = enable_disable;
11675 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11677 unformat_input_t *i = vam->input;
11678 vl_api_l2tpv3_set_lookup_key_t *mp;
11682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11684 if (unformat (i, "lookup_v6_src"))
11685 key = L2T_LOOKUP_SRC_ADDRESS;
11686 else if (unformat (i, "lookup_v6_dst"))
11687 key = L2T_LOOKUP_DST_ADDRESS;
11688 else if (unformat (i, "lookup_session_id"))
11689 key = L2T_LOOKUP_SESSION_ID;
11694 if (key == (u8) ~ 0)
11696 errmsg ("l2tp session lookup key unset");
11700 M (L2TPV3_SET_LOOKUP_KEY, mp);
11709 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11710 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11712 vat_main_t *vam = &vat_main;
11714 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11715 format_ip6_address, mp->our_address,
11716 format_ip6_address, mp->client_address,
11717 clib_net_to_host_u32 (mp->sw_if_index));
11720 " local cookies %016llx %016llx remote cookie %016llx",
11721 clib_net_to_host_u64 (mp->local_cookie[0]),
11722 clib_net_to_host_u64 (mp->local_cookie[1]),
11723 clib_net_to_host_u64 (mp->remote_cookie));
11725 print (vam->ofp, " local session-id %d remote session-id %d",
11726 clib_net_to_host_u32 (mp->local_session_id),
11727 clib_net_to_host_u32 (mp->remote_session_id));
11729 print (vam->ofp, " l2 specific sublayer %s\n",
11730 mp->l2_sublayer_present ? "preset" : "absent");
11734 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11735 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11737 vat_main_t *vam = &vat_main;
11738 vat_json_node_t *node = NULL;
11739 struct in6_addr addr;
11741 if (VAT_JSON_ARRAY != vam->json_tree.type)
11743 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11744 vat_json_init_array (&vam->json_tree);
11746 node = vat_json_array_add (&vam->json_tree);
11748 vat_json_init_object (node);
11750 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11751 vat_json_object_add_ip6 (node, "our_address", addr);
11752 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11753 vat_json_object_add_ip6 (node, "client_address", addr);
11755 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11756 vat_json_init_array (lc);
11757 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11758 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11759 vat_json_object_add_uint (node, "remote_cookie",
11760 clib_net_to_host_u64 (mp->remote_cookie));
11762 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11763 vat_json_object_add_uint (node, "local_session_id",
11764 clib_net_to_host_u32 (mp->local_session_id));
11765 vat_json_object_add_uint (node, "remote_session_id",
11766 clib_net_to_host_u32 (mp->remote_session_id));
11767 vat_json_object_add_string_copy (node, "l2_sublayer",
11768 mp->l2_sublayer_present ? (u8 *) "present"
11769 : (u8 *) "absent");
11773 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11775 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11776 vl_api_control_ping_t *mp_ping;
11779 /* Get list of l2tpv3-tunnel interfaces */
11780 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11783 /* Use a control ping for synchronization */
11784 MPING (CONTROL_PING, mp_ping);
11792 static void vl_api_sw_interface_tap_v2_details_t_handler
11793 (vl_api_sw_interface_tap_v2_details_t * mp)
11795 vat_main_t *vam = &vat_main;
11797 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
11798 mp->host_ip4_prefix_len);
11799 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
11800 mp->host_ip6_prefix_len);
11803 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11804 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11805 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11806 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11807 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11813 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11814 (vl_api_sw_interface_tap_v2_details_t * mp)
11816 vat_main_t *vam = &vat_main;
11817 vat_json_node_t *node = NULL;
11819 if (VAT_JSON_ARRAY != vam->json_tree.type)
11821 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11822 vat_json_init_array (&vam->json_tree);
11824 node = vat_json_array_add (&vam->json_tree);
11826 vat_json_init_object (node);
11827 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11828 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11829 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11830 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11831 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11832 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11833 vat_json_object_add_string_copy (node, "host_mac_addr",
11834 format (0, "%U", format_ethernet_address,
11835 &mp->host_mac_addr));
11836 vat_json_object_add_string_copy (node, "host_namespace",
11837 mp->host_namespace);
11838 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11839 vat_json_object_add_string_copy (node, "host_ip4_addr",
11840 format (0, "%U/%d", format_ip4_address,
11842 mp->host_ip4_prefix_len));
11843 vat_json_object_add_string_copy (node, "host_ip6_addr",
11844 format (0, "%U/%d", format_ip6_address,
11846 mp->host_ip6_prefix_len));
11851 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11853 vl_api_sw_interface_tap_v2_dump_t *mp;
11854 vl_api_control_ping_t *mp_ping;
11858 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11859 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11860 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11863 /* Get list of tap interfaces */
11864 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11867 /* Use a control ping for synchronization */
11868 MPING (CONTROL_PING, mp_ping);
11875 static void vl_api_sw_interface_virtio_pci_details_t_handler
11876 (vl_api_sw_interface_virtio_pci_details_t * mp)
11878 vat_main_t *vam = &vat_main;
11892 addr.as_u32 = ntohl (mp->pci_addr);
11893 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11894 addr.slot, addr.function);
11897 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11898 pci_addr, ntohl (mp->sw_if_index),
11899 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11900 format_ethernet_address, mp->mac_addr,
11901 clib_net_to_host_u64 (mp->features));
11902 vec_free (pci_addr);
11905 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11906 (vl_api_sw_interface_virtio_pci_details_t * mp)
11908 vat_main_t *vam = &vat_main;
11909 vat_json_node_t *node = NULL;
11911 if (VAT_JSON_ARRAY != vam->json_tree.type)
11913 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11914 vat_json_init_array (&vam->json_tree);
11916 node = vat_json_array_add (&vam->json_tree);
11918 vat_json_init_object (node);
11919 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
11920 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11921 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11922 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11923 vat_json_object_add_uint (node, "features",
11924 clib_net_to_host_u64 (mp->features));
11925 vat_json_object_add_string_copy (node, "mac_addr",
11926 format (0, "%U", format_ethernet_address,
11931 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11933 vl_api_sw_interface_virtio_pci_dump_t *mp;
11934 vl_api_control_ping_t *mp_ping;
11938 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11939 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11940 "mac_addr", "features");
11942 /* Get list of tap interfaces */
11943 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11946 /* Use a control ping for synchronization */
11947 MPING (CONTROL_PING, mp_ping);
11955 api_vxlan_offload_rx (vat_main_t * vam)
11957 unformat_input_t *line_input = vam->input;
11958 vl_api_vxlan_offload_rx_t *mp;
11959 u32 hw_if_index = ~0, rx_if_index = ~0;
11963 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11965 if (unformat (line_input, "del"))
11967 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11970 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11972 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11975 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11979 errmsg ("parse error '%U'", format_unformat_error, line_input);
11984 if (hw_if_index == ~0)
11986 errmsg ("no hw interface");
11990 if (rx_if_index == ~0)
11992 errmsg ("no rx tunnel");
11996 M (VXLAN_OFFLOAD_RX, mp);
11998 mp->hw_if_index = ntohl (hw_if_index);
11999 mp->sw_if_index = ntohl (rx_if_index);
12000 mp->enable = is_add;
12007 static uword unformat_vxlan_decap_next
12008 (unformat_input_t * input, va_list * args)
12010 u32 *result = va_arg (*args, u32 *);
12013 if (unformat (input, "l2"))
12014 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12015 else if (unformat (input, "%d", &tmp))
12023 api_vxlan_add_del_tunnel (vat_main_t * vam)
12025 unformat_input_t *line_input = vam->input;
12026 vl_api_vxlan_add_del_tunnel_t *mp;
12027 ip46_address_t src, dst;
12029 u8 ipv4_set = 0, ipv6_set = 0;
12034 u32 mcast_sw_if_index = ~0;
12035 u32 encap_vrf_id = 0;
12036 u32 decap_next_index = ~0;
12040 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12041 clib_memset (&src, 0, sizeof src);
12042 clib_memset (&dst, 0, sizeof dst);
12044 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12046 if (unformat (line_input, "del"))
12048 else if (unformat (line_input, "instance %d", &instance))
12051 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12057 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12063 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12069 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12074 else if (unformat (line_input, "group %U %U",
12075 unformat_ip4_address, &dst.ip4,
12076 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12078 grp_set = dst_set = 1;
12081 else if (unformat (line_input, "group %U",
12082 unformat_ip4_address, &dst.ip4))
12084 grp_set = dst_set = 1;
12087 else if (unformat (line_input, "group %U %U",
12088 unformat_ip6_address, &dst.ip6,
12089 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12091 grp_set = dst_set = 1;
12094 else if (unformat (line_input, "group %U",
12095 unformat_ip6_address, &dst.ip6))
12097 grp_set = dst_set = 1;
12101 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12103 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12105 else if (unformat (line_input, "decap-next %U",
12106 unformat_vxlan_decap_next, &decap_next_index))
12108 else if (unformat (line_input, "vni %d", &vni))
12112 errmsg ("parse error '%U'", format_unformat_error, line_input);
12119 errmsg ("tunnel src address not specified");
12124 errmsg ("tunnel dst address not specified");
12128 if (grp_set && !ip46_address_is_multicast (&dst))
12130 errmsg ("tunnel group address not multicast");
12133 if (grp_set && mcast_sw_if_index == ~0)
12135 errmsg ("tunnel nonexistent multicast device");
12138 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12140 errmsg ("tunnel dst address must be unicast");
12145 if (ipv4_set && ipv6_set)
12147 errmsg ("both IPv4 and IPv6 addresses specified");
12151 if ((vni == 0) || (vni >> 24))
12153 errmsg ("vni not specified or out of range");
12157 M (VXLAN_ADD_DEL_TUNNEL, mp);
12161 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12162 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12166 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12167 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12170 mp->instance = htonl (instance);
12171 mp->encap_vrf_id = ntohl (encap_vrf_id);
12172 mp->decap_next_index = ntohl (decap_next_index);
12173 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12174 mp->vni = ntohl (vni);
12175 mp->is_add = is_add;
12176 mp->is_ipv6 = ipv6_set;
12183 static void vl_api_vxlan_tunnel_details_t_handler
12184 (vl_api_vxlan_tunnel_details_t * mp)
12186 vat_main_t *vam = &vat_main;
12187 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12188 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12190 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12191 ntohl (mp->sw_if_index),
12192 ntohl (mp->instance),
12193 format_ip46_address, &src, IP46_TYPE_ANY,
12194 format_ip46_address, &dst, IP46_TYPE_ANY,
12195 ntohl (mp->encap_vrf_id),
12196 ntohl (mp->decap_next_index), ntohl (mp->vni),
12197 ntohl (mp->mcast_sw_if_index));
12200 static void vl_api_vxlan_tunnel_details_t_handler_json
12201 (vl_api_vxlan_tunnel_details_t * mp)
12203 vat_main_t *vam = &vat_main;
12204 vat_json_node_t *node = NULL;
12206 if (VAT_JSON_ARRAY != vam->json_tree.type)
12208 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12209 vat_json_init_array (&vam->json_tree);
12211 node = vat_json_array_add (&vam->json_tree);
12213 vat_json_init_object (node);
12214 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12216 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12220 struct in6_addr ip6;
12222 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12223 vat_json_object_add_ip6 (node, "src_address", ip6);
12224 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12225 vat_json_object_add_ip6 (node, "dst_address", ip6);
12229 struct in_addr ip4;
12231 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12232 vat_json_object_add_ip4 (node, "src_address", ip4);
12233 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12234 vat_json_object_add_ip4 (node, "dst_address", ip4);
12236 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12237 vat_json_object_add_uint (node, "decap_next_index",
12238 ntohl (mp->decap_next_index));
12239 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12240 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12241 vat_json_object_add_uint (node, "mcast_sw_if_index",
12242 ntohl (mp->mcast_sw_if_index));
12246 api_vxlan_tunnel_dump (vat_main_t * vam)
12248 unformat_input_t *i = vam->input;
12249 vl_api_vxlan_tunnel_dump_t *mp;
12250 vl_api_control_ping_t *mp_ping;
12252 u8 sw_if_index_set = 0;
12255 /* Parse args required to build the message */
12256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12258 if (unformat (i, "sw_if_index %d", &sw_if_index))
12259 sw_if_index_set = 1;
12264 if (sw_if_index_set == 0)
12269 if (!vam->json_output)
12271 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12272 "sw_if_index", "instance", "src_address", "dst_address",
12273 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12276 /* Get list of vxlan-tunnel interfaces */
12277 M (VXLAN_TUNNEL_DUMP, mp);
12279 mp->sw_if_index = htonl (sw_if_index);
12283 /* Use a control ping for synchronization */
12284 MPING (CONTROL_PING, mp_ping);
12291 static uword unformat_geneve_decap_next
12292 (unformat_input_t * input, va_list * args)
12294 u32 *result = va_arg (*args, u32 *);
12297 if (unformat (input, "l2"))
12298 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12299 else if (unformat (input, "%d", &tmp))
12307 api_geneve_add_del_tunnel (vat_main_t * vam)
12309 unformat_input_t *line_input = vam->input;
12310 vl_api_geneve_add_del_tunnel_t *mp;
12311 ip46_address_t src, dst;
12313 u8 ipv4_set = 0, ipv6_set = 0;
12317 u32 mcast_sw_if_index = ~0;
12318 u32 encap_vrf_id = 0;
12319 u32 decap_next_index = ~0;
12323 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12324 clib_memset (&src, 0, sizeof src);
12325 clib_memset (&dst, 0, sizeof dst);
12327 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12329 if (unformat (line_input, "del"))
12332 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12338 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12344 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12350 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12355 else if (unformat (line_input, "group %U %U",
12356 unformat_ip4_address, &dst.ip4,
12357 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12359 grp_set = dst_set = 1;
12362 else if (unformat (line_input, "group %U",
12363 unformat_ip4_address, &dst.ip4))
12365 grp_set = dst_set = 1;
12368 else if (unformat (line_input, "group %U %U",
12369 unformat_ip6_address, &dst.ip6,
12370 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12372 grp_set = dst_set = 1;
12375 else if (unformat (line_input, "group %U",
12376 unformat_ip6_address, &dst.ip6))
12378 grp_set = dst_set = 1;
12382 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12384 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12386 else if (unformat (line_input, "decap-next %U",
12387 unformat_geneve_decap_next, &decap_next_index))
12389 else if (unformat (line_input, "vni %d", &vni))
12393 errmsg ("parse error '%U'", format_unformat_error, line_input);
12400 errmsg ("tunnel src address not specified");
12405 errmsg ("tunnel dst address not specified");
12409 if (grp_set && !ip46_address_is_multicast (&dst))
12411 errmsg ("tunnel group address not multicast");
12414 if (grp_set && mcast_sw_if_index == ~0)
12416 errmsg ("tunnel nonexistent multicast device");
12419 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12421 errmsg ("tunnel dst address must be unicast");
12426 if (ipv4_set && ipv6_set)
12428 errmsg ("both IPv4 and IPv6 addresses specified");
12432 if ((vni == 0) || (vni >> 24))
12434 errmsg ("vni not specified or out of range");
12438 M (GENEVE_ADD_DEL_TUNNEL, mp);
12442 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12443 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12447 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12448 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12450 mp->encap_vrf_id = ntohl (encap_vrf_id);
12451 mp->decap_next_index = ntohl (decap_next_index);
12452 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12453 mp->vni = ntohl (vni);
12454 mp->is_add = is_add;
12461 static void vl_api_geneve_tunnel_details_t_handler
12462 (vl_api_geneve_tunnel_details_t * mp)
12464 vat_main_t *vam = &vat_main;
12465 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12466 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12468 if (mp->src_address.af == ADDRESS_IP6)
12470 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12471 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12475 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12476 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12479 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12480 ntohl (mp->sw_if_index),
12481 format_ip46_address, &src, IP46_TYPE_ANY,
12482 format_ip46_address, &dst, IP46_TYPE_ANY,
12483 ntohl (mp->encap_vrf_id),
12484 ntohl (mp->decap_next_index), ntohl (mp->vni),
12485 ntohl (mp->mcast_sw_if_index));
12488 static void vl_api_geneve_tunnel_details_t_handler_json
12489 (vl_api_geneve_tunnel_details_t * mp)
12491 vat_main_t *vam = &vat_main;
12492 vat_json_node_t *node = NULL;
12495 if (VAT_JSON_ARRAY != vam->json_tree.type)
12497 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12498 vat_json_init_array (&vam->json_tree);
12500 node = vat_json_array_add (&vam->json_tree);
12502 vat_json_init_object (node);
12503 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12504 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12507 struct in6_addr ip6;
12509 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12510 vat_json_object_add_ip6 (node, "src_address", ip6);
12511 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12512 vat_json_object_add_ip6 (node, "dst_address", ip6);
12516 struct in_addr ip4;
12518 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12519 vat_json_object_add_ip4 (node, "src_address", ip4);
12520 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12521 vat_json_object_add_ip4 (node, "dst_address", ip4);
12523 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12524 vat_json_object_add_uint (node, "decap_next_index",
12525 ntohl (mp->decap_next_index));
12526 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12527 vat_json_object_add_uint (node, "mcast_sw_if_index",
12528 ntohl (mp->mcast_sw_if_index));
12532 api_geneve_tunnel_dump (vat_main_t * vam)
12534 unformat_input_t *i = vam->input;
12535 vl_api_geneve_tunnel_dump_t *mp;
12536 vl_api_control_ping_t *mp_ping;
12538 u8 sw_if_index_set = 0;
12541 /* Parse args required to build the message */
12542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12544 if (unformat (i, "sw_if_index %d", &sw_if_index))
12545 sw_if_index_set = 1;
12550 if (sw_if_index_set == 0)
12555 if (!vam->json_output)
12557 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12558 "sw_if_index", "local_address", "remote_address",
12559 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12562 /* Get list of geneve-tunnel interfaces */
12563 M (GENEVE_TUNNEL_DUMP, mp);
12565 mp->sw_if_index = htonl (sw_if_index);
12569 /* Use a control ping for synchronization */
12570 M (CONTROL_PING, mp_ping);
12578 api_gre_tunnel_add_del (vat_main_t * vam)
12580 unformat_input_t *line_input = vam->input;
12581 vl_api_address_t src = { }, dst =
12584 vl_api_gre_tunnel_add_del_t *mp;
12585 vl_api_gre_tunnel_type_t t_type;
12589 u32 outer_fib_id = 0;
12590 u32 session_id = 0;
12594 t_type = GRE_API_TUNNEL_TYPE_L3;
12596 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12598 if (unformat (line_input, "del"))
12600 else if (unformat (line_input, "instance %d", &instance))
12602 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12606 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12610 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12612 else if (unformat (line_input, "teb"))
12613 t_type = GRE_API_TUNNEL_TYPE_TEB;
12614 else if (unformat (line_input, "erspan %d", &session_id))
12615 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12618 errmsg ("parse error '%U'", format_unformat_error, line_input);
12625 errmsg ("tunnel src address not specified");
12630 errmsg ("tunnel dst address not specified");
12634 M (GRE_TUNNEL_ADD_DEL, mp);
12636 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12637 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12639 mp->tunnel.instance = htonl (instance);
12640 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
12641 mp->is_add = is_add;
12642 mp->tunnel.session_id = htons ((u16) session_id);
12643 mp->tunnel.type = htonl (t_type);
12650 static void vl_api_gre_tunnel_details_t_handler
12651 (vl_api_gre_tunnel_details_t * mp)
12653 vat_main_t *vam = &vat_main;
12655 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12656 ntohl (mp->tunnel.sw_if_index),
12657 ntohl (mp->tunnel.instance),
12658 format_vl_api_address, &mp->tunnel.src,
12659 format_vl_api_address, &mp->tunnel.dst,
12660 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
12661 ntohl (mp->tunnel.session_id));
12664 static void vl_api_gre_tunnel_details_t_handler_json
12665 (vl_api_gre_tunnel_details_t * mp)
12667 vat_main_t *vam = &vat_main;
12668 vat_json_node_t *node = NULL;
12670 if (VAT_JSON_ARRAY != vam->json_tree.type)
12672 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12673 vat_json_init_array (&vam->json_tree);
12675 node = vat_json_array_add (&vam->json_tree);
12677 vat_json_init_object (node);
12678 vat_json_object_add_uint (node, "sw_if_index",
12679 ntohl (mp->tunnel.sw_if_index));
12680 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12682 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12683 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12684 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12685 vat_json_object_add_uint (node, "outer_fib_id",
12686 ntohl (mp->tunnel.outer_fib_id));
12687 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12691 api_gre_tunnel_dump (vat_main_t * vam)
12693 unformat_input_t *i = vam->input;
12694 vl_api_gre_tunnel_dump_t *mp;
12695 vl_api_control_ping_t *mp_ping;
12697 u8 sw_if_index_set = 0;
12700 /* Parse args required to build the message */
12701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12703 if (unformat (i, "sw_if_index %d", &sw_if_index))
12704 sw_if_index_set = 1;
12709 if (sw_if_index_set == 0)
12714 if (!vam->json_output)
12716 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12717 "sw_if_index", "instance", "src_address", "dst_address",
12718 "tunnel_type", "outer_fib_id", "session_id");
12721 /* Get list of gre-tunnel interfaces */
12722 M (GRE_TUNNEL_DUMP, mp);
12724 mp->sw_if_index = htonl (sw_if_index);
12728 /* Use a control ping for synchronization */
12729 MPING (CONTROL_PING, mp_ping);
12737 api_l2_fib_clear_table (vat_main_t * vam)
12739 // unformat_input_t * i = vam->input;
12740 vl_api_l2_fib_clear_table_t *mp;
12743 M (L2_FIB_CLEAR_TABLE, mp);
12751 api_l2_interface_efp_filter (vat_main_t * vam)
12753 unformat_input_t *i = vam->input;
12754 vl_api_l2_interface_efp_filter_t *mp;
12757 u8 sw_if_index_set = 0;
12760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12762 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12763 sw_if_index_set = 1;
12764 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12765 sw_if_index_set = 1;
12766 else if (unformat (i, "enable"))
12768 else if (unformat (i, "disable"))
12772 clib_warning ("parse error '%U'", format_unformat_error, i);
12777 if (sw_if_index_set == 0)
12779 errmsg ("missing sw_if_index");
12783 M (L2_INTERFACE_EFP_FILTER, mp);
12785 mp->sw_if_index = ntohl (sw_if_index);
12786 mp->enable_disable = enable;
12793 #define foreach_vtr_op \
12794 _("disable", L2_VTR_DISABLED) \
12795 _("push-1", L2_VTR_PUSH_1) \
12796 _("push-2", L2_VTR_PUSH_2) \
12797 _("pop-1", L2_VTR_POP_1) \
12798 _("pop-2", L2_VTR_POP_2) \
12799 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12800 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12801 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12802 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12805 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12807 unformat_input_t *i = vam->input;
12808 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12810 u8 sw_if_index_set = 0;
12813 u32 push_dot1q = 1;
12818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12820 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12821 sw_if_index_set = 1;
12822 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12823 sw_if_index_set = 1;
12824 else if (unformat (i, "vtr_op %d", &vtr_op))
12826 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12829 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12831 else if (unformat (i, "tag1 %d", &tag1))
12833 else if (unformat (i, "tag2 %d", &tag2))
12837 clib_warning ("parse error '%U'", format_unformat_error, i);
12842 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12844 errmsg ("missing vtr operation or sw_if_index");
12848 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12849 mp->sw_if_index = ntohl (sw_if_index);
12850 mp->vtr_op = ntohl (vtr_op);
12851 mp->push_dot1q = ntohl (push_dot1q);
12852 mp->tag1 = ntohl (tag1);
12853 mp->tag2 = ntohl (tag2);
12861 api_create_vhost_user_if (vat_main_t * vam)
12863 unformat_input_t *i = vam->input;
12864 vl_api_create_vhost_user_if_t *mp;
12867 u8 file_name_set = 0;
12868 u32 custom_dev_instance = ~0;
12870 u8 use_custom_mac = 0;
12871 u8 disable_mrg_rxbuf = 0;
12872 u8 disable_indirect_desc = 0;
12877 /* Shut up coverity */
12878 clib_memset (hwaddr, 0, sizeof (hwaddr));
12880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12882 if (unformat (i, "socket %s", &file_name))
12886 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12888 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12889 use_custom_mac = 1;
12890 else if (unformat (i, "server"))
12892 else if (unformat (i, "disable_mrg_rxbuf"))
12893 disable_mrg_rxbuf = 1;
12894 else if (unformat (i, "disable_indirect_desc"))
12895 disable_indirect_desc = 1;
12896 else if (unformat (i, "gso"))
12898 else if (unformat (i, "tag %s", &tag))
12904 if (file_name_set == 0)
12906 errmsg ("missing socket file name");
12910 if (vec_len (file_name) > 255)
12912 errmsg ("socket file name too long");
12915 vec_add1 (file_name, 0);
12917 M (CREATE_VHOST_USER_IF, mp);
12919 mp->is_server = is_server;
12920 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12921 mp->disable_indirect_desc = disable_indirect_desc;
12922 mp->enable_gso = enable_gso;
12923 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12924 vec_free (file_name);
12925 if (custom_dev_instance != ~0)
12928 mp->custom_dev_instance = ntohl (custom_dev_instance);
12931 mp->use_custom_mac = use_custom_mac;
12932 clib_memcpy (mp->mac_address, hwaddr, 6);
12934 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12943 api_modify_vhost_user_if (vat_main_t * vam)
12945 unformat_input_t *i = vam->input;
12946 vl_api_modify_vhost_user_if_t *mp;
12949 u8 file_name_set = 0;
12950 u32 custom_dev_instance = ~0;
12951 u8 sw_if_index_set = 0;
12952 u32 sw_if_index = (u32) ~ 0;
12956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12958 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12959 sw_if_index_set = 1;
12960 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12961 sw_if_index_set = 1;
12962 else if (unformat (i, "socket %s", &file_name))
12966 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12968 else if (unformat (i, "server"))
12970 else if (unformat (i, "gso"))
12976 if (sw_if_index_set == 0)
12978 errmsg ("missing sw_if_index or interface name");
12982 if (file_name_set == 0)
12984 errmsg ("missing socket file name");
12988 if (vec_len (file_name) > 255)
12990 errmsg ("socket file name too long");
12993 vec_add1 (file_name, 0);
12995 M (MODIFY_VHOST_USER_IF, mp);
12997 mp->sw_if_index = ntohl (sw_if_index);
12998 mp->is_server = is_server;
12999 mp->enable_gso = enable_gso;
13000 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13001 vec_free (file_name);
13002 if (custom_dev_instance != ~0)
13005 mp->custom_dev_instance = ntohl (custom_dev_instance);
13014 api_delete_vhost_user_if (vat_main_t * vam)
13016 unformat_input_t *i = vam->input;
13017 vl_api_delete_vhost_user_if_t *mp;
13018 u32 sw_if_index = ~0;
13019 u8 sw_if_index_set = 0;
13022 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13024 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13025 sw_if_index_set = 1;
13026 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13027 sw_if_index_set = 1;
13032 if (sw_if_index_set == 0)
13034 errmsg ("missing sw_if_index or interface name");
13039 M (DELETE_VHOST_USER_IF, mp);
13041 mp->sw_if_index = ntohl (sw_if_index);
13048 static void vl_api_sw_interface_vhost_user_details_t_handler
13049 (vl_api_sw_interface_vhost_user_details_t * mp)
13051 vat_main_t *vam = &vat_main;
13053 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13054 (char *) mp->interface_name,
13055 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13056 clib_net_to_host_u64 (mp->features), mp->is_server,
13057 ntohl (mp->num_regions), (char *) mp->sock_filename);
13058 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13061 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13062 (vl_api_sw_interface_vhost_user_details_t * mp)
13064 vat_main_t *vam = &vat_main;
13065 vat_json_node_t *node = NULL;
13067 if (VAT_JSON_ARRAY != vam->json_tree.type)
13069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13070 vat_json_init_array (&vam->json_tree);
13072 node = vat_json_array_add (&vam->json_tree);
13074 vat_json_init_object (node);
13075 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13076 vat_json_object_add_string_copy (node, "interface_name",
13077 mp->interface_name);
13078 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13079 ntohl (mp->virtio_net_hdr_sz));
13080 vat_json_object_add_uint (node, "features",
13081 clib_net_to_host_u64 (mp->features));
13082 vat_json_object_add_uint (node, "is_server", mp->is_server);
13083 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13084 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13085 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13089 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13091 vl_api_sw_interface_vhost_user_dump_t *mp;
13092 vl_api_control_ping_t *mp_ping;
13095 "Interface name idx hdr_sz features server regions filename");
13097 /* Get list of vhost-user interfaces */
13098 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13101 /* Use a control ping for synchronization */
13102 MPING (CONTROL_PING, mp_ping);
13110 api_show_version (vat_main_t * vam)
13112 vl_api_show_version_t *mp;
13115 M (SHOW_VERSION, mp);
13124 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13126 unformat_input_t *line_input = vam->input;
13127 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13128 ip4_address_t local4, remote4;
13129 ip6_address_t local6, remote6;
13131 u8 ipv4_set = 0, ipv6_set = 0;
13135 u32 mcast_sw_if_index = ~0;
13136 u32 encap_vrf_id = 0;
13137 u32 decap_vrf_id = 0;
13143 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13144 clib_memset (&local4, 0, sizeof local4);
13145 clib_memset (&remote4, 0, sizeof remote4);
13146 clib_memset (&local6, 0, sizeof local6);
13147 clib_memset (&remote6, 0, sizeof remote6);
13149 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13151 if (unformat (line_input, "del"))
13153 else if (unformat (line_input, "local %U",
13154 unformat_ip4_address, &local4))
13159 else if (unformat (line_input, "remote %U",
13160 unformat_ip4_address, &remote4))
13165 else if (unformat (line_input, "local %U",
13166 unformat_ip6_address, &local6))
13171 else if (unformat (line_input, "remote %U",
13172 unformat_ip6_address, &remote6))
13177 else if (unformat (line_input, "group %U %U",
13178 unformat_ip4_address, &remote4,
13179 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13181 grp_set = remote_set = 1;
13184 else if (unformat (line_input, "group %U",
13185 unformat_ip4_address, &remote4))
13187 grp_set = remote_set = 1;
13190 else if (unformat (line_input, "group %U %U",
13191 unformat_ip6_address, &remote6,
13192 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13194 grp_set = remote_set = 1;
13197 else if (unformat (line_input, "group %U",
13198 unformat_ip6_address, &remote6))
13200 grp_set = remote_set = 1;
13204 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13206 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13208 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13210 else if (unformat (line_input, "vni %d", &vni))
13212 else if (unformat (line_input, "next-ip4"))
13214 else if (unformat (line_input, "next-ip6"))
13216 else if (unformat (line_input, "next-ethernet"))
13218 else if (unformat (line_input, "next-nsh"))
13222 errmsg ("parse error '%U'", format_unformat_error, line_input);
13227 if (local_set == 0)
13229 errmsg ("tunnel local address not specified");
13232 if (remote_set == 0)
13234 errmsg ("tunnel remote address not specified");
13237 if (grp_set && mcast_sw_if_index == ~0)
13239 errmsg ("tunnel nonexistent multicast device");
13242 if (ipv4_set && ipv6_set)
13244 errmsg ("both IPv4 and IPv6 addresses specified");
13250 errmsg ("vni not specified");
13254 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13259 clib_memcpy (&mp->local, &local6, sizeof (local6));
13260 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13264 clib_memcpy (&mp->local, &local4, sizeof (local4));
13265 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13268 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13269 mp->encap_vrf_id = ntohl (encap_vrf_id);
13270 mp->decap_vrf_id = ntohl (decap_vrf_id);
13271 mp->protocol = protocol;
13272 mp->vni = ntohl (vni);
13273 mp->is_add = is_add;
13274 mp->is_ipv6 = ipv6_set;
13281 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13282 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13284 vat_main_t *vam = &vat_main;
13285 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13286 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13288 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13289 ntohl (mp->sw_if_index),
13290 format_ip46_address, &local, IP46_TYPE_ANY,
13291 format_ip46_address, &remote, IP46_TYPE_ANY,
13292 ntohl (mp->vni), mp->protocol,
13293 ntohl (mp->mcast_sw_if_index),
13294 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13298 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13299 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13301 vat_main_t *vam = &vat_main;
13302 vat_json_node_t *node = NULL;
13303 struct in_addr ip4;
13304 struct in6_addr ip6;
13306 if (VAT_JSON_ARRAY != vam->json_tree.type)
13308 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13309 vat_json_init_array (&vam->json_tree);
13311 node = vat_json_array_add (&vam->json_tree);
13313 vat_json_init_object (node);
13314 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13317 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13318 vat_json_object_add_ip6 (node, "local", ip6);
13319 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13320 vat_json_object_add_ip6 (node, "remote", ip6);
13324 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13325 vat_json_object_add_ip4 (node, "local", ip4);
13326 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13327 vat_json_object_add_ip4 (node, "remote", ip4);
13329 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13330 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13331 vat_json_object_add_uint (node, "mcast_sw_if_index",
13332 ntohl (mp->mcast_sw_if_index));
13333 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13334 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13335 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13339 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13341 unformat_input_t *i = vam->input;
13342 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13343 vl_api_control_ping_t *mp_ping;
13345 u8 sw_if_index_set = 0;
13348 /* Parse args required to build the message */
13349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13351 if (unformat (i, "sw_if_index %d", &sw_if_index))
13352 sw_if_index_set = 1;
13357 if (sw_if_index_set == 0)
13362 if (!vam->json_output)
13364 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13365 "sw_if_index", "local", "remote", "vni",
13366 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13369 /* Get list of vxlan-tunnel interfaces */
13370 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13372 mp->sw_if_index = htonl (sw_if_index);
13376 /* Use a control ping for synchronization */
13377 MPING (CONTROL_PING, mp_ping);
13384 static void vl_api_l2_fib_table_details_t_handler
13385 (vl_api_l2_fib_table_details_t * mp)
13387 vat_main_t *vam = &vat_main;
13389 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13391 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13392 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13396 static void vl_api_l2_fib_table_details_t_handler_json
13397 (vl_api_l2_fib_table_details_t * mp)
13399 vat_main_t *vam = &vat_main;
13400 vat_json_node_t *node = NULL;
13402 if (VAT_JSON_ARRAY != vam->json_tree.type)
13404 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13405 vat_json_init_array (&vam->json_tree);
13407 node = vat_json_array_add (&vam->json_tree);
13409 vat_json_init_object (node);
13410 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13411 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13412 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13413 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13414 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13415 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13419 api_l2_fib_table_dump (vat_main_t * vam)
13421 unformat_input_t *i = vam->input;
13422 vl_api_l2_fib_table_dump_t *mp;
13423 vl_api_control_ping_t *mp_ping;
13428 /* Parse args required to build the message */
13429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13431 if (unformat (i, "bd_id %d", &bd_id))
13437 if (bd_id_set == 0)
13439 errmsg ("missing bridge domain");
13443 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13445 /* Get list of l2 fib entries */
13446 M (L2_FIB_TABLE_DUMP, mp);
13448 mp->bd_id = ntohl (bd_id);
13451 /* Use a control ping for synchronization */
13452 MPING (CONTROL_PING, mp_ping);
13461 api_interface_name_renumber (vat_main_t * vam)
13463 unformat_input_t *line_input = vam->input;
13464 vl_api_interface_name_renumber_t *mp;
13465 u32 sw_if_index = ~0;
13466 u32 new_show_dev_instance = ~0;
13469 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13471 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13474 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13476 else if (unformat (line_input, "new_show_dev_instance %d",
13477 &new_show_dev_instance))
13483 if (sw_if_index == ~0)
13485 errmsg ("missing interface name or sw_if_index");
13489 if (new_show_dev_instance == ~0)
13491 errmsg ("missing new_show_dev_instance");
13495 M (INTERFACE_NAME_RENUMBER, mp);
13497 mp->sw_if_index = ntohl (sw_if_index);
13498 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13506 api_ip_probe_neighbor (vat_main_t * vam)
13508 unformat_input_t *i = vam->input;
13509 vl_api_ip_probe_neighbor_t *mp;
13510 vl_api_address_t dst_adr = { };
13516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13518 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13520 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13522 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13530 errmsg ("missing interface");
13536 errmsg ("missing addresses");
13540 M (IP_PROBE_NEIGHBOR, mp);
13542 mp->sw_if_index = ntohl (sw_if_index);
13543 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13551 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13553 unformat_input_t *i = vam->input;
13554 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13555 u8 mode = IP_SCAN_V46_NEIGHBORS;
13556 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13561 if (unformat (i, "ip4"))
13562 mode = IP_SCAN_V4_NEIGHBORS;
13563 else if (unformat (i, "ip6"))
13564 mode = IP_SCAN_V6_NEIGHBORS;
13565 if (unformat (i, "both"))
13566 mode = IP_SCAN_V46_NEIGHBORS;
13567 else if (unformat (i, "disable"))
13568 mode = IP_SCAN_DISABLED;
13569 else if (unformat (i, "interval %d", &interval))
13571 else if (unformat (i, "max-time %d", &time))
13573 else if (unformat (i, "max-update %d", &update))
13575 else if (unformat (i, "delay %d", &delay))
13577 else if (unformat (i, "stale %d", &stale))
13583 if (interval > 255)
13585 errmsg ("interval cannot exceed 255 minutes.");
13590 errmsg ("max-time cannot exceed 255 usec.");
13595 errmsg ("max-update cannot exceed 255.");
13600 errmsg ("delay cannot exceed 255 msec.");
13605 errmsg ("stale cannot exceed 255 minutes.");
13609 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13611 mp->scan_interval = interval;
13612 mp->max_proc_time = time;
13613 mp->max_update = update;
13614 mp->scan_int_delay = delay;
13615 mp->stale_threshold = stale;
13623 api_want_ip4_arp_events (vat_main_t * vam)
13625 unformat_input_t *line_input = vam->input;
13626 vl_api_want_ip4_arp_events_t *mp;
13627 ip4_address_t address;
13628 int address_set = 0;
13629 u32 enable_disable = 1;
13632 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13634 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13636 else if (unformat (line_input, "del"))
13637 enable_disable = 0;
13642 if (address_set == 0)
13644 errmsg ("missing addresses");
13648 M (WANT_IP4_ARP_EVENTS, mp);
13649 mp->enable_disable = enable_disable;
13650 mp->pid = htonl (getpid ());
13651 clib_memcpy (mp->ip, &address, sizeof (address));
13659 api_want_ip6_nd_events (vat_main_t * vam)
13661 unformat_input_t *line_input = vam->input;
13662 vl_api_want_ip6_nd_events_t *mp;
13663 vl_api_ip6_address_t address;
13664 int address_set = 0;
13665 u32 enable_disable = 1;
13668 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13671 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
13673 else if (unformat (line_input, "del"))
13674 enable_disable = 0;
13679 if (address_set == 0)
13681 errmsg ("missing addresses");
13685 M (WANT_IP6_ND_EVENTS, mp);
13686 mp->enable_disable = enable_disable;
13687 mp->pid = htonl (getpid ());
13688 clib_memcpy (&mp->ip, &address, sizeof (address));
13696 api_want_l2_macs_events (vat_main_t * vam)
13698 unformat_input_t *line_input = vam->input;
13699 vl_api_want_l2_macs_events_t *mp;
13700 u8 enable_disable = 1;
13701 u32 scan_delay = 0;
13702 u32 max_macs_in_event = 0;
13703 u32 learn_limit = 0;
13706 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13708 if (unformat (line_input, "learn-limit %d", &learn_limit))
13710 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13712 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13714 else if (unformat (line_input, "disable"))
13715 enable_disable = 0;
13720 M (WANT_L2_MACS_EVENTS, mp);
13721 mp->enable_disable = enable_disable;
13722 mp->pid = htonl (getpid ());
13723 mp->learn_limit = htonl (learn_limit);
13724 mp->scan_delay = (u8) scan_delay;
13725 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13732 api_input_acl_set_interface (vat_main_t * vam)
13734 unformat_input_t *i = vam->input;
13735 vl_api_input_acl_set_interface_t *mp;
13737 int sw_if_index_set;
13738 u32 ip4_table_index = ~0;
13739 u32 ip6_table_index = ~0;
13740 u32 l2_table_index = ~0;
13744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13747 sw_if_index_set = 1;
13748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13749 sw_if_index_set = 1;
13750 else if (unformat (i, "del"))
13752 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13754 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13756 else if (unformat (i, "l2-table %d", &l2_table_index))
13760 clib_warning ("parse error '%U'", format_unformat_error, i);
13765 if (sw_if_index_set == 0)
13767 errmsg ("missing interface name or sw_if_index");
13771 M (INPUT_ACL_SET_INTERFACE, mp);
13773 mp->sw_if_index = ntohl (sw_if_index);
13774 mp->ip4_table_index = ntohl (ip4_table_index);
13775 mp->ip6_table_index = ntohl (ip6_table_index);
13776 mp->l2_table_index = ntohl (l2_table_index);
13777 mp->is_add = is_add;
13785 api_output_acl_set_interface (vat_main_t * vam)
13787 unformat_input_t *i = vam->input;
13788 vl_api_output_acl_set_interface_t *mp;
13790 int sw_if_index_set;
13791 u32 ip4_table_index = ~0;
13792 u32 ip6_table_index = ~0;
13793 u32 l2_table_index = ~0;
13797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13799 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13800 sw_if_index_set = 1;
13801 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13802 sw_if_index_set = 1;
13803 else if (unformat (i, "del"))
13805 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13807 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13809 else if (unformat (i, "l2-table %d", &l2_table_index))
13813 clib_warning ("parse error '%U'", format_unformat_error, i);
13818 if (sw_if_index_set == 0)
13820 errmsg ("missing interface name or sw_if_index");
13824 M (OUTPUT_ACL_SET_INTERFACE, mp);
13826 mp->sw_if_index = ntohl (sw_if_index);
13827 mp->ip4_table_index = ntohl (ip4_table_index);
13828 mp->ip6_table_index = ntohl (ip6_table_index);
13829 mp->l2_table_index = ntohl (l2_table_index);
13830 mp->is_add = is_add;
13838 api_ip_address_dump (vat_main_t * vam)
13840 unformat_input_t *i = vam->input;
13841 vl_api_ip_address_dump_t *mp;
13842 vl_api_control_ping_t *mp_ping;
13843 u32 sw_if_index = ~0;
13844 u8 sw_if_index_set = 0;
13849 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13851 if (unformat (i, "sw_if_index %d", &sw_if_index))
13852 sw_if_index_set = 1;
13854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13855 sw_if_index_set = 1;
13856 else if (unformat (i, "ipv4"))
13858 else if (unformat (i, "ipv6"))
13864 if (ipv4_set && ipv6_set)
13866 errmsg ("ipv4 and ipv6 flags cannot be both set");
13870 if ((!ipv4_set) && (!ipv6_set))
13872 errmsg ("no ipv4 nor ipv6 flag set");
13876 if (sw_if_index_set == 0)
13878 errmsg ("missing interface name or sw_if_index");
13882 vam->current_sw_if_index = sw_if_index;
13883 vam->is_ipv6 = ipv6_set;
13885 M (IP_ADDRESS_DUMP, mp);
13886 mp->sw_if_index = ntohl (sw_if_index);
13887 mp->is_ipv6 = ipv6_set;
13890 /* Use a control ping for synchronization */
13891 MPING (CONTROL_PING, mp_ping);
13899 api_ip_dump (vat_main_t * vam)
13901 vl_api_ip_dump_t *mp;
13902 vl_api_control_ping_t *mp_ping;
13903 unformat_input_t *in = vam->input;
13910 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13912 if (unformat (in, "ipv4"))
13914 else if (unformat (in, "ipv6"))
13920 if (ipv4_set && ipv6_set)
13922 errmsg ("ipv4 and ipv6 flags cannot be both set");
13926 if ((!ipv4_set) && (!ipv6_set))
13928 errmsg ("no ipv4 nor ipv6 flag set");
13932 is_ipv6 = ipv6_set;
13933 vam->is_ipv6 = is_ipv6;
13935 /* free old data */
13936 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13938 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13940 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13943 mp->is_ipv6 = ipv6_set;
13946 /* Use a control ping for synchronization */
13947 MPING (CONTROL_PING, mp_ping);
13955 api_ipsec_spd_add_del (vat_main_t * vam)
13957 unformat_input_t *i = vam->input;
13958 vl_api_ipsec_spd_add_del_t *mp;
13963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13965 if (unformat (i, "spd_id %d", &spd_id))
13967 else if (unformat (i, "del"))
13971 clib_warning ("parse error '%U'", format_unformat_error, i);
13977 errmsg ("spd_id must be set");
13981 M (IPSEC_SPD_ADD_DEL, mp);
13983 mp->spd_id = ntohl (spd_id);
13984 mp->is_add = is_add;
13992 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13994 unformat_input_t *i = vam->input;
13995 vl_api_ipsec_interface_add_del_spd_t *mp;
13997 u8 sw_if_index_set = 0;
13998 u32 spd_id = (u32) ~ 0;
14002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14004 if (unformat (i, "del"))
14006 else if (unformat (i, "spd_id %d", &spd_id))
14009 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14010 sw_if_index_set = 1;
14011 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14012 sw_if_index_set = 1;
14015 clib_warning ("parse error '%U'", format_unformat_error, i);
14021 if (spd_id == (u32) ~ 0)
14023 errmsg ("spd_id must be set");
14027 if (sw_if_index_set == 0)
14029 errmsg ("missing interface name or sw_if_index");
14033 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14035 mp->spd_id = ntohl (spd_id);
14036 mp->sw_if_index = ntohl (sw_if_index);
14037 mp->is_add = is_add;
14045 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14047 unformat_input_t *i = vam->input;
14048 vl_api_ipsec_spd_entry_add_del_t *mp;
14049 u8 is_add = 1, is_outbound = 0;
14050 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14052 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14053 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14054 vl_api_address_t laddr_start = { }, laddr_stop =
14063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14065 if (unformat (i, "del"))
14067 if (unformat (i, "outbound"))
14069 if (unformat (i, "inbound"))
14071 else if (unformat (i, "spd_id %d", &spd_id))
14073 else if (unformat (i, "sa_id %d", &sa_id))
14075 else if (unformat (i, "priority %d", &priority))
14077 else if (unformat (i, "protocol %d", &protocol))
14079 else if (unformat (i, "lport_start %d", &lport_start))
14081 else if (unformat (i, "lport_stop %d", &lport_stop))
14083 else if (unformat (i, "rport_start %d", &rport_start))
14085 else if (unformat (i, "rport_stop %d", &rport_stop))
14087 else if (unformat (i, "laddr_start %U",
14088 unformat_vl_api_address, &laddr_start))
14090 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14093 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14096 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14100 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14102 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14104 clib_warning ("unsupported action: 'resolve'");
14110 clib_warning ("parse error '%U'", format_unformat_error, i);
14116 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14118 mp->is_add = is_add;
14120 mp->entry.spd_id = ntohl (spd_id);
14121 mp->entry.priority = ntohl (priority);
14122 mp->entry.is_outbound = is_outbound;
14124 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14125 sizeof (vl_api_address_t));
14126 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14127 sizeof (vl_api_address_t));
14128 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14129 sizeof (vl_api_address_t));
14130 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14131 sizeof (vl_api_address_t));
14133 mp->entry.protocol = (u8) protocol;
14134 mp->entry.local_port_start = ntohs ((u16) lport_start);
14135 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14136 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14137 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14138 mp->entry.policy = (u8) policy;
14139 mp->entry.sa_id = ntohl (sa_id);
14147 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14149 unformat_input_t *i = vam->input;
14150 vl_api_ipsec_sad_entry_add_del_t *mp;
14151 u32 sad_id = 0, spi = 0;
14152 u8 *ck = 0, *ik = 0;
14155 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14156 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14157 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14158 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14159 vl_api_address_t tun_src, tun_dst;
14162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14164 if (unformat (i, "del"))
14166 else if (unformat (i, "sad_id %d", &sad_id))
14168 else if (unformat (i, "spi %d", &spi))
14170 else if (unformat (i, "esp"))
14171 protocol = IPSEC_API_PROTO_ESP;
14173 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14175 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14176 if (ADDRESS_IP6 == tun_src.af)
14177 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14180 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14182 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14183 if (ADDRESS_IP6 == tun_src.af)
14184 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14187 if (unformat (i, "crypto_alg %U",
14188 unformat_ipsec_api_crypto_alg, &crypto_alg))
14190 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14192 else if (unformat (i, "integ_alg %U",
14193 unformat_ipsec_api_integ_alg, &integ_alg))
14195 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14199 clib_warning ("parse error '%U'", format_unformat_error, i);
14205 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14207 mp->is_add = is_add;
14208 mp->entry.sad_id = ntohl (sad_id);
14209 mp->entry.protocol = protocol;
14210 mp->entry.spi = ntohl (spi);
14211 mp->entry.flags = flags;
14213 mp->entry.crypto_algorithm = crypto_alg;
14214 mp->entry.integrity_algorithm = integ_alg;
14215 mp->entry.crypto_key.length = vec_len (ck);
14216 mp->entry.integrity_key.length = vec_len (ik);
14218 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14219 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14221 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14222 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14225 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14227 clib_memcpy (mp->entry.integrity_key.data, ik,
14228 mp->entry.integrity_key.length);
14230 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14232 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14233 sizeof (mp->entry.tunnel_src));
14234 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14235 sizeof (mp->entry.tunnel_dst));
14244 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14246 unformat_input_t *i = vam->input;
14247 vl_api_ipsec_tunnel_if_add_del_t *mp;
14248 u32 local_spi = 0, remote_spi = 0;
14249 u32 crypto_alg = 0, integ_alg = 0;
14250 u8 *lck = NULL, *rck = NULL;
14251 u8 *lik = NULL, *rik = NULL;
14252 vl_api_address_t local_ip = { 0 };
14253 vl_api_address_t remote_ip = { 0 };
14257 u8 anti_replay = 0;
14263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14265 if (unformat (i, "del"))
14267 else if (unformat (i, "esn"))
14269 else if (unformat (i, "anti-replay"))
14271 else if (unformat (i, "count %d", &count))
14273 else if (unformat (i, "local_spi %d", &local_spi))
14275 else if (unformat (i, "remote_spi %d", &remote_spi))
14278 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14281 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14283 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14286 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14288 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14290 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14294 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14296 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14298 errmsg ("unsupported crypto-alg: '%U'\n",
14299 format_ipsec_crypto_alg, crypto_alg);
14305 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14307 if (integ_alg >= IPSEC_INTEG_N_ALG)
14309 errmsg ("unsupported integ-alg: '%U'\n",
14310 format_ipsec_integ_alg, integ_alg);
14314 else if (unformat (i, "instance %u", &instance))
14318 errmsg ("parse error '%U'\n", format_unformat_error, i);
14325 /* Turn on async mode */
14326 vam->async_mode = 1;
14327 vam->async_errors = 0;
14328 before = vat_time_now (vam);
14331 for (jj = 0; jj < count; jj++)
14333 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14335 mp->is_add = is_add;
14337 mp->anti_replay = anti_replay;
14340 increment_address (&remote_ip);
14342 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14343 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14345 mp->local_spi = htonl (local_spi + jj);
14346 mp->remote_spi = htonl (remote_spi + jj);
14347 mp->crypto_alg = (u8) crypto_alg;
14349 mp->local_crypto_key_len = 0;
14352 mp->local_crypto_key_len = vec_len (lck);
14353 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14354 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14355 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14358 mp->remote_crypto_key_len = 0;
14361 mp->remote_crypto_key_len = vec_len (rck);
14362 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14363 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14364 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14367 mp->integ_alg = (u8) integ_alg;
14369 mp->local_integ_key_len = 0;
14372 mp->local_integ_key_len = vec_len (lik);
14373 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14374 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14375 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14378 mp->remote_integ_key_len = 0;
14381 mp->remote_integ_key_len = vec_len (rik);
14382 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14383 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14384 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14389 mp->renumber = renumber;
14390 mp->show_instance = ntohl (instance);
14395 /* When testing multiple add/del ops, use a control-ping to sync */
14398 vl_api_control_ping_t *mp_ping;
14402 /* Shut off async mode */
14403 vam->async_mode = 0;
14405 MPING (CONTROL_PING, mp_ping);
14408 timeout = vat_time_now (vam) + 1.0;
14409 while (vat_time_now (vam) < timeout)
14410 if (vam->result_ready == 1)
14415 if (vam->retval == -99)
14416 errmsg ("timeout");
14418 if (vam->async_errors > 0)
14420 errmsg ("%d asynchronous errors", vam->async_errors);
14423 vam->async_errors = 0;
14424 after = vat_time_now (vam);
14426 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14430 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14431 count, after - before, count / (after - before));
14435 /* Wait for a reply... */
14444 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14446 vat_main_t *vam = &vat_main;
14448 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14449 "crypto_key %U integ_alg %u integ_key %U flags %x "
14450 "tunnel_src_addr %U tunnel_dst_addr %U "
14451 "salt %u seq_outbound %lu last_seq_inbound %lu "
14452 "replay_window %lu\n",
14453 ntohl (mp->entry.sad_id),
14454 ntohl (mp->sw_if_index),
14455 ntohl (mp->entry.spi),
14456 ntohl (mp->entry.protocol),
14457 ntohl (mp->entry.crypto_algorithm),
14458 format_hex_bytes, mp->entry.crypto_key.data,
14459 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14460 format_hex_bytes, mp->entry.integrity_key.data,
14461 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14462 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14463 &mp->entry.tunnel_dst, ntohl (mp->salt),
14464 clib_net_to_host_u64 (mp->seq_outbound),
14465 clib_net_to_host_u64 (mp->last_seq_inbound),
14466 clib_net_to_host_u64 (mp->replay_window));
14469 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14470 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14472 static void vl_api_ipsec_sa_details_t_handler_json
14473 (vl_api_ipsec_sa_details_t * mp)
14475 vat_main_t *vam = &vat_main;
14476 vat_json_node_t *node = NULL;
14477 vl_api_ipsec_sad_flags_t flags;
14479 if (VAT_JSON_ARRAY != vam->json_tree.type)
14481 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14482 vat_json_init_array (&vam->json_tree);
14484 node = vat_json_array_add (&vam->json_tree);
14486 vat_json_init_object (node);
14487 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14488 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14489 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14490 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14491 vat_json_object_add_uint (node, "crypto_alg",
14492 ntohl (mp->entry.crypto_algorithm));
14493 vat_json_object_add_uint (node, "integ_alg",
14494 ntohl (mp->entry.integrity_algorithm));
14495 flags = ntohl (mp->entry.flags);
14496 vat_json_object_add_uint (node, "use_esn",
14497 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14498 vat_json_object_add_uint (node, "use_anti_replay",
14499 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14500 vat_json_object_add_uint (node, "is_tunnel",
14501 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14502 vat_json_object_add_uint (node, "is_tunnel_ip6",
14503 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14504 vat_json_object_add_uint (node, "udp_encap",
14505 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14506 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14507 mp->entry.crypto_key.length);
14508 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14509 mp->entry.integrity_key.length);
14510 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14511 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14512 vat_json_object_add_uint (node, "replay_window",
14513 clib_net_to_host_u64 (mp->replay_window));
14517 api_ipsec_sa_dump (vat_main_t * vam)
14519 unformat_input_t *i = vam->input;
14520 vl_api_ipsec_sa_dump_t *mp;
14521 vl_api_control_ping_t *mp_ping;
14525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14527 if (unformat (i, "sa_id %d", &sa_id))
14531 clib_warning ("parse error '%U'", format_unformat_error, i);
14536 M (IPSEC_SA_DUMP, mp);
14538 mp->sa_id = ntohl (sa_id);
14542 /* Use a control ping for synchronization */
14543 M (CONTROL_PING, mp_ping);
14551 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14553 unformat_input_t *i = vam->input;
14554 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14555 u32 sw_if_index = ~0;
14557 u8 is_outbound = (u8) ~ 0;
14560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14562 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14564 else if (unformat (i, "sa_id %d", &sa_id))
14566 else if (unformat (i, "outbound"))
14568 else if (unformat (i, "inbound"))
14572 clib_warning ("parse error '%U'", format_unformat_error, i);
14577 if (sw_if_index == ~0)
14579 errmsg ("interface must be specified");
14585 errmsg ("SA ID must be specified");
14589 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14591 mp->sw_if_index = htonl (sw_if_index);
14592 mp->sa_id = htonl (sa_id);
14593 mp->is_outbound = is_outbound;
14602 api_get_first_msg_id (vat_main_t * vam)
14604 vl_api_get_first_msg_id_t *mp;
14605 unformat_input_t *i = vam->input;
14610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14612 if (unformat (i, "client %s", &name))
14620 errmsg ("missing client name");
14623 vec_add1 (name, 0);
14625 if (vec_len (name) > 63)
14627 errmsg ("client name too long");
14631 M (GET_FIRST_MSG_ID, mp);
14632 clib_memcpy (mp->name, name, vec_len (name));
14639 api_cop_interface_enable_disable (vat_main_t * vam)
14641 unformat_input_t *line_input = vam->input;
14642 vl_api_cop_interface_enable_disable_t *mp;
14643 u32 sw_if_index = ~0;
14644 u8 enable_disable = 1;
14647 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14649 if (unformat (line_input, "disable"))
14650 enable_disable = 0;
14651 if (unformat (line_input, "enable"))
14652 enable_disable = 1;
14653 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14654 vam, &sw_if_index))
14656 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14662 if (sw_if_index == ~0)
14664 errmsg ("missing interface name or sw_if_index");
14668 /* Construct the API message */
14669 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14670 mp->sw_if_index = ntohl (sw_if_index);
14671 mp->enable_disable = enable_disable;
14675 /* Wait for the reply */
14681 api_cop_whitelist_enable_disable (vat_main_t * vam)
14683 unformat_input_t *line_input = vam->input;
14684 vl_api_cop_whitelist_enable_disable_t *mp;
14685 u32 sw_if_index = ~0;
14686 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14690 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14692 if (unformat (line_input, "ip4"))
14694 else if (unformat (line_input, "ip6"))
14696 else if (unformat (line_input, "default"))
14698 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14699 vam, &sw_if_index))
14701 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14703 else if (unformat (line_input, "fib-id %d", &fib_id))
14709 if (sw_if_index == ~0)
14711 errmsg ("missing interface name or sw_if_index");
14715 /* Construct the API message */
14716 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14717 mp->sw_if_index = ntohl (sw_if_index);
14718 mp->fib_id = ntohl (fib_id);
14721 mp->default_cop = default_cop;
14725 /* Wait for the reply */
14731 api_get_node_graph (vat_main_t * vam)
14733 vl_api_get_node_graph_t *mp;
14736 M (GET_NODE_GRAPH, mp);
14740 /* Wait for the reply */
14746 /** Used for parsing LISP eids */
14747 typedef CLIB_PACKED(struct{
14748 u8 addr[16]; /**< eid address */
14749 u32 len; /**< prefix length if IP */
14750 u8 type; /**< type of eid */
14755 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14757 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14759 clib_memset (a, 0, sizeof (a[0]));
14761 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14763 a->type = 0; /* ipv4 type */
14765 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14767 a->type = 1; /* ipv6 type */
14769 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14771 a->type = 2; /* mac type */
14773 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14775 a->type = 3; /* NSH type */
14776 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14777 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14784 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14793 lisp_eid_size_vat (u8 type)
14810 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14812 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14816 api_one_add_del_locator_set (vat_main_t * vam)
14818 unformat_input_t *input = vam->input;
14819 vl_api_one_add_del_locator_set_t *mp;
14821 u8 *locator_set_name = NULL;
14822 u8 locator_set_name_set = 0;
14823 vl_api_local_locator_t locator, *locators = 0;
14824 u32 sw_if_index, priority, weight;
14828 /* Parse args required to build the message */
14829 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14831 if (unformat (input, "del"))
14835 else if (unformat (input, "locator-set %s", &locator_set_name))
14837 locator_set_name_set = 1;
14839 else if (unformat (input, "sw_if_index %u p %u w %u",
14840 &sw_if_index, &priority, &weight))
14842 locator.sw_if_index = htonl (sw_if_index);
14843 locator.priority = priority;
14844 locator.weight = weight;
14845 vec_add1 (locators, locator);
14849 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14850 &sw_if_index, &priority, &weight))
14852 locator.sw_if_index = htonl (sw_if_index);
14853 locator.priority = priority;
14854 locator.weight = weight;
14855 vec_add1 (locators, locator);
14861 if (locator_set_name_set == 0)
14863 errmsg ("missing locator-set name");
14864 vec_free (locators);
14868 if (vec_len (locator_set_name) > 64)
14870 errmsg ("locator-set name too long");
14871 vec_free (locator_set_name);
14872 vec_free (locators);
14875 vec_add1 (locator_set_name, 0);
14877 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14879 /* Construct the API message */
14880 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14882 mp->is_add = is_add;
14883 clib_memcpy (mp->locator_set_name, locator_set_name,
14884 vec_len (locator_set_name));
14885 vec_free (locator_set_name);
14887 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14889 clib_memcpy (mp->locators, locators, data_len);
14890 vec_free (locators);
14895 /* Wait for a reply... */
14900 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14903 api_one_add_del_locator (vat_main_t * vam)
14905 unformat_input_t *input = vam->input;
14906 vl_api_one_add_del_locator_t *mp;
14907 u32 tmp_if_index = ~0;
14908 u32 sw_if_index = ~0;
14909 u8 sw_if_index_set = 0;
14910 u8 sw_if_index_if_name_set = 0;
14912 u8 priority_set = 0;
14916 u8 *locator_set_name = NULL;
14917 u8 locator_set_name_set = 0;
14920 /* Parse args required to build the message */
14921 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14923 if (unformat (input, "del"))
14927 else if (unformat (input, "locator-set %s", &locator_set_name))
14929 locator_set_name_set = 1;
14931 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14934 sw_if_index_if_name_set = 1;
14935 sw_if_index = tmp_if_index;
14937 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14939 sw_if_index_set = 1;
14940 sw_if_index = tmp_if_index;
14942 else if (unformat (input, "p %d", &priority))
14946 else if (unformat (input, "w %d", &weight))
14954 if (locator_set_name_set == 0)
14956 errmsg ("missing locator-set name");
14960 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14962 errmsg ("missing sw_if_index");
14963 vec_free (locator_set_name);
14967 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14969 errmsg ("cannot use both params interface name and sw_if_index");
14970 vec_free (locator_set_name);
14974 if (priority_set == 0)
14976 errmsg ("missing locator-set priority");
14977 vec_free (locator_set_name);
14981 if (weight_set == 0)
14983 errmsg ("missing locator-set weight");
14984 vec_free (locator_set_name);
14988 if (vec_len (locator_set_name) > 64)
14990 errmsg ("locator-set name too long");
14991 vec_free (locator_set_name);
14994 vec_add1 (locator_set_name, 0);
14996 /* Construct the API message */
14997 M (ONE_ADD_DEL_LOCATOR, mp);
14999 mp->is_add = is_add;
15000 mp->sw_if_index = ntohl (sw_if_index);
15001 mp->priority = priority;
15002 mp->weight = weight;
15003 clib_memcpy (mp->locator_set_name, locator_set_name,
15004 vec_len (locator_set_name));
15005 vec_free (locator_set_name);
15010 /* Wait for a reply... */
15015 #define api_lisp_add_del_locator api_one_add_del_locator
15018 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15020 u32 *key_id = va_arg (*args, u32 *);
15023 if (unformat (input, "%s", &s))
15025 if (!strcmp ((char *) s, "sha1"))
15026 key_id[0] = HMAC_SHA_1_96;
15027 else if (!strcmp ((char *) s, "sha256"))
15028 key_id[0] = HMAC_SHA_256_128;
15031 clib_warning ("invalid key_id: '%s'", s);
15032 key_id[0] = HMAC_NO_KEY;
15043 api_one_add_del_local_eid (vat_main_t * vam)
15045 unformat_input_t *input = vam->input;
15046 vl_api_one_add_del_local_eid_t *mp;
15049 lisp_eid_vat_t _eid, *eid = &_eid;
15050 u8 *locator_set_name = 0;
15051 u8 locator_set_name_set = 0;
15057 /* Parse args required to build the message */
15058 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15060 if (unformat (input, "del"))
15064 else if (unformat (input, "vni %d", &vni))
15068 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15072 else if (unformat (input, "locator-set %s", &locator_set_name))
15074 locator_set_name_set = 1;
15076 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15078 else if (unformat (input, "secret-key %_%v%_", &key))
15084 if (locator_set_name_set == 0)
15086 errmsg ("missing locator-set name");
15092 errmsg ("EID address not set!");
15093 vec_free (locator_set_name);
15097 if (key && (0 == key_id))
15099 errmsg ("invalid key_id!");
15103 if (vec_len (key) > 64)
15105 errmsg ("key too long");
15110 if (vec_len (locator_set_name) > 64)
15112 errmsg ("locator-set name too long");
15113 vec_free (locator_set_name);
15116 vec_add1 (locator_set_name, 0);
15118 /* Construct the API message */
15119 M (ONE_ADD_DEL_LOCAL_EID, mp);
15121 mp->is_add = is_add;
15122 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15123 mp->eid_type = eid->type;
15124 mp->prefix_len = eid->len;
15125 mp->vni = clib_host_to_net_u32 (vni);
15126 mp->key_id = clib_host_to_net_u16 (key_id);
15127 clib_memcpy (mp->locator_set_name, locator_set_name,
15128 vec_len (locator_set_name));
15129 clib_memcpy (mp->key, key, vec_len (key));
15131 vec_free (locator_set_name);
15137 /* Wait for a reply... */
15142 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15145 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15147 u32 dp_table = 0, vni = 0;;
15148 unformat_input_t *input = vam->input;
15149 vl_api_gpe_add_del_fwd_entry_t *mp;
15151 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15152 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15153 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15154 u32 action = ~0, w;
15155 ip4_address_t rmt_rloc4, lcl_rloc4;
15156 ip6_address_t rmt_rloc6, lcl_rloc6;
15157 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15160 clib_memset (&rloc, 0, sizeof (rloc));
15162 /* Parse args required to build the message */
15163 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15165 if (unformat (input, "del"))
15167 else if (unformat (input, "add"))
15169 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15173 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15177 else if (unformat (input, "vrf %d", &dp_table))
15179 else if (unformat (input, "bd %d", &dp_table))
15181 else if (unformat (input, "vni %d", &vni))
15183 else if (unformat (input, "w %d", &w))
15187 errmsg ("No RLOC configured for setting priority/weight!");
15190 curr_rloc->weight = w;
15192 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15193 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15197 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15199 vec_add1 (lcl_locs, rloc);
15201 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15202 vec_add1 (rmt_locs, rloc);
15203 /* weight saved in rmt loc */
15204 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15206 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15207 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15210 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15212 vec_add1 (lcl_locs, rloc);
15214 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15215 vec_add1 (rmt_locs, rloc);
15216 /* weight saved in rmt loc */
15217 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15219 else if (unformat (input, "action %d", &action))
15225 clib_warning ("parse error '%U'", format_unformat_error, input);
15232 errmsg ("remote eid addresses not set");
15236 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15238 errmsg ("eid types don't match");
15242 if (0 == rmt_locs && (u32) ~ 0 == action)
15244 errmsg ("action not set for negative mapping");
15248 /* Construct the API message */
15249 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15250 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15252 mp->is_add = is_add;
15253 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15254 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15255 mp->eid_type = rmt_eid->type;
15256 mp->dp_table = clib_host_to_net_u32 (dp_table);
15257 mp->vni = clib_host_to_net_u32 (vni);
15258 mp->rmt_len = rmt_eid->len;
15259 mp->lcl_len = lcl_eid->len;
15260 mp->action = action;
15262 if (0 != rmt_locs && 0 != lcl_locs)
15264 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15265 clib_memcpy (mp->locs, lcl_locs,
15266 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15268 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15269 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15270 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15272 vec_free (lcl_locs);
15273 vec_free (rmt_locs);
15278 /* Wait for a reply... */
15284 api_one_add_del_map_server (vat_main_t * vam)
15286 unformat_input_t *input = vam->input;
15287 vl_api_one_add_del_map_server_t *mp;
15291 ip4_address_t ipv4;
15292 ip6_address_t ipv6;
15295 /* Parse args required to build the message */
15296 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15298 if (unformat (input, "del"))
15302 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15306 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15314 if (ipv4_set && ipv6_set)
15316 errmsg ("both eid v4 and v6 addresses set");
15320 if (!ipv4_set && !ipv6_set)
15322 errmsg ("eid addresses not set");
15326 /* Construct the API message */
15327 M (ONE_ADD_DEL_MAP_SERVER, mp);
15329 mp->is_add = is_add;
15333 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15338 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15344 /* Wait for a reply... */
15349 #define api_lisp_add_del_map_server api_one_add_del_map_server
15352 api_one_add_del_map_resolver (vat_main_t * vam)
15354 unformat_input_t *input = vam->input;
15355 vl_api_one_add_del_map_resolver_t *mp;
15359 ip4_address_t ipv4;
15360 ip6_address_t ipv6;
15363 /* Parse args required to build the message */
15364 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15366 if (unformat (input, "del"))
15370 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15374 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15382 if (ipv4_set && ipv6_set)
15384 errmsg ("both eid v4 and v6 addresses set");
15388 if (!ipv4_set && !ipv6_set)
15390 errmsg ("eid addresses not set");
15394 /* Construct the API message */
15395 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15397 mp->is_add = is_add;
15401 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15406 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15412 /* Wait for a reply... */
15417 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15420 api_lisp_gpe_enable_disable (vat_main_t * vam)
15422 unformat_input_t *input = vam->input;
15423 vl_api_gpe_enable_disable_t *mp;
15428 /* Parse args required to build the message */
15429 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15431 if (unformat (input, "enable"))
15436 else if (unformat (input, "disable"))
15447 errmsg ("Value not set");
15451 /* Construct the API message */
15452 M (GPE_ENABLE_DISABLE, mp);
15459 /* Wait for a reply... */
15465 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15467 unformat_input_t *input = vam->input;
15468 vl_api_one_rloc_probe_enable_disable_t *mp;
15473 /* Parse args required to build the message */
15474 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15476 if (unformat (input, "enable"))
15481 else if (unformat (input, "disable"))
15489 errmsg ("Value not set");
15493 /* Construct the API message */
15494 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15496 mp->is_enabled = is_en;
15501 /* Wait for a reply... */
15506 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15509 api_one_map_register_enable_disable (vat_main_t * vam)
15511 unformat_input_t *input = vam->input;
15512 vl_api_one_map_register_enable_disable_t *mp;
15517 /* Parse args required to build the message */
15518 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15520 if (unformat (input, "enable"))
15525 else if (unformat (input, "disable"))
15533 errmsg ("Value not set");
15537 /* Construct the API message */
15538 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15540 mp->is_enabled = is_en;
15545 /* Wait for a reply... */
15550 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15553 api_one_enable_disable (vat_main_t * vam)
15555 unformat_input_t *input = vam->input;
15556 vl_api_one_enable_disable_t *mp;
15561 /* Parse args required to build the message */
15562 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15564 if (unformat (input, "enable"))
15569 else if (unformat (input, "disable"))
15579 errmsg ("Value not set");
15583 /* Construct the API message */
15584 M (ONE_ENABLE_DISABLE, mp);
15591 /* Wait for a reply... */
15596 #define api_lisp_enable_disable api_one_enable_disable
15599 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15601 unformat_input_t *input = vam->input;
15602 vl_api_one_enable_disable_xtr_mode_t *mp;
15607 /* Parse args required to build the message */
15608 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15610 if (unformat (input, "enable"))
15615 else if (unformat (input, "disable"))
15625 errmsg ("Value not set");
15629 /* Construct the API message */
15630 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15637 /* Wait for a reply... */
15643 api_one_show_xtr_mode (vat_main_t * vam)
15645 vl_api_one_show_xtr_mode_t *mp;
15648 /* Construct the API message */
15649 M (ONE_SHOW_XTR_MODE, mp);
15654 /* Wait for a reply... */
15660 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15662 unformat_input_t *input = vam->input;
15663 vl_api_one_enable_disable_pitr_mode_t *mp;
15668 /* Parse args required to build the message */
15669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15671 if (unformat (input, "enable"))
15676 else if (unformat (input, "disable"))
15686 errmsg ("Value not set");
15690 /* Construct the API message */
15691 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15698 /* Wait for a reply... */
15704 api_one_show_pitr_mode (vat_main_t * vam)
15706 vl_api_one_show_pitr_mode_t *mp;
15709 /* Construct the API message */
15710 M (ONE_SHOW_PITR_MODE, mp);
15715 /* Wait for a reply... */
15721 api_one_enable_disable_petr_mode (vat_main_t * vam)
15723 unformat_input_t *input = vam->input;
15724 vl_api_one_enable_disable_petr_mode_t *mp;
15729 /* Parse args required to build the message */
15730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15732 if (unformat (input, "enable"))
15737 else if (unformat (input, "disable"))
15747 errmsg ("Value not set");
15751 /* Construct the API message */
15752 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15759 /* Wait for a reply... */
15765 api_one_show_petr_mode (vat_main_t * vam)
15767 vl_api_one_show_petr_mode_t *mp;
15770 /* Construct the API message */
15771 M (ONE_SHOW_PETR_MODE, mp);
15776 /* Wait for a reply... */
15782 api_show_one_map_register_state (vat_main_t * vam)
15784 vl_api_show_one_map_register_state_t *mp;
15787 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15792 /* wait for reply */
15797 #define api_show_lisp_map_register_state api_show_one_map_register_state
15800 api_show_one_rloc_probe_state (vat_main_t * vam)
15802 vl_api_show_one_rloc_probe_state_t *mp;
15805 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15810 /* wait for reply */
15815 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15818 api_one_add_del_ndp_entry (vat_main_t * vam)
15820 vl_api_one_add_del_ndp_entry_t *mp;
15821 unformat_input_t *input = vam->input;
15826 u8 mac[6] = { 0, };
15827 u8 ip6[16] = { 0, };
15831 /* Parse args required to build the message */
15832 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15834 if (unformat (input, "del"))
15836 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15838 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15840 else if (unformat (input, "bd %d", &bd))
15844 errmsg ("parse error '%U'", format_unformat_error, input);
15849 if (!bd_set || !ip_set || (!mac_set && is_add))
15851 errmsg ("Missing BD, IP or MAC!");
15855 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15856 mp->is_add = is_add;
15857 clib_memcpy (mp->mac, mac, 6);
15858 mp->bd = clib_host_to_net_u32 (bd);
15859 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15864 /* wait for reply */
15870 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15872 vl_api_one_add_del_l2_arp_entry_t *mp;
15873 unformat_input_t *input = vam->input;
15878 u8 mac[6] = { 0, };
15879 u32 ip4 = 0, bd = ~0;
15882 /* Parse args required to build the message */
15883 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15885 if (unformat (input, "del"))
15887 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15889 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15891 else if (unformat (input, "bd %d", &bd))
15895 errmsg ("parse error '%U'", format_unformat_error, input);
15900 if (!bd_set || !ip_set || (!mac_set && is_add))
15902 errmsg ("Missing BD, IP or MAC!");
15906 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15907 mp->is_add = is_add;
15908 clib_memcpy (mp->mac, mac, 6);
15909 mp->bd = clib_host_to_net_u32 (bd);
15915 /* wait for reply */
15921 api_one_ndp_bd_get (vat_main_t * vam)
15923 vl_api_one_ndp_bd_get_t *mp;
15926 M (ONE_NDP_BD_GET, mp);
15931 /* wait for reply */
15937 api_one_ndp_entries_get (vat_main_t * vam)
15939 vl_api_one_ndp_entries_get_t *mp;
15940 unformat_input_t *input = vam->input;
15945 /* Parse args required to build the message */
15946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15948 if (unformat (input, "bd %d", &bd))
15952 errmsg ("parse error '%U'", format_unformat_error, input);
15959 errmsg ("Expected bridge domain!");
15963 M (ONE_NDP_ENTRIES_GET, mp);
15964 mp->bd = clib_host_to_net_u32 (bd);
15969 /* wait for reply */
15975 api_one_l2_arp_bd_get (vat_main_t * vam)
15977 vl_api_one_l2_arp_bd_get_t *mp;
15980 M (ONE_L2_ARP_BD_GET, mp);
15985 /* wait for reply */
15991 api_one_l2_arp_entries_get (vat_main_t * vam)
15993 vl_api_one_l2_arp_entries_get_t *mp;
15994 unformat_input_t *input = vam->input;
15999 /* Parse args required to build the message */
16000 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16002 if (unformat (input, "bd %d", &bd))
16006 errmsg ("parse error '%U'", format_unformat_error, input);
16013 errmsg ("Expected bridge domain!");
16017 M (ONE_L2_ARP_ENTRIES_GET, mp);
16018 mp->bd = clib_host_to_net_u32 (bd);
16023 /* wait for reply */
16029 api_one_stats_enable_disable (vat_main_t * vam)
16031 vl_api_one_stats_enable_disable_t *mp;
16032 unformat_input_t *input = vam->input;
16037 /* Parse args required to build the message */
16038 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16040 if (unformat (input, "enable"))
16045 else if (unformat (input, "disable"))
16055 errmsg ("Value not set");
16059 M (ONE_STATS_ENABLE_DISABLE, mp);
16065 /* wait for reply */
16071 api_show_one_stats_enable_disable (vat_main_t * vam)
16073 vl_api_show_one_stats_enable_disable_t *mp;
16076 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16081 /* wait for reply */
16087 api_show_one_map_request_mode (vat_main_t * vam)
16089 vl_api_show_one_map_request_mode_t *mp;
16092 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16097 /* wait for reply */
16102 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16105 api_one_map_request_mode (vat_main_t * vam)
16107 unformat_input_t *input = vam->input;
16108 vl_api_one_map_request_mode_t *mp;
16112 /* Parse args required to build the message */
16113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16115 if (unformat (input, "dst-only"))
16117 else if (unformat (input, "src-dst"))
16121 errmsg ("parse error '%U'", format_unformat_error, input);
16126 M (ONE_MAP_REQUEST_MODE, mp);
16133 /* wait for reply */
16138 #define api_lisp_map_request_mode api_one_map_request_mode
16141 * Enable/disable ONE proxy ITR.
16143 * @param vam vpp API test context
16144 * @return return code
16147 api_one_pitr_set_locator_set (vat_main_t * vam)
16149 u8 ls_name_set = 0;
16150 unformat_input_t *input = vam->input;
16151 vl_api_one_pitr_set_locator_set_t *mp;
16156 /* Parse args required to build the message */
16157 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16159 if (unformat (input, "del"))
16161 else if (unformat (input, "locator-set %s", &ls_name))
16165 errmsg ("parse error '%U'", format_unformat_error, input);
16172 errmsg ("locator-set name not set!");
16176 M (ONE_PITR_SET_LOCATOR_SET, mp);
16178 mp->is_add = is_add;
16179 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16180 vec_free (ls_name);
16185 /* wait for reply */
16190 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16193 api_one_nsh_set_locator_set (vat_main_t * vam)
16195 u8 ls_name_set = 0;
16196 unformat_input_t *input = vam->input;
16197 vl_api_one_nsh_set_locator_set_t *mp;
16202 /* Parse args required to build the message */
16203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16205 if (unformat (input, "del"))
16207 else if (unformat (input, "ls %s", &ls_name))
16211 errmsg ("parse error '%U'", format_unformat_error, input);
16216 if (!ls_name_set && is_add)
16218 errmsg ("locator-set name not set!");
16222 M (ONE_NSH_SET_LOCATOR_SET, mp);
16224 mp->is_add = is_add;
16225 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16226 vec_free (ls_name);
16231 /* wait for reply */
16237 api_show_one_pitr (vat_main_t * vam)
16239 vl_api_show_one_pitr_t *mp;
16242 if (!vam->json_output)
16244 print (vam->ofp, "%=20s", "lisp status:");
16247 M (SHOW_ONE_PITR, mp);
16251 /* Wait for a reply... */
16256 #define api_show_lisp_pitr api_show_one_pitr
16259 api_one_use_petr (vat_main_t * vam)
16261 unformat_input_t *input = vam->input;
16262 vl_api_one_use_petr_t *mp;
16267 clib_memset (&ip, 0, sizeof (ip));
16269 /* Parse args required to build the message */
16270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16272 if (unformat (input, "disable"))
16275 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16278 ip_addr_version (&ip) = IP4;
16281 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16284 ip_addr_version (&ip) = IP6;
16288 errmsg ("parse error '%U'", format_unformat_error, input);
16293 M (ONE_USE_PETR, mp);
16295 mp->is_add = is_add;
16298 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16300 clib_memcpy (mp->address, &ip, 4);
16302 clib_memcpy (mp->address, &ip, 16);
16308 /* wait for reply */
16313 #define api_lisp_use_petr api_one_use_petr
16316 api_show_one_nsh_mapping (vat_main_t * vam)
16318 vl_api_show_one_use_petr_t *mp;
16321 if (!vam->json_output)
16323 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16326 M (SHOW_ONE_NSH_MAPPING, mp);
16330 /* Wait for a reply... */
16336 api_show_one_use_petr (vat_main_t * vam)
16338 vl_api_show_one_use_petr_t *mp;
16341 if (!vam->json_output)
16343 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16346 M (SHOW_ONE_USE_PETR, mp);
16350 /* Wait for a reply... */
16355 #define api_show_lisp_use_petr api_show_one_use_petr
16358 * Add/delete mapping between vni and vrf
16361 api_one_eid_table_add_del_map (vat_main_t * vam)
16363 unformat_input_t *input = vam->input;
16364 vl_api_one_eid_table_add_del_map_t *mp;
16365 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16366 u32 vni, vrf, bd_index;
16369 /* Parse args required to build the message */
16370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16372 if (unformat (input, "del"))
16374 else if (unformat (input, "vrf %d", &vrf))
16376 else if (unformat (input, "bd_index %d", &bd_index))
16378 else if (unformat (input, "vni %d", &vni))
16384 if (!vni_set || (!vrf_set && !bd_index_set))
16386 errmsg ("missing arguments!");
16390 if (vrf_set && bd_index_set)
16392 errmsg ("error: both vrf and bd entered!");
16396 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16398 mp->is_add = is_add;
16399 mp->vni = htonl (vni);
16400 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16401 mp->is_l2 = bd_index_set;
16406 /* wait for reply */
16411 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16414 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16416 u32 *action = va_arg (*args, u32 *);
16419 if (unformat (input, "%s", &s))
16421 if (!strcmp ((char *) s, "no-action"))
16423 else if (!strcmp ((char *) s, "natively-forward"))
16425 else if (!strcmp ((char *) s, "send-map-request"))
16427 else if (!strcmp ((char *) s, "drop"))
16431 clib_warning ("invalid action: '%s'", s);
16443 * Add/del remote mapping to/from ONE control plane
16445 * @param vam vpp API test context
16446 * @return return code
16449 api_one_add_del_remote_mapping (vat_main_t * vam)
16451 unformat_input_t *input = vam->input;
16452 vl_api_one_add_del_remote_mapping_t *mp;
16454 lisp_eid_vat_t _eid, *eid = &_eid;
16455 lisp_eid_vat_t _seid, *seid = &_seid;
16456 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16457 u32 action = ~0, p, w, data_len;
16458 ip4_address_t rloc4;
16459 ip6_address_t rloc6;
16460 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16463 clib_memset (&rloc, 0, sizeof (rloc));
16465 /* Parse args required to build the message */
16466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16468 if (unformat (input, "del-all"))
16472 else if (unformat (input, "del"))
16476 else if (unformat (input, "add"))
16480 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16484 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16488 else if (unformat (input, "vni %d", &vni))
16492 else if (unformat (input, "p %d w %d", &p, &w))
16496 errmsg ("No RLOC configured for setting priority/weight!");
16499 curr_rloc->priority = p;
16500 curr_rloc->weight = w;
16502 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16505 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16506 vec_add1 (rlocs, rloc);
16507 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16509 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16512 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16513 vec_add1 (rlocs, rloc);
16514 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16516 else if (unformat (input, "action %U",
16517 unformat_negative_mapping_action, &action))
16523 clib_warning ("parse error '%U'", format_unformat_error, input);
16530 errmsg ("missing params!");
16534 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16536 errmsg ("no action set for negative map-reply!");
16540 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16542 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16543 mp->is_add = is_add;
16544 mp->vni = htonl (vni);
16545 mp->action = (u8) action;
16546 mp->is_src_dst = seid_set;
16547 mp->eid_len = eid->len;
16548 mp->seid_len = seid->len;
16549 mp->del_all = del_all;
16550 mp->eid_type = eid->type;
16551 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16552 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16554 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16555 clib_memcpy (mp->rlocs, rlocs, data_len);
16561 /* Wait for a reply... */
16566 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16569 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16570 * forwarding entries in data-plane accordingly.
16572 * @param vam vpp API test context
16573 * @return return code
16576 api_one_add_del_adjacency (vat_main_t * vam)
16578 unformat_input_t *input = vam->input;
16579 vl_api_one_add_del_adjacency_t *mp;
16581 ip4_address_t leid4, reid4;
16582 ip6_address_t leid6, reid6;
16583 u8 reid_mac[6] = { 0 };
16584 u8 leid_mac[6] = { 0 };
16585 u8 reid_type, leid_type;
16586 u32 leid_len = 0, reid_len = 0, len;
16590 leid_type = reid_type = (u8) ~ 0;
16592 /* Parse args required to build the message */
16593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16595 if (unformat (input, "del"))
16599 else if (unformat (input, "add"))
16603 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16606 reid_type = 0; /* ipv4 */
16609 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16612 reid_type = 1; /* ipv6 */
16615 else if (unformat (input, "reid %U", unformat_ethernet_address,
16618 reid_type = 2; /* mac */
16620 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16623 leid_type = 0; /* ipv4 */
16626 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16629 leid_type = 1; /* ipv6 */
16632 else if (unformat (input, "leid %U", unformat_ethernet_address,
16635 leid_type = 2; /* mac */
16637 else if (unformat (input, "vni %d", &vni))
16643 errmsg ("parse error '%U'", format_unformat_error, input);
16648 if ((u8) ~ 0 == reid_type)
16650 errmsg ("missing params!");
16654 if (leid_type != reid_type)
16656 errmsg ("remote and local EIDs are of different types!");
16660 M (ONE_ADD_DEL_ADJACENCY, mp);
16661 mp->is_add = is_add;
16662 mp->vni = htonl (vni);
16663 mp->leid_len = leid_len;
16664 mp->reid_len = reid_len;
16665 mp->eid_type = reid_type;
16667 switch (mp->eid_type)
16670 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16671 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16674 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16675 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16678 clib_memcpy (mp->leid, leid_mac, 6);
16679 clib_memcpy (mp->reid, reid_mac, 6);
16682 errmsg ("unknown EID type %d!", mp->eid_type);
16689 /* Wait for a reply... */
16694 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16697 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16699 u32 *mode = va_arg (*args, u32 *);
16701 if (unformat (input, "lisp"))
16703 else if (unformat (input, "vxlan"))
16712 api_gpe_get_encap_mode (vat_main_t * vam)
16714 vl_api_gpe_get_encap_mode_t *mp;
16717 /* Construct the API message */
16718 M (GPE_GET_ENCAP_MODE, mp);
16723 /* Wait for a reply... */
16729 api_gpe_set_encap_mode (vat_main_t * vam)
16731 unformat_input_t *input = vam->input;
16732 vl_api_gpe_set_encap_mode_t *mp;
16736 /* Parse args required to build the message */
16737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16739 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16745 /* Construct the API message */
16746 M (GPE_SET_ENCAP_MODE, mp);
16753 /* Wait for a reply... */
16759 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16761 unformat_input_t *input = vam->input;
16762 vl_api_gpe_add_del_iface_t *mp;
16763 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16764 u32 dp_table = 0, vni = 0;
16767 /* Parse args required to build the message */
16768 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16770 if (unformat (input, "up"))
16775 else if (unformat (input, "down"))
16780 else if (unformat (input, "table_id %d", &dp_table))
16784 else if (unformat (input, "bd_id %d", &dp_table))
16789 else if (unformat (input, "vni %d", &vni))
16797 if (action_set == 0)
16799 errmsg ("Action not set");
16802 if (dp_table_set == 0 || vni_set == 0)
16804 errmsg ("vni and dp_table must be set");
16808 /* Construct the API message */
16809 M (GPE_ADD_DEL_IFACE, mp);
16811 mp->is_add = is_add;
16812 mp->dp_table = clib_host_to_net_u32 (dp_table);
16814 mp->vni = clib_host_to_net_u32 (vni);
16819 /* Wait for a reply... */
16825 api_one_map_register_fallback_threshold (vat_main_t * vam)
16827 unformat_input_t *input = vam->input;
16828 vl_api_one_map_register_fallback_threshold_t *mp;
16833 /* Parse args required to build the message */
16834 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16836 if (unformat (input, "%u", &value))
16840 clib_warning ("parse error '%U'", format_unformat_error, input);
16847 errmsg ("fallback threshold value is missing!");
16851 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16852 mp->value = clib_host_to_net_u32 (value);
16857 /* Wait for a reply... */
16863 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16865 vl_api_show_one_map_register_fallback_threshold_t *mp;
16868 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16873 /* Wait for a reply... */
16879 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16881 u32 *proto = va_arg (*args, u32 *);
16883 if (unformat (input, "udp"))
16885 else if (unformat (input, "api"))
16894 api_one_set_transport_protocol (vat_main_t * vam)
16896 unformat_input_t *input = vam->input;
16897 vl_api_one_set_transport_protocol_t *mp;
16902 /* Parse args required to build the message */
16903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16905 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16909 clib_warning ("parse error '%U'", format_unformat_error, input);
16916 errmsg ("Transport protocol missing!");
16920 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16921 mp->protocol = (u8) protocol;
16926 /* Wait for a reply... */
16932 api_one_get_transport_protocol (vat_main_t * vam)
16934 vl_api_one_get_transport_protocol_t *mp;
16937 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16942 /* Wait for a reply... */
16948 api_one_map_register_set_ttl (vat_main_t * vam)
16950 unformat_input_t *input = vam->input;
16951 vl_api_one_map_register_set_ttl_t *mp;
16956 /* Parse args required to build the message */
16957 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16959 if (unformat (input, "%u", &ttl))
16963 clib_warning ("parse error '%U'", format_unformat_error, input);
16970 errmsg ("TTL value missing!");
16974 M (ONE_MAP_REGISTER_SET_TTL, mp);
16975 mp->ttl = clib_host_to_net_u32 (ttl);
16980 /* Wait for a reply... */
16986 api_show_one_map_register_ttl (vat_main_t * vam)
16988 vl_api_show_one_map_register_ttl_t *mp;
16991 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16996 /* Wait for a reply... */
17002 * Add/del map request itr rlocs from ONE control plane and updates
17004 * @param vam vpp API test context
17005 * @return return code
17008 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17010 unformat_input_t *input = vam->input;
17011 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17012 u8 *locator_set_name = 0;
17013 u8 locator_set_name_set = 0;
17017 /* Parse args required to build the message */
17018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17020 if (unformat (input, "del"))
17024 else if (unformat (input, "%_%v%_", &locator_set_name))
17026 locator_set_name_set = 1;
17030 clib_warning ("parse error '%U'", format_unformat_error, input);
17035 if (is_add && !locator_set_name_set)
17037 errmsg ("itr-rloc is not set!");
17041 if (is_add && vec_len (locator_set_name) > 64)
17043 errmsg ("itr-rloc locator-set name too long");
17044 vec_free (locator_set_name);
17048 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17049 mp->is_add = is_add;
17052 clib_memcpy (mp->locator_set_name, locator_set_name,
17053 vec_len (locator_set_name));
17057 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17059 vec_free (locator_set_name);
17064 /* Wait for a reply... */
17069 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17072 api_one_locator_dump (vat_main_t * vam)
17074 unformat_input_t *input = vam->input;
17075 vl_api_one_locator_dump_t *mp;
17076 vl_api_control_ping_t *mp_ping;
17077 u8 is_index_set = 0, is_name_set = 0;
17082 /* Parse args required to build the message */
17083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17085 if (unformat (input, "ls_name %_%v%_", &ls_name))
17089 else if (unformat (input, "ls_index %d", &ls_index))
17095 errmsg ("parse error '%U'", format_unformat_error, input);
17100 if (!is_index_set && !is_name_set)
17102 errmsg ("error: expected one of index or name!");
17106 if (is_index_set && is_name_set)
17108 errmsg ("error: only one param expected!");
17112 if (vec_len (ls_name) > 62)
17114 errmsg ("error: locator set name too long!");
17118 if (!vam->json_output)
17120 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17123 M (ONE_LOCATOR_DUMP, mp);
17124 mp->is_index_set = is_index_set;
17127 mp->ls_index = clib_host_to_net_u32 (ls_index);
17130 vec_add1 (ls_name, 0);
17131 strncpy ((char *) mp->ls_name, (char *) ls_name,
17132 sizeof (mp->ls_name) - 1);
17138 /* Use a control ping for synchronization */
17139 MPING (CONTROL_PING, mp_ping);
17142 /* Wait for a reply... */
17147 #define api_lisp_locator_dump api_one_locator_dump
17150 api_one_locator_set_dump (vat_main_t * vam)
17152 vl_api_one_locator_set_dump_t *mp;
17153 vl_api_control_ping_t *mp_ping;
17154 unformat_input_t *input = vam->input;
17158 /* Parse args required to build the message */
17159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17161 if (unformat (input, "local"))
17165 else if (unformat (input, "remote"))
17171 errmsg ("parse error '%U'", format_unformat_error, input);
17176 if (!vam->json_output)
17178 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17181 M (ONE_LOCATOR_SET_DUMP, mp);
17183 mp->filter = filter;
17188 /* Use a control ping for synchronization */
17189 MPING (CONTROL_PING, mp_ping);
17192 /* Wait for a reply... */
17197 #define api_lisp_locator_set_dump api_one_locator_set_dump
17200 api_one_eid_table_map_dump (vat_main_t * vam)
17204 unformat_input_t *input = vam->input;
17205 vl_api_one_eid_table_map_dump_t *mp;
17206 vl_api_control_ping_t *mp_ping;
17209 /* Parse args required to build the message */
17210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17212 if (unformat (input, "l2"))
17217 else if (unformat (input, "l3"))
17224 errmsg ("parse error '%U'", format_unformat_error, input);
17231 errmsg ("expected one of 'l2' or 'l3' parameter!");
17235 if (!vam->json_output)
17237 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17240 M (ONE_EID_TABLE_MAP_DUMP, mp);
17246 /* Use a control ping for synchronization */
17247 MPING (CONTROL_PING, mp_ping);
17250 /* Wait for a reply... */
17255 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17258 api_one_eid_table_vni_dump (vat_main_t * vam)
17260 vl_api_one_eid_table_vni_dump_t *mp;
17261 vl_api_control_ping_t *mp_ping;
17264 if (!vam->json_output)
17266 print (vam->ofp, "VNI");
17269 M (ONE_EID_TABLE_VNI_DUMP, mp);
17274 /* Use a control ping for synchronization */
17275 MPING (CONTROL_PING, mp_ping);
17278 /* Wait for a reply... */
17283 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17286 api_one_eid_table_dump (vat_main_t * vam)
17288 unformat_input_t *i = vam->input;
17289 vl_api_one_eid_table_dump_t *mp;
17290 vl_api_control_ping_t *mp_ping;
17291 struct in_addr ip4;
17292 struct in6_addr ip6;
17294 u8 eid_type = ~0, eid_set = 0;
17295 u32 prefix_length = ~0, t, vni = 0;
17298 lisp_nsh_api_t nsh;
17300 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17302 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17308 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17314 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17319 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17324 else if (unformat (i, "vni %d", &t))
17328 else if (unformat (i, "local"))
17332 else if (unformat (i, "remote"))
17338 errmsg ("parse error '%U'", format_unformat_error, i);
17343 if (!vam->json_output)
17345 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17346 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17349 M (ONE_EID_TABLE_DUMP, mp);
17351 mp->filter = filter;
17355 mp->vni = htonl (vni);
17356 mp->eid_type = eid_type;
17360 mp->prefix_length = prefix_length;
17361 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17364 mp->prefix_length = prefix_length;
17365 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17368 clib_memcpy (mp->eid, mac, sizeof (mac));
17371 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17374 errmsg ("unknown EID type %d!", eid_type);
17382 /* Use a control ping for synchronization */
17383 MPING (CONTROL_PING, mp_ping);
17386 /* Wait for a reply... */
17391 #define api_lisp_eid_table_dump api_one_eid_table_dump
17394 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17396 unformat_input_t *i = vam->input;
17397 vl_api_gpe_fwd_entries_get_t *mp;
17402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17404 if (unformat (i, "vni %d", &vni))
17410 errmsg ("parse error '%U'", format_unformat_error, i);
17417 errmsg ("vni not set!");
17421 if (!vam->json_output)
17423 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17427 M (GPE_FWD_ENTRIES_GET, mp);
17428 mp->vni = clib_host_to_net_u32 (vni);
17433 /* Wait for a reply... */
17438 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17439 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17440 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17441 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17442 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17443 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17444 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17445 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17448 api_one_adjacencies_get (vat_main_t * vam)
17450 unformat_input_t *i = vam->input;
17451 vl_api_one_adjacencies_get_t *mp;
17456 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17458 if (unformat (i, "vni %d", &vni))
17464 errmsg ("parse error '%U'", format_unformat_error, i);
17471 errmsg ("vni not set!");
17475 if (!vam->json_output)
17477 print (vam->ofp, "%s %40s", "leid", "reid");
17480 M (ONE_ADJACENCIES_GET, mp);
17481 mp->vni = clib_host_to_net_u32 (vni);
17486 /* Wait for a reply... */
17491 #define api_lisp_adjacencies_get api_one_adjacencies_get
17494 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17496 unformat_input_t *i = vam->input;
17497 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17499 u8 ip_family_set = 0, is_ip4 = 1;
17501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17503 if (unformat (i, "ip4"))
17508 else if (unformat (i, "ip6"))
17515 errmsg ("parse error '%U'", format_unformat_error, i);
17520 if (!ip_family_set)
17522 errmsg ("ip family not set!");
17526 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17527 mp->is_ip4 = is_ip4;
17532 /* Wait for a reply... */
17538 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17540 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17543 if (!vam->json_output)
17545 print (vam->ofp, "VNIs");
17548 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17553 /* Wait for a reply... */
17559 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17561 unformat_input_t *i = vam->input;
17562 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17564 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17565 struct in_addr ip4;
17566 struct in6_addr ip6;
17567 u32 table_id = 0, nh_sw_if_index = ~0;
17569 clib_memset (&ip4, 0, sizeof (ip4));
17570 clib_memset (&ip6, 0, sizeof (ip6));
17572 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17574 if (unformat (i, "del"))
17576 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17577 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17582 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17583 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17588 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17592 nh_sw_if_index = ~0;
17594 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17598 nh_sw_if_index = ~0;
17600 else if (unformat (i, "table %d", &table_id))
17604 errmsg ("parse error '%U'", format_unformat_error, i);
17611 errmsg ("nh addr not set!");
17615 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17616 mp->is_add = is_add;
17617 mp->table_id = clib_host_to_net_u32 (table_id);
17618 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17619 mp->is_ip4 = is_ip4;
17621 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17623 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17628 /* Wait for a reply... */
17634 api_one_map_server_dump (vat_main_t * vam)
17636 vl_api_one_map_server_dump_t *mp;
17637 vl_api_control_ping_t *mp_ping;
17640 if (!vam->json_output)
17642 print (vam->ofp, "%=20s", "Map server");
17645 M (ONE_MAP_SERVER_DUMP, mp);
17649 /* Use a control ping for synchronization */
17650 MPING (CONTROL_PING, mp_ping);
17653 /* Wait for a reply... */
17658 #define api_lisp_map_server_dump api_one_map_server_dump
17661 api_one_map_resolver_dump (vat_main_t * vam)
17663 vl_api_one_map_resolver_dump_t *mp;
17664 vl_api_control_ping_t *mp_ping;
17667 if (!vam->json_output)
17669 print (vam->ofp, "%=20s", "Map resolver");
17672 M (ONE_MAP_RESOLVER_DUMP, mp);
17676 /* Use a control ping for synchronization */
17677 MPING (CONTROL_PING, mp_ping);
17680 /* Wait for a reply... */
17685 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17688 api_one_stats_flush (vat_main_t * vam)
17690 vl_api_one_stats_flush_t *mp;
17693 M (ONE_STATS_FLUSH, mp);
17700 api_one_stats_dump (vat_main_t * vam)
17702 vl_api_one_stats_dump_t *mp;
17703 vl_api_control_ping_t *mp_ping;
17706 M (ONE_STATS_DUMP, mp);
17710 /* Use a control ping for synchronization */
17711 MPING (CONTROL_PING, mp_ping);
17714 /* Wait for a reply... */
17720 api_show_one_status (vat_main_t * vam)
17722 vl_api_show_one_status_t *mp;
17725 if (!vam->json_output)
17727 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17730 M (SHOW_ONE_STATUS, mp);
17733 /* Wait for a reply... */
17738 #define api_show_lisp_status api_show_one_status
17741 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17743 vl_api_gpe_fwd_entry_path_dump_t *mp;
17744 vl_api_control_ping_t *mp_ping;
17745 unformat_input_t *i = vam->input;
17746 u32 fwd_entry_index = ~0;
17749 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17751 if (unformat (i, "index %d", &fwd_entry_index))
17757 if (~0 == fwd_entry_index)
17759 errmsg ("no index specified!");
17763 if (!vam->json_output)
17765 print (vam->ofp, "first line");
17768 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17772 /* Use a control ping for synchronization */
17773 MPING (CONTROL_PING, mp_ping);
17776 /* Wait for a reply... */
17782 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17784 vl_api_one_get_map_request_itr_rlocs_t *mp;
17787 if (!vam->json_output)
17789 print (vam->ofp, "%=20s", "itr-rlocs:");
17792 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17795 /* Wait for a reply... */
17800 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17803 api_af_packet_create (vat_main_t * vam)
17805 unformat_input_t *i = vam->input;
17806 vl_api_af_packet_create_t *mp;
17807 u8 *host_if_name = 0;
17809 u8 random_hw_addr = 1;
17812 clib_memset (hw_addr, 0, sizeof (hw_addr));
17814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17816 if (unformat (i, "name %s", &host_if_name))
17817 vec_add1 (host_if_name, 0);
17818 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17819 random_hw_addr = 0;
17824 if (!vec_len (host_if_name))
17826 errmsg ("host-interface name must be specified");
17830 if (vec_len (host_if_name) > 64)
17832 errmsg ("host-interface name too long");
17836 M (AF_PACKET_CREATE, mp);
17838 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17839 clib_memcpy (mp->hw_addr, hw_addr, 6);
17840 mp->use_random_hw_addr = random_hw_addr;
17841 vec_free (host_if_name);
17849 fprintf (vam->ofp ? vam->ofp : stderr,
17850 " new sw_if_index = %d\n", vam->sw_if_index);
17857 api_af_packet_delete (vat_main_t * vam)
17859 unformat_input_t *i = vam->input;
17860 vl_api_af_packet_delete_t *mp;
17861 u8 *host_if_name = 0;
17864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17866 if (unformat (i, "name %s", &host_if_name))
17867 vec_add1 (host_if_name, 0);
17872 if (!vec_len (host_if_name))
17874 errmsg ("host-interface name must be specified");
17878 if (vec_len (host_if_name) > 64)
17880 errmsg ("host-interface name too long");
17884 M (AF_PACKET_DELETE, mp);
17886 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17887 vec_free (host_if_name);
17894 static void vl_api_af_packet_details_t_handler
17895 (vl_api_af_packet_details_t * mp)
17897 vat_main_t *vam = &vat_main;
17899 print (vam->ofp, "%-16s %d",
17900 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17903 static void vl_api_af_packet_details_t_handler_json
17904 (vl_api_af_packet_details_t * mp)
17906 vat_main_t *vam = &vat_main;
17907 vat_json_node_t *node = NULL;
17909 if (VAT_JSON_ARRAY != vam->json_tree.type)
17911 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17912 vat_json_init_array (&vam->json_tree);
17914 node = vat_json_array_add (&vam->json_tree);
17916 vat_json_init_object (node);
17917 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17918 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17922 api_af_packet_dump (vat_main_t * vam)
17924 vl_api_af_packet_dump_t *mp;
17925 vl_api_control_ping_t *mp_ping;
17928 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17929 /* Get list of tap interfaces */
17930 M (AF_PACKET_DUMP, mp);
17933 /* Use a control ping for synchronization */
17934 MPING (CONTROL_PING, mp_ping);
17942 api_policer_add_del (vat_main_t * vam)
17944 unformat_input_t *i = vam->input;
17945 vl_api_policer_add_del_t *mp;
17955 u8 color_aware = 0;
17956 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17959 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17960 conform_action.dscp = 0;
17961 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17962 exceed_action.dscp = 0;
17963 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17964 violate_action.dscp = 0;
17966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17968 if (unformat (i, "del"))
17970 else if (unformat (i, "name %s", &name))
17971 vec_add1 (name, 0);
17972 else if (unformat (i, "cir %u", &cir))
17974 else if (unformat (i, "eir %u", &eir))
17976 else if (unformat (i, "cb %u", &cb))
17978 else if (unformat (i, "eb %u", &eb))
17980 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17983 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17986 else if (unformat (i, "type %U", unformat_policer_type, &type))
17988 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17991 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17994 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17997 else if (unformat (i, "color-aware"))
18003 if (!vec_len (name))
18005 errmsg ("policer name must be specified");
18009 if (vec_len (name) > 64)
18011 errmsg ("policer name too long");
18015 M (POLICER_ADD_DEL, mp);
18017 clib_memcpy (mp->name, name, vec_len (name));
18019 mp->is_add = is_add;
18020 mp->cir = ntohl (cir);
18021 mp->eir = ntohl (eir);
18022 mp->cb = clib_net_to_host_u64 (cb);
18023 mp->eb = clib_net_to_host_u64 (eb);
18024 mp->rate_type = rate_type;
18025 mp->round_type = round_type;
18027 mp->conform_action_type = conform_action.action_type;
18028 mp->conform_dscp = conform_action.dscp;
18029 mp->exceed_action_type = exceed_action.action_type;
18030 mp->exceed_dscp = exceed_action.dscp;
18031 mp->violate_action_type = violate_action.action_type;
18032 mp->violate_dscp = violate_action.dscp;
18033 mp->color_aware = color_aware;
18041 api_policer_dump (vat_main_t * vam)
18043 unformat_input_t *i = vam->input;
18044 vl_api_policer_dump_t *mp;
18045 vl_api_control_ping_t *mp_ping;
18046 u8 *match_name = 0;
18047 u8 match_name_valid = 0;
18050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18052 if (unformat (i, "name %s", &match_name))
18054 vec_add1 (match_name, 0);
18055 match_name_valid = 1;
18061 M (POLICER_DUMP, mp);
18062 mp->match_name_valid = match_name_valid;
18063 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18064 vec_free (match_name);
18068 /* Use a control ping for synchronization */
18069 MPING (CONTROL_PING, mp_ping);
18072 /* Wait for a reply... */
18078 api_policer_classify_set_interface (vat_main_t * vam)
18080 unformat_input_t *i = vam->input;
18081 vl_api_policer_classify_set_interface_t *mp;
18083 int sw_if_index_set;
18084 u32 ip4_table_index = ~0;
18085 u32 ip6_table_index = ~0;
18086 u32 l2_table_index = ~0;
18090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18093 sw_if_index_set = 1;
18094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18095 sw_if_index_set = 1;
18096 else if (unformat (i, "del"))
18098 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18100 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18102 else if (unformat (i, "l2-table %d", &l2_table_index))
18106 clib_warning ("parse error '%U'", format_unformat_error, i);
18111 if (sw_if_index_set == 0)
18113 errmsg ("missing interface name or sw_if_index");
18117 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18119 mp->sw_if_index = ntohl (sw_if_index);
18120 mp->ip4_table_index = ntohl (ip4_table_index);
18121 mp->ip6_table_index = ntohl (ip6_table_index);
18122 mp->l2_table_index = ntohl (l2_table_index);
18123 mp->is_add = is_add;
18131 api_policer_classify_dump (vat_main_t * vam)
18133 unformat_input_t *i = vam->input;
18134 vl_api_policer_classify_dump_t *mp;
18135 vl_api_control_ping_t *mp_ping;
18136 u8 type = POLICER_CLASSIFY_N_TABLES;
18139 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18143 errmsg ("classify table type must be specified");
18147 if (!vam->json_output)
18149 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18152 M (POLICER_CLASSIFY_DUMP, mp);
18157 /* Use a control ping for synchronization */
18158 MPING (CONTROL_PING, mp_ping);
18161 /* Wait for a reply... */
18167 api_netmap_create (vat_main_t * vam)
18169 unformat_input_t *i = vam->input;
18170 vl_api_netmap_create_t *mp;
18173 u8 random_hw_addr = 1;
18178 clib_memset (hw_addr, 0, sizeof (hw_addr));
18180 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18182 if (unformat (i, "name %s", &if_name))
18183 vec_add1 (if_name, 0);
18184 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18185 random_hw_addr = 0;
18186 else if (unformat (i, "pipe"))
18188 else if (unformat (i, "master"))
18190 else if (unformat (i, "slave"))
18196 if (!vec_len (if_name))
18198 errmsg ("interface name must be specified");
18202 if (vec_len (if_name) > 64)
18204 errmsg ("interface name too long");
18208 M (NETMAP_CREATE, mp);
18210 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18211 clib_memcpy (mp->hw_addr, hw_addr, 6);
18212 mp->use_random_hw_addr = random_hw_addr;
18213 mp->is_pipe = is_pipe;
18214 mp->is_master = is_master;
18215 vec_free (if_name);
18223 api_netmap_delete (vat_main_t * vam)
18225 unformat_input_t *i = vam->input;
18226 vl_api_netmap_delete_t *mp;
18230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18232 if (unformat (i, "name %s", &if_name))
18233 vec_add1 (if_name, 0);
18238 if (!vec_len (if_name))
18240 errmsg ("interface name must be specified");
18244 if (vec_len (if_name) > 64)
18246 errmsg ("interface name too long");
18250 M (NETMAP_DELETE, mp);
18252 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18253 vec_free (if_name);
18261 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18263 vl_api_fib_path_nh_proto_t proto =
18264 va_arg (*args, vl_api_fib_path_nh_proto_t);
18268 case FIB_API_PATH_NH_PROTO_IP4:
18269 s = format (s, "ip4");
18271 case FIB_API_PATH_NH_PROTO_IP6:
18272 s = format (s, "ip6");
18274 case FIB_API_PATH_NH_PROTO_MPLS:
18275 s = format (s, "mpls");
18277 case FIB_API_PATH_NH_PROTO_BIER:
18278 s = format (s, "bier");
18280 case FIB_API_PATH_NH_PROTO_ETHERNET:
18281 s = format (s, "ethernet");
18289 format_vl_api_ip_address_union (u8 * s, va_list * args)
18291 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18292 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18297 s = format (s, "%U", format_ip4_address, u->ip4);
18300 s = format (s, "%U", format_ip6_address, u->ip6);
18307 format_vl_api_fib_path_type (u8 * s, va_list * args)
18309 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18313 case FIB_API_PATH_TYPE_NORMAL:
18314 s = format (s, "normal");
18316 case FIB_API_PATH_TYPE_LOCAL:
18317 s = format (s, "local");
18319 case FIB_API_PATH_TYPE_DROP:
18320 s = format (s, "drop");
18322 case FIB_API_PATH_TYPE_UDP_ENCAP:
18323 s = format (s, "udp-encap");
18325 case FIB_API_PATH_TYPE_BIER_IMP:
18326 s = format (s, "bier-imp");
18328 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18329 s = format (s, "unreach");
18331 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18332 s = format (s, "prohibit");
18334 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18335 s = format (s, "src-lookup");
18337 case FIB_API_PATH_TYPE_DVR:
18338 s = format (s, "dvr");
18340 case FIB_API_PATH_TYPE_INTERFACE_RX:
18341 s = format (s, "interface-rx");
18343 case FIB_API_PATH_TYPE_CLASSIFY:
18344 s = format (s, "classify");
18352 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18355 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18356 ntohl (fp->weight), ntohl (fp->sw_if_index),
18357 format_vl_api_fib_path_type, fp->type,
18358 format_fib_api_path_nh_proto, fp->proto,
18359 format_vl_api_ip_address_union, &fp->nh.address);
18363 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18364 vl_api_fib_path_t * fp)
18366 struct in_addr ip4;
18367 struct in6_addr ip6;
18369 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18370 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18371 vat_json_object_add_uint (node, "type", fp->type);
18372 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18373 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18375 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18376 vat_json_object_add_ip4 (node, "next_hop", ip4);
18378 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18380 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18381 vat_json_object_add_ip6 (node, "next_hop", ip6);
18386 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18388 vat_main_t *vam = &vat_main;
18389 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18390 vl_api_fib_path_t *fp;
18393 print (vam->ofp, "sw_if_index %d via:",
18394 ntohl (mp->mt_tunnel.mt_sw_if_index));
18395 fp = mp->mt_tunnel.mt_paths;
18396 for (i = 0; i < count; i++)
18398 vl_api_fib_path_print (vam, fp);
18402 print (vam->ofp, "");
18405 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18406 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18409 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18411 vat_main_t *vam = &vat_main;
18412 vat_json_node_t *node = NULL;
18413 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18414 vl_api_fib_path_t *fp;
18417 if (VAT_JSON_ARRAY != vam->json_tree.type)
18419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18420 vat_json_init_array (&vam->json_tree);
18422 node = vat_json_array_add (&vam->json_tree);
18424 vat_json_init_object (node);
18425 vat_json_object_add_uint (node, "sw_if_index",
18426 ntohl (mp->mt_tunnel.mt_sw_if_index));
18428 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18430 fp = mp->mt_tunnel.mt_paths;
18431 for (i = 0; i < count; i++)
18433 vl_api_mpls_fib_path_json_print (node, fp);
18439 api_mpls_tunnel_dump (vat_main_t * vam)
18441 vl_api_mpls_tunnel_dump_t *mp;
18442 vl_api_control_ping_t *mp_ping;
18445 M (MPLS_TUNNEL_DUMP, mp);
18449 /* Use a control ping for synchronization */
18450 MPING (CONTROL_PING, mp_ping);
18457 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18458 #define vl_api_mpls_table_details_t_print vl_noop_handler
18462 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18464 vat_main_t *vam = &vat_main;
18466 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18469 static void vl_api_mpls_table_details_t_handler_json
18470 (vl_api_mpls_table_details_t * mp)
18472 vat_main_t *vam = &vat_main;
18473 vat_json_node_t *node = NULL;
18475 if (VAT_JSON_ARRAY != vam->json_tree.type)
18477 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18478 vat_json_init_array (&vam->json_tree);
18480 node = vat_json_array_add (&vam->json_tree);
18482 vat_json_init_object (node);
18483 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18487 api_mpls_table_dump (vat_main_t * vam)
18489 vl_api_mpls_table_dump_t *mp;
18490 vl_api_control_ping_t *mp_ping;
18493 M (MPLS_TABLE_DUMP, mp);
18496 /* Use a control ping for synchronization */
18497 MPING (CONTROL_PING, mp_ping);
18504 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18505 #define vl_api_mpls_route_details_t_print vl_noop_handler
18508 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18510 vat_main_t *vam = &vat_main;
18511 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18512 vl_api_fib_path_t *fp;
18516 "table-id %d, label %u, ess_bit %u",
18517 ntohl (mp->mr_route.mr_table_id),
18518 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18519 fp = mp->mr_route.mr_paths;
18520 for (i = 0; i < count; i++)
18522 vl_api_fib_path_print (vam, fp);
18527 static void vl_api_mpls_route_details_t_handler_json
18528 (vl_api_mpls_route_details_t * mp)
18530 vat_main_t *vam = &vat_main;
18531 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18532 vat_json_node_t *node = NULL;
18533 vl_api_fib_path_t *fp;
18536 if (VAT_JSON_ARRAY != vam->json_tree.type)
18538 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18539 vat_json_init_array (&vam->json_tree);
18541 node = vat_json_array_add (&vam->json_tree);
18543 vat_json_init_object (node);
18544 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18545 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18546 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18547 vat_json_object_add_uint (node, "path_count", count);
18548 fp = mp->mr_route.mr_paths;
18549 for (i = 0; i < count; i++)
18551 vl_api_mpls_fib_path_json_print (node, fp);
18557 api_mpls_route_dump (vat_main_t * vam)
18559 unformat_input_t *input = vam->input;
18560 vl_api_mpls_route_dump_t *mp;
18561 vl_api_control_ping_t *mp_ping;
18565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18567 if (unformat (input, "table_id %d", &table_id))
18572 if (table_id == ~0)
18574 errmsg ("missing table id");
18578 M (MPLS_ROUTE_DUMP, mp);
18580 mp->table.mt_table_id = ntohl (table_id);
18583 /* Use a control ping for synchronization */
18584 MPING (CONTROL_PING, mp_ping);
18591 #define vl_api_ip_table_details_t_endian vl_noop_handler
18592 #define vl_api_ip_table_details_t_print vl_noop_handler
18595 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18597 vat_main_t *vam = &vat_main;
18600 "%s; table-id %d, prefix %U/%d",
18601 mp->table.name, ntohl (mp->table.table_id));
18605 static void vl_api_ip_table_details_t_handler_json
18606 (vl_api_ip_table_details_t * mp)
18608 vat_main_t *vam = &vat_main;
18609 vat_json_node_t *node = NULL;
18611 if (VAT_JSON_ARRAY != vam->json_tree.type)
18613 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18614 vat_json_init_array (&vam->json_tree);
18616 node = vat_json_array_add (&vam->json_tree);
18618 vat_json_init_object (node);
18619 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18623 api_ip_table_dump (vat_main_t * vam)
18625 vl_api_ip_table_dump_t *mp;
18626 vl_api_control_ping_t *mp_ping;
18629 M (IP_TABLE_DUMP, mp);
18632 /* Use a control ping for synchronization */
18633 MPING (CONTROL_PING, mp_ping);
18641 api_ip_mtable_dump (vat_main_t * vam)
18643 vl_api_ip_mtable_dump_t *mp;
18644 vl_api_control_ping_t *mp_ping;
18647 M (IP_MTABLE_DUMP, mp);
18650 /* Use a control ping for synchronization */
18651 MPING (CONTROL_PING, mp_ping);
18659 api_ip_mroute_dump (vat_main_t * vam)
18661 unformat_input_t *input = vam->input;
18662 vl_api_control_ping_t *mp_ping;
18663 vl_api_ip_mroute_dump_t *mp;
18668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18670 if (unformat (input, "table_id %d", &table_id))
18672 else if (unformat (input, "ip6"))
18674 else if (unformat (input, "ip4"))
18679 if (table_id == ~0)
18681 errmsg ("missing table id");
18685 M (IP_MROUTE_DUMP, mp);
18686 mp->table.table_id = table_id;
18687 mp->table.is_ip6 = is_ip6;
18690 /* Use a control ping for synchronization */
18691 MPING (CONTROL_PING, mp_ping);
18698 static void vl_api_ip_neighbor_details_t_handler
18699 (vl_api_ip_neighbor_details_t * mp)
18701 vat_main_t *vam = &vat_main;
18703 print (vam->ofp, "%c %U %U",
18704 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
18705 format_vl_api_mac_address, &mp->neighbor.mac_address,
18706 format_vl_api_address, &mp->neighbor.ip_address);
18709 static void vl_api_ip_neighbor_details_t_handler_json
18710 (vl_api_ip_neighbor_details_t * mp)
18713 vat_main_t *vam = &vat_main;
18714 vat_json_node_t *node;
18716 if (VAT_JSON_ARRAY != vam->json_tree.type)
18718 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18719 vat_json_init_array (&vam->json_tree);
18721 node = vat_json_array_add (&vam->json_tree);
18723 vat_json_init_object (node);
18724 vat_json_object_add_string_copy
18726 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
18727 (u8 *) "static" : (u8 *) "dynamic"));
18729 vat_json_object_add_string_copy (node, "link_layer",
18730 format (0, "%U", format_vl_api_mac_address,
18731 &mp->neighbor.mac_address));
18732 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
18736 api_ip_neighbor_dump (vat_main_t * vam)
18738 unformat_input_t *i = vam->input;
18739 vl_api_ip_neighbor_dump_t *mp;
18740 vl_api_control_ping_t *mp_ping;
18742 u32 sw_if_index = ~0;
18745 /* Parse args required to build the message */
18746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18752 else if (unformat (i, "ip6"))
18758 if (sw_if_index == ~0)
18760 errmsg ("missing interface name or sw_if_index");
18764 M (IP_NEIGHBOR_DUMP, mp);
18765 mp->is_ipv6 = (u8) is_ipv6;
18766 mp->sw_if_index = ntohl (sw_if_index);
18769 /* Use a control ping for synchronization */
18770 MPING (CONTROL_PING, mp_ping);
18777 #define vl_api_ip_route_details_t_endian vl_noop_handler
18778 #define vl_api_ip_route_details_t_print vl_noop_handler
18781 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18783 vat_main_t *vam = &vat_main;
18784 u8 count = mp->route.n_paths;
18785 vl_api_fib_path_t *fp;
18789 "table-id %d, prefix %U/%d",
18790 ntohl (mp->route.table_id),
18791 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18792 for (i = 0; i < count; i++)
18794 fp = &mp->route.paths[i];
18796 vl_api_fib_path_print (vam, fp);
18801 static void vl_api_ip_route_details_t_handler_json
18802 (vl_api_ip_route_details_t * mp)
18804 vat_main_t *vam = &vat_main;
18805 u8 count = mp->route.n_paths;
18806 vat_json_node_t *node = NULL;
18807 struct in_addr ip4;
18808 struct in6_addr ip6;
18809 vl_api_fib_path_t *fp;
18812 if (VAT_JSON_ARRAY != vam->json_tree.type)
18814 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18815 vat_json_init_array (&vam->json_tree);
18817 node = vat_json_array_add (&vam->json_tree);
18819 vat_json_init_object (node);
18820 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18821 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18823 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18824 vat_json_object_add_ip6 (node, "prefix", ip6);
18828 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18829 vat_json_object_add_ip4 (node, "prefix", ip4);
18831 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18832 vat_json_object_add_uint (node, "path_count", count);
18833 for (i = 0; i < count; i++)
18835 fp = &mp->route.paths[i];
18836 vl_api_mpls_fib_path_json_print (node, fp);
18841 api_ip_route_dump (vat_main_t * vam)
18843 unformat_input_t *input = vam->input;
18844 vl_api_ip_route_dump_t *mp;
18845 vl_api_control_ping_t *mp_ping;
18851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18853 if (unformat (input, "table_id %d", &table_id))
18855 else if (unformat (input, "ip6"))
18857 else if (unformat (input, "ip4"))
18862 if (table_id == ~0)
18864 errmsg ("missing table id");
18868 M (IP_ROUTE_DUMP, mp);
18870 mp->table.table_id = table_id;
18871 mp->table.is_ip6 = is_ip6;
18875 /* Use a control ping for synchronization */
18876 MPING (CONTROL_PING, mp_ping);
18884 api_classify_table_ids (vat_main_t * vam)
18886 vl_api_classify_table_ids_t *mp;
18889 /* Construct the API message */
18890 M (CLASSIFY_TABLE_IDS, mp);
18899 api_classify_table_by_interface (vat_main_t * vam)
18901 unformat_input_t *input = vam->input;
18902 vl_api_classify_table_by_interface_t *mp;
18904 u32 sw_if_index = ~0;
18906 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18908 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18910 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18915 if (sw_if_index == ~0)
18917 errmsg ("missing interface name or sw_if_index");
18921 /* Construct the API message */
18922 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18924 mp->sw_if_index = ntohl (sw_if_index);
18932 api_classify_table_info (vat_main_t * vam)
18934 unformat_input_t *input = vam->input;
18935 vl_api_classify_table_info_t *mp;
18939 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18941 if (unformat (input, "table_id %d", &table_id))
18946 if (table_id == ~0)
18948 errmsg ("missing table id");
18952 /* Construct the API message */
18953 M (CLASSIFY_TABLE_INFO, mp);
18955 mp->table_id = ntohl (table_id);
18963 api_classify_session_dump (vat_main_t * vam)
18965 unformat_input_t *input = vam->input;
18966 vl_api_classify_session_dump_t *mp;
18967 vl_api_control_ping_t *mp_ping;
18971 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18973 if (unformat (input, "table_id %d", &table_id))
18978 if (table_id == ~0)
18980 errmsg ("missing table id");
18984 /* Construct the API message */
18985 M (CLASSIFY_SESSION_DUMP, mp);
18987 mp->table_id = ntohl (table_id);
18990 /* Use a control ping for synchronization */
18991 MPING (CONTROL_PING, mp_ping);
18999 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19001 vat_main_t *vam = &vat_main;
19003 print (vam->ofp, "collector_address %U, collector_port %d, "
19004 "src_address %U, vrf_id %d, path_mtu %u, "
19005 "template_interval %u, udp_checksum %d",
19006 format_ip4_address, mp->collector_address,
19007 ntohs (mp->collector_port),
19008 format_ip4_address, mp->src_address,
19009 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19010 ntohl (mp->template_interval), mp->udp_checksum);
19013 vam->result_ready = 1;
19017 vl_api_ipfix_exporter_details_t_handler_json
19018 (vl_api_ipfix_exporter_details_t * mp)
19020 vat_main_t *vam = &vat_main;
19021 vat_json_node_t node;
19022 struct in_addr collector_address;
19023 struct in_addr src_address;
19025 vat_json_init_object (&node);
19026 clib_memcpy (&collector_address, &mp->collector_address,
19027 sizeof (collector_address));
19028 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19029 vat_json_object_add_uint (&node, "collector_port",
19030 ntohs (mp->collector_port));
19031 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19032 vat_json_object_add_ip4 (&node, "src_address", src_address);
19033 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19034 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19035 vat_json_object_add_uint (&node, "template_interval",
19036 ntohl (mp->template_interval));
19037 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19039 vat_json_print (vam->ofp, &node);
19040 vat_json_free (&node);
19042 vam->result_ready = 1;
19046 api_ipfix_exporter_dump (vat_main_t * vam)
19048 vl_api_ipfix_exporter_dump_t *mp;
19051 /* Construct the API message */
19052 M (IPFIX_EXPORTER_DUMP, mp);
19061 api_ipfix_classify_stream_dump (vat_main_t * vam)
19063 vl_api_ipfix_classify_stream_dump_t *mp;
19066 /* Construct the API message */
19067 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19078 vl_api_ipfix_classify_stream_details_t_handler
19079 (vl_api_ipfix_classify_stream_details_t * mp)
19081 vat_main_t *vam = &vat_main;
19082 print (vam->ofp, "domain_id %d, src_port %d",
19083 ntohl (mp->domain_id), ntohs (mp->src_port));
19085 vam->result_ready = 1;
19089 vl_api_ipfix_classify_stream_details_t_handler_json
19090 (vl_api_ipfix_classify_stream_details_t * mp)
19092 vat_main_t *vam = &vat_main;
19093 vat_json_node_t node;
19095 vat_json_init_object (&node);
19096 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19097 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19099 vat_json_print (vam->ofp, &node);
19100 vat_json_free (&node);
19102 vam->result_ready = 1;
19106 api_ipfix_classify_table_dump (vat_main_t * vam)
19108 vl_api_ipfix_classify_table_dump_t *mp;
19109 vl_api_control_ping_t *mp_ping;
19112 if (!vam->json_output)
19114 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19115 "transport_protocol");
19118 /* Construct the API message */
19119 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19124 /* Use a control ping for synchronization */
19125 MPING (CONTROL_PING, mp_ping);
19133 vl_api_ipfix_classify_table_details_t_handler
19134 (vl_api_ipfix_classify_table_details_t * mp)
19136 vat_main_t *vam = &vat_main;
19137 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19138 mp->transport_protocol);
19142 vl_api_ipfix_classify_table_details_t_handler_json
19143 (vl_api_ipfix_classify_table_details_t * mp)
19145 vat_json_node_t *node = NULL;
19146 vat_main_t *vam = &vat_main;
19148 if (VAT_JSON_ARRAY != vam->json_tree.type)
19150 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19151 vat_json_init_array (&vam->json_tree);
19154 node = vat_json_array_add (&vam->json_tree);
19155 vat_json_init_object (node);
19157 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19158 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19159 vat_json_object_add_uint (node, "transport_protocol",
19160 mp->transport_protocol);
19164 api_sw_interface_span_enable_disable (vat_main_t * vam)
19166 unformat_input_t *i = vam->input;
19167 vl_api_sw_interface_span_enable_disable_t *mp;
19168 u32 src_sw_if_index = ~0;
19169 u32 dst_sw_if_index = ~0;
19174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19177 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19179 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19183 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19185 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19187 else if (unformat (i, "disable"))
19189 else if (unformat (i, "rx"))
19191 else if (unformat (i, "tx"))
19193 else if (unformat (i, "both"))
19195 else if (unformat (i, "l2"))
19201 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19203 mp->sw_if_index_from = htonl (src_sw_if_index);
19204 mp->sw_if_index_to = htonl (dst_sw_if_index);
19214 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19217 vat_main_t *vam = &vat_main;
19218 u8 *sw_if_from_name = 0;
19219 u8 *sw_if_to_name = 0;
19220 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19221 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19222 char *states[] = { "none", "rx", "tx", "both" };
19226 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19228 if ((u32) p->value[0] == sw_if_index_from)
19230 sw_if_from_name = (u8 *)(p->key);
19234 if ((u32) p->value[0] == sw_if_index_to)
19236 sw_if_to_name = (u8 *)(p->key);
19237 if (sw_if_from_name)
19242 print (vam->ofp, "%20s => %20s (%s) %s",
19243 sw_if_from_name, sw_if_to_name, states[mp->state],
19244 mp->is_l2 ? "l2" : "device");
19248 vl_api_sw_interface_span_details_t_handler_json
19249 (vl_api_sw_interface_span_details_t * mp)
19251 vat_main_t *vam = &vat_main;
19252 vat_json_node_t *node = NULL;
19253 u8 *sw_if_from_name = 0;
19254 u8 *sw_if_to_name = 0;
19255 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19256 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19260 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19262 if ((u32) p->value[0] == sw_if_index_from)
19264 sw_if_from_name = (u8 *)(p->key);
19268 if ((u32) p->value[0] == sw_if_index_to)
19270 sw_if_to_name = (u8 *)(p->key);
19271 if (sw_if_from_name)
19277 if (VAT_JSON_ARRAY != vam->json_tree.type)
19279 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19280 vat_json_init_array (&vam->json_tree);
19282 node = vat_json_array_add (&vam->json_tree);
19284 vat_json_init_object (node);
19285 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19286 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19287 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19288 if (0 != sw_if_to_name)
19290 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19292 vat_json_object_add_uint (node, "state", mp->state);
19293 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19297 api_sw_interface_span_dump (vat_main_t * vam)
19299 unformat_input_t *input = vam->input;
19300 vl_api_sw_interface_span_dump_t *mp;
19301 vl_api_control_ping_t *mp_ping;
19305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19307 if (unformat (input, "l2"))
19313 M (SW_INTERFACE_SPAN_DUMP, mp);
19317 /* Use a control ping for synchronization */
19318 MPING (CONTROL_PING, mp_ping);
19326 api_pg_create_interface (vat_main_t * vam)
19328 unformat_input_t *input = vam->input;
19329 vl_api_pg_create_interface_t *mp;
19331 u32 if_id = ~0, gso_size = 0;
19332 u8 gso_enabled = 0;
19334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19336 if (unformat (input, "if_id %d", &if_id))
19338 else if (unformat (input, "gso-enabled"))
19341 if (unformat (input, "gso-size %u", &gso_size))
19345 errmsg ("missing gso-size");
19354 errmsg ("missing pg interface index");
19358 /* Construct the API message */
19359 M (PG_CREATE_INTERFACE, mp);
19361 mp->interface_id = ntohl (if_id);
19362 mp->gso_enabled = gso_enabled;
19370 api_pg_capture (vat_main_t * vam)
19372 unformat_input_t *input = vam->input;
19373 vl_api_pg_capture_t *mp;
19378 u8 pcap_file_set = 0;
19381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19383 if (unformat (input, "if_id %d", &if_id))
19385 else if (unformat (input, "pcap %s", &pcap_file))
19387 else if (unformat (input, "count %d", &count))
19389 else if (unformat (input, "disable"))
19396 errmsg ("missing pg interface index");
19399 if (pcap_file_set > 0)
19401 if (vec_len (pcap_file) > 255)
19403 errmsg ("pcap file name is too long");
19408 u32 name_len = vec_len (pcap_file);
19409 /* Construct the API message */
19410 M (PG_CAPTURE, mp);
19412 mp->interface_id = ntohl (if_id);
19413 mp->is_enabled = enable;
19414 mp->count = ntohl (count);
19415 mp->pcap_name_length = ntohl (name_len);
19416 if (pcap_file_set != 0)
19418 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19420 vec_free (pcap_file);
19428 api_pg_enable_disable (vat_main_t * vam)
19430 unformat_input_t *input = vam->input;
19431 vl_api_pg_enable_disable_t *mp;
19434 u8 stream_name_set = 0;
19435 u8 *stream_name = 0;
19437 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19439 if (unformat (input, "stream %s", &stream_name))
19440 stream_name_set = 1;
19441 else if (unformat (input, "disable"))
19447 if (stream_name_set > 0)
19449 if (vec_len (stream_name) > 255)
19451 errmsg ("stream name too long");
19456 u32 name_len = vec_len (stream_name);
19457 /* Construct the API message */
19458 M (PG_ENABLE_DISABLE, mp);
19460 mp->is_enabled = enable;
19461 if (stream_name_set != 0)
19463 mp->stream_name_length = ntohl (name_len);
19464 clib_memcpy (mp->stream_name, stream_name, name_len);
19466 vec_free (stream_name);
19474 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19476 unformat_input_t *input = vam->input;
19477 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19479 u16 *low_ports = 0;
19480 u16 *high_ports = 0;
19483 vl_api_prefix_t prefix;
19490 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19492 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19494 else if (unformat (input, "vrf %d", &vrf_id))
19496 else if (unformat (input, "del"))
19498 else if (unformat (input, "port %d", &tmp))
19500 if (tmp == 0 || tmp > 65535)
19502 errmsg ("port %d out of range", tmp);
19506 this_hi = this_low + 1;
19507 vec_add1 (low_ports, this_low);
19508 vec_add1 (high_ports, this_hi);
19510 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19512 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19514 errmsg ("incorrect range parameters");
19518 /* Note: in debug CLI +1 is added to high before
19519 passing to real fn that does "the work"
19520 (ip_source_and_port_range_check_add_del).
19521 This fn is a wrapper around the binary API fn a
19522 control plane will call, which expects this increment
19523 to have occurred. Hence letting the binary API control
19524 plane fn do the increment for consistency between VAT
19525 and other control planes.
19528 vec_add1 (low_ports, this_low);
19529 vec_add1 (high_ports, this_hi);
19535 if (prefix_set == 0)
19537 errmsg ("<address>/<mask> not specified");
19543 errmsg ("VRF ID required, not specified");
19550 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19554 if (vec_len (low_ports) == 0)
19556 errmsg ("At least one port or port range required");
19560 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19562 mp->is_add = is_add;
19564 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19566 mp->number_of_ranges = vec_len (low_ports);
19568 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19569 vec_free (low_ports);
19571 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19572 vec_free (high_ports);
19574 mp->vrf_id = ntohl (vrf_id);
19582 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19584 unformat_input_t *input = vam->input;
19585 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19586 u32 sw_if_index = ~0;
19588 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19589 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19595 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19597 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19599 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19601 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19603 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19605 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19607 else if (unformat (input, "del"))
19613 if (sw_if_index == ~0)
19615 errmsg ("Interface required but not specified");
19621 errmsg ("VRF ID required but not specified");
19625 if (tcp_out_vrf_id == 0
19626 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19629 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19633 /* Construct the API message */
19634 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19636 mp->sw_if_index = ntohl (sw_if_index);
19637 mp->is_add = is_add;
19638 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19639 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19640 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19641 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19646 /* Wait for a reply... */
19652 api_set_punt (vat_main_t * vam)
19654 unformat_input_t *i = vam->input;
19655 vl_api_address_family_t af;
19656 vl_api_set_punt_t *mp;
19662 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19664 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
19666 else if (unformat (i, "protocol %d", &protocol))
19668 else if (unformat (i, "port %d", &port))
19670 else if (unformat (i, "del"))
19674 clib_warning ("parse error '%U'", format_unformat_error, i);
19681 mp->is_add = (u8) is_add;
19682 mp->punt.type = PUNT_API_TYPE_L4;
19683 mp->punt.punt.l4.af = af;
19684 mp->punt.punt.l4.protocol = (u8) protocol;
19685 mp->punt.punt.l4.port = htons ((u16) port);
19693 api_delete_subif (vat_main_t * vam)
19695 unformat_input_t *i = vam->input;
19696 vl_api_delete_subif_t *mp;
19697 u32 sw_if_index = ~0;
19700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19704 if (unformat (i, "sw_if_index %d", &sw_if_index))
19710 if (sw_if_index == ~0)
19712 errmsg ("missing sw_if_index");
19716 /* Construct the API message */
19717 M (DELETE_SUBIF, mp);
19718 mp->sw_if_index = ntohl (sw_if_index);
19725 #define foreach_pbb_vtr_op \
19726 _("disable", L2_VTR_DISABLED) \
19727 _("pop", L2_VTR_POP_2) \
19728 _("push", L2_VTR_PUSH_2)
19731 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19733 unformat_input_t *i = vam->input;
19734 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19735 u32 sw_if_index = ~0, vtr_op = ~0;
19736 u16 outer_tag = ~0;
19737 u8 dmac[6], smac[6];
19738 u8 dmac_set = 0, smac_set = 0;
19744 /* Shut up coverity */
19745 clib_memset (dmac, 0, sizeof (dmac));
19746 clib_memset (smac, 0, sizeof (smac));
19748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19750 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19752 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19754 else if (unformat (i, "vtr_op %d", &vtr_op))
19756 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19759 else if (unformat (i, "translate_pbb_stag"))
19761 if (unformat (i, "%d", &tmp))
19763 vtr_op = L2_VTR_TRANSLATE_2_1;
19769 ("translate_pbb_stag operation requires outer tag definition");
19773 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19775 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19777 else if (unformat (i, "sid %d", &sid))
19779 else if (unformat (i, "vlanid %d", &tmp))
19783 clib_warning ("parse error '%U'", format_unformat_error, i);
19788 if ((sw_if_index == ~0) || (vtr_op == ~0))
19790 errmsg ("missing sw_if_index or vtr operation");
19793 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19794 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19797 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19801 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19802 mp->sw_if_index = ntohl (sw_if_index);
19803 mp->vtr_op = ntohl (vtr_op);
19804 mp->outer_tag = ntohs (outer_tag);
19805 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19806 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19807 mp->b_vlanid = ntohs (vlanid);
19808 mp->i_sid = ntohl (sid);
19816 api_flow_classify_set_interface (vat_main_t * vam)
19818 unformat_input_t *i = vam->input;
19819 vl_api_flow_classify_set_interface_t *mp;
19821 int sw_if_index_set;
19822 u32 ip4_table_index = ~0;
19823 u32 ip6_table_index = ~0;
19827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19830 sw_if_index_set = 1;
19831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19832 sw_if_index_set = 1;
19833 else if (unformat (i, "del"))
19835 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19837 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19841 clib_warning ("parse error '%U'", format_unformat_error, i);
19846 if (sw_if_index_set == 0)
19848 errmsg ("missing interface name or sw_if_index");
19852 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19854 mp->sw_if_index = ntohl (sw_if_index);
19855 mp->ip4_table_index = ntohl (ip4_table_index);
19856 mp->ip6_table_index = ntohl (ip6_table_index);
19857 mp->is_add = is_add;
19865 api_flow_classify_dump (vat_main_t * vam)
19867 unformat_input_t *i = vam->input;
19868 vl_api_flow_classify_dump_t *mp;
19869 vl_api_control_ping_t *mp_ping;
19870 u8 type = FLOW_CLASSIFY_N_TABLES;
19873 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19877 errmsg ("classify table type must be specified");
19881 if (!vam->json_output)
19883 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19886 M (FLOW_CLASSIFY_DUMP, mp);
19891 /* Use a control ping for synchronization */
19892 MPING (CONTROL_PING, mp_ping);
19895 /* Wait for a reply... */
19901 api_feature_enable_disable (vat_main_t * vam)
19903 unformat_input_t *i = vam->input;
19904 vl_api_feature_enable_disable_t *mp;
19906 u8 *feature_name = 0;
19907 u32 sw_if_index = ~0;
19911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19913 if (unformat (i, "arc_name %s", &arc_name))
19915 else if (unformat (i, "feature_name %s", &feature_name))
19918 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19920 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19922 else if (unformat (i, "disable"))
19930 errmsg ("missing arc name");
19933 if (vec_len (arc_name) > 63)
19935 errmsg ("arc name too long");
19938 if (feature_name == 0)
19940 errmsg ("missing feature name");
19943 if (vec_len (feature_name) > 63)
19945 errmsg ("feature name too long");
19948 if (sw_if_index == ~0)
19950 errmsg ("missing interface name or sw_if_index");
19954 /* Construct the API message */
19955 M (FEATURE_ENABLE_DISABLE, mp);
19956 mp->sw_if_index = ntohl (sw_if_index);
19957 mp->enable = enable;
19958 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19959 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19960 vec_free (arc_name);
19961 vec_free (feature_name);
19969 api_sw_interface_tag_add_del (vat_main_t * vam)
19971 unformat_input_t *i = vam->input;
19972 vl_api_sw_interface_tag_add_del_t *mp;
19973 u32 sw_if_index = ~0;
19978 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19980 if (unformat (i, "tag %s", &tag))
19982 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19984 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19986 else if (unformat (i, "del"))
19992 if (sw_if_index == ~0)
19994 errmsg ("missing interface name or sw_if_index");
19998 if (enable && (tag == 0))
20000 errmsg ("no tag specified");
20004 /* Construct the API message */
20005 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20006 mp->sw_if_index = ntohl (sw_if_index);
20007 mp->is_add = enable;
20009 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20018 api_sw_interface_add_del_mac_address (vat_main_t * vam)
20020 unformat_input_t *i = vam->input;
20021 vl_api_mac_address_t mac = { 0 };
20022 vl_api_sw_interface_add_del_mac_address_t *mp;
20023 u32 sw_if_index = ~0;
20028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20030 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20032 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20034 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
20036 else if (unformat (i, "del"))
20042 if (sw_if_index == ~0)
20044 errmsg ("missing interface name or sw_if_index");
20050 errmsg ("missing MAC address");
20054 /* Construct the API message */
20055 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
20056 mp->sw_if_index = ntohl (sw_if_index);
20057 mp->is_add = is_add;
20058 clib_memcpy (&mp->addr, &mac, sizeof (mac));
20065 static void vl_api_l2_xconnect_details_t_handler
20066 (vl_api_l2_xconnect_details_t * mp)
20068 vat_main_t *vam = &vat_main;
20070 print (vam->ofp, "%15d%15d",
20071 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20074 static void vl_api_l2_xconnect_details_t_handler_json
20075 (vl_api_l2_xconnect_details_t * mp)
20077 vat_main_t *vam = &vat_main;
20078 vat_json_node_t *node = NULL;
20080 if (VAT_JSON_ARRAY != vam->json_tree.type)
20082 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20083 vat_json_init_array (&vam->json_tree);
20085 node = vat_json_array_add (&vam->json_tree);
20087 vat_json_init_object (node);
20088 vat_json_object_add_uint (node, "rx_sw_if_index",
20089 ntohl (mp->rx_sw_if_index));
20090 vat_json_object_add_uint (node, "tx_sw_if_index",
20091 ntohl (mp->tx_sw_if_index));
20095 api_l2_xconnect_dump (vat_main_t * vam)
20097 vl_api_l2_xconnect_dump_t *mp;
20098 vl_api_control_ping_t *mp_ping;
20101 if (!vam->json_output)
20103 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20106 M (L2_XCONNECT_DUMP, mp);
20110 /* Use a control ping for synchronization */
20111 MPING (CONTROL_PING, mp_ping);
20119 api_hw_interface_set_mtu (vat_main_t * vam)
20121 unformat_input_t *i = vam->input;
20122 vl_api_hw_interface_set_mtu_t *mp;
20123 u32 sw_if_index = ~0;
20127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20129 if (unformat (i, "mtu %d", &mtu))
20131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20139 if (sw_if_index == ~0)
20141 errmsg ("missing interface name or sw_if_index");
20147 errmsg ("no mtu specified");
20151 /* Construct the API message */
20152 M (HW_INTERFACE_SET_MTU, mp);
20153 mp->sw_if_index = ntohl (sw_if_index);
20154 mp->mtu = ntohs ((u16) mtu);
20162 api_p2p_ethernet_add (vat_main_t * vam)
20164 unformat_input_t *i = vam->input;
20165 vl_api_p2p_ethernet_add_t *mp;
20166 u32 parent_if_index = ~0;
20172 clib_memset (remote_mac, 0, sizeof (remote_mac));
20173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20175 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20177 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20181 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20183 else if (unformat (i, "sub_id %d", &sub_id))
20187 clib_warning ("parse error '%U'", format_unformat_error, i);
20192 if (parent_if_index == ~0)
20194 errmsg ("missing interface name or sw_if_index");
20199 errmsg ("missing remote mac address");
20204 errmsg ("missing sub-interface id");
20208 M (P2P_ETHERNET_ADD, mp);
20209 mp->parent_if_index = ntohl (parent_if_index);
20210 mp->subif_id = ntohl (sub_id);
20211 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20219 api_p2p_ethernet_del (vat_main_t * vam)
20221 unformat_input_t *i = vam->input;
20222 vl_api_p2p_ethernet_del_t *mp;
20223 u32 parent_if_index = ~0;
20228 clib_memset (remote_mac, 0, sizeof (remote_mac));
20229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20233 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20237 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20241 clib_warning ("parse error '%U'", format_unformat_error, i);
20246 if (parent_if_index == ~0)
20248 errmsg ("missing interface name or sw_if_index");
20253 errmsg ("missing remote mac address");
20257 M (P2P_ETHERNET_DEL, mp);
20258 mp->parent_if_index = ntohl (parent_if_index);
20259 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20267 api_lldp_config (vat_main_t * vam)
20269 unformat_input_t *i = vam->input;
20270 vl_api_lldp_config_t *mp;
20272 int tx_interval = 0;
20273 u8 *sys_name = NULL;
20276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20278 if (unformat (i, "system-name %s", &sys_name))
20280 else if (unformat (i, "tx-hold %d", &tx_hold))
20282 else if (unformat (i, "tx-interval %d", &tx_interval))
20286 clib_warning ("parse error '%U'", format_unformat_error, i);
20291 vec_add1 (sys_name, 0);
20293 M (LLDP_CONFIG, mp);
20294 mp->tx_hold = htonl (tx_hold);
20295 mp->tx_interval = htonl (tx_interval);
20296 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20297 vec_free (sys_name);
20305 api_sw_interface_set_lldp (vat_main_t * vam)
20307 unformat_input_t *i = vam->input;
20308 vl_api_sw_interface_set_lldp_t *mp;
20309 u32 sw_if_index = ~0;
20311 u8 *port_desc = NULL, *mgmt_oid = NULL;
20312 ip4_address_t ip4_addr;
20313 ip6_address_t ip6_addr;
20316 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20317 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20321 if (unformat (i, "disable"))
20324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20328 else if (unformat (i, "port-desc %s", &port_desc))
20330 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20332 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20334 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20340 if (sw_if_index == ~0)
20342 errmsg ("missing interface name or sw_if_index");
20346 /* Construct the API message */
20347 vec_add1 (port_desc, 0);
20348 vec_add1 (mgmt_oid, 0);
20349 M (SW_INTERFACE_SET_LLDP, mp);
20350 mp->sw_if_index = ntohl (sw_if_index);
20351 mp->enable = enable;
20352 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20353 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20354 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20355 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20356 vec_free (port_desc);
20357 vec_free (mgmt_oid);
20365 api_tcp_configure_src_addresses (vat_main_t * vam)
20367 vl_api_tcp_configure_src_addresses_t *mp;
20368 unformat_input_t *i = vam->input;
20369 ip4_address_t v4first, v4last;
20370 ip6_address_t v6first, v6last;
20375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20377 if (unformat (i, "%U - %U",
20378 unformat_ip4_address, &v4first,
20379 unformat_ip4_address, &v4last))
20383 errmsg ("one range per message (range already set)");
20388 else if (unformat (i, "%U - %U",
20389 unformat_ip6_address, &v6first,
20390 unformat_ip6_address, &v6last))
20394 errmsg ("one range per message (range already set)");
20399 else if (unformat (i, "vrf %d", &vrf_id))
20405 if (range_set == 0)
20407 errmsg ("address range not set");
20411 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20412 mp->vrf_id = ntohl (vrf_id);
20414 if (range_set == 2)
20417 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20418 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20423 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20424 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20431 static void vl_api_app_namespace_add_del_reply_t_handler
20432 (vl_api_app_namespace_add_del_reply_t * mp)
20434 vat_main_t *vam = &vat_main;
20435 i32 retval = ntohl (mp->retval);
20436 if (vam->async_mode)
20438 vam->async_errors += (retval < 0);
20442 vam->retval = retval;
20444 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20445 vam->result_ready = 1;
20449 static void vl_api_app_namespace_add_del_reply_t_handler_json
20450 (vl_api_app_namespace_add_del_reply_t * mp)
20452 vat_main_t *vam = &vat_main;
20453 vat_json_node_t node;
20455 vat_json_init_object (&node);
20456 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20457 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20459 vat_json_print (vam->ofp, &node);
20460 vat_json_free (&node);
20462 vam->retval = ntohl (mp->retval);
20463 vam->result_ready = 1;
20467 api_app_namespace_add_del (vat_main_t * vam)
20469 vl_api_app_namespace_add_del_t *mp;
20470 unformat_input_t *i = vam->input;
20471 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20472 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20476 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20478 if (unformat (i, "id %_%v%_", &ns_id))
20480 else if (unformat (i, "secret %lu", &secret))
20482 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20483 sw_if_index_set = 1;
20484 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20486 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20491 if (!ns_id || !secret_set || !sw_if_index_set)
20493 errmsg ("namespace id, secret and sw_if_index must be set");
20496 if (vec_len (ns_id) > 64)
20498 errmsg ("namespace id too long");
20501 M (APP_NAMESPACE_ADD_DEL, mp);
20503 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20504 mp->namespace_id_len = vec_len (ns_id);
20505 mp->secret = clib_host_to_net_u64 (secret);
20506 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20507 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20508 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20516 api_sock_init_shm (vat_main_t * vam)
20518 #if VPP_API_TEST_BUILTIN == 0
20519 unformat_input_t *i = vam->input;
20520 vl_api_shm_elem_config_t *config = 0;
20521 u64 size = 64 << 20;
20524 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20526 if (unformat (i, "size %U", unformat_memory_size, &size))
20533 * Canned custom ring allocator config.
20534 * Should probably parse all of this
20536 vec_validate (config, 6);
20537 config[0].type = VL_API_VLIB_RING;
20538 config[0].size = 256;
20539 config[0].count = 32;
20541 config[1].type = VL_API_VLIB_RING;
20542 config[1].size = 1024;
20543 config[1].count = 16;
20545 config[2].type = VL_API_VLIB_RING;
20546 config[2].size = 4096;
20547 config[2].count = 2;
20549 config[3].type = VL_API_CLIENT_RING;
20550 config[3].size = 256;
20551 config[3].count = 32;
20553 config[4].type = VL_API_CLIENT_RING;
20554 config[4].size = 1024;
20555 config[4].count = 16;
20557 config[5].type = VL_API_CLIENT_RING;
20558 config[5].size = 4096;
20559 config[5].count = 2;
20561 config[6].type = VL_API_QUEUE;
20562 config[6].count = 128;
20563 config[6].size = sizeof (uword);
20565 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20567 vam->client_index_invalid = 1;
20575 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20577 vat_main_t *vam = &vat_main;
20582 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20583 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20584 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20585 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20586 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20587 clib_net_to_host_u32 (mp->action_index), mp->tag);
20592 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20593 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20594 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20595 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20596 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20597 clib_net_to_host_u32 (mp->action_index), mp->tag);
20602 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20605 vat_main_t *vam = &vat_main;
20606 vat_json_node_t *node = NULL;
20607 struct in6_addr ip6;
20608 struct in_addr ip4;
20610 if (VAT_JSON_ARRAY != vam->json_tree.type)
20612 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20613 vat_json_init_array (&vam->json_tree);
20615 node = vat_json_array_add (&vam->json_tree);
20616 vat_json_init_object (node);
20618 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20619 vat_json_object_add_uint (node, "appns_index",
20620 clib_net_to_host_u32 (mp->appns_index));
20621 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20622 vat_json_object_add_uint (node, "scope", mp->scope);
20623 vat_json_object_add_uint (node, "action_index",
20624 clib_net_to_host_u32 (mp->action_index));
20625 vat_json_object_add_uint (node, "lcl_port",
20626 clib_net_to_host_u16 (mp->lcl_port));
20627 vat_json_object_add_uint (node, "rmt_port",
20628 clib_net_to_host_u16 (mp->rmt_port));
20629 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20630 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20631 vat_json_object_add_string_copy (node, "tag", mp->tag);
20634 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20635 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20636 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20637 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20641 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20642 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20643 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20644 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20649 api_session_rule_add_del (vat_main_t * vam)
20651 vl_api_session_rule_add_del_t *mp;
20652 unformat_input_t *i = vam->input;
20653 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20654 u32 appns_index = 0, scope = 0;
20655 ip4_address_t lcl_ip4, rmt_ip4;
20656 ip6_address_t lcl_ip6, rmt_ip6;
20657 u8 is_ip4 = 1, conn_set = 0;
20658 u8 is_add = 1, *tag = 0;
20661 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20663 if (unformat (i, "del"))
20665 else if (unformat (i, "add"))
20667 else if (unformat (i, "proto tcp"))
20669 else if (unformat (i, "proto udp"))
20671 else if (unformat (i, "appns %d", &appns_index))
20673 else if (unformat (i, "scope %d", &scope))
20675 else if (unformat (i, "tag %_%v%_", &tag))
20679 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
20680 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
20688 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
20689 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
20695 else if (unformat (i, "action %d", &action))
20700 if (proto == ~0 || !conn_set || action == ~0)
20702 errmsg ("transport proto, connection and action must be set");
20708 errmsg ("scope should be 0-3");
20712 M (SESSION_RULE_ADD_DEL, mp);
20714 mp->is_ip4 = is_ip4;
20715 mp->transport_proto = proto;
20716 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20717 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20718 mp->lcl_plen = lcl_plen;
20719 mp->rmt_plen = rmt_plen;
20720 mp->action_index = clib_host_to_net_u32 (action);
20721 mp->appns_index = clib_host_to_net_u32 (appns_index);
20723 mp->is_add = is_add;
20726 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
20727 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
20731 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
20732 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
20736 clib_memcpy (mp->tag, tag, vec_len (tag));
20746 api_session_rules_dump (vat_main_t * vam)
20748 vl_api_session_rules_dump_t *mp;
20749 vl_api_control_ping_t *mp_ping;
20752 if (!vam->json_output)
20754 print (vam->ofp, "%=20s", "Session Rules");
20757 M (SESSION_RULES_DUMP, mp);
20761 /* Use a control ping for synchronization */
20762 MPING (CONTROL_PING, mp_ping);
20765 /* Wait for a reply... */
20771 api_ip_container_proxy_add_del (vat_main_t * vam)
20773 vl_api_ip_container_proxy_add_del_t *mp;
20774 unformat_input_t *i = vam->input;
20775 u32 sw_if_index = ~0;
20776 vl_api_prefix_t pfx = { };
20780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20782 if (unformat (i, "del"))
20784 else if (unformat (i, "add"))
20786 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20788 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20793 if (sw_if_index == ~0 || pfx.len == 0)
20795 errmsg ("address and sw_if_index must be set");
20799 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20801 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20802 mp->is_add = is_add;
20803 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20811 api_qos_record_enable_disable (vat_main_t * vam)
20813 unformat_input_t *i = vam->input;
20814 vl_api_qos_record_enable_disable_t *mp;
20815 u32 sw_if_index, qs = 0xff;
20816 u8 sw_if_index_set = 0;
20820 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20822 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20823 sw_if_index_set = 1;
20824 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20825 sw_if_index_set = 1;
20826 else if (unformat (i, "%U", unformat_qos_source, &qs))
20828 else if (unformat (i, "disable"))
20832 clib_warning ("parse error '%U'", format_unformat_error, i);
20837 if (sw_if_index_set == 0)
20839 errmsg ("missing interface name or sw_if_index");
20844 errmsg ("input location must be specified");
20848 M (QOS_RECORD_ENABLE_DISABLE, mp);
20850 mp->record.sw_if_index = ntohl (sw_if_index);
20851 mp->record.input_source = qs;
20852 mp->enable = enable;
20861 q_or_quit (vat_main_t * vam)
20863 #if VPP_API_TEST_BUILTIN == 0
20864 longjmp (vam->jump_buf, 1);
20866 return 0; /* not so much */
20870 q (vat_main_t * vam)
20872 return q_or_quit (vam);
20876 quit (vat_main_t * vam)
20878 return q_or_quit (vam);
20882 comment (vat_main_t * vam)
20888 elog_save (vat_main_t * vam)
20890 #if VPP_API_TEST_BUILTIN == 0
20891 elog_main_t *em = &vam->elog_main;
20892 unformat_input_t *i = vam->input;
20893 char *file, *chroot_file;
20894 clib_error_t *error;
20896 if (!unformat (i, "%s", &file))
20898 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20902 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20903 if (strstr (file, "..") || index (file, '/'))
20905 errmsg ("illegal characters in filename '%s'", file);
20909 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20913 errmsg ("Saving %wd of %wd events to %s",
20914 elog_n_events_in_buffer (em),
20915 elog_buffer_capacity (em), chroot_file);
20917 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20918 vec_free (chroot_file);
20921 clib_error_report (error);
20923 errmsg ("Use the vpp event loger...");
20930 elog_setup (vat_main_t * vam)
20932 #if VPP_API_TEST_BUILTIN == 0
20933 elog_main_t *em = &vam->elog_main;
20934 unformat_input_t *i = vam->input;
20935 u32 nevents = 128 << 10;
20937 (void) unformat (i, "nevents %d", &nevents);
20939 elog_init (em, nevents);
20940 vl_api_set_elog_main (em);
20941 vl_api_set_elog_trace_api_messages (1);
20942 errmsg ("Event logger initialized with %u events", nevents);
20944 errmsg ("Use the vpp event loger...");
20950 elog_enable (vat_main_t * vam)
20952 #if VPP_API_TEST_BUILTIN == 0
20953 elog_main_t *em = &vam->elog_main;
20955 elog_enable_disable (em, 1 /* enable */ );
20956 vl_api_set_elog_trace_api_messages (1);
20957 errmsg ("Event logger enabled...");
20959 errmsg ("Use the vpp event loger...");
20965 elog_disable (vat_main_t * vam)
20967 #if VPP_API_TEST_BUILTIN == 0
20968 elog_main_t *em = &vam->elog_main;
20970 elog_enable_disable (em, 0 /* enable */ );
20971 vl_api_set_elog_trace_api_messages (1);
20972 errmsg ("Event logger disabled...");
20974 errmsg ("Use the vpp event loger...");
20980 statseg (vat_main_t * vam)
20982 ssvm_private_t *ssvmp = &vam->stat_segment;
20983 ssvm_shared_header_t *shared_header = ssvmp->sh;
20984 vlib_counter_t **counters;
20985 u64 thread0_index1_packets;
20986 u64 thread0_index1_bytes;
20987 f64 vector_rate, input_rate;
20990 uword *counter_vector_by_name;
20991 if (vam->stat_segment_lockp == 0)
20993 errmsg ("Stat segment not mapped...");
20997 /* look up "/if/rx for sw_if_index 1 as a test */
20999 clib_spinlock_lock (vam->stat_segment_lockp);
21001 counter_vector_by_name = (uword *) shared_header->opaque[1];
21003 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21006 clib_spinlock_unlock (vam->stat_segment_lockp);
21007 errmsg ("/if/tx not found?");
21011 /* Fish per-thread vector of combined counters from shared memory */
21012 counters = (vlib_counter_t **) p[0];
21014 if (vec_len (counters[0]) < 2)
21016 clib_spinlock_unlock (vam->stat_segment_lockp);
21017 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21021 /* Read thread 0 sw_if_index 1 counter */
21022 thread0_index1_packets = counters[0][1].packets;
21023 thread0_index1_bytes = counters[0][1].bytes;
21025 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21028 clib_spinlock_unlock (vam->stat_segment_lockp);
21029 errmsg ("vector_rate not found?");
21033 vector_rate = *(f64 *) (p[0]);
21034 p = hash_get_mem (counter_vector_by_name, "input_rate");
21037 clib_spinlock_unlock (vam->stat_segment_lockp);
21038 errmsg ("input_rate not found?");
21041 input_rate = *(f64 *) (p[0]);
21043 clib_spinlock_unlock (vam->stat_segment_lockp);
21045 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21046 vector_rate, input_rate);
21047 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21048 thread0_index1_packets, thread0_index1_bytes);
21054 cmd_cmp (void *a1, void *a2)
21059 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21063 help (vat_main_t * vam)
21068 unformat_input_t *i = vam->input;
21071 if (unformat (i, "%s", &name))
21075 vec_add1 (name, 0);
21077 hs = hash_get_mem (vam->help_by_name, name);
21079 print (vam->ofp, "usage: %s %s", name, hs[0]);
21081 print (vam->ofp, "No such msg / command '%s'", name);
21086 print (vam->ofp, "Help is available for the following:");
21089 hash_foreach_pair (p, vam->function_by_name,
21091 vec_add1 (cmds, (u8 *)(p->key));
21095 vec_sort_with_function (cmds, cmd_cmp);
21097 for (j = 0; j < vec_len (cmds); j++)
21098 print (vam->ofp, "%s", cmds[j]);
21105 set (vat_main_t * vam)
21107 u8 *name = 0, *value = 0;
21108 unformat_input_t *i = vam->input;
21110 if (unformat (i, "%s", &name))
21112 /* The input buffer is a vector, not a string. */
21113 value = vec_dup (i->buffer);
21114 vec_delete (value, i->index, 0);
21115 /* Almost certainly has a trailing newline */
21116 if (value[vec_len (value) - 1] == '\n')
21117 value[vec_len (value) - 1] = 0;
21118 /* Make sure it's a proper string, one way or the other */
21119 vec_add1 (value, 0);
21120 (void) clib_macro_set_value (&vam->macro_main,
21121 (char *) name, (char *) value);
21124 errmsg ("usage: set <name> <value>");
21132 unset (vat_main_t * vam)
21136 if (unformat (vam->input, "%s", &name))
21137 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21138 errmsg ("unset: %s wasn't set", name);
21151 macro_sort_cmp (void *a1, void *a2)
21153 macro_sort_t *s1 = a1;
21154 macro_sort_t *s2 = a2;
21156 return strcmp ((char *) (s1->name), (char *) (s2->name));
21160 dump_macro_table (vat_main_t * vam)
21162 macro_sort_t *sort_me = 0, *sm;
21167 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21169 vec_add2 (sort_me, sm, 1);
21170 sm->name = (u8 *)(p->key);
21171 sm->value = (u8 *) (p->value[0]);
21175 vec_sort_with_function (sort_me, macro_sort_cmp);
21177 if (vec_len (sort_me))
21178 print (vam->ofp, "%-15s%s", "Name", "Value");
21180 print (vam->ofp, "The macro table is empty...");
21182 for (i = 0; i < vec_len (sort_me); i++)
21183 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21188 dump_node_table (vat_main_t * vam)
21191 vlib_node_t *node, *next_node;
21193 if (vec_len (vam->graph_nodes) == 0)
21195 print (vam->ofp, "Node table empty, issue get_node_graph...");
21199 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21201 node = vam->graph_nodes[0][i];
21202 print (vam->ofp, "[%d] %s", i, node->name);
21203 for (j = 0; j < vec_len (node->next_nodes); j++)
21205 if (node->next_nodes[j] != ~0)
21207 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21208 print (vam->ofp, " [%d] %s", j, next_node->name);
21216 value_sort_cmp (void *a1, void *a2)
21218 name_sort_t *n1 = a1;
21219 name_sort_t *n2 = a2;
21221 if (n1->value < n2->value)
21223 if (n1->value > n2->value)
21230 dump_msg_api_table (vat_main_t * vam)
21232 api_main_t *am = &api_main;
21233 name_sort_t *nses = 0, *ns;
21238 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21240 vec_add2 (nses, ns, 1);
21241 ns->name = (u8 *)(hp->key);
21242 ns->value = (u32) hp->value[0];
21246 vec_sort_with_function (nses, value_sort_cmp);
21248 for (i = 0; i < vec_len (nses); i++)
21249 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21255 get_msg_id (vat_main_t * vam)
21260 if (unformat (vam->input, "%s", &name_and_crc))
21262 message_index = vl_msg_api_get_msg_index (name_and_crc);
21263 if (message_index == ~0)
21265 print (vam->ofp, " '%s' not found", name_and_crc);
21268 print (vam->ofp, " '%s' has message index %d",
21269 name_and_crc, message_index);
21272 errmsg ("name_and_crc required...");
21277 search_node_table (vat_main_t * vam)
21279 unformat_input_t *line_input = vam->input;
21282 vlib_node_t *node, *next_node;
21285 if (vam->graph_node_index_by_name == 0)
21287 print (vam->ofp, "Node table empty, issue get_node_graph...");
21291 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21293 if (unformat (line_input, "%s", &node_to_find))
21295 vec_add1 (node_to_find, 0);
21296 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21299 print (vam->ofp, "%s not found...", node_to_find);
21302 node = vam->graph_nodes[0][p[0]];
21303 print (vam->ofp, "[%d] %s", p[0], node->name);
21304 for (j = 0; j < vec_len (node->next_nodes); j++)
21306 if (node->next_nodes[j] != ~0)
21308 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21309 print (vam->ofp, " [%d] %s", j, next_node->name);
21316 clib_warning ("parse error '%U'", format_unformat_error,
21322 vec_free (node_to_find);
21331 script (vat_main_t * vam)
21333 #if (VPP_API_TEST_BUILTIN==0)
21335 char *save_current_file;
21336 unformat_input_t save_input;
21337 jmp_buf save_jump_buf;
21338 u32 save_line_number;
21340 FILE *new_fp, *save_ifp;
21342 if (unformat (vam->input, "%s", &s))
21344 new_fp = fopen ((char *) s, "r");
21347 errmsg ("Couldn't open script file %s", s);
21354 errmsg ("Missing script name");
21358 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21359 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21360 save_ifp = vam->ifp;
21361 save_line_number = vam->input_line_number;
21362 save_current_file = (char *) vam->current_file;
21364 vam->input_line_number = 0;
21366 vam->current_file = s;
21369 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21370 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21371 vam->ifp = save_ifp;
21372 vam->input_line_number = save_line_number;
21373 vam->current_file = (u8 *) save_current_file;
21378 clib_warning ("use the exec command...");
21384 echo (vat_main_t * vam)
21386 print (vam->ofp, "%v", vam->input->buffer);
21390 /* List of API message constructors, CLI names map to api_xxx */
21391 #define foreach_vpe_api_msg \
21392 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21393 _(sw_interface_dump,"") \
21394 _(sw_interface_set_flags, \
21395 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21396 _(sw_interface_add_del_address, \
21397 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21398 _(sw_interface_set_rx_mode, \
21399 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21400 _(sw_interface_set_rx_placement, \
21401 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21402 _(sw_interface_rx_placement_dump, \
21403 "[<intfc> | sw_if_index <id>]") \
21404 _(sw_interface_set_table, \
21405 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21406 _(sw_interface_set_mpls_enable, \
21407 "<intfc> | sw_if_index [disable | dis]") \
21408 _(sw_interface_set_vpath, \
21409 "<intfc> | sw_if_index <id> enable | disable") \
21410 _(sw_interface_set_vxlan_bypass, \
21411 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21412 _(sw_interface_set_geneve_bypass, \
21413 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21414 _(sw_interface_set_l2_xconnect, \
21415 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21416 "enable | disable") \
21417 _(sw_interface_set_l2_bridge, \
21418 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21419 "[shg <split-horizon-group>] [bvi]\n" \
21420 "enable | disable") \
21421 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21422 _(bridge_domain_add_del, \
21423 "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") \
21424 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21426 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21427 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21428 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21430 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21432 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21434 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21436 "<vpp-if-name> | sw_if_index <id>") \
21437 _(sw_interface_tap_v2_dump, "") \
21438 _(virtio_pci_create, \
21439 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21440 _(virtio_pci_delete, \
21441 "<vpp-if-name> | sw_if_index <id>") \
21442 _(sw_interface_virtio_pci_dump, "") \
21444 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21445 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21448 "<vpp-if-name> | sw_if_index <id>") \
21450 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21451 _(bond_detach_slave, \
21452 "sw_if_index <n>") \
21453 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21454 _(sw_interface_bond_dump, "") \
21455 _(sw_interface_slave_dump, \
21456 "<vpp-if-name> | sw_if_index <id>") \
21457 _(ip_table_add_del, \
21458 "table <n> [ipv6] [add | del]\n") \
21459 _(ip_route_add_del, \
21460 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21461 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21462 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21463 "[multipath] [count <n>] [del]") \
21464 _(ip_mroute_add_del, \
21465 "<src> <grp>/<mask> [table-id <n>]\n" \
21466 "[<intfc> | sw_if_index <id>] [local] [del]") \
21467 _(mpls_table_add_del, \
21468 "table <n> [add | del]\n") \
21469 _(mpls_route_add_del, \
21470 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21471 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21472 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21473 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21474 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21475 "[count <n>] [del]") \
21476 _(mpls_ip_bind_unbind, \
21477 "<label> <addr/len>") \
21478 _(mpls_tunnel_add_del, \
21479 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21480 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21481 "[l2-only] [out-label <n>]") \
21482 _(sr_mpls_policy_add, \
21483 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21484 _(sr_mpls_policy_del, \
21486 _(bier_table_add_del, \
21487 "<label> <sub-domain> <set> <bsl> [del]") \
21488 _(bier_route_add_del, \
21489 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21490 "[<intfc> | sw_if_index <id>]" \
21491 "[weight <n>] [del] [multipath]") \
21492 _(proxy_arp_add_del, \
21493 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21494 _(proxy_arp_intfc_enable_disable, \
21495 "<intfc> | sw_if_index <id> enable | disable") \
21496 _(sw_interface_set_unnumbered, \
21497 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21498 _(ip_neighbor_add_del, \
21499 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21500 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21501 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21502 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21503 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21504 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21505 "[outer_vlan_id_any][inner_vlan_id_any]") \
21506 _(reset_fib, "vrf <n> [ipv6]") \
21507 _(set_ip_flow_hash, \
21508 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21509 _(sw_interface_ip6_enable_disable, \
21510 "<intfc> | sw_if_index <id> enable | disable") \
21511 _(ip6nd_proxy_add_del, \
21512 "<intfc> | sw_if_index <id> <ip6-address>") \
21513 _(ip6nd_proxy_dump, "") \
21514 _(sw_interface_ip6nd_ra_prefix, \
21515 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21516 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21517 "[nolink] [isno]") \
21518 _(sw_interface_ip6nd_ra_config, \
21519 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21520 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21521 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21522 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21523 _(l2_patch_add_del, \
21524 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21525 "enable | disable") \
21526 _(sr_localsid_add_del, \
21527 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21528 "fib-table <num> (end.psp) sw_if_index <num>") \
21529 _(classify_add_del_table, \
21530 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21531 " [del] [del-chain] mask <mask-value>\n" \
21532 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21533 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21534 _(classify_add_del_session, \
21535 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21536 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21537 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21538 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21539 _(classify_set_interface_ip_table, \
21540 "<intfc> | sw_if_index <nn> table <nn>") \
21541 _(classify_set_interface_l2_tables, \
21542 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21543 " [other-table <nn>]") \
21544 _(get_node_index, "node <node-name") \
21545 _(add_node_next, "node <node-name> next <next-node-name>") \
21546 _(l2tpv3_create_tunnel, \
21547 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21548 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21549 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21550 _(l2tpv3_set_tunnel_cookies, \
21551 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21552 "[new_remote_cookie <nn>]\n") \
21553 _(l2tpv3_interface_enable_disable, \
21554 "<intfc> | sw_if_index <nn> enable | disable") \
21555 _(l2tpv3_set_lookup_key, \
21556 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21557 _(sw_if_l2tpv3_tunnel_dump, "") \
21558 _(vxlan_offload_rx, \
21559 "hw { <interface name> | hw_if_index <nn>} " \
21560 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21561 _(vxlan_add_del_tunnel, \
21562 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21563 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21564 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21565 _(geneve_add_del_tunnel, \
21566 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21567 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21568 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21569 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21570 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21571 _(gre_tunnel_add_del, \
21572 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21573 "[teb | erspan <session-id>] [del]") \
21574 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21575 _(l2_fib_clear_table, "") \
21576 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21577 _(l2_interface_vlan_tag_rewrite, \
21578 "<intfc> | sw_if_index <nn> \n" \
21579 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21580 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21581 _(create_vhost_user_if, \
21582 "socket <filename> [server] [renumber <dev_instance>] " \
21583 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21584 "[mac <mac_address>]") \
21585 _(modify_vhost_user_if, \
21586 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21587 "[server] [renumber <dev_instance>] [gso]") \
21588 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21589 _(sw_interface_vhost_user_dump, "") \
21590 _(show_version, "") \
21591 _(show_threads, "") \
21592 _(vxlan_gpe_add_del_tunnel, \
21593 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21594 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21595 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21596 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21597 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21598 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21599 _(interface_name_renumber, \
21600 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21601 _(input_acl_set_interface, \
21602 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21603 " [l2-table <nn>] [del]") \
21604 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21605 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21606 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21607 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21608 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21609 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21610 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21611 _(ip_dump, "ipv4 | ipv6") \
21612 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21613 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21615 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21616 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21617 " integ_alg <alg> integ_key <hex>") \
21618 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21619 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21620 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21621 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21622 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21623 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21624 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21625 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21626 " [instance <n>]") \
21627 _(ipsec_sa_dump, "[sa_id <n>]") \
21628 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21629 _(delete_loopback,"sw_if_index <nn>") \
21630 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21631 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21632 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21633 _(want_interface_events, "enable|disable") \
21634 _(get_first_msg_id, "client <name>") \
21635 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21636 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21637 "fib-id <nn> [ip4][ip6][default]") \
21638 _(get_node_graph, " ") \
21639 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21640 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21641 _(ioam_disable, "") \
21642 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21643 " sw_if_index <sw_if_index> p <priority> " \
21644 "w <weight>] [del]") \
21645 _(one_add_del_locator, "locator-set <locator_name> " \
21646 "iface <intf> | sw_if_index <sw_if_index> " \
21647 "p <priority> w <weight> [del]") \
21648 _(one_add_del_local_eid,"vni <vni> eid " \
21649 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21650 "locator-set <locator_name> [del]" \
21651 "[key-id sha1|sha256 secret-key <secret-key>]")\
21652 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21653 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21654 _(one_enable_disable, "enable|disable") \
21655 _(one_map_register_enable_disable, "enable|disable") \
21656 _(one_map_register_fallback_threshold, "<value>") \
21657 _(one_rloc_probe_enable_disable, "enable|disable") \
21658 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21660 "rloc <locator> p <prio> " \
21661 "w <weight> [rloc <loc> ... ] " \
21662 "action <action> [del-all]") \
21663 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21665 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21666 _(one_use_petr, "ip-address> | disable") \
21667 _(one_map_request_mode, "src-dst|dst-only") \
21668 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21669 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21670 _(one_locator_set_dump, "[local | remote]") \
21671 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21672 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21673 "[local] | [remote]") \
21674 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21675 _(one_ndp_bd_get, "") \
21676 _(one_ndp_entries_get, "bd <bridge-domain>") \
21677 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21678 _(one_l2_arp_bd_get, "") \
21679 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21680 _(one_stats_enable_disable, "enable|disable") \
21681 _(show_one_stats_enable_disable, "") \
21682 _(one_eid_table_vni_dump, "") \
21683 _(one_eid_table_map_dump, "l2|l3") \
21684 _(one_map_resolver_dump, "") \
21685 _(one_map_server_dump, "") \
21686 _(one_adjacencies_get, "vni <vni>") \
21687 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21688 _(show_one_rloc_probe_state, "") \
21689 _(show_one_map_register_state, "") \
21690 _(show_one_status, "") \
21691 _(one_stats_dump, "") \
21692 _(one_stats_flush, "") \
21693 _(one_get_map_request_itr_rlocs, "") \
21694 _(one_map_register_set_ttl, "<ttl>") \
21695 _(one_set_transport_protocol, "udp|api") \
21696 _(one_get_transport_protocol, "") \
21697 _(one_enable_disable_xtr_mode, "enable|disable") \
21698 _(one_show_xtr_mode, "") \
21699 _(one_enable_disable_pitr_mode, "enable|disable") \
21700 _(one_show_pitr_mode, "") \
21701 _(one_enable_disable_petr_mode, "enable|disable") \
21702 _(one_show_petr_mode, "") \
21703 _(show_one_nsh_mapping, "") \
21704 _(show_one_pitr, "") \
21705 _(show_one_use_petr, "") \
21706 _(show_one_map_request_mode, "") \
21707 _(show_one_map_register_ttl, "") \
21708 _(show_one_map_register_fallback_threshold, "") \
21709 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21710 " sw_if_index <sw_if_index> p <priority> " \
21711 "w <weight>] [del]") \
21712 _(lisp_add_del_locator, "locator-set <locator_name> " \
21713 "iface <intf> | sw_if_index <sw_if_index> " \
21714 "p <priority> w <weight> [del]") \
21715 _(lisp_add_del_local_eid,"vni <vni> eid " \
21716 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21717 "locator-set <locator_name> [del]" \
21718 "[key-id sha1|sha256 secret-key <secret-key>]") \
21719 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21720 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21721 _(lisp_enable_disable, "enable|disable") \
21722 _(lisp_map_register_enable_disable, "enable|disable") \
21723 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21724 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21726 "rloc <locator> p <prio> " \
21727 "w <weight> [rloc <loc> ... ] " \
21728 "action <action> [del-all]") \
21729 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21731 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21732 _(lisp_use_petr, "<ip-address> | disable") \
21733 _(lisp_map_request_mode, "src-dst|dst-only") \
21734 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21735 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21736 _(lisp_locator_set_dump, "[local | remote]") \
21737 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21738 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21739 "[local] | [remote]") \
21740 _(lisp_eid_table_vni_dump, "") \
21741 _(lisp_eid_table_map_dump, "l2|l3") \
21742 _(lisp_map_resolver_dump, "") \
21743 _(lisp_map_server_dump, "") \
21744 _(lisp_adjacencies_get, "vni <vni>") \
21745 _(gpe_fwd_entry_vnis_get, "") \
21746 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21747 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21748 "[table <table-id>]") \
21749 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21750 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21751 _(gpe_set_encap_mode, "lisp|vxlan") \
21752 _(gpe_get_encap_mode, "") \
21753 _(lisp_gpe_add_del_iface, "up|down") \
21754 _(lisp_gpe_enable_disable, "enable|disable") \
21755 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21756 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21757 _(show_lisp_rloc_probe_state, "") \
21758 _(show_lisp_map_register_state, "") \
21759 _(show_lisp_status, "") \
21760 _(lisp_get_map_request_itr_rlocs, "") \
21761 _(show_lisp_pitr, "") \
21762 _(show_lisp_use_petr, "") \
21763 _(show_lisp_map_request_mode, "") \
21764 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21765 _(af_packet_delete, "name <host interface name>") \
21766 _(af_packet_dump, "") \
21767 _(policer_add_del, "name <policer name> <params> [del]") \
21768 _(policer_dump, "[name <policer name>]") \
21769 _(policer_classify_set_interface, \
21770 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21771 " [l2-table <nn>] [del]") \
21772 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21773 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21774 "[master|slave]") \
21775 _(netmap_delete, "name <interface name>") \
21776 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21777 _(mpls_table_dump, "") \
21778 _(mpls_route_dump, "table-id <ID>") \
21779 _(classify_table_ids, "") \
21780 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21781 _(classify_table_info, "table_id <nn>") \
21782 _(classify_session_dump, "table_id <nn>") \
21783 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21784 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21785 "[template_interval <nn>] [udp_checksum]") \
21786 _(ipfix_exporter_dump, "") \
21787 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21788 _(ipfix_classify_stream_dump, "") \
21789 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21790 _(ipfix_classify_table_dump, "") \
21791 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21792 _(sw_interface_span_dump, "[l2]") \
21793 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21794 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21795 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21796 _(pg_enable_disable, "[stream <id>] disable") \
21797 _(ip_source_and_port_range_check_add_del, \
21798 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21799 _(ip_source_and_port_range_check_interface_add_del, \
21800 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21801 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21802 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21803 _(l2_interface_pbb_tag_rewrite, \
21804 "<intfc> | sw_if_index <nn> \n" \
21805 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21806 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21807 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21808 _(flow_classify_set_interface, \
21809 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21810 _(flow_classify_dump, "type [ip4|ip6]") \
21811 _(ip_table_dump, "") \
21812 _(ip_route_dump, "table-id [ip4|ip6]") \
21813 _(ip_mtable_dump, "") \
21814 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21815 _(feature_enable_disable, "arc_name <arc_name> " \
21816 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21817 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21819 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21820 "mac <mac-address> [del]") \
21821 _(l2_xconnect_dump, "") \
21822 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21823 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21824 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21825 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21826 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21827 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21828 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21829 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21830 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21831 _(sock_init_shm, "size <nnn>") \
21832 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21833 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21834 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21835 _(session_rules_dump, "") \
21836 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21837 _(output_acl_set_interface, \
21838 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21839 " [l2-table <nn>] [del]") \
21840 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21842 /* List of command functions, CLI names map directly to functions */
21843 #define foreach_cli_function \
21844 _(comment, "usage: comment <ignore-rest-of-line>") \
21845 _(dump_interface_table, "usage: dump_interface_table") \
21846 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21847 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21848 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21849 _(dump_macro_table, "usage: dump_macro_table ") \
21850 _(dump_node_table, "usage: dump_node_table") \
21851 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21852 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21853 _(elog_disable, "usage: elog_disable") \
21854 _(elog_enable, "usage: elog_enable") \
21855 _(elog_save, "usage: elog_save <filename>") \
21856 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21857 _(echo, "usage: echo <message>") \
21858 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21859 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21860 _(help, "usage: help") \
21861 _(q, "usage: quit") \
21862 _(quit, "usage: quit") \
21863 _(search_node_table, "usage: search_node_table <name>...") \
21864 _(set, "usage: set <variable-name> <value>") \
21865 _(script, "usage: script <file-name>") \
21866 _(statseg, "usage: statseg") \
21867 _(unset, "usage: unset <variable-name>")
21870 static void vl_api_##n##_t_handler_uni \
21871 (vl_api_##n##_t * mp) \
21873 vat_main_t * vam = &vat_main; \
21874 if (vam->json_output) { \
21875 vl_api_##n##_t_handler_json(mp); \
21877 vl_api_##n##_t_handler(mp); \
21880 foreach_vpe_api_reply_msg;
21881 #if VPP_API_TEST_BUILTIN == 0
21882 foreach_standalone_reply_msg;
21887 vat_api_hookup (vat_main_t * vam)
21890 vl_msg_api_set_handlers(VL_API_##N, #n, \
21891 vl_api_##n##_t_handler_uni, \
21893 vl_api_##n##_t_endian, \
21894 vl_api_##n##_t_print, \
21895 sizeof(vl_api_##n##_t), 1);
21896 foreach_vpe_api_reply_msg;
21897 #if VPP_API_TEST_BUILTIN == 0
21898 foreach_standalone_reply_msg;
21902 #if (VPP_API_TEST_BUILTIN==0)
21903 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21905 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21907 vam->function_by_name = hash_create_string (0, sizeof (uword));
21909 vam->help_by_name = hash_create_string (0, sizeof (uword));
21912 /* API messages we can send */
21913 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21914 foreach_vpe_api_msg;
21918 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21919 foreach_vpe_api_msg;
21922 /* CLI functions */
21923 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21924 foreach_cli_function;
21928 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21929 foreach_cli_function;
21933 #if VPP_API_TEST_BUILTIN
21934 static clib_error_t *
21935 vat_api_hookup_shim (vlib_main_t * vm)
21937 vat_api_hookup (&vat_main);
21941 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21945 * fd.io coding-style-patch-verification: ON
21948 * eval: (c-set-style "gnu")