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_uint (node, "flags", mp->flags);
1033 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1034 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1035 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1036 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1037 vat_json_object_add_uint (node, "sub_number_of_tags",
1038 mp->sub_number_of_tags);
1039 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1040 ntohs (mp->sub_outer_vlan_id));
1041 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1042 ntohs (mp->sub_inner_vlan_id));
1043 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1044 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1045 vat_json_object_add_uint (node, "vtr_push_dot1q",
1046 ntohl (mp->vtr_push_dot1q));
1047 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1048 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1049 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1051 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1053 format_ethernet_address,
1055 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1057 format_ethernet_address,
1059 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1060 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1064 #if VPP_API_TEST_BUILTIN == 0
1065 static void vl_api_sw_interface_event_t_handler
1066 (vl_api_sw_interface_event_t * mp)
1068 vat_main_t *vam = &vat_main;
1069 if (vam->interface_event_display)
1070 errmsg ("interface flags: sw_if_index %d %s %s",
1071 ntohl (mp->sw_if_index),
1072 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1073 "admin-up" : "admin-down",
1074 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1075 "link-up" : "link-down");
1079 __clib_unused static void
1080 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1082 /* JSON output not supported */
1086 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1088 vat_main_t *vam = &vat_main;
1089 i32 retval = ntohl (mp->retval);
1091 vam->retval = retval;
1092 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1093 vam->result_ready = 1;
1097 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1099 vat_main_t *vam = &vat_main;
1100 vat_json_node_t node;
1101 api_main_t *am = &api_main;
1105 vat_json_init_object (&node);
1106 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1107 vat_json_object_add_uint (&node, "reply_in_shmem",
1108 ntohl (mp->reply_in_shmem));
1109 /* Toss the shared-memory original... */
1110 pthread_mutex_lock (&am->vlib_rp->mutex);
1111 oldheap = svm_push_data_heap (am->vlib_rp);
1113 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1116 svm_pop_heap (oldheap);
1117 pthread_mutex_unlock (&am->vlib_rp->mutex);
1119 vat_json_print (vam->ofp, &node);
1120 vat_json_free (&node);
1122 vam->retval = ntohl (mp->retval);
1123 vam->result_ready = 1;
1127 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1129 vat_main_t *vam = &vat_main;
1130 i32 retval = ntohl (mp->retval);
1131 u32 length = vl_api_string_len (&mp->reply);
1133 vec_reset_length (vam->cmd_reply);
1135 vam->retval = retval;
1138 vec_validate (vam->cmd_reply, length);
1139 clib_memcpy ((char *) (vam->cmd_reply),
1140 vl_api_from_api_string (&mp->reply), length);
1141 vam->cmd_reply[length] = 0;
1143 vam->result_ready = 1;
1147 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 vat_json_node_t node;
1152 vec_reset_length (vam->cmd_reply);
1154 vat_json_init_object (&node);
1155 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1156 vat_json_object_add_string_copy (&node, "reply",
1157 vl_api_from_api_string (&mp->reply));
1159 vat_json_print (vam->ofp, &node);
1160 vat_json_free (&node);
1162 vam->retval = ntohl (mp->retval);
1163 vam->result_ready = 1;
1166 static void vl_api_classify_add_del_table_reply_t_handler
1167 (vl_api_classify_add_del_table_reply_t * mp)
1169 vat_main_t *vam = &vat_main;
1170 i32 retval = ntohl (mp->retval);
1171 if (vam->async_mode)
1173 vam->async_errors += (retval < 0);
1177 vam->retval = retval;
1179 ((mp->new_table_index != 0xFFFFFFFF) ||
1180 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1181 (mp->match_n_vectors != 0xFFFFFFFF)))
1183 * Note: this is just barely thread-safe, depends on
1184 * the main thread spinning waiting for an answer...
1186 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1187 ntohl (mp->new_table_index),
1188 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1189 vam->result_ready = 1;
1193 static void vl_api_classify_add_del_table_reply_t_handler_json
1194 (vl_api_classify_add_del_table_reply_t * mp)
1196 vat_main_t *vam = &vat_main;
1197 vat_json_node_t node;
1199 vat_json_init_object (&node);
1200 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1201 vat_json_object_add_uint (&node, "new_table_index",
1202 ntohl (mp->new_table_index));
1203 vat_json_object_add_uint (&node, "skip_n_vectors",
1204 ntohl (mp->skip_n_vectors));
1205 vat_json_object_add_uint (&node, "match_n_vectors",
1206 ntohl (mp->match_n_vectors));
1208 vat_json_print (vam->ofp, &node);
1209 vat_json_free (&node);
1211 vam->retval = ntohl (mp->retval);
1212 vam->result_ready = 1;
1215 static void vl_api_get_node_index_reply_t_handler
1216 (vl_api_get_node_index_reply_t * mp)
1218 vat_main_t *vam = &vat_main;
1219 i32 retval = ntohl (mp->retval);
1220 if (vam->async_mode)
1222 vam->async_errors += (retval < 0);
1226 vam->retval = retval;
1228 errmsg ("node index %d", ntohl (mp->node_index));
1229 vam->result_ready = 1;
1233 static void vl_api_get_node_index_reply_t_handler_json
1234 (vl_api_get_node_index_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1243 vat_json_print (vam->ofp, &node);
1244 vat_json_free (&node);
1246 vam->retval = ntohl (mp->retval);
1247 vam->result_ready = 1;
1250 static void vl_api_get_next_index_reply_t_handler
1251 (vl_api_get_next_index_reply_t * mp)
1253 vat_main_t *vam = &vat_main;
1254 i32 retval = ntohl (mp->retval);
1255 if (vam->async_mode)
1257 vam->async_errors += (retval < 0);
1261 vam->retval = retval;
1263 errmsg ("next node index %d", ntohl (mp->next_index));
1264 vam->result_ready = 1;
1268 static void vl_api_get_next_index_reply_t_handler_json
1269 (vl_api_get_next_index_reply_t * mp)
1271 vat_main_t *vam = &vat_main;
1272 vat_json_node_t node;
1274 vat_json_init_object (&node);
1275 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1276 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1278 vat_json_print (vam->ofp, &node);
1279 vat_json_free (&node);
1281 vam->retval = ntohl (mp->retval);
1282 vam->result_ready = 1;
1285 static void vl_api_add_node_next_reply_t_handler
1286 (vl_api_add_node_next_reply_t * mp)
1288 vat_main_t *vam = &vat_main;
1289 i32 retval = ntohl (mp->retval);
1290 if (vam->async_mode)
1292 vam->async_errors += (retval < 0);
1296 vam->retval = retval;
1298 errmsg ("next index %d", ntohl (mp->next_index));
1299 vam->result_ready = 1;
1303 static void vl_api_add_node_next_reply_t_handler_json
1304 (vl_api_add_node_next_reply_t * mp)
1306 vat_main_t *vam = &vat_main;
1307 vat_json_node_t node;
1309 vat_json_init_object (&node);
1310 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1311 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1313 vat_json_print (vam->ofp, &node);
1314 vat_json_free (&node);
1316 vam->retval = ntohl (mp->retval);
1317 vam->result_ready = 1;
1320 static void vl_api_show_version_reply_t_handler
1321 (vl_api_show_version_reply_t * mp)
1323 vat_main_t *vam = &vat_main;
1324 i32 retval = ntohl (mp->retval);
1328 errmsg (" program: %s", mp->program);
1329 errmsg (" version: %s", mp->version);
1330 errmsg (" build date: %s", mp->build_date);
1331 errmsg ("build directory: %s", mp->build_directory);
1333 vam->retval = retval;
1334 vam->result_ready = 1;
1337 static void vl_api_show_version_reply_t_handler_json
1338 (vl_api_show_version_reply_t * mp)
1340 vat_main_t *vam = &vat_main;
1341 vat_json_node_t node;
1343 vat_json_init_object (&node);
1344 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1345 vat_json_object_add_string_copy (&node, "program", mp->program);
1346 vat_json_object_add_string_copy (&node, "version", mp->version);
1347 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1348 vat_json_object_add_string_copy (&node, "build_directory",
1349 mp->build_directory);
1351 vat_json_print (vam->ofp, &node);
1352 vat_json_free (&node);
1354 vam->retval = ntohl (mp->retval);
1355 vam->result_ready = 1;
1358 static void vl_api_show_threads_reply_t_handler
1359 (vl_api_show_threads_reply_t * mp)
1361 vat_main_t *vam = &vat_main;
1362 i32 retval = ntohl (mp->retval);
1366 count = ntohl (mp->count);
1368 for (i = 0; i < count; i++)
1370 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1371 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1372 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1373 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1374 ntohl (mp->thread_data[i].cpu_socket));
1376 vam->retval = retval;
1377 vam->result_ready = 1;
1380 static void vl_api_show_threads_reply_t_handler_json
1381 (vl_api_show_threads_reply_t * mp)
1383 vat_main_t *vam = &vat_main;
1384 vat_json_node_t node;
1385 vl_api_thread_data_t *td;
1386 i32 retval = ntohl (mp->retval);
1390 count = ntohl (mp->count);
1392 vat_json_init_object (&node);
1393 vat_json_object_add_int (&node, "retval", retval);
1394 vat_json_object_add_uint (&node, "count", count);
1396 for (i = 0; i < count; i++)
1398 td = &mp->thread_data[i];
1399 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1400 vat_json_object_add_string_copy (&node, "name", td->name);
1401 vat_json_object_add_string_copy (&node, "type", td->type);
1402 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1403 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1404 vat_json_object_add_int (&node, "core", ntohl (td->id));
1405 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1408 vat_json_print (vam->ofp, &node);
1409 vat_json_free (&node);
1411 vam->retval = retval;
1412 vam->result_ready = 1;
1416 api_show_threads (vat_main_t * vam)
1418 vl_api_show_threads_t *mp;
1422 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1423 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1425 M (SHOW_THREADS, mp);
1433 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1435 u32 sw_if_index = ntohl (mp->sw_if_index);
1436 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1437 mp->mac_ip ? "mac/ip binding" : "address resolution",
1438 ntohl (mp->pid), format_ip4_address, mp->ip,
1439 format_vl_api_mac_address, &mp->mac, sw_if_index);
1443 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1445 /* JSON output not supported */
1449 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1451 u32 sw_if_index = ntohl (mp->sw_if_index);
1452 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1453 mp->mac_ip ? "mac/ip binding" : "address resolution",
1454 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1455 format_vl_api_mac_address, mp->mac, sw_if_index);
1459 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1461 /* JSON output not supported */
1465 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1467 u32 n_macs = ntohl (mp->n_macs);
1468 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1469 ntohl (mp->pid), mp->client_index, n_macs);
1471 for (i = 0; i < n_macs; i++)
1473 vl_api_mac_entry_t *mac = &mp->mac[i];
1474 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1475 i + 1, ntohl (mac->sw_if_index),
1476 format_ethernet_address, mac->mac_addr, mac->action);
1483 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1485 /* JSON output not supported */
1488 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1489 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1492 * Special-case: build the bridge domain table, maintain
1493 * the next bd id vbl.
1495 static void vl_api_bridge_domain_details_t_handler
1496 (vl_api_bridge_domain_details_t * mp)
1498 vat_main_t *vam = &vat_main;
1499 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1502 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1503 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1505 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1506 ntohl (mp->bd_id), mp->learn, mp->forward,
1507 mp->flood, ntohl (mp->bvi_sw_if_index),
1508 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1512 vl_api_bridge_domain_sw_if_t *sw_ifs;
1513 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1516 sw_ifs = mp->sw_if_details;
1517 for (i = 0; i < n_sw_ifs; i++)
1523 sw_if_index = ntohl (sw_ifs->sw_if_index);
1526 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1528 if ((u32) p->value[0] == sw_if_index)
1530 sw_if_name = (u8 *)(p->key);
1535 print (vam->ofp, "%7d %3d %s", sw_if_index,
1536 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1537 "sw_if_index not found!");
1544 static void vl_api_bridge_domain_details_t_handler_json
1545 (vl_api_bridge_domain_details_t * mp)
1547 vat_main_t *vam = &vat_main;
1548 vat_json_node_t *node, *array = NULL;
1549 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1551 if (VAT_JSON_ARRAY != vam->json_tree.type)
1553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1554 vat_json_init_array (&vam->json_tree);
1556 node = vat_json_array_add (&vam->json_tree);
1558 vat_json_init_object (node);
1559 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1560 vat_json_object_add_uint (node, "flood", mp->flood);
1561 vat_json_object_add_uint (node, "forward", mp->forward);
1562 vat_json_object_add_uint (node, "learn", mp->learn);
1563 vat_json_object_add_uint (node, "bvi_sw_if_index",
1564 ntohl (mp->bvi_sw_if_index));
1565 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1566 array = vat_json_object_add (node, "sw_if");
1567 vat_json_init_array (array);
1573 vl_api_bridge_domain_sw_if_t *sw_ifs;
1576 sw_ifs = mp->sw_if_details;
1577 for (i = 0; i < n_sw_ifs; i++)
1579 node = vat_json_array_add (array);
1580 vat_json_init_object (node);
1581 vat_json_object_add_uint (node, "sw_if_index",
1582 ntohl (sw_ifs->sw_if_index));
1583 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1589 static void vl_api_control_ping_reply_t_handler
1590 (vl_api_control_ping_reply_t * mp)
1592 vat_main_t *vam = &vat_main;
1593 i32 retval = ntohl (mp->retval);
1594 if (vam->async_mode)
1596 vam->async_errors += (retval < 0);
1600 vam->retval = retval;
1601 vam->result_ready = 1;
1603 if (vam->socket_client_main)
1604 vam->socket_client_main->control_pings_outstanding--;
1607 static void vl_api_control_ping_reply_t_handler_json
1608 (vl_api_control_ping_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 i32 retval = ntohl (mp->retval);
1613 if (VAT_JSON_NONE != vam->json_tree.type)
1615 vat_json_print (vam->ofp, &vam->json_tree);
1616 vat_json_free (&vam->json_tree);
1617 vam->json_tree.type = VAT_JSON_NONE;
1622 vat_json_init_array (&vam->json_tree);
1623 vat_json_print (vam->ofp, &vam->json_tree);
1624 vam->json_tree.type = VAT_JSON_NONE;
1627 vam->retval = retval;
1628 vam->result_ready = 1;
1632 vl_api_bridge_domain_set_mac_age_reply_t_handler
1633 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1635 vat_main_t *vam = &vat_main;
1636 i32 retval = ntohl (mp->retval);
1637 if (vam->async_mode)
1639 vam->async_errors += (retval < 0);
1643 vam->retval = retval;
1644 vam->result_ready = 1;
1648 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1649 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1651 vat_main_t *vam = &vat_main;
1652 vat_json_node_t node;
1654 vat_json_init_object (&node);
1655 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_l2_flags_reply_t_handler_json
1681 (vl_api_l2_flags_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1689 ntohl (mp->resulting_feature_bitmap));
1691 vat_json_print (vam->ofp, &node);
1692 vat_json_free (&node);
1694 vam->retval = ntohl (mp->retval);
1695 vam->result_ready = 1;
1698 static void vl_api_bridge_flags_reply_t_handler
1699 (vl_api_bridge_flags_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 i32 retval = ntohl (mp->retval);
1703 if (vam->async_mode)
1705 vam->async_errors += (retval < 0);
1709 vam->retval = retval;
1710 vam->result_ready = 1;
1714 static void vl_api_bridge_flags_reply_t_handler_json
1715 (vl_api_bridge_flags_reply_t * mp)
1717 vat_main_t *vam = &vat_main;
1718 vat_json_node_t node;
1720 vat_json_init_object (&node);
1721 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1722 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1723 ntohl (mp->resulting_feature_bitmap));
1725 vat_json_print (vam->ofp, &node);
1726 vat_json_free (&node);
1728 vam->retval = ntohl (mp->retval);
1729 vam->result_ready = 1;
1733 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 i32 retval = ntohl (mp->retval);
1737 if (vam->async_mode)
1739 vam->async_errors += (retval < 0);
1743 vam->retval = retval;
1744 vam->sw_if_index = ntohl (mp->sw_if_index);
1745 vam->result_ready = 1;
1750 static void vl_api_tap_create_v2_reply_t_handler_json
1751 (vl_api_tap_create_v2_reply_t * mp)
1753 vat_main_t *vam = &vat_main;
1754 vat_json_node_t node;
1756 vat_json_init_object (&node);
1757 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1758 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1760 vat_json_print (vam->ofp, &node);
1761 vat_json_free (&node);
1763 vam->retval = ntohl (mp->retval);
1764 vam->result_ready = 1;
1769 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1771 vat_main_t *vam = &vat_main;
1772 i32 retval = ntohl (mp->retval);
1773 if (vam->async_mode)
1775 vam->async_errors += (retval < 0);
1779 vam->retval = retval;
1780 vam->result_ready = 1;
1784 static void vl_api_tap_delete_v2_reply_t_handler_json
1785 (vl_api_tap_delete_v2_reply_t * mp)
1787 vat_main_t *vam = &vat_main;
1788 vat_json_node_t node;
1790 vat_json_init_object (&node);
1791 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1793 vat_json_print (vam->ofp, &node);
1794 vat_json_free (&node);
1796 vam->retval = ntohl (mp->retval);
1797 vam->result_ready = 1;
1801 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1804 vat_main_t *vam = &vat_main;
1805 i32 retval = ntohl (mp->retval);
1806 if (vam->async_mode)
1808 vam->async_errors += (retval < 0);
1812 vam->retval = retval;
1813 vam->sw_if_index = ntohl (mp->sw_if_index);
1814 vam->result_ready = 1;
1818 static void vl_api_virtio_pci_create_reply_t_handler_json
1819 (vl_api_virtio_pci_create_reply_t * mp)
1821 vat_main_t *vam = &vat_main;
1822 vat_json_node_t node;
1824 vat_json_init_object (&node);
1825 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1826 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1828 vat_json_print (vam->ofp, &node);
1829 vat_json_free (&node);
1831 vam->retval = ntohl (mp->retval);
1832 vam->result_ready = 1;
1837 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1840 vat_main_t *vam = &vat_main;
1841 i32 retval = ntohl (mp->retval);
1842 if (vam->async_mode)
1844 vam->async_errors += (retval < 0);
1848 vam->retval = retval;
1849 vam->result_ready = 1;
1853 static void vl_api_virtio_pci_delete_reply_t_handler_json
1854 (vl_api_virtio_pci_delete_reply_t * mp)
1856 vat_main_t *vam = &vat_main;
1857 vat_json_node_t node;
1859 vat_json_init_object (&node);
1860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1862 vat_json_print (vam->ofp, &node);
1863 vat_json_free (&node);
1865 vam->retval = ntohl (mp->retval);
1866 vam->result_ready = 1;
1870 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1872 vat_main_t *vam = &vat_main;
1873 i32 retval = ntohl (mp->retval);
1875 if (vam->async_mode)
1877 vam->async_errors += (retval < 0);
1881 vam->retval = retval;
1882 vam->sw_if_index = ntohl (mp->sw_if_index);
1883 vam->result_ready = 1;
1887 static void vl_api_bond_create_reply_t_handler_json
1888 (vl_api_bond_create_reply_t * mp)
1890 vat_main_t *vam = &vat_main;
1891 vat_json_node_t node;
1893 vat_json_init_object (&node);
1894 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1895 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1897 vat_json_print (vam->ofp, &node);
1898 vat_json_free (&node);
1900 vam->retval = ntohl (mp->retval);
1901 vam->result_ready = 1;
1905 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1907 vat_main_t *vam = &vat_main;
1908 i32 retval = ntohl (mp->retval);
1910 if (vam->async_mode)
1912 vam->async_errors += (retval < 0);
1916 vam->retval = retval;
1917 vam->result_ready = 1;
1921 static void vl_api_bond_delete_reply_t_handler_json
1922 (vl_api_bond_delete_reply_t * mp)
1924 vat_main_t *vam = &vat_main;
1925 vat_json_node_t node;
1927 vat_json_init_object (&node);
1928 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1930 vat_json_print (vam->ofp, &node);
1931 vat_json_free (&node);
1933 vam->retval = ntohl (mp->retval);
1934 vam->result_ready = 1;
1938 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1940 vat_main_t *vam = &vat_main;
1941 i32 retval = ntohl (mp->retval);
1943 if (vam->async_mode)
1945 vam->async_errors += (retval < 0);
1949 vam->retval = retval;
1950 vam->result_ready = 1;
1954 static void vl_api_bond_enslave_reply_t_handler_json
1955 (vl_api_bond_enslave_reply_t * mp)
1957 vat_main_t *vam = &vat_main;
1958 vat_json_node_t node;
1960 vat_json_init_object (&node);
1961 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1963 vat_json_print (vam->ofp, &node);
1964 vat_json_free (&node);
1966 vam->retval = ntohl (mp->retval);
1967 vam->result_ready = 1;
1971 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1974 vat_main_t *vam = &vat_main;
1975 i32 retval = ntohl (mp->retval);
1977 if (vam->async_mode)
1979 vam->async_errors += (retval < 0);
1983 vam->retval = retval;
1984 vam->result_ready = 1;
1988 static void vl_api_bond_detach_slave_reply_t_handler_json
1989 (vl_api_bond_detach_slave_reply_t * mp)
1991 vat_main_t *vam = &vat_main;
1992 vat_json_node_t node;
1994 vat_json_init_object (&node);
1995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1997 vat_json_print (vam->ofp, &node);
1998 vat_json_free (&node);
2000 vam->retval = ntohl (mp->retval);
2001 vam->result_ready = 1;
2005 api_sw_interface_set_bond_weight (vat_main_t * vam)
2007 unformat_input_t *i = vam->input;
2008 vl_api_sw_interface_set_bond_weight_t *mp;
2009 u32 sw_if_index = ~0;
2011 u8 weight_enter = 0;
2014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2020 else if (unformat (i, "weight %u", &weight))
2026 if (sw_if_index == ~0)
2028 errmsg ("missing interface name or sw_if_index");
2031 if (weight_enter == 0)
2033 errmsg ("missing valid weight");
2037 /* Construct the API message */
2038 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2039 mp->sw_if_index = ntohl (sw_if_index);
2040 mp->weight = ntohl (weight);
2047 static void vl_api_sw_interface_bond_details_t_handler
2048 (vl_api_sw_interface_bond_details_t * mp)
2050 vat_main_t *vam = &vat_main;
2053 "%-16s %-12d %-12U %-13U %-14u %-14u",
2054 mp->interface_name, ntohl (mp->sw_if_index),
2055 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2056 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2059 static void vl_api_sw_interface_bond_details_t_handler_json
2060 (vl_api_sw_interface_bond_details_t * mp)
2062 vat_main_t *vam = &vat_main;
2063 vat_json_node_t *node = NULL;
2065 if (VAT_JSON_ARRAY != vam->json_tree.type)
2067 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2068 vat_json_init_array (&vam->json_tree);
2070 node = vat_json_array_add (&vam->json_tree);
2072 vat_json_init_object (node);
2073 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2074 vat_json_object_add_string_copy (node, "interface_name",
2075 mp->interface_name);
2076 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2077 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2078 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2079 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2083 api_sw_interface_bond_dump (vat_main_t * vam)
2085 vl_api_sw_interface_bond_dump_t *mp;
2086 vl_api_control_ping_t *mp_ping;
2090 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2091 "interface name", "sw_if_index", "mode", "load balance",
2092 "active slaves", "slaves");
2094 /* Get list of bond interfaces */
2095 M (SW_INTERFACE_BOND_DUMP, mp);
2098 /* Use a control ping for synchronization */
2099 MPING (CONTROL_PING, mp_ping);
2106 static void vl_api_sw_interface_slave_details_t_handler
2107 (vl_api_sw_interface_slave_details_t * mp)
2109 vat_main_t *vam = &vat_main;
2112 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2113 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2114 ntohl (mp->weight), mp->is_local_numa);
2117 static void vl_api_sw_interface_slave_details_t_handler_json
2118 (vl_api_sw_interface_slave_details_t * mp)
2120 vat_main_t *vam = &vat_main;
2121 vat_json_node_t *node = NULL;
2123 if (VAT_JSON_ARRAY != vam->json_tree.type)
2125 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2126 vat_json_init_array (&vam->json_tree);
2128 node = vat_json_array_add (&vam->json_tree);
2130 vat_json_init_object (node);
2131 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2132 vat_json_object_add_string_copy (node, "interface_name",
2133 mp->interface_name);
2134 vat_json_object_add_uint (node, "passive", mp->is_passive);
2135 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2136 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2137 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2141 api_sw_interface_slave_dump (vat_main_t * vam)
2143 unformat_input_t *i = vam->input;
2144 vl_api_sw_interface_slave_dump_t *mp;
2145 vl_api_control_ping_t *mp_ping;
2146 u32 sw_if_index = ~0;
2147 u8 sw_if_index_set = 0;
2150 /* Parse args required to build the message */
2151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2153 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2154 sw_if_index_set = 1;
2155 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2156 sw_if_index_set = 1;
2161 if (sw_if_index_set == 0)
2163 errmsg ("missing vpp interface name. ");
2168 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2169 "slave interface name", "sw_if_index", "passive", "long_timeout",
2170 "weight", "local numa");
2172 /* Get list of bond interfaces */
2173 M (SW_INTERFACE_SLAVE_DUMP, mp);
2174 mp->sw_if_index = ntohl (sw_if_index);
2177 /* Use a control ping for synchronization */
2178 MPING (CONTROL_PING, mp_ping);
2185 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2186 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2188 vat_main_t *vam = &vat_main;
2189 i32 retval = ntohl (mp->retval);
2190 if (vam->async_mode)
2192 vam->async_errors += (retval < 0);
2196 vam->retval = retval;
2197 vam->sw_if_index = ntohl (mp->sw_if_index);
2198 vam->result_ready = 1;
2200 vam->regenerate_interface_table = 1;
2203 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2204 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2206 vat_main_t *vam = &vat_main;
2207 vat_json_node_t node;
2209 vat_json_init_object (&node);
2210 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2211 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2212 ntohl (mp->sw_if_index));
2214 vat_json_print (vam->ofp, &node);
2215 vat_json_free (&node);
2217 vam->retval = ntohl (mp->retval);
2218 vam->result_ready = 1;
2221 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2222 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2224 vat_main_t *vam = &vat_main;
2225 i32 retval = ntohl (mp->retval);
2226 if (vam->async_mode)
2228 vam->async_errors += (retval < 0);
2232 vam->retval = retval;
2233 vam->sw_if_index = ntohl (mp->sw_if_index);
2234 vam->result_ready = 1;
2238 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2239 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2241 vat_main_t *vam = &vat_main;
2242 vat_json_node_t node;
2244 vat_json_init_object (&node);
2245 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2246 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2248 vat_json_print (vam->ofp, &node);
2249 vat_json_free (&node);
2251 vam->retval = ntohl (mp->retval);
2252 vam->result_ready = 1;
2255 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2256 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2258 vat_main_t *vam = &vat_main;
2259 i32 retval = ntohl (mp->retval);
2260 if (vam->async_mode)
2262 vam->async_errors += (retval < 0);
2266 vam->retval = retval;
2267 vam->result_ready = 1;
2271 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2272 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 vat_json_node_t node;
2277 vat_json_init_object (&node);
2278 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2279 vat_json_object_add_uint (&node, "fwd_entry_index",
2280 clib_net_to_host_u32 (mp->fwd_entry_index));
2282 vat_json_print (vam->ofp, &node);
2283 vat_json_free (&node);
2285 vam->retval = ntohl (mp->retval);
2286 vam->result_ready = 1;
2290 format_lisp_transport_protocol (u8 * s, va_list * args)
2292 u32 proto = va_arg (*args, u32);
2297 return format (s, "udp");
2299 return format (s, "api");
2306 static void vl_api_one_get_transport_protocol_reply_t_handler
2307 (vl_api_one_get_transport_protocol_reply_t * mp)
2309 vat_main_t *vam = &vat_main;
2310 i32 retval = ntohl (mp->retval);
2311 if (vam->async_mode)
2313 vam->async_errors += (retval < 0);
2317 u32 proto = mp->protocol;
2318 print (vam->ofp, "Transport protocol: %U",
2319 format_lisp_transport_protocol, proto);
2320 vam->retval = retval;
2321 vam->result_ready = 1;
2325 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2326 (vl_api_one_get_transport_protocol_reply_t * mp)
2328 vat_main_t *vam = &vat_main;
2329 vat_json_node_t node;
2332 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2335 vat_json_init_object (&node);
2336 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2337 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2340 vat_json_print (vam->ofp, &node);
2341 vat_json_free (&node);
2343 vam->retval = ntohl (mp->retval);
2344 vam->result_ready = 1;
2347 static void vl_api_one_add_del_locator_set_reply_t_handler
2348 (vl_api_one_add_del_locator_set_reply_t * mp)
2350 vat_main_t *vam = &vat_main;
2351 i32 retval = ntohl (mp->retval);
2352 if (vam->async_mode)
2354 vam->async_errors += (retval < 0);
2358 vam->retval = retval;
2359 vam->result_ready = 1;
2363 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2364 (vl_api_one_add_del_locator_set_reply_t * mp)
2366 vat_main_t *vam = &vat_main;
2367 vat_json_node_t node;
2369 vat_json_init_object (&node);
2370 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2371 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2373 vat_json_print (vam->ofp, &node);
2374 vat_json_free (&node);
2376 vam->retval = ntohl (mp->retval);
2377 vam->result_ready = 1;
2380 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2381 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2383 vat_main_t *vam = &vat_main;
2384 i32 retval = ntohl (mp->retval);
2385 if (vam->async_mode)
2387 vam->async_errors += (retval < 0);
2391 vam->retval = retval;
2392 vam->sw_if_index = ntohl (mp->sw_if_index);
2393 vam->result_ready = 1;
2395 vam->regenerate_interface_table = 1;
2398 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2399 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2401 vat_main_t *vam = &vat_main;
2402 vat_json_node_t node;
2404 vat_json_init_object (&node);
2405 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2406 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2408 vat_json_print (vam->ofp, &node);
2409 vat_json_free (&node);
2411 vam->retval = ntohl (mp->retval);
2412 vam->result_ready = 1;
2415 static void vl_api_vxlan_offload_rx_reply_t_handler
2416 (vl_api_vxlan_offload_rx_reply_t * mp)
2418 vat_main_t *vam = &vat_main;
2419 i32 retval = ntohl (mp->retval);
2420 if (vam->async_mode)
2422 vam->async_errors += (retval < 0);
2426 vam->retval = retval;
2427 vam->result_ready = 1;
2431 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2432 (vl_api_vxlan_offload_rx_reply_t * mp)
2434 vat_main_t *vam = &vat_main;
2435 vat_json_node_t node;
2437 vat_json_init_object (&node);
2438 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2440 vat_json_print (vam->ofp, &node);
2441 vat_json_free (&node);
2443 vam->retval = ntohl (mp->retval);
2444 vam->result_ready = 1;
2447 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2448 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2450 vat_main_t *vam = &vat_main;
2451 i32 retval = ntohl (mp->retval);
2452 if (vam->async_mode)
2454 vam->async_errors += (retval < 0);
2458 vam->retval = retval;
2459 vam->sw_if_index = ntohl (mp->sw_if_index);
2460 vam->result_ready = 1;
2464 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2465 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2467 vat_main_t *vam = &vat_main;
2468 vat_json_node_t node;
2470 vat_json_init_object (&node);
2471 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2472 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2474 vat_json_print (vam->ofp, &node);
2475 vat_json_free (&node);
2477 vam->retval = ntohl (mp->retval);
2478 vam->result_ready = 1;
2481 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2482 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2484 vat_main_t *vam = &vat_main;
2485 i32 retval = ntohl (mp->retval);
2486 if (vam->async_mode)
2488 vam->async_errors += (retval < 0);
2492 vam->retval = retval;
2493 vam->sw_if_index = ntohl (mp->sw_if_index);
2494 vam->result_ready = 1;
2496 vam->regenerate_interface_table = 1;
2499 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2500 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2502 vat_main_t *vam = &vat_main;
2503 vat_json_node_t node;
2505 vat_json_init_object (&node);
2506 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2507 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2509 vat_json_print (vam->ofp, &node);
2510 vat_json_free (&node);
2512 vam->retval = ntohl (mp->retval);
2513 vam->result_ready = 1;
2516 static void vl_api_gre_tunnel_add_del_reply_t_handler
2517 (vl_api_gre_tunnel_add_del_reply_t * mp)
2519 vat_main_t *vam = &vat_main;
2520 i32 retval = ntohl (mp->retval);
2521 if (vam->async_mode)
2523 vam->async_errors += (retval < 0);
2527 vam->retval = retval;
2528 vam->sw_if_index = ntohl (mp->sw_if_index);
2529 vam->result_ready = 1;
2533 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2534 (vl_api_gre_tunnel_add_del_reply_t * mp)
2536 vat_main_t *vam = &vat_main;
2537 vat_json_node_t node;
2539 vat_json_init_object (&node);
2540 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2541 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2543 vat_json_print (vam->ofp, &node);
2544 vat_json_free (&node);
2546 vam->retval = ntohl (mp->retval);
2547 vam->result_ready = 1;
2550 static void vl_api_create_vhost_user_if_reply_t_handler
2551 (vl_api_create_vhost_user_if_reply_t * mp)
2553 vat_main_t *vam = &vat_main;
2554 i32 retval = ntohl (mp->retval);
2555 if (vam->async_mode)
2557 vam->async_errors += (retval < 0);
2561 vam->retval = retval;
2562 vam->sw_if_index = ntohl (mp->sw_if_index);
2563 vam->result_ready = 1;
2565 vam->regenerate_interface_table = 1;
2568 static void vl_api_create_vhost_user_if_reply_t_handler_json
2569 (vl_api_create_vhost_user_if_reply_t * mp)
2571 vat_main_t *vam = &vat_main;
2572 vat_json_node_t node;
2574 vat_json_init_object (&node);
2575 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2576 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2578 vat_json_print (vam->ofp, &node);
2579 vat_json_free (&node);
2581 vam->retval = ntohl (mp->retval);
2582 vam->result_ready = 1;
2585 static void vl_api_ip_address_details_t_handler
2586 (vl_api_ip_address_details_t * mp)
2588 vat_main_t *vam = &vat_main;
2589 static ip_address_details_t empty_ip_address_details = { {0} };
2590 ip_address_details_t *address = NULL;
2591 ip_details_t *current_ip_details = NULL;
2592 ip_details_t *details = NULL;
2594 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2596 if (!details || vam->current_sw_if_index >= vec_len (details)
2597 || !details[vam->current_sw_if_index].present)
2599 errmsg ("ip address details arrived but not stored");
2600 errmsg ("ip_dump should be called first");
2604 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2606 #define addresses (current_ip_details->addr)
2608 vec_validate_init_empty (addresses, vec_len (addresses),
2609 empty_ip_address_details);
2611 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2613 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2614 address->prefix_length = mp->prefix.len;
2618 static void vl_api_ip_address_details_t_handler_json
2619 (vl_api_ip_address_details_t * mp)
2621 vat_main_t *vam = &vat_main;
2622 vat_json_node_t *node = NULL;
2624 if (VAT_JSON_ARRAY != vam->json_tree.type)
2626 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2627 vat_json_init_array (&vam->json_tree);
2629 node = vat_json_array_add (&vam->json_tree);
2631 vat_json_init_object (node);
2632 vat_json_object_add_prefix (node, &mp->prefix);
2636 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2638 vat_main_t *vam = &vat_main;
2639 static ip_details_t empty_ip_details = { 0 };
2640 ip_details_t *ip = NULL;
2641 u32 sw_if_index = ~0;
2643 sw_if_index = ntohl (mp->sw_if_index);
2645 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2646 sw_if_index, empty_ip_details);
2648 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2655 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2657 vat_main_t *vam = &vat_main;
2659 if (VAT_JSON_ARRAY != vam->json_tree.type)
2661 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2662 vat_json_init_array (&vam->json_tree);
2664 vat_json_array_add_uint (&vam->json_tree,
2665 clib_net_to_host_u32 (mp->sw_if_index));
2668 static void vl_api_get_first_msg_id_reply_t_handler
2669 (vl_api_get_first_msg_id_reply_t * mp)
2671 vat_main_t *vam = &vat_main;
2672 i32 retval = ntohl (mp->retval);
2674 if (vam->async_mode)
2676 vam->async_errors += (retval < 0);
2680 vam->retval = retval;
2681 vam->result_ready = 1;
2685 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2689 static void vl_api_get_first_msg_id_reply_t_handler_json
2690 (vl_api_get_first_msg_id_reply_t * mp)
2692 vat_main_t *vam = &vat_main;
2693 vat_json_node_t node;
2695 vat_json_init_object (&node);
2696 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2697 vat_json_object_add_uint (&node, "first_msg_id",
2698 (uint) ntohs (mp->first_msg_id));
2700 vat_json_print (vam->ofp, &node);
2701 vat_json_free (&node);
2703 vam->retval = ntohl (mp->retval);
2704 vam->result_ready = 1;
2707 static void vl_api_get_node_graph_reply_t_handler
2708 (vl_api_get_node_graph_reply_t * mp)
2710 vat_main_t *vam = &vat_main;
2711 api_main_t *am = &api_main;
2712 i32 retval = ntohl (mp->retval);
2713 u8 *pvt_copy, *reply;
2718 if (vam->async_mode)
2720 vam->async_errors += (retval < 0);
2724 vam->retval = retval;
2725 vam->result_ready = 1;
2728 /* "Should never happen..." */
2732 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2733 pvt_copy = vec_dup (reply);
2735 /* Toss the shared-memory original... */
2736 pthread_mutex_lock (&am->vlib_rp->mutex);
2737 oldheap = svm_push_data_heap (am->vlib_rp);
2741 svm_pop_heap (oldheap);
2742 pthread_mutex_unlock (&am->vlib_rp->mutex);
2744 if (vam->graph_nodes)
2746 hash_free (vam->graph_node_index_by_name);
2748 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2750 node = vam->graph_nodes[0][i];
2751 vec_free (node->name);
2752 vec_free (node->next_nodes);
2755 vec_free (vam->graph_nodes[0]);
2756 vec_free (vam->graph_nodes);
2759 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2760 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2761 vec_free (pvt_copy);
2763 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2765 node = vam->graph_nodes[0][i];
2766 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2770 static void vl_api_get_node_graph_reply_t_handler_json
2771 (vl_api_get_node_graph_reply_t * mp)
2773 vat_main_t *vam = &vat_main;
2774 api_main_t *am = &api_main;
2776 vat_json_node_t node;
2779 /* $$$$ make this real? */
2780 vat_json_init_object (&node);
2781 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2782 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2784 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2786 /* Toss the shared-memory original... */
2787 pthread_mutex_lock (&am->vlib_rp->mutex);
2788 oldheap = svm_push_data_heap (am->vlib_rp);
2792 svm_pop_heap (oldheap);
2793 pthread_mutex_unlock (&am->vlib_rp->mutex);
2795 vat_json_print (vam->ofp, &node);
2796 vat_json_free (&node);
2798 vam->retval = ntohl (mp->retval);
2799 vam->result_ready = 1;
2803 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2805 vat_main_t *vam = &vat_main;
2810 s = format (s, "%=16d%=16d%=16d",
2811 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2815 s = format (s, "%=16U%=16d%=16d",
2816 mp->is_ipv6 ? format_ip6_address :
2818 mp->ip_address, mp->priority, mp->weight);
2821 print (vam->ofp, "%v", s);
2826 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2828 vat_main_t *vam = &vat_main;
2829 vat_json_node_t *node = NULL;
2830 struct in6_addr ip6;
2833 if (VAT_JSON_ARRAY != vam->json_tree.type)
2835 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2836 vat_json_init_array (&vam->json_tree);
2838 node = vat_json_array_add (&vam->json_tree);
2839 vat_json_init_object (node);
2841 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2842 vat_json_object_add_uint (node, "priority", mp->priority);
2843 vat_json_object_add_uint (node, "weight", mp->weight);
2846 vat_json_object_add_uint (node, "sw_if_index",
2847 clib_net_to_host_u32 (mp->sw_if_index));
2852 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2853 vat_json_object_add_ip6 (node, "address", ip6);
2857 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2858 vat_json_object_add_ip4 (node, "address", ip4);
2864 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2867 vat_main_t *vam = &vat_main;
2870 ls_name = format (0, "%s", mp->ls_name);
2872 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2878 vl_api_one_locator_set_details_t_handler_json
2879 (vl_api_one_locator_set_details_t * mp)
2881 vat_main_t *vam = &vat_main;
2882 vat_json_node_t *node = 0;
2885 ls_name = format (0, "%s", mp->ls_name);
2886 vec_add1 (ls_name, 0);
2888 if (VAT_JSON_ARRAY != vam->json_tree.type)
2890 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2891 vat_json_init_array (&vam->json_tree);
2893 node = vat_json_array_add (&vam->json_tree);
2895 vat_json_init_object (node);
2896 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2897 vat_json_object_add_uint (node, "ls_index",
2898 clib_net_to_host_u32 (mp->ls_index));
2906 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2909 unformat_nsh_address (unformat_input_t * input, va_list * args)
2911 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2912 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2916 format_nsh_address_vat (u8 * s, va_list * args)
2918 nsh_t *a = va_arg (*args, nsh_t *);
2919 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2923 format_lisp_flat_eid (u8 * s, va_list * args)
2925 u32 type = va_arg (*args, u32);
2926 u8 *eid = va_arg (*args, u8 *);
2927 u32 eid_len = va_arg (*args, u32);
2932 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2934 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2936 return format (s, "%U", format_ethernet_address, eid);
2938 return format (s, "%U", format_nsh_address_vat, eid);
2944 format_lisp_eid_vat (u8 * s, va_list * args)
2946 u32 type = va_arg (*args, u32);
2947 u8 *eid = va_arg (*args, u8 *);
2948 u32 eid_len = va_arg (*args, u32);
2949 u8 *seid = va_arg (*args, u8 *);
2950 u32 seid_len = va_arg (*args, u32);
2951 u32 is_src_dst = va_arg (*args, u32);
2954 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2956 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2962 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2964 vat_main_t *vam = &vat_main;
2965 u8 *s = 0, *eid = 0;
2967 if (~0 == mp->locator_set_index)
2968 s = format (0, "action: %d", mp->action);
2970 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2972 eid = format (0, "%U", format_lisp_eid_vat,
2976 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2979 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2980 clib_net_to_host_u32 (mp->vni),
2982 mp->is_local ? "local" : "remote",
2983 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2984 clib_net_to_host_u16 (mp->key_id), mp->key);
2991 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2994 vat_main_t *vam = &vat_main;
2995 vat_json_node_t *node = 0;
2998 if (VAT_JSON_ARRAY != vam->json_tree.type)
3000 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3001 vat_json_init_array (&vam->json_tree);
3003 node = vat_json_array_add (&vam->json_tree);
3005 vat_json_init_object (node);
3006 if (~0 == mp->locator_set_index)
3007 vat_json_object_add_uint (node, "action", mp->action);
3009 vat_json_object_add_uint (node, "locator_set_index",
3010 clib_net_to_host_u32 (mp->locator_set_index));
3012 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3013 if (mp->eid_type == 3)
3015 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3016 vat_json_init_object (nsh_json);
3017 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3018 vat_json_object_add_uint (nsh_json, "spi",
3019 clib_net_to_host_u32 (nsh->spi));
3020 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3024 eid = format (0, "%U", format_lisp_eid_vat,
3028 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3030 vat_json_object_add_string_copy (node, "eid", eid);
3033 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3034 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3035 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3039 vat_json_object_add_uint (node, "key_id",
3040 clib_net_to_host_u16 (mp->key_id));
3041 vat_json_object_add_string_copy (node, "key", mp->key);
3046 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3048 vat_main_t *vam = &vat_main;
3049 u8 *seid = 0, *deid = 0;
3050 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3052 deid = format (0, "%U", format_lisp_eid_vat,
3053 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3055 seid = format (0, "%U", format_lisp_eid_vat,
3056 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3062 format_ip_address_fcn = format_ip4_address;
3064 format_ip_address_fcn = format_ip6_address;
3067 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3068 clib_net_to_host_u32 (mp->vni),
3070 format_ip_address_fcn, mp->lloc,
3071 format_ip_address_fcn, mp->rloc,
3072 clib_net_to_host_u32 (mp->pkt_count),
3073 clib_net_to_host_u32 (mp->bytes));
3080 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3082 struct in6_addr ip6;
3084 vat_main_t *vam = &vat_main;
3085 vat_json_node_t *node = 0;
3086 u8 *deid = 0, *seid = 0;
3088 if (VAT_JSON_ARRAY != vam->json_tree.type)
3090 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3091 vat_json_init_array (&vam->json_tree);
3093 node = vat_json_array_add (&vam->json_tree);
3095 vat_json_init_object (node);
3096 deid = format (0, "%U", format_lisp_eid_vat,
3097 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3099 seid = format (0, "%U", format_lisp_eid_vat,
3100 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3105 vat_json_object_add_string_copy (node, "seid", seid);
3106 vat_json_object_add_string_copy (node, "deid", deid);
3107 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3111 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3112 vat_json_object_add_ip4 (node, "lloc", ip4);
3113 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3114 vat_json_object_add_ip4 (node, "rloc", ip4);
3118 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3119 vat_json_object_add_ip6 (node, "lloc", ip6);
3120 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3121 vat_json_object_add_ip6 (node, "rloc", ip6);
3123 vat_json_object_add_uint (node, "pkt_count",
3124 clib_net_to_host_u32 (mp->pkt_count));
3125 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3132 vl_api_one_eid_table_map_details_t_handler
3133 (vl_api_one_eid_table_map_details_t * mp)
3135 vat_main_t *vam = &vat_main;
3137 u8 *line = format (0, "%=10d%=10d",
3138 clib_net_to_host_u32 (mp->vni),
3139 clib_net_to_host_u32 (mp->dp_table));
3140 print (vam->ofp, "%v", line);
3145 vl_api_one_eid_table_map_details_t_handler_json
3146 (vl_api_one_eid_table_map_details_t * mp)
3148 vat_main_t *vam = &vat_main;
3149 vat_json_node_t *node = NULL;
3151 if (VAT_JSON_ARRAY != vam->json_tree.type)
3153 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3154 vat_json_init_array (&vam->json_tree);
3156 node = vat_json_array_add (&vam->json_tree);
3157 vat_json_init_object (node);
3158 vat_json_object_add_uint (node, "dp_table",
3159 clib_net_to_host_u32 (mp->dp_table));
3160 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3164 vl_api_one_eid_table_vni_details_t_handler
3165 (vl_api_one_eid_table_vni_details_t * mp)
3167 vat_main_t *vam = &vat_main;
3169 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3170 print (vam->ofp, "%v", line);
3175 vl_api_one_eid_table_vni_details_t_handler_json
3176 (vl_api_one_eid_table_vni_details_t * mp)
3178 vat_main_t *vam = &vat_main;
3179 vat_json_node_t *node = NULL;
3181 if (VAT_JSON_ARRAY != vam->json_tree.type)
3183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3184 vat_json_init_array (&vam->json_tree);
3186 node = vat_json_array_add (&vam->json_tree);
3187 vat_json_init_object (node);
3188 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3192 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3193 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3195 vat_main_t *vam = &vat_main;
3196 int retval = clib_net_to_host_u32 (mp->retval);
3198 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3199 print (vam->ofp, "fallback threshold value: %d", mp->value);
3201 vam->retval = retval;
3202 vam->result_ready = 1;
3206 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3207 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3209 vat_main_t *vam = &vat_main;
3210 vat_json_node_t _node, *node = &_node;
3211 int retval = clib_net_to_host_u32 (mp->retval);
3213 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3214 vat_json_init_object (node);
3215 vat_json_object_add_uint (node, "value", mp->value);
3217 vat_json_print (vam->ofp, node);
3218 vat_json_free (node);
3220 vam->retval = retval;
3221 vam->result_ready = 1;
3225 vl_api_show_one_map_register_state_reply_t_handler
3226 (vl_api_show_one_map_register_state_reply_t * mp)
3228 vat_main_t *vam = &vat_main;
3229 int retval = clib_net_to_host_u32 (mp->retval);
3231 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3233 vam->retval = retval;
3234 vam->result_ready = 1;
3238 vl_api_show_one_map_register_state_reply_t_handler_json
3239 (vl_api_show_one_map_register_state_reply_t * mp)
3241 vat_main_t *vam = &vat_main;
3242 vat_json_node_t _node, *node = &_node;
3243 int retval = clib_net_to_host_u32 (mp->retval);
3245 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3247 vat_json_init_object (node);
3248 vat_json_object_add_string_copy (node, "state", s);
3250 vat_json_print (vam->ofp, node);
3251 vat_json_free (node);
3253 vam->retval = retval;
3254 vam->result_ready = 1;
3259 vl_api_show_one_rloc_probe_state_reply_t_handler
3260 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 int retval = clib_net_to_host_u32 (mp->retval);
3268 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3270 vam->retval = retval;
3271 vam->result_ready = 1;
3275 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3276 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3278 vat_main_t *vam = &vat_main;
3279 vat_json_node_t _node, *node = &_node;
3280 int retval = clib_net_to_host_u32 (mp->retval);
3282 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3283 vat_json_init_object (node);
3284 vat_json_object_add_string_copy (node, "state", s);
3286 vat_json_print (vam->ofp, node);
3287 vat_json_free (node);
3289 vam->retval = retval;
3290 vam->result_ready = 1;
3295 vl_api_show_one_stats_enable_disable_reply_t_handler
3296 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3298 vat_main_t *vam = &vat_main;
3299 int retval = clib_net_to_host_u32 (mp->retval);
3304 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3306 vam->retval = retval;
3307 vam->result_ready = 1;
3311 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3312 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3314 vat_main_t *vam = &vat_main;
3315 vat_json_node_t _node, *node = &_node;
3316 int retval = clib_net_to_host_u32 (mp->retval);
3318 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3319 vat_json_init_object (node);
3320 vat_json_object_add_string_copy (node, "state", s);
3322 vat_json_print (vam->ofp, node);
3323 vat_json_free (node);
3325 vam->retval = retval;
3326 vam->result_ready = 1;
3331 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3333 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3334 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3335 e->vni = clib_net_to_host_u32 (e->vni);
3339 gpe_fwd_entries_get_reply_t_net_to_host
3340 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3344 mp->count = clib_net_to_host_u32 (mp->count);
3345 for (i = 0; i < mp->count; i++)
3347 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3352 format_gpe_encap_mode (u8 * s, va_list * args)
3354 u32 mode = va_arg (*args, u32);
3359 return format (s, "lisp");
3361 return format (s, "vxlan");
3367 vl_api_gpe_get_encap_mode_reply_t_handler
3368 (vl_api_gpe_get_encap_mode_reply_t * mp)
3370 vat_main_t *vam = &vat_main;
3372 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3373 vam->retval = ntohl (mp->retval);
3374 vam->result_ready = 1;
3378 vl_api_gpe_get_encap_mode_reply_t_handler_json
3379 (vl_api_gpe_get_encap_mode_reply_t * mp)
3381 vat_main_t *vam = &vat_main;
3382 vat_json_node_t node;
3384 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3385 vec_add1 (encap_mode, 0);
3387 vat_json_init_object (&node);
3388 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3390 vec_free (encap_mode);
3391 vat_json_print (vam->ofp, &node);
3392 vat_json_free (&node);
3394 vam->retval = ntohl (mp->retval);
3395 vam->result_ready = 1;
3399 vl_api_gpe_fwd_entry_path_details_t_handler
3400 (vl_api_gpe_fwd_entry_path_details_t * mp)
3402 vat_main_t *vam = &vat_main;
3403 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3405 if (mp->lcl_loc.is_ip4)
3406 format_ip_address_fcn = format_ip4_address;
3408 format_ip_address_fcn = format_ip6_address;
3410 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3411 format_ip_address_fcn, &mp->lcl_loc,
3412 format_ip_address_fcn, &mp->rmt_loc);
3416 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3418 struct in6_addr ip6;
3423 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3424 vat_json_object_add_ip4 (n, "address", ip4);
3428 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3429 vat_json_object_add_ip6 (n, "address", ip6);
3431 vat_json_object_add_uint (n, "weight", loc->weight);
3435 vl_api_gpe_fwd_entry_path_details_t_handler_json
3436 (vl_api_gpe_fwd_entry_path_details_t * mp)
3438 vat_main_t *vam = &vat_main;
3439 vat_json_node_t *node = NULL;
3440 vat_json_node_t *loc_node;
3442 if (VAT_JSON_ARRAY != vam->json_tree.type)
3444 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3445 vat_json_init_array (&vam->json_tree);
3447 node = vat_json_array_add (&vam->json_tree);
3448 vat_json_init_object (node);
3450 loc_node = vat_json_object_add (node, "local_locator");
3451 vat_json_init_object (loc_node);
3452 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3454 loc_node = vat_json_object_add (node, "remote_locator");
3455 vat_json_init_object (loc_node);
3456 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3460 vl_api_gpe_fwd_entries_get_reply_t_handler
3461 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3463 vat_main_t *vam = &vat_main;
3465 int retval = clib_net_to_host_u32 (mp->retval);
3466 vl_api_gpe_fwd_entry_t *e;
3471 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3473 for (i = 0; i < mp->count; i++)
3475 e = &mp->entries[i];
3476 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3477 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3478 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3482 vam->retval = retval;
3483 vam->result_ready = 1;
3487 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3488 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3491 vat_main_t *vam = &vat_main;
3492 vat_json_node_t *e = 0, root;
3494 int retval = clib_net_to_host_u32 (mp->retval);
3495 vl_api_gpe_fwd_entry_t *fwd;
3500 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3501 vat_json_init_array (&root);
3503 for (i = 0; i < mp->count; i++)
3505 e = vat_json_array_add (&root);
3506 fwd = &mp->entries[i];
3508 vat_json_init_object (e);
3509 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3510 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3511 vat_json_object_add_int (e, "vni", fwd->vni);
3512 vat_json_object_add_int (e, "action", fwd->action);
3514 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3515 fwd->leid_prefix_len);
3517 vat_json_object_add_string_copy (e, "leid", s);
3520 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3521 fwd->reid_prefix_len);
3523 vat_json_object_add_string_copy (e, "reid", s);
3527 vat_json_print (vam->ofp, &root);
3528 vat_json_free (&root);
3531 vam->retval = retval;
3532 vam->result_ready = 1;
3536 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3537 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3539 vat_main_t *vam = &vat_main;
3541 int retval = clib_net_to_host_u32 (mp->retval);
3542 vl_api_gpe_native_fwd_rpath_t *r;
3547 n = clib_net_to_host_u32 (mp->count);
3549 for (i = 0; i < n; i++)
3551 r = &mp->entries[i];
3552 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3553 clib_net_to_host_u32 (r->fib_index),
3554 clib_net_to_host_u32 (r->nh_sw_if_index),
3555 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3559 vam->retval = retval;
3560 vam->result_ready = 1;
3564 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3565 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3567 vat_main_t *vam = &vat_main;
3568 vat_json_node_t root, *e;
3570 int retval = clib_net_to_host_u32 (mp->retval);
3571 vl_api_gpe_native_fwd_rpath_t *r;
3577 n = clib_net_to_host_u32 (mp->count);
3578 vat_json_init_array (&root);
3580 for (i = 0; i < n; i++)
3582 e = vat_json_array_add (&root);
3583 vat_json_init_object (e);
3584 r = &mp->entries[i];
3586 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3589 vat_json_object_add_string_copy (e, "ip4", s);
3592 vat_json_object_add_uint (e, "fib_index",
3593 clib_net_to_host_u32 (r->fib_index));
3594 vat_json_object_add_uint (e, "nh_sw_if_index",
3595 clib_net_to_host_u32 (r->nh_sw_if_index));
3598 vat_json_print (vam->ofp, &root);
3599 vat_json_free (&root);
3602 vam->retval = retval;
3603 vam->result_ready = 1;
3607 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3608 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3610 vat_main_t *vam = &vat_main;
3612 int retval = clib_net_to_host_u32 (mp->retval);
3617 n = clib_net_to_host_u32 (mp->count);
3619 for (i = 0; i < n; i++)
3620 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3623 vam->retval = retval;
3624 vam->result_ready = 1;
3628 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3629 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3631 vat_main_t *vam = &vat_main;
3632 vat_json_node_t root;
3634 int retval = clib_net_to_host_u32 (mp->retval);
3639 n = clib_net_to_host_u32 (mp->count);
3640 vat_json_init_array (&root);
3642 for (i = 0; i < n; i++)
3643 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3645 vat_json_print (vam->ofp, &root);
3646 vat_json_free (&root);
3649 vam->retval = retval;
3650 vam->result_ready = 1;
3654 vl_api_one_ndp_entries_get_reply_t_handler
3655 (vl_api_one_ndp_entries_get_reply_t * mp)
3657 vat_main_t *vam = &vat_main;
3659 int retval = clib_net_to_host_u32 (mp->retval);
3664 n = clib_net_to_host_u32 (mp->count);
3666 for (i = 0; i < n; i++)
3667 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3668 format_ethernet_address, mp->entries[i].mac);
3671 vam->retval = retval;
3672 vam->result_ready = 1;
3676 vl_api_one_ndp_entries_get_reply_t_handler_json
3677 (vl_api_one_ndp_entries_get_reply_t * mp)
3680 vat_main_t *vam = &vat_main;
3681 vat_json_node_t *e = 0, root;
3683 int retval = clib_net_to_host_u32 (mp->retval);
3684 vl_api_one_ndp_entry_t *arp_entry;
3689 n = clib_net_to_host_u32 (mp->count);
3690 vat_json_init_array (&root);
3692 for (i = 0; i < n; i++)
3694 e = vat_json_array_add (&root);
3695 arp_entry = &mp->entries[i];
3697 vat_json_init_object (e);
3698 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3701 vat_json_object_add_string_copy (e, "mac", s);
3704 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3706 vat_json_object_add_string_copy (e, "ip6", s);
3710 vat_json_print (vam->ofp, &root);
3711 vat_json_free (&root);
3714 vam->retval = retval;
3715 vam->result_ready = 1;
3719 vl_api_one_l2_arp_entries_get_reply_t_handler
3720 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3722 vat_main_t *vam = &vat_main;
3724 int retval = clib_net_to_host_u32 (mp->retval);
3729 n = clib_net_to_host_u32 (mp->count);
3731 for (i = 0; i < n; i++)
3732 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3733 format_ethernet_address, mp->entries[i].mac);
3736 vam->retval = retval;
3737 vam->result_ready = 1;
3741 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3742 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3745 vat_main_t *vam = &vat_main;
3746 vat_json_node_t *e = 0, root;
3748 int retval = clib_net_to_host_u32 (mp->retval);
3749 vl_api_one_l2_arp_entry_t *arp_entry;
3754 n = clib_net_to_host_u32 (mp->count);
3755 vat_json_init_array (&root);
3757 for (i = 0; i < n; i++)
3759 e = vat_json_array_add (&root);
3760 arp_entry = &mp->entries[i];
3762 vat_json_init_object (e);
3763 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3766 vat_json_object_add_string_copy (e, "mac", s);
3769 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3771 vat_json_object_add_string_copy (e, "ip4", s);
3775 vat_json_print (vam->ofp, &root);
3776 vat_json_free (&root);
3779 vam->retval = retval;
3780 vam->result_ready = 1;
3784 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3786 vat_main_t *vam = &vat_main;
3788 int retval = clib_net_to_host_u32 (mp->retval);
3793 n = clib_net_to_host_u32 (mp->count);
3795 for (i = 0; i < n; i++)
3797 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3801 vam->retval = retval;
3802 vam->result_ready = 1;
3806 vl_api_one_ndp_bd_get_reply_t_handler_json
3807 (vl_api_one_ndp_bd_get_reply_t * mp)
3809 vat_main_t *vam = &vat_main;
3810 vat_json_node_t root;
3812 int retval = clib_net_to_host_u32 (mp->retval);
3817 n = clib_net_to_host_u32 (mp->count);
3818 vat_json_init_array (&root);
3820 for (i = 0; i < n; i++)
3822 vat_json_array_add_uint (&root,
3823 clib_net_to_host_u32 (mp->bridge_domains[i]));
3826 vat_json_print (vam->ofp, &root);
3827 vat_json_free (&root);
3830 vam->retval = retval;
3831 vam->result_ready = 1;
3835 vl_api_one_l2_arp_bd_get_reply_t_handler
3836 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3838 vat_main_t *vam = &vat_main;
3840 int retval = clib_net_to_host_u32 (mp->retval);
3845 n = clib_net_to_host_u32 (mp->count);
3847 for (i = 0; i < n; i++)
3849 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3853 vam->retval = retval;
3854 vam->result_ready = 1;
3858 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3859 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3861 vat_main_t *vam = &vat_main;
3862 vat_json_node_t root;
3864 int retval = clib_net_to_host_u32 (mp->retval);
3869 n = clib_net_to_host_u32 (mp->count);
3870 vat_json_init_array (&root);
3872 for (i = 0; i < n; i++)
3874 vat_json_array_add_uint (&root,
3875 clib_net_to_host_u32 (mp->bridge_domains[i]));
3878 vat_json_print (vam->ofp, &root);
3879 vat_json_free (&root);
3882 vam->retval = retval;
3883 vam->result_ready = 1;
3887 vl_api_one_adjacencies_get_reply_t_handler
3888 (vl_api_one_adjacencies_get_reply_t * mp)
3890 vat_main_t *vam = &vat_main;
3892 int retval = clib_net_to_host_u32 (mp->retval);
3893 vl_api_one_adjacency_t *a;
3898 n = clib_net_to_host_u32 (mp->count);
3900 for (i = 0; i < n; i++)
3902 a = &mp->adjacencies[i];
3903 print (vam->ofp, "%U %40U",
3904 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3905 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3909 vam->retval = retval;
3910 vam->result_ready = 1;
3914 vl_api_one_adjacencies_get_reply_t_handler_json
3915 (vl_api_one_adjacencies_get_reply_t * mp)
3918 vat_main_t *vam = &vat_main;
3919 vat_json_node_t *e = 0, root;
3921 int retval = clib_net_to_host_u32 (mp->retval);
3922 vl_api_one_adjacency_t *a;
3927 n = clib_net_to_host_u32 (mp->count);
3928 vat_json_init_array (&root);
3930 for (i = 0; i < n; i++)
3932 e = vat_json_array_add (&root);
3933 a = &mp->adjacencies[i];
3935 vat_json_init_object (e);
3936 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3937 a->leid_prefix_len);
3939 vat_json_object_add_string_copy (e, "leid", s);
3942 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3943 a->reid_prefix_len);
3945 vat_json_object_add_string_copy (e, "reid", s);
3949 vat_json_print (vam->ofp, &root);
3950 vat_json_free (&root);
3953 vam->retval = retval;
3954 vam->result_ready = 1;
3958 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3960 vat_main_t *vam = &vat_main;
3962 print (vam->ofp, "%=20U",
3963 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3968 vl_api_one_map_server_details_t_handler_json
3969 (vl_api_one_map_server_details_t * mp)
3971 vat_main_t *vam = &vat_main;
3972 vat_json_node_t *node = NULL;
3973 struct in6_addr ip6;
3976 if (VAT_JSON_ARRAY != vam->json_tree.type)
3978 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3979 vat_json_init_array (&vam->json_tree);
3981 node = vat_json_array_add (&vam->json_tree);
3983 vat_json_init_object (node);
3986 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3987 vat_json_object_add_ip6 (node, "map-server", ip6);
3991 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3992 vat_json_object_add_ip4 (node, "map-server", ip4);
3997 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4000 vat_main_t *vam = &vat_main;
4002 print (vam->ofp, "%=20U",
4003 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4008 vl_api_one_map_resolver_details_t_handler_json
4009 (vl_api_one_map_resolver_details_t * mp)
4011 vat_main_t *vam = &vat_main;
4012 vat_json_node_t *node = NULL;
4013 struct in6_addr ip6;
4016 if (VAT_JSON_ARRAY != vam->json_tree.type)
4018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4019 vat_json_init_array (&vam->json_tree);
4021 node = vat_json_array_add (&vam->json_tree);
4023 vat_json_init_object (node);
4026 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4027 vat_json_object_add_ip6 (node, "map resolver", ip6);
4031 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4032 vat_json_object_add_ip4 (node, "map resolver", ip4);
4037 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4039 vat_main_t *vam = &vat_main;
4040 i32 retval = ntohl (mp->retval);
4044 print (vam->ofp, "feature: %s\ngpe: %s",
4045 mp->feature_status ? "enabled" : "disabled",
4046 mp->gpe_status ? "enabled" : "disabled");
4049 vam->retval = retval;
4050 vam->result_ready = 1;
4054 vl_api_show_one_status_reply_t_handler_json
4055 (vl_api_show_one_status_reply_t * mp)
4057 vat_main_t *vam = &vat_main;
4058 vat_json_node_t node;
4059 u8 *gpe_status = NULL;
4060 u8 *feature_status = NULL;
4062 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4063 feature_status = format (0, "%s",
4064 mp->feature_status ? "enabled" : "disabled");
4065 vec_add1 (gpe_status, 0);
4066 vec_add1 (feature_status, 0);
4068 vat_json_init_object (&node);
4069 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4070 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4072 vec_free (gpe_status);
4073 vec_free (feature_status);
4075 vat_json_print (vam->ofp, &node);
4076 vat_json_free (&node);
4078 vam->retval = ntohl (mp->retval);
4079 vam->result_ready = 1;
4083 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4084 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4086 vat_main_t *vam = &vat_main;
4087 i32 retval = ntohl (mp->retval);
4091 print (vam->ofp, "%=20s", mp->locator_set_name);
4094 vam->retval = retval;
4095 vam->result_ready = 1;
4099 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4100 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4102 vat_main_t *vam = &vat_main;
4103 vat_json_node_t *node = NULL;
4105 if (VAT_JSON_ARRAY != vam->json_tree.type)
4107 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4108 vat_json_init_array (&vam->json_tree);
4110 node = vat_json_array_add (&vam->json_tree);
4112 vat_json_init_object (node);
4113 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4115 vat_json_print (vam->ofp, node);
4116 vat_json_free (node);
4118 vam->retval = ntohl (mp->retval);
4119 vam->result_ready = 1;
4123 format_lisp_map_request_mode (u8 * s, va_list * args)
4125 u32 mode = va_arg (*args, u32);
4130 return format (0, "dst-only");
4132 return format (0, "src-dst");
4138 vl_api_show_one_map_request_mode_reply_t_handler
4139 (vl_api_show_one_map_request_mode_reply_t * mp)
4141 vat_main_t *vam = &vat_main;
4142 i32 retval = ntohl (mp->retval);
4146 u32 mode = mp->mode;
4147 print (vam->ofp, "map_request_mode: %U",
4148 format_lisp_map_request_mode, mode);
4151 vam->retval = retval;
4152 vam->result_ready = 1;
4156 vl_api_show_one_map_request_mode_reply_t_handler_json
4157 (vl_api_show_one_map_request_mode_reply_t * mp)
4159 vat_main_t *vam = &vat_main;
4160 vat_json_node_t node;
4165 s = format (0, "%U", format_lisp_map_request_mode, mode);
4168 vat_json_init_object (&node);
4169 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4170 vat_json_print (vam->ofp, &node);
4171 vat_json_free (&node);
4174 vam->retval = ntohl (mp->retval);
4175 vam->result_ready = 1;
4179 vl_api_one_show_xtr_mode_reply_t_handler
4180 (vl_api_one_show_xtr_mode_reply_t * mp)
4182 vat_main_t *vam = &vat_main;
4183 i32 retval = ntohl (mp->retval);
4187 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4190 vam->retval = retval;
4191 vam->result_ready = 1;
4195 vl_api_one_show_xtr_mode_reply_t_handler_json
4196 (vl_api_one_show_xtr_mode_reply_t * mp)
4198 vat_main_t *vam = &vat_main;
4199 vat_json_node_t node;
4202 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4203 vec_add1 (status, 0);
4205 vat_json_init_object (&node);
4206 vat_json_object_add_string_copy (&node, "status", status);
4210 vat_json_print (vam->ofp, &node);
4211 vat_json_free (&node);
4213 vam->retval = ntohl (mp->retval);
4214 vam->result_ready = 1;
4218 vl_api_one_show_pitr_mode_reply_t_handler
4219 (vl_api_one_show_pitr_mode_reply_t * mp)
4221 vat_main_t *vam = &vat_main;
4222 i32 retval = ntohl (mp->retval);
4226 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4229 vam->retval = retval;
4230 vam->result_ready = 1;
4234 vl_api_one_show_pitr_mode_reply_t_handler_json
4235 (vl_api_one_show_pitr_mode_reply_t * mp)
4237 vat_main_t *vam = &vat_main;
4238 vat_json_node_t node;
4241 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4242 vec_add1 (status, 0);
4244 vat_json_init_object (&node);
4245 vat_json_object_add_string_copy (&node, "status", status);
4249 vat_json_print (vam->ofp, &node);
4250 vat_json_free (&node);
4252 vam->retval = ntohl (mp->retval);
4253 vam->result_ready = 1;
4257 vl_api_one_show_petr_mode_reply_t_handler
4258 (vl_api_one_show_petr_mode_reply_t * mp)
4260 vat_main_t *vam = &vat_main;
4261 i32 retval = ntohl (mp->retval);
4265 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4268 vam->retval = retval;
4269 vam->result_ready = 1;
4273 vl_api_one_show_petr_mode_reply_t_handler_json
4274 (vl_api_one_show_petr_mode_reply_t * mp)
4276 vat_main_t *vam = &vat_main;
4277 vat_json_node_t node;
4280 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4281 vec_add1 (status, 0);
4283 vat_json_init_object (&node);
4284 vat_json_object_add_string_copy (&node, "status", status);
4288 vat_json_print (vam->ofp, &node);
4289 vat_json_free (&node);
4291 vam->retval = ntohl (mp->retval);
4292 vam->result_ready = 1;
4296 vl_api_show_one_use_petr_reply_t_handler
4297 (vl_api_show_one_use_petr_reply_t * mp)
4299 vat_main_t *vam = &vat_main;
4300 i32 retval = ntohl (mp->retval);
4304 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4307 print (vam->ofp, "Proxy-ETR address; %U",
4308 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4313 vam->retval = retval;
4314 vam->result_ready = 1;
4318 vl_api_show_one_use_petr_reply_t_handler_json
4319 (vl_api_show_one_use_petr_reply_t * mp)
4321 vat_main_t *vam = &vat_main;
4322 vat_json_node_t node;
4325 struct in6_addr ip6;
4327 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4328 vec_add1 (status, 0);
4330 vat_json_init_object (&node);
4331 vat_json_object_add_string_copy (&node, "status", status);
4336 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4337 vat_json_object_add_ip6 (&node, "address", ip6);
4341 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4342 vat_json_object_add_ip4 (&node, "address", ip4);
4348 vat_json_print (vam->ofp, &node);
4349 vat_json_free (&node);
4351 vam->retval = ntohl (mp->retval);
4352 vam->result_ready = 1;
4356 vl_api_show_one_nsh_mapping_reply_t_handler
4357 (vl_api_show_one_nsh_mapping_reply_t * mp)
4359 vat_main_t *vam = &vat_main;
4360 i32 retval = ntohl (mp->retval);
4364 print (vam->ofp, "%-20s%-16s",
4365 mp->is_set ? "set" : "not-set",
4366 mp->is_set ? (char *) mp->locator_set_name : "");
4369 vam->retval = retval;
4370 vam->result_ready = 1;
4374 vl_api_show_one_nsh_mapping_reply_t_handler_json
4375 (vl_api_show_one_nsh_mapping_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 vat_json_node_t node;
4381 status = format (0, "%s", mp->is_set ? "yes" : "no");
4382 vec_add1 (status, 0);
4384 vat_json_init_object (&node);
4385 vat_json_object_add_string_copy (&node, "is_set", status);
4388 vat_json_object_add_string_copy (&node, "locator_set",
4389 mp->locator_set_name);
4394 vat_json_print (vam->ofp, &node);
4395 vat_json_free (&node);
4397 vam->retval = ntohl (mp->retval);
4398 vam->result_ready = 1;
4402 vl_api_show_one_map_register_ttl_reply_t_handler
4403 (vl_api_show_one_map_register_ttl_reply_t * mp)
4405 vat_main_t *vam = &vat_main;
4406 i32 retval = ntohl (mp->retval);
4408 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4412 print (vam->ofp, "ttl: %u", mp->ttl);
4415 vam->retval = retval;
4416 vam->result_ready = 1;
4420 vl_api_show_one_map_register_ttl_reply_t_handler_json
4421 (vl_api_show_one_map_register_ttl_reply_t * mp)
4423 vat_main_t *vam = &vat_main;
4424 vat_json_node_t node;
4426 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4427 vat_json_init_object (&node);
4428 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4430 vat_json_print (vam->ofp, &node);
4431 vat_json_free (&node);
4433 vam->retval = ntohl (mp->retval);
4434 vam->result_ready = 1;
4438 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4440 vat_main_t *vam = &vat_main;
4441 i32 retval = ntohl (mp->retval);
4445 print (vam->ofp, "%-20s%-16s",
4446 mp->status ? "enabled" : "disabled",
4447 mp->status ? (char *) mp->locator_set_name : "");
4450 vam->retval = retval;
4451 vam->result_ready = 1;
4455 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4457 vat_main_t *vam = &vat_main;
4458 vat_json_node_t node;
4461 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4462 vec_add1 (status, 0);
4464 vat_json_init_object (&node);
4465 vat_json_object_add_string_copy (&node, "status", status);
4468 vat_json_object_add_string_copy (&node, "locator_set",
4469 mp->locator_set_name);
4474 vat_json_print (vam->ofp, &node);
4475 vat_json_free (&node);
4477 vam->retval = ntohl (mp->retval);
4478 vam->result_ready = 1;
4482 format_policer_type (u8 * s, va_list * va)
4484 u32 i = va_arg (*va, u32);
4486 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4487 s = format (s, "1r2c");
4488 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4489 s = format (s, "1r3c");
4490 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4491 s = format (s, "2r3c-2698");
4492 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4493 s = format (s, "2r3c-4115");
4494 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4495 s = format (s, "2r3c-mef5cf1");
4497 s = format (s, "ILLEGAL");
4502 format_policer_rate_type (u8 * s, va_list * va)
4504 u32 i = va_arg (*va, u32);
4506 if (i == SSE2_QOS_RATE_KBPS)
4507 s = format (s, "kbps");
4508 else if (i == SSE2_QOS_RATE_PPS)
4509 s = format (s, "pps");
4511 s = format (s, "ILLEGAL");
4516 format_policer_round_type (u8 * s, va_list * va)
4518 u32 i = va_arg (*va, u32);
4520 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4521 s = format (s, "closest");
4522 else if (i == SSE2_QOS_ROUND_TO_UP)
4523 s = format (s, "up");
4524 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4525 s = format (s, "down");
4527 s = format (s, "ILLEGAL");
4532 format_policer_action_type (u8 * s, va_list * va)
4534 u32 i = va_arg (*va, u32);
4536 if (i == SSE2_QOS_ACTION_DROP)
4537 s = format (s, "drop");
4538 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4539 s = format (s, "transmit");
4540 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4541 s = format (s, "mark-and-transmit");
4543 s = format (s, "ILLEGAL");
4548 format_dscp (u8 * s, va_list * va)
4550 u32 i = va_arg (*va, u32);
4555 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4559 return format (s, "ILLEGAL");
4561 s = format (s, "%s", t);
4566 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4568 vat_main_t *vam = &vat_main;
4569 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4571 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4572 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4574 conform_dscp_str = format (0, "");
4576 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4577 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4579 exceed_dscp_str = format (0, "");
4581 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4582 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4584 violate_dscp_str = format (0, "");
4586 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4587 "rate type %U, round type %U, %s rate, %s color-aware, "
4588 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4589 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4590 "conform action %U%s, exceed action %U%s, violate action %U%s",
4592 format_policer_type, mp->type,
4595 clib_net_to_host_u64 (mp->cb),
4596 clib_net_to_host_u64 (mp->eb),
4597 format_policer_rate_type, mp->rate_type,
4598 format_policer_round_type, mp->round_type,
4599 mp->single_rate ? "single" : "dual",
4600 mp->color_aware ? "is" : "not",
4601 ntohl (mp->cir_tokens_per_period),
4602 ntohl (mp->pir_tokens_per_period),
4604 ntohl (mp->current_limit),
4605 ntohl (mp->current_bucket),
4606 ntohl (mp->extended_limit),
4607 ntohl (mp->extended_bucket),
4608 clib_net_to_host_u64 (mp->last_update_time),
4609 format_policer_action_type, mp->conform_action_type,
4611 format_policer_action_type, mp->exceed_action_type,
4613 format_policer_action_type, mp->violate_action_type,
4616 vec_free (conform_dscp_str);
4617 vec_free (exceed_dscp_str);
4618 vec_free (violate_dscp_str);
4621 static void vl_api_policer_details_t_handler_json
4622 (vl_api_policer_details_t * mp)
4624 vat_main_t *vam = &vat_main;
4625 vat_json_node_t *node;
4626 u8 *rate_type_str, *round_type_str, *type_str;
4627 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4629 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4631 format (0, "%U", format_policer_round_type, mp->round_type);
4632 type_str = format (0, "%U", format_policer_type, mp->type);
4633 conform_action_str = format (0, "%U", format_policer_action_type,
4634 mp->conform_action_type);
4635 exceed_action_str = format (0, "%U", format_policer_action_type,
4636 mp->exceed_action_type);
4637 violate_action_str = format (0, "%U", format_policer_action_type,
4638 mp->violate_action_type);
4640 if (VAT_JSON_ARRAY != vam->json_tree.type)
4642 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4643 vat_json_init_array (&vam->json_tree);
4645 node = vat_json_array_add (&vam->json_tree);
4647 vat_json_init_object (node);
4648 vat_json_object_add_string_copy (node, "name", mp->name);
4649 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4650 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4651 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4652 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4653 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4654 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4655 vat_json_object_add_string_copy (node, "type", type_str);
4656 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4657 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4658 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4659 vat_json_object_add_uint (node, "cir_tokens_per_period",
4660 ntohl (mp->cir_tokens_per_period));
4661 vat_json_object_add_uint (node, "eir_tokens_per_period",
4662 ntohl (mp->pir_tokens_per_period));
4663 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4664 vat_json_object_add_uint (node, "current_bucket",
4665 ntohl (mp->current_bucket));
4666 vat_json_object_add_uint (node, "extended_limit",
4667 ntohl (mp->extended_limit));
4668 vat_json_object_add_uint (node, "extended_bucket",
4669 ntohl (mp->extended_bucket));
4670 vat_json_object_add_uint (node, "last_update_time",
4671 ntohl (mp->last_update_time));
4672 vat_json_object_add_string_copy (node, "conform_action",
4673 conform_action_str);
4674 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4676 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4677 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4678 vec_free (dscp_str);
4680 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4681 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4683 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4684 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4685 vec_free (dscp_str);
4687 vat_json_object_add_string_copy (node, "violate_action",
4688 violate_action_str);
4689 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4691 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4692 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4693 vec_free (dscp_str);
4696 vec_free (rate_type_str);
4697 vec_free (round_type_str);
4698 vec_free (type_str);
4699 vec_free (conform_action_str);
4700 vec_free (exceed_action_str);
4701 vec_free (violate_action_str);
4705 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4708 vat_main_t *vam = &vat_main;
4709 int i, count = ntohl (mp->count);
4712 print (vam->ofp, "classify table ids (%d) : ", count);
4713 for (i = 0; i < count; i++)
4715 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4716 print (vam->ofp, (i < count - 1) ? "," : "");
4718 vam->retval = ntohl (mp->retval);
4719 vam->result_ready = 1;
4723 vl_api_classify_table_ids_reply_t_handler_json
4724 (vl_api_classify_table_ids_reply_t * mp)
4726 vat_main_t *vam = &vat_main;
4727 int i, count = ntohl (mp->count);
4731 vat_json_node_t node;
4733 vat_json_init_object (&node);
4734 for (i = 0; i < count; i++)
4736 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4738 vat_json_print (vam->ofp, &node);
4739 vat_json_free (&node);
4741 vam->retval = ntohl (mp->retval);
4742 vam->result_ready = 1;
4746 vl_api_classify_table_by_interface_reply_t_handler
4747 (vl_api_classify_table_by_interface_reply_t * mp)
4749 vat_main_t *vam = &vat_main;
4752 table_id = ntohl (mp->l2_table_id);
4754 print (vam->ofp, "l2 table id : %d", table_id);
4756 print (vam->ofp, "l2 table id : No input ACL tables configured");
4757 table_id = ntohl (mp->ip4_table_id);
4759 print (vam->ofp, "ip4 table id : %d", table_id);
4761 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4762 table_id = ntohl (mp->ip6_table_id);
4764 print (vam->ofp, "ip6 table id : %d", table_id);
4766 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4767 vam->retval = ntohl (mp->retval);
4768 vam->result_ready = 1;
4772 vl_api_classify_table_by_interface_reply_t_handler_json
4773 (vl_api_classify_table_by_interface_reply_t * mp)
4775 vat_main_t *vam = &vat_main;
4776 vat_json_node_t node;
4778 vat_json_init_object (&node);
4780 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4781 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4782 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4784 vat_json_print (vam->ofp, &node);
4785 vat_json_free (&node);
4787 vam->retval = ntohl (mp->retval);
4788 vam->result_ready = 1;
4791 static void vl_api_policer_add_del_reply_t_handler
4792 (vl_api_policer_add_del_reply_t * mp)
4794 vat_main_t *vam = &vat_main;
4795 i32 retval = ntohl (mp->retval);
4796 if (vam->async_mode)
4798 vam->async_errors += (retval < 0);
4802 vam->retval = retval;
4803 vam->result_ready = 1;
4804 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4806 * Note: this is just barely thread-safe, depends on
4807 * the main thread spinning waiting for an answer...
4809 errmsg ("policer index %d", ntohl (mp->policer_index));
4813 static void vl_api_policer_add_del_reply_t_handler_json
4814 (vl_api_policer_add_del_reply_t * mp)
4816 vat_main_t *vam = &vat_main;
4817 vat_json_node_t node;
4819 vat_json_init_object (&node);
4820 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4821 vat_json_object_add_uint (&node, "policer_index",
4822 ntohl (mp->policer_index));
4824 vat_json_print (vam->ofp, &node);
4825 vat_json_free (&node);
4827 vam->retval = ntohl (mp->retval);
4828 vam->result_ready = 1;
4831 /* Format hex dump. */
4833 format_hex_bytes (u8 * s, va_list * va)
4835 u8 *bytes = va_arg (*va, u8 *);
4836 int n_bytes = va_arg (*va, int);
4839 /* Print short or long form depending on byte count. */
4840 uword short_form = n_bytes <= 32;
4841 u32 indent = format_get_indent (s);
4846 for (i = 0; i < n_bytes; i++)
4848 if (!short_form && (i % 32) == 0)
4849 s = format (s, "%08x: ", i);
4850 s = format (s, "%02x", bytes[i]);
4851 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4852 s = format (s, "\n%U", format_white_space, indent);
4859 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4862 vat_main_t *vam = &vat_main;
4863 i32 retval = ntohl (mp->retval);
4866 print (vam->ofp, "classify table info :");
4867 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4868 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4869 ntohl (mp->miss_next_index));
4870 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4871 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4872 ntohl (mp->match_n_vectors));
4873 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4874 ntohl (mp->mask_length));
4876 vam->retval = retval;
4877 vam->result_ready = 1;
4881 vl_api_classify_table_info_reply_t_handler_json
4882 (vl_api_classify_table_info_reply_t * mp)
4884 vat_main_t *vam = &vat_main;
4885 vat_json_node_t node;
4887 i32 retval = ntohl (mp->retval);
4890 vat_json_init_object (&node);
4892 vat_json_object_add_int (&node, "sessions",
4893 ntohl (mp->active_sessions));
4894 vat_json_object_add_int (&node, "nexttbl",
4895 ntohl (mp->next_table_index));
4896 vat_json_object_add_int (&node, "nextnode",
4897 ntohl (mp->miss_next_index));
4898 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4899 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4900 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4901 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4902 ntohl (mp->mask_length), 0);
4903 vat_json_object_add_string_copy (&node, "mask", s);
4905 vat_json_print (vam->ofp, &node);
4906 vat_json_free (&node);
4908 vam->retval = ntohl (mp->retval);
4909 vam->result_ready = 1;
4913 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4916 vat_main_t *vam = &vat_main;
4918 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4919 ntohl (mp->hit_next_index), ntohl (mp->advance),
4920 ntohl (mp->opaque_index));
4921 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4922 ntohl (mp->match_length));
4926 vl_api_classify_session_details_t_handler_json
4927 (vl_api_classify_session_details_t * mp)
4929 vat_main_t *vam = &vat_main;
4930 vat_json_node_t *node = NULL;
4932 if (VAT_JSON_ARRAY != vam->json_tree.type)
4934 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4935 vat_json_init_array (&vam->json_tree);
4937 node = vat_json_array_add (&vam->json_tree);
4939 vat_json_init_object (node);
4940 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4941 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4942 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4944 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4946 vat_json_object_add_string_copy (node, "match", s);
4949 static void vl_api_pg_create_interface_reply_t_handler
4950 (vl_api_pg_create_interface_reply_t * mp)
4952 vat_main_t *vam = &vat_main;
4954 vam->retval = ntohl (mp->retval);
4955 vam->result_ready = 1;
4958 static void vl_api_pg_create_interface_reply_t_handler_json
4959 (vl_api_pg_create_interface_reply_t * mp)
4961 vat_main_t *vam = &vat_main;
4962 vat_json_node_t node;
4964 i32 retval = ntohl (mp->retval);
4967 vat_json_init_object (&node);
4969 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4971 vat_json_print (vam->ofp, &node);
4972 vat_json_free (&node);
4974 vam->retval = ntohl (mp->retval);
4975 vam->result_ready = 1;
4978 static void vl_api_policer_classify_details_t_handler
4979 (vl_api_policer_classify_details_t * mp)
4981 vat_main_t *vam = &vat_main;
4983 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4984 ntohl (mp->table_index));
4987 static void vl_api_policer_classify_details_t_handler_json
4988 (vl_api_policer_classify_details_t * mp)
4990 vat_main_t *vam = &vat_main;
4991 vat_json_node_t *node;
4993 if (VAT_JSON_ARRAY != vam->json_tree.type)
4995 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4996 vat_json_init_array (&vam->json_tree);
4998 node = vat_json_array_add (&vam->json_tree);
5000 vat_json_init_object (node);
5001 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5002 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5005 static void vl_api_flow_classify_details_t_handler
5006 (vl_api_flow_classify_details_t * mp)
5008 vat_main_t *vam = &vat_main;
5010 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5011 ntohl (mp->table_index));
5014 static void vl_api_flow_classify_details_t_handler_json
5015 (vl_api_flow_classify_details_t * mp)
5017 vat_main_t *vam = &vat_main;
5018 vat_json_node_t *node;
5020 if (VAT_JSON_ARRAY != vam->json_tree.type)
5022 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5023 vat_json_init_array (&vam->json_tree);
5025 node = vat_json_array_add (&vam->json_tree);
5027 vat_json_init_object (node);
5028 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5029 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5032 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5033 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5034 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5035 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5036 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5037 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5038 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5039 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5040 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5041 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5044 * Generate boilerplate reply handlers, which
5045 * dig the return value out of the xxx_reply_t API message,
5046 * stick it into vam->retval, and set vam->result_ready
5048 * Could also do this by pointing N message decode slots at
5049 * a single function, but that could break in subtle ways.
5052 #define foreach_standard_reply_retval_handler \
5053 _(sw_interface_set_flags_reply) \
5054 _(sw_interface_add_del_address_reply) \
5055 _(sw_interface_set_rx_mode_reply) \
5056 _(sw_interface_set_rx_placement_reply) \
5057 _(sw_interface_set_table_reply) \
5058 _(sw_interface_set_mpls_enable_reply) \
5059 _(sw_interface_set_vpath_reply) \
5060 _(sw_interface_set_vxlan_bypass_reply) \
5061 _(sw_interface_set_geneve_bypass_reply) \
5062 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5063 _(sw_interface_set_l2_bridge_reply) \
5064 _(sw_interface_set_bond_weight_reply) \
5065 _(bridge_domain_add_del_reply) \
5066 _(sw_interface_set_l2_xconnect_reply) \
5067 _(l2fib_add_del_reply) \
5068 _(l2fib_flush_int_reply) \
5069 _(l2fib_flush_bd_reply) \
5070 _(ip_route_add_del_reply) \
5071 _(ip_table_add_del_reply) \
5072 _(ip_mroute_add_del_reply) \
5073 _(mpls_route_add_del_reply) \
5074 _(mpls_table_add_del_reply) \
5075 _(mpls_ip_bind_unbind_reply) \
5076 _(bier_route_add_del_reply) \
5077 _(bier_table_add_del_reply) \
5078 _(proxy_arp_add_del_reply) \
5079 _(proxy_arp_intfc_enable_disable_reply) \
5080 _(sw_interface_set_unnumbered_reply) \
5081 _(ip_neighbor_add_del_reply) \
5082 _(reset_fib_reply) \
5083 _(set_ip_flow_hash_reply) \
5084 _(sw_interface_ip6_enable_disable_reply) \
5085 _(ip6nd_proxy_add_del_reply) \
5086 _(sw_interface_ip6nd_ra_prefix_reply) \
5087 _(sw_interface_ip6nd_ra_config_reply) \
5088 _(set_arp_neighbor_limit_reply) \
5089 _(l2_patch_add_del_reply) \
5090 _(sr_mpls_policy_add_reply) \
5091 _(sr_mpls_policy_mod_reply) \
5092 _(sr_mpls_policy_del_reply) \
5093 _(sr_policy_add_reply) \
5094 _(sr_policy_mod_reply) \
5095 _(sr_policy_del_reply) \
5096 _(sr_localsid_add_del_reply) \
5097 _(sr_steering_add_del_reply) \
5098 _(classify_add_del_session_reply) \
5099 _(classify_set_interface_ip_table_reply) \
5100 _(classify_set_interface_l2_tables_reply) \
5101 _(l2tpv3_set_tunnel_cookies_reply) \
5102 _(l2tpv3_interface_enable_disable_reply) \
5103 _(l2tpv3_set_lookup_key_reply) \
5104 _(l2_fib_clear_table_reply) \
5105 _(l2_interface_efp_filter_reply) \
5106 _(l2_interface_vlan_tag_rewrite_reply) \
5107 _(modify_vhost_user_if_reply) \
5108 _(delete_vhost_user_if_reply) \
5109 _(ip_probe_neighbor_reply) \
5110 _(ip_scan_neighbor_enable_disable_reply) \
5111 _(want_ip4_arp_events_reply) \
5112 _(want_ip6_nd_events_reply) \
5113 _(want_l2_macs_events_reply) \
5114 _(input_acl_set_interface_reply) \
5115 _(ipsec_spd_add_del_reply) \
5116 _(ipsec_interface_add_del_spd_reply) \
5117 _(ipsec_spd_entry_add_del_reply) \
5118 _(ipsec_sad_entry_add_del_reply) \
5119 _(ipsec_tunnel_if_add_del_reply) \
5120 _(ipsec_tunnel_if_set_sa_reply) \
5121 _(delete_loopback_reply) \
5122 _(bd_ip_mac_add_del_reply) \
5123 _(bd_ip_mac_flush_reply) \
5124 _(want_interface_events_reply) \
5125 _(cop_interface_enable_disable_reply) \
5126 _(cop_whitelist_enable_disable_reply) \
5127 _(sw_interface_clear_stats_reply) \
5128 _(ioam_enable_reply) \
5129 _(ioam_disable_reply) \
5130 _(one_add_del_locator_reply) \
5131 _(one_add_del_local_eid_reply) \
5132 _(one_add_del_remote_mapping_reply) \
5133 _(one_add_del_adjacency_reply) \
5134 _(one_add_del_map_resolver_reply) \
5135 _(one_add_del_map_server_reply) \
5136 _(one_enable_disable_reply) \
5137 _(one_rloc_probe_enable_disable_reply) \
5138 _(one_map_register_enable_disable_reply) \
5139 _(one_map_register_set_ttl_reply) \
5140 _(one_set_transport_protocol_reply) \
5141 _(one_map_register_fallback_threshold_reply) \
5142 _(one_pitr_set_locator_set_reply) \
5143 _(one_map_request_mode_reply) \
5144 _(one_add_del_map_request_itr_rlocs_reply) \
5145 _(one_eid_table_add_del_map_reply) \
5146 _(one_use_petr_reply) \
5147 _(one_stats_enable_disable_reply) \
5148 _(one_add_del_l2_arp_entry_reply) \
5149 _(one_add_del_ndp_entry_reply) \
5150 _(one_stats_flush_reply) \
5151 _(one_enable_disable_xtr_mode_reply) \
5152 _(one_enable_disable_pitr_mode_reply) \
5153 _(one_enable_disable_petr_mode_reply) \
5154 _(gpe_enable_disable_reply) \
5155 _(gpe_set_encap_mode_reply) \
5156 _(gpe_add_del_iface_reply) \
5157 _(gpe_add_del_native_fwd_rpath_reply) \
5158 _(af_packet_delete_reply) \
5159 _(policer_classify_set_interface_reply) \
5160 _(netmap_create_reply) \
5161 _(netmap_delete_reply) \
5162 _(set_ipfix_exporter_reply) \
5163 _(set_ipfix_classify_stream_reply) \
5164 _(ipfix_classify_table_add_del_reply) \
5165 _(flow_classify_set_interface_reply) \
5166 _(sw_interface_span_enable_disable_reply) \
5167 _(pg_capture_reply) \
5168 _(pg_enable_disable_reply) \
5169 _(ip_source_and_port_range_check_add_del_reply) \
5170 _(ip_source_and_port_range_check_interface_add_del_reply)\
5171 _(delete_subif_reply) \
5172 _(l2_interface_pbb_tag_rewrite_reply) \
5174 _(feature_enable_disable_reply) \
5175 _(sw_interface_tag_add_del_reply) \
5176 _(sw_interface_add_del_mac_address_reply) \
5177 _(hw_interface_set_mtu_reply) \
5178 _(p2p_ethernet_add_reply) \
5179 _(p2p_ethernet_del_reply) \
5180 _(lldp_config_reply) \
5181 _(sw_interface_set_lldp_reply) \
5182 _(tcp_configure_src_addresses_reply) \
5183 _(session_rule_add_del_reply) \
5184 _(ip_container_proxy_add_del_reply) \
5185 _(output_acl_set_interface_reply) \
5186 _(qos_record_enable_disable_reply)
5189 static void vl_api_##n##_t_handler \
5190 (vl_api_##n##_t * mp) \
5192 vat_main_t * vam = &vat_main; \
5193 i32 retval = ntohl(mp->retval); \
5194 if (vam->async_mode) { \
5195 vam->async_errors += (retval < 0); \
5197 vam->retval = retval; \
5198 vam->result_ready = 1; \
5201 foreach_standard_reply_retval_handler;
5205 static void vl_api_##n##_t_handler_json \
5206 (vl_api_##n##_t * mp) \
5208 vat_main_t * vam = &vat_main; \
5209 vat_json_node_t node; \
5210 vat_json_init_object(&node); \
5211 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5212 vat_json_print(vam->ofp, &node); \
5213 vam->retval = ntohl(mp->retval); \
5214 vam->result_ready = 1; \
5216 foreach_standard_reply_retval_handler;
5220 * Table of message reply handlers, must include boilerplate handlers
5224 #define foreach_vpe_api_reply_msg \
5225 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5226 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5227 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5228 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5229 _(CONTROL_PING_REPLY, control_ping_reply) \
5230 _(CLI_REPLY, cli_reply) \
5231 _(CLI_INBAND_REPLY, cli_inband_reply) \
5232 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5233 sw_interface_add_del_address_reply) \
5234 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5235 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5236 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5237 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5238 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5239 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5240 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5241 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5242 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5243 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5244 sw_interface_set_l2_xconnect_reply) \
5245 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5246 sw_interface_set_l2_bridge_reply) \
5247 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5248 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5249 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5250 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5251 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5252 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5253 _(L2_FLAGS_REPLY, l2_flags_reply) \
5254 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5255 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5256 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5257 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5258 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5259 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5260 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5261 _(BOND_CREATE_REPLY, bond_create_reply) \
5262 _(BOND_DELETE_REPLY, bond_delete_reply) \
5263 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5264 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5265 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5266 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5267 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5268 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5269 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5270 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5271 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5272 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5273 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5274 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5275 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5276 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5277 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5278 proxy_arp_intfc_enable_disable_reply) \
5279 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5280 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5281 sw_interface_set_unnumbered_reply) \
5282 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5283 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5284 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5285 _(RESET_FIB_REPLY, reset_fib_reply) \
5286 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5287 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5288 sw_interface_ip6_enable_disable_reply) \
5289 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5290 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5291 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5292 sw_interface_ip6nd_ra_prefix_reply) \
5293 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5294 sw_interface_ip6nd_ra_config_reply) \
5295 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5296 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5297 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5298 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5299 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5300 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5301 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5302 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5303 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5304 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5305 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5306 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5307 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5308 classify_set_interface_ip_table_reply) \
5309 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5310 classify_set_interface_l2_tables_reply) \
5311 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5312 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5313 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5314 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5315 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5316 l2tpv3_interface_enable_disable_reply) \
5317 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5318 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5319 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5320 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5321 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5322 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5323 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5324 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5325 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5326 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5327 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5328 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5329 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5330 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5331 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5332 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5333 _(SHOW_VERSION_REPLY, show_version_reply) \
5334 _(SHOW_THREADS_REPLY, show_threads_reply) \
5335 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5336 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5337 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5338 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5339 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5340 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5341 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5342 _(IP4_ARP_EVENT, ip4_arp_event) \
5343 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5344 _(IP6_ND_EVENT, ip6_nd_event) \
5345 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5346 _(L2_MACS_EVENT, l2_macs_event) \
5347 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5348 _(IP_ADDRESS_DETAILS, ip_address_details) \
5349 _(IP_DETAILS, ip_details) \
5350 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5351 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5352 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5353 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5354 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5355 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5356 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5357 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5358 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5359 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5360 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5361 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5362 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5363 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5364 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5365 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5366 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5367 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5368 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5369 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5370 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5371 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5372 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5373 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5374 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5375 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5376 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5377 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5378 one_map_register_enable_disable_reply) \
5379 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5380 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5381 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5382 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5383 one_map_register_fallback_threshold_reply) \
5384 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5385 one_rloc_probe_enable_disable_reply) \
5386 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5387 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5388 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5389 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5390 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5391 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5392 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5393 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5394 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5395 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5396 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5397 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5398 _(ONE_STATS_DETAILS, one_stats_details) \
5399 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5400 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5401 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5402 show_one_stats_enable_disable_reply) \
5403 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5404 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5405 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5406 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5407 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5408 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5409 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5410 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5411 one_enable_disable_pitr_mode_reply) \
5412 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5413 one_enable_disable_petr_mode_reply) \
5414 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5415 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5416 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5417 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5418 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5419 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5420 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5421 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5422 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5423 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5424 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5425 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5426 gpe_add_del_native_fwd_rpath_reply) \
5427 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5428 gpe_fwd_entry_path_details) \
5429 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5430 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5431 one_add_del_map_request_itr_rlocs_reply) \
5432 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5433 one_get_map_request_itr_rlocs_reply) \
5434 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5435 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5436 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5437 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5438 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5439 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5440 show_one_map_register_state_reply) \
5441 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5442 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5443 show_one_map_register_fallback_threshold_reply) \
5444 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5445 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5446 _(AF_PACKET_DETAILS, af_packet_details) \
5447 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5448 _(POLICER_DETAILS, policer_details) \
5449 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5450 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5451 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5452 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5453 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5454 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5455 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5456 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5457 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5458 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5459 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5460 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5461 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5462 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5463 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5464 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5465 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5466 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5467 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5468 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5469 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5470 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5471 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5472 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5473 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5474 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5475 ip_source_and_port_range_check_add_del_reply) \
5476 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5477 ip_source_and_port_range_check_interface_add_del_reply) \
5478 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5479 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5480 _(SET_PUNT_REPLY, set_punt_reply) \
5481 _(IP_TABLE_DETAILS, ip_table_details) \
5482 _(IP_ROUTE_DETAILS, ip_route_details) \
5483 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5484 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5485 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5486 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5487 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5488 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5489 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5490 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5491 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5492 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5493 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5494 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5495 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5496 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5497 _(SESSION_RULES_DETAILS, session_rules_details) \
5498 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5499 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5500 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5502 #define foreach_standalone_reply_msg \
5503 _(SW_INTERFACE_EVENT, sw_interface_event)
5511 #define STR_VTR_OP_CASE(op) \
5512 case L2_VTR_ ## op: \
5516 str_vtr_op (u32 vtr_op)
5520 STR_VTR_OP_CASE (DISABLED);
5521 STR_VTR_OP_CASE (PUSH_1);
5522 STR_VTR_OP_CASE (PUSH_2);
5523 STR_VTR_OP_CASE (POP_1);
5524 STR_VTR_OP_CASE (POP_2);
5525 STR_VTR_OP_CASE (TRANSLATE_1_1);
5526 STR_VTR_OP_CASE (TRANSLATE_1_2);
5527 STR_VTR_OP_CASE (TRANSLATE_2_1);
5528 STR_VTR_OP_CASE (TRANSLATE_2_2);
5535 dump_sub_interface_table (vat_main_t * vam)
5537 const sw_interface_subif_t *sub = NULL;
5539 if (vam->json_output)
5542 ("JSON output supported only for VPE API calls and dump_stats_table");
5547 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5548 "Interface", "sw_if_index",
5549 "sub id", "dot1ad", "tags", "outer id",
5550 "inner id", "exact", "default", "outer any", "inner any");
5552 vec_foreach (sub, vam->sw_if_subif_table)
5555 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5556 sub->interface_name,
5558 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5559 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5560 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5561 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5562 if (sub->vtr_op != L2_VTR_DISABLED)
5565 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5566 "tag1: %d tag2: %d ]",
5567 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5568 sub->vtr_tag1, sub->vtr_tag2);
5576 name_sort_cmp (void *a1, void *a2)
5578 name_sort_t *n1 = a1;
5579 name_sort_t *n2 = a2;
5581 return strcmp ((char *) n1->name, (char *) n2->name);
5585 dump_interface_table (vat_main_t * vam)
5588 name_sort_t *nses = 0, *ns;
5590 if (vam->json_output)
5593 ("JSON output supported only for VPE API calls and dump_stats_table");
5598 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5600 vec_add2 (nses, ns, 1);
5601 ns->name = (u8 *)(p->key);
5602 ns->value = (u32) p->value[0];
5606 vec_sort_with_function (nses, name_sort_cmp);
5608 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5609 vec_foreach (ns, nses)
5611 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5618 dump_ip_table (vat_main_t * vam, int is_ipv6)
5620 const ip_details_t *det = NULL;
5621 const ip_address_details_t *address = NULL;
5624 print (vam->ofp, "%-12s", "sw_if_index");
5626 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5633 print (vam->ofp, "%-12d", i);
5634 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5639 vec_foreach (address, det->addr)
5643 is_ipv6 ? format_ip6_address : format_ip4_address,
5644 address->ip, address->prefix_length);
5652 dump_ipv4_table (vat_main_t * vam)
5654 if (vam->json_output)
5657 ("JSON output supported only for VPE API calls and dump_stats_table");
5661 return dump_ip_table (vam, 0);
5665 dump_ipv6_table (vat_main_t * vam)
5667 if (vam->json_output)
5670 ("JSON output supported only for VPE API calls and dump_stats_table");
5674 return dump_ip_table (vam, 1);
5678 * Pass CLI buffers directly in the CLI_INBAND API message,
5679 * instead of an additional shared memory area.
5682 exec_inband (vat_main_t * vam)
5684 vl_api_cli_inband_t *mp;
5685 unformat_input_t *i = vam->input;
5688 if (vec_len (i->buffer) == 0)
5691 if (vam->exec_mode == 0 && unformat (i, "mode"))
5696 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5703 * In order for the CLI command to work, it
5704 * must be a vector ending in \n, not a C-string ending
5707 u32 len = vec_len (vam->input->buffer);
5708 M2 (CLI_INBAND, mp, len);
5709 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5713 /* json responses may or may not include a useful reply... */
5714 if (vec_len (vam->cmd_reply))
5715 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5720 exec (vat_main_t * vam)
5722 return exec_inband (vam);
5726 api_create_loopback (vat_main_t * vam)
5728 unformat_input_t *i = vam->input;
5729 vl_api_create_loopback_t *mp;
5730 vl_api_create_loopback_instance_t *mp_lbi;
5733 u8 is_specified = 0;
5734 u32 user_instance = 0;
5737 clib_memset (mac_address, 0, sizeof (mac_address));
5739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5741 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5743 if (unformat (i, "instance %d", &user_instance))
5751 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5752 mp_lbi->is_specified = is_specified;
5754 mp_lbi->user_instance = htonl (user_instance);
5756 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5761 /* Construct the API message */
5762 M (CREATE_LOOPBACK, mp);
5764 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5773 api_delete_loopback (vat_main_t * vam)
5775 unformat_input_t *i = vam->input;
5776 vl_api_delete_loopback_t *mp;
5777 u32 sw_if_index = ~0;
5780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5782 if (unformat (i, "sw_if_index %d", &sw_if_index))
5788 if (sw_if_index == ~0)
5790 errmsg ("missing sw_if_index");
5794 /* Construct the API message */
5795 M (DELETE_LOOPBACK, mp);
5796 mp->sw_if_index = ntohl (sw_if_index);
5804 api_want_interface_events (vat_main_t * vam)
5806 unformat_input_t *i = vam->input;
5807 vl_api_want_interface_events_t *mp;
5811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5813 if (unformat (i, "enable"))
5815 else if (unformat (i, "disable"))
5823 errmsg ("missing enable|disable");
5827 M (WANT_INTERFACE_EVENTS, mp);
5828 mp->enable_disable = enable;
5830 vam->interface_event_display = enable;
5838 /* Note: non-static, called once to set up the initial intfc table */
5840 api_sw_interface_dump (vat_main_t * vam)
5842 vl_api_sw_interface_dump_t *mp;
5843 vl_api_control_ping_t *mp_ping;
5845 name_sort_t *nses = 0, *ns;
5846 sw_interface_subif_t *sub = NULL;
5849 /* Toss the old name table */
5851 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5853 vec_add2 (nses, ns, 1);
5854 ns->name = (u8 *)(p->key);
5855 ns->value = (u32) p->value[0];
5859 hash_free (vam->sw_if_index_by_interface_name);
5861 vec_foreach (ns, nses) vec_free (ns->name);
5865 vec_foreach (sub, vam->sw_if_subif_table)
5867 vec_free (sub->interface_name);
5869 vec_free (vam->sw_if_subif_table);
5871 /* recreate the interface name hash table */
5872 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5875 * Ask for all interface names. Otherwise, the epic catalog of
5876 * name filters becomes ridiculously long, and vat ends up needing
5877 * to be taught about new interface types.
5879 M (SW_INTERFACE_DUMP, mp);
5882 /* Use a control ping for synchronization */
5883 MPING (CONTROL_PING, mp_ping);
5891 api_sw_interface_set_flags (vat_main_t * vam)
5893 unformat_input_t *i = vam->input;
5894 vl_api_sw_interface_set_flags_t *mp;
5896 u8 sw_if_index_set = 0;
5900 /* Parse args required to build the message */
5901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5903 if (unformat (i, "admin-up"))
5905 else if (unformat (i, "admin-down"))
5908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5909 sw_if_index_set = 1;
5910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5911 sw_if_index_set = 1;
5916 if (sw_if_index_set == 0)
5918 errmsg ("missing interface name or sw_if_index");
5922 /* Construct the API message */
5923 M (SW_INTERFACE_SET_FLAGS, mp);
5924 mp->sw_if_index = ntohl (sw_if_index);
5925 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5930 /* Wait for a reply, return the good/bad news... */
5936 api_sw_interface_set_rx_mode (vat_main_t * vam)
5938 unformat_input_t *i = vam->input;
5939 vl_api_sw_interface_set_rx_mode_t *mp;
5941 u8 sw_if_index_set = 0;
5943 u8 queue_id_valid = 0;
5945 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5947 /* Parse args required to build the message */
5948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5950 if (unformat (i, "queue %d", &queue_id))
5952 else if (unformat (i, "polling"))
5953 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5954 else if (unformat (i, "interrupt"))
5955 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5956 else if (unformat (i, "adaptive"))
5957 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5959 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5960 sw_if_index_set = 1;
5961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5962 sw_if_index_set = 1;
5967 if (sw_if_index_set == 0)
5969 errmsg ("missing interface name or sw_if_index");
5972 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5974 errmsg ("missing rx-mode");
5978 /* Construct the API message */
5979 M (SW_INTERFACE_SET_RX_MODE, mp);
5980 mp->sw_if_index = ntohl (sw_if_index);
5981 mp->mode = (vl_api_rx_mode_t) mode;
5982 mp->queue_id_valid = queue_id_valid;
5983 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5988 /* Wait for a reply, return the good/bad news... */
5994 api_sw_interface_set_rx_placement (vat_main_t * vam)
5996 unformat_input_t *i = vam->input;
5997 vl_api_sw_interface_set_rx_placement_t *mp;
5999 u8 sw_if_index_set = 0;
6002 u32 queue_id, thread_index;
6004 /* Parse args required to build the message */
6005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6007 if (unformat (i, "queue %d", &queue_id))
6009 else if (unformat (i, "main"))
6011 else if (unformat (i, "worker %d", &thread_index))
6014 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6015 sw_if_index_set = 1;
6016 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6017 sw_if_index_set = 1;
6022 if (sw_if_index_set == 0)
6024 errmsg ("missing interface name or sw_if_index");
6030 /* Construct the API message */
6031 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6032 mp->sw_if_index = ntohl (sw_if_index);
6033 mp->worker_id = ntohl (thread_index);
6034 mp->queue_id = ntohl (queue_id);
6035 mp->is_main = is_main;
6039 /* Wait for a reply, return the good/bad news... */
6044 static void vl_api_sw_interface_rx_placement_details_t_handler
6045 (vl_api_sw_interface_rx_placement_details_t * mp)
6047 vat_main_t *vam = &vat_main;
6048 u32 worker_id = ntohl (mp->worker_id);
6051 "\n%-11d %-11s %-6d %-5d %-9s",
6052 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6053 worker_id, ntohl (mp->queue_id),
6055 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6058 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6059 (vl_api_sw_interface_rx_placement_details_t * mp)
6061 vat_main_t *vam = &vat_main;
6062 vat_json_node_t *node = NULL;
6064 if (VAT_JSON_ARRAY != vam->json_tree.type)
6066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6067 vat_json_init_array (&vam->json_tree);
6069 node = vat_json_array_add (&vam->json_tree);
6071 vat_json_init_object (node);
6072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6073 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6074 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6075 vat_json_object_add_uint (node, "mode", mp->mode);
6079 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6081 unformat_input_t *i = vam->input;
6082 vl_api_sw_interface_rx_placement_dump_t *mp;
6083 vl_api_control_ping_t *mp_ping;
6086 u8 sw_if_index_set = 0;
6088 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6090 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6092 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6099 "\n%-11s %-11s %-6s %-5s %-4s",
6100 "sw_if_index", "main/worker", "thread", "queue", "mode");
6102 /* Dump Interface rx placement */
6103 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6105 if (sw_if_index_set)
6106 mp->sw_if_index = htonl (sw_if_index);
6108 mp->sw_if_index = ~0;
6112 /* Use a control ping for synchronization */
6113 MPING (CONTROL_PING, mp_ping);
6121 api_sw_interface_clear_stats (vat_main_t * vam)
6123 unformat_input_t *i = vam->input;
6124 vl_api_sw_interface_clear_stats_t *mp;
6126 u8 sw_if_index_set = 0;
6129 /* Parse args required to build the message */
6130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6133 sw_if_index_set = 1;
6134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6135 sw_if_index_set = 1;
6140 /* Construct the API message */
6141 M (SW_INTERFACE_CLEAR_STATS, mp);
6143 if (sw_if_index_set == 1)
6144 mp->sw_if_index = ntohl (sw_if_index);
6146 mp->sw_if_index = ~0;
6151 /* Wait for a reply, return the good/bad news... */
6157 api_sw_interface_add_del_address (vat_main_t * vam)
6159 unformat_input_t *i = vam->input;
6160 vl_api_sw_interface_add_del_address_t *mp;
6162 u8 sw_if_index_set = 0;
6163 u8 is_add = 1, del_all = 0;
6164 u32 address_length = 0;
6165 u8 v4_address_set = 0;
6166 u8 v6_address_set = 0;
6167 ip4_address_t v4address;
6168 ip6_address_t v6address;
6171 /* Parse args required to build the message */
6172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6174 if (unformat (i, "del-all"))
6176 else if (unformat (i, "del"))
6179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6180 sw_if_index_set = 1;
6181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6182 sw_if_index_set = 1;
6183 else if (unformat (i, "%U/%d",
6184 unformat_ip4_address, &v4address, &address_length))
6186 else if (unformat (i, "%U/%d",
6187 unformat_ip6_address, &v6address, &address_length))
6193 if (sw_if_index_set == 0)
6195 errmsg ("missing interface name or sw_if_index");
6198 if (v4_address_set && v6_address_set)
6200 errmsg ("both v4 and v6 addresses set");
6203 if (!v4_address_set && !v6_address_set && !del_all)
6205 errmsg ("no addresses set");
6209 /* Construct the API message */
6210 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6212 mp->sw_if_index = ntohl (sw_if_index);
6213 mp->is_add = is_add;
6214 mp->del_all = del_all;
6217 mp->prefix.address.af = ADDRESS_IP6;
6218 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6222 mp->prefix.address.af = ADDRESS_IP4;
6223 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6225 mp->prefix.len = address_length;
6230 /* Wait for a reply, return good/bad news */
6236 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6238 unformat_input_t *i = vam->input;
6239 vl_api_sw_interface_set_mpls_enable_t *mp;
6241 u8 sw_if_index_set = 0;
6245 /* Parse args required to build the message */
6246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6248 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6249 sw_if_index_set = 1;
6250 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6251 sw_if_index_set = 1;
6252 else if (unformat (i, "disable"))
6254 else if (unformat (i, "dis"))
6260 if (sw_if_index_set == 0)
6262 errmsg ("missing interface name or sw_if_index");
6266 /* Construct the API message */
6267 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6269 mp->sw_if_index = ntohl (sw_if_index);
6270 mp->enable = enable;
6275 /* Wait for a reply... */
6281 api_sw_interface_set_table (vat_main_t * vam)
6283 unformat_input_t *i = vam->input;
6284 vl_api_sw_interface_set_table_t *mp;
6285 u32 sw_if_index, vrf_id = 0;
6286 u8 sw_if_index_set = 0;
6290 /* Parse args required to build the message */
6291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6293 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6294 sw_if_index_set = 1;
6295 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6296 sw_if_index_set = 1;
6297 else if (unformat (i, "vrf %d", &vrf_id))
6299 else if (unformat (i, "ipv6"))
6305 if (sw_if_index_set == 0)
6307 errmsg ("missing interface name or sw_if_index");
6311 /* Construct the API message */
6312 M (SW_INTERFACE_SET_TABLE, mp);
6314 mp->sw_if_index = ntohl (sw_if_index);
6315 mp->is_ipv6 = is_ipv6;
6316 mp->vrf_id = ntohl (vrf_id);
6321 /* Wait for a reply... */
6326 static void vl_api_sw_interface_get_table_reply_t_handler
6327 (vl_api_sw_interface_get_table_reply_t * mp)
6329 vat_main_t *vam = &vat_main;
6331 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6333 vam->retval = ntohl (mp->retval);
6334 vam->result_ready = 1;
6338 static void vl_api_sw_interface_get_table_reply_t_handler_json
6339 (vl_api_sw_interface_get_table_reply_t * mp)
6341 vat_main_t *vam = &vat_main;
6342 vat_json_node_t node;
6344 vat_json_init_object (&node);
6345 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6346 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6348 vat_json_print (vam->ofp, &node);
6349 vat_json_free (&node);
6351 vam->retval = ntohl (mp->retval);
6352 vam->result_ready = 1;
6356 api_sw_interface_get_table (vat_main_t * vam)
6358 unformat_input_t *i = vam->input;
6359 vl_api_sw_interface_get_table_t *mp;
6361 u8 sw_if_index_set = 0;
6365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6368 sw_if_index_set = 1;
6369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6370 sw_if_index_set = 1;
6371 else if (unformat (i, "ipv6"))
6377 if (sw_if_index_set == 0)
6379 errmsg ("missing interface name or sw_if_index");
6383 M (SW_INTERFACE_GET_TABLE, mp);
6384 mp->sw_if_index = htonl (sw_if_index);
6385 mp->is_ipv6 = is_ipv6;
6393 api_sw_interface_set_vpath (vat_main_t * vam)
6395 unformat_input_t *i = vam->input;
6396 vl_api_sw_interface_set_vpath_t *mp;
6397 u32 sw_if_index = 0;
6398 u8 sw_if_index_set = 0;
6402 /* Parse args required to build the message */
6403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6405 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6406 sw_if_index_set = 1;
6407 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6408 sw_if_index_set = 1;
6409 else if (unformat (i, "enable"))
6411 else if (unformat (i, "disable"))
6417 if (sw_if_index_set == 0)
6419 errmsg ("missing interface name or sw_if_index");
6423 /* Construct the API message */
6424 M (SW_INTERFACE_SET_VPATH, mp);
6426 mp->sw_if_index = ntohl (sw_if_index);
6427 mp->enable = is_enable;
6432 /* Wait for a reply... */
6438 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6440 unformat_input_t *i = vam->input;
6441 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6442 u32 sw_if_index = 0;
6443 u8 sw_if_index_set = 0;
6448 /* Parse args required to build the message */
6449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6451 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6452 sw_if_index_set = 1;
6453 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6454 sw_if_index_set = 1;
6455 else if (unformat (i, "enable"))
6457 else if (unformat (i, "disable"))
6459 else if (unformat (i, "ip4"))
6461 else if (unformat (i, "ip6"))
6467 if (sw_if_index_set == 0)
6469 errmsg ("missing interface name or sw_if_index");
6473 /* Construct the API message */
6474 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6476 mp->sw_if_index = ntohl (sw_if_index);
6477 mp->enable = is_enable;
6478 mp->is_ipv6 = is_ipv6;
6483 /* Wait for a reply... */
6489 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6491 unformat_input_t *i = vam->input;
6492 vl_api_sw_interface_set_geneve_bypass_t *mp;
6493 u32 sw_if_index = 0;
6494 u8 sw_if_index_set = 0;
6499 /* Parse args required to build the message */
6500 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6502 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6503 sw_if_index_set = 1;
6504 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6505 sw_if_index_set = 1;
6506 else if (unformat (i, "enable"))
6508 else if (unformat (i, "disable"))
6510 else if (unformat (i, "ip4"))
6512 else if (unformat (i, "ip6"))
6518 if (sw_if_index_set == 0)
6520 errmsg ("missing interface name or sw_if_index");
6524 /* Construct the API message */
6525 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6527 mp->sw_if_index = ntohl (sw_if_index);
6528 mp->enable = is_enable;
6529 mp->is_ipv6 = is_ipv6;
6534 /* Wait for a reply... */
6540 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6542 unformat_input_t *i = vam->input;
6543 vl_api_sw_interface_set_l2_xconnect_t *mp;
6545 u8 rx_sw_if_index_set = 0;
6547 u8 tx_sw_if_index_set = 0;
6551 /* Parse args required to build the message */
6552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6554 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6555 rx_sw_if_index_set = 1;
6556 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6557 tx_sw_if_index_set = 1;
6558 else if (unformat (i, "rx"))
6560 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6562 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6564 rx_sw_if_index_set = 1;
6569 else if (unformat (i, "tx"))
6571 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6573 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6575 tx_sw_if_index_set = 1;
6580 else if (unformat (i, "enable"))
6582 else if (unformat (i, "disable"))
6588 if (rx_sw_if_index_set == 0)
6590 errmsg ("missing rx interface name or rx_sw_if_index");
6594 if (enable && (tx_sw_if_index_set == 0))
6596 errmsg ("missing tx interface name or tx_sw_if_index");
6600 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6602 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6603 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6604 mp->enable = enable;
6612 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6614 unformat_input_t *i = vam->input;
6615 vl_api_sw_interface_set_l2_bridge_t *mp;
6616 vl_api_l2_port_type_t port_type;
6618 u8 rx_sw_if_index_set = 0;
6625 port_type = L2_API_PORT_TYPE_NORMAL;
6627 /* Parse args required to build the message */
6628 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6630 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6631 rx_sw_if_index_set = 1;
6632 else if (unformat (i, "bd_id %d", &bd_id))
6636 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6637 rx_sw_if_index_set = 1;
6638 else if (unformat (i, "shg %d", &shg))
6640 else if (unformat (i, "bvi"))
6641 port_type = L2_API_PORT_TYPE_BVI;
6642 else if (unformat (i, "uu-fwd"))
6643 port_type = L2_API_PORT_TYPE_UU_FWD;
6644 else if (unformat (i, "enable"))
6646 else if (unformat (i, "disable"))
6652 if (rx_sw_if_index_set == 0)
6654 errmsg ("missing rx interface name or sw_if_index");
6658 if (enable && (bd_id_set == 0))
6660 errmsg ("missing bridge domain");
6664 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6666 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6667 mp->bd_id = ntohl (bd_id);
6669 mp->port_type = ntohl (port_type);
6670 mp->enable = enable;
6678 api_bridge_domain_dump (vat_main_t * vam)
6680 unformat_input_t *i = vam->input;
6681 vl_api_bridge_domain_dump_t *mp;
6682 vl_api_control_ping_t *mp_ping;
6686 /* Parse args required to build the message */
6687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6689 if (unformat (i, "bd_id %d", &bd_id))
6695 M (BRIDGE_DOMAIN_DUMP, mp);
6696 mp->bd_id = ntohl (bd_id);
6699 /* Use a control ping for synchronization */
6700 MPING (CONTROL_PING, mp_ping);
6708 api_bridge_domain_add_del (vat_main_t * vam)
6710 unformat_input_t *i = vam->input;
6711 vl_api_bridge_domain_add_del_t *mp;
6714 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6719 /* Parse args required to build the message */
6720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6722 if (unformat (i, "bd_id %d", &bd_id))
6724 else if (unformat (i, "flood %d", &flood))
6726 else if (unformat (i, "uu-flood %d", &uu_flood))
6728 else if (unformat (i, "forward %d", &forward))
6730 else if (unformat (i, "learn %d", &learn))
6732 else if (unformat (i, "arp-term %d", &arp_term))
6734 else if (unformat (i, "mac-age %d", &mac_age))
6736 else if (unformat (i, "bd-tag %s", &bd_tag))
6738 else if (unformat (i, "del"))
6741 flood = uu_flood = forward = learn = 0;
6749 errmsg ("missing bridge domain");
6756 errmsg ("mac age must be less than 256 ");
6761 if ((bd_tag) && (vec_len (bd_tag) > 63))
6763 errmsg ("bd-tag cannot be longer than 63");
6768 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6770 mp->bd_id = ntohl (bd_id);
6772 mp->uu_flood = uu_flood;
6773 mp->forward = forward;
6775 mp->arp_term = arp_term;
6776 mp->is_add = is_add;
6777 mp->mac_age = (u8) mac_age;
6780 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6781 mp->bd_tag[vec_len (bd_tag)] = 0;
6792 api_l2fib_flush_bd (vat_main_t * vam)
6794 unformat_input_t *i = vam->input;
6795 vl_api_l2fib_flush_bd_t *mp;
6799 /* Parse args required to build the message */
6800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6802 if (unformat (i, "bd_id %d", &bd_id));
6809 errmsg ("missing bridge domain");
6813 M (L2FIB_FLUSH_BD, mp);
6815 mp->bd_id = htonl (bd_id);
6823 api_l2fib_flush_int (vat_main_t * vam)
6825 unformat_input_t *i = vam->input;
6826 vl_api_l2fib_flush_int_t *mp;
6827 u32 sw_if_index = ~0;
6830 /* Parse args required to build the message */
6831 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6833 if (unformat (i, "sw_if_index %d", &sw_if_index));
6835 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6840 if (sw_if_index == ~0)
6842 errmsg ("missing interface name or sw_if_index");
6846 M (L2FIB_FLUSH_INT, mp);
6848 mp->sw_if_index = ntohl (sw_if_index);
6856 api_l2fib_add_del (vat_main_t * vam)
6858 unformat_input_t *i = vam->input;
6859 vl_api_l2fib_add_del_t *mp;
6865 u32 sw_if_index = 0;
6866 u8 sw_if_index_set = 0;
6875 /* Parse args required to build the message */
6876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6878 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6880 else if (unformat (i, "bd_id %d", &bd_id))
6882 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6883 sw_if_index_set = 1;
6884 else if (unformat (i, "sw_if"))
6886 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6889 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6890 sw_if_index_set = 1;
6895 else if (unformat (i, "static"))
6897 else if (unformat (i, "filter"))
6902 else if (unformat (i, "bvi"))
6907 else if (unformat (i, "del"))
6909 else if (unformat (i, "count %d", &count))
6917 errmsg ("missing mac address");
6923 errmsg ("missing bridge domain");
6927 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6929 errmsg ("missing interface name or sw_if_index");
6935 /* Turn on async mode */
6936 vam->async_mode = 1;
6937 vam->async_errors = 0;
6938 before = vat_time_now (vam);
6941 for (j = 0; j < count; j++)
6943 M (L2FIB_ADD_DEL, mp);
6945 clib_memcpy (mp->mac, mac, 6);
6946 mp->bd_id = ntohl (bd_id);
6947 mp->is_add = is_add;
6948 mp->sw_if_index = ntohl (sw_if_index);
6952 mp->static_mac = static_mac;
6953 mp->filter_mac = filter_mac;
6954 mp->bvi_mac = bvi_mac;
6956 increment_mac_address (mac);
6963 vl_api_control_ping_t *mp_ping;
6966 /* Shut off async mode */
6967 vam->async_mode = 0;
6969 MPING (CONTROL_PING, mp_ping);
6972 timeout = vat_time_now (vam) + 1.0;
6973 while (vat_time_now (vam) < timeout)
6974 if (vam->result_ready == 1)
6979 if (vam->retval == -99)
6982 if (vam->async_errors > 0)
6984 errmsg ("%d asynchronous errors", vam->async_errors);
6987 vam->async_errors = 0;
6988 after = vat_time_now (vam);
6990 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6991 count, after - before, count / (after - before));
6997 /* Wait for a reply... */
7001 /* Return the good/bad news */
7002 return (vam->retval);
7006 api_bridge_domain_set_mac_age (vat_main_t * vam)
7008 unformat_input_t *i = vam->input;
7009 vl_api_bridge_domain_set_mac_age_t *mp;
7014 /* Parse args required to build the message */
7015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7017 if (unformat (i, "bd_id %d", &bd_id));
7018 else if (unformat (i, "mac-age %d", &mac_age));
7025 errmsg ("missing bridge domain");
7031 errmsg ("mac age must be less than 256 ");
7035 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7037 mp->bd_id = htonl (bd_id);
7038 mp->mac_age = (u8) mac_age;
7046 api_l2_flags (vat_main_t * vam)
7048 unformat_input_t *i = vam->input;
7049 vl_api_l2_flags_t *mp;
7052 u8 sw_if_index_set = 0;
7056 /* Parse args required to build the message */
7057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7059 if (unformat (i, "sw_if_index %d", &sw_if_index))
7060 sw_if_index_set = 1;
7061 else if (unformat (i, "sw_if"))
7063 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7066 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7067 sw_if_index_set = 1;
7072 else if (unformat (i, "learn"))
7074 else if (unformat (i, "forward"))
7076 else if (unformat (i, "flood"))
7078 else if (unformat (i, "uu-flood"))
7079 flags |= L2_UU_FLOOD;
7080 else if (unformat (i, "arp-term"))
7081 flags |= L2_ARP_TERM;
7082 else if (unformat (i, "off"))
7084 else if (unformat (i, "disable"))
7090 if (sw_if_index_set == 0)
7092 errmsg ("missing interface name or sw_if_index");
7098 mp->sw_if_index = ntohl (sw_if_index);
7099 mp->feature_bitmap = ntohl (flags);
7100 mp->is_set = is_set;
7108 api_bridge_flags (vat_main_t * vam)
7110 unformat_input_t *i = vam->input;
7111 vl_api_bridge_flags_t *mp;
7115 bd_flags_t flags = 0;
7118 /* Parse args required to build the message */
7119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7121 if (unformat (i, "bd_id %d", &bd_id))
7123 else if (unformat (i, "learn"))
7124 flags |= BRIDGE_API_FLAG_LEARN;
7125 else if (unformat (i, "forward"))
7126 flags |= BRIDGE_API_FLAG_FWD;
7127 else if (unformat (i, "flood"))
7128 flags |= BRIDGE_API_FLAG_FLOOD;
7129 else if (unformat (i, "uu-flood"))
7130 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7131 else if (unformat (i, "arp-term"))
7132 flags |= BRIDGE_API_FLAG_ARP_TERM;
7133 else if (unformat (i, "off"))
7135 else if (unformat (i, "disable"))
7143 errmsg ("missing bridge domain");
7147 M (BRIDGE_FLAGS, mp);
7149 mp->bd_id = ntohl (bd_id);
7150 mp->flags = ntohl (flags);
7151 mp->is_set = is_set;
7159 api_bd_ip_mac_add_del (vat_main_t * vam)
7161 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7162 vl_api_mac_address_t mac = { 0 };
7163 unformat_input_t *i = vam->input;
7164 vl_api_bd_ip_mac_add_del_t *mp;
7173 /* Parse args required to build the message */
7174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7176 if (unformat (i, "bd_id %d", &bd_id))
7180 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7184 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7188 else if (unformat (i, "del"))
7196 errmsg ("missing bridge domain");
7199 else if (ip_set == 0)
7201 errmsg ("missing IP address");
7204 else if (mac_set == 0)
7206 errmsg ("missing MAC address");
7210 M (BD_IP_MAC_ADD_DEL, mp);
7212 mp->entry.bd_id = ntohl (bd_id);
7213 mp->is_add = is_add;
7215 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7216 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7224 api_bd_ip_mac_flush (vat_main_t * vam)
7226 unformat_input_t *i = vam->input;
7227 vl_api_bd_ip_mac_flush_t *mp;
7232 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7234 if (unformat (i, "bd_id %d", &bd_id))
7244 errmsg ("missing bridge domain");
7248 M (BD_IP_MAC_FLUSH, mp);
7250 mp->bd_id = ntohl (bd_id);
7257 static void vl_api_bd_ip_mac_details_t_handler
7258 (vl_api_bd_ip_mac_details_t * mp)
7260 vat_main_t *vam = &vat_main;
7264 ntohl (mp->entry.bd_id),
7265 format_vl_api_mac_address, mp->entry.mac,
7266 format_vl_api_address, &mp->entry.ip);
7269 static void vl_api_bd_ip_mac_details_t_handler_json
7270 (vl_api_bd_ip_mac_details_t * mp)
7272 vat_main_t *vam = &vat_main;
7273 vat_json_node_t *node = NULL;
7275 if (VAT_JSON_ARRAY != vam->json_tree.type)
7277 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7278 vat_json_init_array (&vam->json_tree);
7280 node = vat_json_array_add (&vam->json_tree);
7282 vat_json_init_object (node);
7283 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7284 vat_json_object_add_string_copy (node, "mac_address",
7285 format (0, "%U", format_vl_api_mac_address,
7289 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7290 vat_json_object_add_string_copy (node, "ip_address", ip);
7295 api_bd_ip_mac_dump (vat_main_t * vam)
7297 unformat_input_t *i = vam->input;
7298 vl_api_bd_ip_mac_dump_t *mp;
7299 vl_api_control_ping_t *mp_ping;
7304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7306 if (unformat (i, "bd_id %d", &bd_id))
7315 "\n%-5s %-7s %-20s %-30s",
7316 "bd_id", "is_ipv6", "mac_address", "ip_address");
7318 /* Dump Bridge Domain Ip to Mac entries */
7319 M (BD_IP_MAC_DUMP, mp);
7322 mp->bd_id = htonl (bd_id);
7328 /* Use a control ping for synchronization */
7329 MPING (CONTROL_PING, mp_ping);
7337 api_tap_create_v2 (vat_main_t * vam)
7339 unformat_input_t *i = vam->input;
7340 vl_api_tap_create_v2_t *mp;
7341 #define TAP_FLAG_GSO (1 << 0)
7345 u8 *host_if_name = 0;
7347 u8 host_mac_addr[6];
7348 u8 host_mac_addr_set = 0;
7349 u8 *host_bridge = 0;
7350 ip4_address_t host_ip4_addr;
7351 ip4_address_t host_ip4_gw;
7352 u8 host_ip4_gw_set = 0;
7353 u32 host_ip4_prefix_len = 0;
7354 ip6_address_t host_ip6_addr;
7355 ip6_address_t host_ip6_gw;
7356 u8 host_ip6_gw_set = 0;
7357 u32 host_ip6_prefix_len = 0;
7358 u8 host_mtu_set = 0;
7359 u32 host_mtu_size = 0;
7362 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7364 clib_memset (mac_address, 0, sizeof (mac_address));
7366 /* Parse args required to build the message */
7367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7369 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7373 else if (unformat (i, "id %u", &id))
7375 else if (unformat (i, "host-if-name %s", &host_if_name))
7377 else if (unformat (i, "host-ns %s", &host_ns))
7379 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7381 host_mac_addr_set = 1;
7382 else if (unformat (i, "host-bridge %s", &host_bridge))
7384 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7385 &host_ip4_addr, &host_ip4_prefix_len))
7387 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7388 &host_ip6_addr, &host_ip6_prefix_len))
7390 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7392 host_ip4_gw_set = 1;
7393 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7395 host_ip6_gw_set = 1;
7396 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7398 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7400 else if (unformat (i, "host-mtu-size %d", &host_mtu_size))
7402 else if (unformat (i, "no-gso"))
7403 tap_flags &= ~TAP_FLAG_GSO;
7404 else if (unformat (i, "gso"))
7405 tap_flags |= TAP_FLAG_GSO;
7410 if (vec_len (host_if_name) > 63)
7412 errmsg ("tap name too long. ");
7415 if (vec_len (host_ns) > 63)
7417 errmsg ("host name space too long. ");
7420 if (vec_len (host_bridge) > 63)
7422 errmsg ("host bridge name too long. ");
7425 if (host_ip4_prefix_len > 32)
7427 errmsg ("host ip4 prefix length not valid. ");
7430 if (host_ip6_prefix_len > 128)
7432 errmsg ("host ip6 prefix length not valid. ");
7435 if (!is_pow2 (rx_ring_sz))
7437 errmsg ("rx ring size must be power of 2. ");
7440 if (rx_ring_sz > 32768)
7442 errmsg ("rx ring size must be 32768 or lower. ");
7445 if (!is_pow2 (tx_ring_sz))
7447 errmsg ("tx ring size must be power of 2. ");
7450 if (tx_ring_sz > 32768)
7452 errmsg ("tx ring size must be 32768 or lower. ");
7455 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7457 errmsg ("host MTU size must be in between 64 and 65355. ");
7461 /* Construct the API message */
7462 M (TAP_CREATE_V2, mp);
7464 mp->use_random_mac = random_mac;
7466 mp->id = ntohl (id);
7467 mp->host_namespace_set = host_ns != 0;
7468 mp->host_bridge_set = host_bridge != 0;
7469 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7470 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7471 mp->rx_ring_sz = ntohs (rx_ring_sz);
7472 mp->tx_ring_sz = ntohs (tx_ring_sz);
7473 mp->host_mtu_set = host_mtu_set;
7474 mp->host_mtu_size = ntohl (host_mtu_size);
7475 mp->tap_flags = ntohl (tap_flags);
7477 if (random_mac == 0)
7478 clib_memcpy (mp->mac_address, mac_address, 6);
7479 if (host_mac_addr_set)
7480 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7482 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7484 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7486 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7487 if (host_ip4_prefix_len)
7488 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7489 if (host_ip6_prefix_len)
7490 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7491 if (host_ip4_gw_set)
7492 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7493 if (host_ip6_gw_set)
7494 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7497 vec_free (host_if_name);
7498 vec_free (host_bridge);
7503 /* Wait for a reply... */
7509 api_tap_delete_v2 (vat_main_t * vam)
7511 unformat_input_t *i = vam->input;
7512 vl_api_tap_delete_v2_t *mp;
7513 u32 sw_if_index = ~0;
7514 u8 sw_if_index_set = 0;
7517 /* Parse args required to build the message */
7518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7520 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7521 sw_if_index_set = 1;
7522 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7523 sw_if_index_set = 1;
7528 if (sw_if_index_set == 0)
7530 errmsg ("missing vpp interface name. ");
7534 /* Construct the API message */
7535 M (TAP_DELETE_V2, mp);
7537 mp->sw_if_index = ntohl (sw_if_index);
7542 /* Wait for a reply... */
7548 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7550 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7553 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7556 addr->domain = x[0];
7559 addr->function = x[3];
7565 api_virtio_pci_create (vat_main_t * vam)
7567 unformat_input_t *i = vam->input;
7568 vl_api_virtio_pci_create_t *mp;
7573 u64 features = (u64) ~ (0ULL);
7576 clib_memset (mac_address, 0, sizeof (mac_address));
7578 /* Parse args required to build the message */
7579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7581 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7585 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7587 else if (unformat (i, "features 0x%llx", &features))
7589 else if (unformat (i, "gso-enabled"))
7597 errmsg ("pci address must be non zero. ");
7601 /* Construct the API message */
7602 M (VIRTIO_PCI_CREATE, mp);
7604 mp->use_random_mac = random_mac;
7606 mp->pci_addr = htonl (pci_addr);
7607 mp->features = clib_host_to_net_u64 (features);
7608 mp->gso_enabled = gso_enabled;
7610 if (random_mac == 0)
7611 clib_memcpy (mp->mac_address, mac_address, 6);
7616 /* Wait for a reply... */
7622 api_virtio_pci_delete (vat_main_t * vam)
7624 unformat_input_t *i = vam->input;
7625 vl_api_virtio_pci_delete_t *mp;
7626 u32 sw_if_index = ~0;
7627 u8 sw_if_index_set = 0;
7630 /* Parse args required to build the message */
7631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7633 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7634 sw_if_index_set = 1;
7635 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7636 sw_if_index_set = 1;
7641 if (sw_if_index_set == 0)
7643 errmsg ("missing vpp interface name. ");
7647 /* Construct the API message */
7648 M (VIRTIO_PCI_DELETE, mp);
7650 mp->sw_if_index = htonl (sw_if_index);
7655 /* Wait for a reply... */
7661 api_bond_create (vat_main_t * vam)
7663 unformat_input_t *i = vam->input;
7664 vl_api_bond_create_t *mp;
7674 clib_memset (mac_address, 0, sizeof (mac_address));
7677 /* Parse args required to build the message */
7678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7680 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7682 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7683 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7685 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7688 else if (unformat (i, "numa-only"))
7690 else if (unformat (i, "id %u", &id))
7696 if (mode_is_set == 0)
7698 errmsg ("Missing bond mode. ");
7702 /* Construct the API message */
7703 M (BOND_CREATE, mp);
7705 mp->use_custom_mac = custom_mac;
7707 mp->mode = htonl (mode);
7708 mp->lb = htonl (lb);
7709 mp->id = htonl (id);
7710 mp->numa_only = numa_only;
7713 clib_memcpy (mp->mac_address, mac_address, 6);
7718 /* Wait for a reply... */
7724 api_bond_delete (vat_main_t * vam)
7726 unformat_input_t *i = vam->input;
7727 vl_api_bond_delete_t *mp;
7728 u32 sw_if_index = ~0;
7729 u8 sw_if_index_set = 0;
7732 /* Parse args required to build the message */
7733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7735 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7736 sw_if_index_set = 1;
7737 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7738 sw_if_index_set = 1;
7743 if (sw_if_index_set == 0)
7745 errmsg ("missing vpp interface name. ");
7749 /* Construct the API message */
7750 M (BOND_DELETE, mp);
7752 mp->sw_if_index = ntohl (sw_if_index);
7757 /* Wait for a reply... */
7763 api_bond_enslave (vat_main_t * vam)
7765 unformat_input_t *i = vam->input;
7766 vl_api_bond_enslave_t *mp;
7767 u32 bond_sw_if_index;
7771 u32 bond_sw_if_index_is_set = 0;
7773 u8 sw_if_index_is_set = 0;
7775 /* Parse args required to build the message */
7776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7778 if (unformat (i, "sw_if_index %d", &sw_if_index))
7779 sw_if_index_is_set = 1;
7780 else if (unformat (i, "bond %u", &bond_sw_if_index))
7781 bond_sw_if_index_is_set = 1;
7782 else if (unformat (i, "passive %d", &is_passive))
7784 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7790 if (bond_sw_if_index_is_set == 0)
7792 errmsg ("Missing bond sw_if_index. ");
7795 if (sw_if_index_is_set == 0)
7797 errmsg ("Missing slave sw_if_index. ");
7801 /* Construct the API message */
7802 M (BOND_ENSLAVE, mp);
7804 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7805 mp->sw_if_index = ntohl (sw_if_index);
7806 mp->is_long_timeout = is_long_timeout;
7807 mp->is_passive = is_passive;
7812 /* Wait for a reply... */
7818 api_bond_detach_slave (vat_main_t * vam)
7820 unformat_input_t *i = vam->input;
7821 vl_api_bond_detach_slave_t *mp;
7822 u32 sw_if_index = ~0;
7823 u8 sw_if_index_set = 0;
7826 /* Parse args required to build the message */
7827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7830 sw_if_index_set = 1;
7831 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7832 sw_if_index_set = 1;
7837 if (sw_if_index_set == 0)
7839 errmsg ("missing vpp interface name. ");
7843 /* Construct the API message */
7844 M (BOND_DETACH_SLAVE, mp);
7846 mp->sw_if_index = ntohl (sw_if_index);
7851 /* Wait for a reply... */
7857 api_ip_table_add_del (vat_main_t * vam)
7859 unformat_input_t *i = vam->input;
7860 vl_api_ip_table_add_del_t *mp;
7866 /* Parse args required to build the message */
7867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7869 if (unformat (i, "ipv6"))
7871 else if (unformat (i, "del"))
7873 else if (unformat (i, "add"))
7875 else if (unformat (i, "table %d", &table_id))
7879 clib_warning ("parse error '%U'", format_unformat_error, i);
7886 errmsg ("missing table-ID");
7890 /* Construct the API message */
7891 M (IP_TABLE_ADD_DEL, mp);
7893 mp->table.table_id = ntohl (table_id);
7894 mp->table.is_ip6 = is_ipv6;
7895 mp->is_add = is_add;
7900 /* Wait for a reply... */
7907 unformat_fib_path (unformat_input_t * input, va_list * args)
7909 vat_main_t *vam = va_arg (*args, vat_main_t *);
7910 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7911 u32 weight, preference;
7912 mpls_label_t out_label;
7914 clib_memset (path, 0, sizeof (*path));
7916 path->sw_if_index = ~0;
7920 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7922 if (unformat (input, "%U %U",
7923 unformat_vl_api_ip4_address,
7924 &path->nh.address.ip4,
7925 api_unformat_sw_if_index, vam, &path->sw_if_index))
7927 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7929 else if (unformat (input, "%U %U",
7930 unformat_vl_api_ip6_address,
7931 &path->nh.address.ip6,
7932 api_unformat_sw_if_index, vam, &path->sw_if_index))
7934 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7936 else if (unformat (input, "weight %u", &weight))
7938 path->weight = weight;
7940 else if (unformat (input, "preference %u", &preference))
7942 path->preference = preference;
7944 else if (unformat (input, "%U next-hop-table %d",
7945 unformat_vl_api_ip4_address,
7946 &path->nh.address.ip4, &path->table_id))
7948 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7950 else if (unformat (input, "%U next-hop-table %d",
7951 unformat_vl_api_ip6_address,
7952 &path->nh.address.ip6, &path->table_id))
7954 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7956 else if (unformat (input, "%U",
7957 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7960 * the recursive next-hops are by default in the default table
7963 path->sw_if_index = ~0;
7964 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7966 else if (unformat (input, "%U",
7967 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7970 * the recursive next-hops are by default in the default table
7973 path->sw_if_index = ~0;
7974 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7976 else if (unformat (input, "resolve-via-host"))
7978 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7980 else if (unformat (input, "resolve-via-attached"))
7982 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7984 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7986 path->type = FIB_API_PATH_TYPE_LOCAL;
7987 path->sw_if_index = ~0;
7988 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7990 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7992 path->type = FIB_API_PATH_TYPE_LOCAL;
7993 path->sw_if_index = ~0;
7994 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7996 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
7998 else if (unformat (input, "via-label %d", &path->nh.via_label))
8000 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8001 path->sw_if_index = ~0;
8003 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8005 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8006 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8008 else if (unformat (input, "local"))
8010 path->type = FIB_API_PATH_TYPE_LOCAL;
8012 else if (unformat (input, "out-labels"))
8014 while (unformat (input, "%d", &out_label))
8016 path->label_stack[path->n_labels].label = out_label;
8017 path->label_stack[path->n_labels].is_uniform = 0;
8018 path->label_stack[path->n_labels].ttl = 64;
8022 else if (unformat (input, "via"))
8024 /* new path, back up and return */
8025 unformat_put_input (input);
8026 unformat_put_input (input);
8027 unformat_put_input (input);
8028 unformat_put_input (input);
8037 path->proto = ntohl (path->proto);
8038 path->type = ntohl (path->type);
8039 path->flags = ntohl (path->flags);
8040 path->table_id = ntohl (path->table_id);
8041 path->sw_if_index = ntohl (path->sw_if_index);
8047 api_ip_route_add_del (vat_main_t * vam)
8049 unformat_input_t *i = vam->input;
8050 vl_api_ip_route_add_del_t *mp;
8053 u8 is_multipath = 0;
8056 vl_api_prefix_t pfx = { };
8057 vl_api_fib_path_t paths[8];
8061 u32 random_add_del = 0;
8062 u32 *random_vector = 0;
8063 u32 random_seed = 0xdeaddabe;
8065 /* Parse args required to build the message */
8066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8068 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8070 else if (unformat (i, "del"))
8072 else if (unformat (i, "add"))
8074 else if (unformat (i, "vrf %d", &vrf_id))
8076 else if (unformat (i, "count %d", &count))
8078 else if (unformat (i, "random"))
8080 else if (unformat (i, "multipath"))
8082 else if (unformat (i, "seed %d", &random_seed))
8086 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8089 if (8 == path_count)
8091 errmsg ("max 8 paths");
8097 clib_warning ("parse error '%U'", format_unformat_error, i);
8104 errmsg ("specify a path; via ...");
8107 if (prefix_set == 0)
8109 errmsg ("missing prefix");
8113 /* Generate a pile of unique, random routes */
8116 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8117 u32 this_random_address;
8120 random_hash = hash_create (count, sizeof (uword));
8122 hash_set (random_hash, i->as_u32, 1);
8123 for (j = 0; j <= count; j++)
8127 this_random_address = random_u32 (&random_seed);
8128 this_random_address =
8129 clib_host_to_net_u32 (this_random_address);
8131 while (hash_get (random_hash, this_random_address));
8132 vec_add1 (random_vector, this_random_address);
8133 hash_set (random_hash, this_random_address, 1);
8135 hash_free (random_hash);
8136 set_ip4_address (&pfx.address, random_vector[0]);
8141 /* Turn on async mode */
8142 vam->async_mode = 1;
8143 vam->async_errors = 0;
8144 before = vat_time_now (vam);
8147 for (j = 0; j < count; j++)
8149 /* Construct the API message */
8150 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8152 mp->is_add = is_add;
8153 mp->is_multipath = is_multipath;
8155 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8156 mp->route.table_id = ntohl (vrf_id);
8157 mp->route.n_paths = path_count;
8159 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8162 set_ip4_address (&pfx.address, random_vector[j + 1]);
8164 increment_address (&pfx.address);
8167 /* If we receive SIGTERM, stop now... */
8172 /* When testing multiple add/del ops, use a control-ping to sync */
8175 vl_api_control_ping_t *mp_ping;
8179 /* Shut off async mode */
8180 vam->async_mode = 0;
8182 MPING (CONTROL_PING, mp_ping);
8185 timeout = vat_time_now (vam) + 1.0;
8186 while (vat_time_now (vam) < timeout)
8187 if (vam->result_ready == 1)
8192 if (vam->retval == -99)
8195 if (vam->async_errors > 0)
8197 errmsg ("%d asynchronous errors", vam->async_errors);
8200 vam->async_errors = 0;
8201 after = vat_time_now (vam);
8203 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8207 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8208 count, after - before, count / (after - before));
8214 /* Wait for a reply... */
8219 /* Return the good/bad news */
8220 return (vam->retval);
8224 api_ip_mroute_add_del (vat_main_t * vam)
8226 unformat_input_t *i = vam->input;
8227 u8 path_set = 0, prefix_set = 0, is_add = 1;
8228 vl_api_ip_mroute_add_del_t *mp;
8229 mfib_entry_flags_t eflags = 0;
8230 vl_api_mfib_path_t path;
8231 vl_api_mprefix_t pfx = { };
8235 /* Parse args required to build the message */
8236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8238 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8241 pfx.grp_address_length = htons (pfx.grp_address_length);
8243 else if (unformat (i, "del"))
8245 else if (unformat (i, "add"))
8247 else if (unformat (i, "vrf %d", &vrf_id))
8249 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8250 path.itf_flags = htonl (path.itf_flags);
8251 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8253 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8257 clib_warning ("parse error '%U'", format_unformat_error, i);
8262 if (prefix_set == 0)
8264 errmsg ("missing addresses\n");
8269 errmsg ("missing path\n");
8273 /* Construct the API message */
8274 M (IP_MROUTE_ADD_DEL, mp);
8276 mp->is_add = is_add;
8277 mp->is_multipath = 1;
8279 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8280 mp->route.table_id = htonl (vrf_id);
8281 mp->route.n_paths = 1;
8282 mp->route.entry_flags = htonl (eflags);
8284 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8288 /* Wait for a reply... */
8294 api_mpls_table_add_del (vat_main_t * vam)
8296 unformat_input_t *i = vam->input;
8297 vl_api_mpls_table_add_del_t *mp;
8302 /* Parse args required to build the message */
8303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8305 if (unformat (i, "table %d", &table_id))
8307 else if (unformat (i, "del"))
8309 else if (unformat (i, "add"))
8313 clib_warning ("parse error '%U'", format_unformat_error, i);
8320 errmsg ("missing table-ID");
8324 /* Construct the API message */
8325 M (MPLS_TABLE_ADD_DEL, mp);
8327 mp->mt_table.mt_table_id = ntohl (table_id);
8328 mp->mt_is_add = is_add;
8333 /* Wait for a reply... */
8340 api_mpls_route_add_del (vat_main_t * vam)
8342 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8343 mpls_label_t local_label = MPLS_LABEL_INVALID;
8344 unformat_input_t *i = vam->input;
8345 vl_api_mpls_route_add_del_t *mp;
8346 vl_api_fib_path_t paths[8];
8350 /* Parse args required to build the message */
8351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8353 if (unformat (i, "%d", &local_label))
8355 else if (unformat (i, "eos"))
8357 else if (unformat (i, "non-eos"))
8359 else if (unformat (i, "del"))
8361 else if (unformat (i, "add"))
8363 else if (unformat (i, "multipath"))
8365 else if (unformat (i, "count %d", &count))
8369 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8372 if (8 == path_count)
8374 errmsg ("max 8 paths");
8380 clib_warning ("parse error '%U'", format_unformat_error, i);
8387 errmsg ("specify a path; via ...");
8391 if (MPLS_LABEL_INVALID == local_label)
8393 errmsg ("missing label");
8399 /* Turn on async mode */
8400 vam->async_mode = 1;
8401 vam->async_errors = 0;
8402 before = vat_time_now (vam);
8405 for (j = 0; j < count; j++)
8407 /* Construct the API message */
8408 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8410 mp->mr_is_add = is_add;
8411 mp->mr_is_multipath = is_multipath;
8413 mp->mr_route.mr_label = local_label;
8414 mp->mr_route.mr_eos = is_eos;
8415 mp->mr_route.mr_table_id = 0;
8416 mp->mr_route.mr_n_paths = path_count;
8418 clib_memcpy (&mp->mr_route.mr_paths, paths,
8419 sizeof (paths[0]) * path_count);
8425 /* If we receive SIGTERM, stop now... */
8430 /* When testing multiple add/del ops, use a control-ping to sync */
8433 vl_api_control_ping_t *mp_ping;
8437 /* Shut off async mode */
8438 vam->async_mode = 0;
8440 MPING (CONTROL_PING, mp_ping);
8443 timeout = vat_time_now (vam) + 1.0;
8444 while (vat_time_now (vam) < timeout)
8445 if (vam->result_ready == 1)
8450 if (vam->retval == -99)
8453 if (vam->async_errors > 0)
8455 errmsg ("%d asynchronous errors", vam->async_errors);
8458 vam->async_errors = 0;
8459 after = vat_time_now (vam);
8461 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8465 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8466 count, after - before, count / (after - before));
8472 /* Wait for a reply... */
8477 /* Return the good/bad news */
8478 return (vam->retval);
8483 api_mpls_ip_bind_unbind (vat_main_t * vam)
8485 unformat_input_t *i = vam->input;
8486 vl_api_mpls_ip_bind_unbind_t *mp;
8487 u32 ip_table_id = 0;
8489 vl_api_prefix_t pfx;
8491 mpls_label_t local_label = MPLS_LABEL_INVALID;
8494 /* Parse args required to build the message */
8495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8497 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8499 else if (unformat (i, "%d", &local_label))
8501 else if (unformat (i, "table-id %d", &ip_table_id))
8503 else if (unformat (i, "unbind"))
8505 else if (unformat (i, "bind"))
8509 clib_warning ("parse error '%U'", format_unformat_error, i);
8516 errmsg ("IP prefix not set");
8520 if (MPLS_LABEL_INVALID == local_label)
8522 errmsg ("missing label");
8526 /* Construct the API message */
8527 M (MPLS_IP_BIND_UNBIND, mp);
8529 mp->mb_is_bind = is_bind;
8530 mp->mb_ip_table_id = ntohl (ip_table_id);
8531 mp->mb_mpls_table_id = 0;
8532 mp->mb_label = ntohl (local_label);
8533 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8538 /* Wait for a reply... */
8545 api_sr_mpls_policy_add (vat_main_t * vam)
8547 unformat_input_t *i = vam->input;
8548 vl_api_sr_mpls_policy_add_t *mp;
8554 u32 *segments = NULL;
8557 /* Parse args required to build the message */
8558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8560 if (unformat (i, "bsid %d", &bsid))
8562 else if (unformat (i, "weight %d", &weight))
8564 else if (unformat (i, "spray"))
8566 else if (unformat (i, "next %d", &sid))
8569 vec_add1 (segments, htonl (sid));
8573 clib_warning ("parse error '%U'", format_unformat_error, i);
8580 errmsg ("bsid not set");
8584 if (n_segments == 0)
8586 errmsg ("no sid in segment stack");
8590 /* Construct the API message */
8591 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8593 mp->bsid = htonl (bsid);
8594 mp->weight = htonl (weight);
8596 mp->n_segments = n_segments;
8597 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8598 vec_free (segments);
8603 /* Wait for a reply... */
8609 api_sr_mpls_policy_del (vat_main_t * vam)
8611 unformat_input_t *i = vam->input;
8612 vl_api_sr_mpls_policy_del_t *mp;
8616 /* Parse args required to build the message */
8617 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8619 if (unformat (i, "bsid %d", &bsid))
8623 clib_warning ("parse error '%U'", format_unformat_error, i);
8630 errmsg ("bsid not set");
8634 /* Construct the API message */
8635 M (SR_MPLS_POLICY_DEL, mp);
8637 mp->bsid = htonl (bsid);
8642 /* Wait for a reply... */
8648 api_bier_table_add_del (vat_main_t * vam)
8650 unformat_input_t *i = vam->input;
8651 vl_api_bier_table_add_del_t *mp;
8653 u32 set = 0, sub_domain = 0, hdr_len = 3;
8654 mpls_label_t local_label = MPLS_LABEL_INVALID;
8657 /* Parse args required to build the message */
8658 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (i, "sub-domain %d", &sub_domain))
8662 else if (unformat (i, "set %d", &set))
8664 else if (unformat (i, "label %d", &local_label))
8666 else if (unformat (i, "hdr-len %d", &hdr_len))
8668 else if (unformat (i, "add"))
8670 else if (unformat (i, "del"))
8674 clib_warning ("parse error '%U'", format_unformat_error, i);
8679 if (MPLS_LABEL_INVALID == local_label)
8681 errmsg ("missing label\n");
8685 /* Construct the API message */
8686 M (BIER_TABLE_ADD_DEL, mp);
8688 mp->bt_is_add = is_add;
8689 mp->bt_label = ntohl (local_label);
8690 mp->bt_tbl_id.bt_set = set;
8691 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8692 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8697 /* Wait for a reply... */
8704 api_bier_route_add_del (vat_main_t * vam)
8706 unformat_input_t *i = vam->input;
8707 vl_api_bier_route_add_del_t *mp;
8709 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8710 ip4_address_t v4_next_hop_address;
8711 ip6_address_t v6_next_hop_address;
8712 u8 next_hop_set = 0;
8713 u8 next_hop_proto_is_ip4 = 1;
8714 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8717 /* Parse args required to build the message */
8718 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8720 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8722 next_hop_proto_is_ip4 = 1;
8725 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8727 next_hop_proto_is_ip4 = 0;
8730 if (unformat (i, "sub-domain %d", &sub_domain))
8732 else if (unformat (i, "set %d", &set))
8734 else if (unformat (i, "hdr-len %d", &hdr_len))
8736 else if (unformat (i, "bp %d", &bp))
8738 else if (unformat (i, "add"))
8740 else if (unformat (i, "del"))
8742 else if (unformat (i, "out-label %d", &next_hop_out_label))
8746 clib_warning ("parse error '%U'", format_unformat_error, i);
8751 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8753 errmsg ("next hop / label set\n");
8758 errmsg ("bit=position not set\n");
8762 /* Construct the API message */
8763 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8765 mp->br_is_add = is_add;
8766 mp->br_route.br_tbl_id.bt_set = set;
8767 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8768 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8769 mp->br_route.br_bp = ntohs (bp);
8770 mp->br_route.br_n_paths = 1;
8771 mp->br_route.br_paths[0].n_labels = 1;
8772 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8773 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8774 FIB_API_PATH_NH_PROTO_IP4 :
8775 FIB_API_PATH_NH_PROTO_IP6);
8777 if (next_hop_proto_is_ip4)
8779 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8780 &v4_next_hop_address, sizeof (v4_next_hop_address));
8784 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8785 &v6_next_hop_address, sizeof (v6_next_hop_address));
8791 /* Wait for a reply... */
8798 api_proxy_arp_add_del (vat_main_t * vam)
8800 unformat_input_t *i = vam->input;
8801 vl_api_proxy_arp_add_del_t *mp;
8804 vl_api_ip4_address_t lo, hi;
8808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8810 if (unformat (i, "vrf %d", &vrf_id))
8812 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
8813 unformat_vl_api_ip4_address, &hi))
8815 else if (unformat (i, "del"))
8819 clib_warning ("parse error '%U'", format_unformat_error, i);
8826 errmsg ("address range not set");
8830 M (PROXY_ARP_ADD_DEL, mp);
8832 mp->proxy.table_id = ntohl (vrf_id);
8833 mp->is_add = is_add;
8834 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
8835 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
8843 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8845 unformat_input_t *i = vam->input;
8846 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8849 u8 sw_if_index_set = 0;
8852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8855 sw_if_index_set = 1;
8856 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8857 sw_if_index_set = 1;
8858 else if (unformat (i, "enable"))
8860 else if (unformat (i, "disable"))
8864 clib_warning ("parse error '%U'", format_unformat_error, i);
8869 if (sw_if_index_set == 0)
8871 errmsg ("missing interface name or sw_if_index");
8875 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8877 mp->sw_if_index = ntohl (sw_if_index);
8878 mp->enable_disable = enable;
8886 api_mpls_tunnel_add_del (vat_main_t * vam)
8888 unformat_input_t *i = vam->input;
8889 vl_api_mpls_tunnel_add_del_t *mp;
8891 vl_api_fib_path_t paths[8];
8892 u32 sw_if_index = ~0;
8898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8900 if (unformat (i, "add"))
8904 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8906 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8908 else if (unformat (i, "l2-only"))
8912 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8915 if (8 == path_count)
8917 errmsg ("max 8 paths");
8923 clib_warning ("parse error '%U'", format_unformat_error, i);
8928 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8930 mp->mt_is_add = is_add;
8931 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8932 mp->mt_tunnel.mt_l2_only = l2_only;
8933 mp->mt_tunnel.mt_is_multicast = 0;
8934 mp->mt_tunnel.mt_n_paths = path_count;
8936 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8937 sizeof (paths[0]) * path_count);
8945 api_sw_interface_set_unnumbered (vat_main_t * vam)
8947 unformat_input_t *i = vam->input;
8948 vl_api_sw_interface_set_unnumbered_t *mp;
8950 u32 unnum_sw_index = ~0;
8952 u8 sw_if_index_set = 0;
8955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8957 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8958 sw_if_index_set = 1;
8959 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8960 sw_if_index_set = 1;
8961 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8963 else if (unformat (i, "del"))
8967 clib_warning ("parse error '%U'", format_unformat_error, i);
8972 if (sw_if_index_set == 0)
8974 errmsg ("missing interface name or sw_if_index");
8978 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8980 mp->sw_if_index = ntohl (sw_if_index);
8981 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8982 mp->is_add = is_add;
8990 api_ip_neighbor_add_del (vat_main_t * vam)
8992 vl_api_mac_address_t mac_address;
8993 unformat_input_t *i = vam->input;
8994 vl_api_ip_neighbor_add_del_t *mp;
8995 vl_api_address_t ip_address;
8997 u8 sw_if_index_set = 0;
9002 ip_neighbor_flags_t flags;
9004 flags = IP_NEIGHBOR_FLAG_NONE;
9005 clib_memset (&ip_address, 0, sizeof (ip_address));
9006 clib_memset (&mac_address, 0, sizeof (mac_address));
9008 /* Parse args required to build the message */
9009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9011 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9015 else if (unformat (i, "del"))
9018 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9019 sw_if_index_set = 1;
9020 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9021 sw_if_index_set = 1;
9022 else if (unformat (i, "static"))
9023 flags |= IP_NEIGHBOR_FLAG_STATIC;
9024 else if (unformat (i, "no-fib-entry"))
9025 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9026 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9030 clib_warning ("parse error '%U'", format_unformat_error, i);
9035 if (sw_if_index_set == 0)
9037 errmsg ("missing interface name or sw_if_index");
9042 errmsg ("no address set");
9046 /* Construct the API message */
9047 M (IP_NEIGHBOR_ADD_DEL, mp);
9049 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9050 mp->is_add = is_add;
9051 mp->neighbor.flags = htonl (flags);
9053 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9054 sizeof (mac_address));
9056 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9061 /* Wait for a reply, return good/bad news */
9067 api_create_vlan_subif (vat_main_t * vam)
9069 unformat_input_t *i = vam->input;
9070 vl_api_create_vlan_subif_t *mp;
9072 u8 sw_if_index_set = 0;
9077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9079 if (unformat (i, "sw_if_index %d", &sw_if_index))
9080 sw_if_index_set = 1;
9082 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9083 sw_if_index_set = 1;
9084 else if (unformat (i, "vlan %d", &vlan_id))
9088 clib_warning ("parse error '%U'", format_unformat_error, i);
9093 if (sw_if_index_set == 0)
9095 errmsg ("missing interface name or sw_if_index");
9099 if (vlan_id_set == 0)
9101 errmsg ("missing vlan_id");
9104 M (CREATE_VLAN_SUBIF, mp);
9106 mp->sw_if_index = ntohl (sw_if_index);
9107 mp->vlan_id = ntohl (vlan_id);
9114 #define foreach_create_subif_bit \
9121 _(outer_vlan_id_any) \
9122 _(inner_vlan_id_any)
9124 #define foreach_create_subif_flag \
9129 _(4, "exact_match") \
9130 _(5, "default_sub") \
9131 _(6, "outer_vlan_id_any") \
9132 _(7, "inner_vlan_id_any")
9135 api_create_subif (vat_main_t * vam)
9137 unformat_input_t *i = vam->input;
9138 vl_api_create_subif_t *mp;
9140 u8 sw_if_index_set = 0;
9143 u32 __attribute__ ((unused)) no_tags = 0;
9144 u32 __attribute__ ((unused)) one_tag = 0;
9145 u32 __attribute__ ((unused)) two_tags = 0;
9146 u32 __attribute__ ((unused)) dot1ad = 0;
9147 u32 __attribute__ ((unused)) exact_match = 0;
9148 u32 __attribute__ ((unused)) default_sub = 0;
9149 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9150 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9152 u16 outer_vlan_id = 0;
9153 u16 inner_vlan_id = 0;
9156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9158 if (unformat (i, "sw_if_index %d", &sw_if_index))
9159 sw_if_index_set = 1;
9161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9162 sw_if_index_set = 1;
9163 else if (unformat (i, "sub_id %d", &sub_id))
9165 else if (unformat (i, "outer_vlan_id %d", &tmp))
9166 outer_vlan_id = tmp;
9167 else if (unformat (i, "inner_vlan_id %d", &tmp))
9168 inner_vlan_id = tmp;
9170 #define _(a) else if (unformat (i, #a)) a = 1 ;
9171 foreach_create_subif_bit
9175 clib_warning ("parse error '%U'", format_unformat_error, i);
9180 if (sw_if_index_set == 0)
9182 errmsg ("missing interface name or sw_if_index");
9186 if (sub_id_set == 0)
9188 errmsg ("missing sub_id");
9191 M (CREATE_SUBIF, mp);
9193 mp->sw_if_index = ntohl (sw_if_index);
9194 mp->sub_id = ntohl (sub_id);
9196 #define _(a,b) mp->sub_if_flags |= (1 << a);
9197 foreach_create_subif_flag;
9200 mp->outer_vlan_id = ntohs (outer_vlan_id);
9201 mp->inner_vlan_id = ntohs (inner_vlan_id);
9209 api_reset_fib (vat_main_t * vam)
9211 unformat_input_t *i = vam->input;
9212 vl_api_reset_fib_t *mp;
9218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9220 if (unformat (i, "vrf %d", &vrf_id))
9222 else if (unformat (i, "ipv6"))
9226 clib_warning ("parse error '%U'", format_unformat_error, i);
9231 if (vrf_id_set == 0)
9233 errmsg ("missing vrf id");
9239 mp->vrf_id = ntohl (vrf_id);
9240 mp->is_ipv6 = is_ipv6;
9248 api_set_ip_flow_hash (vat_main_t * vam)
9250 unformat_input_t *i = vam->input;
9251 vl_api_set_ip_flow_hash_t *mp;
9263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9265 if (unformat (i, "vrf %d", &vrf_id))
9267 else if (unformat (i, "ipv6"))
9269 else if (unformat (i, "src"))
9271 else if (unformat (i, "dst"))
9273 else if (unformat (i, "sport"))
9275 else if (unformat (i, "dport"))
9277 else if (unformat (i, "proto"))
9279 else if (unformat (i, "reverse"))
9284 clib_warning ("parse error '%U'", format_unformat_error, i);
9289 if (vrf_id_set == 0)
9291 errmsg ("missing vrf id");
9295 M (SET_IP_FLOW_HASH, mp);
9301 mp->reverse = reverse;
9302 mp->vrf_id = ntohl (vrf_id);
9303 mp->is_ipv6 = is_ipv6;
9311 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9313 unformat_input_t *i = vam->input;
9314 vl_api_sw_interface_ip6_enable_disable_t *mp;
9316 u8 sw_if_index_set = 0;
9320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9322 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9323 sw_if_index_set = 1;
9324 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "enable"))
9328 else if (unformat (i, "disable"))
9332 clib_warning ("parse error '%U'", format_unformat_error, i);
9337 if (sw_if_index_set == 0)
9339 errmsg ("missing interface name or sw_if_index");
9343 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9345 mp->sw_if_index = ntohl (sw_if_index);
9346 mp->enable = enable;
9354 api_ip6nd_proxy_add_del (vat_main_t * vam)
9356 unformat_input_t *i = vam->input;
9357 vl_api_ip6nd_proxy_add_del_t *mp;
9358 u32 sw_if_index = ~0;
9359 u8 v6_address_set = 0;
9360 vl_api_ip6_address_t v6address;
9364 /* Parse args required to build the message */
9365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9371 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
9373 if (unformat (i, "del"))
9377 clib_warning ("parse error '%U'", format_unformat_error, i);
9382 if (sw_if_index == ~0)
9384 errmsg ("missing interface name or sw_if_index");
9387 if (!v6_address_set)
9389 errmsg ("no address set");
9393 /* Construct the API message */
9394 M (IP6ND_PROXY_ADD_DEL, mp);
9396 mp->is_del = is_del;
9397 mp->sw_if_index = ntohl (sw_if_index);
9398 clib_memcpy (mp->ip, v6address, sizeof (v6address));
9403 /* Wait for a reply, return good/bad news */
9409 api_ip6nd_proxy_dump (vat_main_t * vam)
9411 vl_api_ip6nd_proxy_dump_t *mp;
9412 vl_api_control_ping_t *mp_ping;
9415 M (IP6ND_PROXY_DUMP, mp);
9419 /* Use a control ping for synchronization */
9420 MPING (CONTROL_PING, mp_ping);
9427 static void vl_api_ip6nd_proxy_details_t_handler
9428 (vl_api_ip6nd_proxy_details_t * mp)
9430 vat_main_t *vam = &vat_main;
9432 print (vam->ofp, "host %U sw_if_index %d",
9433 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
9436 static void vl_api_ip6nd_proxy_details_t_handler_json
9437 (vl_api_ip6nd_proxy_details_t * mp)
9439 vat_main_t *vam = &vat_main;
9440 struct in6_addr ip6;
9441 vat_json_node_t *node = NULL;
9443 if (VAT_JSON_ARRAY != vam->json_tree.type)
9445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9446 vat_json_init_array (&vam->json_tree);
9448 node = vat_json_array_add (&vam->json_tree);
9450 vat_json_init_object (node);
9451 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9453 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
9454 vat_json_object_add_ip6 (node, "host", ip6);
9458 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9460 unformat_input_t *i = vam->input;
9461 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9463 u8 sw_if_index_set = 0;
9464 u8 v6_address_set = 0;
9465 vl_api_prefix_t pfx;
9467 u8 no_advertise = 0;
9469 u8 no_autoconfig = 0;
9472 u32 val_lifetime = 0;
9473 u32 pref_lifetime = 0;
9476 /* Parse args required to build the message */
9477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9480 sw_if_index_set = 1;
9481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9482 sw_if_index_set = 1;
9483 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
9485 else if (unformat (i, "val_life %d", &val_lifetime))
9487 else if (unformat (i, "pref_life %d", &pref_lifetime))
9489 else if (unformat (i, "def"))
9491 else if (unformat (i, "noadv"))
9493 else if (unformat (i, "offl"))
9495 else if (unformat (i, "noauto"))
9497 else if (unformat (i, "nolink"))
9499 else if (unformat (i, "isno"))
9503 clib_warning ("parse error '%U'", format_unformat_error, i);
9508 if (sw_if_index_set == 0)
9510 errmsg ("missing interface name or sw_if_index");
9513 if (!v6_address_set)
9515 errmsg ("no address set");
9519 /* Construct the API message */
9520 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9522 mp->sw_if_index = ntohl (sw_if_index);
9523 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
9524 mp->use_default = use_default;
9525 mp->no_advertise = no_advertise;
9526 mp->off_link = off_link;
9527 mp->no_autoconfig = no_autoconfig;
9528 mp->no_onlink = no_onlink;
9530 mp->val_lifetime = ntohl (val_lifetime);
9531 mp->pref_lifetime = ntohl (pref_lifetime);
9536 /* Wait for a reply, return good/bad news */
9542 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9544 unformat_input_t *i = vam->input;
9545 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9547 u8 sw_if_index_set = 0;
9552 u8 send_unicast = 0;
9555 u8 default_router = 0;
9556 u32 max_interval = 0;
9557 u32 min_interval = 0;
9559 u32 initial_count = 0;
9560 u32 initial_interval = 0;
9564 /* Parse args required to build the message */
9565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9568 sw_if_index_set = 1;
9569 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9570 sw_if_index_set = 1;
9571 else if (unformat (i, "maxint %d", &max_interval))
9573 else if (unformat (i, "minint %d", &min_interval))
9575 else if (unformat (i, "life %d", &lifetime))
9577 else if (unformat (i, "count %d", &initial_count))
9579 else if (unformat (i, "interval %d", &initial_interval))
9581 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9583 else if (unformat (i, "managed"))
9585 else if (unformat (i, "other"))
9587 else if (unformat (i, "ll"))
9589 else if (unformat (i, "send"))
9591 else if (unformat (i, "cease"))
9593 else if (unformat (i, "isno"))
9595 else if (unformat (i, "def"))
9599 clib_warning ("parse error '%U'", format_unformat_error, i);
9604 if (sw_if_index_set == 0)
9606 errmsg ("missing interface name or sw_if_index");
9610 /* Construct the API message */
9611 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9613 mp->sw_if_index = ntohl (sw_if_index);
9614 mp->max_interval = ntohl (max_interval);
9615 mp->min_interval = ntohl (min_interval);
9616 mp->lifetime = ntohl (lifetime);
9617 mp->initial_count = ntohl (initial_count);
9618 mp->initial_interval = ntohl (initial_interval);
9619 mp->suppress = suppress;
9620 mp->managed = managed;
9622 mp->ll_option = ll_option;
9623 mp->send_unicast = send_unicast;
9626 mp->default_router = default_router;
9631 /* Wait for a reply, return good/bad news */
9637 api_set_arp_neighbor_limit (vat_main_t * vam)
9639 unformat_input_t *i = vam->input;
9640 vl_api_set_arp_neighbor_limit_t *mp;
9646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9648 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9650 else if (unformat (i, "ipv6"))
9654 clib_warning ("parse error '%U'", format_unformat_error, i);
9661 errmsg ("missing limit value");
9665 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9667 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9668 mp->is_ipv6 = is_ipv6;
9676 api_l2_patch_add_del (vat_main_t * vam)
9678 unformat_input_t *i = vam->input;
9679 vl_api_l2_patch_add_del_t *mp;
9681 u8 rx_sw_if_index_set = 0;
9683 u8 tx_sw_if_index_set = 0;
9687 /* Parse args required to build the message */
9688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9690 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9691 rx_sw_if_index_set = 1;
9692 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9693 tx_sw_if_index_set = 1;
9694 else if (unformat (i, "rx"))
9696 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9698 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9700 rx_sw_if_index_set = 1;
9705 else if (unformat (i, "tx"))
9707 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9709 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9711 tx_sw_if_index_set = 1;
9716 else if (unformat (i, "del"))
9722 if (rx_sw_if_index_set == 0)
9724 errmsg ("missing rx interface name or rx_sw_if_index");
9728 if (tx_sw_if_index_set == 0)
9730 errmsg ("missing tx interface name or tx_sw_if_index");
9734 M (L2_PATCH_ADD_DEL, mp);
9736 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9737 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9738 mp->is_add = is_add;
9746 u8 localsid_addr[16];
9755 api_sr_localsid_add_del (vat_main_t * vam)
9757 unformat_input_t *i = vam->input;
9758 vl_api_sr_localsid_add_del_t *mp;
9761 ip6_address_t localsid;
9765 u32 fib_table = ~(u32) 0;
9766 ip6_address_t nh_addr6;
9767 ip4_address_t nh_addr4;
9768 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
9769 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
9771 bool nexthop_set = 0;
9775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9777 if (unformat (i, "del"))
9779 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9780 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
9782 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
9784 else if (unformat (i, "behavior %u", &behavior));
9785 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9786 else if (unformat (i, "fib-table %u", &fib_table));
9787 else if (unformat (i, "end.psp %u", &behavior));
9792 M (SR_LOCALSID_ADD_DEL, mp);
9794 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
9797 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
9798 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
9800 mp->behavior = behavior;
9801 mp->sw_if_index = ntohl (sw_if_index);
9802 mp->fib_table = ntohl (fib_table);
9803 mp->end_psp = end_psp;
9804 mp->is_del = is_del;
9812 api_ioam_enable (vat_main_t * vam)
9814 unformat_input_t *input = vam->input;
9815 vl_api_ioam_enable_t *mp;
9817 int has_trace_option = 0;
9818 int has_pot_option = 0;
9819 int has_seqno_option = 0;
9820 int has_analyse_option = 0;
9823 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9825 if (unformat (input, "trace"))
9826 has_trace_option = 1;
9827 else if (unformat (input, "pot"))
9829 else if (unformat (input, "seqno"))
9830 has_seqno_option = 1;
9831 else if (unformat (input, "analyse"))
9832 has_analyse_option = 1;
9836 M (IOAM_ENABLE, mp);
9837 mp->id = htons (id);
9838 mp->seqno = has_seqno_option;
9839 mp->analyse = has_analyse_option;
9840 mp->pot_enable = has_pot_option;
9841 mp->trace_enable = has_trace_option;
9850 api_ioam_disable (vat_main_t * vam)
9852 vl_api_ioam_disable_t *mp;
9855 M (IOAM_DISABLE, mp);
9861 #define foreach_tcp_proto_field \
9865 #define foreach_udp_proto_field \
9869 #define foreach_ip4_proto_field \
9881 u16 src_port, dst_port;
9884 #if VPP_API_TEST_BUILTIN == 0
9886 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9888 u8 **maskp = va_arg (*args, u8 **);
9890 u8 found_something = 0;
9893 #define _(a) u8 a=0;
9894 foreach_tcp_proto_field;
9897 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9900 #define _(a) else if (unformat (input, #a)) a=1;
9901 foreach_tcp_proto_field
9907 #define _(a) found_something += a;
9908 foreach_tcp_proto_field;
9911 if (found_something == 0)
9914 vec_validate (mask, sizeof (*tcp) - 1);
9916 tcp = (tcp_header_t *) mask;
9918 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9919 foreach_tcp_proto_field;
9927 unformat_udp_mask (unformat_input_t * input, va_list * args)
9929 u8 **maskp = va_arg (*args, u8 **);
9931 u8 found_something = 0;
9934 #define _(a) u8 a=0;
9935 foreach_udp_proto_field;
9938 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9941 #define _(a) else if (unformat (input, #a)) a=1;
9942 foreach_udp_proto_field
9948 #define _(a) found_something += a;
9949 foreach_udp_proto_field;
9952 if (found_something == 0)
9955 vec_validate (mask, sizeof (*udp) - 1);
9957 udp = (udp_header_t *) mask;
9959 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9960 foreach_udp_proto_field;
9968 unformat_l4_mask (unformat_input_t * input, va_list * args)
9970 u8 **maskp = va_arg (*args, u8 **);
9971 u16 src_port = 0, dst_port = 0;
9972 tcpudp_header_t *tcpudp;
9974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9976 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9978 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9980 else if (unformat (input, "src_port"))
9982 else if (unformat (input, "dst_port"))
9988 if (!src_port && !dst_port)
9992 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9994 tcpudp = (tcpudp_header_t *) mask;
9995 tcpudp->src_port = src_port;
9996 tcpudp->dst_port = dst_port;
10004 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10006 u8 **maskp = va_arg (*args, u8 **);
10008 u8 found_something = 0;
10011 #define _(a) u8 a=0;
10012 foreach_ip4_proto_field;
10018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10020 if (unformat (input, "version"))
10022 else if (unformat (input, "hdr_length"))
10024 else if (unformat (input, "src"))
10026 else if (unformat (input, "dst"))
10028 else if (unformat (input, "proto"))
10031 #define _(a) else if (unformat (input, #a)) a=1;
10032 foreach_ip4_proto_field
10038 #define _(a) found_something += a;
10039 foreach_ip4_proto_field;
10042 if (found_something == 0)
10045 vec_validate (mask, sizeof (*ip) - 1);
10047 ip = (ip4_header_t *) mask;
10049 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10050 foreach_ip4_proto_field;
10053 ip->ip_version_and_header_length = 0;
10056 ip->ip_version_and_header_length |= 0xF0;
10059 ip->ip_version_and_header_length |= 0x0F;
10065 #define foreach_ip6_proto_field \
10068 _(payload_length) \
10073 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10075 u8 **maskp = va_arg (*args, u8 **);
10077 u8 found_something = 0;
10079 u32 ip_version_traffic_class_and_flow_label;
10081 #define _(a) u8 a=0;
10082 foreach_ip6_proto_field;
10085 u8 traffic_class = 0;
10088 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10090 if (unformat (input, "version"))
10092 else if (unformat (input, "traffic-class"))
10094 else if (unformat (input, "flow-label"))
10096 else if (unformat (input, "src"))
10098 else if (unformat (input, "dst"))
10100 else if (unformat (input, "proto"))
10103 #define _(a) else if (unformat (input, #a)) a=1;
10104 foreach_ip6_proto_field
10110 #define _(a) found_something += a;
10111 foreach_ip6_proto_field;
10114 if (found_something == 0)
10117 vec_validate (mask, sizeof (*ip) - 1);
10119 ip = (ip6_header_t *) mask;
10121 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10122 foreach_ip6_proto_field;
10125 ip_version_traffic_class_and_flow_label = 0;
10128 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10131 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10134 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10136 ip->ip_version_traffic_class_and_flow_label =
10137 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10144 unformat_l3_mask (unformat_input_t * input, va_list * args)
10146 u8 **maskp = va_arg (*args, u8 **);
10148 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10150 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10152 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10161 unformat_l2_mask (unformat_input_t * input, va_list * args)
10163 u8 **maskp = va_arg (*args, u8 **);
10170 u8 ignore_tag1 = 0;
10171 u8 ignore_tag2 = 0;
10178 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10180 if (unformat (input, "src"))
10182 else if (unformat (input, "dst"))
10184 else if (unformat (input, "proto"))
10186 else if (unformat (input, "tag1"))
10188 else if (unformat (input, "tag2"))
10190 else if (unformat (input, "ignore-tag1"))
10192 else if (unformat (input, "ignore-tag2"))
10194 else if (unformat (input, "cos1"))
10196 else if (unformat (input, "cos2"))
10198 else if (unformat (input, "dot1q"))
10200 else if (unformat (input, "dot1ad"))
10205 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10206 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10209 if (tag1 || ignore_tag1 || cos1 || dot1q)
10211 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10214 vec_validate (mask, len - 1);
10217 clib_memset (mask, 0xff, 6);
10220 clib_memset (mask + 6, 0xff, 6);
10222 if (tag2 || dot1ad)
10224 /* inner vlan tag */
10233 mask[21] = mask[20] = 0xff;
10254 mask[16] = mask[17] = 0xff;
10264 mask[12] = mask[13] = 0xff;
10271 unformat_classify_mask (unformat_input_t * input, va_list * args)
10273 u8 **maskp = va_arg (*args, u8 **);
10274 u32 *skipp = va_arg (*args, u32 *);
10275 u32 *matchp = va_arg (*args, u32 *);
10283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10285 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10287 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10289 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10291 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10305 if (mask || l2 || l3 || l4)
10307 if (l2 || l3 || l4)
10309 /* "With a free Ethernet header in every package" */
10311 vec_validate (l2, 13);
10315 vec_append (mask, l3);
10320 vec_append (mask, l4);
10325 /* Scan forward looking for the first significant mask octet */
10326 for (i = 0; i < vec_len (mask); i++)
10330 /* compute (skip, match) params */
10331 *skipp = i / sizeof (u32x4);
10332 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10334 /* Pad mask to an even multiple of the vector size */
10335 while (vec_len (mask) % sizeof (u32x4))
10336 vec_add1 (mask, 0);
10338 match = vec_len (mask) / sizeof (u32x4);
10340 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10342 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10343 if (*tmp || *(tmp + 1))
10348 clib_warning ("BUG: match 0");
10350 _vec_len (mask) = match * sizeof (u32x4);
10360 #endif /* VPP_API_TEST_BUILTIN */
10362 #define foreach_l2_next \
10364 _(ethernet, ETHERNET_INPUT) \
10365 _(ip4, IP4_INPUT) \
10369 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10371 u32 *miss_next_indexp = va_arg (*args, u32 *);
10372 u32 next_index = 0;
10376 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10380 if (unformat (input, "%d", &tmp))
10389 *miss_next_indexp = next_index;
10393 #define foreach_ip_next \
10396 _(rewrite, REWRITE)
10399 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10401 u32 *miss_next_indexp = va_arg (*args, u32 *);
10402 u32 next_index = 0;
10406 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10410 if (unformat (input, "%d", &tmp))
10419 *miss_next_indexp = next_index;
10423 #define foreach_acl_next \
10427 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10429 u32 *miss_next_indexp = va_arg (*args, u32 *);
10430 u32 next_index = 0;
10434 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10438 if (unformat (input, "permit"))
10443 else if (unformat (input, "%d", &tmp))
10452 *miss_next_indexp = next_index;
10457 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10459 u32 *r = va_arg (*args, u32 *);
10461 if (unformat (input, "conform-color"))
10462 *r = POLICE_CONFORM;
10463 else if (unformat (input, "exceed-color"))
10464 *r = POLICE_EXCEED;
10472 api_classify_add_del_table (vat_main_t * vam)
10474 unformat_input_t *i = vam->input;
10475 vl_api_classify_add_del_table_t *mp;
10482 u32 table_index = ~0;
10483 u32 next_table_index = ~0;
10484 u32 miss_next_index = ~0;
10485 u32 memory_size = 32 << 20;
10487 u32 current_data_flag = 0;
10488 int current_data_offset = 0;
10491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10493 if (unformat (i, "del"))
10495 else if (unformat (i, "del-chain"))
10500 else if (unformat (i, "buckets %d", &nbuckets))
10502 else if (unformat (i, "memory_size %d", &memory_size))
10504 else if (unformat (i, "skip %d", &skip))
10506 else if (unformat (i, "match %d", &match))
10508 else if (unformat (i, "table %d", &table_index))
10510 else if (unformat (i, "mask %U", unformat_classify_mask,
10511 &mask, &skip, &match))
10513 else if (unformat (i, "next-table %d", &next_table_index))
10515 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10518 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10521 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10524 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10526 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10532 if (is_add && mask == 0)
10534 errmsg ("Mask required");
10538 if (is_add && skip == ~0)
10540 errmsg ("skip count required");
10544 if (is_add && match == ~0)
10546 errmsg ("match count required");
10550 if (!is_add && table_index == ~0)
10552 errmsg ("table index required for delete");
10556 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10558 mp->is_add = is_add;
10559 mp->del_chain = del_chain;
10560 mp->table_index = ntohl (table_index);
10561 mp->nbuckets = ntohl (nbuckets);
10562 mp->memory_size = ntohl (memory_size);
10563 mp->skip_n_vectors = ntohl (skip);
10564 mp->match_n_vectors = ntohl (match);
10565 mp->next_table_index = ntohl (next_table_index);
10566 mp->miss_next_index = ntohl (miss_next_index);
10567 mp->current_data_flag = ntohl (current_data_flag);
10568 mp->current_data_offset = ntohl (current_data_offset);
10569 mp->mask_len = ntohl (vec_len (mask));
10570 clib_memcpy (mp->mask, mask, vec_len (mask));
10579 #if VPP_API_TEST_BUILTIN == 0
10581 unformat_l4_match (unformat_input_t * input, va_list * args)
10583 u8 **matchp = va_arg (*args, u8 **);
10585 u8 *proto_header = 0;
10591 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10593 if (unformat (input, "src_port %d", &src_port))
10595 else if (unformat (input, "dst_port %d", &dst_port))
10601 h.src_port = clib_host_to_net_u16 (src_port);
10602 h.dst_port = clib_host_to_net_u16 (dst_port);
10603 vec_validate (proto_header, sizeof (h) - 1);
10604 memcpy (proto_header, &h, sizeof (h));
10606 *matchp = proto_header;
10612 unformat_ip4_match (unformat_input_t * input, va_list * args)
10614 u8 **matchp = va_arg (*args, u8 **);
10619 int hdr_length = 0;
10620 u32 hdr_length_val;
10621 int src = 0, dst = 0;
10622 ip4_address_t src_val, dst_val;
10629 int fragment_id = 0;
10630 u32 fragment_id_val;
10636 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10638 if (unformat (input, "version %d", &version_val))
10640 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10642 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10644 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10646 else if (unformat (input, "proto %d", &proto_val))
10648 else if (unformat (input, "tos %d", &tos_val))
10650 else if (unformat (input, "length %d", &length_val))
10652 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10654 else if (unformat (input, "ttl %d", &ttl_val))
10656 else if (unformat (input, "checksum %d", &checksum_val))
10662 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10663 + ttl + checksum == 0)
10667 * Aligned because we use the real comparison functions
10669 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10671 ip = (ip4_header_t *) match;
10673 /* These are realistically matched in practice */
10675 ip->src_address.as_u32 = src_val.as_u32;
10678 ip->dst_address.as_u32 = dst_val.as_u32;
10681 ip->protocol = proto_val;
10684 /* These are not, but they're included for completeness */
10686 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10689 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10695 ip->length = clib_host_to_net_u16 (length_val);
10701 ip->checksum = clib_host_to_net_u16 (checksum_val);
10708 unformat_ip6_match (unformat_input_t * input, va_list * args)
10710 u8 **matchp = va_arg (*args, u8 **);
10715 u8 traffic_class = 0;
10716 u32 traffic_class_val = 0;
10719 int src = 0, dst = 0;
10720 ip6_address_t src_val, dst_val;
10723 int payload_length = 0;
10724 u32 payload_length_val;
10727 u32 ip_version_traffic_class_and_flow_label;
10729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10731 if (unformat (input, "version %d", &version_val))
10733 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10735 else if (unformat (input, "flow_label %d", &flow_label_val))
10737 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10739 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10741 else if (unformat (input, "proto %d", &proto_val))
10743 else if (unformat (input, "payload_length %d", &payload_length_val))
10744 payload_length = 1;
10745 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10751 if (version + traffic_class + flow_label + src + dst + proto +
10752 payload_length + hop_limit == 0)
10756 * Aligned because we use the real comparison functions
10758 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10760 ip = (ip6_header_t *) match;
10763 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10766 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10769 ip->protocol = proto_val;
10771 ip_version_traffic_class_and_flow_label = 0;
10774 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10777 ip_version_traffic_class_and_flow_label |=
10778 (traffic_class_val & 0xFF) << 20;
10781 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10783 ip->ip_version_traffic_class_and_flow_label =
10784 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10786 if (payload_length)
10787 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10790 ip->hop_limit = hop_limit_val;
10797 unformat_l3_match (unformat_input_t * input, va_list * args)
10799 u8 **matchp = va_arg (*args, u8 **);
10801 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10803 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10805 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10814 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10816 u8 *tagp = va_arg (*args, u8 *);
10819 if (unformat (input, "%d", &tag))
10821 tagp[0] = (tag >> 8) & 0x0F;
10822 tagp[1] = tag & 0xFF;
10830 unformat_l2_match (unformat_input_t * input, va_list * args)
10832 u8 **matchp = va_arg (*args, u8 **);
10845 u8 ignore_tag1 = 0;
10846 u8 ignore_tag2 = 0;
10852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10854 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10857 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10859 else if (unformat (input, "proto %U",
10860 unformat_ethernet_type_host_byte_order, &proto_val))
10862 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10864 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10866 else if (unformat (input, "ignore-tag1"))
10868 else if (unformat (input, "ignore-tag2"))
10870 else if (unformat (input, "cos1 %d", &cos1_val))
10872 else if (unformat (input, "cos2 %d", &cos2_val))
10877 if ((src + dst + proto + tag1 + tag2 +
10878 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10881 if (tag1 || ignore_tag1 || cos1)
10883 if (tag2 || ignore_tag2 || cos2)
10886 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10889 clib_memcpy (match, dst_val, 6);
10892 clib_memcpy (match + 6, src_val, 6);
10896 /* inner vlan tag */
10897 match[19] = tag2_val[1];
10898 match[18] = tag2_val[0];
10900 match[18] |= (cos2_val & 0x7) << 5;
10903 match[21] = proto_val & 0xff;
10904 match[20] = proto_val >> 8;
10908 match[15] = tag1_val[1];
10909 match[14] = tag1_val[0];
10912 match[14] |= (cos1_val & 0x7) << 5;
10918 match[15] = tag1_val[1];
10919 match[14] = tag1_val[0];
10922 match[17] = proto_val & 0xff;
10923 match[16] = proto_val >> 8;
10926 match[14] |= (cos1_val & 0x7) << 5;
10932 match[18] |= (cos2_val & 0x7) << 5;
10934 match[14] |= (cos1_val & 0x7) << 5;
10937 match[13] = proto_val & 0xff;
10938 match[12] = proto_val >> 8;
10946 unformat_qos_source (unformat_input_t * input, va_list * args)
10948 int *qs = va_arg (*args, int *);
10950 if (unformat (input, "ip"))
10951 *qs = QOS_SOURCE_IP;
10952 else if (unformat (input, "mpls"))
10953 *qs = QOS_SOURCE_MPLS;
10954 else if (unformat (input, "ext"))
10955 *qs = QOS_SOURCE_EXT;
10956 else if (unformat (input, "vlan"))
10957 *qs = QOS_SOURCE_VLAN;
10966 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10968 u8 **matchp = va_arg (*args, u8 **);
10969 u32 skip_n_vectors = va_arg (*args, u32);
10970 u32 match_n_vectors = va_arg (*args, u32);
10977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10979 if (unformat (input, "hex %U", unformat_hex_string, &match))
10981 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10983 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10985 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10999 if (match || l2 || l3 || l4)
11001 if (l2 || l3 || l4)
11003 /* "Win a free Ethernet header in every packet" */
11005 vec_validate_aligned (l2, 13, sizeof (u32x4));
11009 vec_append_aligned (match, l3, sizeof (u32x4));
11014 vec_append_aligned (match, l4, sizeof (u32x4));
11019 /* Make sure the vector is big enough even if key is all 0's */
11020 vec_validate_aligned
11021 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11024 /* Set size, include skipped vectors */
11025 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11036 api_classify_add_del_session (vat_main_t * vam)
11038 unformat_input_t *i = vam->input;
11039 vl_api_classify_add_del_session_t *mp;
11041 u32 table_index = ~0;
11042 u32 hit_next_index = ~0;
11043 u32 opaque_index = ~0;
11046 u32 skip_n_vectors = 0;
11047 u32 match_n_vectors = 0;
11053 * Warning: you have to supply skip_n and match_n
11054 * because the API client cant simply look at the classify
11058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11060 if (unformat (i, "del"))
11062 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11065 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11068 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11071 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11073 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11075 else if (unformat (i, "opaque-index %d", &opaque_index))
11077 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11079 else if (unformat (i, "match_n %d", &match_n_vectors))
11081 else if (unformat (i, "match %U", api_unformat_classify_match,
11082 &match, skip_n_vectors, match_n_vectors))
11084 else if (unformat (i, "advance %d", &advance))
11086 else if (unformat (i, "table-index %d", &table_index))
11088 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11090 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11092 else if (unformat (i, "action %d", &action))
11094 else if (unformat (i, "metadata %d", &metadata))
11100 if (table_index == ~0)
11102 errmsg ("Table index required");
11106 if (is_add && match == 0)
11108 errmsg ("Match value required");
11112 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11114 mp->is_add = is_add;
11115 mp->table_index = ntohl (table_index);
11116 mp->hit_next_index = ntohl (hit_next_index);
11117 mp->opaque_index = ntohl (opaque_index);
11118 mp->advance = ntohl (advance);
11119 mp->action = action;
11120 mp->metadata = ntohl (metadata);
11121 mp->match_len = ntohl (vec_len (match));
11122 clib_memcpy (mp->match, match, vec_len (match));
11131 api_classify_set_interface_ip_table (vat_main_t * vam)
11133 unformat_input_t *i = vam->input;
11134 vl_api_classify_set_interface_ip_table_t *mp;
11136 int sw_if_index_set;
11137 u32 table_index = ~0;
11141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11143 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11144 sw_if_index_set = 1;
11145 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11146 sw_if_index_set = 1;
11147 else if (unformat (i, "table %d", &table_index))
11151 clib_warning ("parse error '%U'", format_unformat_error, i);
11156 if (sw_if_index_set == 0)
11158 errmsg ("missing interface name or sw_if_index");
11163 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11165 mp->sw_if_index = ntohl (sw_if_index);
11166 mp->table_index = ntohl (table_index);
11167 mp->is_ipv6 = is_ipv6;
11175 api_classify_set_interface_l2_tables (vat_main_t * vam)
11177 unformat_input_t *i = vam->input;
11178 vl_api_classify_set_interface_l2_tables_t *mp;
11180 int sw_if_index_set;
11181 u32 ip4_table_index = ~0;
11182 u32 ip6_table_index = ~0;
11183 u32 other_table_index = ~0;
11187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11189 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11190 sw_if_index_set = 1;
11191 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11195 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11197 else if (unformat (i, "other-table %d", &other_table_index))
11199 else if (unformat (i, "is-input %d", &is_input))
11203 clib_warning ("parse error '%U'", format_unformat_error, i);
11208 if (sw_if_index_set == 0)
11210 errmsg ("missing interface name or sw_if_index");
11215 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11217 mp->sw_if_index = ntohl (sw_if_index);
11218 mp->ip4_table_index = ntohl (ip4_table_index);
11219 mp->ip6_table_index = ntohl (ip6_table_index);
11220 mp->other_table_index = ntohl (other_table_index);
11221 mp->is_input = (u8) is_input;
11229 api_set_ipfix_exporter (vat_main_t * vam)
11231 unformat_input_t *i = vam->input;
11232 vl_api_set_ipfix_exporter_t *mp;
11233 ip4_address_t collector_address;
11234 u8 collector_address_set = 0;
11235 u32 collector_port = ~0;
11236 ip4_address_t src_address;
11237 u8 src_address_set = 0;
11240 u32 template_interval = ~0;
11241 u8 udp_checksum = 0;
11244 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11246 if (unformat (i, "collector_address %U", unformat_ip4_address,
11247 &collector_address))
11248 collector_address_set = 1;
11249 else if (unformat (i, "collector_port %d", &collector_port))
11251 else if (unformat (i, "src_address %U", unformat_ip4_address,
11253 src_address_set = 1;
11254 else if (unformat (i, "vrf_id %d", &vrf_id))
11256 else if (unformat (i, "path_mtu %d", &path_mtu))
11258 else if (unformat (i, "template_interval %d", &template_interval))
11260 else if (unformat (i, "udp_checksum"))
11266 if (collector_address_set == 0)
11268 errmsg ("collector_address required");
11272 if (src_address_set == 0)
11274 errmsg ("src_address required");
11278 M (SET_IPFIX_EXPORTER, mp);
11280 memcpy (mp->collector_address, collector_address.data,
11281 sizeof (collector_address.data));
11282 mp->collector_port = htons ((u16) collector_port);
11283 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11284 mp->vrf_id = htonl (vrf_id);
11285 mp->path_mtu = htonl (path_mtu);
11286 mp->template_interval = htonl (template_interval);
11287 mp->udp_checksum = udp_checksum;
11295 api_set_ipfix_classify_stream (vat_main_t * vam)
11297 unformat_input_t *i = vam->input;
11298 vl_api_set_ipfix_classify_stream_t *mp;
11300 u32 src_port = UDP_DST_PORT_ipfix;
11303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11305 if (unformat (i, "domain %d", &domain_id))
11307 else if (unformat (i, "src_port %d", &src_port))
11311 errmsg ("unknown input `%U'", format_unformat_error, i);
11316 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11318 mp->domain_id = htonl (domain_id);
11319 mp->src_port = htons ((u16) src_port);
11327 api_ipfix_classify_table_add_del (vat_main_t * vam)
11329 unformat_input_t *i = vam->input;
11330 vl_api_ipfix_classify_table_add_del_t *mp;
11332 u32 classify_table_index = ~0;
11334 u8 transport_protocol = 255;
11337 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11339 if (unformat (i, "add"))
11341 else if (unformat (i, "del"))
11343 else if (unformat (i, "table %d", &classify_table_index))
11345 else if (unformat (i, "ip4"))
11347 else if (unformat (i, "ip6"))
11349 else if (unformat (i, "tcp"))
11350 transport_protocol = 6;
11351 else if (unformat (i, "udp"))
11352 transport_protocol = 17;
11355 errmsg ("unknown input `%U'", format_unformat_error, i);
11362 errmsg ("expecting: add|del");
11365 if (classify_table_index == ~0)
11367 errmsg ("classifier table not specified");
11370 if (ip_version == 0)
11372 errmsg ("IP version not specified");
11376 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11378 mp->is_add = is_add;
11379 mp->table_id = htonl (classify_table_index);
11380 mp->ip_version = ip_version;
11381 mp->transport_protocol = transport_protocol;
11389 api_get_node_index (vat_main_t * vam)
11391 unformat_input_t *i = vam->input;
11392 vl_api_get_node_index_t *mp;
11396 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11398 if (unformat (i, "node %s", &name))
11405 errmsg ("node name required");
11408 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11410 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11414 M (GET_NODE_INDEX, mp);
11415 clib_memcpy (mp->node_name, name, vec_len (name));
11424 api_get_next_index (vat_main_t * vam)
11426 unformat_input_t *i = vam->input;
11427 vl_api_get_next_index_t *mp;
11428 u8 *node_name = 0, *next_node_name = 0;
11431 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11433 if (unformat (i, "node-name %s", &node_name))
11435 else if (unformat (i, "next-node-name %s", &next_node_name))
11439 if (node_name == 0)
11441 errmsg ("node name required");
11444 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11446 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11450 if (next_node_name == 0)
11452 errmsg ("next node name required");
11455 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11457 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11461 M (GET_NEXT_INDEX, mp);
11462 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11463 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11464 vec_free (node_name);
11465 vec_free (next_node_name);
11473 api_add_node_next (vat_main_t * vam)
11475 unformat_input_t *i = vam->input;
11476 vl_api_add_node_next_t *mp;
11481 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11483 if (unformat (i, "node %s", &name))
11485 else if (unformat (i, "next %s", &next))
11492 errmsg ("node name required");
11495 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11497 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11502 errmsg ("next node required");
11505 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11507 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11511 M (ADD_NODE_NEXT, mp);
11512 clib_memcpy (mp->node_name, name, vec_len (name));
11513 clib_memcpy (mp->next_name, next, vec_len (next));
11523 api_l2tpv3_create_tunnel (vat_main_t * vam)
11525 unformat_input_t *i = vam->input;
11526 ip6_address_t client_address, our_address;
11527 int client_address_set = 0;
11528 int our_address_set = 0;
11529 u32 local_session_id = 0;
11530 u32 remote_session_id = 0;
11531 u64 local_cookie = 0;
11532 u64 remote_cookie = 0;
11533 u8 l2_sublayer_present = 0;
11534 vl_api_l2tpv3_create_tunnel_t *mp;
11537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11539 if (unformat (i, "client_address %U", unformat_ip6_address,
11541 client_address_set = 1;
11542 else if (unformat (i, "our_address %U", unformat_ip6_address,
11544 our_address_set = 1;
11545 else if (unformat (i, "local_session_id %d", &local_session_id))
11547 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11549 else if (unformat (i, "local_cookie %lld", &local_cookie))
11551 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11553 else if (unformat (i, "l2-sublayer-present"))
11554 l2_sublayer_present = 1;
11559 if (client_address_set == 0)
11561 errmsg ("client_address required");
11565 if (our_address_set == 0)
11567 errmsg ("our_address required");
11571 M (L2TPV3_CREATE_TUNNEL, mp);
11573 clib_memcpy (mp->client_address, client_address.as_u8,
11574 sizeof (mp->client_address));
11576 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11578 mp->local_session_id = ntohl (local_session_id);
11579 mp->remote_session_id = ntohl (remote_session_id);
11580 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11581 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11582 mp->l2_sublayer_present = l2_sublayer_present;
11591 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11593 unformat_input_t *i = vam->input;
11595 u8 sw_if_index_set = 0;
11596 u64 new_local_cookie = 0;
11597 u64 new_remote_cookie = 0;
11598 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11603 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11604 sw_if_index_set = 1;
11605 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11606 sw_if_index_set = 1;
11607 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11609 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11615 if (sw_if_index_set == 0)
11617 errmsg ("missing interface name or sw_if_index");
11621 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11623 mp->sw_if_index = ntohl (sw_if_index);
11624 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11625 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11633 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11635 unformat_input_t *i = vam->input;
11636 vl_api_l2tpv3_interface_enable_disable_t *mp;
11638 u8 sw_if_index_set = 0;
11639 u8 enable_disable = 1;
11642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11644 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11645 sw_if_index_set = 1;
11646 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11647 sw_if_index_set = 1;
11648 else if (unformat (i, "enable"))
11649 enable_disable = 1;
11650 else if (unformat (i, "disable"))
11651 enable_disable = 0;
11656 if (sw_if_index_set == 0)
11658 errmsg ("missing interface name or sw_if_index");
11662 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11664 mp->sw_if_index = ntohl (sw_if_index);
11665 mp->enable_disable = enable_disable;
11673 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11675 unformat_input_t *i = vam->input;
11676 vl_api_l2tpv3_set_lookup_key_t *mp;
11680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11682 if (unformat (i, "lookup_v6_src"))
11683 key = L2T_LOOKUP_SRC_ADDRESS;
11684 else if (unformat (i, "lookup_v6_dst"))
11685 key = L2T_LOOKUP_DST_ADDRESS;
11686 else if (unformat (i, "lookup_session_id"))
11687 key = L2T_LOOKUP_SESSION_ID;
11692 if (key == (u8) ~ 0)
11694 errmsg ("l2tp session lookup key unset");
11698 M (L2TPV3_SET_LOOKUP_KEY, mp);
11707 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11708 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11710 vat_main_t *vam = &vat_main;
11712 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11713 format_ip6_address, mp->our_address,
11714 format_ip6_address, mp->client_address,
11715 clib_net_to_host_u32 (mp->sw_if_index));
11718 " local cookies %016llx %016llx remote cookie %016llx",
11719 clib_net_to_host_u64 (mp->local_cookie[0]),
11720 clib_net_to_host_u64 (mp->local_cookie[1]),
11721 clib_net_to_host_u64 (mp->remote_cookie));
11723 print (vam->ofp, " local session-id %d remote session-id %d",
11724 clib_net_to_host_u32 (mp->local_session_id),
11725 clib_net_to_host_u32 (mp->remote_session_id));
11727 print (vam->ofp, " l2 specific sublayer %s\n",
11728 mp->l2_sublayer_present ? "preset" : "absent");
11732 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11733 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11735 vat_main_t *vam = &vat_main;
11736 vat_json_node_t *node = NULL;
11737 struct in6_addr addr;
11739 if (VAT_JSON_ARRAY != vam->json_tree.type)
11741 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11742 vat_json_init_array (&vam->json_tree);
11744 node = vat_json_array_add (&vam->json_tree);
11746 vat_json_init_object (node);
11748 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11749 vat_json_object_add_ip6 (node, "our_address", addr);
11750 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11751 vat_json_object_add_ip6 (node, "client_address", addr);
11753 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11754 vat_json_init_array (lc);
11755 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11756 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11757 vat_json_object_add_uint (node, "remote_cookie",
11758 clib_net_to_host_u64 (mp->remote_cookie));
11760 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11761 vat_json_object_add_uint (node, "local_session_id",
11762 clib_net_to_host_u32 (mp->local_session_id));
11763 vat_json_object_add_uint (node, "remote_session_id",
11764 clib_net_to_host_u32 (mp->remote_session_id));
11765 vat_json_object_add_string_copy (node, "l2_sublayer",
11766 mp->l2_sublayer_present ? (u8 *) "present"
11767 : (u8 *) "absent");
11771 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11773 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11774 vl_api_control_ping_t *mp_ping;
11777 /* Get list of l2tpv3-tunnel interfaces */
11778 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11781 /* Use a control ping for synchronization */
11782 MPING (CONTROL_PING, mp_ping);
11790 static void vl_api_sw_interface_tap_v2_details_t_handler
11791 (vl_api_sw_interface_tap_v2_details_t * mp)
11793 vat_main_t *vam = &vat_main;
11795 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
11796 mp->host_ip4_prefix_len);
11797 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
11798 mp->host_ip6_prefix_len);
11801 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11802 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11803 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11804 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11805 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11811 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11812 (vl_api_sw_interface_tap_v2_details_t * mp)
11814 vat_main_t *vam = &vat_main;
11815 vat_json_node_t *node = NULL;
11817 if (VAT_JSON_ARRAY != vam->json_tree.type)
11819 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11820 vat_json_init_array (&vam->json_tree);
11822 node = vat_json_array_add (&vam->json_tree);
11824 vat_json_init_object (node);
11825 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11826 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11827 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11828 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11829 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11830 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11831 vat_json_object_add_string_copy (node, "host_mac_addr",
11832 format (0, "%U", format_ethernet_address,
11833 &mp->host_mac_addr));
11834 vat_json_object_add_string_copy (node, "host_namespace",
11835 mp->host_namespace);
11836 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11837 vat_json_object_add_string_copy (node, "host_ip4_addr",
11838 format (0, "%U/%d", format_ip4_address,
11840 mp->host_ip4_prefix_len));
11841 vat_json_object_add_string_copy (node, "host_ip6_addr",
11842 format (0, "%U/%d", format_ip6_address,
11844 mp->host_ip6_prefix_len));
11849 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11851 vl_api_sw_interface_tap_v2_dump_t *mp;
11852 vl_api_control_ping_t *mp_ping;
11856 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11857 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11858 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11861 /* Get list of tap interfaces */
11862 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11865 /* Use a control ping for synchronization */
11866 MPING (CONTROL_PING, mp_ping);
11873 static void vl_api_sw_interface_virtio_pci_details_t_handler
11874 (vl_api_sw_interface_virtio_pci_details_t * mp)
11876 vat_main_t *vam = &vat_main;
11890 addr.as_u32 = ntohl (mp->pci_addr);
11891 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11892 addr.slot, addr.function);
11895 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11896 pci_addr, ntohl (mp->sw_if_index),
11897 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11898 format_ethernet_address, mp->mac_addr,
11899 clib_net_to_host_u64 (mp->features));
11900 vec_free (pci_addr);
11903 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11904 (vl_api_sw_interface_virtio_pci_details_t * mp)
11906 vat_main_t *vam = &vat_main;
11907 vat_json_node_t *node = NULL;
11909 if (VAT_JSON_ARRAY != vam->json_tree.type)
11911 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11912 vat_json_init_array (&vam->json_tree);
11914 node = vat_json_array_add (&vam->json_tree);
11916 vat_json_init_object (node);
11917 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
11918 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11919 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11920 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11921 vat_json_object_add_uint (node, "features",
11922 clib_net_to_host_u64 (mp->features));
11923 vat_json_object_add_string_copy (node, "mac_addr",
11924 format (0, "%U", format_ethernet_address,
11929 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11931 vl_api_sw_interface_virtio_pci_dump_t *mp;
11932 vl_api_control_ping_t *mp_ping;
11936 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11937 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11938 "mac_addr", "features");
11940 /* Get list of tap interfaces */
11941 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11944 /* Use a control ping for synchronization */
11945 MPING (CONTROL_PING, mp_ping);
11953 api_vxlan_offload_rx (vat_main_t * vam)
11955 unformat_input_t *line_input = vam->input;
11956 vl_api_vxlan_offload_rx_t *mp;
11957 u32 hw_if_index = ~0, rx_if_index = ~0;
11961 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11963 if (unformat (line_input, "del"))
11965 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11968 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11970 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11973 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11977 errmsg ("parse error '%U'", format_unformat_error, line_input);
11982 if (hw_if_index == ~0)
11984 errmsg ("no hw interface");
11988 if (rx_if_index == ~0)
11990 errmsg ("no rx tunnel");
11994 M (VXLAN_OFFLOAD_RX, mp);
11996 mp->hw_if_index = ntohl (hw_if_index);
11997 mp->sw_if_index = ntohl (rx_if_index);
11998 mp->enable = is_add;
12005 static uword unformat_vxlan_decap_next
12006 (unformat_input_t * input, va_list * args)
12008 u32 *result = va_arg (*args, u32 *);
12011 if (unformat (input, "l2"))
12012 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12013 else if (unformat (input, "%d", &tmp))
12021 api_vxlan_add_del_tunnel (vat_main_t * vam)
12023 unformat_input_t *line_input = vam->input;
12024 vl_api_vxlan_add_del_tunnel_t *mp;
12025 ip46_address_t src, dst;
12027 u8 ipv4_set = 0, ipv6_set = 0;
12032 u32 mcast_sw_if_index = ~0;
12033 u32 encap_vrf_id = 0;
12034 u32 decap_next_index = ~0;
12038 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12039 clib_memset (&src, 0, sizeof src);
12040 clib_memset (&dst, 0, sizeof dst);
12042 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12044 if (unformat (line_input, "del"))
12046 else if (unformat (line_input, "instance %d", &instance))
12049 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12055 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12061 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12067 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12072 else if (unformat (line_input, "group %U %U",
12073 unformat_ip4_address, &dst.ip4,
12074 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12076 grp_set = dst_set = 1;
12079 else if (unformat (line_input, "group %U",
12080 unformat_ip4_address, &dst.ip4))
12082 grp_set = dst_set = 1;
12085 else if (unformat (line_input, "group %U %U",
12086 unformat_ip6_address, &dst.ip6,
12087 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12089 grp_set = dst_set = 1;
12092 else if (unformat (line_input, "group %U",
12093 unformat_ip6_address, &dst.ip6))
12095 grp_set = dst_set = 1;
12099 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12101 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12103 else if (unformat (line_input, "decap-next %U",
12104 unformat_vxlan_decap_next, &decap_next_index))
12106 else if (unformat (line_input, "vni %d", &vni))
12110 errmsg ("parse error '%U'", format_unformat_error, line_input);
12117 errmsg ("tunnel src address not specified");
12122 errmsg ("tunnel dst address not specified");
12126 if (grp_set && !ip46_address_is_multicast (&dst))
12128 errmsg ("tunnel group address not multicast");
12131 if (grp_set && mcast_sw_if_index == ~0)
12133 errmsg ("tunnel nonexistent multicast device");
12136 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12138 errmsg ("tunnel dst address must be unicast");
12143 if (ipv4_set && ipv6_set)
12145 errmsg ("both IPv4 and IPv6 addresses specified");
12149 if ((vni == 0) || (vni >> 24))
12151 errmsg ("vni not specified or out of range");
12155 M (VXLAN_ADD_DEL_TUNNEL, mp);
12159 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12160 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12164 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12165 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12168 mp->instance = htonl (instance);
12169 mp->encap_vrf_id = ntohl (encap_vrf_id);
12170 mp->decap_next_index = ntohl (decap_next_index);
12171 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12172 mp->vni = ntohl (vni);
12173 mp->is_add = is_add;
12174 mp->is_ipv6 = ipv6_set;
12181 static void vl_api_vxlan_tunnel_details_t_handler
12182 (vl_api_vxlan_tunnel_details_t * mp)
12184 vat_main_t *vam = &vat_main;
12185 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12186 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12188 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12189 ntohl (mp->sw_if_index),
12190 ntohl (mp->instance),
12191 format_ip46_address, &src, IP46_TYPE_ANY,
12192 format_ip46_address, &dst, IP46_TYPE_ANY,
12193 ntohl (mp->encap_vrf_id),
12194 ntohl (mp->decap_next_index), ntohl (mp->vni),
12195 ntohl (mp->mcast_sw_if_index));
12198 static void vl_api_vxlan_tunnel_details_t_handler_json
12199 (vl_api_vxlan_tunnel_details_t * mp)
12201 vat_main_t *vam = &vat_main;
12202 vat_json_node_t *node = NULL;
12204 if (VAT_JSON_ARRAY != vam->json_tree.type)
12206 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12207 vat_json_init_array (&vam->json_tree);
12209 node = vat_json_array_add (&vam->json_tree);
12211 vat_json_init_object (node);
12212 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12214 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12218 struct in6_addr ip6;
12220 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12221 vat_json_object_add_ip6 (node, "src_address", ip6);
12222 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12223 vat_json_object_add_ip6 (node, "dst_address", ip6);
12227 struct in_addr ip4;
12229 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12230 vat_json_object_add_ip4 (node, "src_address", ip4);
12231 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12232 vat_json_object_add_ip4 (node, "dst_address", ip4);
12234 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12235 vat_json_object_add_uint (node, "decap_next_index",
12236 ntohl (mp->decap_next_index));
12237 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12238 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12239 vat_json_object_add_uint (node, "mcast_sw_if_index",
12240 ntohl (mp->mcast_sw_if_index));
12244 api_vxlan_tunnel_dump (vat_main_t * vam)
12246 unformat_input_t *i = vam->input;
12247 vl_api_vxlan_tunnel_dump_t *mp;
12248 vl_api_control_ping_t *mp_ping;
12250 u8 sw_if_index_set = 0;
12253 /* Parse args required to build the message */
12254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12256 if (unformat (i, "sw_if_index %d", &sw_if_index))
12257 sw_if_index_set = 1;
12262 if (sw_if_index_set == 0)
12267 if (!vam->json_output)
12269 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12270 "sw_if_index", "instance", "src_address", "dst_address",
12271 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12274 /* Get list of vxlan-tunnel interfaces */
12275 M (VXLAN_TUNNEL_DUMP, mp);
12277 mp->sw_if_index = htonl (sw_if_index);
12281 /* Use a control ping for synchronization */
12282 MPING (CONTROL_PING, mp_ping);
12289 static uword unformat_geneve_decap_next
12290 (unformat_input_t * input, va_list * args)
12292 u32 *result = va_arg (*args, u32 *);
12295 if (unformat (input, "l2"))
12296 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12297 else if (unformat (input, "%d", &tmp))
12305 api_geneve_add_del_tunnel (vat_main_t * vam)
12307 unformat_input_t *line_input = vam->input;
12308 vl_api_geneve_add_del_tunnel_t *mp;
12309 ip46_address_t src, dst;
12311 u8 ipv4_set = 0, ipv6_set = 0;
12315 u32 mcast_sw_if_index = ~0;
12316 u32 encap_vrf_id = 0;
12317 u32 decap_next_index = ~0;
12321 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12322 clib_memset (&src, 0, sizeof src);
12323 clib_memset (&dst, 0, sizeof dst);
12325 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12327 if (unformat (line_input, "del"))
12330 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12336 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12342 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12348 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12353 else if (unformat (line_input, "group %U %U",
12354 unformat_ip4_address, &dst.ip4,
12355 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12357 grp_set = dst_set = 1;
12360 else if (unformat (line_input, "group %U",
12361 unformat_ip4_address, &dst.ip4))
12363 grp_set = dst_set = 1;
12366 else if (unformat (line_input, "group %U %U",
12367 unformat_ip6_address, &dst.ip6,
12368 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12370 grp_set = dst_set = 1;
12373 else if (unformat (line_input, "group %U",
12374 unformat_ip6_address, &dst.ip6))
12376 grp_set = dst_set = 1;
12380 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12382 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12384 else if (unformat (line_input, "decap-next %U",
12385 unformat_geneve_decap_next, &decap_next_index))
12387 else if (unformat (line_input, "vni %d", &vni))
12391 errmsg ("parse error '%U'", format_unformat_error, line_input);
12398 errmsg ("tunnel src address not specified");
12403 errmsg ("tunnel dst address not specified");
12407 if (grp_set && !ip46_address_is_multicast (&dst))
12409 errmsg ("tunnel group address not multicast");
12412 if (grp_set && mcast_sw_if_index == ~0)
12414 errmsg ("tunnel nonexistent multicast device");
12417 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12419 errmsg ("tunnel dst address must be unicast");
12424 if (ipv4_set && ipv6_set)
12426 errmsg ("both IPv4 and IPv6 addresses specified");
12430 if ((vni == 0) || (vni >> 24))
12432 errmsg ("vni not specified or out of range");
12436 M (GENEVE_ADD_DEL_TUNNEL, mp);
12440 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
12441 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
12445 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
12446 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
12448 mp->encap_vrf_id = ntohl (encap_vrf_id);
12449 mp->decap_next_index = ntohl (decap_next_index);
12450 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12451 mp->vni = ntohl (vni);
12452 mp->is_add = is_add;
12453 mp->is_ipv6 = ipv6_set;
12460 static void vl_api_geneve_tunnel_details_t_handler
12461 (vl_api_geneve_tunnel_details_t * mp)
12463 vat_main_t *vam = &vat_main;
12464 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12465 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12467 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12468 ntohl (mp->sw_if_index),
12469 format_ip46_address, &src, IP46_TYPE_ANY,
12470 format_ip46_address, &dst, IP46_TYPE_ANY,
12471 ntohl (mp->encap_vrf_id),
12472 ntohl (mp->decap_next_index), ntohl (mp->vni),
12473 ntohl (mp->mcast_sw_if_index));
12476 static void vl_api_geneve_tunnel_details_t_handler_json
12477 (vl_api_geneve_tunnel_details_t * mp)
12479 vat_main_t *vam = &vat_main;
12480 vat_json_node_t *node = NULL;
12482 if (VAT_JSON_ARRAY != vam->json_tree.type)
12484 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12485 vat_json_init_array (&vam->json_tree);
12487 node = vat_json_array_add (&vam->json_tree);
12489 vat_json_init_object (node);
12490 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12493 struct in6_addr ip6;
12495 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12496 vat_json_object_add_ip6 (node, "src_address", ip6);
12497 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12498 vat_json_object_add_ip6 (node, "dst_address", ip6);
12502 struct in_addr ip4;
12504 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12505 vat_json_object_add_ip4 (node, "src_address", ip4);
12506 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12507 vat_json_object_add_ip4 (node, "dst_address", ip4);
12509 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12510 vat_json_object_add_uint (node, "decap_next_index",
12511 ntohl (mp->decap_next_index));
12512 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12513 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12514 vat_json_object_add_uint (node, "mcast_sw_if_index",
12515 ntohl (mp->mcast_sw_if_index));
12519 api_geneve_tunnel_dump (vat_main_t * vam)
12521 unformat_input_t *i = vam->input;
12522 vl_api_geneve_tunnel_dump_t *mp;
12523 vl_api_control_ping_t *mp_ping;
12525 u8 sw_if_index_set = 0;
12528 /* Parse args required to build the message */
12529 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12531 if (unformat (i, "sw_if_index %d", &sw_if_index))
12532 sw_if_index_set = 1;
12537 if (sw_if_index_set == 0)
12542 if (!vam->json_output)
12544 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12545 "sw_if_index", "local_address", "remote_address",
12546 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12549 /* Get list of geneve-tunnel interfaces */
12550 M (GENEVE_TUNNEL_DUMP, mp);
12552 mp->sw_if_index = htonl (sw_if_index);
12556 /* Use a control ping for synchronization */
12557 M (CONTROL_PING, mp_ping);
12565 api_gre_tunnel_add_del (vat_main_t * vam)
12567 unformat_input_t *line_input = vam->input;
12568 vl_api_address_t src = { }, dst =
12571 vl_api_gre_tunnel_add_del_t *mp;
12572 vl_api_gre_tunnel_type_t t_type;
12576 u32 outer_fib_id = 0;
12577 u32 session_id = 0;
12581 t_type = GRE_API_TUNNEL_TYPE_L3;
12583 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12585 if (unformat (line_input, "del"))
12587 else if (unformat (line_input, "instance %d", &instance))
12589 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12593 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12597 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
12599 else if (unformat (line_input, "teb"))
12600 t_type = GRE_API_TUNNEL_TYPE_TEB;
12601 else if (unformat (line_input, "erspan %d", &session_id))
12602 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12605 errmsg ("parse error '%U'", format_unformat_error, line_input);
12612 errmsg ("tunnel src address not specified");
12617 errmsg ("tunnel dst address not specified");
12621 M (GRE_TUNNEL_ADD_DEL, mp);
12623 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12624 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12626 mp->tunnel.instance = htonl (instance);
12627 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
12628 mp->is_add = is_add;
12629 mp->tunnel.session_id = htons ((u16) session_id);
12630 mp->tunnel.type = htonl (t_type);
12637 static void vl_api_gre_tunnel_details_t_handler
12638 (vl_api_gre_tunnel_details_t * mp)
12640 vat_main_t *vam = &vat_main;
12642 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12643 ntohl (mp->tunnel.sw_if_index),
12644 ntohl (mp->tunnel.instance),
12645 format_vl_api_address, &mp->tunnel.src,
12646 format_vl_api_address, &mp->tunnel.dst,
12647 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
12648 ntohl (mp->tunnel.session_id));
12651 static void vl_api_gre_tunnel_details_t_handler_json
12652 (vl_api_gre_tunnel_details_t * mp)
12654 vat_main_t *vam = &vat_main;
12655 vat_json_node_t *node = NULL;
12657 if (VAT_JSON_ARRAY != vam->json_tree.type)
12659 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12660 vat_json_init_array (&vam->json_tree);
12662 node = vat_json_array_add (&vam->json_tree);
12664 vat_json_init_object (node);
12665 vat_json_object_add_uint (node, "sw_if_index",
12666 ntohl (mp->tunnel.sw_if_index));
12667 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12669 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12670 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12671 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12672 vat_json_object_add_uint (node, "outer_fib_id",
12673 ntohl (mp->tunnel.outer_fib_id));
12674 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12678 api_gre_tunnel_dump (vat_main_t * vam)
12680 unformat_input_t *i = vam->input;
12681 vl_api_gre_tunnel_dump_t *mp;
12682 vl_api_control_ping_t *mp_ping;
12684 u8 sw_if_index_set = 0;
12687 /* Parse args required to build the message */
12688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12690 if (unformat (i, "sw_if_index %d", &sw_if_index))
12691 sw_if_index_set = 1;
12696 if (sw_if_index_set == 0)
12701 if (!vam->json_output)
12703 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12704 "sw_if_index", "instance", "src_address", "dst_address",
12705 "tunnel_type", "outer_fib_id", "session_id");
12708 /* Get list of gre-tunnel interfaces */
12709 M (GRE_TUNNEL_DUMP, mp);
12711 mp->sw_if_index = htonl (sw_if_index);
12715 /* Use a control ping for synchronization */
12716 MPING (CONTROL_PING, mp_ping);
12724 api_l2_fib_clear_table (vat_main_t * vam)
12726 // unformat_input_t * i = vam->input;
12727 vl_api_l2_fib_clear_table_t *mp;
12730 M (L2_FIB_CLEAR_TABLE, mp);
12738 api_l2_interface_efp_filter (vat_main_t * vam)
12740 unformat_input_t *i = vam->input;
12741 vl_api_l2_interface_efp_filter_t *mp;
12744 u8 sw_if_index_set = 0;
12747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12749 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12750 sw_if_index_set = 1;
12751 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12752 sw_if_index_set = 1;
12753 else if (unformat (i, "enable"))
12755 else if (unformat (i, "disable"))
12759 clib_warning ("parse error '%U'", format_unformat_error, i);
12764 if (sw_if_index_set == 0)
12766 errmsg ("missing sw_if_index");
12770 M (L2_INTERFACE_EFP_FILTER, mp);
12772 mp->sw_if_index = ntohl (sw_if_index);
12773 mp->enable_disable = enable;
12780 #define foreach_vtr_op \
12781 _("disable", L2_VTR_DISABLED) \
12782 _("push-1", L2_VTR_PUSH_1) \
12783 _("push-2", L2_VTR_PUSH_2) \
12784 _("pop-1", L2_VTR_POP_1) \
12785 _("pop-2", L2_VTR_POP_2) \
12786 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12787 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12788 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12789 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12792 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12794 unformat_input_t *i = vam->input;
12795 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12797 u8 sw_if_index_set = 0;
12800 u32 push_dot1q = 1;
12805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12807 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12808 sw_if_index_set = 1;
12809 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12810 sw_if_index_set = 1;
12811 else if (unformat (i, "vtr_op %d", &vtr_op))
12813 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12816 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12818 else if (unformat (i, "tag1 %d", &tag1))
12820 else if (unformat (i, "tag2 %d", &tag2))
12824 clib_warning ("parse error '%U'", format_unformat_error, i);
12829 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12831 errmsg ("missing vtr operation or sw_if_index");
12835 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12836 mp->sw_if_index = ntohl (sw_if_index);
12837 mp->vtr_op = ntohl (vtr_op);
12838 mp->push_dot1q = ntohl (push_dot1q);
12839 mp->tag1 = ntohl (tag1);
12840 mp->tag2 = ntohl (tag2);
12848 api_create_vhost_user_if (vat_main_t * vam)
12850 unformat_input_t *i = vam->input;
12851 vl_api_create_vhost_user_if_t *mp;
12854 u8 file_name_set = 0;
12855 u32 custom_dev_instance = ~0;
12857 u8 use_custom_mac = 0;
12858 u8 disable_mrg_rxbuf = 0;
12859 u8 disable_indirect_desc = 0;
12864 /* Shut up coverity */
12865 clib_memset (hwaddr, 0, sizeof (hwaddr));
12867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12869 if (unformat (i, "socket %s", &file_name))
12873 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12875 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12876 use_custom_mac = 1;
12877 else if (unformat (i, "server"))
12879 else if (unformat (i, "disable_mrg_rxbuf"))
12880 disable_mrg_rxbuf = 1;
12881 else if (unformat (i, "disable_indirect_desc"))
12882 disable_indirect_desc = 1;
12883 else if (unformat (i, "gso"))
12885 else if (unformat (i, "tag %s", &tag))
12891 if (file_name_set == 0)
12893 errmsg ("missing socket file name");
12897 if (vec_len (file_name) > 255)
12899 errmsg ("socket file name too long");
12902 vec_add1 (file_name, 0);
12904 M (CREATE_VHOST_USER_IF, mp);
12906 mp->is_server = is_server;
12907 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12908 mp->disable_indirect_desc = disable_indirect_desc;
12909 mp->enable_gso = enable_gso;
12910 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12911 vec_free (file_name);
12912 if (custom_dev_instance != ~0)
12915 mp->custom_dev_instance = ntohl (custom_dev_instance);
12918 mp->use_custom_mac = use_custom_mac;
12919 clib_memcpy (mp->mac_address, hwaddr, 6);
12921 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12930 api_modify_vhost_user_if (vat_main_t * vam)
12932 unformat_input_t *i = vam->input;
12933 vl_api_modify_vhost_user_if_t *mp;
12936 u8 file_name_set = 0;
12937 u32 custom_dev_instance = ~0;
12938 u8 sw_if_index_set = 0;
12939 u32 sw_if_index = (u32) ~ 0;
12943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12945 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12946 sw_if_index_set = 1;
12947 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12948 sw_if_index_set = 1;
12949 else if (unformat (i, "socket %s", &file_name))
12953 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12955 else if (unformat (i, "server"))
12957 else if (unformat (i, "gso"))
12963 if (sw_if_index_set == 0)
12965 errmsg ("missing sw_if_index or interface name");
12969 if (file_name_set == 0)
12971 errmsg ("missing socket file name");
12975 if (vec_len (file_name) > 255)
12977 errmsg ("socket file name too long");
12980 vec_add1 (file_name, 0);
12982 M (MODIFY_VHOST_USER_IF, mp);
12984 mp->sw_if_index = ntohl (sw_if_index);
12985 mp->is_server = is_server;
12986 mp->enable_gso = enable_gso;
12987 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12988 vec_free (file_name);
12989 if (custom_dev_instance != ~0)
12992 mp->custom_dev_instance = ntohl (custom_dev_instance);
13001 api_delete_vhost_user_if (vat_main_t * vam)
13003 unformat_input_t *i = vam->input;
13004 vl_api_delete_vhost_user_if_t *mp;
13005 u32 sw_if_index = ~0;
13006 u8 sw_if_index_set = 0;
13009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13012 sw_if_index_set = 1;
13013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13014 sw_if_index_set = 1;
13019 if (sw_if_index_set == 0)
13021 errmsg ("missing sw_if_index or interface name");
13026 M (DELETE_VHOST_USER_IF, mp);
13028 mp->sw_if_index = ntohl (sw_if_index);
13035 static void vl_api_sw_interface_vhost_user_details_t_handler
13036 (vl_api_sw_interface_vhost_user_details_t * mp)
13038 vat_main_t *vam = &vat_main;
13040 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13041 (char *) mp->interface_name,
13042 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13043 clib_net_to_host_u64 (mp->features), mp->is_server,
13044 ntohl (mp->num_regions), (char *) mp->sock_filename);
13045 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13048 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13049 (vl_api_sw_interface_vhost_user_details_t * mp)
13051 vat_main_t *vam = &vat_main;
13052 vat_json_node_t *node = NULL;
13054 if (VAT_JSON_ARRAY != vam->json_tree.type)
13056 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13057 vat_json_init_array (&vam->json_tree);
13059 node = vat_json_array_add (&vam->json_tree);
13061 vat_json_init_object (node);
13062 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13063 vat_json_object_add_string_copy (node, "interface_name",
13064 mp->interface_name);
13065 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13066 ntohl (mp->virtio_net_hdr_sz));
13067 vat_json_object_add_uint (node, "features",
13068 clib_net_to_host_u64 (mp->features));
13069 vat_json_object_add_uint (node, "is_server", mp->is_server);
13070 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13071 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13072 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13076 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13078 vl_api_sw_interface_vhost_user_dump_t *mp;
13079 vl_api_control_ping_t *mp_ping;
13082 "Interface name idx hdr_sz features server regions filename");
13084 /* Get list of vhost-user interfaces */
13085 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13088 /* Use a control ping for synchronization */
13089 MPING (CONTROL_PING, mp_ping);
13097 api_show_version (vat_main_t * vam)
13099 vl_api_show_version_t *mp;
13102 M (SHOW_VERSION, mp);
13111 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13113 unformat_input_t *line_input = vam->input;
13114 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13115 ip4_address_t local4, remote4;
13116 ip6_address_t local6, remote6;
13118 u8 ipv4_set = 0, ipv6_set = 0;
13122 u32 mcast_sw_if_index = ~0;
13123 u32 encap_vrf_id = 0;
13124 u32 decap_vrf_id = 0;
13130 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13131 clib_memset (&local4, 0, sizeof local4);
13132 clib_memset (&remote4, 0, sizeof remote4);
13133 clib_memset (&local6, 0, sizeof local6);
13134 clib_memset (&remote6, 0, sizeof remote6);
13136 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13138 if (unformat (line_input, "del"))
13140 else if (unformat (line_input, "local %U",
13141 unformat_ip4_address, &local4))
13146 else if (unformat (line_input, "remote %U",
13147 unformat_ip4_address, &remote4))
13152 else if (unformat (line_input, "local %U",
13153 unformat_ip6_address, &local6))
13158 else if (unformat (line_input, "remote %U",
13159 unformat_ip6_address, &remote6))
13164 else if (unformat (line_input, "group %U %U",
13165 unformat_ip4_address, &remote4,
13166 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13168 grp_set = remote_set = 1;
13171 else if (unformat (line_input, "group %U",
13172 unformat_ip4_address, &remote4))
13174 grp_set = remote_set = 1;
13177 else if (unformat (line_input, "group %U %U",
13178 unformat_ip6_address, &remote6,
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_ip6_address, &remote6))
13187 grp_set = remote_set = 1;
13191 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13193 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13195 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13197 else if (unformat (line_input, "vni %d", &vni))
13199 else if (unformat (line_input, "next-ip4"))
13201 else if (unformat (line_input, "next-ip6"))
13203 else if (unformat (line_input, "next-ethernet"))
13205 else if (unformat (line_input, "next-nsh"))
13209 errmsg ("parse error '%U'", format_unformat_error, line_input);
13214 if (local_set == 0)
13216 errmsg ("tunnel local address not specified");
13219 if (remote_set == 0)
13221 errmsg ("tunnel remote address not specified");
13224 if (grp_set && mcast_sw_if_index == ~0)
13226 errmsg ("tunnel nonexistent multicast device");
13229 if (ipv4_set && ipv6_set)
13231 errmsg ("both IPv4 and IPv6 addresses specified");
13237 errmsg ("vni not specified");
13241 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13246 clib_memcpy (&mp->local, &local6, sizeof (local6));
13247 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13251 clib_memcpy (&mp->local, &local4, sizeof (local4));
13252 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
13255 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13256 mp->encap_vrf_id = ntohl (encap_vrf_id);
13257 mp->decap_vrf_id = ntohl (decap_vrf_id);
13258 mp->protocol = protocol;
13259 mp->vni = ntohl (vni);
13260 mp->is_add = is_add;
13261 mp->is_ipv6 = ipv6_set;
13268 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13269 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13271 vat_main_t *vam = &vat_main;
13272 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
13273 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
13275 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13276 ntohl (mp->sw_if_index),
13277 format_ip46_address, &local, IP46_TYPE_ANY,
13278 format_ip46_address, &remote, IP46_TYPE_ANY,
13279 ntohl (mp->vni), mp->protocol,
13280 ntohl (mp->mcast_sw_if_index),
13281 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13285 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13286 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13288 vat_main_t *vam = &vat_main;
13289 vat_json_node_t *node = NULL;
13290 struct in_addr ip4;
13291 struct in6_addr ip6;
13293 if (VAT_JSON_ARRAY != vam->json_tree.type)
13295 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13296 vat_json_init_array (&vam->json_tree);
13298 node = vat_json_array_add (&vam->json_tree);
13300 vat_json_init_object (node);
13301 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13304 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
13305 vat_json_object_add_ip6 (node, "local", ip6);
13306 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
13307 vat_json_object_add_ip6 (node, "remote", ip6);
13311 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
13312 vat_json_object_add_ip4 (node, "local", ip4);
13313 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
13314 vat_json_object_add_ip4 (node, "remote", ip4);
13316 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13317 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13318 vat_json_object_add_uint (node, "mcast_sw_if_index",
13319 ntohl (mp->mcast_sw_if_index));
13320 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13321 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13322 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13326 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13328 unformat_input_t *i = vam->input;
13329 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13330 vl_api_control_ping_t *mp_ping;
13332 u8 sw_if_index_set = 0;
13335 /* Parse args required to build the message */
13336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13338 if (unformat (i, "sw_if_index %d", &sw_if_index))
13339 sw_if_index_set = 1;
13344 if (sw_if_index_set == 0)
13349 if (!vam->json_output)
13351 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13352 "sw_if_index", "local", "remote", "vni",
13353 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13356 /* Get list of vxlan-tunnel interfaces */
13357 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13359 mp->sw_if_index = htonl (sw_if_index);
13363 /* Use a control ping for synchronization */
13364 MPING (CONTROL_PING, mp_ping);
13371 static void vl_api_l2_fib_table_details_t_handler
13372 (vl_api_l2_fib_table_details_t * mp)
13374 vat_main_t *vam = &vat_main;
13376 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13378 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13379 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13383 static void vl_api_l2_fib_table_details_t_handler_json
13384 (vl_api_l2_fib_table_details_t * mp)
13386 vat_main_t *vam = &vat_main;
13387 vat_json_node_t *node = NULL;
13389 if (VAT_JSON_ARRAY != vam->json_tree.type)
13391 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13392 vat_json_init_array (&vam->json_tree);
13394 node = vat_json_array_add (&vam->json_tree);
13396 vat_json_init_object (node);
13397 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13398 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13399 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13400 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13401 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13402 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13406 api_l2_fib_table_dump (vat_main_t * vam)
13408 unformat_input_t *i = vam->input;
13409 vl_api_l2_fib_table_dump_t *mp;
13410 vl_api_control_ping_t *mp_ping;
13415 /* Parse args required to build the message */
13416 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13418 if (unformat (i, "bd_id %d", &bd_id))
13424 if (bd_id_set == 0)
13426 errmsg ("missing bridge domain");
13430 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13432 /* Get list of l2 fib entries */
13433 M (L2_FIB_TABLE_DUMP, mp);
13435 mp->bd_id = ntohl (bd_id);
13438 /* Use a control ping for synchronization */
13439 MPING (CONTROL_PING, mp_ping);
13448 api_interface_name_renumber (vat_main_t * vam)
13450 unformat_input_t *line_input = vam->input;
13451 vl_api_interface_name_renumber_t *mp;
13452 u32 sw_if_index = ~0;
13453 u32 new_show_dev_instance = ~0;
13456 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13458 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13461 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13463 else if (unformat (line_input, "new_show_dev_instance %d",
13464 &new_show_dev_instance))
13470 if (sw_if_index == ~0)
13472 errmsg ("missing interface name or sw_if_index");
13476 if (new_show_dev_instance == ~0)
13478 errmsg ("missing new_show_dev_instance");
13482 M (INTERFACE_NAME_RENUMBER, mp);
13484 mp->sw_if_index = ntohl (sw_if_index);
13485 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13493 api_ip_probe_neighbor (vat_main_t * vam)
13495 unformat_input_t *i = vam->input;
13496 vl_api_ip_probe_neighbor_t *mp;
13497 vl_api_address_t dst_adr = { };
13503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13505 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13509 else if (unformat (i, "address %U", unformat_vl_api_address, &dst_adr))
13517 errmsg ("missing interface");
13523 errmsg ("missing addresses");
13527 M (IP_PROBE_NEIGHBOR, mp);
13529 mp->sw_if_index = ntohl (sw_if_index);
13530 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
13538 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
13540 unformat_input_t *i = vam->input;
13541 vl_api_ip_scan_neighbor_enable_disable_t *mp;
13542 u8 mode = IP_SCAN_V46_NEIGHBORS;
13543 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
13546 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13548 if (unformat (i, "ip4"))
13549 mode = IP_SCAN_V4_NEIGHBORS;
13550 else if (unformat (i, "ip6"))
13551 mode = IP_SCAN_V6_NEIGHBORS;
13552 if (unformat (i, "both"))
13553 mode = IP_SCAN_V46_NEIGHBORS;
13554 else if (unformat (i, "disable"))
13555 mode = IP_SCAN_DISABLED;
13556 else if (unformat (i, "interval %d", &interval))
13558 else if (unformat (i, "max-time %d", &time))
13560 else if (unformat (i, "max-update %d", &update))
13562 else if (unformat (i, "delay %d", &delay))
13564 else if (unformat (i, "stale %d", &stale))
13570 if (interval > 255)
13572 errmsg ("interval cannot exceed 255 minutes.");
13577 errmsg ("max-time cannot exceed 255 usec.");
13582 errmsg ("max-update cannot exceed 255.");
13587 errmsg ("delay cannot exceed 255 msec.");
13592 errmsg ("stale cannot exceed 255 minutes.");
13596 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
13598 mp->scan_interval = interval;
13599 mp->max_proc_time = time;
13600 mp->max_update = update;
13601 mp->scan_int_delay = delay;
13602 mp->stale_threshold = stale;
13610 api_want_ip4_arp_events (vat_main_t * vam)
13612 unformat_input_t *line_input = vam->input;
13613 vl_api_want_ip4_arp_events_t *mp;
13614 ip4_address_t address;
13615 int address_set = 0;
13616 u32 enable_disable = 1;
13619 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13621 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
13623 else if (unformat (line_input, "del"))
13624 enable_disable = 0;
13629 if (address_set == 0)
13631 errmsg ("missing addresses");
13635 M (WANT_IP4_ARP_EVENTS, mp);
13636 mp->enable_disable = enable_disable;
13637 mp->pid = htonl (getpid ());
13638 clib_memcpy (mp->ip, &address, sizeof (address));
13646 api_want_ip6_nd_events (vat_main_t * vam)
13648 unformat_input_t *line_input = vam->input;
13649 vl_api_want_ip6_nd_events_t *mp;
13650 vl_api_ip6_address_t address;
13651 int address_set = 0;
13652 u32 enable_disable = 1;
13655 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13658 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
13660 else if (unformat (line_input, "del"))
13661 enable_disable = 0;
13666 if (address_set == 0)
13668 errmsg ("missing addresses");
13672 M (WANT_IP6_ND_EVENTS, mp);
13673 mp->enable_disable = enable_disable;
13674 mp->pid = htonl (getpid ());
13675 clib_memcpy (&mp->ip, &address, sizeof (address));
13683 api_want_l2_macs_events (vat_main_t * vam)
13685 unformat_input_t *line_input = vam->input;
13686 vl_api_want_l2_macs_events_t *mp;
13687 u8 enable_disable = 1;
13688 u32 scan_delay = 0;
13689 u32 max_macs_in_event = 0;
13690 u32 learn_limit = 0;
13693 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13695 if (unformat (line_input, "learn-limit %d", &learn_limit))
13697 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13699 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13701 else if (unformat (line_input, "disable"))
13702 enable_disable = 0;
13707 M (WANT_L2_MACS_EVENTS, mp);
13708 mp->enable_disable = enable_disable;
13709 mp->pid = htonl (getpid ());
13710 mp->learn_limit = htonl (learn_limit);
13711 mp->scan_delay = (u8) scan_delay;
13712 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13719 api_input_acl_set_interface (vat_main_t * vam)
13721 unformat_input_t *i = vam->input;
13722 vl_api_input_acl_set_interface_t *mp;
13724 int sw_if_index_set;
13725 u32 ip4_table_index = ~0;
13726 u32 ip6_table_index = ~0;
13727 u32 l2_table_index = ~0;
13731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13733 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13734 sw_if_index_set = 1;
13735 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13736 sw_if_index_set = 1;
13737 else if (unformat (i, "del"))
13739 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13741 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13743 else if (unformat (i, "l2-table %d", &l2_table_index))
13747 clib_warning ("parse error '%U'", format_unformat_error, i);
13752 if (sw_if_index_set == 0)
13754 errmsg ("missing interface name or sw_if_index");
13758 M (INPUT_ACL_SET_INTERFACE, mp);
13760 mp->sw_if_index = ntohl (sw_if_index);
13761 mp->ip4_table_index = ntohl (ip4_table_index);
13762 mp->ip6_table_index = ntohl (ip6_table_index);
13763 mp->l2_table_index = ntohl (l2_table_index);
13764 mp->is_add = is_add;
13772 api_output_acl_set_interface (vat_main_t * vam)
13774 unformat_input_t *i = vam->input;
13775 vl_api_output_acl_set_interface_t *mp;
13777 int sw_if_index_set;
13778 u32 ip4_table_index = ~0;
13779 u32 ip6_table_index = ~0;
13780 u32 l2_table_index = ~0;
13784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13786 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13787 sw_if_index_set = 1;
13788 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13789 sw_if_index_set = 1;
13790 else if (unformat (i, "del"))
13792 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13794 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13796 else if (unformat (i, "l2-table %d", &l2_table_index))
13800 clib_warning ("parse error '%U'", format_unformat_error, i);
13805 if (sw_if_index_set == 0)
13807 errmsg ("missing interface name or sw_if_index");
13811 M (OUTPUT_ACL_SET_INTERFACE, mp);
13813 mp->sw_if_index = ntohl (sw_if_index);
13814 mp->ip4_table_index = ntohl (ip4_table_index);
13815 mp->ip6_table_index = ntohl (ip6_table_index);
13816 mp->l2_table_index = ntohl (l2_table_index);
13817 mp->is_add = is_add;
13825 api_ip_address_dump (vat_main_t * vam)
13827 unformat_input_t *i = vam->input;
13828 vl_api_ip_address_dump_t *mp;
13829 vl_api_control_ping_t *mp_ping;
13830 u32 sw_if_index = ~0;
13831 u8 sw_if_index_set = 0;
13836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13838 if (unformat (i, "sw_if_index %d", &sw_if_index))
13839 sw_if_index_set = 1;
13841 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13842 sw_if_index_set = 1;
13843 else if (unformat (i, "ipv4"))
13845 else if (unformat (i, "ipv6"))
13851 if (ipv4_set && ipv6_set)
13853 errmsg ("ipv4 and ipv6 flags cannot be both set");
13857 if ((!ipv4_set) && (!ipv6_set))
13859 errmsg ("no ipv4 nor ipv6 flag set");
13863 if (sw_if_index_set == 0)
13865 errmsg ("missing interface name or sw_if_index");
13869 vam->current_sw_if_index = sw_if_index;
13870 vam->is_ipv6 = ipv6_set;
13872 M (IP_ADDRESS_DUMP, mp);
13873 mp->sw_if_index = ntohl (sw_if_index);
13874 mp->is_ipv6 = ipv6_set;
13877 /* Use a control ping for synchronization */
13878 MPING (CONTROL_PING, mp_ping);
13886 api_ip_dump (vat_main_t * vam)
13888 vl_api_ip_dump_t *mp;
13889 vl_api_control_ping_t *mp_ping;
13890 unformat_input_t *in = vam->input;
13897 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13899 if (unformat (in, "ipv4"))
13901 else if (unformat (in, "ipv6"))
13907 if (ipv4_set && ipv6_set)
13909 errmsg ("ipv4 and ipv6 flags cannot be both set");
13913 if ((!ipv4_set) && (!ipv6_set))
13915 errmsg ("no ipv4 nor ipv6 flag set");
13919 is_ipv6 = ipv6_set;
13920 vam->is_ipv6 = is_ipv6;
13922 /* free old data */
13923 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13925 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13927 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13930 mp->is_ipv6 = ipv6_set;
13933 /* Use a control ping for synchronization */
13934 MPING (CONTROL_PING, mp_ping);
13942 api_ipsec_spd_add_del (vat_main_t * vam)
13944 unformat_input_t *i = vam->input;
13945 vl_api_ipsec_spd_add_del_t *mp;
13950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13952 if (unformat (i, "spd_id %d", &spd_id))
13954 else if (unformat (i, "del"))
13958 clib_warning ("parse error '%U'", format_unformat_error, i);
13964 errmsg ("spd_id must be set");
13968 M (IPSEC_SPD_ADD_DEL, mp);
13970 mp->spd_id = ntohl (spd_id);
13971 mp->is_add = is_add;
13979 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13981 unformat_input_t *i = vam->input;
13982 vl_api_ipsec_interface_add_del_spd_t *mp;
13984 u8 sw_if_index_set = 0;
13985 u32 spd_id = (u32) ~ 0;
13989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13991 if (unformat (i, "del"))
13993 else if (unformat (i, "spd_id %d", &spd_id))
13996 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13997 sw_if_index_set = 1;
13998 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13999 sw_if_index_set = 1;
14002 clib_warning ("parse error '%U'", format_unformat_error, i);
14008 if (spd_id == (u32) ~ 0)
14010 errmsg ("spd_id must be set");
14014 if (sw_if_index_set == 0)
14016 errmsg ("missing interface name or sw_if_index");
14020 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14022 mp->spd_id = ntohl (spd_id);
14023 mp->sw_if_index = ntohl (sw_if_index);
14024 mp->is_add = is_add;
14032 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14034 unformat_input_t *i = vam->input;
14035 vl_api_ipsec_spd_entry_add_del_t *mp;
14036 u8 is_add = 1, is_outbound = 0;
14037 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14039 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14040 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14041 vl_api_address_t laddr_start = { }, laddr_stop =
14050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14052 if (unformat (i, "del"))
14054 if (unformat (i, "outbound"))
14056 if (unformat (i, "inbound"))
14058 else if (unformat (i, "spd_id %d", &spd_id))
14060 else if (unformat (i, "sa_id %d", &sa_id))
14062 else if (unformat (i, "priority %d", &priority))
14064 else if (unformat (i, "protocol %d", &protocol))
14066 else if (unformat (i, "lport_start %d", &lport_start))
14068 else if (unformat (i, "lport_stop %d", &lport_stop))
14070 else if (unformat (i, "rport_start %d", &rport_start))
14072 else if (unformat (i, "rport_stop %d", &rport_stop))
14074 else if (unformat (i, "laddr_start %U",
14075 unformat_vl_api_address, &laddr_start))
14077 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14080 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14083 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14087 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14089 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14091 clib_warning ("unsupported action: 'resolve'");
14097 clib_warning ("parse error '%U'", format_unformat_error, i);
14103 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14105 mp->is_add = is_add;
14107 mp->entry.spd_id = ntohl (spd_id);
14108 mp->entry.priority = ntohl (priority);
14109 mp->entry.is_outbound = is_outbound;
14111 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14112 sizeof (vl_api_address_t));
14113 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14114 sizeof (vl_api_address_t));
14115 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14116 sizeof (vl_api_address_t));
14117 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14118 sizeof (vl_api_address_t));
14120 mp->entry.protocol = (u8) protocol;
14121 mp->entry.local_port_start = ntohs ((u16) lport_start);
14122 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14123 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14124 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14125 mp->entry.policy = (u8) policy;
14126 mp->entry.sa_id = ntohl (sa_id);
14134 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14136 unformat_input_t *i = vam->input;
14137 vl_api_ipsec_sad_entry_add_del_t *mp;
14138 u32 sad_id = 0, spi = 0;
14139 u8 *ck = 0, *ik = 0;
14142 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14143 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14144 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14145 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14146 vl_api_address_t tun_src, tun_dst;
14149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14151 if (unformat (i, "del"))
14153 else if (unformat (i, "sad_id %d", &sad_id))
14155 else if (unformat (i, "spi %d", &spi))
14157 else if (unformat (i, "esp"))
14158 protocol = IPSEC_API_PROTO_ESP;
14160 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14162 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14163 if (ADDRESS_IP6 == tun_src.af)
14164 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14167 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14169 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14170 if (ADDRESS_IP6 == tun_src.af)
14171 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14174 if (unformat (i, "crypto_alg %U",
14175 unformat_ipsec_api_crypto_alg, &crypto_alg))
14177 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14179 else if (unformat (i, "integ_alg %U",
14180 unformat_ipsec_api_integ_alg, &integ_alg))
14182 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14186 clib_warning ("parse error '%U'", format_unformat_error, i);
14192 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14194 mp->is_add = is_add;
14195 mp->entry.sad_id = ntohl (sad_id);
14196 mp->entry.protocol = protocol;
14197 mp->entry.spi = ntohl (spi);
14198 mp->entry.flags = flags;
14200 mp->entry.crypto_algorithm = crypto_alg;
14201 mp->entry.integrity_algorithm = integ_alg;
14202 mp->entry.crypto_key.length = vec_len (ck);
14203 mp->entry.integrity_key.length = vec_len (ik);
14205 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14206 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14208 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14209 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14212 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14214 clib_memcpy (mp->entry.integrity_key.data, ik,
14215 mp->entry.integrity_key.length);
14217 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14219 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14220 sizeof (mp->entry.tunnel_src));
14221 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14222 sizeof (mp->entry.tunnel_dst));
14231 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
14233 unformat_input_t *i = vam->input;
14234 vl_api_ipsec_tunnel_if_add_del_t *mp;
14235 u32 local_spi = 0, remote_spi = 0;
14236 u32 crypto_alg = 0, integ_alg = 0;
14237 u8 *lck = NULL, *rck = NULL;
14238 u8 *lik = NULL, *rik = NULL;
14239 vl_api_address_t local_ip = { 0 };
14240 vl_api_address_t remote_ip = { 0 };
14244 u8 anti_replay = 0;
14250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14252 if (unformat (i, "del"))
14254 else if (unformat (i, "esn"))
14256 else if (unformat (i, "anti-replay"))
14258 else if (unformat (i, "count %d", &count))
14260 else if (unformat (i, "local_spi %d", &local_spi))
14262 else if (unformat (i, "remote_spi %d", &remote_spi))
14265 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
14268 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
14270 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
14273 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
14275 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
14277 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
14281 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
14283 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
14285 errmsg ("unsupported crypto-alg: '%U'\n",
14286 format_ipsec_crypto_alg, crypto_alg);
14292 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
14294 if (integ_alg >= IPSEC_INTEG_N_ALG)
14296 errmsg ("unsupported integ-alg: '%U'\n",
14297 format_ipsec_integ_alg, integ_alg);
14301 else if (unformat (i, "instance %u", &instance))
14305 errmsg ("parse error '%U'\n", format_unformat_error, i);
14312 /* Turn on async mode */
14313 vam->async_mode = 1;
14314 vam->async_errors = 0;
14315 before = vat_time_now (vam);
14318 for (jj = 0; jj < count; jj++)
14320 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
14322 mp->is_add = is_add;
14324 mp->anti_replay = anti_replay;
14327 increment_address (&remote_ip);
14329 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
14330 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
14332 mp->local_spi = htonl (local_spi + jj);
14333 mp->remote_spi = htonl (remote_spi + jj);
14334 mp->crypto_alg = (u8) crypto_alg;
14336 mp->local_crypto_key_len = 0;
14339 mp->local_crypto_key_len = vec_len (lck);
14340 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
14341 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
14342 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
14345 mp->remote_crypto_key_len = 0;
14348 mp->remote_crypto_key_len = vec_len (rck);
14349 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
14350 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
14351 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
14354 mp->integ_alg = (u8) integ_alg;
14356 mp->local_integ_key_len = 0;
14359 mp->local_integ_key_len = vec_len (lik);
14360 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
14361 mp->local_integ_key_len = sizeof (mp->local_integ_key);
14362 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
14365 mp->remote_integ_key_len = 0;
14368 mp->remote_integ_key_len = vec_len (rik);
14369 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
14370 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
14371 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
14376 mp->renumber = renumber;
14377 mp->show_instance = ntohl (instance);
14382 /* When testing multiple add/del ops, use a control-ping to sync */
14385 vl_api_control_ping_t *mp_ping;
14389 /* Shut off async mode */
14390 vam->async_mode = 0;
14392 MPING (CONTROL_PING, mp_ping);
14395 timeout = vat_time_now (vam) + 1.0;
14396 while (vat_time_now (vam) < timeout)
14397 if (vam->result_ready == 1)
14402 if (vam->retval == -99)
14403 errmsg ("timeout");
14405 if (vam->async_errors > 0)
14407 errmsg ("%d asynchronous errors", vam->async_errors);
14410 vam->async_errors = 0;
14411 after = vat_time_now (vam);
14413 /* slim chance, but we might have eaten SIGTERM on the first iteration */
14417 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
14418 count, after - before, count / (after - before));
14422 /* Wait for a reply... */
14431 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
14433 vat_main_t *vam = &vat_main;
14435 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
14436 "crypto_key %U integ_alg %u integ_key %U flags %x "
14437 "tunnel_src_addr %U tunnel_dst_addr %U "
14438 "salt %u seq_outbound %lu last_seq_inbound %lu "
14439 "replay_window %lu\n",
14440 ntohl (mp->entry.sad_id),
14441 ntohl (mp->sw_if_index),
14442 ntohl (mp->entry.spi),
14443 ntohl (mp->entry.protocol),
14444 ntohl (mp->entry.crypto_algorithm),
14445 format_hex_bytes, mp->entry.crypto_key.data,
14446 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
14447 format_hex_bytes, mp->entry.integrity_key.data,
14448 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14449 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14450 &mp->entry.tunnel_dst, ntohl (mp->salt),
14451 clib_net_to_host_u64 (mp->seq_outbound),
14452 clib_net_to_host_u64 (mp->last_seq_inbound),
14453 clib_net_to_host_u64 (mp->replay_window));
14456 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14457 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14459 static void vl_api_ipsec_sa_details_t_handler_json
14460 (vl_api_ipsec_sa_details_t * mp)
14462 vat_main_t *vam = &vat_main;
14463 vat_json_node_t *node = NULL;
14464 vl_api_ipsec_sad_flags_t flags;
14466 if (VAT_JSON_ARRAY != vam->json_tree.type)
14468 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14469 vat_json_init_array (&vam->json_tree);
14471 node = vat_json_array_add (&vam->json_tree);
14473 vat_json_init_object (node);
14474 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14475 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14476 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14477 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14478 vat_json_object_add_uint (node, "crypto_alg",
14479 ntohl (mp->entry.crypto_algorithm));
14480 vat_json_object_add_uint (node, "integ_alg",
14481 ntohl (mp->entry.integrity_algorithm));
14482 flags = ntohl (mp->entry.flags);
14483 vat_json_object_add_uint (node, "use_esn",
14484 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14485 vat_json_object_add_uint (node, "use_anti_replay",
14486 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14487 vat_json_object_add_uint (node, "is_tunnel",
14488 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14489 vat_json_object_add_uint (node, "is_tunnel_ip6",
14490 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14491 vat_json_object_add_uint (node, "udp_encap",
14492 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14493 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14494 mp->entry.crypto_key.length);
14495 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14496 mp->entry.integrity_key.length);
14497 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14498 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14499 vat_json_object_add_uint (node, "replay_window",
14500 clib_net_to_host_u64 (mp->replay_window));
14504 api_ipsec_sa_dump (vat_main_t * vam)
14506 unformat_input_t *i = vam->input;
14507 vl_api_ipsec_sa_dump_t *mp;
14508 vl_api_control_ping_t *mp_ping;
14512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14514 if (unformat (i, "sa_id %d", &sa_id))
14518 clib_warning ("parse error '%U'", format_unformat_error, i);
14523 M (IPSEC_SA_DUMP, mp);
14525 mp->sa_id = ntohl (sa_id);
14529 /* Use a control ping for synchronization */
14530 M (CONTROL_PING, mp_ping);
14538 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14540 unformat_input_t *i = vam->input;
14541 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14542 u32 sw_if_index = ~0;
14544 u8 is_outbound = (u8) ~ 0;
14547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14549 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14551 else if (unformat (i, "sa_id %d", &sa_id))
14553 else if (unformat (i, "outbound"))
14555 else if (unformat (i, "inbound"))
14559 clib_warning ("parse error '%U'", format_unformat_error, i);
14564 if (sw_if_index == ~0)
14566 errmsg ("interface must be specified");
14572 errmsg ("SA ID must be specified");
14576 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14578 mp->sw_if_index = htonl (sw_if_index);
14579 mp->sa_id = htonl (sa_id);
14580 mp->is_outbound = is_outbound;
14589 api_get_first_msg_id (vat_main_t * vam)
14591 vl_api_get_first_msg_id_t *mp;
14592 unformat_input_t *i = vam->input;
14597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14599 if (unformat (i, "client %s", &name))
14607 errmsg ("missing client name");
14610 vec_add1 (name, 0);
14612 if (vec_len (name) > 63)
14614 errmsg ("client name too long");
14618 M (GET_FIRST_MSG_ID, mp);
14619 clib_memcpy (mp->name, name, vec_len (name));
14626 api_cop_interface_enable_disable (vat_main_t * vam)
14628 unformat_input_t *line_input = vam->input;
14629 vl_api_cop_interface_enable_disable_t *mp;
14630 u32 sw_if_index = ~0;
14631 u8 enable_disable = 1;
14634 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14636 if (unformat (line_input, "disable"))
14637 enable_disable = 0;
14638 if (unformat (line_input, "enable"))
14639 enable_disable = 1;
14640 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14641 vam, &sw_if_index))
14643 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14649 if (sw_if_index == ~0)
14651 errmsg ("missing interface name or sw_if_index");
14655 /* Construct the API message */
14656 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14657 mp->sw_if_index = ntohl (sw_if_index);
14658 mp->enable_disable = enable_disable;
14662 /* Wait for the reply */
14668 api_cop_whitelist_enable_disable (vat_main_t * vam)
14670 unformat_input_t *line_input = vam->input;
14671 vl_api_cop_whitelist_enable_disable_t *mp;
14672 u32 sw_if_index = ~0;
14673 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14677 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14679 if (unformat (line_input, "ip4"))
14681 else if (unformat (line_input, "ip6"))
14683 else if (unformat (line_input, "default"))
14685 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14686 vam, &sw_if_index))
14688 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14690 else if (unformat (line_input, "fib-id %d", &fib_id))
14696 if (sw_if_index == ~0)
14698 errmsg ("missing interface name or sw_if_index");
14702 /* Construct the API message */
14703 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14704 mp->sw_if_index = ntohl (sw_if_index);
14705 mp->fib_id = ntohl (fib_id);
14708 mp->default_cop = default_cop;
14712 /* Wait for the reply */
14718 api_get_node_graph (vat_main_t * vam)
14720 vl_api_get_node_graph_t *mp;
14723 M (GET_NODE_GRAPH, mp);
14727 /* Wait for the reply */
14733 /** Used for parsing LISP eids */
14734 typedef CLIB_PACKED(struct{
14735 u8 addr[16]; /**< eid address */
14736 u32 len; /**< prefix length if IP */
14737 u8 type; /**< type of eid */
14742 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14744 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14746 clib_memset (a, 0, sizeof (a[0]));
14748 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14750 a->type = 0; /* ipv4 type */
14752 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14754 a->type = 1; /* ipv6 type */
14756 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14758 a->type = 2; /* mac type */
14760 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14762 a->type = 3; /* NSH type */
14763 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14764 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14771 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14780 lisp_eid_size_vat (u8 type)
14797 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14799 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14803 api_one_add_del_locator_set (vat_main_t * vam)
14805 unformat_input_t *input = vam->input;
14806 vl_api_one_add_del_locator_set_t *mp;
14808 u8 *locator_set_name = NULL;
14809 u8 locator_set_name_set = 0;
14810 vl_api_local_locator_t locator, *locators = 0;
14811 u32 sw_if_index, priority, weight;
14815 /* Parse args required to build the message */
14816 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14818 if (unformat (input, "del"))
14822 else if (unformat (input, "locator-set %s", &locator_set_name))
14824 locator_set_name_set = 1;
14826 else if (unformat (input, "sw_if_index %u p %u w %u",
14827 &sw_if_index, &priority, &weight))
14829 locator.sw_if_index = htonl (sw_if_index);
14830 locator.priority = priority;
14831 locator.weight = weight;
14832 vec_add1 (locators, locator);
14836 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14837 &sw_if_index, &priority, &weight))
14839 locator.sw_if_index = htonl (sw_if_index);
14840 locator.priority = priority;
14841 locator.weight = weight;
14842 vec_add1 (locators, locator);
14848 if (locator_set_name_set == 0)
14850 errmsg ("missing locator-set name");
14851 vec_free (locators);
14855 if (vec_len (locator_set_name) > 64)
14857 errmsg ("locator-set name too long");
14858 vec_free (locator_set_name);
14859 vec_free (locators);
14862 vec_add1 (locator_set_name, 0);
14864 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14866 /* Construct the API message */
14867 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14869 mp->is_add = is_add;
14870 clib_memcpy (mp->locator_set_name, locator_set_name,
14871 vec_len (locator_set_name));
14872 vec_free (locator_set_name);
14874 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14876 clib_memcpy (mp->locators, locators, data_len);
14877 vec_free (locators);
14882 /* Wait for a reply... */
14887 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14890 api_one_add_del_locator (vat_main_t * vam)
14892 unformat_input_t *input = vam->input;
14893 vl_api_one_add_del_locator_t *mp;
14894 u32 tmp_if_index = ~0;
14895 u32 sw_if_index = ~0;
14896 u8 sw_if_index_set = 0;
14897 u8 sw_if_index_if_name_set = 0;
14899 u8 priority_set = 0;
14903 u8 *locator_set_name = NULL;
14904 u8 locator_set_name_set = 0;
14907 /* Parse args required to build the message */
14908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14910 if (unformat (input, "del"))
14914 else if (unformat (input, "locator-set %s", &locator_set_name))
14916 locator_set_name_set = 1;
14918 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14921 sw_if_index_if_name_set = 1;
14922 sw_if_index = tmp_if_index;
14924 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14926 sw_if_index_set = 1;
14927 sw_if_index = tmp_if_index;
14929 else if (unformat (input, "p %d", &priority))
14933 else if (unformat (input, "w %d", &weight))
14941 if (locator_set_name_set == 0)
14943 errmsg ("missing locator-set name");
14947 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14949 errmsg ("missing sw_if_index");
14950 vec_free (locator_set_name);
14954 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14956 errmsg ("cannot use both params interface name and sw_if_index");
14957 vec_free (locator_set_name);
14961 if (priority_set == 0)
14963 errmsg ("missing locator-set priority");
14964 vec_free (locator_set_name);
14968 if (weight_set == 0)
14970 errmsg ("missing locator-set weight");
14971 vec_free (locator_set_name);
14975 if (vec_len (locator_set_name) > 64)
14977 errmsg ("locator-set name too long");
14978 vec_free (locator_set_name);
14981 vec_add1 (locator_set_name, 0);
14983 /* Construct the API message */
14984 M (ONE_ADD_DEL_LOCATOR, mp);
14986 mp->is_add = is_add;
14987 mp->sw_if_index = ntohl (sw_if_index);
14988 mp->priority = priority;
14989 mp->weight = weight;
14990 clib_memcpy (mp->locator_set_name, locator_set_name,
14991 vec_len (locator_set_name));
14992 vec_free (locator_set_name);
14997 /* Wait for a reply... */
15002 #define api_lisp_add_del_locator api_one_add_del_locator
15005 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15007 u32 *key_id = va_arg (*args, u32 *);
15010 if (unformat (input, "%s", &s))
15012 if (!strcmp ((char *) s, "sha1"))
15013 key_id[0] = HMAC_SHA_1_96;
15014 else if (!strcmp ((char *) s, "sha256"))
15015 key_id[0] = HMAC_SHA_256_128;
15018 clib_warning ("invalid key_id: '%s'", s);
15019 key_id[0] = HMAC_NO_KEY;
15030 api_one_add_del_local_eid (vat_main_t * vam)
15032 unformat_input_t *input = vam->input;
15033 vl_api_one_add_del_local_eid_t *mp;
15036 lisp_eid_vat_t _eid, *eid = &_eid;
15037 u8 *locator_set_name = 0;
15038 u8 locator_set_name_set = 0;
15044 /* Parse args required to build the message */
15045 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15047 if (unformat (input, "del"))
15051 else if (unformat (input, "vni %d", &vni))
15055 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15059 else if (unformat (input, "locator-set %s", &locator_set_name))
15061 locator_set_name_set = 1;
15063 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15065 else if (unformat (input, "secret-key %_%v%_", &key))
15071 if (locator_set_name_set == 0)
15073 errmsg ("missing locator-set name");
15079 errmsg ("EID address not set!");
15080 vec_free (locator_set_name);
15084 if (key && (0 == key_id))
15086 errmsg ("invalid key_id!");
15090 if (vec_len (key) > 64)
15092 errmsg ("key too long");
15097 if (vec_len (locator_set_name) > 64)
15099 errmsg ("locator-set name too long");
15100 vec_free (locator_set_name);
15103 vec_add1 (locator_set_name, 0);
15105 /* Construct the API message */
15106 M (ONE_ADD_DEL_LOCAL_EID, mp);
15108 mp->is_add = is_add;
15109 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15110 mp->eid_type = eid->type;
15111 mp->prefix_len = eid->len;
15112 mp->vni = clib_host_to_net_u32 (vni);
15113 mp->key_id = clib_host_to_net_u16 (key_id);
15114 clib_memcpy (mp->locator_set_name, locator_set_name,
15115 vec_len (locator_set_name));
15116 clib_memcpy (mp->key, key, vec_len (key));
15118 vec_free (locator_set_name);
15124 /* Wait for a reply... */
15129 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15132 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15134 u32 dp_table = 0, vni = 0;;
15135 unformat_input_t *input = vam->input;
15136 vl_api_gpe_add_del_fwd_entry_t *mp;
15138 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15139 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15140 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15141 u32 action = ~0, w;
15142 ip4_address_t rmt_rloc4, lcl_rloc4;
15143 ip6_address_t rmt_rloc6, lcl_rloc6;
15144 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15147 clib_memset (&rloc, 0, sizeof (rloc));
15149 /* Parse args required to build the message */
15150 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15152 if (unformat (input, "del"))
15154 else if (unformat (input, "add"))
15156 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15160 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15164 else if (unformat (input, "vrf %d", &dp_table))
15166 else if (unformat (input, "bd %d", &dp_table))
15168 else if (unformat (input, "vni %d", &vni))
15170 else if (unformat (input, "w %d", &w))
15174 errmsg ("No RLOC configured for setting priority/weight!");
15177 curr_rloc->weight = w;
15179 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15180 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15184 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15186 vec_add1 (lcl_locs, rloc);
15188 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15189 vec_add1 (rmt_locs, rloc);
15190 /* weight saved in rmt loc */
15191 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15193 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15194 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15197 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15199 vec_add1 (lcl_locs, rloc);
15201 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
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, "action %d", &action))
15212 clib_warning ("parse error '%U'", format_unformat_error, input);
15219 errmsg ("remote eid addresses not set");
15223 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15225 errmsg ("eid types don't match");
15229 if (0 == rmt_locs && (u32) ~ 0 == action)
15231 errmsg ("action not set for negative mapping");
15235 /* Construct the API message */
15236 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15237 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15239 mp->is_add = is_add;
15240 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15241 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15242 mp->eid_type = rmt_eid->type;
15243 mp->dp_table = clib_host_to_net_u32 (dp_table);
15244 mp->vni = clib_host_to_net_u32 (vni);
15245 mp->rmt_len = rmt_eid->len;
15246 mp->lcl_len = lcl_eid->len;
15247 mp->action = action;
15249 if (0 != rmt_locs && 0 != lcl_locs)
15251 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15252 clib_memcpy (mp->locs, lcl_locs,
15253 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15255 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15256 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15257 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15259 vec_free (lcl_locs);
15260 vec_free (rmt_locs);
15265 /* Wait for a reply... */
15271 api_one_add_del_map_server (vat_main_t * vam)
15273 unformat_input_t *input = vam->input;
15274 vl_api_one_add_del_map_server_t *mp;
15278 ip4_address_t ipv4;
15279 ip6_address_t ipv6;
15282 /* Parse args required to build the message */
15283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15285 if (unformat (input, "del"))
15289 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15293 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15301 if (ipv4_set && ipv6_set)
15303 errmsg ("both eid v4 and v6 addresses set");
15307 if (!ipv4_set && !ipv6_set)
15309 errmsg ("eid addresses not set");
15313 /* Construct the API message */
15314 M (ONE_ADD_DEL_MAP_SERVER, mp);
15316 mp->is_add = is_add;
15320 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15325 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15331 /* Wait for a reply... */
15336 #define api_lisp_add_del_map_server api_one_add_del_map_server
15339 api_one_add_del_map_resolver (vat_main_t * vam)
15341 unformat_input_t *input = vam->input;
15342 vl_api_one_add_del_map_resolver_t *mp;
15346 ip4_address_t ipv4;
15347 ip6_address_t ipv6;
15350 /* Parse args required to build the message */
15351 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15353 if (unformat (input, "del"))
15357 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15361 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15369 if (ipv4_set && ipv6_set)
15371 errmsg ("both eid v4 and v6 addresses set");
15375 if (!ipv4_set && !ipv6_set)
15377 errmsg ("eid addresses not set");
15381 /* Construct the API message */
15382 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15384 mp->is_add = is_add;
15388 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15393 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15399 /* Wait for a reply... */
15404 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15407 api_lisp_gpe_enable_disable (vat_main_t * vam)
15409 unformat_input_t *input = vam->input;
15410 vl_api_gpe_enable_disable_t *mp;
15415 /* Parse args required to build the message */
15416 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15418 if (unformat (input, "enable"))
15423 else if (unformat (input, "disable"))
15434 errmsg ("Value not set");
15438 /* Construct the API message */
15439 M (GPE_ENABLE_DISABLE, mp);
15446 /* Wait for a reply... */
15452 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15454 unformat_input_t *input = vam->input;
15455 vl_api_one_rloc_probe_enable_disable_t *mp;
15460 /* Parse args required to build the message */
15461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15463 if (unformat (input, "enable"))
15468 else if (unformat (input, "disable"))
15476 errmsg ("Value not set");
15480 /* Construct the API message */
15481 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15483 mp->is_enabled = is_en;
15488 /* Wait for a reply... */
15493 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15496 api_one_map_register_enable_disable (vat_main_t * vam)
15498 unformat_input_t *input = vam->input;
15499 vl_api_one_map_register_enable_disable_t *mp;
15504 /* Parse args required to build the message */
15505 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15507 if (unformat (input, "enable"))
15512 else if (unformat (input, "disable"))
15520 errmsg ("Value not set");
15524 /* Construct the API message */
15525 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15527 mp->is_enabled = is_en;
15532 /* Wait for a reply... */
15537 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15540 api_one_enable_disable (vat_main_t * vam)
15542 unformat_input_t *input = vam->input;
15543 vl_api_one_enable_disable_t *mp;
15548 /* Parse args required to build the message */
15549 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15551 if (unformat (input, "enable"))
15556 else if (unformat (input, "disable"))
15566 errmsg ("Value not set");
15570 /* Construct the API message */
15571 M (ONE_ENABLE_DISABLE, mp);
15578 /* Wait for a reply... */
15583 #define api_lisp_enable_disable api_one_enable_disable
15586 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15588 unformat_input_t *input = vam->input;
15589 vl_api_one_enable_disable_xtr_mode_t *mp;
15594 /* Parse args required to build the message */
15595 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15597 if (unformat (input, "enable"))
15602 else if (unformat (input, "disable"))
15612 errmsg ("Value not set");
15616 /* Construct the API message */
15617 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15624 /* Wait for a reply... */
15630 api_one_show_xtr_mode (vat_main_t * vam)
15632 vl_api_one_show_xtr_mode_t *mp;
15635 /* Construct the API message */
15636 M (ONE_SHOW_XTR_MODE, mp);
15641 /* Wait for a reply... */
15647 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15649 unformat_input_t *input = vam->input;
15650 vl_api_one_enable_disable_pitr_mode_t *mp;
15655 /* Parse args required to build the message */
15656 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15658 if (unformat (input, "enable"))
15663 else if (unformat (input, "disable"))
15673 errmsg ("Value not set");
15677 /* Construct the API message */
15678 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15685 /* Wait for a reply... */
15691 api_one_show_pitr_mode (vat_main_t * vam)
15693 vl_api_one_show_pitr_mode_t *mp;
15696 /* Construct the API message */
15697 M (ONE_SHOW_PITR_MODE, mp);
15702 /* Wait for a reply... */
15708 api_one_enable_disable_petr_mode (vat_main_t * vam)
15710 unformat_input_t *input = vam->input;
15711 vl_api_one_enable_disable_petr_mode_t *mp;
15716 /* Parse args required to build the message */
15717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15719 if (unformat (input, "enable"))
15724 else if (unformat (input, "disable"))
15734 errmsg ("Value not set");
15738 /* Construct the API message */
15739 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15746 /* Wait for a reply... */
15752 api_one_show_petr_mode (vat_main_t * vam)
15754 vl_api_one_show_petr_mode_t *mp;
15757 /* Construct the API message */
15758 M (ONE_SHOW_PETR_MODE, mp);
15763 /* Wait for a reply... */
15769 api_show_one_map_register_state (vat_main_t * vam)
15771 vl_api_show_one_map_register_state_t *mp;
15774 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15779 /* wait for reply */
15784 #define api_show_lisp_map_register_state api_show_one_map_register_state
15787 api_show_one_rloc_probe_state (vat_main_t * vam)
15789 vl_api_show_one_rloc_probe_state_t *mp;
15792 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15797 /* wait for reply */
15802 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15805 api_one_add_del_ndp_entry (vat_main_t * vam)
15807 vl_api_one_add_del_ndp_entry_t *mp;
15808 unformat_input_t *input = vam->input;
15813 u8 mac[6] = { 0, };
15814 u8 ip6[16] = { 0, };
15818 /* Parse args required to build the message */
15819 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15821 if (unformat (input, "del"))
15823 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15825 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15827 else if (unformat (input, "bd %d", &bd))
15831 errmsg ("parse error '%U'", format_unformat_error, input);
15836 if (!bd_set || !ip_set || (!mac_set && is_add))
15838 errmsg ("Missing BD, IP or MAC!");
15842 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15843 mp->is_add = is_add;
15844 clib_memcpy (mp->mac, mac, 6);
15845 mp->bd = clib_host_to_net_u32 (bd);
15846 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15851 /* wait for reply */
15857 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15859 vl_api_one_add_del_l2_arp_entry_t *mp;
15860 unformat_input_t *input = vam->input;
15865 u8 mac[6] = { 0, };
15866 u32 ip4 = 0, bd = ~0;
15869 /* Parse args required to build the message */
15870 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15872 if (unformat (input, "del"))
15874 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15876 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15878 else if (unformat (input, "bd %d", &bd))
15882 errmsg ("parse error '%U'", format_unformat_error, input);
15887 if (!bd_set || !ip_set || (!mac_set && is_add))
15889 errmsg ("Missing BD, IP or MAC!");
15893 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15894 mp->is_add = is_add;
15895 clib_memcpy (mp->mac, mac, 6);
15896 mp->bd = clib_host_to_net_u32 (bd);
15902 /* wait for reply */
15908 api_one_ndp_bd_get (vat_main_t * vam)
15910 vl_api_one_ndp_bd_get_t *mp;
15913 M (ONE_NDP_BD_GET, mp);
15918 /* wait for reply */
15924 api_one_ndp_entries_get (vat_main_t * vam)
15926 vl_api_one_ndp_entries_get_t *mp;
15927 unformat_input_t *input = vam->input;
15932 /* Parse args required to build the message */
15933 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15935 if (unformat (input, "bd %d", &bd))
15939 errmsg ("parse error '%U'", format_unformat_error, input);
15946 errmsg ("Expected bridge domain!");
15950 M (ONE_NDP_ENTRIES_GET, mp);
15951 mp->bd = clib_host_to_net_u32 (bd);
15956 /* wait for reply */
15962 api_one_l2_arp_bd_get (vat_main_t * vam)
15964 vl_api_one_l2_arp_bd_get_t *mp;
15967 M (ONE_L2_ARP_BD_GET, mp);
15972 /* wait for reply */
15978 api_one_l2_arp_entries_get (vat_main_t * vam)
15980 vl_api_one_l2_arp_entries_get_t *mp;
15981 unformat_input_t *input = vam->input;
15986 /* Parse args required to build the message */
15987 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15989 if (unformat (input, "bd %d", &bd))
15993 errmsg ("parse error '%U'", format_unformat_error, input);
16000 errmsg ("Expected bridge domain!");
16004 M (ONE_L2_ARP_ENTRIES_GET, mp);
16005 mp->bd = clib_host_to_net_u32 (bd);
16010 /* wait for reply */
16016 api_one_stats_enable_disable (vat_main_t * vam)
16018 vl_api_one_stats_enable_disable_t *mp;
16019 unformat_input_t *input = vam->input;
16024 /* Parse args required to build the message */
16025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16027 if (unformat (input, "enable"))
16032 else if (unformat (input, "disable"))
16042 errmsg ("Value not set");
16046 M (ONE_STATS_ENABLE_DISABLE, mp);
16052 /* wait for reply */
16058 api_show_one_stats_enable_disable (vat_main_t * vam)
16060 vl_api_show_one_stats_enable_disable_t *mp;
16063 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16068 /* wait for reply */
16074 api_show_one_map_request_mode (vat_main_t * vam)
16076 vl_api_show_one_map_request_mode_t *mp;
16079 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16084 /* wait for reply */
16089 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16092 api_one_map_request_mode (vat_main_t * vam)
16094 unformat_input_t *input = vam->input;
16095 vl_api_one_map_request_mode_t *mp;
16099 /* Parse args required to build the message */
16100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16102 if (unformat (input, "dst-only"))
16104 else if (unformat (input, "src-dst"))
16108 errmsg ("parse error '%U'", format_unformat_error, input);
16113 M (ONE_MAP_REQUEST_MODE, mp);
16120 /* wait for reply */
16125 #define api_lisp_map_request_mode api_one_map_request_mode
16128 * Enable/disable ONE proxy ITR.
16130 * @param vam vpp API test context
16131 * @return return code
16134 api_one_pitr_set_locator_set (vat_main_t * vam)
16136 u8 ls_name_set = 0;
16137 unformat_input_t *input = vam->input;
16138 vl_api_one_pitr_set_locator_set_t *mp;
16143 /* Parse args required to build the message */
16144 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16146 if (unformat (input, "del"))
16148 else if (unformat (input, "locator-set %s", &ls_name))
16152 errmsg ("parse error '%U'", format_unformat_error, input);
16159 errmsg ("locator-set name not set!");
16163 M (ONE_PITR_SET_LOCATOR_SET, mp);
16165 mp->is_add = is_add;
16166 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16167 vec_free (ls_name);
16172 /* wait for reply */
16177 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
16180 api_one_nsh_set_locator_set (vat_main_t * vam)
16182 u8 ls_name_set = 0;
16183 unformat_input_t *input = vam->input;
16184 vl_api_one_nsh_set_locator_set_t *mp;
16189 /* Parse args required to build the message */
16190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16192 if (unformat (input, "del"))
16194 else if (unformat (input, "ls %s", &ls_name))
16198 errmsg ("parse error '%U'", format_unformat_error, input);
16203 if (!ls_name_set && is_add)
16205 errmsg ("locator-set name not set!");
16209 M (ONE_NSH_SET_LOCATOR_SET, mp);
16211 mp->is_add = is_add;
16212 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16213 vec_free (ls_name);
16218 /* wait for reply */
16224 api_show_one_pitr (vat_main_t * vam)
16226 vl_api_show_one_pitr_t *mp;
16229 if (!vam->json_output)
16231 print (vam->ofp, "%=20s", "lisp status:");
16234 M (SHOW_ONE_PITR, mp);
16238 /* Wait for a reply... */
16243 #define api_show_lisp_pitr api_show_one_pitr
16246 api_one_use_petr (vat_main_t * vam)
16248 unformat_input_t *input = vam->input;
16249 vl_api_one_use_petr_t *mp;
16254 clib_memset (&ip, 0, sizeof (ip));
16256 /* Parse args required to build the message */
16257 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16259 if (unformat (input, "disable"))
16262 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16265 ip_addr_version (&ip) = IP4;
16268 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16271 ip_addr_version (&ip) = IP6;
16275 errmsg ("parse error '%U'", format_unformat_error, input);
16280 M (ONE_USE_PETR, mp);
16282 mp->is_add = is_add;
16285 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16287 clib_memcpy (mp->address, &ip, 4);
16289 clib_memcpy (mp->address, &ip, 16);
16295 /* wait for reply */
16300 #define api_lisp_use_petr api_one_use_petr
16303 api_show_one_nsh_mapping (vat_main_t * vam)
16305 vl_api_show_one_use_petr_t *mp;
16308 if (!vam->json_output)
16310 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16313 M (SHOW_ONE_NSH_MAPPING, mp);
16317 /* Wait for a reply... */
16323 api_show_one_use_petr (vat_main_t * vam)
16325 vl_api_show_one_use_petr_t *mp;
16328 if (!vam->json_output)
16330 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16333 M (SHOW_ONE_USE_PETR, mp);
16337 /* Wait for a reply... */
16342 #define api_show_lisp_use_petr api_show_one_use_petr
16345 * Add/delete mapping between vni and vrf
16348 api_one_eid_table_add_del_map (vat_main_t * vam)
16350 unformat_input_t *input = vam->input;
16351 vl_api_one_eid_table_add_del_map_t *mp;
16352 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16353 u32 vni, vrf, bd_index;
16356 /* Parse args required to build the message */
16357 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16359 if (unformat (input, "del"))
16361 else if (unformat (input, "vrf %d", &vrf))
16363 else if (unformat (input, "bd_index %d", &bd_index))
16365 else if (unformat (input, "vni %d", &vni))
16371 if (!vni_set || (!vrf_set && !bd_index_set))
16373 errmsg ("missing arguments!");
16377 if (vrf_set && bd_index_set)
16379 errmsg ("error: both vrf and bd entered!");
16383 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16385 mp->is_add = is_add;
16386 mp->vni = htonl (vni);
16387 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16388 mp->is_l2 = bd_index_set;
16393 /* wait for reply */
16398 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16401 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16403 u32 *action = va_arg (*args, u32 *);
16406 if (unformat (input, "%s", &s))
16408 if (!strcmp ((char *) s, "no-action"))
16410 else if (!strcmp ((char *) s, "natively-forward"))
16412 else if (!strcmp ((char *) s, "send-map-request"))
16414 else if (!strcmp ((char *) s, "drop"))
16418 clib_warning ("invalid action: '%s'", s);
16430 * Add/del remote mapping to/from ONE control plane
16432 * @param vam vpp API test context
16433 * @return return code
16436 api_one_add_del_remote_mapping (vat_main_t * vam)
16438 unformat_input_t *input = vam->input;
16439 vl_api_one_add_del_remote_mapping_t *mp;
16441 lisp_eid_vat_t _eid, *eid = &_eid;
16442 lisp_eid_vat_t _seid, *seid = &_seid;
16443 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16444 u32 action = ~0, p, w, data_len;
16445 ip4_address_t rloc4;
16446 ip6_address_t rloc6;
16447 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16450 clib_memset (&rloc, 0, sizeof (rloc));
16452 /* Parse args required to build the message */
16453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16455 if (unformat (input, "del-all"))
16459 else if (unformat (input, "del"))
16463 else if (unformat (input, "add"))
16467 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16471 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16475 else if (unformat (input, "vni %d", &vni))
16479 else if (unformat (input, "p %d w %d", &p, &w))
16483 errmsg ("No RLOC configured for setting priority/weight!");
16486 curr_rloc->priority = p;
16487 curr_rloc->weight = w;
16489 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16492 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16493 vec_add1 (rlocs, rloc);
16494 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16496 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16499 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16500 vec_add1 (rlocs, rloc);
16501 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16503 else if (unformat (input, "action %U",
16504 unformat_negative_mapping_action, &action))
16510 clib_warning ("parse error '%U'", format_unformat_error, input);
16517 errmsg ("missing params!");
16521 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16523 errmsg ("no action set for negative map-reply!");
16527 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16529 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16530 mp->is_add = is_add;
16531 mp->vni = htonl (vni);
16532 mp->action = (u8) action;
16533 mp->is_src_dst = seid_set;
16534 mp->eid_len = eid->len;
16535 mp->seid_len = seid->len;
16536 mp->del_all = del_all;
16537 mp->eid_type = eid->type;
16538 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16539 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16541 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16542 clib_memcpy (mp->rlocs, rlocs, data_len);
16548 /* Wait for a reply... */
16553 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16556 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16557 * forwarding entries in data-plane accordingly.
16559 * @param vam vpp API test context
16560 * @return return code
16563 api_one_add_del_adjacency (vat_main_t * vam)
16565 unformat_input_t *input = vam->input;
16566 vl_api_one_add_del_adjacency_t *mp;
16568 ip4_address_t leid4, reid4;
16569 ip6_address_t leid6, reid6;
16570 u8 reid_mac[6] = { 0 };
16571 u8 leid_mac[6] = { 0 };
16572 u8 reid_type, leid_type;
16573 u32 leid_len = 0, reid_len = 0, len;
16577 leid_type = reid_type = (u8) ~ 0;
16579 /* Parse args required to build the message */
16580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16582 if (unformat (input, "del"))
16586 else if (unformat (input, "add"))
16590 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16593 reid_type = 0; /* ipv4 */
16596 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16599 reid_type = 1; /* ipv6 */
16602 else if (unformat (input, "reid %U", unformat_ethernet_address,
16605 reid_type = 2; /* mac */
16607 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16610 leid_type = 0; /* ipv4 */
16613 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16616 leid_type = 1; /* ipv6 */
16619 else if (unformat (input, "leid %U", unformat_ethernet_address,
16622 leid_type = 2; /* mac */
16624 else if (unformat (input, "vni %d", &vni))
16630 errmsg ("parse error '%U'", format_unformat_error, input);
16635 if ((u8) ~ 0 == reid_type)
16637 errmsg ("missing params!");
16641 if (leid_type != reid_type)
16643 errmsg ("remote and local EIDs are of different types!");
16647 M (ONE_ADD_DEL_ADJACENCY, mp);
16648 mp->is_add = is_add;
16649 mp->vni = htonl (vni);
16650 mp->leid_len = leid_len;
16651 mp->reid_len = reid_len;
16652 mp->eid_type = reid_type;
16654 switch (mp->eid_type)
16657 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16658 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16661 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16662 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16665 clib_memcpy (mp->leid, leid_mac, 6);
16666 clib_memcpy (mp->reid, reid_mac, 6);
16669 errmsg ("unknown EID type %d!", mp->eid_type);
16676 /* Wait for a reply... */
16681 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16684 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16686 u32 *mode = va_arg (*args, u32 *);
16688 if (unformat (input, "lisp"))
16690 else if (unformat (input, "vxlan"))
16699 api_gpe_get_encap_mode (vat_main_t * vam)
16701 vl_api_gpe_get_encap_mode_t *mp;
16704 /* Construct the API message */
16705 M (GPE_GET_ENCAP_MODE, mp);
16710 /* Wait for a reply... */
16716 api_gpe_set_encap_mode (vat_main_t * vam)
16718 unformat_input_t *input = vam->input;
16719 vl_api_gpe_set_encap_mode_t *mp;
16723 /* Parse args required to build the message */
16724 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16726 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16732 /* Construct the API message */
16733 M (GPE_SET_ENCAP_MODE, mp);
16740 /* Wait for a reply... */
16746 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16748 unformat_input_t *input = vam->input;
16749 vl_api_gpe_add_del_iface_t *mp;
16750 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16751 u32 dp_table = 0, vni = 0;
16754 /* Parse args required to build the message */
16755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16757 if (unformat (input, "up"))
16762 else if (unformat (input, "down"))
16767 else if (unformat (input, "table_id %d", &dp_table))
16771 else if (unformat (input, "bd_id %d", &dp_table))
16776 else if (unformat (input, "vni %d", &vni))
16784 if (action_set == 0)
16786 errmsg ("Action not set");
16789 if (dp_table_set == 0 || vni_set == 0)
16791 errmsg ("vni and dp_table must be set");
16795 /* Construct the API message */
16796 M (GPE_ADD_DEL_IFACE, mp);
16798 mp->is_add = is_add;
16799 mp->dp_table = clib_host_to_net_u32 (dp_table);
16801 mp->vni = clib_host_to_net_u32 (vni);
16806 /* Wait for a reply... */
16812 api_one_map_register_fallback_threshold (vat_main_t * vam)
16814 unformat_input_t *input = vam->input;
16815 vl_api_one_map_register_fallback_threshold_t *mp;
16820 /* Parse args required to build the message */
16821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16823 if (unformat (input, "%u", &value))
16827 clib_warning ("parse error '%U'", format_unformat_error, input);
16834 errmsg ("fallback threshold value is missing!");
16838 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16839 mp->value = clib_host_to_net_u32 (value);
16844 /* Wait for a reply... */
16850 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16852 vl_api_show_one_map_register_fallback_threshold_t *mp;
16855 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16860 /* Wait for a reply... */
16866 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16868 u32 *proto = va_arg (*args, u32 *);
16870 if (unformat (input, "udp"))
16872 else if (unformat (input, "api"))
16881 api_one_set_transport_protocol (vat_main_t * vam)
16883 unformat_input_t *input = vam->input;
16884 vl_api_one_set_transport_protocol_t *mp;
16889 /* Parse args required to build the message */
16890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16892 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16896 clib_warning ("parse error '%U'", format_unformat_error, input);
16903 errmsg ("Transport protocol missing!");
16907 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16908 mp->protocol = (u8) protocol;
16913 /* Wait for a reply... */
16919 api_one_get_transport_protocol (vat_main_t * vam)
16921 vl_api_one_get_transport_protocol_t *mp;
16924 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16929 /* Wait for a reply... */
16935 api_one_map_register_set_ttl (vat_main_t * vam)
16937 unformat_input_t *input = vam->input;
16938 vl_api_one_map_register_set_ttl_t *mp;
16943 /* Parse args required to build the message */
16944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16946 if (unformat (input, "%u", &ttl))
16950 clib_warning ("parse error '%U'", format_unformat_error, input);
16957 errmsg ("TTL value missing!");
16961 M (ONE_MAP_REGISTER_SET_TTL, mp);
16962 mp->ttl = clib_host_to_net_u32 (ttl);
16967 /* Wait for a reply... */
16973 api_show_one_map_register_ttl (vat_main_t * vam)
16975 vl_api_show_one_map_register_ttl_t *mp;
16978 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16983 /* Wait for a reply... */
16989 * Add/del map request itr rlocs from ONE control plane and updates
16991 * @param vam vpp API test context
16992 * @return return code
16995 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16997 unformat_input_t *input = vam->input;
16998 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16999 u8 *locator_set_name = 0;
17000 u8 locator_set_name_set = 0;
17004 /* Parse args required to build the message */
17005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17007 if (unformat (input, "del"))
17011 else if (unformat (input, "%_%v%_", &locator_set_name))
17013 locator_set_name_set = 1;
17017 clib_warning ("parse error '%U'", format_unformat_error, input);
17022 if (is_add && !locator_set_name_set)
17024 errmsg ("itr-rloc is not set!");
17028 if (is_add && vec_len (locator_set_name) > 64)
17030 errmsg ("itr-rloc locator-set name too long");
17031 vec_free (locator_set_name);
17035 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17036 mp->is_add = is_add;
17039 clib_memcpy (mp->locator_set_name, locator_set_name,
17040 vec_len (locator_set_name));
17044 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17046 vec_free (locator_set_name);
17051 /* Wait for a reply... */
17056 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17059 api_one_locator_dump (vat_main_t * vam)
17061 unformat_input_t *input = vam->input;
17062 vl_api_one_locator_dump_t *mp;
17063 vl_api_control_ping_t *mp_ping;
17064 u8 is_index_set = 0, is_name_set = 0;
17069 /* Parse args required to build the message */
17070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17072 if (unformat (input, "ls_name %_%v%_", &ls_name))
17076 else if (unformat (input, "ls_index %d", &ls_index))
17082 errmsg ("parse error '%U'", format_unformat_error, input);
17087 if (!is_index_set && !is_name_set)
17089 errmsg ("error: expected one of index or name!");
17093 if (is_index_set && is_name_set)
17095 errmsg ("error: only one param expected!");
17099 if (vec_len (ls_name) > 62)
17101 errmsg ("error: locator set name too long!");
17105 if (!vam->json_output)
17107 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17110 M (ONE_LOCATOR_DUMP, mp);
17111 mp->is_index_set = is_index_set;
17114 mp->ls_index = clib_host_to_net_u32 (ls_index);
17117 vec_add1 (ls_name, 0);
17118 strncpy ((char *) mp->ls_name, (char *) ls_name,
17119 sizeof (mp->ls_name) - 1);
17125 /* Use a control ping for synchronization */
17126 MPING (CONTROL_PING, mp_ping);
17129 /* Wait for a reply... */
17134 #define api_lisp_locator_dump api_one_locator_dump
17137 api_one_locator_set_dump (vat_main_t * vam)
17139 vl_api_one_locator_set_dump_t *mp;
17140 vl_api_control_ping_t *mp_ping;
17141 unformat_input_t *input = vam->input;
17145 /* Parse args required to build the message */
17146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17148 if (unformat (input, "local"))
17152 else if (unformat (input, "remote"))
17158 errmsg ("parse error '%U'", format_unformat_error, input);
17163 if (!vam->json_output)
17165 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17168 M (ONE_LOCATOR_SET_DUMP, mp);
17170 mp->filter = filter;
17175 /* Use a control ping for synchronization */
17176 MPING (CONTROL_PING, mp_ping);
17179 /* Wait for a reply... */
17184 #define api_lisp_locator_set_dump api_one_locator_set_dump
17187 api_one_eid_table_map_dump (vat_main_t * vam)
17191 unformat_input_t *input = vam->input;
17192 vl_api_one_eid_table_map_dump_t *mp;
17193 vl_api_control_ping_t *mp_ping;
17196 /* Parse args required to build the message */
17197 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17199 if (unformat (input, "l2"))
17204 else if (unformat (input, "l3"))
17211 errmsg ("parse error '%U'", format_unformat_error, input);
17218 errmsg ("expected one of 'l2' or 'l3' parameter!");
17222 if (!vam->json_output)
17224 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
17227 M (ONE_EID_TABLE_MAP_DUMP, mp);
17233 /* Use a control ping for synchronization */
17234 MPING (CONTROL_PING, mp_ping);
17237 /* Wait for a reply... */
17242 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
17245 api_one_eid_table_vni_dump (vat_main_t * vam)
17247 vl_api_one_eid_table_vni_dump_t *mp;
17248 vl_api_control_ping_t *mp_ping;
17251 if (!vam->json_output)
17253 print (vam->ofp, "VNI");
17256 M (ONE_EID_TABLE_VNI_DUMP, mp);
17261 /* Use a control ping for synchronization */
17262 MPING (CONTROL_PING, mp_ping);
17265 /* Wait for a reply... */
17270 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
17273 api_one_eid_table_dump (vat_main_t * vam)
17275 unformat_input_t *i = vam->input;
17276 vl_api_one_eid_table_dump_t *mp;
17277 vl_api_control_ping_t *mp_ping;
17278 struct in_addr ip4;
17279 struct in6_addr ip6;
17281 u8 eid_type = ~0, eid_set = 0;
17282 u32 prefix_length = ~0, t, vni = 0;
17285 lisp_nsh_api_t nsh;
17287 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17289 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
17295 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
17301 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
17306 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
17311 else if (unformat (i, "vni %d", &t))
17315 else if (unformat (i, "local"))
17319 else if (unformat (i, "remote"))
17325 errmsg ("parse error '%U'", format_unformat_error, i);
17330 if (!vam->json_output)
17332 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17333 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17336 M (ONE_EID_TABLE_DUMP, mp);
17338 mp->filter = filter;
17342 mp->vni = htonl (vni);
17343 mp->eid_type = eid_type;
17347 mp->prefix_length = prefix_length;
17348 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17351 mp->prefix_length = prefix_length;
17352 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17355 clib_memcpy (mp->eid, mac, sizeof (mac));
17358 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17361 errmsg ("unknown EID type %d!", eid_type);
17369 /* Use a control ping for synchronization */
17370 MPING (CONTROL_PING, mp_ping);
17373 /* Wait for a reply... */
17378 #define api_lisp_eid_table_dump api_one_eid_table_dump
17381 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17383 unformat_input_t *i = vam->input;
17384 vl_api_gpe_fwd_entries_get_t *mp;
17389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17391 if (unformat (i, "vni %d", &vni))
17397 errmsg ("parse error '%U'", format_unformat_error, i);
17404 errmsg ("vni not set!");
17408 if (!vam->json_output)
17410 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17414 M (GPE_FWD_ENTRIES_GET, mp);
17415 mp->vni = clib_host_to_net_u32 (vni);
17420 /* Wait for a reply... */
17425 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17426 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17427 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17428 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17429 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17430 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17431 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17432 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17435 api_one_adjacencies_get (vat_main_t * vam)
17437 unformat_input_t *i = vam->input;
17438 vl_api_one_adjacencies_get_t *mp;
17443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17445 if (unformat (i, "vni %d", &vni))
17451 errmsg ("parse error '%U'", format_unformat_error, i);
17458 errmsg ("vni not set!");
17462 if (!vam->json_output)
17464 print (vam->ofp, "%s %40s", "leid", "reid");
17467 M (ONE_ADJACENCIES_GET, mp);
17468 mp->vni = clib_host_to_net_u32 (vni);
17473 /* Wait for a reply... */
17478 #define api_lisp_adjacencies_get api_one_adjacencies_get
17481 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17483 unformat_input_t *i = vam->input;
17484 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17486 u8 ip_family_set = 0, is_ip4 = 1;
17488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17490 if (unformat (i, "ip4"))
17495 else if (unformat (i, "ip6"))
17502 errmsg ("parse error '%U'", format_unformat_error, i);
17507 if (!ip_family_set)
17509 errmsg ("ip family not set!");
17513 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17514 mp->is_ip4 = is_ip4;
17519 /* Wait for a reply... */
17525 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17527 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17530 if (!vam->json_output)
17532 print (vam->ofp, "VNIs");
17535 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17540 /* Wait for a reply... */
17546 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17548 unformat_input_t *i = vam->input;
17549 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17551 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17552 struct in_addr ip4;
17553 struct in6_addr ip6;
17554 u32 table_id = 0, nh_sw_if_index = ~0;
17556 clib_memset (&ip4, 0, sizeof (ip4));
17557 clib_memset (&ip6, 0, sizeof (ip6));
17559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17561 if (unformat (i, "del"))
17563 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17564 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17569 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17570 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17575 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17579 nh_sw_if_index = ~0;
17581 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17585 nh_sw_if_index = ~0;
17587 else if (unformat (i, "table %d", &table_id))
17591 errmsg ("parse error '%U'", format_unformat_error, i);
17598 errmsg ("nh addr not set!");
17602 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17603 mp->is_add = is_add;
17604 mp->table_id = clib_host_to_net_u32 (table_id);
17605 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17606 mp->is_ip4 = is_ip4;
17608 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17610 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17615 /* Wait for a reply... */
17621 api_one_map_server_dump (vat_main_t * vam)
17623 vl_api_one_map_server_dump_t *mp;
17624 vl_api_control_ping_t *mp_ping;
17627 if (!vam->json_output)
17629 print (vam->ofp, "%=20s", "Map server");
17632 M (ONE_MAP_SERVER_DUMP, mp);
17636 /* Use a control ping for synchronization */
17637 MPING (CONTROL_PING, mp_ping);
17640 /* Wait for a reply... */
17645 #define api_lisp_map_server_dump api_one_map_server_dump
17648 api_one_map_resolver_dump (vat_main_t * vam)
17650 vl_api_one_map_resolver_dump_t *mp;
17651 vl_api_control_ping_t *mp_ping;
17654 if (!vam->json_output)
17656 print (vam->ofp, "%=20s", "Map resolver");
17659 M (ONE_MAP_RESOLVER_DUMP, mp);
17663 /* Use a control ping for synchronization */
17664 MPING (CONTROL_PING, mp_ping);
17667 /* Wait for a reply... */
17672 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17675 api_one_stats_flush (vat_main_t * vam)
17677 vl_api_one_stats_flush_t *mp;
17680 M (ONE_STATS_FLUSH, mp);
17687 api_one_stats_dump (vat_main_t * vam)
17689 vl_api_one_stats_dump_t *mp;
17690 vl_api_control_ping_t *mp_ping;
17693 M (ONE_STATS_DUMP, mp);
17697 /* Use a control ping for synchronization */
17698 MPING (CONTROL_PING, mp_ping);
17701 /* Wait for a reply... */
17707 api_show_one_status (vat_main_t * vam)
17709 vl_api_show_one_status_t *mp;
17712 if (!vam->json_output)
17714 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17717 M (SHOW_ONE_STATUS, mp);
17720 /* Wait for a reply... */
17725 #define api_show_lisp_status api_show_one_status
17728 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17730 vl_api_gpe_fwd_entry_path_dump_t *mp;
17731 vl_api_control_ping_t *mp_ping;
17732 unformat_input_t *i = vam->input;
17733 u32 fwd_entry_index = ~0;
17736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17738 if (unformat (i, "index %d", &fwd_entry_index))
17744 if (~0 == fwd_entry_index)
17746 errmsg ("no index specified!");
17750 if (!vam->json_output)
17752 print (vam->ofp, "first line");
17755 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17759 /* Use a control ping for synchronization */
17760 MPING (CONTROL_PING, mp_ping);
17763 /* Wait for a reply... */
17769 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17771 vl_api_one_get_map_request_itr_rlocs_t *mp;
17774 if (!vam->json_output)
17776 print (vam->ofp, "%=20s", "itr-rlocs:");
17779 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17782 /* Wait for a reply... */
17787 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17790 api_af_packet_create (vat_main_t * vam)
17792 unformat_input_t *i = vam->input;
17793 vl_api_af_packet_create_t *mp;
17794 u8 *host_if_name = 0;
17796 u8 random_hw_addr = 1;
17799 clib_memset (hw_addr, 0, sizeof (hw_addr));
17801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17803 if (unformat (i, "name %s", &host_if_name))
17804 vec_add1 (host_if_name, 0);
17805 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17806 random_hw_addr = 0;
17811 if (!vec_len (host_if_name))
17813 errmsg ("host-interface name must be specified");
17817 if (vec_len (host_if_name) > 64)
17819 errmsg ("host-interface name too long");
17823 M (AF_PACKET_CREATE, mp);
17825 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17826 clib_memcpy (mp->hw_addr, hw_addr, 6);
17827 mp->use_random_hw_addr = random_hw_addr;
17828 vec_free (host_if_name);
17836 fprintf (vam->ofp ? vam->ofp : stderr,
17837 " new sw_if_index = %d\n", vam->sw_if_index);
17844 api_af_packet_delete (vat_main_t * vam)
17846 unformat_input_t *i = vam->input;
17847 vl_api_af_packet_delete_t *mp;
17848 u8 *host_if_name = 0;
17851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17853 if (unformat (i, "name %s", &host_if_name))
17854 vec_add1 (host_if_name, 0);
17859 if (!vec_len (host_if_name))
17861 errmsg ("host-interface name must be specified");
17865 if (vec_len (host_if_name) > 64)
17867 errmsg ("host-interface name too long");
17871 M (AF_PACKET_DELETE, mp);
17873 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17874 vec_free (host_if_name);
17881 static void vl_api_af_packet_details_t_handler
17882 (vl_api_af_packet_details_t * mp)
17884 vat_main_t *vam = &vat_main;
17886 print (vam->ofp, "%-16s %d",
17887 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17890 static void vl_api_af_packet_details_t_handler_json
17891 (vl_api_af_packet_details_t * mp)
17893 vat_main_t *vam = &vat_main;
17894 vat_json_node_t *node = NULL;
17896 if (VAT_JSON_ARRAY != vam->json_tree.type)
17898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17899 vat_json_init_array (&vam->json_tree);
17901 node = vat_json_array_add (&vam->json_tree);
17903 vat_json_init_object (node);
17904 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17905 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17909 api_af_packet_dump (vat_main_t * vam)
17911 vl_api_af_packet_dump_t *mp;
17912 vl_api_control_ping_t *mp_ping;
17915 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17916 /* Get list of tap interfaces */
17917 M (AF_PACKET_DUMP, mp);
17920 /* Use a control ping for synchronization */
17921 MPING (CONTROL_PING, mp_ping);
17929 api_policer_add_del (vat_main_t * vam)
17931 unformat_input_t *i = vam->input;
17932 vl_api_policer_add_del_t *mp;
17942 u8 color_aware = 0;
17943 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17946 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17947 conform_action.dscp = 0;
17948 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17949 exceed_action.dscp = 0;
17950 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17951 violate_action.dscp = 0;
17953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17955 if (unformat (i, "del"))
17957 else if (unformat (i, "name %s", &name))
17958 vec_add1 (name, 0);
17959 else if (unformat (i, "cir %u", &cir))
17961 else if (unformat (i, "eir %u", &eir))
17963 else if (unformat (i, "cb %u", &cb))
17965 else if (unformat (i, "eb %u", &eb))
17967 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17970 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17973 else if (unformat (i, "type %U", unformat_policer_type, &type))
17975 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17978 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17981 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17984 else if (unformat (i, "color-aware"))
17990 if (!vec_len (name))
17992 errmsg ("policer name must be specified");
17996 if (vec_len (name) > 64)
17998 errmsg ("policer name too long");
18002 M (POLICER_ADD_DEL, mp);
18004 clib_memcpy (mp->name, name, vec_len (name));
18006 mp->is_add = is_add;
18007 mp->cir = ntohl (cir);
18008 mp->eir = ntohl (eir);
18009 mp->cb = clib_net_to_host_u64 (cb);
18010 mp->eb = clib_net_to_host_u64 (eb);
18011 mp->rate_type = rate_type;
18012 mp->round_type = round_type;
18014 mp->conform_action_type = conform_action.action_type;
18015 mp->conform_dscp = conform_action.dscp;
18016 mp->exceed_action_type = exceed_action.action_type;
18017 mp->exceed_dscp = exceed_action.dscp;
18018 mp->violate_action_type = violate_action.action_type;
18019 mp->violate_dscp = violate_action.dscp;
18020 mp->color_aware = color_aware;
18028 api_policer_dump (vat_main_t * vam)
18030 unformat_input_t *i = vam->input;
18031 vl_api_policer_dump_t *mp;
18032 vl_api_control_ping_t *mp_ping;
18033 u8 *match_name = 0;
18034 u8 match_name_valid = 0;
18037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18039 if (unformat (i, "name %s", &match_name))
18041 vec_add1 (match_name, 0);
18042 match_name_valid = 1;
18048 M (POLICER_DUMP, mp);
18049 mp->match_name_valid = match_name_valid;
18050 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18051 vec_free (match_name);
18055 /* Use a control ping for synchronization */
18056 MPING (CONTROL_PING, mp_ping);
18059 /* Wait for a reply... */
18065 api_policer_classify_set_interface (vat_main_t * vam)
18067 unformat_input_t *i = vam->input;
18068 vl_api_policer_classify_set_interface_t *mp;
18070 int sw_if_index_set;
18071 u32 ip4_table_index = ~0;
18072 u32 ip6_table_index = ~0;
18073 u32 l2_table_index = ~0;
18077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18079 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18080 sw_if_index_set = 1;
18081 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18082 sw_if_index_set = 1;
18083 else if (unformat (i, "del"))
18085 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18087 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18089 else if (unformat (i, "l2-table %d", &l2_table_index))
18093 clib_warning ("parse error '%U'", format_unformat_error, i);
18098 if (sw_if_index_set == 0)
18100 errmsg ("missing interface name or sw_if_index");
18104 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18106 mp->sw_if_index = ntohl (sw_if_index);
18107 mp->ip4_table_index = ntohl (ip4_table_index);
18108 mp->ip6_table_index = ntohl (ip6_table_index);
18109 mp->l2_table_index = ntohl (l2_table_index);
18110 mp->is_add = is_add;
18118 api_policer_classify_dump (vat_main_t * vam)
18120 unformat_input_t *i = vam->input;
18121 vl_api_policer_classify_dump_t *mp;
18122 vl_api_control_ping_t *mp_ping;
18123 u8 type = POLICER_CLASSIFY_N_TABLES;
18126 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18130 errmsg ("classify table type must be specified");
18134 if (!vam->json_output)
18136 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18139 M (POLICER_CLASSIFY_DUMP, mp);
18144 /* Use a control ping for synchronization */
18145 MPING (CONTROL_PING, mp_ping);
18148 /* Wait for a reply... */
18154 api_netmap_create (vat_main_t * vam)
18156 unformat_input_t *i = vam->input;
18157 vl_api_netmap_create_t *mp;
18160 u8 random_hw_addr = 1;
18165 clib_memset (hw_addr, 0, sizeof (hw_addr));
18167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18169 if (unformat (i, "name %s", &if_name))
18170 vec_add1 (if_name, 0);
18171 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18172 random_hw_addr = 0;
18173 else if (unformat (i, "pipe"))
18175 else if (unformat (i, "master"))
18177 else if (unformat (i, "slave"))
18183 if (!vec_len (if_name))
18185 errmsg ("interface name must be specified");
18189 if (vec_len (if_name) > 64)
18191 errmsg ("interface name too long");
18195 M (NETMAP_CREATE, mp);
18197 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18198 clib_memcpy (mp->hw_addr, hw_addr, 6);
18199 mp->use_random_hw_addr = random_hw_addr;
18200 mp->is_pipe = is_pipe;
18201 mp->is_master = is_master;
18202 vec_free (if_name);
18210 api_netmap_delete (vat_main_t * vam)
18212 unformat_input_t *i = vam->input;
18213 vl_api_netmap_delete_t *mp;
18217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18219 if (unformat (i, "name %s", &if_name))
18220 vec_add1 (if_name, 0);
18225 if (!vec_len (if_name))
18227 errmsg ("interface name must be specified");
18231 if (vec_len (if_name) > 64)
18233 errmsg ("interface name too long");
18237 M (NETMAP_DELETE, mp);
18239 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
18240 vec_free (if_name);
18248 format_fib_api_path_nh_proto (u8 * s, va_list * args)
18250 vl_api_fib_path_nh_proto_t proto =
18251 va_arg (*args, vl_api_fib_path_nh_proto_t);
18255 case FIB_API_PATH_NH_PROTO_IP4:
18256 s = format (s, "ip4");
18258 case FIB_API_PATH_NH_PROTO_IP6:
18259 s = format (s, "ip6");
18261 case FIB_API_PATH_NH_PROTO_MPLS:
18262 s = format (s, "mpls");
18264 case FIB_API_PATH_NH_PROTO_BIER:
18265 s = format (s, "bier");
18267 case FIB_API_PATH_NH_PROTO_ETHERNET:
18268 s = format (s, "ethernet");
18276 format_vl_api_ip_address_union (u8 * s, va_list * args)
18278 vl_api_address_family_t af = va_arg (*args, vl_api_address_family_t);
18279 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
18284 s = format (s, "%U", format_ip4_address, u->ip4);
18287 s = format (s, "%U", format_ip6_address, u->ip6);
18294 format_vl_api_fib_path_type (u8 * s, va_list * args)
18296 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
18300 case FIB_API_PATH_TYPE_NORMAL:
18301 s = format (s, "normal");
18303 case FIB_API_PATH_TYPE_LOCAL:
18304 s = format (s, "local");
18306 case FIB_API_PATH_TYPE_DROP:
18307 s = format (s, "drop");
18309 case FIB_API_PATH_TYPE_UDP_ENCAP:
18310 s = format (s, "udp-encap");
18312 case FIB_API_PATH_TYPE_BIER_IMP:
18313 s = format (s, "bier-imp");
18315 case FIB_API_PATH_TYPE_ICMP_UNREACH:
18316 s = format (s, "unreach");
18318 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
18319 s = format (s, "prohibit");
18321 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
18322 s = format (s, "src-lookup");
18324 case FIB_API_PATH_TYPE_DVR:
18325 s = format (s, "dvr");
18327 case FIB_API_PATH_TYPE_INTERFACE_RX:
18328 s = format (s, "interface-rx");
18330 case FIB_API_PATH_TYPE_CLASSIFY:
18331 s = format (s, "classify");
18339 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
18342 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
18343 ntohl (fp->weight), ntohl (fp->sw_if_index),
18344 format_vl_api_fib_path_type, fp->type,
18345 format_fib_api_path_nh_proto, fp->proto,
18346 format_vl_api_ip_address_union, &fp->nh.address);
18350 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
18351 vl_api_fib_path_t * fp)
18353 struct in_addr ip4;
18354 struct in6_addr ip6;
18356 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18357 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18358 vat_json_object_add_uint (node, "type", fp->type);
18359 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
18360 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18362 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
18363 vat_json_object_add_ip4 (node, "next_hop", ip4);
18365 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
18367 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
18368 vat_json_object_add_ip6 (node, "next_hop", ip6);
18373 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
18375 vat_main_t *vam = &vat_main;
18376 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18377 vl_api_fib_path_t *fp;
18380 print (vam->ofp, "sw_if_index %d via:",
18381 ntohl (mp->mt_tunnel.mt_sw_if_index));
18382 fp = mp->mt_tunnel.mt_paths;
18383 for (i = 0; i < count; i++)
18385 vl_api_fib_path_print (vam, fp);
18389 print (vam->ofp, "");
18392 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
18393 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
18396 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
18398 vat_main_t *vam = &vat_main;
18399 vat_json_node_t *node = NULL;
18400 int count = ntohl (mp->mt_tunnel.mt_n_paths);
18401 vl_api_fib_path_t *fp;
18404 if (VAT_JSON_ARRAY != vam->json_tree.type)
18406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18407 vat_json_init_array (&vam->json_tree);
18409 node = vat_json_array_add (&vam->json_tree);
18411 vat_json_init_object (node);
18412 vat_json_object_add_uint (node, "sw_if_index",
18413 ntohl (mp->mt_tunnel.mt_sw_if_index));
18415 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
18417 fp = mp->mt_tunnel.mt_paths;
18418 for (i = 0; i < count; i++)
18420 vl_api_mpls_fib_path_json_print (node, fp);
18426 api_mpls_tunnel_dump (vat_main_t * vam)
18428 vl_api_mpls_tunnel_dump_t *mp;
18429 vl_api_control_ping_t *mp_ping;
18432 M (MPLS_TUNNEL_DUMP, mp);
18436 /* Use a control ping for synchronization */
18437 MPING (CONTROL_PING, mp_ping);
18444 #define vl_api_mpls_table_details_t_endian vl_noop_handler
18445 #define vl_api_mpls_table_details_t_print vl_noop_handler
18449 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
18451 vat_main_t *vam = &vat_main;
18453 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
18456 static void vl_api_mpls_table_details_t_handler_json
18457 (vl_api_mpls_table_details_t * mp)
18459 vat_main_t *vam = &vat_main;
18460 vat_json_node_t *node = NULL;
18462 if (VAT_JSON_ARRAY != vam->json_tree.type)
18464 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18465 vat_json_init_array (&vam->json_tree);
18467 node = vat_json_array_add (&vam->json_tree);
18469 vat_json_init_object (node);
18470 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
18474 api_mpls_table_dump (vat_main_t * vam)
18476 vl_api_mpls_table_dump_t *mp;
18477 vl_api_control_ping_t *mp_ping;
18480 M (MPLS_TABLE_DUMP, mp);
18483 /* Use a control ping for synchronization */
18484 MPING (CONTROL_PING, mp_ping);
18491 #define vl_api_mpls_route_details_t_endian vl_noop_handler
18492 #define vl_api_mpls_route_details_t_print vl_noop_handler
18495 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
18497 vat_main_t *vam = &vat_main;
18498 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
18499 vl_api_fib_path_t *fp;
18503 "table-id %d, label %u, ess_bit %u",
18504 ntohl (mp->mr_route.mr_table_id),
18505 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
18506 fp = mp->mr_route.mr_paths;
18507 for (i = 0; i < count; i++)
18509 vl_api_fib_path_print (vam, fp);
18514 static void vl_api_mpls_route_details_t_handler_json
18515 (vl_api_mpls_route_details_t * mp)
18517 vat_main_t *vam = &vat_main;
18518 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
18519 vat_json_node_t *node = NULL;
18520 vl_api_fib_path_t *fp;
18523 if (VAT_JSON_ARRAY != vam->json_tree.type)
18525 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18526 vat_json_init_array (&vam->json_tree);
18528 node = vat_json_array_add (&vam->json_tree);
18530 vat_json_init_object (node);
18531 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
18532 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
18533 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
18534 vat_json_object_add_uint (node, "path_count", count);
18535 fp = mp->mr_route.mr_paths;
18536 for (i = 0; i < count; i++)
18538 vl_api_mpls_fib_path_json_print (node, fp);
18544 api_mpls_route_dump (vat_main_t * vam)
18546 unformat_input_t *input = vam->input;
18547 vl_api_mpls_route_dump_t *mp;
18548 vl_api_control_ping_t *mp_ping;
18552 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18554 if (unformat (input, "table_id %d", &table_id))
18559 if (table_id == ~0)
18561 errmsg ("missing table id");
18565 M (MPLS_ROUTE_DUMP, mp);
18567 mp->table.mt_table_id = ntohl (table_id);
18570 /* Use a control ping for synchronization */
18571 MPING (CONTROL_PING, mp_ping);
18578 #define vl_api_ip_table_details_t_endian vl_noop_handler
18579 #define vl_api_ip_table_details_t_print vl_noop_handler
18582 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
18584 vat_main_t *vam = &vat_main;
18587 "%s; table-id %d, prefix %U/%d",
18588 mp->table.name, ntohl (mp->table.table_id));
18592 static void vl_api_ip_table_details_t_handler_json
18593 (vl_api_ip_table_details_t * mp)
18595 vat_main_t *vam = &vat_main;
18596 vat_json_node_t *node = NULL;
18598 if (VAT_JSON_ARRAY != vam->json_tree.type)
18600 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18601 vat_json_init_array (&vam->json_tree);
18603 node = vat_json_array_add (&vam->json_tree);
18605 vat_json_init_object (node);
18606 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18610 api_ip_table_dump (vat_main_t * vam)
18612 vl_api_ip_table_dump_t *mp;
18613 vl_api_control_ping_t *mp_ping;
18616 M (IP_TABLE_DUMP, mp);
18619 /* Use a control ping for synchronization */
18620 MPING (CONTROL_PING, mp_ping);
18628 api_ip_mtable_dump (vat_main_t * vam)
18630 vl_api_ip_mtable_dump_t *mp;
18631 vl_api_control_ping_t *mp_ping;
18634 M (IP_MTABLE_DUMP, mp);
18637 /* Use a control ping for synchronization */
18638 MPING (CONTROL_PING, mp_ping);
18646 api_ip_mroute_dump (vat_main_t * vam)
18648 unformat_input_t *input = vam->input;
18649 vl_api_control_ping_t *mp_ping;
18650 vl_api_ip_mroute_dump_t *mp;
18655 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18657 if (unformat (input, "table_id %d", &table_id))
18659 else if (unformat (input, "ip6"))
18661 else if (unformat (input, "ip4"))
18666 if (table_id == ~0)
18668 errmsg ("missing table id");
18672 M (IP_MROUTE_DUMP, mp);
18673 mp->table.table_id = table_id;
18674 mp->table.is_ip6 = is_ip6;
18677 /* Use a control ping for synchronization */
18678 MPING (CONTROL_PING, mp_ping);
18685 static void vl_api_ip_neighbor_details_t_handler
18686 (vl_api_ip_neighbor_details_t * mp)
18688 vat_main_t *vam = &vat_main;
18690 print (vam->ofp, "%c %U %U",
18691 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
18692 format_vl_api_mac_address, &mp->neighbor.mac_address,
18693 format_vl_api_address, &mp->neighbor.ip_address);
18696 static void vl_api_ip_neighbor_details_t_handler_json
18697 (vl_api_ip_neighbor_details_t * mp)
18700 vat_main_t *vam = &vat_main;
18701 vat_json_node_t *node;
18703 if (VAT_JSON_ARRAY != vam->json_tree.type)
18705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18706 vat_json_init_array (&vam->json_tree);
18708 node = vat_json_array_add (&vam->json_tree);
18710 vat_json_init_object (node);
18711 vat_json_object_add_string_copy
18713 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
18714 (u8 *) "static" : (u8 *) "dynamic"));
18716 vat_json_object_add_string_copy (node, "link_layer",
18717 format (0, "%U", format_vl_api_mac_address,
18718 &mp->neighbor.mac_address));
18719 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
18723 api_ip_neighbor_dump (vat_main_t * vam)
18725 unformat_input_t *i = vam->input;
18726 vl_api_ip_neighbor_dump_t *mp;
18727 vl_api_control_ping_t *mp_ping;
18729 u32 sw_if_index = ~0;
18732 /* Parse args required to build the message */
18733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18735 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18737 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18739 else if (unformat (i, "ip6"))
18745 if (sw_if_index == ~0)
18747 errmsg ("missing interface name or sw_if_index");
18751 M (IP_NEIGHBOR_DUMP, mp);
18752 mp->is_ipv6 = (u8) is_ipv6;
18753 mp->sw_if_index = ntohl (sw_if_index);
18756 /* Use a control ping for synchronization */
18757 MPING (CONTROL_PING, mp_ping);
18764 #define vl_api_ip_route_details_t_endian vl_noop_handler
18765 #define vl_api_ip_route_details_t_print vl_noop_handler
18768 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18770 vat_main_t *vam = &vat_main;
18771 u8 count = mp->route.n_paths;
18772 vl_api_fib_path_t *fp;
18776 "table-id %d, prefix %U/%d",
18777 ntohl (mp->route.table_id),
18778 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18779 for (i = 0; i < count; i++)
18781 fp = &mp->route.paths[i];
18783 vl_api_fib_path_print (vam, fp);
18788 static void vl_api_ip_route_details_t_handler_json
18789 (vl_api_ip_route_details_t * mp)
18791 vat_main_t *vam = &vat_main;
18792 u8 count = mp->route.n_paths;
18793 vat_json_node_t *node = NULL;
18794 struct in_addr ip4;
18795 struct in6_addr ip6;
18796 vl_api_fib_path_t *fp;
18799 if (VAT_JSON_ARRAY != vam->json_tree.type)
18801 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18802 vat_json_init_array (&vam->json_tree);
18804 node = vat_json_array_add (&vam->json_tree);
18806 vat_json_init_object (node);
18807 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18808 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18810 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18811 vat_json_object_add_ip6 (node, "prefix", ip6);
18815 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18816 vat_json_object_add_ip4 (node, "prefix", ip4);
18818 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18819 vat_json_object_add_uint (node, "path_count", count);
18820 for (i = 0; i < count; i++)
18822 fp = &mp->route.paths[i];
18823 vl_api_mpls_fib_path_json_print (node, fp);
18828 api_ip_route_dump (vat_main_t * vam)
18830 unformat_input_t *input = vam->input;
18831 vl_api_ip_route_dump_t *mp;
18832 vl_api_control_ping_t *mp_ping;
18838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18840 if (unformat (input, "table_id %d", &table_id))
18842 else if (unformat (input, "ip6"))
18844 else if (unformat (input, "ip4"))
18849 if (table_id == ~0)
18851 errmsg ("missing table id");
18855 M (IP_ROUTE_DUMP, mp);
18857 mp->table.table_id = table_id;
18858 mp->table.is_ip6 = is_ip6;
18862 /* Use a control ping for synchronization */
18863 MPING (CONTROL_PING, mp_ping);
18871 api_classify_table_ids (vat_main_t * vam)
18873 vl_api_classify_table_ids_t *mp;
18876 /* Construct the API message */
18877 M (CLASSIFY_TABLE_IDS, mp);
18886 api_classify_table_by_interface (vat_main_t * vam)
18888 unformat_input_t *input = vam->input;
18889 vl_api_classify_table_by_interface_t *mp;
18891 u32 sw_if_index = ~0;
18893 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18895 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18897 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18902 if (sw_if_index == ~0)
18904 errmsg ("missing interface name or sw_if_index");
18908 /* Construct the API message */
18909 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18911 mp->sw_if_index = ntohl (sw_if_index);
18919 api_classify_table_info (vat_main_t * vam)
18921 unformat_input_t *input = vam->input;
18922 vl_api_classify_table_info_t *mp;
18926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18928 if (unformat (input, "table_id %d", &table_id))
18933 if (table_id == ~0)
18935 errmsg ("missing table id");
18939 /* Construct the API message */
18940 M (CLASSIFY_TABLE_INFO, mp);
18942 mp->table_id = ntohl (table_id);
18950 api_classify_session_dump (vat_main_t * vam)
18952 unformat_input_t *input = vam->input;
18953 vl_api_classify_session_dump_t *mp;
18954 vl_api_control_ping_t *mp_ping;
18958 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18960 if (unformat (input, "table_id %d", &table_id))
18965 if (table_id == ~0)
18967 errmsg ("missing table id");
18971 /* Construct the API message */
18972 M (CLASSIFY_SESSION_DUMP, mp);
18974 mp->table_id = ntohl (table_id);
18977 /* Use a control ping for synchronization */
18978 MPING (CONTROL_PING, mp_ping);
18986 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18988 vat_main_t *vam = &vat_main;
18990 print (vam->ofp, "collector_address %U, collector_port %d, "
18991 "src_address %U, vrf_id %d, path_mtu %u, "
18992 "template_interval %u, udp_checksum %d",
18993 format_ip4_address, mp->collector_address,
18994 ntohs (mp->collector_port),
18995 format_ip4_address, mp->src_address,
18996 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18997 ntohl (mp->template_interval), mp->udp_checksum);
19000 vam->result_ready = 1;
19004 vl_api_ipfix_exporter_details_t_handler_json
19005 (vl_api_ipfix_exporter_details_t * mp)
19007 vat_main_t *vam = &vat_main;
19008 vat_json_node_t node;
19009 struct in_addr collector_address;
19010 struct in_addr src_address;
19012 vat_json_init_object (&node);
19013 clib_memcpy (&collector_address, &mp->collector_address,
19014 sizeof (collector_address));
19015 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19016 vat_json_object_add_uint (&node, "collector_port",
19017 ntohs (mp->collector_port));
19018 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19019 vat_json_object_add_ip4 (&node, "src_address", src_address);
19020 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19021 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19022 vat_json_object_add_uint (&node, "template_interval",
19023 ntohl (mp->template_interval));
19024 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19026 vat_json_print (vam->ofp, &node);
19027 vat_json_free (&node);
19029 vam->result_ready = 1;
19033 api_ipfix_exporter_dump (vat_main_t * vam)
19035 vl_api_ipfix_exporter_dump_t *mp;
19038 /* Construct the API message */
19039 M (IPFIX_EXPORTER_DUMP, mp);
19048 api_ipfix_classify_stream_dump (vat_main_t * vam)
19050 vl_api_ipfix_classify_stream_dump_t *mp;
19053 /* Construct the API message */
19054 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19065 vl_api_ipfix_classify_stream_details_t_handler
19066 (vl_api_ipfix_classify_stream_details_t * mp)
19068 vat_main_t *vam = &vat_main;
19069 print (vam->ofp, "domain_id %d, src_port %d",
19070 ntohl (mp->domain_id), ntohs (mp->src_port));
19072 vam->result_ready = 1;
19076 vl_api_ipfix_classify_stream_details_t_handler_json
19077 (vl_api_ipfix_classify_stream_details_t * mp)
19079 vat_main_t *vam = &vat_main;
19080 vat_json_node_t node;
19082 vat_json_init_object (&node);
19083 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19084 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19086 vat_json_print (vam->ofp, &node);
19087 vat_json_free (&node);
19089 vam->result_ready = 1;
19093 api_ipfix_classify_table_dump (vat_main_t * vam)
19095 vl_api_ipfix_classify_table_dump_t *mp;
19096 vl_api_control_ping_t *mp_ping;
19099 if (!vam->json_output)
19101 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19102 "transport_protocol");
19105 /* Construct the API message */
19106 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19111 /* Use a control ping for synchronization */
19112 MPING (CONTROL_PING, mp_ping);
19120 vl_api_ipfix_classify_table_details_t_handler
19121 (vl_api_ipfix_classify_table_details_t * mp)
19123 vat_main_t *vam = &vat_main;
19124 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19125 mp->transport_protocol);
19129 vl_api_ipfix_classify_table_details_t_handler_json
19130 (vl_api_ipfix_classify_table_details_t * mp)
19132 vat_json_node_t *node = NULL;
19133 vat_main_t *vam = &vat_main;
19135 if (VAT_JSON_ARRAY != vam->json_tree.type)
19137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19138 vat_json_init_array (&vam->json_tree);
19141 node = vat_json_array_add (&vam->json_tree);
19142 vat_json_init_object (node);
19144 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19145 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19146 vat_json_object_add_uint (node, "transport_protocol",
19147 mp->transport_protocol);
19151 api_sw_interface_span_enable_disable (vat_main_t * vam)
19153 unformat_input_t *i = vam->input;
19154 vl_api_sw_interface_span_enable_disable_t *mp;
19155 u32 src_sw_if_index = ~0;
19156 u32 dst_sw_if_index = ~0;
19161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19164 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19166 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19170 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19172 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19174 else if (unformat (i, "disable"))
19176 else if (unformat (i, "rx"))
19178 else if (unformat (i, "tx"))
19180 else if (unformat (i, "both"))
19182 else if (unformat (i, "l2"))
19188 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19190 mp->sw_if_index_from = htonl (src_sw_if_index);
19191 mp->sw_if_index_to = htonl (dst_sw_if_index);
19201 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19204 vat_main_t *vam = &vat_main;
19205 u8 *sw_if_from_name = 0;
19206 u8 *sw_if_to_name = 0;
19207 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19208 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19209 char *states[] = { "none", "rx", "tx", "both" };
19213 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19215 if ((u32) p->value[0] == sw_if_index_from)
19217 sw_if_from_name = (u8 *)(p->key);
19221 if ((u32) p->value[0] == sw_if_index_to)
19223 sw_if_to_name = (u8 *)(p->key);
19224 if (sw_if_from_name)
19229 print (vam->ofp, "%20s => %20s (%s) %s",
19230 sw_if_from_name, sw_if_to_name, states[mp->state],
19231 mp->is_l2 ? "l2" : "device");
19235 vl_api_sw_interface_span_details_t_handler_json
19236 (vl_api_sw_interface_span_details_t * mp)
19238 vat_main_t *vam = &vat_main;
19239 vat_json_node_t *node = NULL;
19240 u8 *sw_if_from_name = 0;
19241 u8 *sw_if_to_name = 0;
19242 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19243 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19247 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19249 if ((u32) p->value[0] == sw_if_index_from)
19251 sw_if_from_name = (u8 *)(p->key);
19255 if ((u32) p->value[0] == sw_if_index_to)
19257 sw_if_to_name = (u8 *)(p->key);
19258 if (sw_if_from_name)
19264 if (VAT_JSON_ARRAY != vam->json_tree.type)
19266 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19267 vat_json_init_array (&vam->json_tree);
19269 node = vat_json_array_add (&vam->json_tree);
19271 vat_json_init_object (node);
19272 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19273 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19274 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19275 if (0 != sw_if_to_name)
19277 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
19279 vat_json_object_add_uint (node, "state", mp->state);
19280 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
19284 api_sw_interface_span_dump (vat_main_t * vam)
19286 unformat_input_t *input = vam->input;
19287 vl_api_sw_interface_span_dump_t *mp;
19288 vl_api_control_ping_t *mp_ping;
19292 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19294 if (unformat (input, "l2"))
19300 M (SW_INTERFACE_SPAN_DUMP, mp);
19304 /* Use a control ping for synchronization */
19305 MPING (CONTROL_PING, mp_ping);
19313 api_pg_create_interface (vat_main_t * vam)
19315 unformat_input_t *input = vam->input;
19316 vl_api_pg_create_interface_t *mp;
19318 u32 if_id = ~0, gso_size = 0;
19319 u8 gso_enabled = 0;
19321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19323 if (unformat (input, "if_id %d", &if_id))
19325 else if (unformat (input, "gso-enabled"))
19328 if (unformat (input, "gso-size %u", &gso_size))
19332 errmsg ("missing gso-size");
19341 errmsg ("missing pg interface index");
19345 /* Construct the API message */
19346 M (PG_CREATE_INTERFACE, mp);
19348 mp->interface_id = ntohl (if_id);
19349 mp->gso_enabled = gso_enabled;
19357 api_pg_capture (vat_main_t * vam)
19359 unformat_input_t *input = vam->input;
19360 vl_api_pg_capture_t *mp;
19365 u8 pcap_file_set = 0;
19368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19370 if (unformat (input, "if_id %d", &if_id))
19372 else if (unformat (input, "pcap %s", &pcap_file))
19374 else if (unformat (input, "count %d", &count))
19376 else if (unformat (input, "disable"))
19383 errmsg ("missing pg interface index");
19386 if (pcap_file_set > 0)
19388 if (vec_len (pcap_file) > 255)
19390 errmsg ("pcap file name is too long");
19395 u32 name_len = vec_len (pcap_file);
19396 /* Construct the API message */
19397 M (PG_CAPTURE, mp);
19399 mp->interface_id = ntohl (if_id);
19400 mp->is_enabled = enable;
19401 mp->count = ntohl (count);
19402 mp->pcap_name_length = ntohl (name_len);
19403 if (pcap_file_set != 0)
19405 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
19407 vec_free (pcap_file);
19415 api_pg_enable_disable (vat_main_t * vam)
19417 unformat_input_t *input = vam->input;
19418 vl_api_pg_enable_disable_t *mp;
19421 u8 stream_name_set = 0;
19422 u8 *stream_name = 0;
19424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19426 if (unformat (input, "stream %s", &stream_name))
19427 stream_name_set = 1;
19428 else if (unformat (input, "disable"))
19434 if (stream_name_set > 0)
19436 if (vec_len (stream_name) > 255)
19438 errmsg ("stream name too long");
19443 u32 name_len = vec_len (stream_name);
19444 /* Construct the API message */
19445 M (PG_ENABLE_DISABLE, mp);
19447 mp->is_enabled = enable;
19448 if (stream_name_set != 0)
19450 mp->stream_name_length = ntohl (name_len);
19451 clib_memcpy (mp->stream_name, stream_name, name_len);
19453 vec_free (stream_name);
19461 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
19463 unformat_input_t *input = vam->input;
19464 vl_api_ip_source_and_port_range_check_add_del_t *mp;
19466 u16 *low_ports = 0;
19467 u16 *high_ports = 0;
19470 vl_api_prefix_t prefix;
19477 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19479 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
19481 else if (unformat (input, "vrf %d", &vrf_id))
19483 else if (unformat (input, "del"))
19485 else if (unformat (input, "port %d", &tmp))
19487 if (tmp == 0 || tmp > 65535)
19489 errmsg ("port %d out of range", tmp);
19493 this_hi = this_low + 1;
19494 vec_add1 (low_ports, this_low);
19495 vec_add1 (high_ports, this_hi);
19497 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19499 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19501 errmsg ("incorrect range parameters");
19505 /* Note: in debug CLI +1 is added to high before
19506 passing to real fn that does "the work"
19507 (ip_source_and_port_range_check_add_del).
19508 This fn is a wrapper around the binary API fn a
19509 control plane will call, which expects this increment
19510 to have occurred. Hence letting the binary API control
19511 plane fn do the increment for consistency between VAT
19512 and other control planes.
19515 vec_add1 (low_ports, this_low);
19516 vec_add1 (high_ports, this_hi);
19522 if (prefix_set == 0)
19524 errmsg ("<address>/<mask> not specified");
19530 errmsg ("VRF ID required, not specified");
19537 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19541 if (vec_len (low_ports) == 0)
19543 errmsg ("At least one port or port range required");
19547 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19549 mp->is_add = is_add;
19551 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
19553 mp->number_of_ranges = vec_len (low_ports);
19555 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19556 vec_free (low_ports);
19558 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19559 vec_free (high_ports);
19561 mp->vrf_id = ntohl (vrf_id);
19569 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19571 unformat_input_t *input = vam->input;
19572 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19573 u32 sw_if_index = ~0;
19575 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19576 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19582 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19584 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19586 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19588 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19590 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19592 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19594 else if (unformat (input, "del"))
19600 if (sw_if_index == ~0)
19602 errmsg ("Interface required but not specified");
19608 errmsg ("VRF ID required but not specified");
19612 if (tcp_out_vrf_id == 0
19613 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19616 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19620 /* Construct the API message */
19621 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19623 mp->sw_if_index = ntohl (sw_if_index);
19624 mp->is_add = is_add;
19625 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19626 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19627 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19628 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19633 /* Wait for a reply... */
19639 api_set_punt (vat_main_t * vam)
19641 unformat_input_t *i = vam->input;
19642 vl_api_address_family_t af;
19643 vl_api_set_punt_t *mp;
19649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19651 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
19653 else if (unformat (i, "protocol %d", &protocol))
19655 else if (unformat (i, "port %d", &port))
19657 else if (unformat (i, "del"))
19661 clib_warning ("parse error '%U'", format_unformat_error, i);
19668 mp->is_add = (u8) is_add;
19669 mp->punt.type = PUNT_API_TYPE_L4;
19670 mp->punt.punt.l4.af = af;
19671 mp->punt.punt.l4.protocol = (u8) protocol;
19672 mp->punt.punt.l4.port = htons ((u16) port);
19680 api_delete_subif (vat_main_t * vam)
19682 unformat_input_t *i = vam->input;
19683 vl_api_delete_subif_t *mp;
19684 u32 sw_if_index = ~0;
19687 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19689 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19691 if (unformat (i, "sw_if_index %d", &sw_if_index))
19697 if (sw_if_index == ~0)
19699 errmsg ("missing sw_if_index");
19703 /* Construct the API message */
19704 M (DELETE_SUBIF, mp);
19705 mp->sw_if_index = ntohl (sw_if_index);
19712 #define foreach_pbb_vtr_op \
19713 _("disable", L2_VTR_DISABLED) \
19714 _("pop", L2_VTR_POP_2) \
19715 _("push", L2_VTR_PUSH_2)
19718 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19720 unformat_input_t *i = vam->input;
19721 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19722 u32 sw_if_index = ~0, vtr_op = ~0;
19723 u16 outer_tag = ~0;
19724 u8 dmac[6], smac[6];
19725 u8 dmac_set = 0, smac_set = 0;
19731 /* Shut up coverity */
19732 clib_memset (dmac, 0, sizeof (dmac));
19733 clib_memset (smac, 0, sizeof (smac));
19735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19737 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19739 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19741 else if (unformat (i, "vtr_op %d", &vtr_op))
19743 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19746 else if (unformat (i, "translate_pbb_stag"))
19748 if (unformat (i, "%d", &tmp))
19750 vtr_op = L2_VTR_TRANSLATE_2_1;
19756 ("translate_pbb_stag operation requires outer tag definition");
19760 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19762 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19764 else if (unformat (i, "sid %d", &sid))
19766 else if (unformat (i, "vlanid %d", &tmp))
19770 clib_warning ("parse error '%U'", format_unformat_error, i);
19775 if ((sw_if_index == ~0) || (vtr_op == ~0))
19777 errmsg ("missing sw_if_index or vtr operation");
19780 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19781 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19784 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19788 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19789 mp->sw_if_index = ntohl (sw_if_index);
19790 mp->vtr_op = ntohl (vtr_op);
19791 mp->outer_tag = ntohs (outer_tag);
19792 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19793 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19794 mp->b_vlanid = ntohs (vlanid);
19795 mp->i_sid = ntohl (sid);
19803 api_flow_classify_set_interface (vat_main_t * vam)
19805 unformat_input_t *i = vam->input;
19806 vl_api_flow_classify_set_interface_t *mp;
19808 int sw_if_index_set;
19809 u32 ip4_table_index = ~0;
19810 u32 ip6_table_index = ~0;
19814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19816 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19817 sw_if_index_set = 1;
19818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19819 sw_if_index_set = 1;
19820 else if (unformat (i, "del"))
19822 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19824 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19828 clib_warning ("parse error '%U'", format_unformat_error, i);
19833 if (sw_if_index_set == 0)
19835 errmsg ("missing interface name or sw_if_index");
19839 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19841 mp->sw_if_index = ntohl (sw_if_index);
19842 mp->ip4_table_index = ntohl (ip4_table_index);
19843 mp->ip6_table_index = ntohl (ip6_table_index);
19844 mp->is_add = is_add;
19852 api_flow_classify_dump (vat_main_t * vam)
19854 unformat_input_t *i = vam->input;
19855 vl_api_flow_classify_dump_t *mp;
19856 vl_api_control_ping_t *mp_ping;
19857 u8 type = FLOW_CLASSIFY_N_TABLES;
19860 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19864 errmsg ("classify table type must be specified");
19868 if (!vam->json_output)
19870 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19873 M (FLOW_CLASSIFY_DUMP, mp);
19878 /* Use a control ping for synchronization */
19879 MPING (CONTROL_PING, mp_ping);
19882 /* Wait for a reply... */
19888 api_feature_enable_disable (vat_main_t * vam)
19890 unformat_input_t *i = vam->input;
19891 vl_api_feature_enable_disable_t *mp;
19893 u8 *feature_name = 0;
19894 u32 sw_if_index = ~0;
19898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19900 if (unformat (i, "arc_name %s", &arc_name))
19902 else if (unformat (i, "feature_name %s", &feature_name))
19905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19907 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19909 else if (unformat (i, "disable"))
19917 errmsg ("missing arc name");
19920 if (vec_len (arc_name) > 63)
19922 errmsg ("arc name too long");
19925 if (feature_name == 0)
19927 errmsg ("missing feature name");
19930 if (vec_len (feature_name) > 63)
19932 errmsg ("feature name too long");
19935 if (sw_if_index == ~0)
19937 errmsg ("missing interface name or sw_if_index");
19941 /* Construct the API message */
19942 M (FEATURE_ENABLE_DISABLE, mp);
19943 mp->sw_if_index = ntohl (sw_if_index);
19944 mp->enable = enable;
19945 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19946 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19947 vec_free (arc_name);
19948 vec_free (feature_name);
19956 api_sw_interface_tag_add_del (vat_main_t * vam)
19958 unformat_input_t *i = vam->input;
19959 vl_api_sw_interface_tag_add_del_t *mp;
19960 u32 sw_if_index = ~0;
19965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19967 if (unformat (i, "tag %s", &tag))
19969 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19971 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19973 else if (unformat (i, "del"))
19979 if (sw_if_index == ~0)
19981 errmsg ("missing interface name or sw_if_index");
19985 if (enable && (tag == 0))
19987 errmsg ("no tag specified");
19991 /* Construct the API message */
19992 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19993 mp->sw_if_index = ntohl (sw_if_index);
19994 mp->is_add = enable;
19996 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20005 api_sw_interface_add_del_mac_address (vat_main_t * vam)
20007 unformat_input_t *i = vam->input;
20008 vl_api_mac_address_t mac = { 0 };
20009 vl_api_sw_interface_add_del_mac_address_t *mp;
20010 u32 sw_if_index = ~0;
20015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20017 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20019 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20021 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
20023 else if (unformat (i, "del"))
20029 if (sw_if_index == ~0)
20031 errmsg ("missing interface name or sw_if_index");
20037 errmsg ("missing MAC address");
20041 /* Construct the API message */
20042 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
20043 mp->sw_if_index = ntohl (sw_if_index);
20044 mp->is_add = is_add;
20045 clib_memcpy (&mp->addr, &mac, sizeof (mac));
20052 static void vl_api_l2_xconnect_details_t_handler
20053 (vl_api_l2_xconnect_details_t * mp)
20055 vat_main_t *vam = &vat_main;
20057 print (vam->ofp, "%15d%15d",
20058 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20061 static void vl_api_l2_xconnect_details_t_handler_json
20062 (vl_api_l2_xconnect_details_t * mp)
20064 vat_main_t *vam = &vat_main;
20065 vat_json_node_t *node = NULL;
20067 if (VAT_JSON_ARRAY != vam->json_tree.type)
20069 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20070 vat_json_init_array (&vam->json_tree);
20072 node = vat_json_array_add (&vam->json_tree);
20074 vat_json_init_object (node);
20075 vat_json_object_add_uint (node, "rx_sw_if_index",
20076 ntohl (mp->rx_sw_if_index));
20077 vat_json_object_add_uint (node, "tx_sw_if_index",
20078 ntohl (mp->tx_sw_if_index));
20082 api_l2_xconnect_dump (vat_main_t * vam)
20084 vl_api_l2_xconnect_dump_t *mp;
20085 vl_api_control_ping_t *mp_ping;
20088 if (!vam->json_output)
20090 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20093 M (L2_XCONNECT_DUMP, mp);
20097 /* Use a control ping for synchronization */
20098 MPING (CONTROL_PING, mp_ping);
20106 api_hw_interface_set_mtu (vat_main_t * vam)
20108 unformat_input_t *i = vam->input;
20109 vl_api_hw_interface_set_mtu_t *mp;
20110 u32 sw_if_index = ~0;
20114 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20116 if (unformat (i, "mtu %d", &mtu))
20118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20120 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20126 if (sw_if_index == ~0)
20128 errmsg ("missing interface name or sw_if_index");
20134 errmsg ("no mtu specified");
20138 /* Construct the API message */
20139 M (HW_INTERFACE_SET_MTU, mp);
20140 mp->sw_if_index = ntohl (sw_if_index);
20141 mp->mtu = ntohs ((u16) mtu);
20149 api_p2p_ethernet_add (vat_main_t * vam)
20151 unformat_input_t *i = vam->input;
20152 vl_api_p2p_ethernet_add_t *mp;
20153 u32 parent_if_index = ~0;
20159 clib_memset (remote_mac, 0, sizeof (remote_mac));
20160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20164 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20168 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20170 else if (unformat (i, "sub_id %d", &sub_id))
20174 clib_warning ("parse error '%U'", format_unformat_error, i);
20179 if (parent_if_index == ~0)
20181 errmsg ("missing interface name or sw_if_index");
20186 errmsg ("missing remote mac address");
20191 errmsg ("missing sub-interface id");
20195 M (P2P_ETHERNET_ADD, mp);
20196 mp->parent_if_index = ntohl (parent_if_index);
20197 mp->subif_id = ntohl (sub_id);
20198 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20206 api_p2p_ethernet_del (vat_main_t * vam)
20208 unformat_input_t *i = vam->input;
20209 vl_api_p2p_ethernet_del_t *mp;
20210 u32 parent_if_index = ~0;
20215 clib_memset (remote_mac, 0, sizeof (remote_mac));
20216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20220 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20224 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20228 clib_warning ("parse error '%U'", format_unformat_error, i);
20233 if (parent_if_index == ~0)
20235 errmsg ("missing interface name or sw_if_index");
20240 errmsg ("missing remote mac address");
20244 M (P2P_ETHERNET_DEL, mp);
20245 mp->parent_if_index = ntohl (parent_if_index);
20246 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20254 api_lldp_config (vat_main_t * vam)
20256 unformat_input_t *i = vam->input;
20257 vl_api_lldp_config_t *mp;
20259 int tx_interval = 0;
20260 u8 *sys_name = NULL;
20263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20265 if (unformat (i, "system-name %s", &sys_name))
20267 else if (unformat (i, "tx-hold %d", &tx_hold))
20269 else if (unformat (i, "tx-interval %d", &tx_interval))
20273 clib_warning ("parse error '%U'", format_unformat_error, i);
20278 vec_add1 (sys_name, 0);
20280 M (LLDP_CONFIG, mp);
20281 mp->tx_hold = htonl (tx_hold);
20282 mp->tx_interval = htonl (tx_interval);
20283 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
20284 vec_free (sys_name);
20292 api_sw_interface_set_lldp (vat_main_t * vam)
20294 unformat_input_t *i = vam->input;
20295 vl_api_sw_interface_set_lldp_t *mp;
20296 u32 sw_if_index = ~0;
20298 u8 *port_desc = NULL, *mgmt_oid = NULL;
20299 ip4_address_t ip4_addr;
20300 ip6_address_t ip6_addr;
20303 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
20304 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
20306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20308 if (unformat (i, "disable"))
20311 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20313 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20315 else if (unformat (i, "port-desc %s", &port_desc))
20317 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
20319 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
20321 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
20327 if (sw_if_index == ~0)
20329 errmsg ("missing interface name or sw_if_index");
20333 /* Construct the API message */
20334 vec_add1 (port_desc, 0);
20335 vec_add1 (mgmt_oid, 0);
20336 M (SW_INTERFACE_SET_LLDP, mp);
20337 mp->sw_if_index = ntohl (sw_if_index);
20338 mp->enable = enable;
20339 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
20340 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
20341 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
20342 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
20343 vec_free (port_desc);
20344 vec_free (mgmt_oid);
20352 api_tcp_configure_src_addresses (vat_main_t * vam)
20354 vl_api_tcp_configure_src_addresses_t *mp;
20355 unformat_input_t *i = vam->input;
20356 ip4_address_t v4first, v4last;
20357 ip6_address_t v6first, v6last;
20362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20364 if (unformat (i, "%U - %U",
20365 unformat_ip4_address, &v4first,
20366 unformat_ip4_address, &v4last))
20370 errmsg ("one range per message (range already set)");
20375 else if (unformat (i, "%U - %U",
20376 unformat_ip6_address, &v6first,
20377 unformat_ip6_address, &v6last))
20381 errmsg ("one range per message (range already set)");
20386 else if (unformat (i, "vrf %d", &vrf_id))
20392 if (range_set == 0)
20394 errmsg ("address range not set");
20398 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
20399 mp->vrf_id = ntohl (vrf_id);
20401 if (range_set == 2)
20404 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20405 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20410 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20411 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20418 static void vl_api_app_namespace_add_del_reply_t_handler
20419 (vl_api_app_namespace_add_del_reply_t * mp)
20421 vat_main_t *vam = &vat_main;
20422 i32 retval = ntohl (mp->retval);
20423 if (vam->async_mode)
20425 vam->async_errors += (retval < 0);
20429 vam->retval = retval;
20431 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
20432 vam->result_ready = 1;
20436 static void vl_api_app_namespace_add_del_reply_t_handler_json
20437 (vl_api_app_namespace_add_del_reply_t * mp)
20439 vat_main_t *vam = &vat_main;
20440 vat_json_node_t node;
20442 vat_json_init_object (&node);
20443 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
20444 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
20446 vat_json_print (vam->ofp, &node);
20447 vat_json_free (&node);
20449 vam->retval = ntohl (mp->retval);
20450 vam->result_ready = 1;
20454 api_app_namespace_add_del (vat_main_t * vam)
20456 vl_api_app_namespace_add_del_t *mp;
20457 unformat_input_t *i = vam->input;
20458 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
20459 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
20463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20465 if (unformat (i, "id %_%v%_", &ns_id))
20467 else if (unformat (i, "secret %lu", &secret))
20469 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20470 sw_if_index_set = 1;
20471 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
20473 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
20478 if (!ns_id || !secret_set || !sw_if_index_set)
20480 errmsg ("namespace id, secret and sw_if_index must be set");
20483 if (vec_len (ns_id) > 64)
20485 errmsg ("namespace id too long");
20488 M (APP_NAMESPACE_ADD_DEL, mp);
20490 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
20491 mp->namespace_id_len = vec_len (ns_id);
20492 mp->secret = clib_host_to_net_u64 (secret);
20493 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20494 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
20495 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
20503 api_sock_init_shm (vat_main_t * vam)
20505 #if VPP_API_TEST_BUILTIN == 0
20506 unformat_input_t *i = vam->input;
20507 vl_api_shm_elem_config_t *config = 0;
20508 u64 size = 64 << 20;
20511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20513 if (unformat (i, "size %U", unformat_memory_size, &size))
20520 * Canned custom ring allocator config.
20521 * Should probably parse all of this
20523 vec_validate (config, 6);
20524 config[0].type = VL_API_VLIB_RING;
20525 config[0].size = 256;
20526 config[0].count = 32;
20528 config[1].type = VL_API_VLIB_RING;
20529 config[1].size = 1024;
20530 config[1].count = 16;
20532 config[2].type = VL_API_VLIB_RING;
20533 config[2].size = 4096;
20534 config[2].count = 2;
20536 config[3].type = VL_API_CLIENT_RING;
20537 config[3].size = 256;
20538 config[3].count = 32;
20540 config[4].type = VL_API_CLIENT_RING;
20541 config[4].size = 1024;
20542 config[4].count = 16;
20544 config[5].type = VL_API_CLIENT_RING;
20545 config[5].size = 4096;
20546 config[5].count = 2;
20548 config[6].type = VL_API_QUEUE;
20549 config[6].count = 128;
20550 config[6].size = sizeof (uword);
20552 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
20554 vam->client_index_invalid = 1;
20562 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
20564 vat_main_t *vam = &vat_main;
20569 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20570 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20571 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
20572 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
20573 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20574 clib_net_to_host_u32 (mp->action_index), mp->tag);
20579 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
20580 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
20581 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
20582 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
20583 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
20584 clib_net_to_host_u32 (mp->action_index), mp->tag);
20589 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
20592 vat_main_t *vam = &vat_main;
20593 vat_json_node_t *node = NULL;
20594 struct in6_addr ip6;
20595 struct in_addr ip4;
20597 if (VAT_JSON_ARRAY != vam->json_tree.type)
20599 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20600 vat_json_init_array (&vam->json_tree);
20602 node = vat_json_array_add (&vam->json_tree);
20603 vat_json_init_object (node);
20605 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
20606 vat_json_object_add_uint (node, "appns_index",
20607 clib_net_to_host_u32 (mp->appns_index));
20608 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
20609 vat_json_object_add_uint (node, "scope", mp->scope);
20610 vat_json_object_add_uint (node, "action_index",
20611 clib_net_to_host_u32 (mp->action_index));
20612 vat_json_object_add_uint (node, "lcl_port",
20613 clib_net_to_host_u16 (mp->lcl_port));
20614 vat_json_object_add_uint (node, "rmt_port",
20615 clib_net_to_host_u16 (mp->rmt_port));
20616 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
20617 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
20618 vat_json_object_add_string_copy (node, "tag", mp->tag);
20621 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
20622 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20623 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
20624 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20628 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
20629 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20630 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
20631 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20636 api_session_rule_add_del (vat_main_t * vam)
20638 vl_api_session_rule_add_del_t *mp;
20639 unformat_input_t *i = vam->input;
20640 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20641 u32 appns_index = 0, scope = 0;
20642 ip4_address_t lcl_ip4, rmt_ip4;
20643 ip6_address_t lcl_ip6, rmt_ip6;
20644 u8 is_ip4 = 1, conn_set = 0;
20645 u8 is_add = 1, *tag = 0;
20648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20650 if (unformat (i, "del"))
20652 else if (unformat (i, "add"))
20654 else if (unformat (i, "proto tcp"))
20656 else if (unformat (i, "proto udp"))
20658 else if (unformat (i, "appns %d", &appns_index))
20660 else if (unformat (i, "scope %d", &scope))
20662 else if (unformat (i, "tag %_%v%_", &tag))
20666 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
20667 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
20675 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
20676 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
20682 else if (unformat (i, "action %d", &action))
20687 if (proto == ~0 || !conn_set || action == ~0)
20689 errmsg ("transport proto, connection and action must be set");
20695 errmsg ("scope should be 0-3");
20699 M (SESSION_RULE_ADD_DEL, mp);
20701 mp->is_ip4 = is_ip4;
20702 mp->transport_proto = proto;
20703 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20704 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20705 mp->lcl_plen = lcl_plen;
20706 mp->rmt_plen = rmt_plen;
20707 mp->action_index = clib_host_to_net_u32 (action);
20708 mp->appns_index = clib_host_to_net_u32 (appns_index);
20710 mp->is_add = is_add;
20713 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
20714 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
20718 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
20719 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
20723 clib_memcpy (mp->tag, tag, vec_len (tag));
20733 api_session_rules_dump (vat_main_t * vam)
20735 vl_api_session_rules_dump_t *mp;
20736 vl_api_control_ping_t *mp_ping;
20739 if (!vam->json_output)
20741 print (vam->ofp, "%=20s", "Session Rules");
20744 M (SESSION_RULES_DUMP, mp);
20748 /* Use a control ping for synchronization */
20749 MPING (CONTROL_PING, mp_ping);
20752 /* Wait for a reply... */
20758 api_ip_container_proxy_add_del (vat_main_t * vam)
20760 vl_api_ip_container_proxy_add_del_t *mp;
20761 unformat_input_t *i = vam->input;
20762 u32 sw_if_index = ~0;
20763 vl_api_prefix_t pfx = { };
20767 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20769 if (unformat (i, "del"))
20771 else if (unformat (i, "add"))
20773 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20775 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20780 if (sw_if_index == ~0 || pfx.len == 0)
20782 errmsg ("address and sw_if_index must be set");
20786 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20788 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20789 mp->is_add = is_add;
20790 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20798 api_qos_record_enable_disable (vat_main_t * vam)
20800 unformat_input_t *i = vam->input;
20801 vl_api_qos_record_enable_disable_t *mp;
20802 u32 sw_if_index, qs = 0xff;
20803 u8 sw_if_index_set = 0;
20807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20809 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20810 sw_if_index_set = 1;
20811 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20812 sw_if_index_set = 1;
20813 else if (unformat (i, "%U", unformat_qos_source, &qs))
20815 else if (unformat (i, "disable"))
20819 clib_warning ("parse error '%U'", format_unformat_error, i);
20824 if (sw_if_index_set == 0)
20826 errmsg ("missing interface name or sw_if_index");
20831 errmsg ("input location must be specified");
20835 M (QOS_RECORD_ENABLE_DISABLE, mp);
20837 mp->record.sw_if_index = ntohl (sw_if_index);
20838 mp->record.input_source = qs;
20839 mp->enable = enable;
20848 q_or_quit (vat_main_t * vam)
20850 #if VPP_API_TEST_BUILTIN == 0
20851 longjmp (vam->jump_buf, 1);
20853 return 0; /* not so much */
20857 q (vat_main_t * vam)
20859 return q_or_quit (vam);
20863 quit (vat_main_t * vam)
20865 return q_or_quit (vam);
20869 comment (vat_main_t * vam)
20875 elog_save (vat_main_t * vam)
20877 #if VPP_API_TEST_BUILTIN == 0
20878 elog_main_t *em = &vam->elog_main;
20879 unformat_input_t *i = vam->input;
20880 char *file, *chroot_file;
20881 clib_error_t *error;
20883 if (!unformat (i, "%s", &file))
20885 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20889 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20890 if (strstr (file, "..") || index (file, '/'))
20892 errmsg ("illegal characters in filename '%s'", file);
20896 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20900 errmsg ("Saving %wd of %wd events to %s",
20901 elog_n_events_in_buffer (em),
20902 elog_buffer_capacity (em), chroot_file);
20904 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20905 vec_free (chroot_file);
20908 clib_error_report (error);
20910 errmsg ("Use the vpp event loger...");
20917 elog_setup (vat_main_t * vam)
20919 #if VPP_API_TEST_BUILTIN == 0
20920 elog_main_t *em = &vam->elog_main;
20921 unformat_input_t *i = vam->input;
20922 u32 nevents = 128 << 10;
20924 (void) unformat (i, "nevents %d", &nevents);
20926 elog_init (em, nevents);
20927 vl_api_set_elog_main (em);
20928 vl_api_set_elog_trace_api_messages (1);
20929 errmsg ("Event logger initialized with %u events", nevents);
20931 errmsg ("Use the vpp event loger...");
20937 elog_enable (vat_main_t * vam)
20939 #if VPP_API_TEST_BUILTIN == 0
20940 elog_main_t *em = &vam->elog_main;
20942 elog_enable_disable (em, 1 /* enable */ );
20943 vl_api_set_elog_trace_api_messages (1);
20944 errmsg ("Event logger enabled...");
20946 errmsg ("Use the vpp event loger...");
20952 elog_disable (vat_main_t * vam)
20954 #if VPP_API_TEST_BUILTIN == 0
20955 elog_main_t *em = &vam->elog_main;
20957 elog_enable_disable (em, 0 /* enable */ );
20958 vl_api_set_elog_trace_api_messages (1);
20959 errmsg ("Event logger disabled...");
20961 errmsg ("Use the vpp event loger...");
20967 statseg (vat_main_t * vam)
20969 ssvm_private_t *ssvmp = &vam->stat_segment;
20970 ssvm_shared_header_t *shared_header = ssvmp->sh;
20971 vlib_counter_t **counters;
20972 u64 thread0_index1_packets;
20973 u64 thread0_index1_bytes;
20974 f64 vector_rate, input_rate;
20977 uword *counter_vector_by_name;
20978 if (vam->stat_segment_lockp == 0)
20980 errmsg ("Stat segment not mapped...");
20984 /* look up "/if/rx for sw_if_index 1 as a test */
20986 clib_spinlock_lock (vam->stat_segment_lockp);
20988 counter_vector_by_name = (uword *) shared_header->opaque[1];
20990 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20993 clib_spinlock_unlock (vam->stat_segment_lockp);
20994 errmsg ("/if/tx not found?");
20998 /* Fish per-thread vector of combined counters from shared memory */
20999 counters = (vlib_counter_t **) p[0];
21001 if (vec_len (counters[0]) < 2)
21003 clib_spinlock_unlock (vam->stat_segment_lockp);
21004 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21008 /* Read thread 0 sw_if_index 1 counter */
21009 thread0_index1_packets = counters[0][1].packets;
21010 thread0_index1_bytes = counters[0][1].bytes;
21012 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21015 clib_spinlock_unlock (vam->stat_segment_lockp);
21016 errmsg ("vector_rate not found?");
21020 vector_rate = *(f64 *) (p[0]);
21021 p = hash_get_mem (counter_vector_by_name, "input_rate");
21024 clib_spinlock_unlock (vam->stat_segment_lockp);
21025 errmsg ("input_rate not found?");
21028 input_rate = *(f64 *) (p[0]);
21030 clib_spinlock_unlock (vam->stat_segment_lockp);
21032 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21033 vector_rate, input_rate);
21034 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21035 thread0_index1_packets, thread0_index1_bytes);
21041 cmd_cmp (void *a1, void *a2)
21046 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21050 help (vat_main_t * vam)
21055 unformat_input_t *i = vam->input;
21058 if (unformat (i, "%s", &name))
21062 vec_add1 (name, 0);
21064 hs = hash_get_mem (vam->help_by_name, name);
21066 print (vam->ofp, "usage: %s %s", name, hs[0]);
21068 print (vam->ofp, "No such msg / command '%s'", name);
21073 print (vam->ofp, "Help is available for the following:");
21076 hash_foreach_pair (p, vam->function_by_name,
21078 vec_add1 (cmds, (u8 *)(p->key));
21082 vec_sort_with_function (cmds, cmd_cmp);
21084 for (j = 0; j < vec_len (cmds); j++)
21085 print (vam->ofp, "%s", cmds[j]);
21092 set (vat_main_t * vam)
21094 u8 *name = 0, *value = 0;
21095 unformat_input_t *i = vam->input;
21097 if (unformat (i, "%s", &name))
21099 /* The input buffer is a vector, not a string. */
21100 value = vec_dup (i->buffer);
21101 vec_delete (value, i->index, 0);
21102 /* Almost certainly has a trailing newline */
21103 if (value[vec_len (value) - 1] == '\n')
21104 value[vec_len (value) - 1] = 0;
21105 /* Make sure it's a proper string, one way or the other */
21106 vec_add1 (value, 0);
21107 (void) clib_macro_set_value (&vam->macro_main,
21108 (char *) name, (char *) value);
21111 errmsg ("usage: set <name> <value>");
21119 unset (vat_main_t * vam)
21123 if (unformat (vam->input, "%s", &name))
21124 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21125 errmsg ("unset: %s wasn't set", name);
21138 macro_sort_cmp (void *a1, void *a2)
21140 macro_sort_t *s1 = a1;
21141 macro_sort_t *s2 = a2;
21143 return strcmp ((char *) (s1->name), (char *) (s2->name));
21147 dump_macro_table (vat_main_t * vam)
21149 macro_sort_t *sort_me = 0, *sm;
21154 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
21156 vec_add2 (sort_me, sm, 1);
21157 sm->name = (u8 *)(p->key);
21158 sm->value = (u8 *) (p->value[0]);
21162 vec_sort_with_function (sort_me, macro_sort_cmp);
21164 if (vec_len (sort_me))
21165 print (vam->ofp, "%-15s%s", "Name", "Value");
21167 print (vam->ofp, "The macro table is empty...");
21169 for (i = 0; i < vec_len (sort_me); i++)
21170 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
21175 dump_node_table (vat_main_t * vam)
21178 vlib_node_t *node, *next_node;
21180 if (vec_len (vam->graph_nodes) == 0)
21182 print (vam->ofp, "Node table empty, issue get_node_graph...");
21186 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
21188 node = vam->graph_nodes[0][i];
21189 print (vam->ofp, "[%d] %s", i, node->name);
21190 for (j = 0; j < vec_len (node->next_nodes); j++)
21192 if (node->next_nodes[j] != ~0)
21194 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21195 print (vam->ofp, " [%d] %s", j, next_node->name);
21203 value_sort_cmp (void *a1, void *a2)
21205 name_sort_t *n1 = a1;
21206 name_sort_t *n2 = a2;
21208 if (n1->value < n2->value)
21210 if (n1->value > n2->value)
21217 dump_msg_api_table (vat_main_t * vam)
21219 api_main_t *am = &api_main;
21220 name_sort_t *nses = 0, *ns;
21225 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
21227 vec_add2 (nses, ns, 1);
21228 ns->name = (u8 *)(hp->key);
21229 ns->value = (u32) hp->value[0];
21233 vec_sort_with_function (nses, value_sort_cmp);
21235 for (i = 0; i < vec_len (nses); i++)
21236 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
21242 get_msg_id (vat_main_t * vam)
21247 if (unformat (vam->input, "%s", &name_and_crc))
21249 message_index = vl_msg_api_get_msg_index (name_and_crc);
21250 if (message_index == ~0)
21252 print (vam->ofp, " '%s' not found", name_and_crc);
21255 print (vam->ofp, " '%s' has message index %d",
21256 name_and_crc, message_index);
21259 errmsg ("name_and_crc required...");
21264 search_node_table (vat_main_t * vam)
21266 unformat_input_t *line_input = vam->input;
21269 vlib_node_t *node, *next_node;
21272 if (vam->graph_node_index_by_name == 0)
21274 print (vam->ofp, "Node table empty, issue get_node_graph...");
21278 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21280 if (unformat (line_input, "%s", &node_to_find))
21282 vec_add1 (node_to_find, 0);
21283 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
21286 print (vam->ofp, "%s not found...", node_to_find);
21289 node = vam->graph_nodes[0][p[0]];
21290 print (vam->ofp, "[%d] %s", p[0], node->name);
21291 for (j = 0; j < vec_len (node->next_nodes); j++)
21293 if (node->next_nodes[j] != ~0)
21295 next_node = vam->graph_nodes[0][node->next_nodes[j]];
21296 print (vam->ofp, " [%d] %s", j, next_node->name);
21303 clib_warning ("parse error '%U'", format_unformat_error,
21309 vec_free (node_to_find);
21318 script (vat_main_t * vam)
21320 #if (VPP_API_TEST_BUILTIN==0)
21322 char *save_current_file;
21323 unformat_input_t save_input;
21324 jmp_buf save_jump_buf;
21325 u32 save_line_number;
21327 FILE *new_fp, *save_ifp;
21329 if (unformat (vam->input, "%s", &s))
21331 new_fp = fopen ((char *) s, "r");
21334 errmsg ("Couldn't open script file %s", s);
21341 errmsg ("Missing script name");
21345 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
21346 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
21347 save_ifp = vam->ifp;
21348 save_line_number = vam->input_line_number;
21349 save_current_file = (char *) vam->current_file;
21351 vam->input_line_number = 0;
21353 vam->current_file = s;
21356 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
21357 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
21358 vam->ifp = save_ifp;
21359 vam->input_line_number = save_line_number;
21360 vam->current_file = (u8 *) save_current_file;
21365 clib_warning ("use the exec command...");
21371 echo (vat_main_t * vam)
21373 print (vam->ofp, "%v", vam->input->buffer);
21377 /* List of API message constructors, CLI names map to api_xxx */
21378 #define foreach_vpe_api_msg \
21379 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
21380 _(sw_interface_dump,"") \
21381 _(sw_interface_set_flags, \
21382 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
21383 _(sw_interface_add_del_address, \
21384 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
21385 _(sw_interface_set_rx_mode, \
21386 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
21387 _(sw_interface_set_rx_placement, \
21388 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
21389 _(sw_interface_rx_placement_dump, \
21390 "[<intfc> | sw_if_index <id>]") \
21391 _(sw_interface_set_table, \
21392 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
21393 _(sw_interface_set_mpls_enable, \
21394 "<intfc> | sw_if_index [disable | dis]") \
21395 _(sw_interface_set_vpath, \
21396 "<intfc> | sw_if_index <id> enable | disable") \
21397 _(sw_interface_set_vxlan_bypass, \
21398 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21399 _(sw_interface_set_geneve_bypass, \
21400 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
21401 _(sw_interface_set_l2_xconnect, \
21402 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21403 "enable | disable") \
21404 _(sw_interface_set_l2_bridge, \
21405 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
21406 "[shg <split-horizon-group>] [bvi]\n" \
21407 "enable | disable") \
21408 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
21409 _(bridge_domain_add_del, \
21410 "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") \
21411 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
21413 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
21414 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
21415 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
21417 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21419 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
21421 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>] [host-mtu-size <mtu>] [gso | no-gso]") \
21423 "<vpp-if-name> | sw_if_index <id>") \
21424 _(sw_interface_tap_v2_dump, "") \
21425 _(virtio_pci_create, \
21426 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled]") \
21427 _(virtio_pci_delete, \
21428 "<vpp-if-name> | sw_if_index <id>") \
21429 _(sw_interface_virtio_pci_dump, "") \
21431 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
21432 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
21435 "<vpp-if-name> | sw_if_index <id>") \
21437 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
21438 _(bond_detach_slave, \
21439 "sw_if_index <n>") \
21440 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
21441 _(sw_interface_bond_dump, "") \
21442 _(sw_interface_slave_dump, \
21443 "<vpp-if-name> | sw_if_index <id>") \
21444 _(ip_table_add_del, \
21445 "table <n> [ipv6] [add | del]\n") \
21446 _(ip_route_add_del, \
21447 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
21448 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
21449 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
21450 "[multipath] [count <n>] [del]") \
21451 _(ip_mroute_add_del, \
21452 "<src> <grp>/<mask> [table-id <n>]\n" \
21453 "[<intfc> | sw_if_index <id>] [local] [del]") \
21454 _(mpls_table_add_del, \
21455 "table <n> [add | del]\n") \
21456 _(mpls_route_add_del, \
21457 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
21458 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
21459 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
21460 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
21461 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
21462 "[count <n>] [del]") \
21463 _(mpls_ip_bind_unbind, \
21464 "<label> <addr/len>") \
21465 _(mpls_tunnel_add_del, \
21466 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
21467 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
21468 "[l2-only] [out-label <n>]") \
21469 _(sr_mpls_policy_add, \
21470 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
21471 _(sr_mpls_policy_del, \
21473 _(bier_table_add_del, \
21474 "<label> <sub-domain> <set> <bsl> [del]") \
21475 _(bier_route_add_del, \
21476 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
21477 "[<intfc> | sw_if_index <id>]" \
21478 "[weight <n>] [del] [multipath]") \
21479 _(proxy_arp_add_del, \
21480 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
21481 _(proxy_arp_intfc_enable_disable, \
21482 "<intfc> | sw_if_index <id> enable | disable") \
21483 _(sw_interface_set_unnumbered, \
21484 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
21485 _(ip_neighbor_add_del, \
21486 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
21487 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
21488 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
21489 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
21490 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
21491 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
21492 "[outer_vlan_id_any][inner_vlan_id_any]") \
21493 _(reset_fib, "vrf <n> [ipv6]") \
21494 _(set_ip_flow_hash, \
21495 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
21496 _(sw_interface_ip6_enable_disable, \
21497 "<intfc> | sw_if_index <id> enable | disable") \
21498 _(ip6nd_proxy_add_del, \
21499 "<intfc> | sw_if_index <id> <ip6-address>") \
21500 _(ip6nd_proxy_dump, "") \
21501 _(sw_interface_ip6nd_ra_prefix, \
21502 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
21503 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
21504 "[nolink] [isno]") \
21505 _(sw_interface_ip6nd_ra_config, \
21506 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
21507 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
21508 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
21509 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
21510 _(l2_patch_add_del, \
21511 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
21512 "enable | disable") \
21513 _(sr_localsid_add_del, \
21514 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
21515 "fib-table <num> (end.psp) sw_if_index <num>") \
21516 _(classify_add_del_table, \
21517 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
21518 " [del] [del-chain] mask <mask-value>\n" \
21519 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
21520 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
21521 _(classify_add_del_session, \
21522 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
21523 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
21524 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
21525 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
21526 _(classify_set_interface_ip_table, \
21527 "<intfc> | sw_if_index <nn> table <nn>") \
21528 _(classify_set_interface_l2_tables, \
21529 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21530 " [other-table <nn>]") \
21531 _(get_node_index, "node <node-name") \
21532 _(add_node_next, "node <node-name> next <next-node-name>") \
21533 _(l2tpv3_create_tunnel, \
21534 "client_address <ip6-addr> our_address <ip6-addr>\n" \
21535 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
21536 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
21537 _(l2tpv3_set_tunnel_cookies, \
21538 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
21539 "[new_remote_cookie <nn>]\n") \
21540 _(l2tpv3_interface_enable_disable, \
21541 "<intfc> | sw_if_index <nn> enable | disable") \
21542 _(l2tpv3_set_lookup_key, \
21543 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
21544 _(sw_if_l2tpv3_tunnel_dump, "") \
21545 _(vxlan_offload_rx, \
21546 "hw { <interface name> | hw_if_index <nn>} " \
21547 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
21548 _(vxlan_add_del_tunnel, \
21549 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21550 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
21551 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21552 _(geneve_add_del_tunnel, \
21553 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
21554 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21555 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
21556 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21557 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21558 _(gre_tunnel_add_del, \
21559 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
21560 "[teb | erspan <session-id>] [del]") \
21561 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21562 _(l2_fib_clear_table, "") \
21563 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
21564 _(l2_interface_vlan_tag_rewrite, \
21565 "<intfc> | sw_if_index <nn> \n" \
21566 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
21567 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
21568 _(create_vhost_user_if, \
21569 "socket <filename> [server] [renumber <dev_instance>] " \
21570 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
21571 "[mac <mac_address>]") \
21572 _(modify_vhost_user_if, \
21573 "<intfc> | sw_if_index <nn> socket <filename>\n" \
21574 "[server] [renumber <dev_instance>] [gso]") \
21575 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
21576 _(sw_interface_vhost_user_dump, "") \
21577 _(show_version, "") \
21578 _(show_threads, "") \
21579 _(vxlan_gpe_add_del_tunnel, \
21580 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
21581 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
21582 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
21583 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
21584 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
21585 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
21586 _(interface_name_renumber, \
21587 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
21588 _(input_acl_set_interface, \
21589 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21590 " [l2-table <nn>] [del]") \
21591 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
21592 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
21593 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
21594 _(want_ip4_arp_events, "address <ip4-address> [del]") \
21595 _(want_ip6_nd_events, "address <ip6-address> [del]") \
21596 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
21597 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
21598 _(ip_dump, "ipv4 | ipv6") \
21599 _(ipsec_spd_add_del, "spd_id <n> [del]") \
21600 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
21602 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
21603 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
21604 " integ_alg <alg> integ_key <hex>") \
21605 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
21606 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
21607 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
21608 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
21609 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
21610 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
21611 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
21612 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
21613 " [instance <n>]") \
21614 _(ipsec_sa_dump, "[sa_id <n>]") \
21615 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
21616 _(delete_loopback,"sw_if_index <nn>") \
21617 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
21618 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
21619 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
21620 _(want_interface_events, "enable|disable") \
21621 _(get_first_msg_id, "client <name>") \
21622 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
21623 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
21624 "fib-id <nn> [ip4][ip6][default]") \
21625 _(get_node_graph, " ") \
21626 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
21627 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
21628 _(ioam_disable, "") \
21629 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21630 " sw_if_index <sw_if_index> p <priority> " \
21631 "w <weight>] [del]") \
21632 _(one_add_del_locator, "locator-set <locator_name> " \
21633 "iface <intf> | sw_if_index <sw_if_index> " \
21634 "p <priority> w <weight> [del]") \
21635 _(one_add_del_local_eid,"vni <vni> eid " \
21636 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21637 "locator-set <locator_name> [del]" \
21638 "[key-id sha1|sha256 secret-key <secret-key>]")\
21639 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21640 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21641 _(one_enable_disable, "enable|disable") \
21642 _(one_map_register_enable_disable, "enable|disable") \
21643 _(one_map_register_fallback_threshold, "<value>") \
21644 _(one_rloc_probe_enable_disable, "enable|disable") \
21645 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21647 "rloc <locator> p <prio> " \
21648 "w <weight> [rloc <loc> ... ] " \
21649 "action <action> [del-all]") \
21650 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21652 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21653 _(one_use_petr, "ip-address> | disable") \
21654 _(one_map_request_mode, "src-dst|dst-only") \
21655 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21656 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21657 _(one_locator_set_dump, "[local | remote]") \
21658 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21659 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21660 "[local] | [remote]") \
21661 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21662 _(one_ndp_bd_get, "") \
21663 _(one_ndp_entries_get, "bd <bridge-domain>") \
21664 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
21665 _(one_l2_arp_bd_get, "") \
21666 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21667 _(one_stats_enable_disable, "enable|disable") \
21668 _(show_one_stats_enable_disable, "") \
21669 _(one_eid_table_vni_dump, "") \
21670 _(one_eid_table_map_dump, "l2|l3") \
21671 _(one_map_resolver_dump, "") \
21672 _(one_map_server_dump, "") \
21673 _(one_adjacencies_get, "vni <vni>") \
21674 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21675 _(show_one_rloc_probe_state, "") \
21676 _(show_one_map_register_state, "") \
21677 _(show_one_status, "") \
21678 _(one_stats_dump, "") \
21679 _(one_stats_flush, "") \
21680 _(one_get_map_request_itr_rlocs, "") \
21681 _(one_map_register_set_ttl, "<ttl>") \
21682 _(one_set_transport_protocol, "udp|api") \
21683 _(one_get_transport_protocol, "") \
21684 _(one_enable_disable_xtr_mode, "enable|disable") \
21685 _(one_show_xtr_mode, "") \
21686 _(one_enable_disable_pitr_mode, "enable|disable") \
21687 _(one_show_pitr_mode, "") \
21688 _(one_enable_disable_petr_mode, "enable|disable") \
21689 _(one_show_petr_mode, "") \
21690 _(show_one_nsh_mapping, "") \
21691 _(show_one_pitr, "") \
21692 _(show_one_use_petr, "") \
21693 _(show_one_map_request_mode, "") \
21694 _(show_one_map_register_ttl, "") \
21695 _(show_one_map_register_fallback_threshold, "") \
21696 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21697 " sw_if_index <sw_if_index> p <priority> " \
21698 "w <weight>] [del]") \
21699 _(lisp_add_del_locator, "locator-set <locator_name> " \
21700 "iface <intf> | sw_if_index <sw_if_index> " \
21701 "p <priority> w <weight> [del]") \
21702 _(lisp_add_del_local_eid,"vni <vni> eid " \
21703 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21704 "locator-set <locator_name> [del]" \
21705 "[key-id sha1|sha256 secret-key <secret-key>]") \
21706 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21707 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21708 _(lisp_enable_disable, "enable|disable") \
21709 _(lisp_map_register_enable_disable, "enable|disable") \
21710 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21711 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21713 "rloc <locator> p <prio> " \
21714 "w <weight> [rloc <loc> ... ] " \
21715 "action <action> [del-all]") \
21716 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21718 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21719 _(lisp_use_petr, "<ip-address> | disable") \
21720 _(lisp_map_request_mode, "src-dst|dst-only") \
21721 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21722 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21723 _(lisp_locator_set_dump, "[local | remote]") \
21724 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21725 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21726 "[local] | [remote]") \
21727 _(lisp_eid_table_vni_dump, "") \
21728 _(lisp_eid_table_map_dump, "l2|l3") \
21729 _(lisp_map_resolver_dump, "") \
21730 _(lisp_map_server_dump, "") \
21731 _(lisp_adjacencies_get, "vni <vni>") \
21732 _(gpe_fwd_entry_vnis_get, "") \
21733 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21734 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21735 "[table <table-id>]") \
21736 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21737 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21738 _(gpe_set_encap_mode, "lisp|vxlan") \
21739 _(gpe_get_encap_mode, "") \
21740 _(lisp_gpe_add_del_iface, "up|down") \
21741 _(lisp_gpe_enable_disable, "enable|disable") \
21742 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21743 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21744 _(show_lisp_rloc_probe_state, "") \
21745 _(show_lisp_map_register_state, "") \
21746 _(show_lisp_status, "") \
21747 _(lisp_get_map_request_itr_rlocs, "") \
21748 _(show_lisp_pitr, "") \
21749 _(show_lisp_use_petr, "") \
21750 _(show_lisp_map_request_mode, "") \
21751 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21752 _(af_packet_delete, "name <host interface name>") \
21753 _(af_packet_dump, "") \
21754 _(policer_add_del, "name <policer name> <params> [del]") \
21755 _(policer_dump, "[name <policer name>]") \
21756 _(policer_classify_set_interface, \
21757 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21758 " [l2-table <nn>] [del]") \
21759 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21760 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
21761 "[master|slave]") \
21762 _(netmap_delete, "name <interface name>") \
21763 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21764 _(mpls_table_dump, "") \
21765 _(mpls_route_dump, "table-id <ID>") \
21766 _(classify_table_ids, "") \
21767 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21768 _(classify_table_info, "table_id <nn>") \
21769 _(classify_session_dump, "table_id <nn>") \
21770 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21771 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21772 "[template_interval <nn>] [udp_checksum]") \
21773 _(ipfix_exporter_dump, "") \
21774 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21775 _(ipfix_classify_stream_dump, "") \
21776 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21777 _(ipfix_classify_table_dump, "") \
21778 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21779 _(sw_interface_span_dump, "[l2]") \
21780 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21781 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21782 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21783 _(pg_enable_disable, "[stream <id>] disable") \
21784 _(ip_source_and_port_range_check_add_del, \
21785 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21786 _(ip_source_and_port_range_check_interface_add_del, \
21787 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21788 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21789 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21790 _(l2_interface_pbb_tag_rewrite, \
21791 "<intfc> | sw_if_index <nn> \n" \
21792 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21793 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21794 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21795 _(flow_classify_set_interface, \
21796 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21797 _(flow_classify_dump, "type [ip4|ip6]") \
21798 _(ip_table_dump, "") \
21799 _(ip_route_dump, "table-id [ip4|ip6]") \
21800 _(ip_mtable_dump, "") \
21801 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21802 _(feature_enable_disable, "arc_name <arc_name> " \
21803 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21804 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21806 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21807 "mac <mac-address> [del]") \
21808 _(l2_xconnect_dump, "") \
21809 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21810 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
21811 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21812 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21813 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21814 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21815 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21816 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21817 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21818 _(sock_init_shm, "size <nnn>") \
21819 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21820 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21821 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21822 _(session_rules_dump, "") \
21823 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21824 _(output_acl_set_interface, \
21825 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21826 " [l2-table <nn>] [del]") \
21827 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21829 /* List of command functions, CLI names map directly to functions */
21830 #define foreach_cli_function \
21831 _(comment, "usage: comment <ignore-rest-of-line>") \
21832 _(dump_interface_table, "usage: dump_interface_table") \
21833 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21834 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21835 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21836 _(dump_macro_table, "usage: dump_macro_table ") \
21837 _(dump_node_table, "usage: dump_node_table") \
21838 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21839 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21840 _(elog_disable, "usage: elog_disable") \
21841 _(elog_enable, "usage: elog_enable") \
21842 _(elog_save, "usage: elog_save <filename>") \
21843 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21844 _(echo, "usage: echo <message>") \
21845 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21846 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21847 _(help, "usage: help") \
21848 _(q, "usage: quit") \
21849 _(quit, "usage: quit") \
21850 _(search_node_table, "usage: search_node_table <name>...") \
21851 _(set, "usage: set <variable-name> <value>") \
21852 _(script, "usage: script <file-name>") \
21853 _(statseg, "usage: statseg") \
21854 _(unset, "usage: unset <variable-name>")
21857 static void vl_api_##n##_t_handler_uni \
21858 (vl_api_##n##_t * mp) \
21860 vat_main_t * vam = &vat_main; \
21861 if (vam->json_output) { \
21862 vl_api_##n##_t_handler_json(mp); \
21864 vl_api_##n##_t_handler(mp); \
21867 foreach_vpe_api_reply_msg;
21868 #if VPP_API_TEST_BUILTIN == 0
21869 foreach_standalone_reply_msg;
21874 vat_api_hookup (vat_main_t * vam)
21877 vl_msg_api_set_handlers(VL_API_##N, #n, \
21878 vl_api_##n##_t_handler_uni, \
21880 vl_api_##n##_t_endian, \
21881 vl_api_##n##_t_print, \
21882 sizeof(vl_api_##n##_t), 1);
21883 foreach_vpe_api_reply_msg;
21884 #if VPP_API_TEST_BUILTIN == 0
21885 foreach_standalone_reply_msg;
21889 #if (VPP_API_TEST_BUILTIN==0)
21890 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21892 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21894 vam->function_by_name = hash_create_string (0, sizeof (uword));
21896 vam->help_by_name = hash_create_string (0, sizeof (uword));
21899 /* API messages we can send */
21900 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21901 foreach_vpe_api_msg;
21905 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21906 foreach_vpe_api_msg;
21909 /* CLI functions */
21910 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21911 foreach_cli_function;
21915 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21916 foreach_cli_function;
21920 #if VPP_API_TEST_BUILTIN
21921 static clib_error_t *
21922 vat_api_hookup_shim (vlib_main_t * vm)
21924 vat_api_hookup (&vat_main);
21928 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21932 * fd.io coding-style-patch-verification: ON
21935 * eval: (c-set-style "gnu")