2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2020 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-neighbor/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/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include <vnet/ethernet/ethernet_types_api.h>
56 #include <vnet/ip/ip_types_api.h>
57 #include "vat/json_format.h"
58 #include <vnet/ip/ip_types_api.h>
59 #include <vnet/ethernet/ethernet_types_api.h>
64 #define vl_typedefs /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* declare message handlers for each api */
70 #define vl_endianfun /* define message structures */
71 #include <vpp/api/vpe_all_api_h.h>
74 /* instantiate all the print functions we know about */
75 #if VPP_API_TEST_BUILTIN == 0
76 #define vl_print(handle, ...)
78 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
81 #include <vpp/api/vpe_all_api_h.h>
84 #define __plugin_msg_base 0
85 #include <vlibapi/vat_helper_macros.h>
87 #include <vnet/format_fns.h>
89 void vl_api_set_elog_main (elog_main_t * m);
90 int vl_api_set_elog_trace_api_messages (int enable);
92 #if VPP_API_TEST_BUILTIN == 0
102 vat_socket_connect (vat_main_t * vam)
105 api_main_t *am = vlibapi_get_main ();
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 */ )))
112 /* vpp expects the client index in network order */
113 vam->my_client_index = htonl (socket_client_main.client_index);
114 am->my_client_index = vam->my_client_index;
117 #else /* vpp built-in case, we don't do sockets... */
119 vat_socket_connect (vat_main_t * vam)
125 vl_socket_client_read (int wait)
131 vl_socket_client_write ()
137 vl_socket_client_msg_alloc (int nbytes)
145 vat_time_now (vat_main_t * vam)
147 #if VPP_API_TEST_BUILTIN
148 return vlib_time_now (vam->vlib_main);
150 return clib_time_now (&vam->clib_time);
155 errmsg (char *fmt, ...)
157 vat_main_t *vam = &vat_main;
162 s = va_format (0, fmt, &va);
167 #if VPP_API_TEST_BUILTIN
168 vlib_cli_output (vam->vlib_main, (char *) s);
171 if (vam->ifp != stdin)
172 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
173 vam->input_line_number);
175 fformat (vam->ofp, "%s\n", (char *) s);
183 #if VPP_API_TEST_BUILTIN == 0
185 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
187 vat_main_t *vam = va_arg (*args, vat_main_t *);
188 u32 *result = va_arg (*args, u32 *);
192 if (!unformat (input, "%s", &if_name))
195 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
203 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
208 /* Parse an IP4 address %d.%d.%d.%d. */
210 unformat_ip4_address (unformat_input_t * input, va_list * args)
212 u8 *result = va_arg (*args, u8 *);
215 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
218 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
230 unformat_ethernet_address (unformat_input_t * input, va_list * args)
232 u8 *result = va_arg (*args, u8 *);
235 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
236 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
240 for (i = 0; i < 6; i++)
241 if (a[i] >= (1 << 8))
244 for (i = 0; i < 6; i++)
250 /* Returns ethernet type as an int in host byte order. */
252 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
255 u16 *result = va_arg (*args, u16 *);
259 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
261 if (type >= (1 << 16))
269 /* Parse an IP46 address. */
271 unformat_ip46_address (unformat_input_t * input, va_list * args)
273 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
274 ip46_type_t type = va_arg (*args, ip46_type_t);
275 if ((type != IP46_TYPE_IP6) &&
276 unformat (input, "%U", unformat_ip4_address, &ip46->ip4))
278 ip46_address_mask_ip4 (ip46);
281 else if ((type != IP46_TYPE_IP4) &&
282 unformat (input, "%U", unformat_ip6_address, &ip46->ip6))
289 /* Parse an IP6 address. */
291 unformat_ip6_address (unformat_input_t * input, va_list * args)
293 ip6_address_t *result = va_arg (*args, ip6_address_t *);
295 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
296 uword c, n_colon, double_colon_index;
298 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
299 double_colon_index = ARRAY_LEN (hex_quads);
300 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
303 if (c >= '0' && c <= '9')
305 else if (c >= 'a' && c <= 'f')
306 hex_digit = c + 10 - 'a';
307 else if (c >= 'A' && c <= 'F')
308 hex_digit = c + 10 - 'A';
309 else if (c == ':' && n_colon < 2)
313 unformat_put_input (input);
317 /* Too many hex quads. */
318 if (n_hex_quads >= ARRAY_LEN (hex_quads))
323 hex_quad = (hex_quad << 4) | hex_digit;
325 /* Hex quad must fit in 16 bits. */
326 if (n_hex_digits >= 4)
333 /* Save position of :: */
336 /* More than one :: ? */
337 if (double_colon_index < ARRAY_LEN (hex_quads))
339 double_colon_index = n_hex_quads;
342 if (n_colon > 0 && n_hex_digits > 0)
344 hex_quads[n_hex_quads++] = hex_quad;
350 if (n_hex_digits > 0)
351 hex_quads[n_hex_quads++] = hex_quad;
356 /* Expand :: to appropriate number of zero hex quads. */
357 if (double_colon_index < ARRAY_LEN (hex_quads))
359 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
361 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
362 hex_quads[n_zero + i] = hex_quads[i];
364 for (i = 0; i < n_zero; i++)
365 hex_quads[double_colon_index + i] = 0;
367 n_hex_quads = ARRAY_LEN (hex_quads);
370 /* Too few hex quads given. */
371 if (n_hex_quads < ARRAY_LEN (hex_quads))
374 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
375 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
382 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
384 u32 *r = va_arg (*args, u32 *);
387 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
388 foreach_ipsec_policy_action
396 format_ipsec_crypto_alg (u8 * s, va_list * args)
398 u32 i = va_arg (*args, u32);
403 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
404 foreach_ipsec_crypto_alg
407 return format (s, "unknown");
409 return format (s, "%s", t);
413 format_ipsec_integ_alg (u8 * s, va_list * args)
415 u32 i = va_arg (*args, u32);
420 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
421 foreach_ipsec_integ_alg
424 return format (s, "unknown");
426 return format (s, "%s", t);
429 #else /* VPP_API_TEST_BUILTIN == 1 */
431 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
433 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
434 vnet_main_t *vnm = vnet_get_main ();
435 u32 *result = va_arg (*args, u32 *);
437 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
441 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
443 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
444 vnet_main_t *vnm = vnet_get_main ();
445 u32 *result = va_arg (*args, u32 *);
447 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
450 #endif /* VPP_API_TEST_BUILTIN */
453 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
455 u32 *r = va_arg (*args, u32 *);
458 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
459 foreach_ipsec_crypto_alg
467 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
469 u32 *r = va_arg (*args, u32 *);
472 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
473 foreach_ipsec_integ_alg
481 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
483 u8 *r = va_arg (*args, u8 *);
485 if (unformat (input, "kbps"))
486 *r = SSE2_QOS_RATE_KBPS;
487 else if (unformat (input, "pps"))
488 *r = SSE2_QOS_RATE_PPS;
495 unformat_policer_round_type (unformat_input_t * input, va_list * args)
497 u8 *r = va_arg (*args, u8 *);
499 if (unformat (input, "closest"))
500 *r = SSE2_QOS_ROUND_TO_CLOSEST;
501 else if (unformat (input, "up"))
502 *r = SSE2_QOS_ROUND_TO_UP;
503 else if (unformat (input, "down"))
504 *r = SSE2_QOS_ROUND_TO_DOWN;
511 unformat_policer_type (unformat_input_t * input, va_list * args)
513 u8 *r = va_arg (*args, u8 *);
515 if (unformat (input, "1r2c"))
516 *r = SSE2_QOS_POLICER_TYPE_1R2C;
517 else if (unformat (input, "1r3c"))
518 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
519 else if (unformat (input, "2r3c-2698"))
520 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
521 else if (unformat (input, "2r3c-4115"))
522 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
523 else if (unformat (input, "2r3c-mef5cf1"))
524 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
531 unformat_dscp (unformat_input_t * input, va_list * va)
533 u8 *r = va_arg (*va, u8 *);
536 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
545 unformat_policer_action_type (unformat_input_t * input, va_list * va)
547 sse2_qos_pol_action_params_st *a
548 = va_arg (*va, sse2_qos_pol_action_params_st *);
550 if (unformat (input, "drop"))
551 a->action_type = SSE2_QOS_ACTION_DROP;
552 else if (unformat (input, "transmit"))
553 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
554 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
555 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
562 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
564 u32 *r = va_arg (*va, u32 *);
567 if (unformat (input, "ip4"))
568 tid = POLICER_CLASSIFY_TABLE_IP4;
569 else if (unformat (input, "ip6"))
570 tid = POLICER_CLASSIFY_TABLE_IP6;
571 else if (unformat (input, "l2"))
572 tid = POLICER_CLASSIFY_TABLE_L2;
581 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
583 u32 *r = va_arg (*va, u32 *);
586 if (unformat (input, "ip4"))
587 tid = FLOW_CLASSIFY_TABLE_IP4;
588 else if (unformat (input, "ip6"))
589 tid = FLOW_CLASSIFY_TABLE_IP6;
597 #if (VPP_API_TEST_BUILTIN==0)
599 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
600 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
601 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
602 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
605 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
607 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
608 mfib_itf_attribute_t attr;
611 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
613 if (unformat (input, mfib_itf_flag_long_names[attr]))
614 *iflags |= (1 << attr);
616 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
618 if (unformat (input, mfib_itf_flag_names[attr]))
619 *iflags |= (1 << attr);
622 return (old == *iflags ? 0 : 1);
626 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
628 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
629 mfib_entry_attribute_t attr;
632 FOR_EACH_MFIB_ATTRIBUTE (attr)
634 if (unformat (input, mfib_flag_long_names[attr]))
635 *eflags |= (1 << attr);
637 FOR_EACH_MFIB_ATTRIBUTE (attr)
639 if (unformat (input, mfib_flag_names[attr]))
640 *eflags |= (1 << attr);
643 return (old == *eflags ? 0 : 1);
647 format_ip4_address (u8 * s, va_list * args)
649 u8 *a = va_arg (*args, u8 *);
650 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
654 format_ip6_address (u8 * s, va_list * args)
656 ip6_address_t *a = va_arg (*args, ip6_address_t *);
657 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
659 i_max_n_zero = ARRAY_LEN (a->as_u16);
661 i_first_zero = i_max_n_zero;
663 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
665 u32 is_zero = a->as_u16[i] == 0;
666 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
672 if ((!is_zero && n_zeros > max_n_zeros)
673 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
675 i_max_n_zero = i_first_zero;
676 max_n_zeros = n_zeros;
677 i_first_zero = ARRAY_LEN (a->as_u16);
682 last_double_colon = 0;
683 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
685 if (i == i_max_n_zero && max_n_zeros > 1)
687 s = format (s, "::");
688 i += max_n_zeros - 1;
689 last_double_colon = 1;
693 s = format (s, "%s%x",
694 (last_double_colon || i == 0) ? "" : ":",
695 clib_net_to_host_u16 (a->as_u16[i]));
696 last_double_colon = 0;
703 /* Format an IP46 address. */
705 format_ip46_address (u8 * s, va_list * args)
707 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
708 ip46_type_t type = va_arg (*args, ip46_type_t);
714 is_ip4 = ip46_address_is_ip4 (ip46);
725 format (s, "%U", format_ip4_address, &ip46->ip4) :
726 format (s, "%U", format_ip6_address, &ip46->ip6);
730 format_ethernet_address (u8 * s, va_list * args)
732 u8 *a = va_arg (*args, u8 *);
734 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
735 a[0], a[1], a[2], a[3], a[4], a[5]);
740 increment_v4_address (vl_api_ip4_address_t * i)
742 ip4_address_t *a = (ip4_address_t *) i;
745 v = ntohl (a->as_u32) + 1;
746 a->as_u32 = ntohl (v);
750 increment_v6_address (vl_api_ip6_address_t * i)
752 ip6_address_t *a = (ip6_address_t *) i;
755 v0 = clib_net_to_host_u64 (a->as_u64[0]);
756 v1 = clib_net_to_host_u64 (a->as_u64[1]);
761 a->as_u64[0] = clib_net_to_host_u64 (v0);
762 a->as_u64[1] = clib_net_to_host_u64 (v1);
766 increment_address (vl_api_address_t * a)
768 if (a->af == ADDRESS_IP4)
769 increment_v4_address (&a->un.ip4);
770 else if (a->af == ADDRESS_IP6)
771 increment_v6_address (&a->un.ip6);
775 set_ip4_address (vl_api_address_t * a, u32 v)
777 if (a->af == ADDRESS_IP4)
779 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
785 ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
788 dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
790 clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
791 sizeof (ip6_address_t));
795 increment_mac_address (u8 * mac)
797 u64 tmp = *((u64 *) mac);
798 tmp = clib_net_to_host_u64 (tmp);
799 tmp += 1 << 16; /* skip unused (least significant) octets */
800 tmp = clib_host_to_net_u64 (tmp);
802 clib_memcpy (mac, &tmp, 6);
806 vat_json_object_add_address (vat_json_node_t * node,
807 const char *str, const vl_api_address_t * addr)
809 if (ADDRESS_IP6 == addr->af)
813 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
814 vat_json_object_add_ip6 (node, str, ip6);
820 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
821 vat_json_object_add_ip4 (node, str, ip4);
826 vat_json_object_add_prefix (vat_json_node_t * node,
827 const vl_api_prefix_t * prefix)
829 vat_json_object_add_uint (node, "len", prefix->len);
830 vat_json_object_add_address (node, "address", &prefix->address);
833 static void vl_api_create_loopback_reply_t_handler
834 (vl_api_create_loopback_reply_t * mp)
836 vat_main_t *vam = &vat_main;
837 i32 retval = ntohl (mp->retval);
839 vam->retval = retval;
840 vam->regenerate_interface_table = 1;
841 vam->sw_if_index = ntohl (mp->sw_if_index);
842 vam->result_ready = 1;
845 static void vl_api_create_loopback_reply_t_handler_json
846 (vl_api_create_loopback_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 vat_json_node_t node;
851 vat_json_init_object (&node);
852 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
853 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
855 vat_json_print (vam->ofp, &node);
856 vat_json_free (&node);
857 vam->retval = ntohl (mp->retval);
858 vam->result_ready = 1;
861 static void vl_api_create_loopback_instance_reply_t_handler
862 (vl_api_create_loopback_instance_reply_t * mp)
864 vat_main_t *vam = &vat_main;
865 i32 retval = ntohl (mp->retval);
867 vam->retval = retval;
868 vam->regenerate_interface_table = 1;
869 vam->sw_if_index = ntohl (mp->sw_if_index);
870 vam->result_ready = 1;
873 static void vl_api_create_loopback_instance_reply_t_handler_json
874 (vl_api_create_loopback_instance_reply_t * mp)
876 vat_main_t *vam = &vat_main;
877 vat_json_node_t node;
879 vat_json_init_object (&node);
880 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
881 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
883 vat_json_print (vam->ofp, &node);
884 vat_json_free (&node);
885 vam->retval = ntohl (mp->retval);
886 vam->result_ready = 1;
889 static void vl_api_af_packet_create_reply_t_handler
890 (vl_api_af_packet_create_reply_t * mp)
892 vat_main_t *vam = &vat_main;
893 i32 retval = ntohl (mp->retval);
895 vam->retval = retval;
896 vam->regenerate_interface_table = 1;
897 vam->sw_if_index = ntohl (mp->sw_if_index);
898 vam->result_ready = 1;
901 static void vl_api_af_packet_create_reply_t_handler_json
902 (vl_api_af_packet_create_reply_t * mp)
904 vat_main_t *vam = &vat_main;
905 vat_json_node_t node;
907 vat_json_init_object (&node);
908 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
909 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
911 vat_json_print (vam->ofp, &node);
912 vat_json_free (&node);
914 vam->retval = ntohl (mp->retval);
915 vam->result_ready = 1;
918 static void vl_api_create_vlan_subif_reply_t_handler
919 (vl_api_create_vlan_subif_reply_t * mp)
921 vat_main_t *vam = &vat_main;
922 i32 retval = ntohl (mp->retval);
924 vam->retval = retval;
925 vam->regenerate_interface_table = 1;
926 vam->sw_if_index = ntohl (mp->sw_if_index);
927 vam->result_ready = 1;
930 static void vl_api_create_vlan_subif_reply_t_handler_json
931 (vl_api_create_vlan_subif_reply_t * mp)
933 vat_main_t *vam = &vat_main;
934 vat_json_node_t node;
936 vat_json_init_object (&node);
937 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
938 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
940 vat_json_print (vam->ofp, &node);
941 vat_json_free (&node);
943 vam->retval = ntohl (mp->retval);
944 vam->result_ready = 1;
947 static void vl_api_create_subif_reply_t_handler
948 (vl_api_create_subif_reply_t * mp)
950 vat_main_t *vam = &vat_main;
951 i32 retval = ntohl (mp->retval);
953 vam->retval = retval;
954 vam->regenerate_interface_table = 1;
955 vam->sw_if_index = ntohl (mp->sw_if_index);
956 vam->result_ready = 1;
959 static void vl_api_create_subif_reply_t_handler_json
960 (vl_api_create_subif_reply_t * mp)
962 vat_main_t *vam = &vat_main;
963 vat_json_node_t node;
965 vat_json_init_object (&node);
966 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
967 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
969 vat_json_print (vam->ofp, &node);
970 vat_json_free (&node);
972 vam->retval = ntohl (mp->retval);
973 vam->result_ready = 1;
976 static void vl_api_interface_name_renumber_reply_t_handler
977 (vl_api_interface_name_renumber_reply_t * mp)
979 vat_main_t *vam = &vat_main;
980 i32 retval = ntohl (mp->retval);
982 vam->retval = retval;
983 vam->regenerate_interface_table = 1;
984 vam->result_ready = 1;
987 static void vl_api_interface_name_renumber_reply_t_handler_json
988 (vl_api_interface_name_renumber_reply_t * mp)
990 vat_main_t *vam = &vat_main;
991 vat_json_node_t node;
993 vat_json_init_object (&node);
994 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
996 vat_json_print (vam->ofp, &node);
997 vat_json_free (&node);
999 vam->retval = ntohl (mp->retval);
1000 vam->result_ready = 1;
1004 * Special-case: build the interface table, maintain
1005 * the next loopback sw_if_index vbl.
1007 static void vl_api_sw_interface_details_t_handler
1008 (vl_api_sw_interface_details_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 u8 *s = format (0, "%s%c", mp->interface_name, 0);
1013 hash_set_mem (vam->sw_if_index_by_interface_name, s,
1014 ntohl (mp->sw_if_index));
1016 /* In sub interface case, fill the sub interface table entry */
1017 if (mp->sw_if_index != mp->sup_sw_if_index)
1019 sw_interface_subif_t *sub = NULL;
1021 vec_add2 (vam->sw_if_subif_table, sub, 1);
1023 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
1024 strncpy ((char *) sub->interface_name, (char *) s,
1025 vec_len (sub->interface_name));
1026 sub->sw_if_index = ntohl (mp->sw_if_index);
1027 sub->sub_id = ntohl (mp->sub_id);
1029 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1031 sub->sub_number_of_tags = mp->sub_number_of_tags;
1032 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1033 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1035 /* vlan tag rewrite */
1036 sub->vtr_op = ntohl (mp->vtr_op);
1037 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1038 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1039 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1043 static void vl_api_sw_interface_details_t_handler_json
1044 (vl_api_sw_interface_details_t * mp)
1046 vat_main_t *vam = &vat_main;
1047 vat_json_node_t *node = NULL;
1049 if (VAT_JSON_ARRAY != vam->json_tree.type)
1051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1052 vat_json_init_array (&vam->json_tree);
1054 node = vat_json_array_add (&vam->json_tree);
1056 vat_json_init_object (node);
1057 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1058 vat_json_object_add_uint (node, "sup_sw_if_index",
1059 ntohl (mp->sup_sw_if_index));
1060 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1061 sizeof (mp->l2_address));
1062 vat_json_object_add_string_copy (node, "interface_name",
1063 mp->interface_name);
1064 vat_json_object_add_string_copy (node, "interface_dev_type",
1065 mp->interface_dev_type);
1066 vat_json_object_add_uint (node, "flags", mp->flags);
1067 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1068 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1069 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1070 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1071 vat_json_object_add_uint (node, "sub_number_of_tags",
1072 mp->sub_number_of_tags);
1073 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1074 ntohs (mp->sub_outer_vlan_id));
1075 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1076 ntohs (mp->sub_inner_vlan_id));
1077 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1078 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1079 vat_json_object_add_uint (node, "vtr_push_dot1q",
1080 ntohl (mp->vtr_push_dot1q));
1081 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1082 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1083 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1085 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1087 format_ethernet_address,
1089 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1091 format_ethernet_address,
1093 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1094 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1098 #if VPP_API_TEST_BUILTIN == 0
1099 static void vl_api_sw_interface_event_t_handler
1100 (vl_api_sw_interface_event_t * mp)
1102 vat_main_t *vam = &vat_main;
1103 if (vam->interface_event_display)
1104 errmsg ("interface flags: sw_if_index %d %s %s",
1105 ntohl (mp->sw_if_index),
1106 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1107 "admin-up" : "admin-down",
1108 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1109 "link-up" : "link-down");
1113 __clib_unused static void
1114 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1116 /* JSON output not supported */
1120 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1122 vat_main_t *vam = &vat_main;
1123 i32 retval = ntohl (mp->retval);
1125 vam->retval = retval;
1126 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1127 vam->result_ready = 1;
1131 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 vat_json_node_t node;
1138 vat_json_init_object (&node);
1139 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1140 vat_json_object_add_uint (&node, "reply_in_shmem",
1141 ntohl (mp->reply_in_shmem));
1142 /* Toss the shared-memory original... */
1143 oldheap = vl_msg_push_heap ();
1145 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1148 vl_msg_pop_heap (oldheap);
1150 vat_json_print (vam->ofp, &node);
1151 vat_json_free (&node);
1153 vam->retval = ntohl (mp->retval);
1154 vam->result_ready = 1;
1158 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1160 vat_main_t *vam = &vat_main;
1161 i32 retval = ntohl (mp->retval);
1163 vec_reset_length (vam->cmd_reply);
1165 vam->retval = retval;
1167 vam->cmd_reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1168 vam->result_ready = 1;
1172 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1176 u8 *reply = 0; /* reply vector */
1178 reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1179 vec_reset_length (vam->cmd_reply);
1181 vat_json_init_object (&node);
1182 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1183 vat_json_object_add_string_copy (&node, "reply", reply);
1185 vat_json_print (vam->ofp, &node);
1186 vat_json_free (&node);
1189 vam->retval = ntohl (mp->retval);
1190 vam->result_ready = 1;
1193 static void vl_api_classify_add_del_table_reply_t_handler
1194 (vl_api_classify_add_del_table_reply_t * mp)
1196 vat_main_t *vam = &vat_main;
1197 i32 retval = ntohl (mp->retval);
1198 if (vam->async_mode)
1200 vam->async_errors += (retval < 0);
1204 vam->retval = retval;
1206 ((mp->new_table_index != 0xFFFFFFFF) ||
1207 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1208 (mp->match_n_vectors != 0xFFFFFFFF)))
1210 * Note: this is just barely thread-safe, depends on
1211 * the main thread spinning waiting for an answer...
1213 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1214 ntohl (mp->new_table_index),
1215 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1216 vam->result_ready = 1;
1220 static void vl_api_classify_add_del_table_reply_t_handler_json
1221 (vl_api_classify_add_del_table_reply_t * mp)
1223 vat_main_t *vam = &vat_main;
1224 vat_json_node_t node;
1226 vat_json_init_object (&node);
1227 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1228 vat_json_object_add_uint (&node, "new_table_index",
1229 ntohl (mp->new_table_index));
1230 vat_json_object_add_uint (&node, "skip_n_vectors",
1231 ntohl (mp->skip_n_vectors));
1232 vat_json_object_add_uint (&node, "match_n_vectors",
1233 ntohl (mp->match_n_vectors));
1235 vat_json_print (vam->ofp, &node);
1236 vat_json_free (&node);
1238 vam->retval = ntohl (mp->retval);
1239 vam->result_ready = 1;
1242 static void vl_api_get_node_index_reply_t_handler
1243 (vl_api_get_node_index_reply_t * mp)
1245 vat_main_t *vam = &vat_main;
1246 i32 retval = ntohl (mp->retval);
1247 if (vam->async_mode)
1249 vam->async_errors += (retval < 0);
1253 vam->retval = retval;
1255 errmsg ("node index %d", ntohl (mp->node_index));
1256 vam->result_ready = 1;
1260 static void vl_api_get_node_index_reply_t_handler_json
1261 (vl_api_get_node_index_reply_t * mp)
1263 vat_main_t *vam = &vat_main;
1264 vat_json_node_t node;
1266 vat_json_init_object (&node);
1267 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1268 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1270 vat_json_print (vam->ofp, &node);
1271 vat_json_free (&node);
1273 vam->retval = ntohl (mp->retval);
1274 vam->result_ready = 1;
1277 static void vl_api_get_next_index_reply_t_handler
1278 (vl_api_get_next_index_reply_t * mp)
1280 vat_main_t *vam = &vat_main;
1281 i32 retval = ntohl (mp->retval);
1282 if (vam->async_mode)
1284 vam->async_errors += (retval < 0);
1288 vam->retval = retval;
1290 errmsg ("next node index %d", ntohl (mp->next_index));
1291 vam->result_ready = 1;
1295 static void vl_api_get_next_index_reply_t_handler_json
1296 (vl_api_get_next_index_reply_t * mp)
1298 vat_main_t *vam = &vat_main;
1299 vat_json_node_t node;
1301 vat_json_init_object (&node);
1302 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1303 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1305 vat_json_print (vam->ofp, &node);
1306 vat_json_free (&node);
1308 vam->retval = ntohl (mp->retval);
1309 vam->result_ready = 1;
1312 static void vl_api_add_node_next_reply_t_handler
1313 (vl_api_add_node_next_reply_t * mp)
1315 vat_main_t *vam = &vat_main;
1316 i32 retval = ntohl (mp->retval);
1317 if (vam->async_mode)
1319 vam->async_errors += (retval < 0);
1323 vam->retval = retval;
1325 errmsg ("next index %d", ntohl (mp->next_index));
1326 vam->result_ready = 1;
1330 static void vl_api_add_node_next_reply_t_handler_json
1331 (vl_api_add_node_next_reply_t * mp)
1333 vat_main_t *vam = &vat_main;
1334 vat_json_node_t node;
1336 vat_json_init_object (&node);
1337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1338 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1340 vat_json_print (vam->ofp, &node);
1341 vat_json_free (&node);
1343 vam->retval = ntohl (mp->retval);
1344 vam->result_ready = 1;
1347 static void vl_api_show_version_reply_t_handler
1348 (vl_api_show_version_reply_t * mp)
1350 vat_main_t *vam = &vat_main;
1351 i32 retval = ntohl (mp->retval);
1355 errmsg (" program: %s", mp->program);
1356 errmsg (" version: %s", mp->version);
1357 errmsg (" build date: %s", mp->build_date);
1358 errmsg ("build directory: %s", mp->build_directory);
1360 vam->retval = retval;
1361 vam->result_ready = 1;
1364 static void vl_api_show_version_reply_t_handler_json
1365 (vl_api_show_version_reply_t * mp)
1367 vat_main_t *vam = &vat_main;
1368 vat_json_node_t node;
1370 vat_json_init_object (&node);
1371 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1372 vat_json_object_add_string_copy (&node, "program", mp->program);
1373 vat_json_object_add_string_copy (&node, "version", mp->version);
1374 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1375 vat_json_object_add_string_copy (&node, "build_directory",
1376 mp->build_directory);
1378 vat_json_print (vam->ofp, &node);
1379 vat_json_free (&node);
1381 vam->retval = ntohl (mp->retval);
1382 vam->result_ready = 1;
1385 static void vl_api_show_threads_reply_t_handler
1386 (vl_api_show_threads_reply_t * mp)
1388 vat_main_t *vam = &vat_main;
1389 i32 retval = ntohl (mp->retval);
1393 count = ntohl (mp->count);
1395 for (i = 0; i < count; i++)
1397 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1398 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1399 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1400 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1401 ntohl (mp->thread_data[i].cpu_socket));
1403 vam->retval = retval;
1404 vam->result_ready = 1;
1407 static void vl_api_show_threads_reply_t_handler_json
1408 (vl_api_show_threads_reply_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t node;
1412 vl_api_thread_data_t *td;
1413 i32 retval = ntohl (mp->retval);
1417 count = ntohl (mp->count);
1419 vat_json_init_object (&node);
1420 vat_json_object_add_int (&node, "retval", retval);
1421 vat_json_object_add_uint (&node, "count", count);
1423 for (i = 0; i < count; i++)
1425 td = &mp->thread_data[i];
1426 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1427 vat_json_object_add_string_copy (&node, "name", td->name);
1428 vat_json_object_add_string_copy (&node, "type", td->type);
1429 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1430 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1431 vat_json_object_add_int (&node, "core", ntohl (td->id));
1432 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1435 vat_json_print (vam->ofp, &node);
1436 vat_json_free (&node);
1438 vam->retval = retval;
1439 vam->result_ready = 1;
1443 api_show_threads (vat_main_t * vam)
1445 vl_api_show_threads_t *mp;
1449 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1450 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1452 M (SHOW_THREADS, mp);
1460 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1462 u32 n_macs = ntohl (mp->n_macs);
1463 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1464 ntohl (mp->pid), mp->client_index, n_macs);
1466 for (i = 0; i < n_macs; i++)
1468 vl_api_mac_entry_t *mac = &mp->mac[i];
1469 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1470 i + 1, ntohl (mac->sw_if_index),
1471 format_ethernet_address, mac->mac_addr, mac->action);
1478 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1480 /* JSON output not supported */
1483 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1484 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1487 * Special-case: build the bridge domain table, maintain
1488 * the next bd id vbl.
1490 static void vl_api_bridge_domain_details_t_handler
1491 (vl_api_bridge_domain_details_t * mp)
1493 vat_main_t *vam = &vat_main;
1494 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1497 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1498 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1500 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1501 ntohl (mp->bd_id), mp->learn, mp->forward,
1502 mp->flood, ntohl (mp->bvi_sw_if_index),
1503 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1507 vl_api_bridge_domain_sw_if_t *sw_ifs;
1508 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1511 sw_ifs = mp->sw_if_details;
1512 for (i = 0; i < n_sw_ifs; i++)
1518 sw_if_index = ntohl (sw_ifs->sw_if_index);
1521 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1523 if ((u32) p->value[0] == sw_if_index)
1525 sw_if_name = (u8 *)(p->key);
1530 print (vam->ofp, "%7d %3d %s", sw_if_index,
1531 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1532 "sw_if_index not found!");
1539 static void vl_api_bridge_domain_details_t_handler_json
1540 (vl_api_bridge_domain_details_t * mp)
1542 vat_main_t *vam = &vat_main;
1543 vat_json_node_t *node, *array = NULL;
1544 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1546 if (VAT_JSON_ARRAY != vam->json_tree.type)
1548 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1549 vat_json_init_array (&vam->json_tree);
1551 node = vat_json_array_add (&vam->json_tree);
1553 vat_json_init_object (node);
1554 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1555 vat_json_object_add_uint (node, "flood", mp->flood);
1556 vat_json_object_add_uint (node, "forward", mp->forward);
1557 vat_json_object_add_uint (node, "learn", mp->learn);
1558 vat_json_object_add_uint (node, "bvi_sw_if_index",
1559 ntohl (mp->bvi_sw_if_index));
1560 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1561 array = vat_json_object_add (node, "sw_if");
1562 vat_json_init_array (array);
1568 vl_api_bridge_domain_sw_if_t *sw_ifs;
1571 sw_ifs = mp->sw_if_details;
1572 for (i = 0; i < n_sw_ifs; i++)
1574 node = vat_json_array_add (array);
1575 vat_json_init_object (node);
1576 vat_json_object_add_uint (node, "sw_if_index",
1577 ntohl (sw_ifs->sw_if_index));
1578 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1584 static void vl_api_control_ping_reply_t_handler
1585 (vl_api_control_ping_reply_t * mp)
1587 vat_main_t *vam = &vat_main;
1588 i32 retval = ntohl (mp->retval);
1589 if (vam->async_mode)
1591 vam->async_errors += (retval < 0);
1595 vam->retval = retval;
1596 vam->result_ready = 1;
1598 if (vam->socket_client_main)
1599 vam->socket_client_main->control_pings_outstanding--;
1602 static void vl_api_control_ping_reply_t_handler_json
1603 (vl_api_control_ping_reply_t * mp)
1605 vat_main_t *vam = &vat_main;
1606 i32 retval = ntohl (mp->retval);
1608 if (VAT_JSON_NONE != vam->json_tree.type)
1610 vat_json_print (vam->ofp, &vam->json_tree);
1611 vat_json_free (&vam->json_tree);
1612 vam->json_tree.type = VAT_JSON_NONE;
1617 vat_json_init_array (&vam->json_tree);
1618 vat_json_print (vam->ofp, &vam->json_tree);
1619 vam->json_tree.type = VAT_JSON_NONE;
1622 vam->retval = retval;
1623 vam->result_ready = 1;
1627 vl_api_bridge_domain_set_mac_age_reply_t_handler
1628 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1630 vat_main_t *vam = &vat_main;
1631 i32 retval = ntohl (mp->retval);
1632 if (vam->async_mode)
1634 vam->async_errors += (retval < 0);
1638 vam->retval = retval;
1639 vam->result_ready = 1;
1643 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1644 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1646 vat_main_t *vam = &vat_main;
1647 vat_json_node_t node;
1649 vat_json_init_object (&node);
1650 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1662 vat_main_t *vam = &vat_main;
1663 i32 retval = ntohl (mp->retval);
1664 if (vam->async_mode)
1666 vam->async_errors += (retval < 0);
1670 vam->retval = retval;
1671 vam->result_ready = 1;
1675 static void vl_api_l2_flags_reply_t_handler_json
1676 (vl_api_l2_flags_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 vat_json_node_t node;
1681 vat_json_init_object (&node);
1682 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1683 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1684 ntohl (mp->resulting_feature_bitmap));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_bridge_flags_reply_t_handler
1694 (vl_api_bridge_flags_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->result_ready = 1;
1709 static void vl_api_bridge_flags_reply_t_handler_json
1710 (vl_api_bridge_flags_reply_t * mp)
1712 vat_main_t *vam = &vat_main;
1713 vat_json_node_t node;
1715 vat_json_init_object (&node);
1716 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1717 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1718 ntohl (mp->resulting_feature_bitmap));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1728 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1745 static void vl_api_tap_create_v2_reply_t_handler_json
1746 (vl_api_tap_create_v2_reply_t * mp)
1748 vat_main_t *vam = &vat_main;
1749 vat_json_node_t node;
1751 vat_json_init_object (&node);
1752 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1753 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1755 vat_json_print (vam->ofp, &node);
1756 vat_json_free (&node);
1758 vam->retval = ntohl (mp->retval);
1759 vam->result_ready = 1;
1764 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1766 vat_main_t *vam = &vat_main;
1767 i32 retval = ntohl (mp->retval);
1768 if (vam->async_mode)
1770 vam->async_errors += (retval < 0);
1774 vam->retval = retval;
1775 vam->result_ready = 1;
1779 static void vl_api_tap_delete_v2_reply_t_handler_json
1780 (vl_api_tap_delete_v2_reply_t * mp)
1782 vat_main_t *vam = &vat_main;
1783 vat_json_node_t node;
1785 vat_json_init_object (&node);
1786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1796 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1799 vat_main_t *vam = &vat_main;
1800 i32 retval = ntohl (mp->retval);
1801 if (vam->async_mode)
1803 vam->async_errors += (retval < 0);
1807 vam->retval = retval;
1808 vam->sw_if_index = ntohl (mp->sw_if_index);
1809 vam->result_ready = 1;
1813 static void vl_api_virtio_pci_create_reply_t_handler_json
1814 (vl_api_virtio_pci_create_reply_t * mp)
1816 vat_main_t *vam = &vat_main;
1817 vat_json_node_t node;
1819 vat_json_init_object (&node);
1820 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1821 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1823 vat_json_print (vam->ofp, &node);
1824 vat_json_free (&node);
1826 vam->retval = ntohl (mp->retval);
1827 vam->result_ready = 1;
1832 vl_api_virtio_pci_create_v2_reply_t_handler
1833 (vl_api_virtio_pci_create_v2_reply_t * mp)
1835 vat_main_t *vam = &vat_main;
1836 i32 retval = ntohl (mp->retval);
1837 if (vam->async_mode)
1839 vam->async_errors += (retval < 0);
1843 vam->retval = retval;
1844 vam->sw_if_index = ntohl (mp->sw_if_index);
1845 vam->result_ready = 1;
1849 static void vl_api_virtio_pci_create_v2_reply_t_handler_json
1850 (vl_api_virtio_pci_create_v2_reply_t * mp)
1852 vat_main_t *vam = &vat_main;
1853 vat_json_node_t node;
1855 vat_json_init_object (&node);
1856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1859 vat_json_print (vam->ofp, &node);
1860 vat_json_free (&node);
1862 vam->retval = ntohl (mp->retval);
1863 vam->result_ready = 1;
1867 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1870 vat_main_t *vam = &vat_main;
1871 i32 retval = ntohl (mp->retval);
1872 if (vam->async_mode)
1874 vam->async_errors += (retval < 0);
1878 vam->retval = retval;
1879 vam->result_ready = 1;
1883 static void vl_api_virtio_pci_delete_reply_t_handler_json
1884 (vl_api_virtio_pci_delete_reply_t * mp)
1886 vat_main_t *vam = &vat_main;
1887 vat_json_node_t node;
1889 vat_json_init_object (&node);
1890 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1892 vat_json_print (vam->ofp, &node);
1893 vat_json_free (&node);
1895 vam->retval = ntohl (mp->retval);
1896 vam->result_ready = 1;
1900 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1902 vat_main_t *vam = &vat_main;
1903 i32 retval = ntohl (mp->retval);
1905 if (vam->async_mode)
1907 vam->async_errors += (retval < 0);
1911 vam->retval = retval;
1912 vam->sw_if_index = ntohl (mp->sw_if_index);
1913 vam->result_ready = 1;
1917 static void vl_api_bond_create_reply_t_handler_json
1918 (vl_api_bond_create_reply_t * mp)
1920 vat_main_t *vam = &vat_main;
1921 vat_json_node_t node;
1923 vat_json_init_object (&node);
1924 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1925 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1927 vat_json_print (vam->ofp, &node);
1928 vat_json_free (&node);
1930 vam->retval = ntohl (mp->retval);
1931 vam->result_ready = 1;
1935 vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp)
1937 vat_main_t *vam = &vat_main;
1938 i32 retval = ntohl (mp->retval);
1940 if (vam->async_mode)
1942 vam->async_errors += (retval < 0);
1946 vam->retval = retval;
1947 vam->sw_if_index = ntohl (mp->sw_if_index);
1948 vam->result_ready = 1;
1952 static void vl_api_bond_create2_reply_t_handler_json
1953 (vl_api_bond_create2_reply_t * mp)
1955 vat_main_t *vam = &vat_main;
1956 vat_json_node_t node;
1958 vat_json_init_object (&node);
1959 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1960 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1962 vat_json_print (vam->ofp, &node);
1963 vat_json_free (&node);
1965 vam->retval = ntohl (mp->retval);
1966 vam->result_ready = 1;
1970 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1972 vat_main_t *vam = &vat_main;
1973 i32 retval = ntohl (mp->retval);
1975 if (vam->async_mode)
1977 vam->async_errors += (retval < 0);
1981 vam->retval = retval;
1982 vam->result_ready = 1;
1986 static void vl_api_bond_delete_reply_t_handler_json
1987 (vl_api_bond_delete_reply_t * mp)
1989 vat_main_t *vam = &vat_main;
1990 vat_json_node_t node;
1992 vat_json_init_object (&node);
1993 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1995 vat_json_print (vam->ofp, &node);
1996 vat_json_free (&node);
1998 vam->retval = ntohl (mp->retval);
1999 vam->result_ready = 1;
2003 vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp)
2005 vat_main_t *vam = &vat_main;
2006 i32 retval = ntohl (mp->retval);
2008 if (vam->async_mode)
2010 vam->async_errors += (retval < 0);
2014 vam->retval = retval;
2015 vam->result_ready = 1;
2019 static void vl_api_bond_add_member_reply_t_handler_json
2020 (vl_api_bond_add_member_reply_t * mp)
2022 vat_main_t *vam = &vat_main;
2023 vat_json_node_t node;
2025 vat_json_init_object (&node);
2026 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2028 vat_json_print (vam->ofp, &node);
2029 vat_json_free (&node);
2031 vam->retval = ntohl (mp->retval);
2032 vam->result_ready = 1;
2036 vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t *
2039 vat_main_t *vam = &vat_main;
2040 i32 retval = ntohl (mp->retval);
2042 if (vam->async_mode)
2044 vam->async_errors += (retval < 0);
2048 vam->retval = retval;
2049 vam->result_ready = 1;
2053 static void vl_api_bond_detach_member_reply_t_handler_json
2054 (vl_api_bond_detach_member_reply_t * mp)
2056 vat_main_t *vam = &vat_main;
2057 vat_json_node_t node;
2059 vat_json_init_object (&node);
2060 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2062 vat_json_print (vam->ofp, &node);
2063 vat_json_free (&node);
2065 vam->retval = ntohl (mp->retval);
2066 vam->result_ready = 1;
2070 api_sw_interface_set_bond_weight (vat_main_t * vam)
2072 unformat_input_t *i = vam->input;
2073 vl_api_sw_interface_set_bond_weight_t *mp;
2074 u32 sw_if_index = ~0;
2076 u8 weight_enter = 0;
2079 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2081 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2083 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2085 else if (unformat (i, "weight %u", &weight))
2091 if (sw_if_index == ~0)
2093 errmsg ("missing interface name or sw_if_index");
2096 if (weight_enter == 0)
2098 errmsg ("missing valid weight");
2102 /* Construct the API message */
2103 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2104 mp->sw_if_index = ntohl (sw_if_index);
2105 mp->weight = ntohl (weight);
2112 static void vl_api_sw_bond_interface_details_t_handler
2113 (vl_api_sw_bond_interface_details_t * mp)
2115 vat_main_t *vam = &vat_main;
2118 "%-16s %-12d %-12U %-13U %-14u %-14u",
2119 mp->interface_name, ntohl (mp->sw_if_index),
2120 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2121 ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members));
2124 static void vl_api_sw_bond_interface_details_t_handler_json
2125 (vl_api_sw_bond_interface_details_t * mp)
2127 vat_main_t *vam = &vat_main;
2128 vat_json_node_t *node = NULL;
2130 if (VAT_JSON_ARRAY != vam->json_tree.type)
2132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2133 vat_json_init_array (&vam->json_tree);
2135 node = vat_json_array_add (&vam->json_tree);
2137 vat_json_init_object (node);
2138 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2139 vat_json_object_add_string_copy (node, "interface_name",
2140 mp->interface_name);
2141 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2142 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2143 vat_json_object_add_uint (node, "active_members",
2144 ntohl (mp->active_members));
2145 vat_json_object_add_uint (node, "members", ntohl (mp->members));
2149 api_sw_bond_interface_dump (vat_main_t * vam)
2151 unformat_input_t *i = vam->input;
2152 vl_api_sw_bond_interface_dump_t *mp;
2153 vl_api_control_ping_t *mp_ping;
2155 u32 sw_if_index = ~0;
2157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2159 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2161 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2168 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2169 "interface name", "sw_if_index", "mode", "load balance",
2170 "active members", "members");
2172 /* Get list of bond interfaces */
2173 M (SW_BOND_INTERFACE_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_sw_member_interface_details_t_handler
2186 (vl_api_sw_member_interface_details_t * mp)
2188 vat_main_t *vam = &vat_main;
2191 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2192 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2193 ntohl (mp->weight), mp->is_local_numa);
2196 static void vl_api_sw_member_interface_details_t_handler_json
2197 (vl_api_sw_member_interface_details_t * mp)
2199 vat_main_t *vam = &vat_main;
2200 vat_json_node_t *node = NULL;
2202 if (VAT_JSON_ARRAY != vam->json_tree.type)
2204 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2205 vat_json_init_array (&vam->json_tree);
2207 node = vat_json_array_add (&vam->json_tree);
2209 vat_json_init_object (node);
2210 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2211 vat_json_object_add_string_copy (node, "interface_name",
2212 mp->interface_name);
2213 vat_json_object_add_uint (node, "passive", mp->is_passive);
2214 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2215 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2216 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2220 api_sw_member_interface_dump (vat_main_t * vam)
2222 unformat_input_t *i = vam->input;
2223 vl_api_sw_member_interface_dump_t *mp;
2224 vl_api_control_ping_t *mp_ping;
2225 u32 sw_if_index = ~0;
2226 u8 sw_if_index_set = 0;
2229 /* Parse args required to build the message */
2230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2233 sw_if_index_set = 1;
2234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2235 sw_if_index_set = 1;
2240 if (sw_if_index_set == 0)
2242 errmsg ("missing vpp interface name. ");
2247 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2248 "member interface name", "sw_if_index", "passive", "long_timeout",
2249 "weight", "local numa");
2251 /* Get list of bond interfaces */
2252 M (SW_MEMBER_INTERFACE_DUMP, mp);
2253 mp->sw_if_index = ntohl (sw_if_index);
2256 /* Use a control ping for synchronization */
2257 MPING (CONTROL_PING, mp_ping);
2264 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2265 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2267 vat_main_t *vam = &vat_main;
2268 i32 retval = ntohl (mp->retval);
2269 if (vam->async_mode)
2271 vam->async_errors += (retval < 0);
2275 vam->retval = retval;
2276 vam->sw_if_index = ntohl (mp->sw_if_index);
2277 vam->result_ready = 1;
2279 vam->regenerate_interface_table = 1;
2282 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2283 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2285 vat_main_t *vam = &vat_main;
2286 vat_json_node_t node;
2288 vat_json_init_object (&node);
2289 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2290 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2291 ntohl (mp->sw_if_index));
2293 vat_json_print (vam->ofp, &node);
2294 vat_json_free (&node);
2296 vam->retval = ntohl (mp->retval);
2297 vam->result_ready = 1;
2300 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2301 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2303 vat_main_t *vam = &vat_main;
2304 i32 retval = ntohl (mp->retval);
2305 if (vam->async_mode)
2307 vam->async_errors += (retval < 0);
2311 vam->retval = retval;
2312 vam->sw_if_index = ntohl (mp->sw_if_index);
2313 vam->result_ready = 1;
2317 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2318 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2320 vat_main_t *vam = &vat_main;
2321 vat_json_node_t node;
2323 vat_json_init_object (&node);
2324 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2325 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2327 vat_json_print (vam->ofp, &node);
2328 vat_json_free (&node);
2330 vam->retval = ntohl (mp->retval);
2331 vam->result_ready = 1;
2334 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2335 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2337 vat_main_t *vam = &vat_main;
2338 i32 retval = ntohl (mp->retval);
2339 if (vam->async_mode)
2341 vam->async_errors += (retval < 0);
2345 vam->retval = retval;
2346 vam->result_ready = 1;
2350 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2351 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2353 vat_main_t *vam = &vat_main;
2354 vat_json_node_t node;
2356 vat_json_init_object (&node);
2357 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2358 vat_json_object_add_uint (&node, "fwd_entry_index",
2359 clib_net_to_host_u32 (mp->fwd_entry_index));
2361 vat_json_print (vam->ofp, &node);
2362 vat_json_free (&node);
2364 vam->retval = ntohl (mp->retval);
2365 vam->result_ready = 1;
2369 format_lisp_transport_protocol (u8 * s, va_list * args)
2371 u32 proto = va_arg (*args, u32);
2376 return format (s, "udp");
2378 return format (s, "api");
2385 static void vl_api_one_get_transport_protocol_reply_t_handler
2386 (vl_api_one_get_transport_protocol_reply_t * mp)
2388 vat_main_t *vam = &vat_main;
2389 i32 retval = ntohl (mp->retval);
2390 if (vam->async_mode)
2392 vam->async_errors += (retval < 0);
2396 u32 proto = mp->protocol;
2397 print (vam->ofp, "Transport protocol: %U",
2398 format_lisp_transport_protocol, proto);
2399 vam->retval = retval;
2400 vam->result_ready = 1;
2404 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2405 (vl_api_one_get_transport_protocol_reply_t * mp)
2407 vat_main_t *vam = &vat_main;
2408 vat_json_node_t node;
2411 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2414 vat_json_init_object (&node);
2415 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2416 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2419 vat_json_print (vam->ofp, &node);
2420 vat_json_free (&node);
2422 vam->retval = ntohl (mp->retval);
2423 vam->result_ready = 1;
2426 static void vl_api_one_add_del_locator_set_reply_t_handler
2427 (vl_api_one_add_del_locator_set_reply_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 i32 retval = ntohl (mp->retval);
2431 if (vam->async_mode)
2433 vam->async_errors += (retval < 0);
2437 vam->retval = retval;
2438 vam->result_ready = 1;
2442 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2443 (vl_api_one_add_del_locator_set_reply_t * mp)
2445 vat_main_t *vam = &vat_main;
2446 vat_json_node_t node;
2448 vat_json_init_object (&node);
2449 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2450 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2452 vat_json_print (vam->ofp, &node);
2453 vat_json_free (&node);
2455 vam->retval = ntohl (mp->retval);
2456 vam->result_ready = 1;
2459 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2460 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2462 vat_main_t *vam = &vat_main;
2463 i32 retval = ntohl (mp->retval);
2464 if (vam->async_mode)
2466 vam->async_errors += (retval < 0);
2470 vam->retval = retval;
2471 vam->sw_if_index = ntohl (mp->sw_if_index);
2472 vam->result_ready = 1;
2474 vam->regenerate_interface_table = 1;
2477 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2478 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2480 vat_main_t *vam = &vat_main;
2481 vat_json_node_t node;
2483 vat_json_init_object (&node);
2484 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2485 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2487 vat_json_print (vam->ofp, &node);
2488 vat_json_free (&node);
2490 vam->retval = ntohl (mp->retval);
2491 vam->result_ready = 1;
2494 static void vl_api_vxlan_offload_rx_reply_t_handler
2495 (vl_api_vxlan_offload_rx_reply_t * mp)
2497 vat_main_t *vam = &vat_main;
2498 i32 retval = ntohl (mp->retval);
2499 if (vam->async_mode)
2501 vam->async_errors += (retval < 0);
2505 vam->retval = retval;
2506 vam->result_ready = 1;
2510 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2511 (vl_api_vxlan_offload_rx_reply_t * mp)
2513 vat_main_t *vam = &vat_main;
2514 vat_json_node_t node;
2516 vat_json_init_object (&node);
2517 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2519 vat_json_print (vam->ofp, &node);
2520 vat_json_free (&node);
2522 vam->retval = ntohl (mp->retval);
2523 vam->result_ready = 1;
2526 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2527 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2529 vat_main_t *vam = &vat_main;
2530 i32 retval = ntohl (mp->retval);
2531 if (vam->async_mode)
2533 vam->async_errors += (retval < 0);
2537 vam->retval = retval;
2538 vam->sw_if_index = ntohl (mp->sw_if_index);
2539 vam->result_ready = 1;
2543 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2544 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2546 vat_main_t *vam = &vat_main;
2547 vat_json_node_t node;
2549 vat_json_init_object (&node);
2550 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2551 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2553 vat_json_print (vam->ofp, &node);
2554 vat_json_free (&node);
2556 vam->retval = ntohl (mp->retval);
2557 vam->result_ready = 1;
2560 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2561 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2563 vat_main_t *vam = &vat_main;
2564 i32 retval = ntohl (mp->retval);
2565 if (vam->async_mode)
2567 vam->async_errors += (retval < 0);
2571 vam->retval = retval;
2572 vam->sw_if_index = ntohl (mp->sw_if_index);
2573 vam->result_ready = 1;
2575 vam->regenerate_interface_table = 1;
2578 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2579 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2581 vat_main_t *vam = &vat_main;
2582 vat_json_node_t node;
2584 vat_json_init_object (&node);
2585 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2586 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2588 vat_json_print (vam->ofp, &node);
2589 vat_json_free (&node);
2591 vam->retval = ntohl (mp->retval);
2592 vam->result_ready = 1;
2595 static void vl_api_gre_tunnel_add_del_reply_t_handler
2596 (vl_api_gre_tunnel_add_del_reply_t * mp)
2598 vat_main_t *vam = &vat_main;
2599 i32 retval = ntohl (mp->retval);
2600 if (vam->async_mode)
2602 vam->async_errors += (retval < 0);
2606 vam->retval = retval;
2607 vam->sw_if_index = ntohl (mp->sw_if_index);
2608 vam->result_ready = 1;
2612 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2613 (vl_api_gre_tunnel_add_del_reply_t * mp)
2615 vat_main_t *vam = &vat_main;
2616 vat_json_node_t node;
2618 vat_json_init_object (&node);
2619 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2620 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2622 vat_json_print (vam->ofp, &node);
2623 vat_json_free (&node);
2625 vam->retval = ntohl (mp->retval);
2626 vam->result_ready = 1;
2629 static void vl_api_create_vhost_user_if_reply_t_handler
2630 (vl_api_create_vhost_user_if_reply_t * mp)
2632 vat_main_t *vam = &vat_main;
2633 i32 retval = ntohl (mp->retval);
2634 if (vam->async_mode)
2636 vam->async_errors += (retval < 0);
2640 vam->retval = retval;
2641 vam->sw_if_index = ntohl (mp->sw_if_index);
2642 vam->result_ready = 1;
2644 vam->regenerate_interface_table = 1;
2647 static void vl_api_create_vhost_user_if_reply_t_handler_json
2648 (vl_api_create_vhost_user_if_reply_t * mp)
2650 vat_main_t *vam = &vat_main;
2651 vat_json_node_t node;
2653 vat_json_init_object (&node);
2654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2657 vat_json_print (vam->ofp, &node);
2658 vat_json_free (&node);
2660 vam->retval = ntohl (mp->retval);
2661 vam->result_ready = 1;
2664 static void vl_api_ip_address_details_t_handler
2665 (vl_api_ip_address_details_t * mp)
2667 vat_main_t *vam = &vat_main;
2668 static ip_address_details_t empty_ip_address_details = { {0} };
2669 ip_address_details_t *address = NULL;
2670 ip_details_t *current_ip_details = NULL;
2671 ip_details_t *details = NULL;
2673 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2675 if (!details || vam->current_sw_if_index >= vec_len (details)
2676 || !details[vam->current_sw_if_index].present)
2678 errmsg ("ip address details arrived but not stored");
2679 errmsg ("ip_dump should be called first");
2683 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2685 #define addresses (current_ip_details->addr)
2687 vec_validate_init_empty (addresses, vec_len (addresses),
2688 empty_ip_address_details);
2690 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2692 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2693 address->prefix_length = mp->prefix.len;
2697 static void vl_api_ip_address_details_t_handler_json
2698 (vl_api_ip_address_details_t * mp)
2700 vat_main_t *vam = &vat_main;
2701 vat_json_node_t *node = NULL;
2703 if (VAT_JSON_ARRAY != vam->json_tree.type)
2705 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2706 vat_json_init_array (&vam->json_tree);
2708 node = vat_json_array_add (&vam->json_tree);
2710 vat_json_init_object (node);
2711 vat_json_object_add_prefix (node, &mp->prefix);
2715 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2717 vat_main_t *vam = &vat_main;
2718 static ip_details_t empty_ip_details = { 0 };
2719 ip_details_t *ip = NULL;
2720 u32 sw_if_index = ~0;
2722 sw_if_index = ntohl (mp->sw_if_index);
2724 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2725 sw_if_index, empty_ip_details);
2727 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2734 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2736 vat_main_t *vam = &vat_main;
2738 if (VAT_JSON_ARRAY != vam->json_tree.type)
2740 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2741 vat_json_init_array (&vam->json_tree);
2743 vat_json_array_add_uint (&vam->json_tree,
2744 clib_net_to_host_u32 (mp->sw_if_index));
2747 static void vl_api_get_first_msg_id_reply_t_handler
2748 (vl_api_get_first_msg_id_reply_t * mp)
2750 vat_main_t *vam = &vat_main;
2751 i32 retval = ntohl (mp->retval);
2753 if (vam->async_mode)
2755 vam->async_errors += (retval < 0);
2759 vam->retval = retval;
2760 vam->result_ready = 1;
2764 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2768 static void vl_api_get_first_msg_id_reply_t_handler_json
2769 (vl_api_get_first_msg_id_reply_t * mp)
2771 vat_main_t *vam = &vat_main;
2772 vat_json_node_t node;
2774 vat_json_init_object (&node);
2775 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2776 vat_json_object_add_uint (&node, "first_msg_id",
2777 (uint) ntohs (mp->first_msg_id));
2779 vat_json_print (vam->ofp, &node);
2780 vat_json_free (&node);
2782 vam->retval = ntohl (mp->retval);
2783 vam->result_ready = 1;
2786 static void vl_api_get_node_graph_reply_t_handler
2787 (vl_api_get_node_graph_reply_t * mp)
2789 vat_main_t *vam = &vat_main;
2790 i32 retval = ntohl (mp->retval);
2791 u8 *pvt_copy, *reply;
2796 if (vam->async_mode)
2798 vam->async_errors += (retval < 0);
2802 vam->retval = retval;
2803 vam->result_ready = 1;
2806 /* "Should never happen..." */
2810 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2811 pvt_copy = vec_dup (reply);
2813 /* Toss the shared-memory original... */
2814 oldheap = vl_msg_push_heap ();
2818 vl_msg_pop_heap (oldheap);
2820 if (vam->graph_nodes)
2822 hash_free (vam->graph_node_index_by_name);
2824 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2826 node = vam->graph_nodes[0][i];
2827 vec_free (node->name);
2828 vec_free (node->next_nodes);
2831 vec_free (vam->graph_nodes[0]);
2832 vec_free (vam->graph_nodes);
2835 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2836 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2837 vec_free (pvt_copy);
2839 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2841 node = vam->graph_nodes[0][i];
2842 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2846 static void vl_api_get_node_graph_reply_t_handler_json
2847 (vl_api_get_node_graph_reply_t * mp)
2849 vat_main_t *vam = &vat_main;
2851 vat_json_node_t node;
2854 /* $$$$ make this real? */
2855 vat_json_init_object (&node);
2856 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2857 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2859 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2861 /* Toss the shared-memory original... */
2862 oldheap = vl_msg_push_heap ();
2866 vl_msg_pop_heap (oldheap);
2868 vat_json_print (vam->ofp, &node);
2869 vat_json_free (&node);
2871 vam->retval = ntohl (mp->retval);
2872 vam->result_ready = 1;
2876 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2878 vat_main_t *vam = &vat_main;
2883 s = format (s, "%=16d%=16d%=16d",
2884 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2888 s = format (s, "%=16U%=16d%=16d",
2889 format_ip46_address,
2890 mp->ip_address, mp->priority, mp->weight);
2893 print (vam->ofp, "%v", s);
2898 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2900 vat_main_t *vam = &vat_main;
2901 vat_json_node_t *node = NULL;
2902 struct in6_addr ip6;
2905 if (VAT_JSON_ARRAY != vam->json_tree.type)
2907 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2908 vat_json_init_array (&vam->json_tree);
2910 node = vat_json_array_add (&vam->json_tree);
2911 vat_json_init_object (node);
2913 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2914 vat_json_object_add_uint (node, "priority", mp->priority);
2915 vat_json_object_add_uint (node, "weight", mp->weight);
2918 vat_json_object_add_uint (node, "sw_if_index",
2919 clib_net_to_host_u32 (mp->sw_if_index));
2922 if (mp->ip_address.af)
2924 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
2925 vat_json_object_add_ip6 (node, "address", ip6);
2929 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
2930 vat_json_object_add_ip4 (node, "address", ip4);
2936 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2939 vat_main_t *vam = &vat_main;
2942 ls_name = format (0, "%s", mp->ls_name);
2944 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2950 vl_api_one_locator_set_details_t_handler_json
2951 (vl_api_one_locator_set_details_t * mp)
2953 vat_main_t *vam = &vat_main;
2954 vat_json_node_t *node = 0;
2957 ls_name = format (0, "%s", mp->ls_name);
2958 vec_add1 (ls_name, 0);
2960 if (VAT_JSON_ARRAY != vam->json_tree.type)
2962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2963 vat_json_init_array (&vam->json_tree);
2965 node = vat_json_array_add (&vam->json_tree);
2967 vat_json_init_object (node);
2968 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2969 vat_json_object_add_uint (node, "ls_index",
2970 clib_net_to_host_u32 (mp->ls_index));
2978 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2981 unformat_nsh_address (unformat_input_t * input, va_list * args)
2983 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2984 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2988 format_nsh_address_vat (u8 * s, va_list * args)
2990 nsh_t *a = va_arg (*args, nsh_t *);
2991 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2995 format_lisp_flat_eid (u8 * s, va_list * args)
2997 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
3001 case EID_TYPE_API_PREFIX:
3002 if (eid->address.prefix.address.af)
3003 return format (s, "%U/%d", format_ip6_address,
3004 eid->address.prefix.address.un.ip6,
3005 eid->address.prefix.len);
3006 return format (s, "%U/%d", format_ip4_address,
3007 eid->address.prefix.address.un.ip4,
3008 eid->address.prefix.len);
3009 case EID_TYPE_API_MAC:
3010 return format (s, "%U", format_ethernet_address, eid->address.mac);
3011 case EID_TYPE_API_NSH:
3012 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
3018 format_lisp_eid_vat (u8 * s, va_list * args)
3020 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
3021 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
3022 u8 is_src_dst = (u8) va_arg (*args, int);
3025 s = format (s, "%U|", format_lisp_flat_eid, seid);
3027 s = format (s, "%U", format_lisp_flat_eid, deid);
3033 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3035 vat_main_t *vam = &vat_main;
3036 u8 *s = 0, *eid = 0;
3038 if (~0 == mp->locator_set_index)
3039 s = format (0, "action: %d", mp->action);
3041 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3043 eid = format (0, "%U", format_lisp_eid_vat,
3044 &mp->deid, &mp->seid, mp->is_src_dst);
3047 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3048 clib_net_to_host_u32 (mp->vni),
3050 mp->is_local ? "local" : "remote",
3051 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3052 clib_net_to_host_u16 (mp->key.id), mp->key.key);
3059 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3062 vat_main_t *vam = &vat_main;
3063 vat_json_node_t *node = 0;
3066 if (VAT_JSON_ARRAY != vam->json_tree.type)
3068 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3069 vat_json_init_array (&vam->json_tree);
3071 node = vat_json_array_add (&vam->json_tree);
3073 vat_json_init_object (node);
3074 if (~0 == mp->locator_set_index)
3075 vat_json_object_add_uint (node, "action", mp->action);
3077 vat_json_object_add_uint (node, "locator_set_index",
3078 clib_net_to_host_u32 (mp->locator_set_index));
3080 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3081 if (mp->deid.type == 3)
3083 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3084 vat_json_init_object (nsh_json);
3085 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh;
3086 vat_json_object_add_uint (nsh_json, "spi",
3087 clib_net_to_host_u32 (nsh->spi));
3088 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3092 eid = format (0, "%U", format_lisp_eid_vat,
3093 &mp->deid, &mp->seid, mp->is_src_dst);
3095 vat_json_object_add_string_copy (node, "eid", eid);
3098 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3099 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3100 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3104 vat_json_object_add_uint (node, "key_id",
3105 clib_net_to_host_u16 (mp->key.id));
3106 vat_json_object_add_string_copy (node, "key", mp->key.key);
3111 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3113 vat_main_t *vam = &vat_main;
3114 u8 *seid = 0, *deid = 0;
3115 ip46_address_t lloc, rloc;
3117 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3119 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3126 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
3127 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
3131 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
3132 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
3136 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3137 clib_net_to_host_u32 (mp->vni),
3139 format_ip46_address, lloc,
3140 format_ip46_address, rloc,
3141 clib_net_to_host_u32 (mp->pkt_count),
3142 clib_net_to_host_u32 (mp->bytes));
3149 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3151 struct in6_addr ip6;
3153 vat_main_t *vam = &vat_main;
3154 vat_json_node_t *node = 0;
3155 u8 *deid = 0, *seid = 0;
3157 if (VAT_JSON_ARRAY != vam->json_tree.type)
3159 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3160 vat_json_init_array (&vam->json_tree);
3162 node = vat_json_array_add (&vam->json_tree);
3164 vat_json_init_object (node);
3165 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3167 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3172 vat_json_object_add_string_copy (node, "seid", seid);
3173 vat_json_object_add_string_copy (node, "deid", deid);
3174 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3178 clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6));
3179 vat_json_object_add_ip6 (node, "lloc", ip6);
3180 clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6));
3181 vat_json_object_add_ip6 (node, "rloc", ip6);
3186 clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4));
3187 vat_json_object_add_ip4 (node, "lloc", ip4);
3188 clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4));
3189 vat_json_object_add_ip4 (node, "rloc", ip4);
3191 vat_json_object_add_uint (node, "pkt_count",
3192 clib_net_to_host_u32 (mp->pkt_count));
3193 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3200 vl_api_one_eid_table_map_details_t_handler
3201 (vl_api_one_eid_table_map_details_t * mp)
3203 vat_main_t *vam = &vat_main;
3205 u8 *line = format (0, "%=10d%=10d",
3206 clib_net_to_host_u32 (mp->vni),
3207 clib_net_to_host_u32 (mp->dp_table));
3208 print (vam->ofp, "%v", line);
3213 vl_api_one_eid_table_map_details_t_handler_json
3214 (vl_api_one_eid_table_map_details_t * mp)
3216 vat_main_t *vam = &vat_main;
3217 vat_json_node_t *node = NULL;
3219 if (VAT_JSON_ARRAY != vam->json_tree.type)
3221 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3222 vat_json_init_array (&vam->json_tree);
3224 node = vat_json_array_add (&vam->json_tree);
3225 vat_json_init_object (node);
3226 vat_json_object_add_uint (node, "dp_table",
3227 clib_net_to_host_u32 (mp->dp_table));
3228 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3232 vl_api_one_eid_table_vni_details_t_handler
3233 (vl_api_one_eid_table_vni_details_t * mp)
3235 vat_main_t *vam = &vat_main;
3237 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3238 print (vam->ofp, "%v", line);
3243 vl_api_one_eid_table_vni_details_t_handler_json
3244 (vl_api_one_eid_table_vni_details_t * mp)
3246 vat_main_t *vam = &vat_main;
3247 vat_json_node_t *node = NULL;
3249 if (VAT_JSON_ARRAY != vam->json_tree.type)
3251 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3252 vat_json_init_array (&vam->json_tree);
3254 node = vat_json_array_add (&vam->json_tree);
3255 vat_json_init_object (node);
3256 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3260 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3261 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3263 vat_main_t *vam = &vat_main;
3264 int retval = clib_net_to_host_u32 (mp->retval);
3266 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3267 print (vam->ofp, "fallback threshold value: %d", mp->value);
3269 vam->retval = retval;
3270 vam->result_ready = 1;
3274 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3275 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3277 vat_main_t *vam = &vat_main;
3278 vat_json_node_t _node, *node = &_node;
3279 int retval = clib_net_to_host_u32 (mp->retval);
3281 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3282 vat_json_init_object (node);
3283 vat_json_object_add_uint (node, "value", mp->value);
3285 vat_json_print (vam->ofp, node);
3286 vat_json_free (node);
3288 vam->retval = retval;
3289 vam->result_ready = 1;
3293 vl_api_show_one_map_register_state_reply_t_handler
3294 (vl_api_show_one_map_register_state_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3299 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3301 vam->retval = retval;
3302 vam->result_ready = 1;
3306 vl_api_show_one_map_register_state_reply_t_handler_json
3307 (vl_api_show_one_map_register_state_reply_t * mp)
3309 vat_main_t *vam = &vat_main;
3310 vat_json_node_t _node, *node = &_node;
3311 int retval = clib_net_to_host_u32 (mp->retval);
3313 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3315 vat_json_init_object (node);
3316 vat_json_object_add_string_copy (node, "state", s);
3318 vat_json_print (vam->ofp, node);
3319 vat_json_free (node);
3321 vam->retval = retval;
3322 vam->result_ready = 1;
3327 vl_api_show_one_rloc_probe_state_reply_t_handler
3328 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3330 vat_main_t *vam = &vat_main;
3331 int retval = clib_net_to_host_u32 (mp->retval);
3336 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3338 vam->retval = retval;
3339 vam->result_ready = 1;
3343 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3344 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3346 vat_main_t *vam = &vat_main;
3347 vat_json_node_t _node, *node = &_node;
3348 int retval = clib_net_to_host_u32 (mp->retval);
3350 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3351 vat_json_init_object (node);
3352 vat_json_object_add_string_copy (node, "state", s);
3354 vat_json_print (vam->ofp, node);
3355 vat_json_free (node);
3357 vam->retval = retval;
3358 vam->result_ready = 1;
3363 vl_api_show_one_stats_enable_disable_reply_t_handler
3364 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3366 vat_main_t *vam = &vat_main;
3367 int retval = clib_net_to_host_u32 (mp->retval);
3372 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3374 vam->retval = retval;
3375 vam->result_ready = 1;
3379 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3380 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3382 vat_main_t *vam = &vat_main;
3383 vat_json_node_t _node, *node = &_node;
3384 int retval = clib_net_to_host_u32 (mp->retval);
3386 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3387 vat_json_init_object (node);
3388 vat_json_object_add_string_copy (node, "state", s);
3390 vat_json_print (vam->ofp, node);
3391 vat_json_free (node);
3393 vam->retval = retval;
3394 vam->result_ready = 1;
3399 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3401 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3402 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3403 e->vni = clib_net_to_host_u32 (e->vni);
3407 gpe_fwd_entries_get_reply_t_net_to_host
3408 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3412 mp->count = clib_net_to_host_u32 (mp->count);
3413 for (i = 0; i < mp->count; i++)
3415 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3420 format_gpe_encap_mode (u8 * s, va_list * args)
3422 u32 mode = va_arg (*args, u32);
3427 return format (s, "lisp");
3429 return format (s, "vxlan");
3435 vl_api_gpe_get_encap_mode_reply_t_handler
3436 (vl_api_gpe_get_encap_mode_reply_t * mp)
3438 vat_main_t *vam = &vat_main;
3440 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3441 vam->retval = ntohl (mp->retval);
3442 vam->result_ready = 1;
3446 vl_api_gpe_get_encap_mode_reply_t_handler_json
3447 (vl_api_gpe_get_encap_mode_reply_t * mp)
3449 vat_main_t *vam = &vat_main;
3450 vat_json_node_t node;
3452 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3453 vec_add1 (encap_mode, 0);
3455 vat_json_init_object (&node);
3456 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3458 vec_free (encap_mode);
3459 vat_json_print (vam->ofp, &node);
3460 vat_json_free (&node);
3462 vam->retval = ntohl (mp->retval);
3463 vam->result_ready = 1;
3467 vl_api_gpe_fwd_entry_path_details_t_handler
3468 (vl_api_gpe_fwd_entry_path_details_t * mp)
3470 vat_main_t *vam = &vat_main;
3471 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3473 if (mp->lcl_loc.addr.af)
3474 format_ip_address_fcn = format_ip6_address;
3476 format_ip_address_fcn = format_ip4_address;
3478 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3479 format_ip_address_fcn, &mp->lcl_loc.addr.un,
3480 format_ip_address_fcn, &mp->rmt_loc.addr.un);
3484 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3486 struct in6_addr ip6;
3491 clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6));
3492 vat_json_object_add_ip6 (n, "address", ip6);
3496 clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4));
3497 vat_json_object_add_ip4 (n, "address", ip4);
3499 vat_json_object_add_uint (n, "weight", loc->weight);
3503 vl_api_gpe_fwd_entry_path_details_t_handler_json
3504 (vl_api_gpe_fwd_entry_path_details_t * mp)
3506 vat_main_t *vam = &vat_main;
3507 vat_json_node_t *node = NULL;
3508 vat_json_node_t *loc_node;
3510 if (VAT_JSON_ARRAY != vam->json_tree.type)
3512 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3513 vat_json_init_array (&vam->json_tree);
3515 node = vat_json_array_add (&vam->json_tree);
3516 vat_json_init_object (node);
3518 loc_node = vat_json_object_add (node, "local_locator");
3519 vat_json_init_object (loc_node);
3520 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3522 loc_node = vat_json_object_add (node, "remote_locator");
3523 vat_json_init_object (loc_node);
3524 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3528 vl_api_gpe_fwd_entries_get_reply_t_handler
3529 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3531 vat_main_t *vam = &vat_main;
3533 int retval = clib_net_to_host_u32 (mp->retval);
3534 vl_api_gpe_fwd_entry_t *e;
3539 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3541 for (i = 0; i < mp->count; i++)
3543 e = &mp->entries[i];
3544 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3545 format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid);
3549 vam->retval = retval;
3550 vam->result_ready = 1;
3554 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3555 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3558 vat_main_t *vam = &vat_main;
3559 vat_json_node_t *e = 0, root;
3561 int retval = clib_net_to_host_u32 (mp->retval);
3562 vl_api_gpe_fwd_entry_t *fwd;
3567 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3568 vat_json_init_array (&root);
3570 for (i = 0; i < mp->count; i++)
3572 e = vat_json_array_add (&root);
3573 fwd = &mp->entries[i];
3575 vat_json_init_object (e);
3576 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3577 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3578 vat_json_object_add_int (e, "vni", fwd->vni);
3579 vat_json_object_add_int (e, "action", fwd->action);
3581 s = format (0, "%U", format_lisp_flat_eid, fwd->leid);
3583 vat_json_object_add_string_copy (e, "leid", s);
3586 s = format (0, "%U", format_lisp_flat_eid, fwd->reid);
3588 vat_json_object_add_string_copy (e, "reid", s);
3592 vat_json_print (vam->ofp, &root);
3593 vat_json_free (&root);
3596 vam->retval = retval;
3597 vam->result_ready = 1;
3601 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3602 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3604 vat_main_t *vam = &vat_main;
3606 int retval = clib_net_to_host_u32 (mp->retval);
3607 vl_api_gpe_native_fwd_rpath_t *r;
3612 n = clib_net_to_host_u32 (mp->count);
3614 for (i = 0; i < n; i++)
3616 r = &mp->entries[i];
3617 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3618 clib_net_to_host_u32 (r->fib_index),
3619 clib_net_to_host_u32 (r->nh_sw_if_index),
3620 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3625 vam->retval = retval;
3626 vam->result_ready = 1;
3630 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3631 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3633 vat_main_t *vam = &vat_main;
3634 vat_json_node_t root, *e;
3636 int retval = clib_net_to_host_u32 (mp->retval);
3637 vl_api_gpe_native_fwd_rpath_t *r;
3643 n = clib_net_to_host_u32 (mp->count);
3644 vat_json_init_array (&root);
3646 for (i = 0; i < n; i++)
3648 e = vat_json_array_add (&root);
3649 vat_json_init_object (e);
3650 r = &mp->entries[i];
3653 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3656 vat_json_object_add_string_copy (e, "ip4", s);
3659 vat_json_object_add_uint (e, "fib_index",
3660 clib_net_to_host_u32 (r->fib_index));
3661 vat_json_object_add_uint (e, "nh_sw_if_index",
3662 clib_net_to_host_u32 (r->nh_sw_if_index));
3665 vat_json_print (vam->ofp, &root);
3666 vat_json_free (&root);
3669 vam->retval = retval;
3670 vam->result_ready = 1;
3674 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3675 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3677 vat_main_t *vam = &vat_main;
3679 int retval = clib_net_to_host_u32 (mp->retval);
3684 n = clib_net_to_host_u32 (mp->count);
3686 for (i = 0; i < n; i++)
3687 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3690 vam->retval = retval;
3691 vam->result_ready = 1;
3695 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3696 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3698 vat_main_t *vam = &vat_main;
3699 vat_json_node_t root;
3701 int retval = clib_net_to_host_u32 (mp->retval);
3706 n = clib_net_to_host_u32 (mp->count);
3707 vat_json_init_array (&root);
3709 for (i = 0; i < n; i++)
3710 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3712 vat_json_print (vam->ofp, &root);
3713 vat_json_free (&root);
3716 vam->retval = retval;
3717 vam->result_ready = 1;
3721 vl_api_one_ndp_entries_get_reply_t_handler
3722 (vl_api_one_ndp_entries_get_reply_t * mp)
3724 vat_main_t *vam = &vat_main;
3726 int retval = clib_net_to_host_u32 (mp->retval);
3731 n = clib_net_to_host_u32 (mp->count);
3733 for (i = 0; i < n; i++)
3734 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3735 format_ethernet_address, mp->entries[i].mac);
3738 vam->retval = retval;
3739 vam->result_ready = 1;
3743 vl_api_one_ndp_entries_get_reply_t_handler_json
3744 (vl_api_one_ndp_entries_get_reply_t * mp)
3747 vat_main_t *vam = &vat_main;
3748 vat_json_node_t *e = 0, root;
3750 int retval = clib_net_to_host_u32 (mp->retval);
3751 vl_api_one_ndp_entry_t *arp_entry;
3756 n = clib_net_to_host_u32 (mp->count);
3757 vat_json_init_array (&root);
3759 for (i = 0; i < n; i++)
3761 e = vat_json_array_add (&root);
3762 arp_entry = &mp->entries[i];
3764 vat_json_init_object (e);
3765 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3768 vat_json_object_add_string_copy (e, "mac", s);
3771 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3773 vat_json_object_add_string_copy (e, "ip6", s);
3777 vat_json_print (vam->ofp, &root);
3778 vat_json_free (&root);
3781 vam->retval = retval;
3782 vam->result_ready = 1;
3786 vl_api_one_l2_arp_entries_get_reply_t_handler
3787 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3789 vat_main_t *vam = &vat_main;
3791 int retval = clib_net_to_host_u32 (mp->retval);
3796 n = clib_net_to_host_u32 (mp->count);
3798 for (i = 0; i < n; i++)
3799 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3800 format_ethernet_address, mp->entries[i].mac);
3803 vam->retval = retval;
3804 vam->result_ready = 1;
3808 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3809 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3812 vat_main_t *vam = &vat_main;
3813 vat_json_node_t *e = 0, root;
3815 int retval = clib_net_to_host_u32 (mp->retval);
3816 vl_api_one_l2_arp_entry_t *arp_entry;
3821 n = clib_net_to_host_u32 (mp->count);
3822 vat_json_init_array (&root);
3824 for (i = 0; i < n; i++)
3826 e = vat_json_array_add (&root);
3827 arp_entry = &mp->entries[i];
3829 vat_json_init_object (e);
3830 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3833 vat_json_object_add_string_copy (e, "mac", s);
3836 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3838 vat_json_object_add_string_copy (e, "ip4", s);
3842 vat_json_print (vam->ofp, &root);
3843 vat_json_free (&root);
3846 vam->retval = retval;
3847 vam->result_ready = 1;
3851 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3853 vat_main_t *vam = &vat_main;
3855 int retval = clib_net_to_host_u32 (mp->retval);
3860 n = clib_net_to_host_u32 (mp->count);
3862 for (i = 0; i < n; i++)
3864 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3868 vam->retval = retval;
3869 vam->result_ready = 1;
3873 vl_api_one_ndp_bd_get_reply_t_handler_json
3874 (vl_api_one_ndp_bd_get_reply_t * mp)
3876 vat_main_t *vam = &vat_main;
3877 vat_json_node_t root;
3879 int retval = clib_net_to_host_u32 (mp->retval);
3884 n = clib_net_to_host_u32 (mp->count);
3885 vat_json_init_array (&root);
3887 for (i = 0; i < n; i++)
3889 vat_json_array_add_uint (&root,
3890 clib_net_to_host_u32 (mp->bridge_domains[i]));
3893 vat_json_print (vam->ofp, &root);
3894 vat_json_free (&root);
3897 vam->retval = retval;
3898 vam->result_ready = 1;
3902 vl_api_one_l2_arp_bd_get_reply_t_handler
3903 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3905 vat_main_t *vam = &vat_main;
3907 int retval = clib_net_to_host_u32 (mp->retval);
3912 n = clib_net_to_host_u32 (mp->count);
3914 for (i = 0; i < n; i++)
3916 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3920 vam->retval = retval;
3921 vam->result_ready = 1;
3925 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3926 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3928 vat_main_t *vam = &vat_main;
3929 vat_json_node_t root;
3931 int retval = clib_net_to_host_u32 (mp->retval);
3936 n = clib_net_to_host_u32 (mp->count);
3937 vat_json_init_array (&root);
3939 for (i = 0; i < n; i++)
3941 vat_json_array_add_uint (&root,
3942 clib_net_to_host_u32 (mp->bridge_domains[i]));
3945 vat_json_print (vam->ofp, &root);
3946 vat_json_free (&root);
3949 vam->retval = retval;
3950 vam->result_ready = 1;
3954 vl_api_one_adjacencies_get_reply_t_handler
3955 (vl_api_one_adjacencies_get_reply_t * mp)
3957 vat_main_t *vam = &vat_main;
3959 int retval = clib_net_to_host_u32 (mp->retval);
3960 vl_api_one_adjacency_t *a;
3965 n = clib_net_to_host_u32 (mp->count);
3967 for (i = 0; i < n; i++)
3969 a = &mp->adjacencies[i];
3970 print (vam->ofp, "%U %40U",
3971 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
3975 vam->retval = retval;
3976 vam->result_ready = 1;
3980 vl_api_one_adjacencies_get_reply_t_handler_json
3981 (vl_api_one_adjacencies_get_reply_t * mp)
3984 vat_main_t *vam = &vat_main;
3985 vat_json_node_t *e = 0, root;
3987 int retval = clib_net_to_host_u32 (mp->retval);
3988 vl_api_one_adjacency_t *a;
3993 n = clib_net_to_host_u32 (mp->count);
3994 vat_json_init_array (&root);
3996 for (i = 0; i < n; i++)
3998 e = vat_json_array_add (&root);
3999 a = &mp->adjacencies[i];
4001 vat_json_init_object (e);
4002 s = format (0, "%U", format_lisp_flat_eid, a->leid);
4004 vat_json_object_add_string_copy (e, "leid", s);
4007 s = format (0, "%U", format_lisp_flat_eid, a->reid);
4009 vat_json_object_add_string_copy (e, "reid", s);
4013 vat_json_print (vam->ofp, &root);
4014 vat_json_free (&root);
4017 vam->retval = retval;
4018 vam->result_ready = 1;
4022 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4024 vat_main_t *vam = &vat_main;
4026 print (vam->ofp, "%=20U",
4027 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4032 vl_api_one_map_server_details_t_handler_json
4033 (vl_api_one_map_server_details_t * mp)
4035 vat_main_t *vam = &vat_main;
4036 vat_json_node_t *node = NULL;
4037 struct in6_addr ip6;
4040 if (VAT_JSON_ARRAY != vam->json_tree.type)
4042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4043 vat_json_init_array (&vam->json_tree);
4045 node = vat_json_array_add (&vam->json_tree);
4047 vat_json_init_object (node);
4048 if (mp->ip_address.af)
4050 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4051 vat_json_object_add_ip6 (node, "map-server", ip6);
4055 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4056 vat_json_object_add_ip4 (node, "map-server", ip4);
4061 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4064 vat_main_t *vam = &vat_main;
4066 print (vam->ofp, "%=20U",
4067 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4072 vl_api_one_map_resolver_details_t_handler_json
4073 (vl_api_one_map_resolver_details_t * mp)
4075 vat_main_t *vam = &vat_main;
4076 vat_json_node_t *node = NULL;
4077 struct in6_addr ip6;
4080 if (VAT_JSON_ARRAY != vam->json_tree.type)
4082 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4083 vat_json_init_array (&vam->json_tree);
4085 node = vat_json_array_add (&vam->json_tree);
4087 vat_json_init_object (node);
4088 if (mp->ip_address.af)
4090 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4091 vat_json_object_add_ip6 (node, "map resolver", ip6);
4095 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4096 vat_json_object_add_ip4 (node, "map resolver", ip4);
4101 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4103 vat_main_t *vam = &vat_main;
4104 i32 retval = ntohl (mp->retval);
4108 print (vam->ofp, "feature: %s\ngpe: %s",
4109 mp->feature_status ? "enabled" : "disabled",
4110 mp->gpe_status ? "enabled" : "disabled");
4113 vam->retval = retval;
4114 vam->result_ready = 1;
4118 vl_api_show_one_status_reply_t_handler_json
4119 (vl_api_show_one_status_reply_t * mp)
4121 vat_main_t *vam = &vat_main;
4122 vat_json_node_t node;
4123 u8 *gpe_status = NULL;
4124 u8 *feature_status = NULL;
4126 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4127 feature_status = format (0, "%s",
4128 mp->feature_status ? "enabled" : "disabled");
4129 vec_add1 (gpe_status, 0);
4130 vec_add1 (feature_status, 0);
4132 vat_json_init_object (&node);
4133 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4134 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4136 vec_free (gpe_status);
4137 vec_free (feature_status);
4139 vat_json_print (vam->ofp, &node);
4140 vat_json_free (&node);
4142 vam->retval = ntohl (mp->retval);
4143 vam->result_ready = 1;
4147 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4148 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4150 vat_main_t *vam = &vat_main;
4151 i32 retval = ntohl (mp->retval);
4155 print (vam->ofp, "%=20s", mp->locator_set_name);
4158 vam->retval = retval;
4159 vam->result_ready = 1;
4163 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4164 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4166 vat_main_t *vam = &vat_main;
4167 vat_json_node_t *node = NULL;
4169 if (VAT_JSON_ARRAY != vam->json_tree.type)
4171 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4172 vat_json_init_array (&vam->json_tree);
4174 node = vat_json_array_add (&vam->json_tree);
4176 vat_json_init_object (node);
4177 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4179 vat_json_print (vam->ofp, node);
4180 vat_json_free (node);
4182 vam->retval = ntohl (mp->retval);
4183 vam->result_ready = 1;
4187 format_lisp_map_request_mode (u8 * s, va_list * args)
4189 u32 mode = va_arg (*args, u32);
4194 return format (0, "dst-only");
4196 return format (0, "src-dst");
4202 vl_api_show_one_map_request_mode_reply_t_handler
4203 (vl_api_show_one_map_request_mode_reply_t * mp)
4205 vat_main_t *vam = &vat_main;
4206 i32 retval = ntohl (mp->retval);
4210 u32 mode = mp->mode;
4211 print (vam->ofp, "map_request_mode: %U",
4212 format_lisp_map_request_mode, mode);
4215 vam->retval = retval;
4216 vam->result_ready = 1;
4220 vl_api_show_one_map_request_mode_reply_t_handler_json
4221 (vl_api_show_one_map_request_mode_reply_t * mp)
4223 vat_main_t *vam = &vat_main;
4224 vat_json_node_t node;
4229 s = format (0, "%U", format_lisp_map_request_mode, mode);
4232 vat_json_init_object (&node);
4233 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4234 vat_json_print (vam->ofp, &node);
4235 vat_json_free (&node);
4238 vam->retval = ntohl (mp->retval);
4239 vam->result_ready = 1;
4243 vl_api_one_show_xtr_mode_reply_t_handler
4244 (vl_api_one_show_xtr_mode_reply_t * mp)
4246 vat_main_t *vam = &vat_main;
4247 i32 retval = ntohl (mp->retval);
4251 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4254 vam->retval = retval;
4255 vam->result_ready = 1;
4259 vl_api_one_show_xtr_mode_reply_t_handler_json
4260 (vl_api_one_show_xtr_mode_reply_t * mp)
4262 vat_main_t *vam = &vat_main;
4263 vat_json_node_t node;
4266 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4267 vec_add1 (status, 0);
4269 vat_json_init_object (&node);
4270 vat_json_object_add_string_copy (&node, "status", status);
4274 vat_json_print (vam->ofp, &node);
4275 vat_json_free (&node);
4277 vam->retval = ntohl (mp->retval);
4278 vam->result_ready = 1;
4282 vl_api_one_show_pitr_mode_reply_t_handler
4283 (vl_api_one_show_pitr_mode_reply_t * mp)
4285 vat_main_t *vam = &vat_main;
4286 i32 retval = ntohl (mp->retval);
4290 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4293 vam->retval = retval;
4294 vam->result_ready = 1;
4298 vl_api_one_show_pitr_mode_reply_t_handler_json
4299 (vl_api_one_show_pitr_mode_reply_t * mp)
4301 vat_main_t *vam = &vat_main;
4302 vat_json_node_t node;
4305 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4306 vec_add1 (status, 0);
4308 vat_json_init_object (&node);
4309 vat_json_object_add_string_copy (&node, "status", status);
4313 vat_json_print (vam->ofp, &node);
4314 vat_json_free (&node);
4316 vam->retval = ntohl (mp->retval);
4317 vam->result_ready = 1;
4321 vl_api_one_show_petr_mode_reply_t_handler
4322 (vl_api_one_show_petr_mode_reply_t * mp)
4324 vat_main_t *vam = &vat_main;
4325 i32 retval = ntohl (mp->retval);
4329 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4332 vam->retval = retval;
4333 vam->result_ready = 1;
4337 vl_api_one_show_petr_mode_reply_t_handler_json
4338 (vl_api_one_show_petr_mode_reply_t * mp)
4340 vat_main_t *vam = &vat_main;
4341 vat_json_node_t node;
4344 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4345 vec_add1 (status, 0);
4347 vat_json_init_object (&node);
4348 vat_json_object_add_string_copy (&node, "status", status);
4352 vat_json_print (vam->ofp, &node);
4353 vat_json_free (&node);
4355 vam->retval = ntohl (mp->retval);
4356 vam->result_ready = 1;
4360 vl_api_show_one_use_petr_reply_t_handler
4361 (vl_api_show_one_use_petr_reply_t * mp)
4363 vat_main_t *vam = &vat_main;
4364 i32 retval = ntohl (mp->retval);
4368 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4371 print (vam->ofp, "Proxy-ETR address; %U",
4372 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4377 vam->retval = retval;
4378 vam->result_ready = 1;
4382 vl_api_show_one_use_petr_reply_t_handler_json
4383 (vl_api_show_one_use_petr_reply_t * mp)
4385 vat_main_t *vam = &vat_main;
4386 vat_json_node_t node;
4389 struct in6_addr ip6;
4391 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4392 vec_add1 (status, 0);
4394 vat_json_init_object (&node);
4395 vat_json_object_add_string_copy (&node, "status", status);
4398 if (mp->ip_address.af)
4400 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4401 vat_json_object_add_ip6 (&node, "address", ip6);
4405 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4406 vat_json_object_add_ip4 (&node, "address", ip4);
4412 vat_json_print (vam->ofp, &node);
4413 vat_json_free (&node);
4415 vam->retval = ntohl (mp->retval);
4416 vam->result_ready = 1;
4420 vl_api_show_one_nsh_mapping_reply_t_handler
4421 (vl_api_show_one_nsh_mapping_reply_t * mp)
4423 vat_main_t *vam = &vat_main;
4424 i32 retval = ntohl (mp->retval);
4428 print (vam->ofp, "%-20s%-16s",
4429 mp->is_set ? "set" : "not-set",
4430 mp->is_set ? (char *) mp->locator_set_name : "");
4433 vam->retval = retval;
4434 vam->result_ready = 1;
4438 vl_api_show_one_nsh_mapping_reply_t_handler_json
4439 (vl_api_show_one_nsh_mapping_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 vat_json_node_t node;
4445 status = format (0, "%s", mp->is_set ? "yes" : "no");
4446 vec_add1 (status, 0);
4448 vat_json_init_object (&node);
4449 vat_json_object_add_string_copy (&node, "is_set", status);
4452 vat_json_object_add_string_copy (&node, "locator_set",
4453 mp->locator_set_name);
4458 vat_json_print (vam->ofp, &node);
4459 vat_json_free (&node);
4461 vam->retval = ntohl (mp->retval);
4462 vam->result_ready = 1;
4466 vl_api_show_one_map_register_ttl_reply_t_handler
4467 (vl_api_show_one_map_register_ttl_reply_t * mp)
4469 vat_main_t *vam = &vat_main;
4470 i32 retval = ntohl (mp->retval);
4472 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4476 print (vam->ofp, "ttl: %u", mp->ttl);
4479 vam->retval = retval;
4480 vam->result_ready = 1;
4484 vl_api_show_one_map_register_ttl_reply_t_handler_json
4485 (vl_api_show_one_map_register_ttl_reply_t * mp)
4487 vat_main_t *vam = &vat_main;
4488 vat_json_node_t node;
4490 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4491 vat_json_init_object (&node);
4492 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4494 vat_json_print (vam->ofp, &node);
4495 vat_json_free (&node);
4497 vam->retval = ntohl (mp->retval);
4498 vam->result_ready = 1;
4502 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4504 vat_main_t *vam = &vat_main;
4505 i32 retval = ntohl (mp->retval);
4509 print (vam->ofp, "%-20s%-16s",
4510 mp->status ? "enabled" : "disabled",
4511 mp->status ? (char *) mp->locator_set_name : "");
4514 vam->retval = retval;
4515 vam->result_ready = 1;
4519 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4521 vat_main_t *vam = &vat_main;
4522 vat_json_node_t node;
4525 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4526 vec_add1 (status, 0);
4528 vat_json_init_object (&node);
4529 vat_json_object_add_string_copy (&node, "status", status);
4532 vat_json_object_add_string_copy (&node, "locator_set",
4533 mp->locator_set_name);
4538 vat_json_print (vam->ofp, &node);
4539 vat_json_free (&node);
4541 vam->retval = ntohl (mp->retval);
4542 vam->result_ready = 1;
4546 format_policer_type (u8 * s, va_list * va)
4548 u32 i = va_arg (*va, u32);
4550 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4551 s = format (s, "1r2c");
4552 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4553 s = format (s, "1r3c");
4554 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4555 s = format (s, "2r3c-2698");
4556 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4557 s = format (s, "2r3c-4115");
4558 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4559 s = format (s, "2r3c-mef5cf1");
4561 s = format (s, "ILLEGAL");
4566 format_policer_rate_type (u8 * s, va_list * va)
4568 u32 i = va_arg (*va, u32);
4570 if (i == SSE2_QOS_RATE_KBPS)
4571 s = format (s, "kbps");
4572 else if (i == SSE2_QOS_RATE_PPS)
4573 s = format (s, "pps");
4575 s = format (s, "ILLEGAL");
4580 format_policer_round_type (u8 * s, va_list * va)
4582 u32 i = va_arg (*va, u32);
4584 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4585 s = format (s, "closest");
4586 else if (i == SSE2_QOS_ROUND_TO_UP)
4587 s = format (s, "up");
4588 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4589 s = format (s, "down");
4591 s = format (s, "ILLEGAL");
4596 format_policer_action_type (u8 * s, va_list * va)
4598 u32 i = va_arg (*va, u32);
4600 if (i == SSE2_QOS_ACTION_DROP)
4601 s = format (s, "drop");
4602 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4603 s = format (s, "transmit");
4604 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4605 s = format (s, "mark-and-transmit");
4607 s = format (s, "ILLEGAL");
4612 format_dscp (u8 * s, va_list * va)
4614 u32 i = va_arg (*va, u32);
4619 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4623 return format (s, "ILLEGAL");
4625 s = format (s, "%s", t);
4630 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4632 vat_main_t *vam = &vat_main;
4633 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4635 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4636 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4638 conform_dscp_str = format (0, "");
4640 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4641 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4643 exceed_dscp_str = format (0, "");
4645 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4646 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4648 violate_dscp_str = format (0, "");
4650 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4651 "rate type %U, round type %U, %s rate, %s color-aware, "
4652 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4653 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4654 "conform action %U%s, exceed action %U%s, violate action %U%s",
4656 format_policer_type, mp->type,
4659 clib_net_to_host_u64 (mp->cb),
4660 clib_net_to_host_u64 (mp->eb),
4661 format_policer_rate_type, mp->rate_type,
4662 format_policer_round_type, mp->round_type,
4663 mp->single_rate ? "single" : "dual",
4664 mp->color_aware ? "is" : "not",
4665 ntohl (mp->cir_tokens_per_period),
4666 ntohl (mp->pir_tokens_per_period),
4668 ntohl (mp->current_limit),
4669 ntohl (mp->current_bucket),
4670 ntohl (mp->extended_limit),
4671 ntohl (mp->extended_bucket),
4672 clib_net_to_host_u64 (mp->last_update_time),
4673 format_policer_action_type, mp->conform_action.type,
4675 format_policer_action_type, mp->exceed_action.type,
4677 format_policer_action_type, mp->violate_action.type,
4680 vec_free (conform_dscp_str);
4681 vec_free (exceed_dscp_str);
4682 vec_free (violate_dscp_str);
4685 static void vl_api_policer_details_t_handler_json
4686 (vl_api_policer_details_t * mp)
4688 vat_main_t *vam = &vat_main;
4689 vat_json_node_t *node;
4690 u8 *rate_type_str, *round_type_str, *type_str;
4691 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4693 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4695 format (0, "%U", format_policer_round_type, mp->round_type);
4696 type_str = format (0, "%U", format_policer_type, mp->type);
4697 conform_action_str = format (0, "%U", format_policer_action_type,
4698 mp->conform_action.type);
4699 exceed_action_str = format (0, "%U", format_policer_action_type,
4700 mp->exceed_action.type);
4701 violate_action_str = format (0, "%U", format_policer_action_type,
4702 mp->violate_action.type);
4704 if (VAT_JSON_ARRAY != vam->json_tree.type)
4706 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4707 vat_json_init_array (&vam->json_tree);
4709 node = vat_json_array_add (&vam->json_tree);
4711 vat_json_init_object (node);
4712 vat_json_object_add_string_copy (node, "name", mp->name);
4713 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4714 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4715 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4716 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4717 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4718 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4719 vat_json_object_add_string_copy (node, "type", type_str);
4720 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4721 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4722 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4723 vat_json_object_add_uint (node, "cir_tokens_per_period",
4724 ntohl (mp->cir_tokens_per_period));
4725 vat_json_object_add_uint (node, "eir_tokens_per_period",
4726 ntohl (mp->pir_tokens_per_period));
4727 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4728 vat_json_object_add_uint (node, "current_bucket",
4729 ntohl (mp->current_bucket));
4730 vat_json_object_add_uint (node, "extended_limit",
4731 ntohl (mp->extended_limit));
4732 vat_json_object_add_uint (node, "extended_bucket",
4733 ntohl (mp->extended_bucket));
4734 vat_json_object_add_uint (node, "last_update_time",
4735 ntohl (mp->last_update_time));
4736 vat_json_object_add_string_copy (node, "conform_action",
4737 conform_action_str);
4738 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4740 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4741 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4742 vec_free (dscp_str);
4744 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4745 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4747 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4748 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4749 vec_free (dscp_str);
4751 vat_json_object_add_string_copy (node, "violate_action",
4752 violate_action_str);
4753 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4755 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4756 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4757 vec_free (dscp_str);
4760 vec_free (rate_type_str);
4761 vec_free (round_type_str);
4762 vec_free (type_str);
4763 vec_free (conform_action_str);
4764 vec_free (exceed_action_str);
4765 vec_free (violate_action_str);
4769 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4772 vat_main_t *vam = &vat_main;
4773 int i, count = ntohl (mp->count);
4776 print (vam->ofp, "classify table ids (%d) : ", count);
4777 for (i = 0; i < count; i++)
4779 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4780 print (vam->ofp, (i < count - 1) ? "," : "");
4782 vam->retval = ntohl (mp->retval);
4783 vam->result_ready = 1;
4787 vl_api_classify_table_ids_reply_t_handler_json
4788 (vl_api_classify_table_ids_reply_t * mp)
4790 vat_main_t *vam = &vat_main;
4791 int i, count = ntohl (mp->count);
4795 vat_json_node_t node;
4797 vat_json_init_object (&node);
4798 for (i = 0; i < count; i++)
4800 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4802 vat_json_print (vam->ofp, &node);
4803 vat_json_free (&node);
4805 vam->retval = ntohl (mp->retval);
4806 vam->result_ready = 1;
4810 vl_api_classify_table_by_interface_reply_t_handler
4811 (vl_api_classify_table_by_interface_reply_t * mp)
4813 vat_main_t *vam = &vat_main;
4816 table_id = ntohl (mp->l2_table_id);
4818 print (vam->ofp, "l2 table id : %d", table_id);
4820 print (vam->ofp, "l2 table id : No input ACL tables configured");
4821 table_id = ntohl (mp->ip4_table_id);
4823 print (vam->ofp, "ip4 table id : %d", table_id);
4825 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4826 table_id = ntohl (mp->ip6_table_id);
4828 print (vam->ofp, "ip6 table id : %d", table_id);
4830 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4831 vam->retval = ntohl (mp->retval);
4832 vam->result_ready = 1;
4836 vl_api_classify_table_by_interface_reply_t_handler_json
4837 (vl_api_classify_table_by_interface_reply_t * mp)
4839 vat_main_t *vam = &vat_main;
4840 vat_json_node_t node;
4842 vat_json_init_object (&node);
4844 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4845 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4846 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4848 vat_json_print (vam->ofp, &node);
4849 vat_json_free (&node);
4851 vam->retval = ntohl (mp->retval);
4852 vam->result_ready = 1;
4855 static void vl_api_policer_add_del_reply_t_handler
4856 (vl_api_policer_add_del_reply_t * mp)
4858 vat_main_t *vam = &vat_main;
4859 i32 retval = ntohl (mp->retval);
4860 if (vam->async_mode)
4862 vam->async_errors += (retval < 0);
4866 vam->retval = retval;
4867 vam->result_ready = 1;
4868 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4870 * Note: this is just barely thread-safe, depends on
4871 * the main thread spinning waiting for an answer...
4873 errmsg ("policer index %d", ntohl (mp->policer_index));
4877 static void vl_api_policer_add_del_reply_t_handler_json
4878 (vl_api_policer_add_del_reply_t * mp)
4880 vat_main_t *vam = &vat_main;
4881 vat_json_node_t node;
4883 vat_json_init_object (&node);
4884 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4885 vat_json_object_add_uint (&node, "policer_index",
4886 ntohl (mp->policer_index));
4888 vat_json_print (vam->ofp, &node);
4889 vat_json_free (&node);
4891 vam->retval = ntohl (mp->retval);
4892 vam->result_ready = 1;
4895 /* Format hex dump. */
4897 format_hex_bytes (u8 * s, va_list * va)
4899 u8 *bytes = va_arg (*va, u8 *);
4900 int n_bytes = va_arg (*va, int);
4903 /* Print short or long form depending on byte count. */
4904 uword short_form = n_bytes <= 32;
4905 u32 indent = format_get_indent (s);
4910 for (i = 0; i < n_bytes; i++)
4912 if (!short_form && (i % 32) == 0)
4913 s = format (s, "%08x: ", i);
4914 s = format (s, "%02x", bytes[i]);
4915 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4916 s = format (s, "\n%U", format_white_space, indent);
4923 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4926 vat_main_t *vam = &vat_main;
4927 i32 retval = ntohl (mp->retval);
4930 print (vam->ofp, "classify table info :");
4931 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4932 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4933 ntohl (mp->miss_next_index));
4934 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4935 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4936 ntohl (mp->match_n_vectors));
4937 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4938 ntohl (mp->mask_length));
4940 vam->retval = retval;
4941 vam->result_ready = 1;
4945 vl_api_classify_table_info_reply_t_handler_json
4946 (vl_api_classify_table_info_reply_t * mp)
4948 vat_main_t *vam = &vat_main;
4949 vat_json_node_t node;
4951 i32 retval = ntohl (mp->retval);
4954 vat_json_init_object (&node);
4956 vat_json_object_add_int (&node, "sessions",
4957 ntohl (mp->active_sessions));
4958 vat_json_object_add_int (&node, "nexttbl",
4959 ntohl (mp->next_table_index));
4960 vat_json_object_add_int (&node, "nextnode",
4961 ntohl (mp->miss_next_index));
4962 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4963 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4964 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4965 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4966 ntohl (mp->mask_length), 0);
4967 vat_json_object_add_string_copy (&node, "mask", s);
4969 vat_json_print (vam->ofp, &node);
4970 vat_json_free (&node);
4972 vam->retval = ntohl (mp->retval);
4973 vam->result_ready = 1;
4977 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4980 vat_main_t *vam = &vat_main;
4982 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4983 ntohl (mp->hit_next_index), ntohl (mp->advance),
4984 ntohl (mp->opaque_index));
4985 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4986 ntohl (mp->match_length));
4990 vl_api_classify_session_details_t_handler_json
4991 (vl_api_classify_session_details_t * mp)
4993 vat_main_t *vam = &vat_main;
4994 vat_json_node_t *node = NULL;
4996 if (VAT_JSON_ARRAY != vam->json_tree.type)
4998 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4999 vat_json_init_array (&vam->json_tree);
5001 node = vat_json_array_add (&vam->json_tree);
5003 vat_json_init_object (node);
5004 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
5005 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
5006 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5008 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5010 vat_json_object_add_string_copy (node, "match", s);
5013 static void vl_api_pg_create_interface_reply_t_handler
5014 (vl_api_pg_create_interface_reply_t * mp)
5016 vat_main_t *vam = &vat_main;
5018 vam->retval = ntohl (mp->retval);
5019 vam->result_ready = 1;
5022 static void vl_api_pg_create_interface_reply_t_handler_json
5023 (vl_api_pg_create_interface_reply_t * mp)
5025 vat_main_t *vam = &vat_main;
5026 vat_json_node_t node;
5028 i32 retval = ntohl (mp->retval);
5031 vat_json_init_object (&node);
5033 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5035 vat_json_print (vam->ofp, &node);
5036 vat_json_free (&node);
5038 vam->retval = ntohl (mp->retval);
5039 vam->result_ready = 1;
5042 static void vl_api_policer_classify_details_t_handler
5043 (vl_api_policer_classify_details_t * mp)
5045 vat_main_t *vam = &vat_main;
5047 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5048 ntohl (mp->table_index));
5051 static void vl_api_policer_classify_details_t_handler_json
5052 (vl_api_policer_classify_details_t * mp)
5054 vat_main_t *vam = &vat_main;
5055 vat_json_node_t *node;
5057 if (VAT_JSON_ARRAY != vam->json_tree.type)
5059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5060 vat_json_init_array (&vam->json_tree);
5062 node = vat_json_array_add (&vam->json_tree);
5064 vat_json_init_object (node);
5065 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5066 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5069 static void vl_api_flow_classify_details_t_handler
5070 (vl_api_flow_classify_details_t * mp)
5072 vat_main_t *vam = &vat_main;
5074 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5075 ntohl (mp->table_index));
5078 static void vl_api_flow_classify_details_t_handler_json
5079 (vl_api_flow_classify_details_t * mp)
5081 vat_main_t *vam = &vat_main;
5082 vat_json_node_t *node;
5084 if (VAT_JSON_ARRAY != vam->json_tree.type)
5086 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5087 vat_json_init_array (&vam->json_tree);
5089 node = vat_json_array_add (&vam->json_tree);
5091 vat_json_init_object (node);
5092 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5093 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5096 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5097 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5098 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5099 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5100 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5101 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5102 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5103 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5104 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5105 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5108 * Generate boilerplate reply handlers, which
5109 * dig the return value out of the xxx_reply_t API message,
5110 * stick it into vam->retval, and set vam->result_ready
5112 * Could also do this by pointing N message decode slots at
5113 * a single function, but that could break in subtle ways.
5116 #define foreach_standard_reply_retval_handler \
5117 _(sw_interface_set_flags_reply) \
5118 _(sw_interface_add_del_address_reply) \
5119 _(sw_interface_set_rx_mode_reply) \
5120 _(sw_interface_set_rx_placement_reply) \
5121 _(sw_interface_set_table_reply) \
5122 _(sw_interface_set_mpls_enable_reply) \
5123 _(sw_interface_set_vpath_reply) \
5124 _(sw_interface_set_vxlan_bypass_reply) \
5125 _(sw_interface_set_geneve_bypass_reply) \
5126 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5127 _(sw_interface_set_l2_bridge_reply) \
5128 _(sw_interface_set_bond_weight_reply) \
5129 _(bridge_domain_add_del_reply) \
5130 _(sw_interface_set_l2_xconnect_reply) \
5131 _(l2fib_add_del_reply) \
5132 _(l2fib_flush_int_reply) \
5133 _(l2fib_flush_bd_reply) \
5134 _(ip_route_add_del_reply) \
5135 _(ip_table_add_del_reply) \
5136 _(ip_table_replace_begin_reply) \
5137 _(ip_table_flush_reply) \
5138 _(ip_table_replace_end_reply) \
5139 _(ip_mroute_add_del_reply) \
5140 _(mpls_route_add_del_reply) \
5141 _(mpls_table_add_del_reply) \
5142 _(mpls_ip_bind_unbind_reply) \
5143 _(bier_route_add_del_reply) \
5144 _(bier_table_add_del_reply) \
5145 _(sw_interface_set_unnumbered_reply) \
5146 _(set_ip_flow_hash_reply) \
5147 _(sw_interface_ip6_enable_disable_reply) \
5148 _(l2_patch_add_del_reply) \
5149 _(sr_mpls_policy_add_reply) \
5150 _(sr_mpls_policy_mod_reply) \
5151 _(sr_mpls_policy_del_reply) \
5152 _(sr_policy_add_reply) \
5153 _(sr_policy_mod_reply) \
5154 _(sr_policy_del_reply) \
5155 _(sr_localsid_add_del_reply) \
5156 _(sr_steering_add_del_reply) \
5157 _(classify_add_del_session_reply) \
5158 _(classify_set_interface_ip_table_reply) \
5159 _(classify_set_interface_l2_tables_reply) \
5160 _(l2tpv3_set_tunnel_cookies_reply) \
5161 _(l2tpv3_interface_enable_disable_reply) \
5162 _(l2tpv3_set_lookup_key_reply) \
5163 _(l2_fib_clear_table_reply) \
5164 _(l2_interface_efp_filter_reply) \
5165 _(l2_interface_vlan_tag_rewrite_reply) \
5166 _(modify_vhost_user_if_reply) \
5167 _(delete_vhost_user_if_reply) \
5168 _(want_l2_macs_events_reply) \
5169 _(input_acl_set_interface_reply) \
5170 _(ipsec_spd_add_del_reply) \
5171 _(ipsec_interface_add_del_spd_reply) \
5172 _(ipsec_spd_entry_add_del_reply) \
5173 _(ipsec_sad_entry_add_del_reply) \
5174 _(ipsec_tunnel_if_add_del_reply) \
5175 _(ipsec_tunnel_if_set_sa_reply) \
5176 _(delete_loopback_reply) \
5177 _(bd_ip_mac_add_del_reply) \
5178 _(bd_ip_mac_flush_reply) \
5179 _(want_interface_events_reply) \
5180 _(cop_interface_enable_disable_reply) \
5181 _(cop_whitelist_enable_disable_reply) \
5182 _(sw_interface_clear_stats_reply) \
5183 _(ioam_enable_reply) \
5184 _(ioam_disable_reply) \
5185 _(one_add_del_locator_reply) \
5186 _(one_add_del_local_eid_reply) \
5187 _(one_add_del_remote_mapping_reply) \
5188 _(one_add_del_adjacency_reply) \
5189 _(one_add_del_map_resolver_reply) \
5190 _(one_add_del_map_server_reply) \
5191 _(one_enable_disable_reply) \
5192 _(one_rloc_probe_enable_disable_reply) \
5193 _(one_map_register_enable_disable_reply) \
5194 _(one_map_register_set_ttl_reply) \
5195 _(one_set_transport_protocol_reply) \
5196 _(one_map_register_fallback_threshold_reply) \
5197 _(one_pitr_set_locator_set_reply) \
5198 _(one_map_request_mode_reply) \
5199 _(one_add_del_map_request_itr_rlocs_reply) \
5200 _(one_eid_table_add_del_map_reply) \
5201 _(one_use_petr_reply) \
5202 _(one_stats_enable_disable_reply) \
5203 _(one_add_del_l2_arp_entry_reply) \
5204 _(one_add_del_ndp_entry_reply) \
5205 _(one_stats_flush_reply) \
5206 _(one_enable_disable_xtr_mode_reply) \
5207 _(one_enable_disable_pitr_mode_reply) \
5208 _(one_enable_disable_petr_mode_reply) \
5209 _(gpe_enable_disable_reply) \
5210 _(gpe_set_encap_mode_reply) \
5211 _(gpe_add_del_iface_reply) \
5212 _(gpe_add_del_native_fwd_rpath_reply) \
5213 _(af_packet_delete_reply) \
5214 _(policer_classify_set_interface_reply) \
5215 _(set_ipfix_exporter_reply) \
5216 _(set_ipfix_classify_stream_reply) \
5217 _(ipfix_classify_table_add_del_reply) \
5218 _(flow_classify_set_interface_reply) \
5219 _(sw_interface_span_enable_disable_reply) \
5220 _(pg_capture_reply) \
5221 _(pg_enable_disable_reply) \
5222 _(pg_interface_enable_disable_coalesce_reply) \
5223 _(ip_source_and_port_range_check_add_del_reply) \
5224 _(ip_source_and_port_range_check_interface_add_del_reply)\
5225 _(delete_subif_reply) \
5226 _(l2_interface_pbb_tag_rewrite_reply) \
5228 _(feature_enable_disable_reply) \
5229 _(feature_gso_enable_disable_reply) \
5230 _(sw_interface_tag_add_del_reply) \
5231 _(sw_interface_add_del_mac_address_reply) \
5232 _(hw_interface_set_mtu_reply) \
5233 _(p2p_ethernet_add_reply) \
5234 _(p2p_ethernet_del_reply) \
5235 _(lldp_config_reply) \
5236 _(sw_interface_set_lldp_reply) \
5237 _(tcp_configure_src_addresses_reply) \
5238 _(session_rule_add_del_reply) \
5239 _(ip_container_proxy_add_del_reply) \
5240 _(output_acl_set_interface_reply) \
5241 _(qos_record_enable_disable_reply) \
5245 static void vl_api_##n##_t_handler \
5246 (vl_api_##n##_t * mp) \
5248 vat_main_t * vam = &vat_main; \
5249 i32 retval = ntohl(mp->retval); \
5250 if (vam->async_mode) { \
5251 vam->async_errors += (retval < 0); \
5253 vam->retval = retval; \
5254 vam->result_ready = 1; \
5257 foreach_standard_reply_retval_handler;
5261 static void vl_api_##n##_t_handler_json \
5262 (vl_api_##n##_t * mp) \
5264 vat_main_t * vam = &vat_main; \
5265 vat_json_node_t node; \
5266 vat_json_init_object(&node); \
5267 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5268 vat_json_print(vam->ofp, &node); \
5269 vam->retval = ntohl(mp->retval); \
5270 vam->result_ready = 1; \
5272 foreach_standard_reply_retval_handler;
5276 * Table of message reply handlers, must include boilerplate handlers
5280 #define foreach_vpe_api_reply_msg \
5281 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5282 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5283 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5284 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5285 _(CONTROL_PING_REPLY, control_ping_reply) \
5286 _(CLI_REPLY, cli_reply) \
5287 _(CLI_INBAND_REPLY, cli_inband_reply) \
5288 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5289 sw_interface_add_del_address_reply) \
5290 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5291 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5292 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5293 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5294 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5295 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5296 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5297 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5298 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5299 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5300 sw_interface_set_l2_xconnect_reply) \
5301 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5302 sw_interface_set_l2_bridge_reply) \
5303 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5304 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5305 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5306 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5307 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5308 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5309 _(L2_FLAGS_REPLY, l2_flags_reply) \
5310 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5311 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5312 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5313 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5314 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5315 _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
5316 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5317 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5318 _(BOND_CREATE_REPLY, bond_create_reply) \
5319 _(BOND_CREATE2_REPLY, bond_create2_reply) \
5320 _(BOND_DELETE_REPLY, bond_delete_reply) \
5321 _(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
5322 _(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
5323 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5324 _(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
5325 _(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
5326 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5327 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5328 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5329 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5330 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5331 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5332 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5333 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5334 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5335 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5336 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5337 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5338 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5339 sw_interface_set_unnumbered_reply) \
5340 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5341 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5342 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5343 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5344 sw_interface_ip6_enable_disable_reply) \
5345 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5346 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5347 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5348 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5349 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5350 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5351 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5352 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5353 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5354 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5355 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5356 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5357 classify_set_interface_ip_table_reply) \
5358 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5359 classify_set_interface_l2_tables_reply) \
5360 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5361 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5362 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5363 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5364 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5365 l2tpv3_interface_enable_disable_reply) \
5366 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5367 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5368 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5369 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5370 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5371 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5372 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5373 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5374 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5375 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5376 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5377 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5378 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5379 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5380 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5381 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5382 _(SHOW_VERSION_REPLY, show_version_reply) \
5383 _(SHOW_THREADS_REPLY, show_threads_reply) \
5384 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5385 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5386 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5387 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5388 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5389 _(L2_MACS_EVENT, l2_macs_event) \
5390 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5391 _(IP_ADDRESS_DETAILS, ip_address_details) \
5392 _(IP_DETAILS, ip_details) \
5393 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5394 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5395 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5396 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5397 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5398 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5399 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5400 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5401 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5402 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5403 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5404 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5405 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5406 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5407 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5408 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5409 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5410 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5411 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5412 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5413 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5414 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5415 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5416 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5417 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5418 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5419 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5420 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5421 one_map_register_enable_disable_reply) \
5422 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5423 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5424 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5425 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5426 one_map_register_fallback_threshold_reply) \
5427 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5428 one_rloc_probe_enable_disable_reply) \
5429 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5430 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5431 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5432 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5433 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5434 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5435 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5436 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5437 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5438 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5439 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5440 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5441 _(ONE_STATS_DETAILS, one_stats_details) \
5442 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5443 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5444 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5445 show_one_stats_enable_disable_reply) \
5446 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5447 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5448 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5449 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5450 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5451 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5452 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5453 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5454 one_enable_disable_pitr_mode_reply) \
5455 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5456 one_enable_disable_petr_mode_reply) \
5457 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5458 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5459 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5460 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5461 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5462 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5463 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5464 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5465 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5466 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5467 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5468 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5469 gpe_add_del_native_fwd_rpath_reply) \
5470 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5471 gpe_fwd_entry_path_details) \
5472 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5473 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5474 one_add_del_map_request_itr_rlocs_reply) \
5475 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5476 one_get_map_request_itr_rlocs_reply) \
5477 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5478 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5479 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5480 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5481 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5482 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5483 show_one_map_register_state_reply) \
5484 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5485 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5486 show_one_map_register_fallback_threshold_reply) \
5487 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5488 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5489 _(AF_PACKET_DETAILS, af_packet_details) \
5490 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5491 _(POLICER_DETAILS, policer_details) \
5492 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5493 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5494 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5495 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5496 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5497 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5498 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5499 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5500 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5501 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5502 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5503 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5504 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5505 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5506 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5507 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5508 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5509 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5510 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5511 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5512 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5513 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5514 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5515 _(PG_INTERFACE_ENABLE_DISABLE_COALESCE_REPLY, pg_interface_enable_disable_coalesce_reply) \
5516 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5517 ip_source_and_port_range_check_add_del_reply) \
5518 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5519 ip_source_and_port_range_check_interface_add_del_reply) \
5520 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5521 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5522 _(SET_PUNT_REPLY, set_punt_reply) \
5523 _(IP_TABLE_DETAILS, ip_table_details) \
5524 _(IP_ROUTE_DETAILS, ip_route_details) \
5525 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5526 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5527 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5528 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5529 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5530 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5531 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5532 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5533 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5534 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5535 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5536 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5537 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5538 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5539 _(SESSION_RULES_DETAILS, session_rules_details) \
5540 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5541 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5542 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
5543 _(FLOW_ADD_REPLY, flow_add_reply) \
5545 #define foreach_standalone_reply_msg \
5546 _(SW_INTERFACE_EVENT, sw_interface_event)
5554 #define STR_VTR_OP_CASE(op) \
5555 case L2_VTR_ ## op: \
5559 str_vtr_op (u32 vtr_op)
5563 STR_VTR_OP_CASE (DISABLED);
5564 STR_VTR_OP_CASE (PUSH_1);
5565 STR_VTR_OP_CASE (PUSH_2);
5566 STR_VTR_OP_CASE (POP_1);
5567 STR_VTR_OP_CASE (POP_2);
5568 STR_VTR_OP_CASE (TRANSLATE_1_1);
5569 STR_VTR_OP_CASE (TRANSLATE_1_2);
5570 STR_VTR_OP_CASE (TRANSLATE_2_1);
5571 STR_VTR_OP_CASE (TRANSLATE_2_2);
5578 dump_sub_interface_table (vat_main_t * vam)
5580 const sw_interface_subif_t *sub = NULL;
5582 if (vam->json_output)
5585 ("JSON output supported only for VPE API calls and dump_stats_table");
5590 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5591 "Interface", "sw_if_index",
5592 "sub id", "dot1ad", "tags", "outer id",
5593 "inner id", "exact", "default", "outer any", "inner any");
5595 vec_foreach (sub, vam->sw_if_subif_table)
5598 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5599 sub->interface_name,
5601 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5602 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5603 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5604 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5605 if (sub->vtr_op != L2_VTR_DISABLED)
5608 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5609 "tag1: %d tag2: %d ]",
5610 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5611 sub->vtr_tag1, sub->vtr_tag2);
5619 name_sort_cmp (void *a1, void *a2)
5621 name_sort_t *n1 = a1;
5622 name_sort_t *n2 = a2;
5624 return strcmp ((char *) n1->name, (char *) n2->name);
5628 dump_interface_table (vat_main_t * vam)
5631 name_sort_t *nses = 0, *ns;
5633 if (vam->json_output)
5636 ("JSON output supported only for VPE API calls and dump_stats_table");
5641 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5643 vec_add2 (nses, ns, 1);
5644 ns->name = (u8 *)(p->key);
5645 ns->value = (u32) p->value[0];
5649 vec_sort_with_function (nses, name_sort_cmp);
5651 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5652 vec_foreach (ns, nses)
5654 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5661 dump_ip_table (vat_main_t * vam, int is_ipv6)
5663 const ip_details_t *det = NULL;
5664 const ip_address_details_t *address = NULL;
5667 print (vam->ofp, "%-12s", "sw_if_index");
5669 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5676 print (vam->ofp, "%-12d", i);
5677 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5682 vec_foreach (address, det->addr)
5686 is_ipv6 ? format_ip6_address : format_ip4_address,
5687 address->ip, address->prefix_length);
5695 dump_ipv4_table (vat_main_t * vam)
5697 if (vam->json_output)
5700 ("JSON output supported only for VPE API calls and dump_stats_table");
5704 return dump_ip_table (vam, 0);
5708 dump_ipv6_table (vat_main_t * vam)
5710 if (vam->json_output)
5713 ("JSON output supported only for VPE API calls and dump_stats_table");
5717 return dump_ip_table (vam, 1);
5721 * Pass CLI buffers directly in the CLI_INBAND API message,
5722 * instead of an additional shared memory area.
5725 exec_inband (vat_main_t * vam)
5727 vl_api_cli_inband_t *mp;
5728 unformat_input_t *i = vam->input;
5731 if (vec_len (i->buffer) == 0)
5734 if (vam->exec_mode == 0 && unformat (i, "mode"))
5739 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5746 * In order for the CLI command to work, it
5747 * must be a vector ending in \n, not a C-string ending
5750 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5751 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5755 /* json responses may or may not include a useful reply... */
5756 if (vec_len (vam->cmd_reply))
5757 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5762 exec (vat_main_t * vam)
5764 return exec_inband (vam);
5768 api_create_loopback (vat_main_t * vam)
5770 unformat_input_t *i = vam->input;
5771 vl_api_create_loopback_t *mp;
5772 vl_api_create_loopback_instance_t *mp_lbi;
5775 u8 is_specified = 0;
5776 u32 user_instance = 0;
5779 clib_memset (mac_address, 0, sizeof (mac_address));
5781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5783 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5785 if (unformat (i, "instance %d", &user_instance))
5793 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5794 mp_lbi->is_specified = is_specified;
5796 mp_lbi->user_instance = htonl (user_instance);
5798 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5803 /* Construct the API message */
5804 M (CREATE_LOOPBACK, mp);
5806 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5815 api_delete_loopback (vat_main_t * vam)
5817 unformat_input_t *i = vam->input;
5818 vl_api_delete_loopback_t *mp;
5819 u32 sw_if_index = ~0;
5822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5824 if (unformat (i, "sw_if_index %d", &sw_if_index))
5830 if (sw_if_index == ~0)
5832 errmsg ("missing sw_if_index");
5836 /* Construct the API message */
5837 M (DELETE_LOOPBACK, mp);
5838 mp->sw_if_index = ntohl (sw_if_index);
5846 api_want_interface_events (vat_main_t * vam)
5848 unformat_input_t *i = vam->input;
5849 vl_api_want_interface_events_t *mp;
5853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5855 if (unformat (i, "enable"))
5857 else if (unformat (i, "disable"))
5865 errmsg ("missing enable|disable");
5869 M (WANT_INTERFACE_EVENTS, mp);
5870 mp->enable_disable = enable;
5872 vam->interface_event_display = enable;
5880 /* Note: non-static, called once to set up the initial intfc table */
5882 api_sw_interface_dump (vat_main_t * vam)
5884 vl_api_sw_interface_dump_t *mp;
5885 vl_api_control_ping_t *mp_ping;
5887 name_sort_t *nses = 0, *ns;
5888 sw_interface_subif_t *sub = NULL;
5891 /* Toss the old name table */
5893 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5895 vec_add2 (nses, ns, 1);
5896 ns->name = (u8 *)(p->key);
5897 ns->value = (u32) p->value[0];
5901 hash_free (vam->sw_if_index_by_interface_name);
5903 vec_foreach (ns, nses) vec_free (ns->name);
5907 vec_foreach (sub, vam->sw_if_subif_table)
5909 vec_free (sub->interface_name);
5911 vec_free (vam->sw_if_subif_table);
5913 /* recreate the interface name hash table */
5914 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5917 * Ask for all interface names. Otherwise, the epic catalog of
5918 * name filters becomes ridiculously long, and vat ends up needing
5919 * to be taught about new interface types.
5921 M (SW_INTERFACE_DUMP, mp);
5924 /* Use a control ping for synchronization */
5925 MPING (CONTROL_PING, mp_ping);
5933 api_sw_interface_set_flags (vat_main_t * vam)
5935 unformat_input_t *i = vam->input;
5936 vl_api_sw_interface_set_flags_t *mp;
5938 u8 sw_if_index_set = 0;
5942 /* Parse args required to build the message */
5943 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5945 if (unformat (i, "admin-up"))
5947 else if (unformat (i, "admin-down"))
5950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5951 sw_if_index_set = 1;
5952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5953 sw_if_index_set = 1;
5958 if (sw_if_index_set == 0)
5960 errmsg ("missing interface name or sw_if_index");
5964 /* Construct the API message */
5965 M (SW_INTERFACE_SET_FLAGS, mp);
5966 mp->sw_if_index = ntohl (sw_if_index);
5967 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5972 /* Wait for a reply, return the good/bad news... */
5978 api_sw_interface_set_rx_mode (vat_main_t * vam)
5980 unformat_input_t *i = vam->input;
5981 vl_api_sw_interface_set_rx_mode_t *mp;
5983 u8 sw_if_index_set = 0;
5985 u8 queue_id_valid = 0;
5987 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5989 /* Parse args required to build the message */
5990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5992 if (unformat (i, "queue %d", &queue_id))
5994 else if (unformat (i, "polling"))
5995 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5996 else if (unformat (i, "interrupt"))
5997 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5998 else if (unformat (i, "adaptive"))
5999 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6001 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6002 sw_if_index_set = 1;
6003 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6004 sw_if_index_set = 1;
6009 if (sw_if_index_set == 0)
6011 errmsg ("missing interface name or sw_if_index");
6014 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6016 errmsg ("missing rx-mode");
6020 /* Construct the API message */
6021 M (SW_INTERFACE_SET_RX_MODE, mp);
6022 mp->sw_if_index = ntohl (sw_if_index);
6023 mp->mode = (vl_api_rx_mode_t) mode;
6024 mp->queue_id_valid = queue_id_valid;
6025 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6030 /* Wait for a reply, return the good/bad news... */
6036 api_sw_interface_set_rx_placement (vat_main_t * vam)
6038 unformat_input_t *i = vam->input;
6039 vl_api_sw_interface_set_rx_placement_t *mp;
6041 u8 sw_if_index_set = 0;
6044 u32 queue_id, thread_index;
6046 /* Parse args required to build the message */
6047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6049 if (unformat (i, "queue %d", &queue_id))
6051 else if (unformat (i, "main"))
6053 else if (unformat (i, "worker %d", &thread_index))
6056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6057 sw_if_index_set = 1;
6058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6059 sw_if_index_set = 1;
6064 if (sw_if_index_set == 0)
6066 errmsg ("missing interface name or sw_if_index");
6072 /* Construct the API message */
6073 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6074 mp->sw_if_index = ntohl (sw_if_index);
6075 mp->worker_id = ntohl (thread_index);
6076 mp->queue_id = ntohl (queue_id);
6077 mp->is_main = is_main;
6081 /* Wait for a reply, return the good/bad news... */
6086 static void vl_api_sw_interface_rx_placement_details_t_handler
6087 (vl_api_sw_interface_rx_placement_details_t * mp)
6089 vat_main_t *vam = &vat_main;
6090 u32 worker_id = ntohl (mp->worker_id);
6093 "\n%-11d %-11s %-6d %-5d %-9s",
6094 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6095 worker_id, ntohl (mp->queue_id),
6097 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6100 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6101 (vl_api_sw_interface_rx_placement_details_t * mp)
6103 vat_main_t *vam = &vat_main;
6104 vat_json_node_t *node = NULL;
6106 if (VAT_JSON_ARRAY != vam->json_tree.type)
6108 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6109 vat_json_init_array (&vam->json_tree);
6111 node = vat_json_array_add (&vam->json_tree);
6113 vat_json_init_object (node);
6114 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6115 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6116 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6117 vat_json_object_add_uint (node, "mode", mp->mode);
6121 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6123 unformat_input_t *i = vam->input;
6124 vl_api_sw_interface_rx_placement_dump_t *mp;
6125 vl_api_control_ping_t *mp_ping;
6128 u8 sw_if_index_set = 0;
6130 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6132 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6134 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6141 "\n%-11s %-11s %-6s %-5s %-4s",
6142 "sw_if_index", "main/worker", "thread", "queue", "mode");
6144 /* Dump Interface rx placement */
6145 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6147 if (sw_if_index_set)
6148 mp->sw_if_index = htonl (sw_if_index);
6150 mp->sw_if_index = ~0;
6154 /* Use a control ping for synchronization */
6155 MPING (CONTROL_PING, mp_ping);
6163 api_sw_interface_clear_stats (vat_main_t * vam)
6165 unformat_input_t *i = vam->input;
6166 vl_api_sw_interface_clear_stats_t *mp;
6168 u8 sw_if_index_set = 0;
6171 /* Parse args required to build the message */
6172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6174 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6175 sw_if_index_set = 1;
6176 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6177 sw_if_index_set = 1;
6182 /* Construct the API message */
6183 M (SW_INTERFACE_CLEAR_STATS, mp);
6185 if (sw_if_index_set == 1)
6186 mp->sw_if_index = ntohl (sw_if_index);
6188 mp->sw_if_index = ~0;
6193 /* Wait for a reply, return the good/bad news... */
6199 api_sw_interface_add_del_address (vat_main_t * vam)
6201 unformat_input_t *i = vam->input;
6202 vl_api_sw_interface_add_del_address_t *mp;
6204 u8 sw_if_index_set = 0;
6205 u8 is_add = 1, del_all = 0;
6206 u32 address_length = 0;
6207 u8 v4_address_set = 0;
6208 u8 v6_address_set = 0;
6209 ip4_address_t v4address;
6210 ip6_address_t v6address;
6213 /* Parse args required to build the message */
6214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6216 if (unformat (i, "del-all"))
6218 else if (unformat (i, "del"))
6221 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6222 sw_if_index_set = 1;
6223 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6224 sw_if_index_set = 1;
6225 else if (unformat (i, "%U/%d",
6226 unformat_ip4_address, &v4address, &address_length))
6228 else if (unformat (i, "%U/%d",
6229 unformat_ip6_address, &v6address, &address_length))
6235 if (sw_if_index_set == 0)
6237 errmsg ("missing interface name or sw_if_index");
6240 if (v4_address_set && v6_address_set)
6242 errmsg ("both v4 and v6 addresses set");
6245 if (!v4_address_set && !v6_address_set && !del_all)
6247 errmsg ("no addresses set");
6251 /* Construct the API message */
6252 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6254 mp->sw_if_index = ntohl (sw_if_index);
6255 mp->is_add = is_add;
6256 mp->del_all = del_all;
6259 mp->prefix.address.af = ADDRESS_IP6;
6260 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6264 mp->prefix.address.af = ADDRESS_IP4;
6265 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6267 mp->prefix.len = address_length;
6272 /* Wait for a reply, return good/bad news */
6278 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6280 unformat_input_t *i = vam->input;
6281 vl_api_sw_interface_set_mpls_enable_t *mp;
6283 u8 sw_if_index_set = 0;
6287 /* Parse args required to build the message */
6288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6290 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6291 sw_if_index_set = 1;
6292 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6293 sw_if_index_set = 1;
6294 else if (unformat (i, "disable"))
6296 else if (unformat (i, "dis"))
6302 if (sw_if_index_set == 0)
6304 errmsg ("missing interface name or sw_if_index");
6308 /* Construct the API message */
6309 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6311 mp->sw_if_index = ntohl (sw_if_index);
6312 mp->enable = enable;
6317 /* Wait for a reply... */
6323 api_sw_interface_set_table (vat_main_t * vam)
6325 unformat_input_t *i = vam->input;
6326 vl_api_sw_interface_set_table_t *mp;
6327 u32 sw_if_index, vrf_id = 0;
6328 u8 sw_if_index_set = 0;
6332 /* Parse args required to build the message */
6333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6335 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6336 sw_if_index_set = 1;
6337 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6338 sw_if_index_set = 1;
6339 else if (unformat (i, "vrf %d", &vrf_id))
6341 else if (unformat (i, "ipv6"))
6347 if (sw_if_index_set == 0)
6349 errmsg ("missing interface name or sw_if_index");
6353 /* Construct the API message */
6354 M (SW_INTERFACE_SET_TABLE, mp);
6356 mp->sw_if_index = ntohl (sw_if_index);
6357 mp->is_ipv6 = is_ipv6;
6358 mp->vrf_id = ntohl (vrf_id);
6363 /* Wait for a reply... */
6368 static void vl_api_sw_interface_get_table_reply_t_handler
6369 (vl_api_sw_interface_get_table_reply_t * mp)
6371 vat_main_t *vam = &vat_main;
6373 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6375 vam->retval = ntohl (mp->retval);
6376 vam->result_ready = 1;
6380 static void vl_api_sw_interface_get_table_reply_t_handler_json
6381 (vl_api_sw_interface_get_table_reply_t * mp)
6383 vat_main_t *vam = &vat_main;
6384 vat_json_node_t node;
6386 vat_json_init_object (&node);
6387 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6388 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6390 vat_json_print (vam->ofp, &node);
6391 vat_json_free (&node);
6393 vam->retval = ntohl (mp->retval);
6394 vam->result_ready = 1;
6398 api_sw_interface_get_table (vat_main_t * vam)
6400 unformat_input_t *i = vam->input;
6401 vl_api_sw_interface_get_table_t *mp;
6403 u8 sw_if_index_set = 0;
6407 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6409 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6410 sw_if_index_set = 1;
6411 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6412 sw_if_index_set = 1;
6413 else if (unformat (i, "ipv6"))
6419 if (sw_if_index_set == 0)
6421 errmsg ("missing interface name or sw_if_index");
6425 M (SW_INTERFACE_GET_TABLE, mp);
6426 mp->sw_if_index = htonl (sw_if_index);
6427 mp->is_ipv6 = is_ipv6;
6435 api_sw_interface_set_vpath (vat_main_t * vam)
6437 unformat_input_t *i = vam->input;
6438 vl_api_sw_interface_set_vpath_t *mp;
6439 u32 sw_if_index = 0;
6440 u8 sw_if_index_set = 0;
6444 /* Parse args required to build the message */
6445 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6447 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6448 sw_if_index_set = 1;
6449 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6450 sw_if_index_set = 1;
6451 else if (unformat (i, "enable"))
6453 else if (unformat (i, "disable"))
6459 if (sw_if_index_set == 0)
6461 errmsg ("missing interface name or sw_if_index");
6465 /* Construct the API message */
6466 M (SW_INTERFACE_SET_VPATH, mp);
6468 mp->sw_if_index = ntohl (sw_if_index);
6469 mp->enable = is_enable;
6474 /* Wait for a reply... */
6480 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6482 unformat_input_t *i = vam->input;
6483 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6484 u32 sw_if_index = 0;
6485 u8 sw_if_index_set = 0;
6490 /* Parse args required to build the message */
6491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6493 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6494 sw_if_index_set = 1;
6495 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6496 sw_if_index_set = 1;
6497 else if (unformat (i, "enable"))
6499 else if (unformat (i, "disable"))
6501 else if (unformat (i, "ip4"))
6503 else if (unformat (i, "ip6"))
6509 if (sw_if_index_set == 0)
6511 errmsg ("missing interface name or sw_if_index");
6515 /* Construct the API message */
6516 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6518 mp->sw_if_index = ntohl (sw_if_index);
6519 mp->enable = is_enable;
6520 mp->is_ipv6 = is_ipv6;
6525 /* Wait for a reply... */
6531 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6533 unformat_input_t *i = vam->input;
6534 vl_api_sw_interface_set_geneve_bypass_t *mp;
6535 u32 sw_if_index = 0;
6536 u8 sw_if_index_set = 0;
6541 /* Parse args required to build the message */
6542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6544 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6545 sw_if_index_set = 1;
6546 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6547 sw_if_index_set = 1;
6548 else if (unformat (i, "enable"))
6550 else if (unformat (i, "disable"))
6552 else if (unformat (i, "ip4"))
6554 else if (unformat (i, "ip6"))
6560 if (sw_if_index_set == 0)
6562 errmsg ("missing interface name or sw_if_index");
6566 /* Construct the API message */
6567 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6569 mp->sw_if_index = ntohl (sw_if_index);
6570 mp->enable = is_enable;
6571 mp->is_ipv6 = is_ipv6;
6576 /* Wait for a reply... */
6582 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6584 unformat_input_t *i = vam->input;
6585 vl_api_sw_interface_set_l2_xconnect_t *mp;
6587 u8 rx_sw_if_index_set = 0;
6589 u8 tx_sw_if_index_set = 0;
6593 /* Parse args required to build the message */
6594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6596 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6597 rx_sw_if_index_set = 1;
6598 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6599 tx_sw_if_index_set = 1;
6600 else if (unformat (i, "rx"))
6602 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6604 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6606 rx_sw_if_index_set = 1;
6611 else if (unformat (i, "tx"))
6613 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6615 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6617 tx_sw_if_index_set = 1;
6622 else if (unformat (i, "enable"))
6624 else if (unformat (i, "disable"))
6630 if (rx_sw_if_index_set == 0)
6632 errmsg ("missing rx interface name or rx_sw_if_index");
6636 if (enable && (tx_sw_if_index_set == 0))
6638 errmsg ("missing tx interface name or tx_sw_if_index");
6642 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6644 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6645 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6646 mp->enable = enable;
6654 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6656 unformat_input_t *i = vam->input;
6657 vl_api_sw_interface_set_l2_bridge_t *mp;
6658 vl_api_l2_port_type_t port_type;
6660 u8 rx_sw_if_index_set = 0;
6667 port_type = L2_API_PORT_TYPE_NORMAL;
6669 /* Parse args required to build the message */
6670 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6672 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6673 rx_sw_if_index_set = 1;
6674 else if (unformat (i, "bd_id %d", &bd_id))
6678 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6679 rx_sw_if_index_set = 1;
6680 else if (unformat (i, "shg %d", &shg))
6682 else if (unformat (i, "bvi"))
6683 port_type = L2_API_PORT_TYPE_BVI;
6684 else if (unformat (i, "uu-fwd"))
6685 port_type = L2_API_PORT_TYPE_UU_FWD;
6686 else if (unformat (i, "enable"))
6688 else if (unformat (i, "disable"))
6694 if (rx_sw_if_index_set == 0)
6696 errmsg ("missing rx interface name or sw_if_index");
6700 if (enable && (bd_id_set == 0))
6702 errmsg ("missing bridge domain");
6706 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6708 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6709 mp->bd_id = ntohl (bd_id);
6711 mp->port_type = ntohl (port_type);
6712 mp->enable = enable;
6720 api_bridge_domain_dump (vat_main_t * vam)
6722 unformat_input_t *i = vam->input;
6723 vl_api_bridge_domain_dump_t *mp;
6724 vl_api_control_ping_t *mp_ping;
6728 /* Parse args required to build the message */
6729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6731 if (unformat (i, "bd_id %d", &bd_id))
6737 M (BRIDGE_DOMAIN_DUMP, mp);
6738 mp->bd_id = ntohl (bd_id);
6741 /* Use a control ping for synchronization */
6742 MPING (CONTROL_PING, mp_ping);
6750 api_bridge_domain_add_del (vat_main_t * vam)
6752 unformat_input_t *i = vam->input;
6753 vl_api_bridge_domain_add_del_t *mp;
6756 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6761 /* Parse args required to build the message */
6762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6764 if (unformat (i, "bd_id %d", &bd_id))
6766 else if (unformat (i, "flood %d", &flood))
6768 else if (unformat (i, "uu-flood %d", &uu_flood))
6770 else if (unformat (i, "forward %d", &forward))
6772 else if (unformat (i, "learn %d", &learn))
6774 else if (unformat (i, "arp-term %d", &arp_term))
6776 else if (unformat (i, "mac-age %d", &mac_age))
6778 else if (unformat (i, "bd-tag %s", &bd_tag))
6780 else if (unformat (i, "del"))
6783 flood = uu_flood = forward = learn = 0;
6791 errmsg ("missing bridge domain");
6798 errmsg ("mac age must be less than 256 ");
6803 if ((bd_tag) && (vec_len (bd_tag) > 63))
6805 errmsg ("bd-tag cannot be longer than 63");
6810 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6812 mp->bd_id = ntohl (bd_id);
6814 mp->uu_flood = uu_flood;
6815 mp->forward = forward;
6817 mp->arp_term = arp_term;
6818 mp->is_add = is_add;
6819 mp->mac_age = (u8) mac_age;
6822 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6823 mp->bd_tag[vec_len (bd_tag)] = 0;
6834 api_l2fib_flush_bd (vat_main_t * vam)
6836 unformat_input_t *i = vam->input;
6837 vl_api_l2fib_flush_bd_t *mp;
6841 /* Parse args required to build the message */
6842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6844 if (unformat (i, "bd_id %d", &bd_id));
6851 errmsg ("missing bridge domain");
6855 M (L2FIB_FLUSH_BD, mp);
6857 mp->bd_id = htonl (bd_id);
6865 api_l2fib_flush_int (vat_main_t * vam)
6867 unformat_input_t *i = vam->input;
6868 vl_api_l2fib_flush_int_t *mp;
6869 u32 sw_if_index = ~0;
6872 /* Parse args required to build the message */
6873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6875 if (unformat (i, "sw_if_index %d", &sw_if_index));
6877 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6882 if (sw_if_index == ~0)
6884 errmsg ("missing interface name or sw_if_index");
6888 M (L2FIB_FLUSH_INT, mp);
6890 mp->sw_if_index = ntohl (sw_if_index);
6898 api_l2fib_add_del (vat_main_t * vam)
6900 unformat_input_t *i = vam->input;
6901 vl_api_l2fib_add_del_t *mp;
6907 u32 sw_if_index = 0;
6908 u8 sw_if_index_set = 0;
6917 /* Parse args required to build the message */
6918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6920 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6922 else if (unformat (i, "bd_id %d", &bd_id))
6924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6925 sw_if_index_set = 1;
6926 else if (unformat (i, "sw_if"))
6928 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6931 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6932 sw_if_index_set = 1;
6937 else if (unformat (i, "static"))
6939 else if (unformat (i, "filter"))
6944 else if (unformat (i, "bvi"))
6949 else if (unformat (i, "del"))
6951 else if (unformat (i, "count %d", &count))
6959 errmsg ("missing mac address");
6965 errmsg ("missing bridge domain");
6969 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6971 errmsg ("missing interface name or sw_if_index");
6977 /* Turn on async mode */
6978 vam->async_mode = 1;
6979 vam->async_errors = 0;
6980 before = vat_time_now (vam);
6983 for (j = 0; j < count; j++)
6985 M (L2FIB_ADD_DEL, mp);
6987 clib_memcpy (mp->mac, mac, 6);
6988 mp->bd_id = ntohl (bd_id);
6989 mp->is_add = is_add;
6990 mp->sw_if_index = ntohl (sw_if_index);
6994 mp->static_mac = static_mac;
6995 mp->filter_mac = filter_mac;
6996 mp->bvi_mac = bvi_mac;
6998 increment_mac_address (mac);
7005 vl_api_control_ping_t *mp_ping;
7008 /* Shut off async mode */
7009 vam->async_mode = 0;
7011 MPING (CONTROL_PING, mp_ping);
7014 timeout = vat_time_now (vam) + 1.0;
7015 while (vat_time_now (vam) < timeout)
7016 if (vam->result_ready == 1)
7021 if (vam->retval == -99)
7024 if (vam->async_errors > 0)
7026 errmsg ("%d asynchronous errors", vam->async_errors);
7029 vam->async_errors = 0;
7030 after = vat_time_now (vam);
7032 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7033 count, after - before, count / (after - before));
7039 /* Wait for a reply... */
7043 /* Return the good/bad news */
7044 return (vam->retval);
7048 api_bridge_domain_set_mac_age (vat_main_t * vam)
7050 unformat_input_t *i = vam->input;
7051 vl_api_bridge_domain_set_mac_age_t *mp;
7056 /* Parse args required to build the message */
7057 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7059 if (unformat (i, "bd_id %d", &bd_id));
7060 else if (unformat (i, "mac-age %d", &mac_age));
7067 errmsg ("missing bridge domain");
7073 errmsg ("mac age must be less than 256 ");
7077 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7079 mp->bd_id = htonl (bd_id);
7080 mp->mac_age = (u8) mac_age;
7088 api_l2_flags (vat_main_t * vam)
7090 unformat_input_t *i = vam->input;
7091 vl_api_l2_flags_t *mp;
7094 u8 sw_if_index_set = 0;
7098 /* Parse args required to build the message */
7099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7101 if (unformat (i, "sw_if_index %d", &sw_if_index))
7102 sw_if_index_set = 1;
7103 else if (unformat (i, "sw_if"))
7105 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7108 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7109 sw_if_index_set = 1;
7114 else if (unformat (i, "learn"))
7116 else if (unformat (i, "forward"))
7118 else if (unformat (i, "flood"))
7120 else if (unformat (i, "uu-flood"))
7121 flags |= L2_UU_FLOOD;
7122 else if (unformat (i, "arp-term"))
7123 flags |= L2_ARP_TERM;
7124 else if (unformat (i, "off"))
7126 else if (unformat (i, "disable"))
7132 if (sw_if_index_set == 0)
7134 errmsg ("missing interface name or sw_if_index");
7140 mp->sw_if_index = ntohl (sw_if_index);
7141 mp->feature_bitmap = ntohl (flags);
7142 mp->is_set = is_set;
7150 api_bridge_flags (vat_main_t * vam)
7152 unformat_input_t *i = vam->input;
7153 vl_api_bridge_flags_t *mp;
7157 bd_flags_t flags = 0;
7160 /* Parse args required to build the message */
7161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7163 if (unformat (i, "bd_id %d", &bd_id))
7165 else if (unformat (i, "learn"))
7166 flags |= BRIDGE_API_FLAG_LEARN;
7167 else if (unformat (i, "forward"))
7168 flags |= BRIDGE_API_FLAG_FWD;
7169 else if (unformat (i, "flood"))
7170 flags |= BRIDGE_API_FLAG_FLOOD;
7171 else if (unformat (i, "uu-flood"))
7172 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7173 else if (unformat (i, "arp-term"))
7174 flags |= BRIDGE_API_FLAG_ARP_TERM;
7175 else if (unformat (i, "off"))
7177 else if (unformat (i, "disable"))
7185 errmsg ("missing bridge domain");
7189 M (BRIDGE_FLAGS, mp);
7191 mp->bd_id = ntohl (bd_id);
7192 mp->flags = ntohl (flags);
7193 mp->is_set = is_set;
7201 api_bd_ip_mac_add_del (vat_main_t * vam)
7203 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7204 vl_api_mac_address_t mac = { 0 };
7205 unformat_input_t *i = vam->input;
7206 vl_api_bd_ip_mac_add_del_t *mp;
7215 /* Parse args required to build the message */
7216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7218 if (unformat (i, "bd_id %d", &bd_id))
7222 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7226 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7230 else if (unformat (i, "del"))
7238 errmsg ("missing bridge domain");
7241 else if (ip_set == 0)
7243 errmsg ("missing IP address");
7246 else if (mac_set == 0)
7248 errmsg ("missing MAC address");
7252 M (BD_IP_MAC_ADD_DEL, mp);
7254 mp->entry.bd_id = ntohl (bd_id);
7255 mp->is_add = is_add;
7257 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7258 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7266 api_bd_ip_mac_flush (vat_main_t * vam)
7268 unformat_input_t *i = vam->input;
7269 vl_api_bd_ip_mac_flush_t *mp;
7274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7276 if (unformat (i, "bd_id %d", &bd_id))
7286 errmsg ("missing bridge domain");
7290 M (BD_IP_MAC_FLUSH, mp);
7292 mp->bd_id = ntohl (bd_id);
7299 static void vl_api_bd_ip_mac_details_t_handler
7300 (vl_api_bd_ip_mac_details_t * mp)
7302 vat_main_t *vam = &vat_main;
7306 ntohl (mp->entry.bd_id),
7307 format_vl_api_mac_address, mp->entry.mac,
7308 format_vl_api_address, &mp->entry.ip);
7311 static void vl_api_bd_ip_mac_details_t_handler_json
7312 (vl_api_bd_ip_mac_details_t * mp)
7314 vat_main_t *vam = &vat_main;
7315 vat_json_node_t *node = NULL;
7317 if (VAT_JSON_ARRAY != vam->json_tree.type)
7319 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7320 vat_json_init_array (&vam->json_tree);
7322 node = vat_json_array_add (&vam->json_tree);
7324 vat_json_init_object (node);
7325 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7326 vat_json_object_add_string_copy (node, "mac_address",
7327 format (0, "%U", format_vl_api_mac_address,
7331 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7332 vat_json_object_add_string_copy (node, "ip_address", ip);
7337 api_bd_ip_mac_dump (vat_main_t * vam)
7339 unformat_input_t *i = vam->input;
7340 vl_api_bd_ip_mac_dump_t *mp;
7341 vl_api_control_ping_t *mp_ping;
7346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7348 if (unformat (i, "bd_id %d", &bd_id))
7357 "\n%-5s %-7s %-20s %-30s",
7358 "bd_id", "is_ipv6", "mac_address", "ip_address");
7360 /* Dump Bridge Domain Ip to Mac entries */
7361 M (BD_IP_MAC_DUMP, mp);
7364 mp->bd_id = htonl (bd_id);
7370 /* Use a control ping for synchronization */
7371 MPING (CONTROL_PING, mp_ping);
7379 api_tap_create_v2 (vat_main_t * vam)
7381 unformat_input_t *i = vam->input;
7382 vl_api_tap_create_v2_t *mp;
7386 u32 num_rx_queues = 0;
7387 u8 *host_if_name = 0;
7388 u8 host_if_name_set = 0;
7391 u8 host_mac_addr[6];
7392 u8 host_mac_addr_set = 0;
7393 u8 *host_bridge = 0;
7394 u8 host_bridge_set = 0;
7395 u8 host_ip4_prefix_set = 0;
7396 u8 host_ip6_prefix_set = 0;
7397 ip4_address_t host_ip4_addr;
7398 ip4_address_t host_ip4_gw;
7399 u8 host_ip4_gw_set = 0;
7400 u32 host_ip4_prefix_len = 0;
7401 ip6_address_t host_ip6_addr;
7402 ip6_address_t host_ip6_gw;
7403 u8 host_ip6_gw_set = 0;
7404 u32 host_ip6_prefix_len = 0;
7405 u32 host_mtu_size = 0;
7406 u8 host_mtu_set = 0;
7409 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7411 clib_memset (mac_address, 0, sizeof (mac_address));
7413 /* Parse args required to build the message */
7414 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7416 if (unformat (i, "id %u", &id))
7420 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7422 else if (unformat (i, "host-if-name %s", &host_if_name))
7423 host_if_name_set = 1;
7424 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7426 else if (unformat (i, "host-ns %s", &host_ns))
7428 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7430 host_mac_addr_set = 1;
7431 else if (unformat (i, "host-bridge %s", &host_bridge))
7432 host_bridge_set = 1;
7433 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7434 &host_ip4_addr, &host_ip4_prefix_len))
7435 host_ip4_prefix_set = 1;
7436 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7437 &host_ip6_addr, &host_ip6_prefix_len))
7438 host_ip6_prefix_set = 1;
7439 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7441 host_ip4_gw_set = 1;
7442 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7444 host_ip6_gw_set = 1;
7445 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7447 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7449 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7451 else if (unformat (i, "no-gso"))
7452 tap_flags &= ~TAP_API_FLAG_GSO;
7453 else if (unformat (i, "gso"))
7454 tap_flags |= TAP_API_FLAG_GSO;
7455 else if (unformat (i, "csum-offload"))
7456 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
7457 else if (unformat (i, "persist"))
7458 tap_flags |= TAP_API_FLAG_PERSIST;
7459 else if (unformat (i, "attach"))
7460 tap_flags |= TAP_API_FLAG_ATTACH;
7461 else if (unformat (i, "tun"))
7462 tap_flags |= TAP_API_FLAG_TUN;
7463 else if (unformat (i, "gro-coalesce"))
7464 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
7465 else if (unformat (i, "packed"))
7466 tap_flags |= TAP_API_FLAG_PACKED;
7467 else if (unformat (i, "in-order"))
7468 tap_flags |= TAP_API_FLAG_IN_ORDER;
7473 if (vec_len (host_if_name) > 63)
7475 errmsg ("tap name too long. ");
7478 if (vec_len (host_ns) > 63)
7480 errmsg ("host name space too long. ");
7483 if (vec_len (host_bridge) > 63)
7485 errmsg ("host bridge name too long. ");
7488 if (host_ip4_prefix_len > 32)
7490 errmsg ("host ip4 prefix length not valid. ");
7493 if (host_ip6_prefix_len > 128)
7495 errmsg ("host ip6 prefix length not valid. ");
7498 if (!is_pow2 (rx_ring_sz))
7500 errmsg ("rx ring size must be power of 2. ");
7503 if (rx_ring_sz > 32768)
7505 errmsg ("rx ring size must be 32768 or lower. ");
7508 if (!is_pow2 (tx_ring_sz))
7510 errmsg ("tx ring size must be power of 2. ");
7513 if (tx_ring_sz > 32768)
7515 errmsg ("tx ring size must be 32768 or lower. ");
7518 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7520 errmsg ("host MTU size must be in between 64 and 65355. ");
7524 /* Construct the API message */
7525 M (TAP_CREATE_V2, mp);
7527 mp->id = ntohl (id);
7528 mp->use_random_mac = random_mac;
7529 mp->num_rx_queues = (u8) num_rx_queues;
7530 mp->tx_ring_sz = ntohs (tx_ring_sz);
7531 mp->rx_ring_sz = ntohs (rx_ring_sz);
7532 mp->host_mtu_set = host_mtu_set;
7533 mp->host_mtu_size = ntohl (host_mtu_size);
7534 mp->host_mac_addr_set = host_mac_addr_set;
7535 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7536 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7537 mp->host_ip4_gw_set = host_ip4_gw_set;
7538 mp->host_ip6_gw_set = host_ip6_gw_set;
7539 mp->tap_flags = ntohl (tap_flags);
7540 mp->host_namespace_set = host_ns_set;
7541 mp->host_if_name_set = host_if_name_set;
7542 mp->host_bridge_set = host_bridge_set;
7544 if (random_mac == 0)
7545 clib_memcpy (mp->mac_address, mac_address, 6);
7546 if (host_mac_addr_set)
7547 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7548 if (host_if_name_set)
7549 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7551 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7552 if (host_bridge_set)
7553 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7554 if (host_ip4_prefix_set)
7556 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7557 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7559 if (host_ip6_prefix_set)
7561 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7562 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7564 if (host_ip4_gw_set)
7565 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7566 if (host_ip6_gw_set)
7567 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7570 vec_free (host_if_name);
7571 vec_free (host_bridge);
7576 /* Wait for a reply... */
7582 api_tap_delete_v2 (vat_main_t * vam)
7584 unformat_input_t *i = vam->input;
7585 vl_api_tap_delete_v2_t *mp;
7586 u32 sw_if_index = ~0;
7587 u8 sw_if_index_set = 0;
7590 /* Parse args required to build the message */
7591 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7594 sw_if_index_set = 1;
7595 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7596 sw_if_index_set = 1;
7601 if (sw_if_index_set == 0)
7603 errmsg ("missing vpp interface name. ");
7607 /* Construct the API message */
7608 M (TAP_DELETE_V2, mp);
7610 mp->sw_if_index = ntohl (sw_if_index);
7615 /* Wait for a reply... */
7621 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7623 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7626 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7629 addr->domain = x[0];
7632 addr->function = x[3];
7638 api_virtio_pci_create_v2 (vat_main_t * vam)
7640 unformat_input_t *i = vam->input;
7641 vl_api_virtio_pci_create_v2_t *mp;
7645 u64 features = (u64) ~ (0ULL);
7646 u32 virtio_flags = 0;
7649 clib_memset (mac_address, 0, sizeof (mac_address));
7651 /* Parse args required to build the message */
7652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7654 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7658 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7660 else if (unformat (i, "features 0x%llx", &features))
7662 else if (unformat (i, "gso-enabled"))
7663 virtio_flags |= VIRTIO_API_FLAG_GSO;
7664 else if (unformat (i, "csum-offload-enabled"))
7665 virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
7666 else if (unformat (i, "gro-coalesce"))
7667 virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
7668 else if (unformat (i, "packed"))
7669 virtio_flags |= VIRTIO_API_FLAG_PACKED;
7670 else if (unformat (i, "in-order"))
7671 virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
7678 errmsg ("pci address must be non zero. ");
7682 /* Construct the API message */
7683 M (VIRTIO_PCI_CREATE_V2, mp);
7685 mp->use_random_mac = random_mac;
7687 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7688 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7689 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7690 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7692 mp->features = clib_host_to_net_u64 (features);
7693 mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
7695 if (random_mac == 0)
7696 clib_memcpy (mp->mac_address, mac_address, 6);
7701 /* Wait for a reply... */
7707 api_virtio_pci_delete (vat_main_t * vam)
7709 unformat_input_t *i = vam->input;
7710 vl_api_virtio_pci_delete_t *mp;
7711 u32 sw_if_index = ~0;
7712 u8 sw_if_index_set = 0;
7715 /* Parse args required to build the message */
7716 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7718 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7719 sw_if_index_set = 1;
7720 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7721 sw_if_index_set = 1;
7726 if (sw_if_index_set == 0)
7728 errmsg ("missing vpp interface name. ");
7732 /* Construct the API message */
7733 M (VIRTIO_PCI_DELETE, mp);
7735 mp->sw_if_index = htonl (sw_if_index);
7740 /* Wait for a reply... */
7746 api_bond_create (vat_main_t * vam)
7748 unformat_input_t *i = vam->input;
7749 vl_api_bond_create_t *mp;
7759 clib_memset (mac_address, 0, sizeof (mac_address));
7762 /* Parse args required to build the message */
7763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7765 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7767 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7768 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7770 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7773 else if (unformat (i, "numa-only"))
7775 else if (unformat (i, "id %u", &id))
7781 if (mode_is_set == 0)
7783 errmsg ("Missing bond mode. ");
7787 /* Construct the API message */
7788 M (BOND_CREATE, mp);
7790 mp->use_custom_mac = custom_mac;
7792 mp->mode = htonl (mode);
7793 mp->lb = htonl (lb);
7794 mp->id = htonl (id);
7795 mp->numa_only = numa_only;
7798 clib_memcpy (mp->mac_address, mac_address, 6);
7803 /* Wait for a reply... */
7809 api_bond_create2 (vat_main_t * vam)
7811 unformat_input_t *i = vam->input;
7812 vl_api_bond_create2_t *mp;
7823 clib_memset (mac_address, 0, sizeof (mac_address));
7826 /* Parse args required to build the message */
7827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7829 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7831 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7832 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7834 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7837 else if (unformat (i, "numa-only"))
7839 else if (unformat (i, "gso"))
7841 else if (unformat (i, "id %u", &id))
7847 if (mode_is_set == 0)
7849 errmsg ("Missing bond mode. ");
7853 /* Construct the API message */
7854 M (BOND_CREATE2, mp);
7856 mp->use_custom_mac = custom_mac;
7858 mp->mode = htonl (mode);
7859 mp->lb = htonl (lb);
7860 mp->id = htonl (id);
7861 mp->numa_only = numa_only;
7862 mp->enable_gso = gso;
7865 clib_memcpy (mp->mac_address, mac_address, 6);
7870 /* Wait for a reply... */
7876 api_bond_delete (vat_main_t * vam)
7878 unformat_input_t *i = vam->input;
7879 vl_api_bond_delete_t *mp;
7880 u32 sw_if_index = ~0;
7881 u8 sw_if_index_set = 0;
7884 /* Parse args required to build the message */
7885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7888 sw_if_index_set = 1;
7889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7890 sw_if_index_set = 1;
7895 if (sw_if_index_set == 0)
7897 errmsg ("missing vpp interface name. ");
7901 /* Construct the API message */
7902 M (BOND_DELETE, mp);
7904 mp->sw_if_index = ntohl (sw_if_index);
7909 /* Wait for a reply... */
7915 api_bond_add_member (vat_main_t * vam)
7917 unformat_input_t *i = vam->input;
7918 vl_api_bond_add_member_t *mp;
7919 u32 bond_sw_if_index;
7923 u32 bond_sw_if_index_is_set = 0;
7925 u8 sw_if_index_is_set = 0;
7927 /* Parse args required to build the message */
7928 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7930 if (unformat (i, "sw_if_index %d", &sw_if_index))
7931 sw_if_index_is_set = 1;
7932 else if (unformat (i, "bond %u", &bond_sw_if_index))
7933 bond_sw_if_index_is_set = 1;
7934 else if (unformat (i, "passive %d", &is_passive))
7936 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7942 if (bond_sw_if_index_is_set == 0)
7944 errmsg ("Missing bond sw_if_index. ");
7947 if (sw_if_index_is_set == 0)
7949 errmsg ("Missing member sw_if_index. ");
7953 /* Construct the API message */
7954 M (BOND_ADD_MEMBER, mp);
7956 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7957 mp->sw_if_index = ntohl (sw_if_index);
7958 mp->is_long_timeout = is_long_timeout;
7959 mp->is_passive = is_passive;
7964 /* Wait for a reply... */
7970 api_bond_detach_member (vat_main_t * vam)
7972 unformat_input_t *i = vam->input;
7973 vl_api_bond_detach_member_t *mp;
7974 u32 sw_if_index = ~0;
7975 u8 sw_if_index_set = 0;
7978 /* Parse args required to build the message */
7979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7981 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7982 sw_if_index_set = 1;
7983 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7984 sw_if_index_set = 1;
7989 if (sw_if_index_set == 0)
7991 errmsg ("missing vpp interface name. ");
7995 /* Construct the API message */
7996 M (BOND_DETACH_MEMBER, mp);
7998 mp->sw_if_index = ntohl (sw_if_index);
8003 /* Wait for a reply... */
8009 api_ip_table_add_del (vat_main_t * vam)
8011 unformat_input_t *i = vam->input;
8012 vl_api_ip_table_add_del_t *mp;
8018 /* Parse args required to build the message */
8019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8021 if (unformat (i, "ipv6"))
8023 else if (unformat (i, "del"))
8025 else if (unformat (i, "add"))
8027 else if (unformat (i, "table %d", &table_id))
8031 clib_warning ("parse error '%U'", format_unformat_error, i);
8038 errmsg ("missing table-ID");
8042 /* Construct the API message */
8043 M (IP_TABLE_ADD_DEL, mp);
8045 mp->table.table_id = ntohl (table_id);
8046 mp->table.is_ip6 = is_ipv6;
8047 mp->is_add = is_add;
8052 /* Wait for a reply... */
8059 unformat_fib_path (unformat_input_t * input, va_list * args)
8061 vat_main_t *vam = va_arg (*args, vat_main_t *);
8062 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
8063 u32 weight, preference;
8064 mpls_label_t out_label;
8066 clib_memset (path, 0, sizeof (*path));
8068 path->sw_if_index = ~0;
8072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8074 if (unformat (input, "%U %U",
8075 unformat_vl_api_ip4_address,
8076 &path->nh.address.ip4,
8077 api_unformat_sw_if_index, vam, &path->sw_if_index))
8079 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8081 else if (unformat (input, "%U %U",
8082 unformat_vl_api_ip6_address,
8083 &path->nh.address.ip6,
8084 api_unformat_sw_if_index, vam, &path->sw_if_index))
8086 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8088 else if (unformat (input, "weight %u", &weight))
8090 path->weight = weight;
8092 else if (unformat (input, "preference %u", &preference))
8094 path->preference = preference;
8096 else if (unformat (input, "%U next-hop-table %d",
8097 unformat_vl_api_ip4_address,
8098 &path->nh.address.ip4, &path->table_id))
8100 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8102 else if (unformat (input, "%U next-hop-table %d",
8103 unformat_vl_api_ip6_address,
8104 &path->nh.address.ip6, &path->table_id))
8106 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8108 else if (unformat (input, "%U",
8109 unformat_vl_api_ip4_address, &path->nh.address.ip4))
8112 * the recursive next-hops are by default in the default table
8115 path->sw_if_index = ~0;
8116 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8118 else if (unformat (input, "%U",
8119 unformat_vl_api_ip6_address, &path->nh.address.ip6))
8122 * the recursive next-hops are by default in the default table
8125 path->sw_if_index = ~0;
8126 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8128 else if (unformat (input, "resolve-via-host"))
8130 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
8132 else if (unformat (input, "resolve-via-attached"))
8134 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
8136 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
8138 path->type = FIB_API_PATH_TYPE_LOCAL;
8139 path->sw_if_index = ~0;
8140 path->proto = FIB_API_PATH_NH_PROTO_IP4;
8142 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
8144 path->type = FIB_API_PATH_TYPE_LOCAL;
8145 path->sw_if_index = ~0;
8146 path->proto = FIB_API_PATH_NH_PROTO_IP6;
8148 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
8150 else if (unformat (input, "via-label %d", &path->nh.via_label))
8152 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8153 path->sw_if_index = ~0;
8155 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8157 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8158 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8160 else if (unformat (input, "local"))
8162 path->type = FIB_API_PATH_TYPE_LOCAL;
8164 else if (unformat (input, "out-labels"))
8166 while (unformat (input, "%d", &out_label))
8168 path->label_stack[path->n_labels].label = out_label;
8169 path->label_stack[path->n_labels].is_uniform = 0;
8170 path->label_stack[path->n_labels].ttl = 64;
8174 else if (unformat (input, "via"))
8176 /* new path, back up and return */
8177 unformat_put_input (input);
8178 unformat_put_input (input);
8179 unformat_put_input (input);
8180 unformat_put_input (input);
8189 path->proto = ntohl (path->proto);
8190 path->type = ntohl (path->type);
8191 path->flags = ntohl (path->flags);
8192 path->table_id = ntohl (path->table_id);
8193 path->sw_if_index = ntohl (path->sw_if_index);
8199 api_ip_route_add_del (vat_main_t * vam)
8201 unformat_input_t *i = vam->input;
8202 vl_api_ip_route_add_del_t *mp;
8205 u8 is_multipath = 0;
8208 vl_api_prefix_t pfx = { };
8209 vl_api_fib_path_t paths[8];
8213 u32 random_add_del = 0;
8214 u32 *random_vector = 0;
8215 u32 random_seed = 0xdeaddabe;
8217 /* Parse args required to build the message */
8218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8220 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8222 else if (unformat (i, "del"))
8224 else if (unformat (i, "add"))
8226 else if (unformat (i, "vrf %d", &vrf_id))
8228 else if (unformat (i, "count %d", &count))
8230 else if (unformat (i, "random"))
8232 else if (unformat (i, "multipath"))
8234 else if (unformat (i, "seed %d", &random_seed))
8238 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8241 if (8 == path_count)
8243 errmsg ("max 8 paths");
8249 clib_warning ("parse error '%U'", format_unformat_error, i);
8256 errmsg ("specify a path; via ...");
8259 if (prefix_set == 0)
8261 errmsg ("missing prefix");
8265 /* Generate a pile of unique, random routes */
8268 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8269 u32 this_random_address;
8272 random_hash = hash_create (count, sizeof (uword));
8274 hash_set (random_hash, i->as_u32, 1);
8275 for (j = 0; j <= count; j++)
8279 this_random_address = random_u32 (&random_seed);
8280 this_random_address =
8281 clib_host_to_net_u32 (this_random_address);
8283 while (hash_get (random_hash, this_random_address));
8284 vec_add1 (random_vector, this_random_address);
8285 hash_set (random_hash, this_random_address, 1);
8287 hash_free (random_hash);
8288 set_ip4_address (&pfx.address, random_vector[0]);
8293 /* Turn on async mode */
8294 vam->async_mode = 1;
8295 vam->async_errors = 0;
8296 before = vat_time_now (vam);
8299 for (j = 0; j < count; j++)
8301 /* Construct the API message */
8302 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8304 mp->is_add = is_add;
8305 mp->is_multipath = is_multipath;
8307 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8308 mp->route.table_id = ntohl (vrf_id);
8309 mp->route.n_paths = path_count;
8311 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8314 set_ip4_address (&pfx.address, random_vector[j + 1]);
8316 increment_address (&pfx.address);
8319 /* If we receive SIGTERM, stop now... */
8324 /* When testing multiple add/del ops, use a control-ping to sync */
8327 vl_api_control_ping_t *mp_ping;
8331 /* Shut off async mode */
8332 vam->async_mode = 0;
8334 MPING (CONTROL_PING, mp_ping);
8337 timeout = vat_time_now (vam) + 1.0;
8338 while (vat_time_now (vam) < timeout)
8339 if (vam->result_ready == 1)
8344 if (vam->retval == -99)
8347 if (vam->async_errors > 0)
8349 errmsg ("%d asynchronous errors", vam->async_errors);
8352 vam->async_errors = 0;
8353 after = vat_time_now (vam);
8355 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8359 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8360 count, after - before, count / (after - before));
8366 /* Wait for a reply... */
8371 /* Return the good/bad news */
8372 return (vam->retval);
8376 api_ip_mroute_add_del (vat_main_t * vam)
8378 unformat_input_t *i = vam->input;
8379 u8 path_set = 0, prefix_set = 0, is_add = 1;
8380 vl_api_ip_mroute_add_del_t *mp;
8381 mfib_entry_flags_t eflags = 0;
8382 vl_api_mfib_path_t path;
8383 vl_api_mprefix_t pfx = { };
8387 /* Parse args required to build the message */
8388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8390 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8393 pfx.grp_address_length = htons (pfx.grp_address_length);
8395 else if (unformat (i, "del"))
8397 else if (unformat (i, "add"))
8399 else if (unformat (i, "vrf %d", &vrf_id))
8401 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8402 path.itf_flags = htonl (path.itf_flags);
8403 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8405 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8409 clib_warning ("parse error '%U'", format_unformat_error, i);
8414 if (prefix_set == 0)
8416 errmsg ("missing addresses\n");
8421 errmsg ("missing path\n");
8425 /* Construct the API message */
8426 M (IP_MROUTE_ADD_DEL, mp);
8428 mp->is_add = is_add;
8429 mp->is_multipath = 1;
8431 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8432 mp->route.table_id = htonl (vrf_id);
8433 mp->route.n_paths = 1;
8434 mp->route.entry_flags = htonl (eflags);
8436 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8440 /* Wait for a reply... */
8446 api_mpls_table_add_del (vat_main_t * vam)
8448 unformat_input_t *i = vam->input;
8449 vl_api_mpls_table_add_del_t *mp;
8454 /* Parse args required to build the message */
8455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8457 if (unformat (i, "table %d", &table_id))
8459 else if (unformat (i, "del"))
8461 else if (unformat (i, "add"))
8465 clib_warning ("parse error '%U'", format_unformat_error, i);
8472 errmsg ("missing table-ID");
8476 /* Construct the API message */
8477 M (MPLS_TABLE_ADD_DEL, mp);
8479 mp->mt_table.mt_table_id = ntohl (table_id);
8480 mp->mt_is_add = is_add;
8485 /* Wait for a reply... */
8492 api_mpls_route_add_del (vat_main_t * vam)
8494 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8495 mpls_label_t local_label = MPLS_LABEL_INVALID;
8496 unformat_input_t *i = vam->input;
8497 vl_api_mpls_route_add_del_t *mp;
8498 vl_api_fib_path_t paths[8];
8502 /* Parse args required to build the message */
8503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8505 if (unformat (i, "%d", &local_label))
8507 else if (unformat (i, "eos"))
8509 else if (unformat (i, "non-eos"))
8511 else if (unformat (i, "del"))
8513 else if (unformat (i, "add"))
8515 else if (unformat (i, "multipath"))
8517 else if (unformat (i, "count %d", &count))
8521 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8524 if (8 == path_count)
8526 errmsg ("max 8 paths");
8532 clib_warning ("parse error '%U'", format_unformat_error, i);
8539 errmsg ("specify a path; via ...");
8543 if (MPLS_LABEL_INVALID == local_label)
8545 errmsg ("missing label");
8551 /* Turn on async mode */
8552 vam->async_mode = 1;
8553 vam->async_errors = 0;
8554 before = vat_time_now (vam);
8557 for (j = 0; j < count; j++)
8559 /* Construct the API message */
8560 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8562 mp->mr_is_add = is_add;
8563 mp->mr_is_multipath = is_multipath;
8565 mp->mr_route.mr_label = local_label;
8566 mp->mr_route.mr_eos = is_eos;
8567 mp->mr_route.mr_table_id = 0;
8568 mp->mr_route.mr_n_paths = path_count;
8570 clib_memcpy (&mp->mr_route.mr_paths, paths,
8571 sizeof (paths[0]) * path_count);
8577 /* If we receive SIGTERM, stop now... */
8582 /* When testing multiple add/del ops, use a control-ping to sync */
8585 vl_api_control_ping_t *mp_ping;
8589 /* Shut off async mode */
8590 vam->async_mode = 0;
8592 MPING (CONTROL_PING, mp_ping);
8595 timeout = vat_time_now (vam) + 1.0;
8596 while (vat_time_now (vam) < timeout)
8597 if (vam->result_ready == 1)
8602 if (vam->retval == -99)
8605 if (vam->async_errors > 0)
8607 errmsg ("%d asynchronous errors", vam->async_errors);
8610 vam->async_errors = 0;
8611 after = vat_time_now (vam);
8613 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8617 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8618 count, after - before, count / (after - before));
8624 /* Wait for a reply... */
8629 /* Return the good/bad news */
8630 return (vam->retval);
8635 api_mpls_ip_bind_unbind (vat_main_t * vam)
8637 unformat_input_t *i = vam->input;
8638 vl_api_mpls_ip_bind_unbind_t *mp;
8639 u32 ip_table_id = 0;
8641 vl_api_prefix_t pfx;
8643 mpls_label_t local_label = MPLS_LABEL_INVALID;
8646 /* Parse args required to build the message */
8647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8649 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8651 else if (unformat (i, "%d", &local_label))
8653 else if (unformat (i, "table-id %d", &ip_table_id))
8655 else if (unformat (i, "unbind"))
8657 else if (unformat (i, "bind"))
8661 clib_warning ("parse error '%U'", format_unformat_error, i);
8668 errmsg ("IP prefix not set");
8672 if (MPLS_LABEL_INVALID == local_label)
8674 errmsg ("missing label");
8678 /* Construct the API message */
8679 M (MPLS_IP_BIND_UNBIND, mp);
8681 mp->mb_is_bind = is_bind;
8682 mp->mb_ip_table_id = ntohl (ip_table_id);
8683 mp->mb_mpls_table_id = 0;
8684 mp->mb_label = ntohl (local_label);
8685 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8690 /* Wait for a reply... */
8697 api_sr_mpls_policy_add (vat_main_t * vam)
8699 unformat_input_t *i = vam->input;
8700 vl_api_sr_mpls_policy_add_t *mp;
8706 u32 *segments = NULL;
8709 /* Parse args required to build the message */
8710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8712 if (unformat (i, "bsid %d", &bsid))
8714 else if (unformat (i, "weight %d", &weight))
8716 else if (unformat (i, "spray"))
8718 else if (unformat (i, "next %d", &sid))
8721 vec_add1 (segments, htonl (sid));
8725 clib_warning ("parse error '%U'", format_unformat_error, i);
8732 errmsg ("bsid not set");
8736 if (n_segments == 0)
8738 errmsg ("no sid in segment stack");
8742 /* Construct the API message */
8743 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8745 mp->bsid = htonl (bsid);
8746 mp->weight = htonl (weight);
8747 mp->is_spray = type;
8748 mp->n_segments = n_segments;
8749 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8750 vec_free (segments);
8755 /* Wait for a reply... */
8761 api_sr_mpls_policy_del (vat_main_t * vam)
8763 unformat_input_t *i = vam->input;
8764 vl_api_sr_mpls_policy_del_t *mp;
8768 /* Parse args required to build the message */
8769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8771 if (unformat (i, "bsid %d", &bsid))
8775 clib_warning ("parse error '%U'", format_unformat_error, i);
8782 errmsg ("bsid not set");
8786 /* Construct the API message */
8787 M (SR_MPLS_POLICY_DEL, mp);
8789 mp->bsid = htonl (bsid);
8794 /* Wait for a reply... */
8800 api_bier_table_add_del (vat_main_t * vam)
8802 unformat_input_t *i = vam->input;
8803 vl_api_bier_table_add_del_t *mp;
8805 u32 set = 0, sub_domain = 0, hdr_len = 3;
8806 mpls_label_t local_label = MPLS_LABEL_INVALID;
8809 /* Parse args required to build the message */
8810 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8812 if (unformat (i, "sub-domain %d", &sub_domain))
8814 else if (unformat (i, "set %d", &set))
8816 else if (unformat (i, "label %d", &local_label))
8818 else if (unformat (i, "hdr-len %d", &hdr_len))
8820 else if (unformat (i, "add"))
8822 else if (unformat (i, "del"))
8826 clib_warning ("parse error '%U'", format_unformat_error, i);
8831 if (MPLS_LABEL_INVALID == local_label)
8833 errmsg ("missing label\n");
8837 /* Construct the API message */
8838 M (BIER_TABLE_ADD_DEL, mp);
8840 mp->bt_is_add = is_add;
8841 mp->bt_label = ntohl (local_label);
8842 mp->bt_tbl_id.bt_set = set;
8843 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8844 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8849 /* Wait for a reply... */
8856 api_bier_route_add_del (vat_main_t * vam)
8858 unformat_input_t *i = vam->input;
8859 vl_api_bier_route_add_del_t *mp;
8861 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8862 ip4_address_t v4_next_hop_address;
8863 ip6_address_t v6_next_hop_address;
8864 u8 next_hop_set = 0;
8865 u8 next_hop_proto_is_ip4 = 1;
8866 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8869 /* Parse args required to build the message */
8870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8872 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8874 next_hop_proto_is_ip4 = 1;
8877 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8879 next_hop_proto_is_ip4 = 0;
8882 if (unformat (i, "sub-domain %d", &sub_domain))
8884 else if (unformat (i, "set %d", &set))
8886 else if (unformat (i, "hdr-len %d", &hdr_len))
8888 else if (unformat (i, "bp %d", &bp))
8890 else if (unformat (i, "add"))
8892 else if (unformat (i, "del"))
8894 else if (unformat (i, "out-label %d", &next_hop_out_label))
8898 clib_warning ("parse error '%U'", format_unformat_error, i);
8903 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8905 errmsg ("next hop / label set\n");
8910 errmsg ("bit=position not set\n");
8914 /* Construct the API message */
8915 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8917 mp->br_is_add = is_add;
8918 mp->br_route.br_tbl_id.bt_set = set;
8919 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8920 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8921 mp->br_route.br_bp = ntohs (bp);
8922 mp->br_route.br_n_paths = 1;
8923 mp->br_route.br_paths[0].n_labels = 1;
8924 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8925 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8926 FIB_API_PATH_NH_PROTO_IP4 :
8927 FIB_API_PATH_NH_PROTO_IP6);
8929 if (next_hop_proto_is_ip4)
8931 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8932 &v4_next_hop_address, sizeof (v4_next_hop_address));
8936 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8937 &v6_next_hop_address, sizeof (v6_next_hop_address));
8943 /* Wait for a reply... */
8950 api_mpls_tunnel_add_del (vat_main_t * vam)
8952 unformat_input_t *i = vam->input;
8953 vl_api_mpls_tunnel_add_del_t *mp;
8955 vl_api_fib_path_t paths[8];
8956 u32 sw_if_index = ~0;
8962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8964 if (unformat (i, "add"))
8968 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8970 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8972 else if (unformat (i, "l2-only"))
8976 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8979 if (8 == path_count)
8981 errmsg ("max 8 paths");
8987 clib_warning ("parse error '%U'", format_unformat_error, i);
8992 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8994 mp->mt_is_add = is_add;
8995 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8996 mp->mt_tunnel.mt_l2_only = l2_only;
8997 mp->mt_tunnel.mt_is_multicast = 0;
8998 mp->mt_tunnel.mt_n_paths = path_count;
9000 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
9001 sizeof (paths[0]) * path_count);
9009 api_sw_interface_set_unnumbered (vat_main_t * vam)
9011 unformat_input_t *i = vam->input;
9012 vl_api_sw_interface_set_unnumbered_t *mp;
9014 u32 unnum_sw_index = ~0;
9016 u8 sw_if_index_set = 0;
9019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9021 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9022 sw_if_index_set = 1;
9023 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9024 sw_if_index_set = 1;
9025 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9027 else if (unformat (i, "del"))
9031 clib_warning ("parse error '%U'", format_unformat_error, i);
9036 if (sw_if_index_set == 0)
9038 errmsg ("missing interface name or sw_if_index");
9042 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9044 mp->sw_if_index = ntohl (sw_if_index);
9045 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9046 mp->is_add = is_add;
9055 api_create_vlan_subif (vat_main_t * vam)
9057 unformat_input_t *i = vam->input;
9058 vl_api_create_vlan_subif_t *mp;
9060 u8 sw_if_index_set = 0;
9065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9067 if (unformat (i, "sw_if_index %d", &sw_if_index))
9068 sw_if_index_set = 1;
9070 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9071 sw_if_index_set = 1;
9072 else if (unformat (i, "vlan %d", &vlan_id))
9076 clib_warning ("parse error '%U'", format_unformat_error, i);
9081 if (sw_if_index_set == 0)
9083 errmsg ("missing interface name or sw_if_index");
9087 if (vlan_id_set == 0)
9089 errmsg ("missing vlan_id");
9092 M (CREATE_VLAN_SUBIF, mp);
9094 mp->sw_if_index = ntohl (sw_if_index);
9095 mp->vlan_id = ntohl (vlan_id);
9102 #define foreach_create_subif_bit \
9109 _(outer_vlan_id_any) \
9110 _(inner_vlan_id_any)
9112 #define foreach_create_subif_flag \
9117 _(4, "exact_match") \
9118 _(5, "default_sub") \
9119 _(6, "outer_vlan_id_any") \
9120 _(7, "inner_vlan_id_any")
9123 api_create_subif (vat_main_t * vam)
9125 unformat_input_t *i = vam->input;
9126 vl_api_create_subif_t *mp;
9128 u8 sw_if_index_set = 0;
9131 u32 __attribute__ ((unused)) no_tags = 0;
9132 u32 __attribute__ ((unused)) one_tag = 0;
9133 u32 __attribute__ ((unused)) two_tags = 0;
9134 u32 __attribute__ ((unused)) dot1ad = 0;
9135 u32 __attribute__ ((unused)) exact_match = 0;
9136 u32 __attribute__ ((unused)) default_sub = 0;
9137 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
9138 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
9140 u16 outer_vlan_id = 0;
9141 u16 inner_vlan_id = 0;
9144 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9146 if (unformat (i, "sw_if_index %d", &sw_if_index))
9147 sw_if_index_set = 1;
9149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9150 sw_if_index_set = 1;
9151 else if (unformat (i, "sub_id %d", &sub_id))
9153 else if (unformat (i, "outer_vlan_id %d", &tmp))
9154 outer_vlan_id = tmp;
9155 else if (unformat (i, "inner_vlan_id %d", &tmp))
9156 inner_vlan_id = tmp;
9158 #define _(a) else if (unformat (i, #a)) a = 1 ;
9159 foreach_create_subif_bit
9163 clib_warning ("parse error '%U'", format_unformat_error, i);
9168 if (sw_if_index_set == 0)
9170 errmsg ("missing interface name or sw_if_index");
9174 if (sub_id_set == 0)
9176 errmsg ("missing sub_id");
9179 M (CREATE_SUBIF, mp);
9181 mp->sw_if_index = ntohl (sw_if_index);
9182 mp->sub_id = ntohl (sub_id);
9184 #define _(a,b) mp->sub_if_flags |= (1 << a);
9185 foreach_create_subif_flag;
9188 mp->outer_vlan_id = ntohs (outer_vlan_id);
9189 mp->inner_vlan_id = ntohs (inner_vlan_id);
9197 api_ip_table_replace_begin (vat_main_t * vam)
9199 unformat_input_t *i = vam->input;
9200 vl_api_ip_table_replace_begin_t *mp;
9205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9207 if (unformat (i, "table %d", &table_id))
9209 else if (unformat (i, "ipv6"))
9213 clib_warning ("parse error '%U'", format_unformat_error, i);
9218 M (IP_TABLE_REPLACE_BEGIN, mp);
9220 mp->table.table_id = ntohl (table_id);
9221 mp->table.is_ip6 = is_ipv6;
9229 api_ip_table_flush (vat_main_t * vam)
9231 unformat_input_t *i = vam->input;
9232 vl_api_ip_table_flush_t *mp;
9237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9239 if (unformat (i, "table %d", &table_id))
9241 else if (unformat (i, "ipv6"))
9245 clib_warning ("parse error '%U'", format_unformat_error, i);
9250 M (IP_TABLE_FLUSH, mp);
9252 mp->table.table_id = ntohl (table_id);
9253 mp->table.is_ip6 = is_ipv6;
9261 api_ip_table_replace_end (vat_main_t * vam)
9263 unformat_input_t *i = vam->input;
9264 vl_api_ip_table_replace_end_t *mp;
9269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9271 if (unformat (i, "table %d", &table_id))
9273 else if (unformat (i, "ipv6"))
9277 clib_warning ("parse error '%U'", format_unformat_error, i);
9282 M (IP_TABLE_REPLACE_END, mp);
9284 mp->table.table_id = ntohl (table_id);
9285 mp->table.is_ip6 = is_ipv6;
9293 api_set_ip_flow_hash (vat_main_t * vam)
9295 unformat_input_t *i = vam->input;
9296 vl_api_set_ip_flow_hash_t *mp;
9308 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9310 if (unformat (i, "vrf %d", &vrf_id))
9312 else if (unformat (i, "ipv6"))
9314 else if (unformat (i, "src"))
9316 else if (unformat (i, "dst"))
9318 else if (unformat (i, "sport"))
9320 else if (unformat (i, "dport"))
9322 else if (unformat (i, "proto"))
9324 else if (unformat (i, "reverse"))
9329 clib_warning ("parse error '%U'", format_unformat_error, i);
9334 if (vrf_id_set == 0)
9336 errmsg ("missing vrf id");
9340 M (SET_IP_FLOW_HASH, mp);
9346 mp->reverse = reverse;
9347 mp->vrf_id = ntohl (vrf_id);
9348 mp->is_ipv6 = is_ipv6;
9356 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9358 unformat_input_t *i = vam->input;
9359 vl_api_sw_interface_ip6_enable_disable_t *mp;
9361 u8 sw_if_index_set = 0;
9365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9367 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9368 sw_if_index_set = 1;
9369 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9370 sw_if_index_set = 1;
9371 else if (unformat (i, "enable"))
9373 else if (unformat (i, "disable"))
9377 clib_warning ("parse error '%U'", format_unformat_error, i);
9382 if (sw_if_index_set == 0)
9384 errmsg ("missing interface name or sw_if_index");
9388 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9390 mp->sw_if_index = ntohl (sw_if_index);
9391 mp->enable = enable;
9400 api_l2_patch_add_del (vat_main_t * vam)
9402 unformat_input_t *i = vam->input;
9403 vl_api_l2_patch_add_del_t *mp;
9405 u8 rx_sw_if_index_set = 0;
9407 u8 tx_sw_if_index_set = 0;
9411 /* Parse args required to build the message */
9412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9414 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9415 rx_sw_if_index_set = 1;
9416 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9417 tx_sw_if_index_set = 1;
9418 else if (unformat (i, "rx"))
9420 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9422 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9424 rx_sw_if_index_set = 1;
9429 else if (unformat (i, "tx"))
9431 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9433 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9435 tx_sw_if_index_set = 1;
9440 else if (unformat (i, "del"))
9446 if (rx_sw_if_index_set == 0)
9448 errmsg ("missing rx interface name or rx_sw_if_index");
9452 if (tx_sw_if_index_set == 0)
9454 errmsg ("missing tx interface name or tx_sw_if_index");
9458 M (L2_PATCH_ADD_DEL, mp);
9460 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9461 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9462 mp->is_add = is_add;
9470 u8 localsid_addr[16];
9479 api_sr_localsid_add_del (vat_main_t * vam)
9481 unformat_input_t *i = vam->input;
9482 vl_api_sr_localsid_add_del_t *mp;
9485 ip6_address_t localsid;
9489 u32 fib_table = ~(u32) 0;
9490 ip46_address_t nh_addr;
9491 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9493 bool nexthop_set = 0;
9497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9499 if (unformat (i, "del"))
9501 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9502 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9504 else if (unformat (i, "behavior %u", &behavior));
9505 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9506 else if (unformat (i, "fib-table %u", &fib_table));
9507 else if (unformat (i, "end.psp %u", &behavior));
9512 M (SR_LOCALSID_ADD_DEL, mp);
9514 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9518 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9520 mp->behavior = behavior;
9521 mp->sw_if_index = ntohl (sw_if_index);
9522 mp->fib_table = ntohl (fib_table);
9523 mp->end_psp = end_psp;
9524 mp->is_del = is_del;
9532 api_ioam_enable (vat_main_t * vam)
9534 unformat_input_t *input = vam->input;
9535 vl_api_ioam_enable_t *mp;
9537 int has_trace_option = 0;
9538 int has_pot_option = 0;
9539 int has_seqno_option = 0;
9540 int has_analyse_option = 0;
9543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9545 if (unformat (input, "trace"))
9546 has_trace_option = 1;
9547 else if (unformat (input, "pot"))
9549 else if (unformat (input, "seqno"))
9550 has_seqno_option = 1;
9551 else if (unformat (input, "analyse"))
9552 has_analyse_option = 1;
9556 M (IOAM_ENABLE, mp);
9557 mp->id = htons (id);
9558 mp->seqno = has_seqno_option;
9559 mp->analyse = has_analyse_option;
9560 mp->pot_enable = has_pot_option;
9561 mp->trace_enable = has_trace_option;
9570 api_ioam_disable (vat_main_t * vam)
9572 vl_api_ioam_disable_t *mp;
9575 M (IOAM_DISABLE, mp);
9581 #define foreach_tcp_proto_field \
9585 #define foreach_udp_proto_field \
9589 #define foreach_ip4_proto_field \
9601 u16 src_port, dst_port;
9604 #if VPP_API_TEST_BUILTIN == 0
9606 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9608 u8 **maskp = va_arg (*args, u8 **);
9610 u8 found_something = 0;
9613 #define _(a) u8 a=0;
9614 foreach_tcp_proto_field;
9617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9620 #define _(a) else if (unformat (input, #a)) a=1;
9621 foreach_tcp_proto_field
9627 #define _(a) found_something += a;
9628 foreach_tcp_proto_field;
9631 if (found_something == 0)
9634 vec_validate (mask, sizeof (*tcp) - 1);
9636 tcp = (tcp_header_t *) mask;
9638 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9639 foreach_tcp_proto_field;
9647 unformat_udp_mask (unformat_input_t * input, va_list * args)
9649 u8 **maskp = va_arg (*args, u8 **);
9651 u8 found_something = 0;
9654 #define _(a) u8 a=0;
9655 foreach_udp_proto_field;
9658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9661 #define _(a) else if (unformat (input, #a)) a=1;
9662 foreach_udp_proto_field
9668 #define _(a) found_something += a;
9669 foreach_udp_proto_field;
9672 if (found_something == 0)
9675 vec_validate (mask, sizeof (*udp) - 1);
9677 udp = (udp_header_t *) mask;
9679 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9680 foreach_udp_proto_field;
9688 unformat_l4_mask (unformat_input_t * input, va_list * args)
9690 u8 **maskp = va_arg (*args, u8 **);
9691 u16 src_port = 0, dst_port = 0;
9692 tcpudp_header_t *tcpudp;
9694 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9696 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9698 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9700 else if (unformat (input, "src_port"))
9702 else if (unformat (input, "dst_port"))
9708 if (!src_port && !dst_port)
9712 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9714 tcpudp = (tcpudp_header_t *) mask;
9715 tcpudp->src_port = src_port;
9716 tcpudp->dst_port = dst_port;
9724 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9726 u8 **maskp = va_arg (*args, u8 **);
9728 u8 found_something = 0;
9731 #define _(a) u8 a=0;
9732 foreach_ip4_proto_field;
9738 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9740 if (unformat (input, "version"))
9742 else if (unformat (input, "hdr_length"))
9744 else if (unformat (input, "src"))
9746 else if (unformat (input, "dst"))
9748 else if (unformat (input, "proto"))
9751 #define _(a) else if (unformat (input, #a)) a=1;
9752 foreach_ip4_proto_field
9758 #define _(a) found_something += a;
9759 foreach_ip4_proto_field;
9762 if (found_something == 0)
9765 vec_validate (mask, sizeof (*ip) - 1);
9767 ip = (ip4_header_t *) mask;
9769 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9770 foreach_ip4_proto_field;
9773 ip->ip_version_and_header_length = 0;
9776 ip->ip_version_and_header_length |= 0xF0;
9779 ip->ip_version_and_header_length |= 0x0F;
9785 #define foreach_ip6_proto_field \
9793 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9795 u8 **maskp = va_arg (*args, u8 **);
9797 u8 found_something = 0;
9799 u32 ip_version_traffic_class_and_flow_label;
9801 #define _(a) u8 a=0;
9802 foreach_ip6_proto_field;
9805 u8 traffic_class = 0;
9808 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9810 if (unformat (input, "version"))
9812 else if (unformat (input, "traffic-class"))
9814 else if (unformat (input, "flow-label"))
9816 else if (unformat (input, "src"))
9818 else if (unformat (input, "dst"))
9820 else if (unformat (input, "proto"))
9823 #define _(a) else if (unformat (input, #a)) a=1;
9824 foreach_ip6_proto_field
9830 #define _(a) found_something += a;
9831 foreach_ip6_proto_field;
9834 if (found_something == 0)
9837 vec_validate (mask, sizeof (*ip) - 1);
9839 ip = (ip6_header_t *) mask;
9841 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9842 foreach_ip6_proto_field;
9845 ip_version_traffic_class_and_flow_label = 0;
9848 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9851 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9854 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9856 ip->ip_version_traffic_class_and_flow_label =
9857 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9864 unformat_l3_mask (unformat_input_t * input, va_list * args)
9866 u8 **maskp = va_arg (*args, u8 **);
9868 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9870 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9872 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9881 unformat_l2_mask (unformat_input_t * input, va_list * args)
9883 u8 **maskp = va_arg (*args, u8 **);
9898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9900 if (unformat (input, "src"))
9902 else if (unformat (input, "dst"))
9904 else if (unformat (input, "proto"))
9906 else if (unformat (input, "tag1"))
9908 else if (unformat (input, "tag2"))
9910 else if (unformat (input, "ignore-tag1"))
9912 else if (unformat (input, "ignore-tag2"))
9914 else if (unformat (input, "cos1"))
9916 else if (unformat (input, "cos2"))
9918 else if (unformat (input, "dot1q"))
9920 else if (unformat (input, "dot1ad"))
9925 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9926 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9929 if (tag1 || ignore_tag1 || cos1 || dot1q)
9931 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9934 vec_validate (mask, len - 1);
9937 clib_memset (mask, 0xff, 6);
9940 clib_memset (mask + 6, 0xff, 6);
9944 /* inner vlan tag */
9953 mask[21] = mask[20] = 0xff;
9974 mask[16] = mask[17] = 0xff;
9984 mask[12] = mask[13] = 0xff;
9991 unformat_classify_mask (unformat_input_t * input, va_list * args)
9993 u8 **maskp = va_arg (*args, u8 **);
9994 u32 *skipp = va_arg (*args, u32 *);
9995 u32 *matchp = va_arg (*args, u32 *);
10003 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10005 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10007 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10009 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10011 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10025 if (mask || l2 || l3 || l4)
10027 if (l2 || l3 || l4)
10029 /* "With a free Ethernet header in every package" */
10031 vec_validate (l2, 13);
10035 vec_append (mask, l3);
10040 vec_append (mask, l4);
10045 /* Scan forward looking for the first significant mask octet */
10046 for (i = 0; i < vec_len (mask); i++)
10050 /* compute (skip, match) params */
10051 *skipp = i / sizeof (u32x4);
10052 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10054 /* Pad mask to an even multiple of the vector size */
10055 while (vec_len (mask) % sizeof (u32x4))
10056 vec_add1 (mask, 0);
10058 match = vec_len (mask) / sizeof (u32x4);
10060 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10062 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10063 if (*tmp || *(tmp + 1))
10068 clib_warning ("BUG: match 0");
10070 _vec_len (mask) = match * sizeof (u32x4);
10080 #endif /* VPP_API_TEST_BUILTIN */
10082 #define foreach_l2_next \
10084 _(ethernet, ETHERNET_INPUT) \
10085 _(ip4, IP4_INPUT) \
10089 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10091 u32 *miss_next_indexp = va_arg (*args, u32 *);
10092 u32 next_index = 0;
10096 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10100 if (unformat (input, "%d", &tmp))
10109 *miss_next_indexp = next_index;
10113 #define foreach_ip_next \
10116 _(rewrite, REWRITE)
10119 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10121 u32 *miss_next_indexp = va_arg (*args, u32 *);
10122 u32 next_index = 0;
10126 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10130 if (unformat (input, "%d", &tmp))
10139 *miss_next_indexp = next_index;
10143 #define foreach_acl_next \
10147 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10149 u32 *miss_next_indexp = va_arg (*args, u32 *);
10150 u32 next_index = 0;
10154 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10158 if (unformat (input, "permit"))
10163 else if (unformat (input, "%d", &tmp))
10172 *miss_next_indexp = next_index;
10177 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10179 u32 *r = va_arg (*args, u32 *);
10181 if (unformat (input, "conform-color"))
10182 *r = POLICE_CONFORM;
10183 else if (unformat (input, "exceed-color"))
10184 *r = POLICE_EXCEED;
10192 api_classify_add_del_table (vat_main_t * vam)
10194 unformat_input_t *i = vam->input;
10195 vl_api_classify_add_del_table_t *mp;
10202 u32 table_index = ~0;
10203 u32 next_table_index = ~0;
10204 u32 miss_next_index = ~0;
10205 u32 memory_size = 32 << 20;
10207 u32 current_data_flag = 0;
10208 int current_data_offset = 0;
10211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10213 if (unformat (i, "del"))
10215 else if (unformat (i, "del-chain"))
10220 else if (unformat (i, "buckets %d", &nbuckets))
10222 else if (unformat (i, "memory_size %d", &memory_size))
10224 else if (unformat (i, "skip %d", &skip))
10226 else if (unformat (i, "match %d", &match))
10228 else if (unformat (i, "table %d", &table_index))
10230 else if (unformat (i, "mask %U", unformat_classify_mask,
10231 &mask, &skip, &match))
10233 else if (unformat (i, "next-table %d", &next_table_index))
10235 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10238 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10241 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10244 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10246 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10252 if (is_add && mask == 0)
10254 errmsg ("Mask required");
10258 if (is_add && skip == ~0)
10260 errmsg ("skip count required");
10264 if (is_add && match == ~0)
10266 errmsg ("match count required");
10270 if (!is_add && table_index == ~0)
10272 errmsg ("table index required for delete");
10276 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10278 mp->is_add = is_add;
10279 mp->del_chain = del_chain;
10280 mp->table_index = ntohl (table_index);
10281 mp->nbuckets = ntohl (nbuckets);
10282 mp->memory_size = ntohl (memory_size);
10283 mp->skip_n_vectors = ntohl (skip);
10284 mp->match_n_vectors = ntohl (match);
10285 mp->next_table_index = ntohl (next_table_index);
10286 mp->miss_next_index = ntohl (miss_next_index);
10287 mp->current_data_flag = ntohl (current_data_flag);
10288 mp->current_data_offset = ntohl (current_data_offset);
10289 mp->mask_len = ntohl (vec_len (mask));
10290 clib_memcpy (mp->mask, mask, vec_len (mask));
10299 #if VPP_API_TEST_BUILTIN == 0
10301 unformat_l4_match (unformat_input_t * input, va_list * args)
10303 u8 **matchp = va_arg (*args, u8 **);
10305 u8 *proto_header = 0;
10311 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10313 if (unformat (input, "src_port %d", &src_port))
10315 else if (unformat (input, "dst_port %d", &dst_port))
10321 h.src_port = clib_host_to_net_u16 (src_port);
10322 h.dst_port = clib_host_to_net_u16 (dst_port);
10323 vec_validate (proto_header, sizeof (h) - 1);
10324 memcpy (proto_header, &h, sizeof (h));
10326 *matchp = proto_header;
10332 unformat_ip4_match (unformat_input_t * input, va_list * args)
10334 u8 **matchp = va_arg (*args, u8 **);
10339 int hdr_length = 0;
10340 u32 hdr_length_val;
10341 int src = 0, dst = 0;
10342 ip4_address_t src_val, dst_val;
10349 int fragment_id = 0;
10350 u32 fragment_id_val;
10356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10358 if (unformat (input, "version %d", &version_val))
10360 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10362 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10364 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10366 else if (unformat (input, "proto %d", &proto_val))
10368 else if (unformat (input, "tos %d", &tos_val))
10370 else if (unformat (input, "length %d", &length_val))
10372 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10374 else if (unformat (input, "ttl %d", &ttl_val))
10376 else if (unformat (input, "checksum %d", &checksum_val))
10382 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10383 + ttl + checksum == 0)
10387 * Aligned because we use the real comparison functions
10389 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10391 ip = (ip4_header_t *) match;
10393 /* These are realistically matched in practice */
10395 ip->src_address.as_u32 = src_val.as_u32;
10398 ip->dst_address.as_u32 = dst_val.as_u32;
10401 ip->protocol = proto_val;
10404 /* These are not, but they're included for completeness */
10406 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10409 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10415 ip->length = clib_host_to_net_u16 (length_val);
10421 ip->checksum = clib_host_to_net_u16 (checksum_val);
10428 unformat_ip6_match (unformat_input_t * input, va_list * args)
10430 u8 **matchp = va_arg (*args, u8 **);
10435 u8 traffic_class = 0;
10436 u32 traffic_class_val = 0;
10439 int src = 0, dst = 0;
10440 ip6_address_t src_val, dst_val;
10443 int payload_length = 0;
10444 u32 payload_length_val;
10447 u32 ip_version_traffic_class_and_flow_label;
10449 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10451 if (unformat (input, "version %d", &version_val))
10453 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10455 else if (unformat (input, "flow_label %d", &flow_label_val))
10457 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10459 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10461 else if (unformat (input, "proto %d", &proto_val))
10463 else if (unformat (input, "payload_length %d", &payload_length_val))
10464 payload_length = 1;
10465 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10471 if (version + traffic_class + flow_label + src + dst + proto +
10472 payload_length + hop_limit == 0)
10476 * Aligned because we use the real comparison functions
10478 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10480 ip = (ip6_header_t *) match;
10483 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10486 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10489 ip->protocol = proto_val;
10491 ip_version_traffic_class_and_flow_label = 0;
10494 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10497 ip_version_traffic_class_and_flow_label |=
10498 (traffic_class_val & 0xFF) << 20;
10501 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10503 ip->ip_version_traffic_class_and_flow_label =
10504 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10506 if (payload_length)
10507 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10510 ip->hop_limit = hop_limit_val;
10517 unformat_l3_match (unformat_input_t * input, va_list * args)
10519 u8 **matchp = va_arg (*args, u8 **);
10521 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10523 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10525 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10534 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10536 u8 *tagp = va_arg (*args, u8 *);
10539 if (unformat (input, "%d", &tag))
10541 tagp[0] = (tag >> 8) & 0x0F;
10542 tagp[1] = tag & 0xFF;
10550 unformat_l2_match (unformat_input_t * input, va_list * args)
10552 u8 **matchp = va_arg (*args, u8 **);
10565 u8 ignore_tag1 = 0;
10566 u8 ignore_tag2 = 0;
10572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10574 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10577 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10579 else if (unformat (input, "proto %U",
10580 unformat_ethernet_type_host_byte_order, &proto_val))
10582 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10584 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10586 else if (unformat (input, "ignore-tag1"))
10588 else if (unformat (input, "ignore-tag2"))
10590 else if (unformat (input, "cos1 %d", &cos1_val))
10592 else if (unformat (input, "cos2 %d", &cos2_val))
10597 if ((src + dst + proto + tag1 + tag2 +
10598 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10601 if (tag1 || ignore_tag1 || cos1)
10603 if (tag2 || ignore_tag2 || cos2)
10606 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10609 clib_memcpy (match, dst_val, 6);
10612 clib_memcpy (match + 6, src_val, 6);
10616 /* inner vlan tag */
10617 match[19] = tag2_val[1];
10618 match[18] = tag2_val[0];
10620 match[18] |= (cos2_val & 0x7) << 5;
10623 match[21] = proto_val & 0xff;
10624 match[20] = proto_val >> 8;
10628 match[15] = tag1_val[1];
10629 match[14] = tag1_val[0];
10632 match[14] |= (cos1_val & 0x7) << 5;
10638 match[15] = tag1_val[1];
10639 match[14] = tag1_val[0];
10642 match[17] = proto_val & 0xff;
10643 match[16] = proto_val >> 8;
10646 match[14] |= (cos1_val & 0x7) << 5;
10652 match[18] |= (cos2_val & 0x7) << 5;
10654 match[14] |= (cos1_val & 0x7) << 5;
10657 match[13] = proto_val & 0xff;
10658 match[12] = proto_val >> 8;
10666 unformat_qos_source (unformat_input_t * input, va_list * args)
10668 int *qs = va_arg (*args, int *);
10670 if (unformat (input, "ip"))
10671 *qs = QOS_SOURCE_IP;
10672 else if (unformat (input, "mpls"))
10673 *qs = QOS_SOURCE_MPLS;
10674 else if (unformat (input, "ext"))
10675 *qs = QOS_SOURCE_EXT;
10676 else if (unformat (input, "vlan"))
10677 *qs = QOS_SOURCE_VLAN;
10686 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10688 u8 **matchp = va_arg (*args, u8 **);
10689 u32 skip_n_vectors = va_arg (*args, u32);
10690 u32 match_n_vectors = va_arg (*args, u32);
10697 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10699 if (unformat (input, "hex %U", unformat_hex_string, &match))
10701 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10703 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10705 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10719 if (match || l2 || l3 || l4)
10721 if (l2 || l3 || l4)
10723 /* "Win a free Ethernet header in every packet" */
10725 vec_validate_aligned (l2, 13, sizeof (u32x4));
10729 vec_append_aligned (match, l3, sizeof (u32x4));
10734 vec_append_aligned (match, l4, sizeof (u32x4));
10739 /* Make sure the vector is big enough even if key is all 0's */
10740 vec_validate_aligned
10741 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10744 /* Set size, include skipped vectors */
10745 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10756 api_classify_add_del_session (vat_main_t * vam)
10758 unformat_input_t *i = vam->input;
10759 vl_api_classify_add_del_session_t *mp;
10761 u32 table_index = ~0;
10762 u32 hit_next_index = ~0;
10763 u32 opaque_index = ~0;
10766 u32 skip_n_vectors = 0;
10767 u32 match_n_vectors = 0;
10773 * Warning: you have to supply skip_n and match_n
10774 * because the API client cant simply look at the classify
10778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10780 if (unformat (i, "del"))
10782 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10785 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10788 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10791 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10793 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10795 else if (unformat (i, "opaque-index %d", &opaque_index))
10797 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10799 else if (unformat (i, "match_n %d", &match_n_vectors))
10801 else if (unformat (i, "match %U", api_unformat_classify_match,
10802 &match, skip_n_vectors, match_n_vectors))
10804 else if (unformat (i, "advance %d", &advance))
10806 else if (unformat (i, "table-index %d", &table_index))
10808 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10810 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10812 else if (unformat (i, "action %d", &action))
10814 else if (unformat (i, "metadata %d", &metadata))
10820 if (table_index == ~0)
10822 errmsg ("Table index required");
10826 if (is_add && match == 0)
10828 errmsg ("Match value required");
10832 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10834 mp->is_add = is_add;
10835 mp->table_index = ntohl (table_index);
10836 mp->hit_next_index = ntohl (hit_next_index);
10837 mp->opaque_index = ntohl (opaque_index);
10838 mp->advance = ntohl (advance);
10839 mp->action = action;
10840 mp->metadata = ntohl (metadata);
10841 mp->match_len = ntohl (vec_len (match));
10842 clib_memcpy (mp->match, match, vec_len (match));
10851 api_classify_set_interface_ip_table (vat_main_t * vam)
10853 unformat_input_t *i = vam->input;
10854 vl_api_classify_set_interface_ip_table_t *mp;
10856 int sw_if_index_set;
10857 u32 table_index = ~0;
10861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10864 sw_if_index_set = 1;
10865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10866 sw_if_index_set = 1;
10867 else if (unformat (i, "table %d", &table_index))
10871 clib_warning ("parse error '%U'", format_unformat_error, i);
10876 if (sw_if_index_set == 0)
10878 errmsg ("missing interface name or sw_if_index");
10883 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10885 mp->sw_if_index = ntohl (sw_if_index);
10886 mp->table_index = ntohl (table_index);
10887 mp->is_ipv6 = is_ipv6;
10895 api_classify_set_interface_l2_tables (vat_main_t * vam)
10897 unformat_input_t *i = vam->input;
10898 vl_api_classify_set_interface_l2_tables_t *mp;
10900 int sw_if_index_set;
10901 u32 ip4_table_index = ~0;
10902 u32 ip6_table_index = ~0;
10903 u32 other_table_index = ~0;
10907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10909 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10910 sw_if_index_set = 1;
10911 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10912 sw_if_index_set = 1;
10913 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10915 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10917 else if (unformat (i, "other-table %d", &other_table_index))
10919 else if (unformat (i, "is-input %d", &is_input))
10923 clib_warning ("parse error '%U'", format_unformat_error, i);
10928 if (sw_if_index_set == 0)
10930 errmsg ("missing interface name or sw_if_index");
10935 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10937 mp->sw_if_index = ntohl (sw_if_index);
10938 mp->ip4_table_index = ntohl (ip4_table_index);
10939 mp->ip6_table_index = ntohl (ip6_table_index);
10940 mp->other_table_index = ntohl (other_table_index);
10941 mp->is_input = (u8) is_input;
10949 api_set_ipfix_exporter (vat_main_t * vam)
10951 unformat_input_t *i = vam->input;
10952 vl_api_set_ipfix_exporter_t *mp;
10953 ip4_address_t collector_address;
10954 u8 collector_address_set = 0;
10955 u32 collector_port = ~0;
10956 ip4_address_t src_address;
10957 u8 src_address_set = 0;
10960 u32 template_interval = ~0;
10961 u8 udp_checksum = 0;
10964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10966 if (unformat (i, "collector_address %U", unformat_ip4_address,
10967 &collector_address))
10968 collector_address_set = 1;
10969 else if (unformat (i, "collector_port %d", &collector_port))
10971 else if (unformat (i, "src_address %U", unformat_ip4_address,
10973 src_address_set = 1;
10974 else if (unformat (i, "vrf_id %d", &vrf_id))
10976 else if (unformat (i, "path_mtu %d", &path_mtu))
10978 else if (unformat (i, "template_interval %d", &template_interval))
10980 else if (unformat (i, "udp_checksum"))
10986 if (collector_address_set == 0)
10988 errmsg ("collector_address required");
10992 if (src_address_set == 0)
10994 errmsg ("src_address required");
10998 M (SET_IPFIX_EXPORTER, mp);
11000 memcpy (mp->collector_address.un.ip4, collector_address.data,
11001 sizeof (collector_address.data));
11002 mp->collector_port = htons ((u16) collector_port);
11003 memcpy (mp->src_address.un.ip4, src_address.data,
11004 sizeof (src_address.data));
11005 mp->vrf_id = htonl (vrf_id);
11006 mp->path_mtu = htonl (path_mtu);
11007 mp->template_interval = htonl (template_interval);
11008 mp->udp_checksum = udp_checksum;
11016 api_set_ipfix_classify_stream (vat_main_t * vam)
11018 unformat_input_t *i = vam->input;
11019 vl_api_set_ipfix_classify_stream_t *mp;
11021 u32 src_port = UDP_DST_PORT_ipfix;
11024 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11026 if (unformat (i, "domain %d", &domain_id))
11028 else if (unformat (i, "src_port %d", &src_port))
11032 errmsg ("unknown input `%U'", format_unformat_error, i);
11037 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11039 mp->domain_id = htonl (domain_id);
11040 mp->src_port = htons ((u16) src_port);
11048 api_ipfix_classify_table_add_del (vat_main_t * vam)
11050 unformat_input_t *i = vam->input;
11051 vl_api_ipfix_classify_table_add_del_t *mp;
11053 u32 classify_table_index = ~0;
11055 u8 transport_protocol = 255;
11058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11060 if (unformat (i, "add"))
11062 else if (unformat (i, "del"))
11064 else if (unformat (i, "table %d", &classify_table_index))
11066 else if (unformat (i, "ip4"))
11068 else if (unformat (i, "ip6"))
11070 else if (unformat (i, "tcp"))
11071 transport_protocol = 6;
11072 else if (unformat (i, "udp"))
11073 transport_protocol = 17;
11076 errmsg ("unknown input `%U'", format_unformat_error, i);
11083 errmsg ("expecting: add|del");
11086 if (classify_table_index == ~0)
11088 errmsg ("classifier table not specified");
11091 if (ip_version == 0)
11093 errmsg ("IP version not specified");
11097 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11099 mp->is_add = is_add;
11100 mp->table_id = htonl (classify_table_index);
11101 mp->ip_version = ip_version;
11102 mp->transport_protocol = transport_protocol;
11110 api_get_node_index (vat_main_t * vam)
11112 unformat_input_t *i = vam->input;
11113 vl_api_get_node_index_t *mp;
11117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11119 if (unformat (i, "node %s", &name))
11126 errmsg ("node name required");
11129 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11131 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11135 M (GET_NODE_INDEX, mp);
11136 clib_memcpy (mp->node_name, name, vec_len (name));
11145 api_get_next_index (vat_main_t * vam)
11147 unformat_input_t *i = vam->input;
11148 vl_api_get_next_index_t *mp;
11149 u8 *node_name = 0, *next_node_name = 0;
11152 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11154 if (unformat (i, "node-name %s", &node_name))
11156 else if (unformat (i, "next-node-name %s", &next_node_name))
11160 if (node_name == 0)
11162 errmsg ("node name required");
11165 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11167 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11171 if (next_node_name == 0)
11173 errmsg ("next node name required");
11176 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11178 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11182 M (GET_NEXT_INDEX, mp);
11183 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11184 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11185 vec_free (node_name);
11186 vec_free (next_node_name);
11194 api_add_node_next (vat_main_t * vam)
11196 unformat_input_t *i = vam->input;
11197 vl_api_add_node_next_t *mp;
11202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11204 if (unformat (i, "node %s", &name))
11206 else if (unformat (i, "next %s", &next))
11213 errmsg ("node name required");
11216 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11218 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11223 errmsg ("next node required");
11226 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11228 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11232 M (ADD_NODE_NEXT, mp);
11233 clib_memcpy (mp->node_name, name, vec_len (name));
11234 clib_memcpy (mp->next_name, next, vec_len (next));
11244 api_l2tpv3_create_tunnel (vat_main_t * vam)
11246 unformat_input_t *i = vam->input;
11247 ip6_address_t client_address, our_address;
11248 int client_address_set = 0;
11249 int our_address_set = 0;
11250 u32 local_session_id = 0;
11251 u32 remote_session_id = 0;
11252 u64 local_cookie = 0;
11253 u64 remote_cookie = 0;
11254 u8 l2_sublayer_present = 0;
11255 vl_api_l2tpv3_create_tunnel_t *mp;
11258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11260 if (unformat (i, "client_address %U", unformat_ip6_address,
11262 client_address_set = 1;
11263 else if (unformat (i, "our_address %U", unformat_ip6_address,
11265 our_address_set = 1;
11266 else if (unformat (i, "local_session_id %d", &local_session_id))
11268 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11270 else if (unformat (i, "local_cookie %lld", &local_cookie))
11272 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11274 else if (unformat (i, "l2-sublayer-present"))
11275 l2_sublayer_present = 1;
11280 if (client_address_set == 0)
11282 errmsg ("client_address required");
11286 if (our_address_set == 0)
11288 errmsg ("our_address required");
11292 M (L2TPV3_CREATE_TUNNEL, mp);
11294 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11295 sizeof (ip6_address_t));
11297 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11298 sizeof (ip6_address_t));
11300 mp->local_session_id = ntohl (local_session_id);
11301 mp->remote_session_id = ntohl (remote_session_id);
11302 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11303 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11304 mp->l2_sublayer_present = l2_sublayer_present;
11312 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11314 unformat_input_t *i = vam->input;
11316 u8 sw_if_index_set = 0;
11317 u64 new_local_cookie = 0;
11318 u64 new_remote_cookie = 0;
11319 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11325 sw_if_index_set = 1;
11326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11327 sw_if_index_set = 1;
11328 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11330 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11336 if (sw_if_index_set == 0)
11338 errmsg ("missing interface name or sw_if_index");
11342 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11344 mp->sw_if_index = ntohl (sw_if_index);
11345 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11346 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11354 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11356 unformat_input_t *i = vam->input;
11357 vl_api_l2tpv3_interface_enable_disable_t *mp;
11359 u8 sw_if_index_set = 0;
11360 u8 enable_disable = 1;
11363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11365 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11366 sw_if_index_set = 1;
11367 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11368 sw_if_index_set = 1;
11369 else if (unformat (i, "enable"))
11370 enable_disable = 1;
11371 else if (unformat (i, "disable"))
11372 enable_disable = 0;
11377 if (sw_if_index_set == 0)
11379 errmsg ("missing interface name or sw_if_index");
11383 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11385 mp->sw_if_index = ntohl (sw_if_index);
11386 mp->enable_disable = enable_disable;
11394 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11396 unformat_input_t *i = vam->input;
11397 vl_api_l2tpv3_set_lookup_key_t *mp;
11401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11403 if (unformat (i, "lookup_v6_src"))
11404 key = L2T_LOOKUP_SRC_ADDRESS;
11405 else if (unformat (i, "lookup_v6_dst"))
11406 key = L2T_LOOKUP_DST_ADDRESS;
11407 else if (unformat (i, "lookup_session_id"))
11408 key = L2T_LOOKUP_SESSION_ID;
11413 if (key == (u8) ~ 0)
11415 errmsg ("l2tp session lookup key unset");
11419 M (L2TPV3_SET_LOOKUP_KEY, mp);
11428 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11429 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11431 vat_main_t *vam = &vat_main;
11433 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11434 format_ip6_address, mp->our_address,
11435 format_ip6_address, mp->client_address,
11436 clib_net_to_host_u32 (mp->sw_if_index));
11439 " local cookies %016llx %016llx remote cookie %016llx",
11440 clib_net_to_host_u64 (mp->local_cookie[0]),
11441 clib_net_to_host_u64 (mp->local_cookie[1]),
11442 clib_net_to_host_u64 (mp->remote_cookie));
11444 print (vam->ofp, " local session-id %d remote session-id %d",
11445 clib_net_to_host_u32 (mp->local_session_id),
11446 clib_net_to_host_u32 (mp->remote_session_id));
11448 print (vam->ofp, " l2 specific sublayer %s\n",
11449 mp->l2_sublayer_present ? "preset" : "absent");
11453 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11454 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11456 vat_main_t *vam = &vat_main;
11457 vat_json_node_t *node = NULL;
11458 struct in6_addr addr;
11460 if (VAT_JSON_ARRAY != vam->json_tree.type)
11462 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11463 vat_json_init_array (&vam->json_tree);
11465 node = vat_json_array_add (&vam->json_tree);
11467 vat_json_init_object (node);
11469 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11470 vat_json_object_add_ip6 (node, "our_address", addr);
11471 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11472 vat_json_object_add_ip6 (node, "client_address", addr);
11474 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11475 vat_json_init_array (lc);
11476 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11477 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11478 vat_json_object_add_uint (node, "remote_cookie",
11479 clib_net_to_host_u64 (mp->remote_cookie));
11481 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11482 vat_json_object_add_uint (node, "local_session_id",
11483 clib_net_to_host_u32 (mp->local_session_id));
11484 vat_json_object_add_uint (node, "remote_session_id",
11485 clib_net_to_host_u32 (mp->remote_session_id));
11486 vat_json_object_add_string_copy (node, "l2_sublayer",
11487 mp->l2_sublayer_present ? (u8 *) "present"
11488 : (u8 *) "absent");
11492 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11494 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11495 vl_api_control_ping_t *mp_ping;
11498 /* Get list of l2tpv3-tunnel interfaces */
11499 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11502 /* Use a control ping for synchronization */
11503 MPING (CONTROL_PING, mp_ping);
11511 static void vl_api_sw_interface_tap_v2_details_t_handler
11512 (vl_api_sw_interface_tap_v2_details_t * mp)
11514 vat_main_t *vam = &vat_main;
11517 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11518 mp->host_ip4_prefix.len);
11520 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11521 mp->host_ip6_prefix.len);
11524 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11525 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11526 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11527 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11528 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11534 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11535 (vl_api_sw_interface_tap_v2_details_t * mp)
11537 vat_main_t *vam = &vat_main;
11538 vat_json_node_t *node = NULL;
11540 if (VAT_JSON_ARRAY != vam->json_tree.type)
11542 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11543 vat_json_init_array (&vam->json_tree);
11545 node = vat_json_array_add (&vam->json_tree);
11547 vat_json_init_object (node);
11548 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11549 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11550 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11551 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11552 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11553 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11554 vat_json_object_add_string_copy (node, "host_mac_addr",
11555 format (0, "%U", format_ethernet_address,
11556 &mp->host_mac_addr));
11557 vat_json_object_add_string_copy (node, "host_namespace",
11558 mp->host_namespace);
11559 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11560 vat_json_object_add_string_copy (node, "host_ip4_addr",
11561 format (0, "%U/%d", format_ip4_address,
11562 mp->host_ip4_prefix.address,
11563 mp->host_ip4_prefix.len));
11564 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11565 format (0, "%U/%d", format_ip6_address,
11566 mp->host_ip6_prefix.address,
11567 mp->host_ip6_prefix.len));
11572 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11574 vl_api_sw_interface_tap_v2_dump_t *mp;
11575 vl_api_control_ping_t *mp_ping;
11579 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11580 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11581 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11584 /* Get list of tap interfaces */
11585 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11588 /* Use a control ping for synchronization */
11589 MPING (CONTROL_PING, mp_ping);
11596 static void vl_api_sw_interface_virtio_pci_details_t_handler
11597 (vl_api_sw_interface_virtio_pci_details_t * mp)
11599 vat_main_t *vam = &vat_main;
11614 addr.domain = ntohs (mp->pci_addr.domain);
11615 addr.bus = mp->pci_addr.bus;
11616 addr.slot = mp->pci_addr.slot;
11617 addr.function = mp->pci_addr.function;
11619 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11620 addr.slot, addr.function);
11623 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11624 pci_addr, ntohl (mp->sw_if_index),
11625 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11626 format_ethernet_address, mp->mac_addr,
11627 clib_net_to_host_u64 (mp->features));
11628 vec_free (pci_addr);
11631 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11632 (vl_api_sw_interface_virtio_pci_details_t * mp)
11634 vat_main_t *vam = &vat_main;
11635 vat_json_node_t *node = NULL;
11636 vlib_pci_addr_t pci_addr;
11638 if (VAT_JSON_ARRAY != vam->json_tree.type)
11640 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11641 vat_json_init_array (&vam->json_tree);
11643 node = vat_json_array_add (&vam->json_tree);
11645 pci_addr.domain = ntohs (mp->pci_addr.domain);
11646 pci_addr.bus = mp->pci_addr.bus;
11647 pci_addr.slot = mp->pci_addr.slot;
11648 pci_addr.function = mp->pci_addr.function;
11650 vat_json_init_object (node);
11651 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11652 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11653 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11654 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11655 vat_json_object_add_uint (node, "features",
11656 clib_net_to_host_u64 (mp->features));
11657 vat_json_object_add_string_copy (node, "mac_addr",
11658 format (0, "%U", format_ethernet_address,
11663 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11665 vl_api_sw_interface_virtio_pci_dump_t *mp;
11666 vl_api_control_ping_t *mp_ping;
11670 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11671 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11672 "mac_addr", "features");
11674 /* Get list of tap interfaces */
11675 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11678 /* Use a control ping for synchronization */
11679 MPING (CONTROL_PING, mp_ping);
11687 api_vxlan_offload_rx (vat_main_t * vam)
11689 unformat_input_t *line_input = vam->input;
11690 vl_api_vxlan_offload_rx_t *mp;
11691 u32 hw_if_index = ~0, rx_if_index = ~0;
11695 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11697 if (unformat (line_input, "del"))
11699 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11702 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11704 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11707 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11711 errmsg ("parse error '%U'", format_unformat_error, line_input);
11716 if (hw_if_index == ~0)
11718 errmsg ("no hw interface");
11722 if (rx_if_index == ~0)
11724 errmsg ("no rx tunnel");
11728 M (VXLAN_OFFLOAD_RX, mp);
11730 mp->hw_if_index = ntohl (hw_if_index);
11731 mp->sw_if_index = ntohl (rx_if_index);
11732 mp->enable = is_add;
11739 static uword unformat_vxlan_decap_next
11740 (unformat_input_t * input, va_list * args)
11742 u32 *result = va_arg (*args, u32 *);
11745 if (unformat (input, "l2"))
11746 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11747 else if (unformat (input, "%d", &tmp))
11755 api_vxlan_add_del_tunnel (vat_main_t * vam)
11757 unformat_input_t *line_input = vam->input;
11758 vl_api_vxlan_add_del_tunnel_t *mp;
11759 ip46_address_t src, dst;
11761 u8 ipv4_set = 0, ipv6_set = 0;
11766 u32 mcast_sw_if_index = ~0;
11767 u32 encap_vrf_id = 0;
11768 u32 decap_next_index = ~0;
11772 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11773 clib_memset (&src, 0, sizeof src);
11774 clib_memset (&dst, 0, sizeof dst);
11776 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11778 if (unformat (line_input, "del"))
11780 else if (unformat (line_input, "instance %d", &instance))
11783 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11789 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11795 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11801 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11806 else if (unformat (line_input, "group %U %U",
11807 unformat_ip4_address, &dst.ip4,
11808 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11810 grp_set = dst_set = 1;
11813 else if (unformat (line_input, "group %U",
11814 unformat_ip4_address, &dst.ip4))
11816 grp_set = dst_set = 1;
11819 else if (unformat (line_input, "group %U %U",
11820 unformat_ip6_address, &dst.ip6,
11821 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11823 grp_set = dst_set = 1;
11826 else if (unformat (line_input, "group %U",
11827 unformat_ip6_address, &dst.ip6))
11829 grp_set = dst_set = 1;
11833 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11835 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11837 else if (unformat (line_input, "decap-next %U",
11838 unformat_vxlan_decap_next, &decap_next_index))
11840 else if (unformat (line_input, "vni %d", &vni))
11844 errmsg ("parse error '%U'", format_unformat_error, line_input);
11851 errmsg ("tunnel src address not specified");
11856 errmsg ("tunnel dst address not specified");
11860 if (grp_set && !ip46_address_is_multicast (&dst))
11862 errmsg ("tunnel group address not multicast");
11865 if (grp_set && mcast_sw_if_index == ~0)
11867 errmsg ("tunnel nonexistent multicast device");
11870 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11872 errmsg ("tunnel dst address must be unicast");
11877 if (ipv4_set && ipv6_set)
11879 errmsg ("both IPv4 and IPv6 addresses specified");
11883 if ((vni == 0) || (vni >> 24))
11885 errmsg ("vni not specified or out of range");
11889 M (VXLAN_ADD_DEL_TUNNEL, mp);
11893 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11894 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11898 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11899 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11901 mp->src_address.af = ipv6_set;
11902 mp->dst_address.af = ipv6_set;
11904 mp->instance = htonl (instance);
11905 mp->encap_vrf_id = ntohl (encap_vrf_id);
11906 mp->decap_next_index = ntohl (decap_next_index);
11907 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11908 mp->vni = ntohl (vni);
11909 mp->is_add = is_add;
11916 static void vl_api_vxlan_tunnel_details_t_handler
11917 (vl_api_vxlan_tunnel_details_t * mp)
11919 vat_main_t *vam = &vat_main;
11920 ip46_address_t src =
11921 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11922 ip46_address_t dst =
11923 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11925 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11926 ntohl (mp->sw_if_index),
11927 ntohl (mp->instance),
11928 format_ip46_address, &src, IP46_TYPE_ANY,
11929 format_ip46_address, &dst, IP46_TYPE_ANY,
11930 ntohl (mp->encap_vrf_id),
11931 ntohl (mp->decap_next_index), ntohl (mp->vni),
11932 ntohl (mp->mcast_sw_if_index));
11935 static void vl_api_vxlan_tunnel_details_t_handler_json
11936 (vl_api_vxlan_tunnel_details_t * mp)
11938 vat_main_t *vam = &vat_main;
11939 vat_json_node_t *node = NULL;
11941 if (VAT_JSON_ARRAY != vam->json_tree.type)
11943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11944 vat_json_init_array (&vam->json_tree);
11946 node = vat_json_array_add (&vam->json_tree);
11948 vat_json_init_object (node);
11949 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11951 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11953 if (mp->src_address.af)
11955 struct in6_addr ip6;
11957 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11958 vat_json_object_add_ip6 (node, "src_address", ip6);
11959 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11960 vat_json_object_add_ip6 (node, "dst_address", ip6);
11964 struct in_addr ip4;
11966 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11967 vat_json_object_add_ip4 (node, "src_address", ip4);
11968 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11969 vat_json_object_add_ip4 (node, "dst_address", ip4);
11971 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11972 vat_json_object_add_uint (node, "decap_next_index",
11973 ntohl (mp->decap_next_index));
11974 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11975 vat_json_object_add_uint (node, "mcast_sw_if_index",
11976 ntohl (mp->mcast_sw_if_index));
11980 api_vxlan_tunnel_dump (vat_main_t * vam)
11982 unformat_input_t *i = vam->input;
11983 vl_api_vxlan_tunnel_dump_t *mp;
11984 vl_api_control_ping_t *mp_ping;
11986 u8 sw_if_index_set = 0;
11989 /* Parse args required to build the message */
11990 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11992 if (unformat (i, "sw_if_index %d", &sw_if_index))
11993 sw_if_index_set = 1;
11998 if (sw_if_index_set == 0)
12003 if (!vam->json_output)
12005 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12006 "sw_if_index", "instance", "src_address", "dst_address",
12007 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12010 /* Get list of vxlan-tunnel interfaces */
12011 M (VXLAN_TUNNEL_DUMP, mp);
12013 mp->sw_if_index = htonl (sw_if_index);
12017 /* Use a control ping for synchronization */
12018 MPING (CONTROL_PING, mp_ping);
12025 static uword unformat_geneve_decap_next
12026 (unformat_input_t * input, va_list * args)
12028 u32 *result = va_arg (*args, u32 *);
12031 if (unformat (input, "l2"))
12032 *result = GENEVE_INPUT_NEXT_L2_INPUT;
12033 else if (unformat (input, "%d", &tmp))
12041 api_geneve_add_del_tunnel (vat_main_t * vam)
12043 unformat_input_t *line_input = vam->input;
12044 vl_api_geneve_add_del_tunnel_t *mp;
12045 ip46_address_t src, dst;
12047 u8 ipv4_set = 0, ipv6_set = 0;
12051 u32 mcast_sw_if_index = ~0;
12052 u32 encap_vrf_id = 0;
12053 u32 decap_next_index = ~0;
12057 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12058 clib_memset (&src, 0, sizeof src);
12059 clib_memset (&dst, 0, sizeof dst);
12061 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12063 if (unformat (line_input, "del"))
12066 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12072 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12078 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12084 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12089 else if (unformat (line_input, "group %U %U",
12090 unformat_ip4_address, &dst.ip4,
12091 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12093 grp_set = dst_set = 1;
12096 else if (unformat (line_input, "group %U",
12097 unformat_ip4_address, &dst.ip4))
12099 grp_set = dst_set = 1;
12102 else if (unformat (line_input, "group %U %U",
12103 unformat_ip6_address, &dst.ip6,
12104 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12106 grp_set = dst_set = 1;
12109 else if (unformat (line_input, "group %U",
12110 unformat_ip6_address, &dst.ip6))
12112 grp_set = dst_set = 1;
12116 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12118 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12120 else if (unformat (line_input, "decap-next %U",
12121 unformat_geneve_decap_next, &decap_next_index))
12123 else if (unformat (line_input, "vni %d", &vni))
12127 errmsg ("parse error '%U'", format_unformat_error, line_input);
12134 errmsg ("tunnel src address not specified");
12139 errmsg ("tunnel dst address not specified");
12143 if (grp_set && !ip46_address_is_multicast (&dst))
12145 errmsg ("tunnel group address not multicast");
12148 if (grp_set && mcast_sw_if_index == ~0)
12150 errmsg ("tunnel nonexistent multicast device");
12153 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12155 errmsg ("tunnel dst address must be unicast");
12160 if (ipv4_set && ipv6_set)
12162 errmsg ("both IPv4 and IPv6 addresses specified");
12166 if ((vni == 0) || (vni >> 24))
12168 errmsg ("vni not specified or out of range");
12172 M (GENEVE_ADD_DEL_TUNNEL, mp);
12176 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12177 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12181 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12182 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12184 mp->encap_vrf_id = ntohl (encap_vrf_id);
12185 mp->decap_next_index = ntohl (decap_next_index);
12186 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12187 mp->vni = ntohl (vni);
12188 mp->is_add = is_add;
12195 static void vl_api_geneve_tunnel_details_t_handler
12196 (vl_api_geneve_tunnel_details_t * mp)
12198 vat_main_t *vam = &vat_main;
12199 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12200 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12202 if (mp->src_address.af == ADDRESS_IP6)
12204 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12205 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12209 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12210 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12213 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12214 ntohl (mp->sw_if_index),
12215 format_ip46_address, &src, IP46_TYPE_ANY,
12216 format_ip46_address, &dst, IP46_TYPE_ANY,
12217 ntohl (mp->encap_vrf_id),
12218 ntohl (mp->decap_next_index), ntohl (mp->vni),
12219 ntohl (mp->mcast_sw_if_index));
12222 static void vl_api_geneve_tunnel_details_t_handler_json
12223 (vl_api_geneve_tunnel_details_t * mp)
12225 vat_main_t *vam = &vat_main;
12226 vat_json_node_t *node = NULL;
12229 if (VAT_JSON_ARRAY != vam->json_tree.type)
12231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12232 vat_json_init_array (&vam->json_tree);
12234 node = vat_json_array_add (&vam->json_tree);
12236 vat_json_init_object (node);
12237 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12238 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12241 struct in6_addr ip6;
12243 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12244 vat_json_object_add_ip6 (node, "src_address", ip6);
12245 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12246 vat_json_object_add_ip6 (node, "dst_address", ip6);
12250 struct in_addr ip4;
12252 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12253 vat_json_object_add_ip4 (node, "src_address", ip4);
12254 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12255 vat_json_object_add_ip4 (node, "dst_address", ip4);
12257 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12258 vat_json_object_add_uint (node, "decap_next_index",
12259 ntohl (mp->decap_next_index));
12260 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12261 vat_json_object_add_uint (node, "mcast_sw_if_index",
12262 ntohl (mp->mcast_sw_if_index));
12266 api_geneve_tunnel_dump (vat_main_t * vam)
12268 unformat_input_t *i = vam->input;
12269 vl_api_geneve_tunnel_dump_t *mp;
12270 vl_api_control_ping_t *mp_ping;
12272 u8 sw_if_index_set = 0;
12275 /* Parse args required to build the message */
12276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12278 if (unformat (i, "sw_if_index %d", &sw_if_index))
12279 sw_if_index_set = 1;
12284 if (sw_if_index_set == 0)
12289 if (!vam->json_output)
12291 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12292 "sw_if_index", "local_address", "remote_address",
12293 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12296 /* Get list of geneve-tunnel interfaces */
12297 M (GENEVE_TUNNEL_DUMP, mp);
12299 mp->sw_if_index = htonl (sw_if_index);
12303 /* Use a control ping for synchronization */
12304 M (CONTROL_PING, mp_ping);
12312 api_gre_tunnel_add_del (vat_main_t * vam)
12314 unformat_input_t *line_input = vam->input;
12315 vl_api_address_t src = { }, dst =
12318 vl_api_gre_tunnel_add_del_t *mp;
12319 vl_api_gre_tunnel_type_t t_type;
12323 u32 outer_table_id = 0;
12324 u32 session_id = 0;
12328 t_type = GRE_API_TUNNEL_TYPE_L3;
12330 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12332 if (unformat (line_input, "del"))
12334 else if (unformat (line_input, "instance %d", &instance))
12336 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12340 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12344 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12346 else if (unformat (line_input, "teb"))
12347 t_type = GRE_API_TUNNEL_TYPE_TEB;
12348 else if (unformat (line_input, "erspan %d", &session_id))
12349 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12352 errmsg ("parse error '%U'", format_unformat_error, line_input);
12359 errmsg ("tunnel src address not specified");
12364 errmsg ("tunnel dst address not specified");
12368 M (GRE_TUNNEL_ADD_DEL, mp);
12370 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12371 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12373 mp->tunnel.instance = htonl (instance);
12374 mp->tunnel.outer_table_id = htonl (outer_table_id);
12375 mp->is_add = is_add;
12376 mp->tunnel.session_id = htons ((u16) session_id);
12377 mp->tunnel.type = htonl (t_type);
12384 static void vl_api_gre_tunnel_details_t_handler
12385 (vl_api_gre_tunnel_details_t * mp)
12387 vat_main_t *vam = &vat_main;
12389 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12390 ntohl (mp->tunnel.sw_if_index),
12391 ntohl (mp->tunnel.instance),
12392 format_vl_api_address, &mp->tunnel.src,
12393 format_vl_api_address, &mp->tunnel.dst,
12394 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12395 ntohl (mp->tunnel.session_id));
12398 static void vl_api_gre_tunnel_details_t_handler_json
12399 (vl_api_gre_tunnel_details_t * mp)
12401 vat_main_t *vam = &vat_main;
12402 vat_json_node_t *node = NULL;
12404 if (VAT_JSON_ARRAY != vam->json_tree.type)
12406 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12407 vat_json_init_array (&vam->json_tree);
12409 node = vat_json_array_add (&vam->json_tree);
12411 vat_json_init_object (node);
12412 vat_json_object_add_uint (node, "sw_if_index",
12413 ntohl (mp->tunnel.sw_if_index));
12414 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12416 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12417 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12418 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12419 vat_json_object_add_uint (node, "outer_table_id",
12420 ntohl (mp->tunnel.outer_table_id));
12421 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12425 api_gre_tunnel_dump (vat_main_t * vam)
12427 unformat_input_t *i = vam->input;
12428 vl_api_gre_tunnel_dump_t *mp;
12429 vl_api_control_ping_t *mp_ping;
12431 u8 sw_if_index_set = 0;
12434 /* Parse args required to build the message */
12435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12437 if (unformat (i, "sw_if_index %d", &sw_if_index))
12438 sw_if_index_set = 1;
12443 if (sw_if_index_set == 0)
12448 if (!vam->json_output)
12450 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12451 "sw_if_index", "instance", "src_address", "dst_address",
12452 "tunnel_type", "outer_fib_id", "session_id");
12455 /* Get list of gre-tunnel interfaces */
12456 M (GRE_TUNNEL_DUMP, mp);
12458 mp->sw_if_index = htonl (sw_if_index);
12462 /* Use a control ping for synchronization */
12463 MPING (CONTROL_PING, mp_ping);
12471 api_l2_fib_clear_table (vat_main_t * vam)
12473 // unformat_input_t * i = vam->input;
12474 vl_api_l2_fib_clear_table_t *mp;
12477 M (L2_FIB_CLEAR_TABLE, mp);
12485 api_l2_interface_efp_filter (vat_main_t * vam)
12487 unformat_input_t *i = vam->input;
12488 vl_api_l2_interface_efp_filter_t *mp;
12491 u8 sw_if_index_set = 0;
12494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12496 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12497 sw_if_index_set = 1;
12498 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12499 sw_if_index_set = 1;
12500 else if (unformat (i, "enable"))
12502 else if (unformat (i, "disable"))
12506 clib_warning ("parse error '%U'", format_unformat_error, i);
12511 if (sw_if_index_set == 0)
12513 errmsg ("missing sw_if_index");
12517 M (L2_INTERFACE_EFP_FILTER, mp);
12519 mp->sw_if_index = ntohl (sw_if_index);
12520 mp->enable_disable = enable;
12527 #define foreach_vtr_op \
12528 _("disable", L2_VTR_DISABLED) \
12529 _("push-1", L2_VTR_PUSH_1) \
12530 _("push-2", L2_VTR_PUSH_2) \
12531 _("pop-1", L2_VTR_POP_1) \
12532 _("pop-2", L2_VTR_POP_2) \
12533 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12534 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12535 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12536 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12539 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12541 unformat_input_t *i = vam->input;
12542 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12544 u8 sw_if_index_set = 0;
12547 u32 push_dot1q = 1;
12552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12554 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12555 sw_if_index_set = 1;
12556 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12557 sw_if_index_set = 1;
12558 else if (unformat (i, "vtr_op %d", &vtr_op))
12560 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12563 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12565 else if (unformat (i, "tag1 %d", &tag1))
12567 else if (unformat (i, "tag2 %d", &tag2))
12571 clib_warning ("parse error '%U'", format_unformat_error, i);
12576 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12578 errmsg ("missing vtr operation or sw_if_index");
12582 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12583 mp->sw_if_index = ntohl (sw_if_index);
12584 mp->vtr_op = ntohl (vtr_op);
12585 mp->push_dot1q = ntohl (push_dot1q);
12586 mp->tag1 = ntohl (tag1);
12587 mp->tag2 = ntohl (tag2);
12595 api_create_vhost_user_if (vat_main_t * vam)
12597 unformat_input_t *i = vam->input;
12598 vl_api_create_vhost_user_if_t *mp;
12601 u8 file_name_set = 0;
12602 u32 custom_dev_instance = ~0;
12604 u8 use_custom_mac = 0;
12605 u8 disable_mrg_rxbuf = 0;
12606 u8 disable_indirect_desc = 0;
12609 u8 enable_packed = 0;
12612 /* Shut up coverity */
12613 clib_memset (hwaddr, 0, sizeof (hwaddr));
12615 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12617 if (unformat (i, "socket %s", &file_name))
12621 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12623 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12624 use_custom_mac = 1;
12625 else if (unformat (i, "server"))
12627 else if (unformat (i, "disable_mrg_rxbuf"))
12628 disable_mrg_rxbuf = 1;
12629 else if (unformat (i, "disable_indirect_desc"))
12630 disable_indirect_desc = 1;
12631 else if (unformat (i, "gso"))
12633 else if (unformat (i, "packed"))
12635 else if (unformat (i, "tag %s", &tag))
12641 if (file_name_set == 0)
12643 errmsg ("missing socket file name");
12647 if (vec_len (file_name) > 255)
12649 errmsg ("socket file name too long");
12652 vec_add1 (file_name, 0);
12654 M (CREATE_VHOST_USER_IF, mp);
12656 mp->is_server = is_server;
12657 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12658 mp->disable_indirect_desc = disable_indirect_desc;
12659 mp->enable_gso = enable_gso;
12660 mp->enable_packed = enable_packed;
12661 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12662 vec_free (file_name);
12663 if (custom_dev_instance != ~0)
12666 mp->custom_dev_instance = ntohl (custom_dev_instance);
12669 mp->use_custom_mac = use_custom_mac;
12670 clib_memcpy (mp->mac_address, hwaddr, 6);
12672 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12681 api_modify_vhost_user_if (vat_main_t * vam)
12683 unformat_input_t *i = vam->input;
12684 vl_api_modify_vhost_user_if_t *mp;
12687 u8 file_name_set = 0;
12688 u32 custom_dev_instance = ~0;
12689 u8 sw_if_index_set = 0;
12690 u32 sw_if_index = (u32) ~ 0;
12692 u8 enable_packed = 0;
12695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12697 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12698 sw_if_index_set = 1;
12699 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12700 sw_if_index_set = 1;
12701 else if (unformat (i, "socket %s", &file_name))
12705 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12707 else if (unformat (i, "server"))
12709 else if (unformat (i, "gso"))
12711 else if (unformat (i, "packed"))
12717 if (sw_if_index_set == 0)
12719 errmsg ("missing sw_if_index or interface name");
12723 if (file_name_set == 0)
12725 errmsg ("missing socket file name");
12729 if (vec_len (file_name) > 255)
12731 errmsg ("socket file name too long");
12734 vec_add1 (file_name, 0);
12736 M (MODIFY_VHOST_USER_IF, mp);
12738 mp->sw_if_index = ntohl (sw_if_index);
12739 mp->is_server = is_server;
12740 mp->enable_gso = enable_gso;
12741 mp->enable_packed = enable_packed;
12742 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12743 vec_free (file_name);
12744 if (custom_dev_instance != ~0)
12747 mp->custom_dev_instance = ntohl (custom_dev_instance);
12756 api_delete_vhost_user_if (vat_main_t * vam)
12758 unformat_input_t *i = vam->input;
12759 vl_api_delete_vhost_user_if_t *mp;
12760 u32 sw_if_index = ~0;
12761 u8 sw_if_index_set = 0;
12764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12766 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12767 sw_if_index_set = 1;
12768 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12769 sw_if_index_set = 1;
12774 if (sw_if_index_set == 0)
12776 errmsg ("missing sw_if_index or interface name");
12781 M (DELETE_VHOST_USER_IF, mp);
12783 mp->sw_if_index = ntohl (sw_if_index);
12790 static void vl_api_sw_interface_vhost_user_details_t_handler
12791 (vl_api_sw_interface_vhost_user_details_t * mp)
12793 vat_main_t *vam = &vat_main;
12797 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12798 clib_net_to_host_u32
12799 (mp->features_last_32) <<
12802 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12803 (char *) mp->interface_name,
12804 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12805 features, mp->is_server,
12806 ntohl (mp->num_regions), (char *) mp->sock_filename);
12807 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12810 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12811 (vl_api_sw_interface_vhost_user_details_t * mp)
12813 vat_main_t *vam = &vat_main;
12814 vat_json_node_t *node = NULL;
12816 if (VAT_JSON_ARRAY != vam->json_tree.type)
12818 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12819 vat_json_init_array (&vam->json_tree);
12821 node = vat_json_array_add (&vam->json_tree);
12823 vat_json_init_object (node);
12824 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12825 vat_json_object_add_string_copy (node, "interface_name",
12826 mp->interface_name);
12827 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12828 ntohl (mp->virtio_net_hdr_sz));
12829 vat_json_object_add_uint (node, "features_first_32",
12830 clib_net_to_host_u32 (mp->features_first_32));
12831 vat_json_object_add_uint (node, "features_last_32",
12832 clib_net_to_host_u32 (mp->features_last_32));
12833 vat_json_object_add_uint (node, "is_server", mp->is_server);
12834 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12835 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12836 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12840 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12842 unformat_input_t *i = vam->input;
12843 vl_api_sw_interface_vhost_user_dump_t *mp;
12844 vl_api_control_ping_t *mp_ping;
12846 u32 sw_if_index = ~0;
12848 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12850 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12852 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12859 "Interface name idx hdr_sz features server regions filename");
12861 /* Get list of vhost-user interfaces */
12862 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12863 mp->sw_if_index = ntohl (sw_if_index);
12866 /* Use a control ping for synchronization */
12867 MPING (CONTROL_PING, mp_ping);
12875 api_show_version (vat_main_t * vam)
12877 vl_api_show_version_t *mp;
12880 M (SHOW_VERSION, mp);
12889 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12891 unformat_input_t *line_input = vam->input;
12892 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12893 ip46_address_t local, remote;
12898 u32 mcast_sw_if_index = ~0;
12899 u32 encap_vrf_id = 0;
12900 u32 decap_vrf_id = 0;
12906 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12908 if (unformat (line_input, "del"))
12910 else if (unformat (line_input, "local %U",
12911 unformat_ip46_address, &local))
12915 else if (unformat (line_input, "remote %U",
12916 unformat_ip46_address, &remote))
12920 else if (unformat (line_input, "group %U %U",
12921 unformat_ip46_address, &remote,
12922 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12924 grp_set = remote_set = 1;
12926 else if (unformat (line_input, "group %U",
12927 unformat_ip46_address, &remote))
12929 grp_set = remote_set = 1;
12932 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12934 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12936 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12938 else if (unformat (line_input, "vni %d", &vni))
12940 else if (unformat (line_input, "next-ip4"))
12942 else if (unformat (line_input, "next-ip6"))
12944 else if (unformat (line_input, "next-ethernet"))
12946 else if (unformat (line_input, "next-nsh"))
12950 errmsg ("parse error '%U'", format_unformat_error, line_input);
12955 if (local_set == 0)
12957 errmsg ("tunnel local address not specified");
12960 if (remote_set == 0)
12962 errmsg ("tunnel remote address not specified");
12965 if (grp_set && mcast_sw_if_index == ~0)
12967 errmsg ("tunnel nonexistent multicast device");
12970 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12972 errmsg ("both IPv4 and IPv6 addresses specified");
12978 errmsg ("vni not specified");
12982 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12984 ip_address_encode (&local,
12985 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12986 IP46_TYPE_IP6, &mp->local);
12987 ip_address_encode (&remote,
12988 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12989 IP46_TYPE_IP6, &mp->remote);
12991 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12992 mp->encap_vrf_id = ntohl (encap_vrf_id);
12993 mp->decap_vrf_id = ntohl (decap_vrf_id);
12994 mp->protocol = protocol;
12995 mp->vni = ntohl (vni);
12996 mp->is_add = is_add;
13003 static void vl_api_vxlan_gpe_tunnel_details_t_handler
13004 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13006 vat_main_t *vam = &vat_main;
13007 ip46_address_t local, remote;
13009 ip_address_decode (&mp->local, &local);
13010 ip_address_decode (&mp->remote, &remote);
13012 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
13013 ntohl (mp->sw_if_index),
13014 format_ip46_address, &local, IP46_TYPE_ANY,
13015 format_ip46_address, &remote, IP46_TYPE_ANY,
13016 ntohl (mp->vni), mp->protocol,
13017 ntohl (mp->mcast_sw_if_index),
13018 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
13022 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
13023 (vl_api_vxlan_gpe_tunnel_details_t * mp)
13025 vat_main_t *vam = &vat_main;
13026 vat_json_node_t *node = NULL;
13027 struct in_addr ip4;
13028 struct in6_addr ip6;
13029 ip46_address_t local, remote;
13031 ip_address_decode (&mp->local, &local);
13032 ip_address_decode (&mp->remote, &remote);
13034 if (VAT_JSON_ARRAY != vam->json_tree.type)
13036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13037 vat_json_init_array (&vam->json_tree);
13039 node = vat_json_array_add (&vam->json_tree);
13041 vat_json_init_object (node);
13042 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13043 if (ip46_address_is_ip4 (&local))
13045 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
13046 vat_json_object_add_ip4 (node, "local", ip4);
13047 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
13048 vat_json_object_add_ip4 (node, "remote", ip4);
13052 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
13053 vat_json_object_add_ip6 (node, "local", ip6);
13054 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
13055 vat_json_object_add_ip6 (node, "remote", ip6);
13057 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13058 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
13059 vat_json_object_add_uint (node, "mcast_sw_if_index",
13060 ntohl (mp->mcast_sw_if_index));
13061 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13062 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
13063 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13067 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
13069 unformat_input_t *i = vam->input;
13070 vl_api_vxlan_gpe_tunnel_dump_t *mp;
13071 vl_api_control_ping_t *mp_ping;
13073 u8 sw_if_index_set = 0;
13076 /* Parse args required to build the message */
13077 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13079 if (unformat (i, "sw_if_index %d", &sw_if_index))
13080 sw_if_index_set = 1;
13085 if (sw_if_index_set == 0)
13090 if (!vam->json_output)
13092 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
13093 "sw_if_index", "local", "remote", "vni",
13094 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
13097 /* Get list of vxlan-tunnel interfaces */
13098 M (VXLAN_GPE_TUNNEL_DUMP, mp);
13100 mp->sw_if_index = htonl (sw_if_index);
13104 /* Use a control ping for synchronization */
13105 MPING (CONTROL_PING, mp_ping);
13112 static void vl_api_l2_fib_table_details_t_handler
13113 (vl_api_l2_fib_table_details_t * mp)
13115 vat_main_t *vam = &vat_main;
13117 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
13119 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
13120 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
13124 static void vl_api_l2_fib_table_details_t_handler_json
13125 (vl_api_l2_fib_table_details_t * mp)
13127 vat_main_t *vam = &vat_main;
13128 vat_json_node_t *node = NULL;
13130 if (VAT_JSON_ARRAY != vam->json_tree.type)
13132 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13133 vat_json_init_array (&vam->json_tree);
13135 node = vat_json_array_add (&vam->json_tree);
13137 vat_json_init_object (node);
13138 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
13139 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
13140 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13141 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
13142 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
13143 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
13147 api_l2_fib_table_dump (vat_main_t * vam)
13149 unformat_input_t *i = vam->input;
13150 vl_api_l2_fib_table_dump_t *mp;
13151 vl_api_control_ping_t *mp_ping;
13156 /* Parse args required to build the message */
13157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13159 if (unformat (i, "bd_id %d", &bd_id))
13165 if (bd_id_set == 0)
13167 errmsg ("missing bridge domain");
13171 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13173 /* Get list of l2 fib entries */
13174 M (L2_FIB_TABLE_DUMP, mp);
13176 mp->bd_id = ntohl (bd_id);
13179 /* Use a control ping for synchronization */
13180 MPING (CONTROL_PING, mp_ping);
13189 api_interface_name_renumber (vat_main_t * vam)
13191 unformat_input_t *line_input = vam->input;
13192 vl_api_interface_name_renumber_t *mp;
13193 u32 sw_if_index = ~0;
13194 u32 new_show_dev_instance = ~0;
13197 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13199 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13202 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13204 else if (unformat (line_input, "new_show_dev_instance %d",
13205 &new_show_dev_instance))
13211 if (sw_if_index == ~0)
13213 errmsg ("missing interface name or sw_if_index");
13217 if (new_show_dev_instance == ~0)
13219 errmsg ("missing new_show_dev_instance");
13223 M (INTERFACE_NAME_RENUMBER, mp);
13225 mp->sw_if_index = ntohl (sw_if_index);
13226 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13234 api_want_l2_macs_events (vat_main_t * vam)
13236 unformat_input_t *line_input = vam->input;
13237 vl_api_want_l2_macs_events_t *mp;
13238 u8 enable_disable = 1;
13239 u32 scan_delay = 0;
13240 u32 max_macs_in_event = 0;
13241 u32 learn_limit = 0;
13244 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13246 if (unformat (line_input, "learn-limit %d", &learn_limit))
13248 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13250 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13252 else if (unformat (line_input, "disable"))
13253 enable_disable = 0;
13258 M (WANT_L2_MACS_EVENTS, mp);
13259 mp->enable_disable = enable_disable;
13260 mp->pid = htonl (getpid ());
13261 mp->learn_limit = htonl (learn_limit);
13262 mp->scan_delay = (u8) scan_delay;
13263 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13270 api_input_acl_set_interface (vat_main_t * vam)
13272 unformat_input_t *i = vam->input;
13273 vl_api_input_acl_set_interface_t *mp;
13275 int sw_if_index_set;
13276 u32 ip4_table_index = ~0;
13277 u32 ip6_table_index = ~0;
13278 u32 l2_table_index = ~0;
13282 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13284 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13285 sw_if_index_set = 1;
13286 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13287 sw_if_index_set = 1;
13288 else if (unformat (i, "del"))
13290 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13292 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13294 else if (unformat (i, "l2-table %d", &l2_table_index))
13298 clib_warning ("parse error '%U'", format_unformat_error, i);
13303 if (sw_if_index_set == 0)
13305 errmsg ("missing interface name or sw_if_index");
13309 M (INPUT_ACL_SET_INTERFACE, mp);
13311 mp->sw_if_index = ntohl (sw_if_index);
13312 mp->ip4_table_index = ntohl (ip4_table_index);
13313 mp->ip6_table_index = ntohl (ip6_table_index);
13314 mp->l2_table_index = ntohl (l2_table_index);
13315 mp->is_add = is_add;
13323 api_output_acl_set_interface (vat_main_t * vam)
13325 unformat_input_t *i = vam->input;
13326 vl_api_output_acl_set_interface_t *mp;
13328 int sw_if_index_set;
13329 u32 ip4_table_index = ~0;
13330 u32 ip6_table_index = ~0;
13331 u32 l2_table_index = ~0;
13335 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13337 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13338 sw_if_index_set = 1;
13339 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13340 sw_if_index_set = 1;
13341 else if (unformat (i, "del"))
13343 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13345 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13347 else if (unformat (i, "l2-table %d", &l2_table_index))
13351 clib_warning ("parse error '%U'", format_unformat_error, i);
13356 if (sw_if_index_set == 0)
13358 errmsg ("missing interface name or sw_if_index");
13362 M (OUTPUT_ACL_SET_INTERFACE, mp);
13364 mp->sw_if_index = ntohl (sw_if_index);
13365 mp->ip4_table_index = ntohl (ip4_table_index);
13366 mp->ip6_table_index = ntohl (ip6_table_index);
13367 mp->l2_table_index = ntohl (l2_table_index);
13368 mp->is_add = is_add;
13376 api_ip_address_dump (vat_main_t * vam)
13378 unformat_input_t *i = vam->input;
13379 vl_api_ip_address_dump_t *mp;
13380 vl_api_control_ping_t *mp_ping;
13381 u32 sw_if_index = ~0;
13382 u8 sw_if_index_set = 0;
13387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13389 if (unformat (i, "sw_if_index %d", &sw_if_index))
13390 sw_if_index_set = 1;
13392 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13393 sw_if_index_set = 1;
13394 else if (unformat (i, "ipv4"))
13396 else if (unformat (i, "ipv6"))
13402 if (ipv4_set && ipv6_set)
13404 errmsg ("ipv4 and ipv6 flags cannot be both set");
13408 if ((!ipv4_set) && (!ipv6_set))
13410 errmsg ("no ipv4 nor ipv6 flag set");
13414 if (sw_if_index_set == 0)
13416 errmsg ("missing interface name or sw_if_index");
13420 vam->current_sw_if_index = sw_if_index;
13421 vam->is_ipv6 = ipv6_set;
13423 M (IP_ADDRESS_DUMP, mp);
13424 mp->sw_if_index = ntohl (sw_if_index);
13425 mp->is_ipv6 = ipv6_set;
13428 /* Use a control ping for synchronization */
13429 MPING (CONTROL_PING, mp_ping);
13437 api_ip_dump (vat_main_t * vam)
13439 vl_api_ip_dump_t *mp;
13440 vl_api_control_ping_t *mp_ping;
13441 unformat_input_t *in = vam->input;
13448 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13450 if (unformat (in, "ipv4"))
13452 else if (unformat (in, "ipv6"))
13458 if (ipv4_set && ipv6_set)
13460 errmsg ("ipv4 and ipv6 flags cannot be both set");
13464 if ((!ipv4_set) && (!ipv6_set))
13466 errmsg ("no ipv4 nor ipv6 flag set");
13470 is_ipv6 = ipv6_set;
13471 vam->is_ipv6 = is_ipv6;
13473 /* free old data */
13474 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13476 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13478 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13481 mp->is_ipv6 = ipv6_set;
13484 /* Use a control ping for synchronization */
13485 MPING (CONTROL_PING, mp_ping);
13493 api_ipsec_spd_add_del (vat_main_t * vam)
13495 unformat_input_t *i = vam->input;
13496 vl_api_ipsec_spd_add_del_t *mp;
13501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13503 if (unformat (i, "spd_id %d", &spd_id))
13505 else if (unformat (i, "del"))
13509 clib_warning ("parse error '%U'", format_unformat_error, i);
13515 errmsg ("spd_id must be set");
13519 M (IPSEC_SPD_ADD_DEL, mp);
13521 mp->spd_id = ntohl (spd_id);
13522 mp->is_add = is_add;
13530 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13532 unformat_input_t *i = vam->input;
13533 vl_api_ipsec_interface_add_del_spd_t *mp;
13535 u8 sw_if_index_set = 0;
13536 u32 spd_id = (u32) ~ 0;
13540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13542 if (unformat (i, "del"))
13544 else if (unformat (i, "spd_id %d", &spd_id))
13547 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13548 sw_if_index_set = 1;
13549 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13550 sw_if_index_set = 1;
13553 clib_warning ("parse error '%U'", format_unformat_error, i);
13559 if (spd_id == (u32) ~ 0)
13561 errmsg ("spd_id must be set");
13565 if (sw_if_index_set == 0)
13567 errmsg ("missing interface name or sw_if_index");
13571 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13573 mp->spd_id = ntohl (spd_id);
13574 mp->sw_if_index = ntohl (sw_if_index);
13575 mp->is_add = is_add;
13583 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13585 unformat_input_t *i = vam->input;
13586 vl_api_ipsec_spd_entry_add_del_t *mp;
13587 u8 is_add = 1, is_outbound = 0;
13588 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13590 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13591 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13592 vl_api_address_t laddr_start = { }, laddr_stop =
13601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13603 if (unformat (i, "del"))
13605 if (unformat (i, "outbound"))
13607 if (unformat (i, "inbound"))
13609 else if (unformat (i, "spd_id %d", &spd_id))
13611 else if (unformat (i, "sa_id %d", &sa_id))
13613 else if (unformat (i, "priority %d", &priority))
13615 else if (unformat (i, "protocol %d", &protocol))
13617 else if (unformat (i, "lport_start %d", &lport_start))
13619 else if (unformat (i, "lport_stop %d", &lport_stop))
13621 else if (unformat (i, "rport_start %d", &rport_start))
13623 else if (unformat (i, "rport_stop %d", &rport_stop))
13625 else if (unformat (i, "laddr_start %U",
13626 unformat_vl_api_address, &laddr_start))
13628 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13631 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13634 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13638 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13640 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13642 clib_warning ("unsupported action: 'resolve'");
13648 clib_warning ("parse error '%U'", format_unformat_error, i);
13654 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13656 mp->is_add = is_add;
13658 mp->entry.spd_id = ntohl (spd_id);
13659 mp->entry.priority = ntohl (priority);
13660 mp->entry.is_outbound = is_outbound;
13662 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13663 sizeof (vl_api_address_t));
13664 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13665 sizeof (vl_api_address_t));
13666 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13667 sizeof (vl_api_address_t));
13668 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13669 sizeof (vl_api_address_t));
13671 mp->entry.protocol = (u8) protocol;
13672 mp->entry.local_port_start = ntohs ((u16) lport_start);
13673 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13674 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13675 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13676 mp->entry.policy = (u8) policy;
13677 mp->entry.sa_id = ntohl (sa_id);
13685 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13687 unformat_input_t *i = vam->input;
13688 vl_api_ipsec_sad_entry_add_del_t *mp;
13689 u32 sad_id = 0, spi = 0;
13690 u8 *ck = 0, *ik = 0;
13693 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13694 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13695 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13696 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13697 vl_api_address_t tun_src, tun_dst;
13700 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13702 if (unformat (i, "del"))
13704 else if (unformat (i, "sad_id %d", &sad_id))
13706 else if (unformat (i, "spi %d", &spi))
13708 else if (unformat (i, "esp"))
13709 protocol = IPSEC_API_PROTO_ESP;
13711 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13713 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13714 if (ADDRESS_IP6 == tun_src.af)
13715 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13718 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13720 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13721 if (ADDRESS_IP6 == tun_src.af)
13722 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13725 if (unformat (i, "crypto_alg %U",
13726 unformat_ipsec_api_crypto_alg, &crypto_alg))
13728 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13730 else if (unformat (i, "integ_alg %U",
13731 unformat_ipsec_api_integ_alg, &integ_alg))
13733 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13737 clib_warning ("parse error '%U'", format_unformat_error, i);
13743 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13745 mp->is_add = is_add;
13746 mp->entry.sad_id = ntohl (sad_id);
13747 mp->entry.protocol = protocol;
13748 mp->entry.spi = ntohl (spi);
13749 mp->entry.flags = flags;
13751 mp->entry.crypto_algorithm = crypto_alg;
13752 mp->entry.integrity_algorithm = integ_alg;
13753 mp->entry.crypto_key.length = vec_len (ck);
13754 mp->entry.integrity_key.length = vec_len (ik);
13756 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13757 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13759 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13760 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13763 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13765 clib_memcpy (mp->entry.integrity_key.data, ik,
13766 mp->entry.integrity_key.length);
13768 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13770 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13771 sizeof (mp->entry.tunnel_src));
13772 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13773 sizeof (mp->entry.tunnel_dst));
13782 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13784 unformat_input_t *i = vam->input;
13785 vl_api_ipsec_tunnel_if_add_del_t *mp;
13786 u32 local_spi = 0, remote_spi = 0;
13787 u32 crypto_alg = 0, integ_alg = 0;
13788 u8 *lck = NULL, *rck = NULL;
13789 u8 *lik = NULL, *rik = NULL;
13790 vl_api_address_t local_ip = { 0 };
13791 vl_api_address_t remote_ip = { 0 };
13795 u8 anti_replay = 0;
13801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13803 if (unformat (i, "del"))
13805 else if (unformat (i, "esn"))
13807 else if (unformat (i, "anti-replay"))
13809 else if (unformat (i, "count %d", &count))
13811 else if (unformat (i, "local_spi %d", &local_spi))
13813 else if (unformat (i, "remote_spi %d", &remote_spi))
13816 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13819 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13821 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13824 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13826 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13828 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13832 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13834 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13836 errmsg ("unsupported crypto-alg: '%U'\n",
13837 format_ipsec_crypto_alg, crypto_alg);
13843 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13845 if (integ_alg >= IPSEC_INTEG_N_ALG)
13847 errmsg ("unsupported integ-alg: '%U'\n",
13848 format_ipsec_integ_alg, integ_alg);
13852 else if (unformat (i, "instance %u", &instance))
13856 errmsg ("parse error '%U'\n", format_unformat_error, i);
13863 /* Turn on async mode */
13864 vam->async_mode = 1;
13865 vam->async_errors = 0;
13866 before = vat_time_now (vam);
13869 for (jj = 0; jj < count; jj++)
13871 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13873 mp->is_add = is_add;
13875 mp->anti_replay = anti_replay;
13878 increment_address (&remote_ip);
13880 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13881 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13883 mp->local_spi = htonl (local_spi + jj);
13884 mp->remote_spi = htonl (remote_spi + jj);
13885 mp->crypto_alg = (u8) crypto_alg;
13887 mp->local_crypto_key_len = 0;
13890 mp->local_crypto_key_len = vec_len (lck);
13891 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13892 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13893 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13896 mp->remote_crypto_key_len = 0;
13899 mp->remote_crypto_key_len = vec_len (rck);
13900 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13901 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13902 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13905 mp->integ_alg = (u8) integ_alg;
13907 mp->local_integ_key_len = 0;
13910 mp->local_integ_key_len = vec_len (lik);
13911 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13912 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13913 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13916 mp->remote_integ_key_len = 0;
13919 mp->remote_integ_key_len = vec_len (rik);
13920 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13921 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13922 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13927 mp->renumber = renumber;
13928 mp->show_instance = ntohl (instance);
13933 /* When testing multiple add/del ops, use a control-ping to sync */
13936 vl_api_control_ping_t *mp_ping;
13940 /* Shut off async mode */
13941 vam->async_mode = 0;
13943 MPING (CONTROL_PING, mp_ping);
13946 timeout = vat_time_now (vam) + 1.0;
13947 while (vat_time_now (vam) < timeout)
13948 if (vam->result_ready == 1)
13953 if (vam->retval == -99)
13954 errmsg ("timeout");
13956 if (vam->async_errors > 0)
13958 errmsg ("%d asynchronous errors", vam->async_errors);
13961 vam->async_errors = 0;
13962 after = vat_time_now (vam);
13964 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13968 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13969 count, after - before, count / (after - before));
13973 /* Wait for a reply... */
13982 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13984 vat_main_t *vam = &vat_main;
13986 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13987 "crypto_key %U integ_alg %u integ_key %U flags %x "
13988 "tunnel_src_addr %U tunnel_dst_addr %U "
13989 "salt %u seq_outbound %lu last_seq_inbound %lu "
13990 "replay_window %lu stat_index %u\n",
13991 ntohl (mp->entry.sad_id),
13992 ntohl (mp->sw_if_index),
13993 ntohl (mp->entry.spi),
13994 ntohl (mp->entry.protocol),
13995 ntohl (mp->entry.crypto_algorithm),
13996 format_hex_bytes, mp->entry.crypto_key.data,
13997 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13998 format_hex_bytes, mp->entry.integrity_key.data,
13999 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
14000 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
14001 &mp->entry.tunnel_dst, ntohl (mp->salt),
14002 clib_net_to_host_u64 (mp->seq_outbound),
14003 clib_net_to_host_u64 (mp->last_seq_inbound),
14004 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
14007 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
14008 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
14010 static void vl_api_ipsec_sa_details_t_handler_json
14011 (vl_api_ipsec_sa_details_t * mp)
14013 vat_main_t *vam = &vat_main;
14014 vat_json_node_t *node = NULL;
14015 vl_api_ipsec_sad_flags_t flags;
14017 if (VAT_JSON_ARRAY != vam->json_tree.type)
14019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14020 vat_json_init_array (&vam->json_tree);
14022 node = vat_json_array_add (&vam->json_tree);
14024 vat_json_init_object (node);
14025 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
14026 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14027 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
14028 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
14029 vat_json_object_add_uint (node, "crypto_alg",
14030 ntohl (mp->entry.crypto_algorithm));
14031 vat_json_object_add_uint (node, "integ_alg",
14032 ntohl (mp->entry.integrity_algorithm));
14033 flags = ntohl (mp->entry.flags);
14034 vat_json_object_add_uint (node, "use_esn",
14035 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
14036 vat_json_object_add_uint (node, "use_anti_replay",
14037 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
14038 vat_json_object_add_uint (node, "is_tunnel",
14039 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
14040 vat_json_object_add_uint (node, "is_tunnel_ip6",
14041 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
14042 vat_json_object_add_uint (node, "udp_encap",
14043 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
14044 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
14045 mp->entry.crypto_key.length);
14046 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
14047 mp->entry.integrity_key.length);
14048 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
14049 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
14050 vat_json_object_add_uint (node, "replay_window",
14051 clib_net_to_host_u64 (mp->replay_window));
14052 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
14056 api_ipsec_sa_dump (vat_main_t * vam)
14058 unformat_input_t *i = vam->input;
14059 vl_api_ipsec_sa_dump_t *mp;
14060 vl_api_control_ping_t *mp_ping;
14064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14066 if (unformat (i, "sa_id %d", &sa_id))
14070 clib_warning ("parse error '%U'", format_unformat_error, i);
14075 M (IPSEC_SA_DUMP, mp);
14077 mp->sa_id = ntohl (sa_id);
14081 /* Use a control ping for synchronization */
14082 M (CONTROL_PING, mp_ping);
14090 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
14092 unformat_input_t *i = vam->input;
14093 vl_api_ipsec_tunnel_if_set_sa_t *mp;
14094 u32 sw_if_index = ~0;
14096 u8 is_outbound = (u8) ~ 0;
14099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14101 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14103 else if (unformat (i, "sa_id %d", &sa_id))
14105 else if (unformat (i, "outbound"))
14107 else if (unformat (i, "inbound"))
14111 clib_warning ("parse error '%U'", format_unformat_error, i);
14116 if (sw_if_index == ~0)
14118 errmsg ("interface must be specified");
14124 errmsg ("SA ID must be specified");
14128 M (IPSEC_TUNNEL_IF_SET_SA, mp);
14130 mp->sw_if_index = htonl (sw_if_index);
14131 mp->sa_id = htonl (sa_id);
14132 mp->is_outbound = is_outbound;
14141 api_get_first_msg_id (vat_main_t * vam)
14143 vl_api_get_first_msg_id_t *mp;
14144 unformat_input_t *i = vam->input;
14149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14151 if (unformat (i, "client %s", &name))
14159 errmsg ("missing client name");
14162 vec_add1 (name, 0);
14164 if (vec_len (name) > 63)
14166 errmsg ("client name too long");
14170 M (GET_FIRST_MSG_ID, mp);
14171 clib_memcpy (mp->name, name, vec_len (name));
14178 api_cop_interface_enable_disable (vat_main_t * vam)
14180 unformat_input_t *line_input = vam->input;
14181 vl_api_cop_interface_enable_disable_t *mp;
14182 u32 sw_if_index = ~0;
14183 u8 enable_disable = 1;
14186 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14188 if (unformat (line_input, "disable"))
14189 enable_disable = 0;
14190 if (unformat (line_input, "enable"))
14191 enable_disable = 1;
14192 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14193 vam, &sw_if_index))
14195 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14201 if (sw_if_index == ~0)
14203 errmsg ("missing interface name or sw_if_index");
14207 /* Construct the API message */
14208 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14209 mp->sw_if_index = ntohl (sw_if_index);
14210 mp->enable_disable = enable_disable;
14214 /* Wait for the reply */
14220 api_cop_whitelist_enable_disable (vat_main_t * vam)
14222 unformat_input_t *line_input = vam->input;
14223 vl_api_cop_whitelist_enable_disable_t *mp;
14224 u32 sw_if_index = ~0;
14225 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14229 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14231 if (unformat (line_input, "ip4"))
14233 else if (unformat (line_input, "ip6"))
14235 else if (unformat (line_input, "default"))
14237 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14238 vam, &sw_if_index))
14240 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14242 else if (unformat (line_input, "fib-id %d", &fib_id))
14248 if (sw_if_index == ~0)
14250 errmsg ("missing interface name or sw_if_index");
14254 /* Construct the API message */
14255 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14256 mp->sw_if_index = ntohl (sw_if_index);
14257 mp->fib_id = ntohl (fib_id);
14260 mp->default_cop = default_cop;
14264 /* Wait for the reply */
14270 api_get_node_graph (vat_main_t * vam)
14272 vl_api_get_node_graph_t *mp;
14275 M (GET_NODE_GRAPH, mp);
14279 /* Wait for the reply */
14285 /** Used for parsing LISP eids */
14286 typedef CLIB_PACKED(struct{
14290 lisp_nsh_api_t nsh;
14292 u32 len; /**< prefix length if IP */
14293 u8 type; /**< type of eid */
14298 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14300 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14302 clib_memset (a, 0, sizeof (a[0]));
14304 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
14306 a->type = 0; /* ip prefix type */
14308 else if (unformat (input, "%U", unformat_ethernet_address, a->addr.mac))
14310 a->type = 1; /* mac type */
14312 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
14314 a->type = 2; /* NSH type */
14315 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
14324 if (ip46_address_is_ip4 (&a->addr.ip))
14325 return a->len > 32 ? 1 : 0;
14327 return a->len > 128 ? 1 : 0;
14334 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
14336 eid->type = vat_eid->type;
14339 case EID_TYPE_API_PREFIX:
14340 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
14342 clib_memcpy (&eid->address.prefix.address.un.ip4,
14343 &vat_eid->addr.ip.ip4, 4);
14344 eid->address.prefix.address.af = ADDRESS_IP4;
14345 eid->address.prefix.len = vat_eid->len;
14349 clib_memcpy (&eid->address.prefix.address.un.ip6,
14350 &vat_eid->addr.ip.ip6, 16);
14351 eid->address.prefix.address.af = ADDRESS_IP6;
14352 eid->address.prefix.len = vat_eid->len;
14355 case EID_TYPE_API_MAC:
14356 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
14357 sizeof (eid->address.mac));
14359 case EID_TYPE_API_NSH:
14360 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
14361 sizeof (eid->address.nsh));
14370 api_one_add_del_locator_set (vat_main_t * vam)
14372 unformat_input_t *input = vam->input;
14373 vl_api_one_add_del_locator_set_t *mp;
14375 u8 *locator_set_name = NULL;
14376 u8 locator_set_name_set = 0;
14377 vl_api_local_locator_t locator, *locators = 0;
14378 u32 sw_if_index, priority, weight;
14382 /* Parse args required to build the message */
14383 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14385 if (unformat (input, "del"))
14389 else if (unformat (input, "locator-set %s", &locator_set_name))
14391 locator_set_name_set = 1;
14393 else if (unformat (input, "sw_if_index %u p %u w %u",
14394 &sw_if_index, &priority, &weight))
14396 locator.sw_if_index = htonl (sw_if_index);
14397 locator.priority = priority;
14398 locator.weight = weight;
14399 vec_add1 (locators, locator);
14403 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14404 &sw_if_index, &priority, &weight))
14406 locator.sw_if_index = htonl (sw_if_index);
14407 locator.priority = priority;
14408 locator.weight = weight;
14409 vec_add1 (locators, locator);
14415 if (locator_set_name_set == 0)
14417 errmsg ("missing locator-set name");
14418 vec_free (locators);
14422 if (vec_len (locator_set_name) > 64)
14424 errmsg ("locator-set name too long");
14425 vec_free (locator_set_name);
14426 vec_free (locators);
14429 vec_add1 (locator_set_name, 0);
14431 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14433 /* Construct the API message */
14434 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14436 mp->is_add = is_add;
14437 clib_memcpy (mp->locator_set_name, locator_set_name,
14438 vec_len (locator_set_name));
14439 vec_free (locator_set_name);
14441 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14443 clib_memcpy (mp->locators, locators, data_len);
14444 vec_free (locators);
14449 /* Wait for a reply... */
14454 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14457 api_one_add_del_locator (vat_main_t * vam)
14459 unformat_input_t *input = vam->input;
14460 vl_api_one_add_del_locator_t *mp;
14461 u32 tmp_if_index = ~0;
14462 u32 sw_if_index = ~0;
14463 u8 sw_if_index_set = 0;
14464 u8 sw_if_index_if_name_set = 0;
14466 u8 priority_set = 0;
14470 u8 *locator_set_name = NULL;
14471 u8 locator_set_name_set = 0;
14474 /* Parse args required to build the message */
14475 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14477 if (unformat (input, "del"))
14481 else if (unformat (input, "locator-set %s", &locator_set_name))
14483 locator_set_name_set = 1;
14485 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14488 sw_if_index_if_name_set = 1;
14489 sw_if_index = tmp_if_index;
14491 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14493 sw_if_index_set = 1;
14494 sw_if_index = tmp_if_index;
14496 else if (unformat (input, "p %d", &priority))
14500 else if (unformat (input, "w %d", &weight))
14508 if (locator_set_name_set == 0)
14510 errmsg ("missing locator-set name");
14514 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14516 errmsg ("missing sw_if_index");
14517 vec_free (locator_set_name);
14521 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14523 errmsg ("cannot use both params interface name and sw_if_index");
14524 vec_free (locator_set_name);
14528 if (priority_set == 0)
14530 errmsg ("missing locator-set priority");
14531 vec_free (locator_set_name);
14535 if (weight_set == 0)
14537 errmsg ("missing locator-set weight");
14538 vec_free (locator_set_name);
14542 if (vec_len (locator_set_name) > 64)
14544 errmsg ("locator-set name too long");
14545 vec_free (locator_set_name);
14548 vec_add1 (locator_set_name, 0);
14550 /* Construct the API message */
14551 M (ONE_ADD_DEL_LOCATOR, mp);
14553 mp->is_add = is_add;
14554 mp->sw_if_index = ntohl (sw_if_index);
14555 mp->priority = priority;
14556 mp->weight = weight;
14557 clib_memcpy (mp->locator_set_name, locator_set_name,
14558 vec_len (locator_set_name));
14559 vec_free (locator_set_name);
14564 /* Wait for a reply... */
14569 #define api_lisp_add_del_locator api_one_add_del_locator
14572 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14574 u32 *key_id = va_arg (*args, u32 *);
14577 if (unformat (input, "%s", &s))
14579 if (!strcmp ((char *) s, "sha1"))
14580 key_id[0] = HMAC_SHA_1_96;
14581 else if (!strcmp ((char *) s, "sha256"))
14582 key_id[0] = HMAC_SHA_256_128;
14585 clib_warning ("invalid key_id: '%s'", s);
14586 key_id[0] = HMAC_NO_KEY;
14597 api_one_add_del_local_eid (vat_main_t * vam)
14599 unformat_input_t *input = vam->input;
14600 vl_api_one_add_del_local_eid_t *mp;
14603 lisp_eid_vat_t _eid, *eid = &_eid;
14604 u8 *locator_set_name = 0;
14605 u8 locator_set_name_set = 0;
14611 /* Parse args required to build the message */
14612 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14614 if (unformat (input, "del"))
14618 else if (unformat (input, "vni %d", &vni))
14622 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14626 else if (unformat (input, "locator-set %s", &locator_set_name))
14628 locator_set_name_set = 1;
14630 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14632 else if (unformat (input, "secret-key %_%v%_", &key))
14638 if (locator_set_name_set == 0)
14640 errmsg ("missing locator-set name");
14646 errmsg ("EID address not set!");
14647 vec_free (locator_set_name);
14651 if (key && (0 == key_id))
14653 errmsg ("invalid key_id!");
14657 if (vec_len (key) > 64)
14659 errmsg ("key too long");
14664 if (vec_len (locator_set_name) > 64)
14666 errmsg ("locator-set name too long");
14667 vec_free (locator_set_name);
14670 vec_add1 (locator_set_name, 0);
14672 /* Construct the API message */
14673 M (ONE_ADD_DEL_LOCAL_EID, mp);
14675 mp->is_add = is_add;
14676 lisp_eid_put_vat (&mp->eid, eid);
14677 mp->vni = clib_host_to_net_u32 (vni);
14678 mp->key.id = key_id;
14679 clib_memcpy (mp->locator_set_name, locator_set_name,
14680 vec_len (locator_set_name));
14681 clib_memcpy (mp->key.key, key, vec_len (key));
14683 vec_free (locator_set_name);
14689 /* Wait for a reply... */
14694 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14697 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14699 u32 dp_table = 0, vni = 0;;
14700 unformat_input_t *input = vam->input;
14701 vl_api_gpe_add_del_fwd_entry_t *mp;
14703 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14704 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14705 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14706 u32 action = ~0, w;
14707 ip4_address_t rmt_rloc4, lcl_rloc4;
14708 ip6_address_t rmt_rloc6, lcl_rloc6;
14709 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14712 clib_memset (&rloc, 0, sizeof (rloc));
14714 /* Parse args required to build the message */
14715 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14717 if (unformat (input, "del"))
14719 else if (unformat (input, "add"))
14721 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14725 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14729 else if (unformat (input, "vrf %d", &dp_table))
14731 else if (unformat (input, "bd %d", &dp_table))
14733 else if (unformat (input, "vni %d", &vni))
14735 else if (unformat (input, "w %d", &w))
14739 errmsg ("No RLOC configured for setting priority/weight!");
14742 curr_rloc->weight = w;
14744 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14745 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14748 clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
14750 vec_add1 (lcl_locs, rloc);
14752 clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
14753 vec_add1 (rmt_locs, rloc);
14754 /* weight saved in rmt loc */
14755 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14757 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14758 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14761 clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
14763 vec_add1 (lcl_locs, rloc);
14765 clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
14766 vec_add1 (rmt_locs, rloc);
14767 /* weight saved in rmt loc */
14768 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14770 else if (unformat (input, "action %d", &action))
14776 clib_warning ("parse error '%U'", format_unformat_error, input);
14783 errmsg ("remote eid addresses not set");
14787 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14789 errmsg ("eid types don't match");
14793 if (0 == rmt_locs && (u32) ~ 0 == action)
14795 errmsg ("action not set for negative mapping");
14799 /* Construct the API message */
14800 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14801 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14803 mp->is_add = is_add;
14804 lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
14805 lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
14806 mp->dp_table = clib_host_to_net_u32 (dp_table);
14807 mp->vni = clib_host_to_net_u32 (vni);
14808 mp->action = action;
14810 if (0 != rmt_locs && 0 != lcl_locs)
14812 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14813 clib_memcpy (mp->locs, lcl_locs,
14814 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14816 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14817 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14818 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14820 vec_free (lcl_locs);
14821 vec_free (rmt_locs);
14826 /* Wait for a reply... */
14832 api_one_add_del_map_server (vat_main_t * vam)
14834 unformat_input_t *input = vam->input;
14835 vl_api_one_add_del_map_server_t *mp;
14839 ip4_address_t ipv4;
14840 ip6_address_t ipv6;
14843 /* Parse args required to build the message */
14844 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14846 if (unformat (input, "del"))
14850 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14854 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14862 if (ipv4_set && ipv6_set)
14864 errmsg ("both eid v4 and v6 addresses set");
14868 if (!ipv4_set && !ipv6_set)
14870 errmsg ("eid addresses not set");
14874 /* Construct the API message */
14875 M (ONE_ADD_DEL_MAP_SERVER, mp);
14877 mp->is_add = is_add;
14880 mp->ip_address.af = 1;
14881 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14885 mp->ip_address.af = 0;
14886 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
14892 /* Wait for a reply... */
14897 #define api_lisp_add_del_map_server api_one_add_del_map_server
14900 api_one_add_del_map_resolver (vat_main_t * vam)
14902 unformat_input_t *input = vam->input;
14903 vl_api_one_add_del_map_resolver_t *mp;
14907 ip4_address_t ipv4;
14908 ip6_address_t ipv6;
14911 /* Parse args required to build the message */
14912 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14914 if (unformat (input, "del"))
14918 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14922 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14930 if (ipv4_set && ipv6_set)
14932 errmsg ("both eid v4 and v6 addresses set");
14936 if (!ipv4_set && !ipv6_set)
14938 errmsg ("eid addresses not set");
14942 /* Construct the API message */
14943 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14945 mp->is_add = is_add;
14948 mp->ip_address.af = 1;
14949 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14953 mp->ip_address.af = 0;
14954 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
14960 /* Wait for a reply... */
14965 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14968 api_lisp_gpe_enable_disable (vat_main_t * vam)
14970 unformat_input_t *input = vam->input;
14971 vl_api_gpe_enable_disable_t *mp;
14976 /* Parse args required to build the message */
14977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14979 if (unformat (input, "enable"))
14984 else if (unformat (input, "disable"))
14995 errmsg ("Value not set");
14999 /* Construct the API message */
15000 M (GPE_ENABLE_DISABLE, mp);
15002 mp->is_enable = is_enable;
15007 /* Wait for a reply... */
15013 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15015 unformat_input_t *input = vam->input;
15016 vl_api_one_rloc_probe_enable_disable_t *mp;
15021 /* Parse args required to build the message */
15022 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15024 if (unformat (input, "enable"))
15029 else if (unformat (input, "disable"))
15037 errmsg ("Value not set");
15041 /* Construct the API message */
15042 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15044 mp->is_enable = is_enable;
15049 /* Wait for a reply... */
15054 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15057 api_one_map_register_enable_disable (vat_main_t * vam)
15059 unformat_input_t *input = vam->input;
15060 vl_api_one_map_register_enable_disable_t *mp;
15065 /* Parse args required to build the message */
15066 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15068 if (unformat (input, "enable"))
15073 else if (unformat (input, "disable"))
15081 errmsg ("Value not set");
15085 /* Construct the API message */
15086 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15088 mp->is_enable = is_enable;
15093 /* Wait for a reply... */
15098 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15101 api_one_enable_disable (vat_main_t * vam)
15103 unformat_input_t *input = vam->input;
15104 vl_api_one_enable_disable_t *mp;
15109 /* Parse args required to build the message */
15110 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15112 if (unformat (input, "enable"))
15117 else if (unformat (input, "disable"))
15127 errmsg ("Value not set");
15131 /* Construct the API message */
15132 M (ONE_ENABLE_DISABLE, mp);
15134 mp->is_enable = is_enable;
15139 /* Wait for a reply... */
15144 #define api_lisp_enable_disable api_one_enable_disable
15147 api_one_enable_disable_xtr_mode (vat_main_t * vam)
15149 unformat_input_t *input = vam->input;
15150 vl_api_one_enable_disable_xtr_mode_t *mp;
15155 /* Parse args required to build the message */
15156 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15158 if (unformat (input, "enable"))
15163 else if (unformat (input, "disable"))
15173 errmsg ("Value not set");
15177 /* Construct the API message */
15178 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15180 mp->is_enable = is_enable;
15185 /* Wait for a reply... */
15191 api_one_show_xtr_mode (vat_main_t * vam)
15193 vl_api_one_show_xtr_mode_t *mp;
15196 /* Construct the API message */
15197 M (ONE_SHOW_XTR_MODE, mp);
15202 /* Wait for a reply... */
15208 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15210 unformat_input_t *input = vam->input;
15211 vl_api_one_enable_disable_pitr_mode_t *mp;
15216 /* Parse args required to build the message */
15217 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15219 if (unformat (input, "enable"))
15224 else if (unformat (input, "disable"))
15234 errmsg ("Value not set");
15238 /* Construct the API message */
15239 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15241 mp->is_enable = is_enable;
15246 /* Wait for a reply... */
15252 api_one_show_pitr_mode (vat_main_t * vam)
15254 vl_api_one_show_pitr_mode_t *mp;
15257 /* Construct the API message */
15258 M (ONE_SHOW_PITR_MODE, mp);
15263 /* Wait for a reply... */
15269 api_one_enable_disable_petr_mode (vat_main_t * vam)
15271 unformat_input_t *input = vam->input;
15272 vl_api_one_enable_disable_petr_mode_t *mp;
15277 /* Parse args required to build the message */
15278 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15280 if (unformat (input, "enable"))
15285 else if (unformat (input, "disable"))
15295 errmsg ("Value not set");
15299 /* Construct the API message */
15300 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15302 mp->is_enable = is_enable;
15307 /* Wait for a reply... */
15313 api_one_show_petr_mode (vat_main_t * vam)
15315 vl_api_one_show_petr_mode_t *mp;
15318 /* Construct the API message */
15319 M (ONE_SHOW_PETR_MODE, mp);
15324 /* Wait for a reply... */
15330 api_show_one_map_register_state (vat_main_t * vam)
15332 vl_api_show_one_map_register_state_t *mp;
15335 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15340 /* wait for reply */
15345 #define api_show_lisp_map_register_state api_show_one_map_register_state
15348 api_show_one_rloc_probe_state (vat_main_t * vam)
15350 vl_api_show_one_rloc_probe_state_t *mp;
15353 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15358 /* wait for reply */
15363 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15366 api_one_add_del_ndp_entry (vat_main_t * vam)
15368 vl_api_one_add_del_ndp_entry_t *mp;
15369 unformat_input_t *input = vam->input;
15374 u8 mac[6] = { 0, };
15375 u8 ip6[16] = { 0, };
15379 /* Parse args required to build the message */
15380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15382 if (unformat (input, "del"))
15384 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15386 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15388 else if (unformat (input, "bd %d", &bd))
15392 errmsg ("parse error '%U'", format_unformat_error, input);
15397 if (!bd_set || !ip_set || (!mac_set && is_add))
15399 errmsg ("Missing BD, IP or MAC!");
15403 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15404 mp->is_add = is_add;
15405 clib_memcpy (&mp->entry.mac, mac, 6);
15406 mp->bd = clib_host_to_net_u32 (bd);
15407 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
15412 /* wait for reply */
15418 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15420 vl_api_one_add_del_l2_arp_entry_t *mp;
15421 unformat_input_t *input = vam->input;
15426 u8 mac[6] = { 0, };
15427 u32 ip4 = 0, bd = ~0;
15430 /* Parse args required to build the message */
15431 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15433 if (unformat (input, "del"))
15435 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15437 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15439 else if (unformat (input, "bd %d", &bd))
15443 errmsg ("parse error '%U'", format_unformat_error, input);
15448 if (!bd_set || !ip_set || (!mac_set && is_add))
15450 errmsg ("Missing BD, IP or MAC!");
15454 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15455 mp->is_add = is_add;
15456 clib_memcpy (&mp->entry.mac, mac, 6);
15457 mp->bd = clib_host_to_net_u32 (bd);
15458 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
15463 /* wait for reply */
15469 api_one_ndp_bd_get (vat_main_t * vam)
15471 vl_api_one_ndp_bd_get_t *mp;
15474 M (ONE_NDP_BD_GET, mp);
15479 /* wait for reply */
15485 api_one_ndp_entries_get (vat_main_t * vam)
15487 vl_api_one_ndp_entries_get_t *mp;
15488 unformat_input_t *input = vam->input;
15493 /* Parse args required to build the message */
15494 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15496 if (unformat (input, "bd %d", &bd))
15500 errmsg ("parse error '%U'", format_unformat_error, input);
15507 errmsg ("Expected bridge domain!");
15511 M (ONE_NDP_ENTRIES_GET, mp);
15512 mp->bd = clib_host_to_net_u32 (bd);
15517 /* wait for reply */
15523 api_one_l2_arp_bd_get (vat_main_t * vam)
15525 vl_api_one_l2_arp_bd_get_t *mp;
15528 M (ONE_L2_ARP_BD_GET, mp);
15533 /* wait for reply */
15539 api_one_l2_arp_entries_get (vat_main_t * vam)
15541 vl_api_one_l2_arp_entries_get_t *mp;
15542 unformat_input_t *input = vam->input;
15547 /* Parse args required to build the message */
15548 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15550 if (unformat (input, "bd %d", &bd))
15554 errmsg ("parse error '%U'", format_unformat_error, input);
15561 errmsg ("Expected bridge domain!");
15565 M (ONE_L2_ARP_ENTRIES_GET, mp);
15566 mp->bd = clib_host_to_net_u32 (bd);
15571 /* wait for reply */
15577 api_one_stats_enable_disable (vat_main_t * vam)
15579 vl_api_one_stats_enable_disable_t *mp;
15580 unformat_input_t *input = vam->input;
15585 /* Parse args required to build the message */
15586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15588 if (unformat (input, "enable"))
15593 else if (unformat (input, "disable"))
15603 errmsg ("Value not set");
15607 M (ONE_STATS_ENABLE_DISABLE, mp);
15608 mp->is_enable = is_enable;
15613 /* wait for reply */
15619 api_show_one_stats_enable_disable (vat_main_t * vam)
15621 vl_api_show_one_stats_enable_disable_t *mp;
15624 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15629 /* wait for reply */
15635 api_show_one_map_request_mode (vat_main_t * vam)
15637 vl_api_show_one_map_request_mode_t *mp;
15640 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15645 /* wait for reply */
15650 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15653 api_one_map_request_mode (vat_main_t * vam)
15655 unformat_input_t *input = vam->input;
15656 vl_api_one_map_request_mode_t *mp;
15660 /* Parse args required to build the message */
15661 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15663 if (unformat (input, "dst-only"))
15665 else if (unformat (input, "src-dst"))
15669 errmsg ("parse error '%U'", format_unformat_error, input);
15674 M (ONE_MAP_REQUEST_MODE, mp);
15681 /* wait for reply */
15686 #define api_lisp_map_request_mode api_one_map_request_mode
15689 * Enable/disable ONE proxy ITR.
15691 * @param vam vpp API test context
15692 * @return return code
15695 api_one_pitr_set_locator_set (vat_main_t * vam)
15697 u8 ls_name_set = 0;
15698 unformat_input_t *input = vam->input;
15699 vl_api_one_pitr_set_locator_set_t *mp;
15704 /* Parse args required to build the message */
15705 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15707 if (unformat (input, "del"))
15709 else if (unformat (input, "locator-set %s", &ls_name))
15713 errmsg ("parse error '%U'", format_unformat_error, input);
15720 errmsg ("locator-set name not set!");
15724 M (ONE_PITR_SET_LOCATOR_SET, mp);
15726 mp->is_add = is_add;
15727 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15728 vec_free (ls_name);
15733 /* wait for reply */
15738 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15741 api_one_nsh_set_locator_set (vat_main_t * vam)
15743 u8 ls_name_set = 0;
15744 unformat_input_t *input = vam->input;
15745 vl_api_one_nsh_set_locator_set_t *mp;
15750 /* Parse args required to build the message */
15751 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15753 if (unformat (input, "del"))
15755 else if (unformat (input, "ls %s", &ls_name))
15759 errmsg ("parse error '%U'", format_unformat_error, input);
15764 if (!ls_name_set && is_add)
15766 errmsg ("locator-set name not set!");
15770 M (ONE_NSH_SET_LOCATOR_SET, mp);
15772 mp->is_add = is_add;
15773 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15774 vec_free (ls_name);
15779 /* wait for reply */
15785 api_show_one_pitr (vat_main_t * vam)
15787 vl_api_show_one_pitr_t *mp;
15790 if (!vam->json_output)
15792 print (vam->ofp, "%=20s", "lisp status:");
15795 M (SHOW_ONE_PITR, mp);
15799 /* Wait for a reply... */
15804 #define api_show_lisp_pitr api_show_one_pitr
15807 api_one_use_petr (vat_main_t * vam)
15809 unformat_input_t *input = vam->input;
15810 vl_api_one_use_petr_t *mp;
15815 clib_memset (&ip, 0, sizeof (ip));
15817 /* Parse args required to build the message */
15818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15820 if (unformat (input, "disable"))
15823 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15826 ip_addr_version (&ip) = AF_IP4;
15829 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15832 ip_addr_version (&ip) = AF_IP6;
15836 errmsg ("parse error '%U'", format_unformat_error, input);
15841 M (ONE_USE_PETR, mp);
15843 mp->is_add = is_add;
15846 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
15847 if (mp->ip_address.af)
15848 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
15850 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
15856 /* wait for reply */
15861 #define api_lisp_use_petr api_one_use_petr
15864 api_show_one_nsh_mapping (vat_main_t * vam)
15866 vl_api_show_one_use_petr_t *mp;
15869 if (!vam->json_output)
15871 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15874 M (SHOW_ONE_NSH_MAPPING, mp);
15878 /* Wait for a reply... */
15884 api_show_one_use_petr (vat_main_t * vam)
15886 vl_api_show_one_use_petr_t *mp;
15889 if (!vam->json_output)
15891 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15894 M (SHOW_ONE_USE_PETR, mp);
15898 /* Wait for a reply... */
15903 #define api_show_lisp_use_petr api_show_one_use_petr
15906 * Add/delete mapping between vni and vrf
15909 api_one_eid_table_add_del_map (vat_main_t * vam)
15911 unformat_input_t *input = vam->input;
15912 vl_api_one_eid_table_add_del_map_t *mp;
15913 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15914 u32 vni, vrf, bd_index;
15917 /* Parse args required to build the message */
15918 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15920 if (unformat (input, "del"))
15922 else if (unformat (input, "vrf %d", &vrf))
15924 else if (unformat (input, "bd_index %d", &bd_index))
15926 else if (unformat (input, "vni %d", &vni))
15932 if (!vni_set || (!vrf_set && !bd_index_set))
15934 errmsg ("missing arguments!");
15938 if (vrf_set && bd_index_set)
15940 errmsg ("error: both vrf and bd entered!");
15944 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15946 mp->is_add = is_add;
15947 mp->vni = htonl (vni);
15948 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15949 mp->is_l2 = bd_index_set;
15954 /* wait for reply */
15959 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15962 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15964 u32 *action = va_arg (*args, u32 *);
15967 if (unformat (input, "%s", &s))
15969 if (!strcmp ((char *) s, "no-action"))
15971 else if (!strcmp ((char *) s, "natively-forward"))
15973 else if (!strcmp ((char *) s, "send-map-request"))
15975 else if (!strcmp ((char *) s, "drop"))
15979 clib_warning ("invalid action: '%s'", s);
15991 * Add/del remote mapping to/from ONE control plane
15993 * @param vam vpp API test context
15994 * @return return code
15997 api_one_add_del_remote_mapping (vat_main_t * vam)
15999 unformat_input_t *input = vam->input;
16000 vl_api_one_add_del_remote_mapping_t *mp;
16002 lisp_eid_vat_t _eid, *eid = &_eid;
16003 lisp_eid_vat_t _seid, *seid = &_seid;
16004 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16005 u32 action = ~0, p, w, data_len;
16006 ip4_address_t rloc4;
16007 ip6_address_t rloc6;
16008 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16011 clib_memset (&rloc, 0, sizeof (rloc));
16013 /* Parse args required to build the message */
16014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16016 if (unformat (input, "del-all"))
16020 else if (unformat (input, "del"))
16024 else if (unformat (input, "add"))
16028 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16032 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16036 else if (unformat (input, "vni %d", &vni))
16040 else if (unformat (input, "p %d w %d", &p, &w))
16044 errmsg ("No RLOC configured for setting priority/weight!");
16047 curr_rloc->priority = p;
16048 curr_rloc->weight = w;
16050 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16052 rloc.ip_address.af = 0;
16053 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
16054 vec_add1 (rlocs, rloc);
16055 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16057 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16059 rloc.ip_address.af = 1;
16060 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
16061 vec_add1 (rlocs, rloc);
16062 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16064 else if (unformat (input, "action %U",
16065 unformat_negative_mapping_action, &action))
16071 clib_warning ("parse error '%U'", format_unformat_error, input);
16078 errmsg ("missing params!");
16082 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16084 errmsg ("no action set for negative map-reply!");
16088 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16090 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16091 mp->is_add = is_add;
16092 mp->vni = htonl (vni);
16093 mp->action = (u8) action;
16094 mp->is_src_dst = seid_set;
16095 mp->del_all = del_all;
16096 lisp_eid_put_vat (&mp->deid, eid);
16097 lisp_eid_put_vat (&mp->seid, seid);
16099 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16100 clib_memcpy (mp->rlocs, rlocs, data_len);
16106 /* Wait for a reply... */
16111 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16114 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16115 * forwarding entries in data-plane accordingly.
16117 * @param vam vpp API test context
16118 * @return return code
16121 api_one_add_del_adjacency (vat_main_t * vam)
16123 unformat_input_t *input = vam->input;
16124 vl_api_one_add_del_adjacency_t *mp;
16128 lisp_eid_vat_t leid, reid;
16130 leid.type = reid.type = (u8) ~ 0;
16132 /* Parse args required to build the message */
16133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16135 if (unformat (input, "del"))
16139 else if (unformat (input, "add"))
16143 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
16144 &reid.addr.ip, &reid.len))
16146 reid.type = 0; /* ipv4 */
16148 else if (unformat (input, "reid %U", unformat_ethernet_address,
16151 reid.type = 1; /* mac */
16153 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
16154 &leid.addr.ip, &leid.len))
16156 leid.type = 0; /* ipv4 */
16158 else if (unformat (input, "leid %U", unformat_ethernet_address,
16161 leid.type = 1; /* mac */
16163 else if (unformat (input, "vni %d", &vni))
16169 errmsg ("parse error '%U'", format_unformat_error, input);
16174 if ((u8) ~ 0 == reid.type)
16176 errmsg ("missing params!");
16180 if (leid.type != reid.type)
16182 errmsg ("remote and local EIDs are of different types!");
16186 M (ONE_ADD_DEL_ADJACENCY, mp);
16187 mp->is_add = is_add;
16188 mp->vni = htonl (vni);
16189 lisp_eid_put_vat (&mp->leid, &leid);
16190 lisp_eid_put_vat (&mp->reid, &reid);
16195 /* Wait for a reply... */
16200 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16203 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16205 u32 *mode = va_arg (*args, u32 *);
16207 if (unformat (input, "lisp"))
16209 else if (unformat (input, "vxlan"))
16218 api_gpe_get_encap_mode (vat_main_t * vam)
16220 vl_api_gpe_get_encap_mode_t *mp;
16223 /* Construct the API message */
16224 M (GPE_GET_ENCAP_MODE, mp);
16229 /* Wait for a reply... */
16235 api_gpe_set_encap_mode (vat_main_t * vam)
16237 unformat_input_t *input = vam->input;
16238 vl_api_gpe_set_encap_mode_t *mp;
16242 /* Parse args required to build the message */
16243 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16245 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16251 /* Construct the API message */
16252 M (GPE_SET_ENCAP_MODE, mp);
16254 mp->is_vxlan = mode;
16259 /* Wait for a reply... */
16265 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16267 unformat_input_t *input = vam->input;
16268 vl_api_gpe_add_del_iface_t *mp;
16269 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16270 u32 dp_table = 0, vni = 0;
16273 /* Parse args required to build the message */
16274 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16276 if (unformat (input, "up"))
16281 else if (unformat (input, "down"))
16286 else if (unformat (input, "table_id %d", &dp_table))
16290 else if (unformat (input, "bd_id %d", &dp_table))
16295 else if (unformat (input, "vni %d", &vni))
16303 if (action_set == 0)
16305 errmsg ("Action not set");
16308 if (dp_table_set == 0 || vni_set == 0)
16310 errmsg ("vni and dp_table must be set");
16314 /* Construct the API message */
16315 M (GPE_ADD_DEL_IFACE, mp);
16317 mp->is_add = is_add;
16318 mp->dp_table = clib_host_to_net_u32 (dp_table);
16320 mp->vni = clib_host_to_net_u32 (vni);
16325 /* Wait for a reply... */
16331 api_one_map_register_fallback_threshold (vat_main_t * vam)
16333 unformat_input_t *input = vam->input;
16334 vl_api_one_map_register_fallback_threshold_t *mp;
16339 /* Parse args required to build the message */
16340 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16342 if (unformat (input, "%u", &value))
16346 clib_warning ("parse error '%U'", format_unformat_error, input);
16353 errmsg ("fallback threshold value is missing!");
16357 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16358 mp->value = clib_host_to_net_u32 (value);
16363 /* Wait for a reply... */
16369 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16371 vl_api_show_one_map_register_fallback_threshold_t *mp;
16374 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16379 /* Wait for a reply... */
16385 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16387 u32 *proto = va_arg (*args, u32 *);
16389 if (unformat (input, "udp"))
16391 else if (unformat (input, "api"))
16400 api_one_set_transport_protocol (vat_main_t * vam)
16402 unformat_input_t *input = vam->input;
16403 vl_api_one_set_transport_protocol_t *mp;
16408 /* Parse args required to build the message */
16409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16411 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16415 clib_warning ("parse error '%U'", format_unformat_error, input);
16422 errmsg ("Transport protocol missing!");
16426 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16427 mp->protocol = (u8) protocol;
16432 /* Wait for a reply... */
16438 api_one_get_transport_protocol (vat_main_t * vam)
16440 vl_api_one_get_transport_protocol_t *mp;
16443 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16448 /* Wait for a reply... */
16454 api_one_map_register_set_ttl (vat_main_t * vam)
16456 unformat_input_t *input = vam->input;
16457 vl_api_one_map_register_set_ttl_t *mp;
16462 /* Parse args required to build the message */
16463 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16465 if (unformat (input, "%u", &ttl))
16469 clib_warning ("parse error '%U'", format_unformat_error, input);
16476 errmsg ("TTL value missing!");
16480 M (ONE_MAP_REGISTER_SET_TTL, mp);
16481 mp->ttl = clib_host_to_net_u32 (ttl);
16486 /* Wait for a reply... */
16492 api_show_one_map_register_ttl (vat_main_t * vam)
16494 vl_api_show_one_map_register_ttl_t *mp;
16497 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16502 /* Wait for a reply... */
16508 * Add/del map request itr rlocs from ONE control plane and updates
16510 * @param vam vpp API test context
16511 * @return return code
16514 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16516 unformat_input_t *input = vam->input;
16517 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16518 u8 *locator_set_name = 0;
16519 u8 locator_set_name_set = 0;
16523 /* Parse args required to build the message */
16524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16526 if (unformat (input, "del"))
16530 else if (unformat (input, "%_%v%_", &locator_set_name))
16532 locator_set_name_set = 1;
16536 clib_warning ("parse error '%U'", format_unformat_error, input);
16541 if (is_add && !locator_set_name_set)
16543 errmsg ("itr-rloc is not set!");
16547 if (is_add && vec_len (locator_set_name) > 64)
16549 errmsg ("itr-rloc locator-set name too long");
16550 vec_free (locator_set_name);
16554 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16555 mp->is_add = is_add;
16558 clib_memcpy (mp->locator_set_name, locator_set_name,
16559 vec_len (locator_set_name));
16563 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16565 vec_free (locator_set_name);
16570 /* Wait for a reply... */
16575 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16578 api_one_locator_dump (vat_main_t * vam)
16580 unformat_input_t *input = vam->input;
16581 vl_api_one_locator_dump_t *mp;
16582 vl_api_control_ping_t *mp_ping;
16583 u8 is_index_set = 0, is_name_set = 0;
16588 /* Parse args required to build the message */
16589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16591 if (unformat (input, "ls_name %_%v%_", &ls_name))
16595 else if (unformat (input, "ls_index %d", &ls_index))
16601 errmsg ("parse error '%U'", format_unformat_error, input);
16606 if (!is_index_set && !is_name_set)
16608 errmsg ("error: expected one of index or name!");
16612 if (is_index_set && is_name_set)
16614 errmsg ("error: only one param expected!");
16618 if (vec_len (ls_name) > 62)
16620 errmsg ("error: locator set name too long!");
16624 if (!vam->json_output)
16626 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16629 M (ONE_LOCATOR_DUMP, mp);
16630 mp->is_index_set = is_index_set;
16633 mp->ls_index = clib_host_to_net_u32 (ls_index);
16636 vec_add1 (ls_name, 0);
16637 strncpy ((char *) mp->ls_name, (char *) ls_name,
16638 sizeof (mp->ls_name) - 1);
16644 /* Use a control ping for synchronization */
16645 MPING (CONTROL_PING, mp_ping);
16648 /* Wait for a reply... */
16653 #define api_lisp_locator_dump api_one_locator_dump
16656 api_one_locator_set_dump (vat_main_t * vam)
16658 vl_api_one_locator_set_dump_t *mp;
16659 vl_api_control_ping_t *mp_ping;
16660 unformat_input_t *input = vam->input;
16664 /* Parse args required to build the message */
16665 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16667 if (unformat (input, "local"))
16671 else if (unformat (input, "remote"))
16677 errmsg ("parse error '%U'", format_unformat_error, input);
16682 if (!vam->json_output)
16684 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16687 M (ONE_LOCATOR_SET_DUMP, mp);
16689 mp->filter = filter;
16694 /* Use a control ping for synchronization */
16695 MPING (CONTROL_PING, mp_ping);
16698 /* Wait for a reply... */
16703 #define api_lisp_locator_set_dump api_one_locator_set_dump
16706 api_one_eid_table_map_dump (vat_main_t * vam)
16710 unformat_input_t *input = vam->input;
16711 vl_api_one_eid_table_map_dump_t *mp;
16712 vl_api_control_ping_t *mp_ping;
16715 /* Parse args required to build the message */
16716 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16718 if (unformat (input, "l2"))
16723 else if (unformat (input, "l3"))
16730 errmsg ("parse error '%U'", format_unformat_error, input);
16737 errmsg ("expected one of 'l2' or 'l3' parameter!");
16741 if (!vam->json_output)
16743 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16746 M (ONE_EID_TABLE_MAP_DUMP, mp);
16752 /* Use a control ping for synchronization */
16753 MPING (CONTROL_PING, mp_ping);
16756 /* Wait for a reply... */
16761 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16764 api_one_eid_table_vni_dump (vat_main_t * vam)
16766 vl_api_one_eid_table_vni_dump_t *mp;
16767 vl_api_control_ping_t *mp_ping;
16770 if (!vam->json_output)
16772 print (vam->ofp, "VNI");
16775 M (ONE_EID_TABLE_VNI_DUMP, mp);
16780 /* Use a control ping for synchronization */
16781 MPING (CONTROL_PING, mp_ping);
16784 /* Wait for a reply... */
16789 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16792 api_one_eid_table_dump (vat_main_t * vam)
16794 unformat_input_t *i = vam->input;
16795 vl_api_one_eid_table_dump_t *mp;
16796 vl_api_control_ping_t *mp_ping;
16800 lisp_eid_vat_t eid;
16803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16806 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
16812 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
16817 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
16822 else if (unformat (i, "vni %d", &t))
16826 else if (unformat (i, "local"))
16830 else if (unformat (i, "remote"))
16836 errmsg ("parse error '%U'", format_unformat_error, i);
16841 if (!vam->json_output)
16843 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16844 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16847 M (ONE_EID_TABLE_DUMP, mp);
16849 mp->filter = filter;
16853 mp->vni = htonl (vni);
16854 lisp_eid_put_vat (&mp->eid, &eid);
16860 /* Use a control ping for synchronization */
16861 MPING (CONTROL_PING, mp_ping);
16864 /* Wait for a reply... */
16869 #define api_lisp_eid_table_dump api_one_eid_table_dump
16872 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16874 unformat_input_t *i = vam->input;
16875 vl_api_gpe_fwd_entries_get_t *mp;
16880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16882 if (unformat (i, "vni %d", &vni))
16888 errmsg ("parse error '%U'", format_unformat_error, i);
16895 errmsg ("vni not set!");
16899 if (!vam->json_output)
16901 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16905 M (GPE_FWD_ENTRIES_GET, mp);
16906 mp->vni = clib_host_to_net_u32 (vni);
16911 /* Wait for a reply... */
16916 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16917 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16918 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16919 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16920 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16921 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16922 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16923 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16926 api_one_adjacencies_get (vat_main_t * vam)
16928 unformat_input_t *i = vam->input;
16929 vl_api_one_adjacencies_get_t *mp;
16934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16936 if (unformat (i, "vni %d", &vni))
16942 errmsg ("parse error '%U'", format_unformat_error, i);
16949 errmsg ("vni not set!");
16953 if (!vam->json_output)
16955 print (vam->ofp, "%s %40s", "leid", "reid");
16958 M (ONE_ADJACENCIES_GET, mp);
16959 mp->vni = clib_host_to_net_u32 (vni);
16964 /* Wait for a reply... */
16969 #define api_lisp_adjacencies_get api_one_adjacencies_get
16972 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16974 unformat_input_t *i = vam->input;
16975 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16977 u8 ip_family_set = 0, is_ip4 = 1;
16979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16981 if (unformat (i, "ip4"))
16986 else if (unformat (i, "ip6"))
16993 errmsg ("parse error '%U'", format_unformat_error, i);
16998 if (!ip_family_set)
17000 errmsg ("ip family not set!");
17004 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17005 mp->is_ip4 = is_ip4;
17010 /* Wait for a reply... */
17016 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17018 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17021 if (!vam->json_output)
17023 print (vam->ofp, "VNIs");
17026 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17031 /* Wait for a reply... */
17037 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17039 unformat_input_t *i = vam->input;
17040 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17042 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17043 struct in_addr ip4;
17044 struct in6_addr ip6;
17045 u32 table_id = 0, nh_sw_if_index = ~0;
17047 clib_memset (&ip4, 0, sizeof (ip4));
17048 clib_memset (&ip6, 0, sizeof (ip6));
17050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17052 if (unformat (i, "del"))
17054 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17055 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17060 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17061 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17066 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17070 nh_sw_if_index = ~0;
17072 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17076 nh_sw_if_index = ~0;
17078 else if (unformat (i, "table %d", &table_id))
17082 errmsg ("parse error '%U'", format_unformat_error, i);
17089 errmsg ("nh addr not set!");
17093 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17094 mp->is_add = is_add;
17095 mp->table_id = clib_host_to_net_u32 (table_id);
17096 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17097 mp->nh_addr.af = is_ip4 ? 0 : 1;
17099 clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
17101 clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
17106 /* Wait for a reply... */
17112 api_one_map_server_dump (vat_main_t * vam)
17114 vl_api_one_map_server_dump_t *mp;
17115 vl_api_control_ping_t *mp_ping;
17118 if (!vam->json_output)
17120 print (vam->ofp, "%=20s", "Map server");
17123 M (ONE_MAP_SERVER_DUMP, mp);
17127 /* Use a control ping for synchronization */
17128 MPING (CONTROL_PING, mp_ping);
17131 /* Wait for a reply... */
17136 #define api_lisp_map_server_dump api_one_map_server_dump
17139 api_one_map_resolver_dump (vat_main_t * vam)
17141 vl_api_one_map_resolver_dump_t *mp;
17142 vl_api_control_ping_t *mp_ping;
17145 if (!vam->json_output)
17147 print (vam->ofp, "%=20s", "Map resolver");
17150 M (ONE_MAP_RESOLVER_DUMP, mp);
17154 /* Use a control ping for synchronization */
17155 MPING (CONTROL_PING, mp_ping);
17158 /* Wait for a reply... */
17163 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17166 api_one_stats_flush (vat_main_t * vam)
17168 vl_api_one_stats_flush_t *mp;
17171 M (ONE_STATS_FLUSH, mp);
17178 api_one_stats_dump (vat_main_t * vam)
17180 vl_api_one_stats_dump_t *mp;
17181 vl_api_control_ping_t *mp_ping;
17184 M (ONE_STATS_DUMP, mp);
17188 /* Use a control ping for synchronization */
17189 MPING (CONTROL_PING, mp_ping);
17192 /* Wait for a reply... */
17198 api_show_one_status (vat_main_t * vam)
17200 vl_api_show_one_status_t *mp;
17203 if (!vam->json_output)
17205 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17208 M (SHOW_ONE_STATUS, mp);
17211 /* Wait for a reply... */
17216 #define api_show_lisp_status api_show_one_status
17219 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17221 vl_api_gpe_fwd_entry_path_dump_t *mp;
17222 vl_api_control_ping_t *mp_ping;
17223 unformat_input_t *i = vam->input;
17224 u32 fwd_entry_index = ~0;
17227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17229 if (unformat (i, "index %d", &fwd_entry_index))
17235 if (~0 == fwd_entry_index)
17237 errmsg ("no index specified!");
17241 if (!vam->json_output)
17243 print (vam->ofp, "first line");
17246 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17250 /* Use a control ping for synchronization */
17251 MPING (CONTROL_PING, mp_ping);
17254 /* Wait for a reply... */
17260 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17262 vl_api_one_get_map_request_itr_rlocs_t *mp;
17265 if (!vam->json_output)
17267 print (vam->ofp, "%=20s", "itr-rlocs:");
17270 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17273 /* Wait for a reply... */
17278 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17281 api_af_packet_create (vat_main_t * vam)
17283 unformat_input_t *i = vam->input;
17284 vl_api_af_packet_create_t *mp;
17285 u8 *host_if_name = 0;
17287 u8 random_hw_addr = 1;
17290 clib_memset (hw_addr, 0, sizeof (hw_addr));
17292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17294 if (unformat (i, "name %s", &host_if_name))
17295 vec_add1 (host_if_name, 0);
17296 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17297 random_hw_addr = 0;
17302 if (!vec_len (host_if_name))
17304 errmsg ("host-interface name must be specified");
17308 if (vec_len (host_if_name) > 64)
17310 errmsg ("host-interface name too long");
17314 M (AF_PACKET_CREATE, mp);
17316 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17317 clib_memcpy (mp->hw_addr, hw_addr, 6);
17318 mp->use_random_hw_addr = random_hw_addr;
17319 vec_free (host_if_name);
17327 fprintf (vam->ofp ? vam->ofp : stderr,
17328 " new sw_if_index = %d\n", vam->sw_if_index);
17335 api_af_packet_delete (vat_main_t * vam)
17337 unformat_input_t *i = vam->input;
17338 vl_api_af_packet_delete_t *mp;
17339 u8 *host_if_name = 0;
17342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17344 if (unformat (i, "name %s", &host_if_name))
17345 vec_add1 (host_if_name, 0);
17350 if (!vec_len (host_if_name))
17352 errmsg ("host-interface name must be specified");
17356 if (vec_len (host_if_name) > 64)
17358 errmsg ("host-interface name too long");
17362 M (AF_PACKET_DELETE, mp);
17364 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17365 vec_free (host_if_name);
17372 static void vl_api_af_packet_details_t_handler
17373 (vl_api_af_packet_details_t * mp)
17375 vat_main_t *vam = &vat_main;
17377 print (vam->ofp, "%-16s %d",
17378 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17381 static void vl_api_af_packet_details_t_handler_json
17382 (vl_api_af_packet_details_t * mp)
17384 vat_main_t *vam = &vat_main;
17385 vat_json_node_t *node = NULL;
17387 if (VAT_JSON_ARRAY != vam->json_tree.type)
17389 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17390 vat_json_init_array (&vam->json_tree);
17392 node = vat_json_array_add (&vam->json_tree);
17394 vat_json_init_object (node);
17395 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17396 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17400 api_af_packet_dump (vat_main_t * vam)
17402 vl_api_af_packet_dump_t *mp;
17403 vl_api_control_ping_t *mp_ping;
17406 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17407 /* Get list of tap interfaces */
17408 M (AF_PACKET_DUMP, mp);
17411 /* Use a control ping for synchronization */
17412 MPING (CONTROL_PING, mp_ping);
17420 api_policer_add_del (vat_main_t * vam)
17422 unformat_input_t *i = vam->input;
17423 vl_api_policer_add_del_t *mp;
17433 u8 color_aware = 0;
17434 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17437 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17438 conform_action.dscp = 0;
17439 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17440 exceed_action.dscp = 0;
17441 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17442 violate_action.dscp = 0;
17444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17446 if (unformat (i, "del"))
17448 else if (unformat (i, "name %s", &name))
17449 vec_add1 (name, 0);
17450 else if (unformat (i, "cir %u", &cir))
17452 else if (unformat (i, "eir %u", &eir))
17454 else if (unformat (i, "cb %u", &cb))
17456 else if (unformat (i, "eb %u", &eb))
17458 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17461 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17464 else if (unformat (i, "type %U", unformat_policer_type, &type))
17466 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17469 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17472 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17475 else if (unformat (i, "color-aware"))
17481 if (!vec_len (name))
17483 errmsg ("policer name must be specified");
17487 if (vec_len (name) > 64)
17489 errmsg ("policer name too long");
17493 M (POLICER_ADD_DEL, mp);
17495 clib_memcpy (mp->name, name, vec_len (name));
17497 mp->is_add = is_add;
17498 mp->cir = ntohl (cir);
17499 mp->eir = ntohl (eir);
17500 mp->cb = clib_net_to_host_u64 (cb);
17501 mp->eb = clib_net_to_host_u64 (eb);
17502 mp->rate_type = rate_type;
17503 mp->round_type = round_type;
17505 mp->conform_action.type = conform_action.action_type;
17506 mp->conform_action.dscp = conform_action.dscp;
17507 mp->exceed_action.type = exceed_action.action_type;
17508 mp->exceed_action.dscp = exceed_action.dscp;
17509 mp->violate_action.type = violate_action.action_type;
17510 mp->violate_action.dscp = violate_action.dscp;
17511 mp->color_aware = color_aware;
17519 api_policer_dump (vat_main_t * vam)
17521 unformat_input_t *i = vam->input;
17522 vl_api_policer_dump_t *mp;
17523 vl_api_control_ping_t *mp_ping;
17524 u8 *match_name = 0;
17525 u8 match_name_valid = 0;
17528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17530 if (unformat (i, "name %s", &match_name))
17532 vec_add1 (match_name, 0);
17533 match_name_valid = 1;
17539 M (POLICER_DUMP, mp);
17540 mp->match_name_valid = match_name_valid;
17541 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17542 vec_free (match_name);
17546 /* Use a control ping for synchronization */
17547 MPING (CONTROL_PING, mp_ping);
17550 /* Wait for a reply... */
17556 api_policer_classify_set_interface (vat_main_t * vam)
17558 unformat_input_t *i = vam->input;
17559 vl_api_policer_classify_set_interface_t *mp;
17561 int sw_if_index_set;
17562 u32 ip4_table_index = ~0;
17563 u32 ip6_table_index = ~0;
17564 u32 l2_table_index = ~0;
17568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17570 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17571 sw_if_index_set = 1;
17572 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17573 sw_if_index_set = 1;
17574 else if (unformat (i, "del"))
17576 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17578 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17580 else if (unformat (i, "l2-table %d", &l2_table_index))
17584 clib_warning ("parse error '%U'", format_unformat_error, i);
17589 if (sw_if_index_set == 0)
17591 errmsg ("missing interface name or sw_if_index");
17595 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17597 mp->sw_if_index = ntohl (sw_if_index);
17598 mp->ip4_table_index = ntohl (ip4_table_index);
17599 mp->ip6_table_index = ntohl (ip6_table_index);
17600 mp->l2_table_index = ntohl (l2_table_index);
17601 mp->is_add = is_add;
17609 api_policer_classify_dump (vat_main_t * vam)
17611 unformat_input_t *i = vam->input;
17612 vl_api_policer_classify_dump_t *mp;
17613 vl_api_control_ping_t *mp_ping;
17614 u8 type = POLICER_CLASSIFY_N_TABLES;
17617 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17621 errmsg ("classify table type must be specified");
17625 if (!vam->json_output)
17627 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17630 M (POLICER_CLASSIFY_DUMP, mp);
17635 /* Use a control ping for synchronization */
17636 MPING (CONTROL_PING, mp_ping);
17639 /* Wait for a reply... */
17645 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17647 vl_api_fib_path_nh_proto_t proto =
17648 va_arg (*args, vl_api_fib_path_nh_proto_t);
17652 case FIB_API_PATH_NH_PROTO_IP4:
17653 s = format (s, "ip4");
17655 case FIB_API_PATH_NH_PROTO_IP6:
17656 s = format (s, "ip6");
17658 case FIB_API_PATH_NH_PROTO_MPLS:
17659 s = format (s, "mpls");
17661 case FIB_API_PATH_NH_PROTO_BIER:
17662 s = format (s, "bier");
17664 case FIB_API_PATH_NH_PROTO_ETHERNET:
17665 s = format (s, "ethernet");
17673 format_vl_api_ip_address_union (u8 * s, va_list * args)
17675 vl_api_address_family_t af = va_arg (*args, int);
17676 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17681 s = format (s, "%U", format_ip4_address, u->ip4);
17684 s = format (s, "%U", format_ip6_address, u->ip6);
17691 format_vl_api_fib_path_type (u8 * s, va_list * args)
17693 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17697 case FIB_API_PATH_TYPE_NORMAL:
17698 s = format (s, "normal");
17700 case FIB_API_PATH_TYPE_LOCAL:
17701 s = format (s, "local");
17703 case FIB_API_PATH_TYPE_DROP:
17704 s = format (s, "drop");
17706 case FIB_API_PATH_TYPE_UDP_ENCAP:
17707 s = format (s, "udp-encap");
17709 case FIB_API_PATH_TYPE_BIER_IMP:
17710 s = format (s, "bier-imp");
17712 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17713 s = format (s, "unreach");
17715 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17716 s = format (s, "prohibit");
17718 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17719 s = format (s, "src-lookup");
17721 case FIB_API_PATH_TYPE_DVR:
17722 s = format (s, "dvr");
17724 case FIB_API_PATH_TYPE_INTERFACE_RX:
17725 s = format (s, "interface-rx");
17727 case FIB_API_PATH_TYPE_CLASSIFY:
17728 s = format (s, "classify");
17736 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17739 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17740 ntohl (fp->weight), ntohl (fp->sw_if_index),
17741 format_vl_api_fib_path_type, fp->type,
17742 format_fib_api_path_nh_proto, fp->proto,
17743 format_vl_api_ip_address_union, &fp->nh.address);
17747 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17748 vl_api_fib_path_t * fp)
17750 struct in_addr ip4;
17751 struct in6_addr ip6;
17753 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17754 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17755 vat_json_object_add_uint (node, "type", fp->type);
17756 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17757 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17759 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17760 vat_json_object_add_ip4 (node, "next_hop", ip4);
17762 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17764 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17765 vat_json_object_add_ip6 (node, "next_hop", ip6);
17770 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17772 vat_main_t *vam = &vat_main;
17773 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17774 vl_api_fib_path_t *fp;
17777 print (vam->ofp, "sw_if_index %d via:",
17778 ntohl (mp->mt_tunnel.mt_sw_if_index));
17779 fp = mp->mt_tunnel.mt_paths;
17780 for (i = 0; i < count; i++)
17782 vl_api_fib_path_print (vam, fp);
17786 print (vam->ofp, "");
17789 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17790 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17793 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17795 vat_main_t *vam = &vat_main;
17796 vat_json_node_t *node = NULL;
17797 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17798 vl_api_fib_path_t *fp;
17801 if (VAT_JSON_ARRAY != vam->json_tree.type)
17803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17804 vat_json_init_array (&vam->json_tree);
17806 node = vat_json_array_add (&vam->json_tree);
17808 vat_json_init_object (node);
17809 vat_json_object_add_uint (node, "sw_if_index",
17810 ntohl (mp->mt_tunnel.mt_sw_if_index));
17812 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17814 fp = mp->mt_tunnel.mt_paths;
17815 for (i = 0; i < count; i++)
17817 vl_api_mpls_fib_path_json_print (node, fp);
17823 api_mpls_tunnel_dump (vat_main_t * vam)
17825 vl_api_mpls_tunnel_dump_t *mp;
17826 vl_api_control_ping_t *mp_ping;
17829 M (MPLS_TUNNEL_DUMP, mp);
17833 /* Use a control ping for synchronization */
17834 MPING (CONTROL_PING, mp_ping);
17841 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17842 #define vl_api_mpls_table_details_t_print vl_noop_handler
17846 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17848 vat_main_t *vam = &vat_main;
17850 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17853 static void vl_api_mpls_table_details_t_handler_json
17854 (vl_api_mpls_table_details_t * mp)
17856 vat_main_t *vam = &vat_main;
17857 vat_json_node_t *node = NULL;
17859 if (VAT_JSON_ARRAY != vam->json_tree.type)
17861 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17862 vat_json_init_array (&vam->json_tree);
17864 node = vat_json_array_add (&vam->json_tree);
17866 vat_json_init_object (node);
17867 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17871 api_mpls_table_dump (vat_main_t * vam)
17873 vl_api_mpls_table_dump_t *mp;
17874 vl_api_control_ping_t *mp_ping;
17877 M (MPLS_TABLE_DUMP, mp);
17880 /* Use a control ping for synchronization */
17881 MPING (CONTROL_PING, mp_ping);
17888 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17889 #define vl_api_mpls_route_details_t_print vl_noop_handler
17892 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17894 vat_main_t *vam = &vat_main;
17895 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17896 vl_api_fib_path_t *fp;
17900 "table-id %d, label %u, ess_bit %u",
17901 ntohl (mp->mr_route.mr_table_id),
17902 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17903 fp = mp->mr_route.mr_paths;
17904 for (i = 0; i < count; i++)
17906 vl_api_fib_path_print (vam, fp);
17911 static void vl_api_mpls_route_details_t_handler_json
17912 (vl_api_mpls_route_details_t * mp)
17914 vat_main_t *vam = &vat_main;
17915 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17916 vat_json_node_t *node = NULL;
17917 vl_api_fib_path_t *fp;
17920 if (VAT_JSON_ARRAY != vam->json_tree.type)
17922 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17923 vat_json_init_array (&vam->json_tree);
17925 node = vat_json_array_add (&vam->json_tree);
17927 vat_json_init_object (node);
17928 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17929 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17930 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17931 vat_json_object_add_uint (node, "path_count", count);
17932 fp = mp->mr_route.mr_paths;
17933 for (i = 0; i < count; i++)
17935 vl_api_mpls_fib_path_json_print (node, fp);
17941 api_mpls_route_dump (vat_main_t * vam)
17943 unformat_input_t *input = vam->input;
17944 vl_api_mpls_route_dump_t *mp;
17945 vl_api_control_ping_t *mp_ping;
17949 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17951 if (unformat (input, "table_id %d", &table_id))
17956 if (table_id == ~0)
17958 errmsg ("missing table id");
17962 M (MPLS_ROUTE_DUMP, mp);
17964 mp->table.mt_table_id = ntohl (table_id);
17967 /* Use a control ping for synchronization */
17968 MPING (CONTROL_PING, mp_ping);
17975 #define vl_api_ip_table_details_t_endian vl_noop_handler
17976 #define vl_api_ip_table_details_t_print vl_noop_handler
17979 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17981 vat_main_t *vam = &vat_main;
17984 "%s; table-id %d, prefix %U/%d",
17985 mp->table.name, ntohl (mp->table.table_id));
17989 static void vl_api_ip_table_details_t_handler_json
17990 (vl_api_ip_table_details_t * mp)
17992 vat_main_t *vam = &vat_main;
17993 vat_json_node_t *node = NULL;
17995 if (VAT_JSON_ARRAY != vam->json_tree.type)
17997 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17998 vat_json_init_array (&vam->json_tree);
18000 node = vat_json_array_add (&vam->json_tree);
18002 vat_json_init_object (node);
18003 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
18007 api_ip_table_dump (vat_main_t * vam)
18009 vl_api_ip_table_dump_t *mp;
18010 vl_api_control_ping_t *mp_ping;
18013 M (IP_TABLE_DUMP, mp);
18016 /* Use a control ping for synchronization */
18017 MPING (CONTROL_PING, mp_ping);
18025 api_ip_mtable_dump (vat_main_t * vam)
18027 vl_api_ip_mtable_dump_t *mp;
18028 vl_api_control_ping_t *mp_ping;
18031 M (IP_MTABLE_DUMP, mp);
18034 /* Use a control ping for synchronization */
18035 MPING (CONTROL_PING, mp_ping);
18043 api_ip_mroute_dump (vat_main_t * vam)
18045 unformat_input_t *input = vam->input;
18046 vl_api_control_ping_t *mp_ping;
18047 vl_api_ip_mroute_dump_t *mp;
18052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18054 if (unformat (input, "table_id %d", &table_id))
18056 else if (unformat (input, "ip6"))
18058 else if (unformat (input, "ip4"))
18063 if (table_id == ~0)
18065 errmsg ("missing table id");
18069 M (IP_MROUTE_DUMP, mp);
18070 mp->table.table_id = table_id;
18071 mp->table.is_ip6 = is_ip6;
18074 /* Use a control ping for synchronization */
18075 MPING (CONTROL_PING, mp_ping);
18082 #define vl_api_ip_route_details_t_endian vl_noop_handler
18083 #define vl_api_ip_route_details_t_print vl_noop_handler
18086 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
18088 vat_main_t *vam = &vat_main;
18089 u8 count = mp->route.n_paths;
18090 vl_api_fib_path_t *fp;
18094 "table-id %d, prefix %U/%d",
18095 ntohl (mp->route.table_id),
18096 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
18097 for (i = 0; i < count; i++)
18099 fp = &mp->route.paths[i];
18101 vl_api_fib_path_print (vam, fp);
18106 static void vl_api_ip_route_details_t_handler_json
18107 (vl_api_ip_route_details_t * mp)
18109 vat_main_t *vam = &vat_main;
18110 u8 count = mp->route.n_paths;
18111 vat_json_node_t *node = NULL;
18112 struct in_addr ip4;
18113 struct in6_addr ip6;
18114 vl_api_fib_path_t *fp;
18117 if (VAT_JSON_ARRAY != vam->json_tree.type)
18119 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18120 vat_json_init_array (&vam->json_tree);
18122 node = vat_json_array_add (&vam->json_tree);
18124 vat_json_init_object (node);
18125 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
18126 if (ADDRESS_IP6 == mp->route.prefix.address.af)
18128 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
18129 vat_json_object_add_ip6 (node, "prefix", ip6);
18133 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
18134 vat_json_object_add_ip4 (node, "prefix", ip4);
18136 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
18137 vat_json_object_add_uint (node, "path_count", count);
18138 for (i = 0; i < count; i++)
18140 fp = &mp->route.paths[i];
18141 vl_api_mpls_fib_path_json_print (node, fp);
18146 api_ip_route_dump (vat_main_t * vam)
18148 unformat_input_t *input = vam->input;
18149 vl_api_ip_route_dump_t *mp;
18150 vl_api_control_ping_t *mp_ping;
18156 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18158 if (unformat (input, "table_id %d", &table_id))
18160 else if (unformat (input, "ip6"))
18162 else if (unformat (input, "ip4"))
18167 if (table_id == ~0)
18169 errmsg ("missing table id");
18173 M (IP_ROUTE_DUMP, mp);
18175 mp->table.table_id = table_id;
18176 mp->table.is_ip6 = is_ip6;
18180 /* Use a control ping for synchronization */
18181 MPING (CONTROL_PING, mp_ping);
18189 api_classify_table_ids (vat_main_t * vam)
18191 vl_api_classify_table_ids_t *mp;
18194 /* Construct the API message */
18195 M (CLASSIFY_TABLE_IDS, mp);
18204 api_classify_table_by_interface (vat_main_t * vam)
18206 unformat_input_t *input = vam->input;
18207 vl_api_classify_table_by_interface_t *mp;
18209 u32 sw_if_index = ~0;
18211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18213 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18215 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18220 if (sw_if_index == ~0)
18222 errmsg ("missing interface name or sw_if_index");
18226 /* Construct the API message */
18227 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18229 mp->sw_if_index = ntohl (sw_if_index);
18237 api_classify_table_info (vat_main_t * vam)
18239 unformat_input_t *input = vam->input;
18240 vl_api_classify_table_info_t *mp;
18244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18246 if (unformat (input, "table_id %d", &table_id))
18251 if (table_id == ~0)
18253 errmsg ("missing table id");
18257 /* Construct the API message */
18258 M (CLASSIFY_TABLE_INFO, mp);
18260 mp->table_id = ntohl (table_id);
18268 api_classify_session_dump (vat_main_t * vam)
18270 unformat_input_t *input = vam->input;
18271 vl_api_classify_session_dump_t *mp;
18272 vl_api_control_ping_t *mp_ping;
18276 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18278 if (unformat (input, "table_id %d", &table_id))
18283 if (table_id == ~0)
18285 errmsg ("missing table id");
18289 /* Construct the API message */
18290 M (CLASSIFY_SESSION_DUMP, mp);
18292 mp->table_id = ntohl (table_id);
18295 /* Use a control ping for synchronization */
18296 MPING (CONTROL_PING, mp_ping);
18304 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18306 vat_main_t *vam = &vat_main;
18308 print (vam->ofp, "collector_address %U, collector_port %d, "
18309 "src_address %U, vrf_id %d, path_mtu %u, "
18310 "template_interval %u, udp_checksum %d",
18311 format_ip4_address, mp->collector_address,
18312 ntohs (mp->collector_port),
18313 format_ip4_address, mp->src_address,
18314 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18315 ntohl (mp->template_interval), mp->udp_checksum);
18318 vam->result_ready = 1;
18322 vl_api_ipfix_exporter_details_t_handler_json
18323 (vl_api_ipfix_exporter_details_t * mp)
18325 vat_main_t *vam = &vat_main;
18326 vat_json_node_t node;
18327 struct in_addr collector_address;
18328 struct in_addr src_address;
18330 vat_json_init_object (&node);
18331 clib_memcpy (&collector_address, &mp->collector_address,
18332 sizeof (collector_address));
18333 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18334 vat_json_object_add_uint (&node, "collector_port",
18335 ntohs (mp->collector_port));
18336 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18337 vat_json_object_add_ip4 (&node, "src_address", src_address);
18338 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18339 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18340 vat_json_object_add_uint (&node, "template_interval",
18341 ntohl (mp->template_interval));
18342 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18344 vat_json_print (vam->ofp, &node);
18345 vat_json_free (&node);
18347 vam->result_ready = 1;
18351 api_ipfix_exporter_dump (vat_main_t * vam)
18353 vl_api_ipfix_exporter_dump_t *mp;
18356 /* Construct the API message */
18357 M (IPFIX_EXPORTER_DUMP, mp);
18366 api_ipfix_classify_stream_dump (vat_main_t * vam)
18368 vl_api_ipfix_classify_stream_dump_t *mp;
18371 /* Construct the API message */
18372 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18383 vl_api_ipfix_classify_stream_details_t_handler
18384 (vl_api_ipfix_classify_stream_details_t * mp)
18386 vat_main_t *vam = &vat_main;
18387 print (vam->ofp, "domain_id %d, src_port %d",
18388 ntohl (mp->domain_id), ntohs (mp->src_port));
18390 vam->result_ready = 1;
18394 vl_api_ipfix_classify_stream_details_t_handler_json
18395 (vl_api_ipfix_classify_stream_details_t * mp)
18397 vat_main_t *vam = &vat_main;
18398 vat_json_node_t node;
18400 vat_json_init_object (&node);
18401 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18402 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18404 vat_json_print (vam->ofp, &node);
18405 vat_json_free (&node);
18407 vam->result_ready = 1;
18411 api_ipfix_classify_table_dump (vat_main_t * vam)
18413 vl_api_ipfix_classify_table_dump_t *mp;
18414 vl_api_control_ping_t *mp_ping;
18417 if (!vam->json_output)
18419 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18420 "transport_protocol");
18423 /* Construct the API message */
18424 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18429 /* Use a control ping for synchronization */
18430 MPING (CONTROL_PING, mp_ping);
18438 vl_api_ipfix_classify_table_details_t_handler
18439 (vl_api_ipfix_classify_table_details_t * mp)
18441 vat_main_t *vam = &vat_main;
18442 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18443 mp->transport_protocol);
18447 vl_api_ipfix_classify_table_details_t_handler_json
18448 (vl_api_ipfix_classify_table_details_t * mp)
18450 vat_json_node_t *node = NULL;
18451 vat_main_t *vam = &vat_main;
18453 if (VAT_JSON_ARRAY != vam->json_tree.type)
18455 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18456 vat_json_init_array (&vam->json_tree);
18459 node = vat_json_array_add (&vam->json_tree);
18460 vat_json_init_object (node);
18462 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18463 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18464 vat_json_object_add_uint (node, "transport_protocol",
18465 mp->transport_protocol);
18469 api_sw_interface_span_enable_disable (vat_main_t * vam)
18471 unformat_input_t *i = vam->input;
18472 vl_api_sw_interface_span_enable_disable_t *mp;
18473 u32 src_sw_if_index = ~0;
18474 u32 dst_sw_if_index = ~0;
18479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18482 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18484 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18488 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18490 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18492 else if (unformat (i, "disable"))
18494 else if (unformat (i, "rx"))
18496 else if (unformat (i, "tx"))
18498 else if (unformat (i, "both"))
18500 else if (unformat (i, "l2"))
18506 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18508 mp->sw_if_index_from = htonl (src_sw_if_index);
18509 mp->sw_if_index_to = htonl (dst_sw_if_index);
18519 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18522 vat_main_t *vam = &vat_main;
18523 u8 *sw_if_from_name = 0;
18524 u8 *sw_if_to_name = 0;
18525 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18526 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18527 char *states[] = { "none", "rx", "tx", "both" };
18531 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18533 if ((u32) p->value[0] == sw_if_index_from)
18535 sw_if_from_name = (u8 *)(p->key);
18539 if ((u32) p->value[0] == sw_if_index_to)
18541 sw_if_to_name = (u8 *)(p->key);
18542 if (sw_if_from_name)
18547 print (vam->ofp, "%20s => %20s (%s) %s",
18548 sw_if_from_name, sw_if_to_name, states[mp->state],
18549 mp->is_l2 ? "l2" : "device");
18553 vl_api_sw_interface_span_details_t_handler_json
18554 (vl_api_sw_interface_span_details_t * mp)
18556 vat_main_t *vam = &vat_main;
18557 vat_json_node_t *node = NULL;
18558 u8 *sw_if_from_name = 0;
18559 u8 *sw_if_to_name = 0;
18560 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18561 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18565 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18567 if ((u32) p->value[0] == sw_if_index_from)
18569 sw_if_from_name = (u8 *)(p->key);
18573 if ((u32) p->value[0] == sw_if_index_to)
18575 sw_if_to_name = (u8 *)(p->key);
18576 if (sw_if_from_name)
18582 if (VAT_JSON_ARRAY != vam->json_tree.type)
18584 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18585 vat_json_init_array (&vam->json_tree);
18587 node = vat_json_array_add (&vam->json_tree);
18589 vat_json_init_object (node);
18590 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18591 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18592 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18593 if (0 != sw_if_to_name)
18595 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18597 vat_json_object_add_uint (node, "state", mp->state);
18598 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18602 api_sw_interface_span_dump (vat_main_t * vam)
18604 unformat_input_t *input = vam->input;
18605 vl_api_sw_interface_span_dump_t *mp;
18606 vl_api_control_ping_t *mp_ping;
18610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18612 if (unformat (input, "l2"))
18618 M (SW_INTERFACE_SPAN_DUMP, mp);
18622 /* Use a control ping for synchronization */
18623 MPING (CONTROL_PING, mp_ping);
18631 api_pg_create_interface (vat_main_t * vam)
18633 unformat_input_t *input = vam->input;
18634 vl_api_pg_create_interface_t *mp;
18636 u32 if_id = ~0, gso_size = 0;
18637 u8 gso_enabled = 0;
18639 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18641 if (unformat (input, "if_id %d", &if_id))
18643 else if (unformat (input, "gso-enabled"))
18646 if (unformat (input, "gso-size %u", &gso_size))
18650 errmsg ("missing gso-size");
18659 errmsg ("missing pg interface index");
18663 /* Construct the API message */
18664 M (PG_CREATE_INTERFACE, mp);
18666 mp->interface_id = ntohl (if_id);
18667 mp->gso_enabled = gso_enabled;
18675 api_pg_capture (vat_main_t * vam)
18677 unformat_input_t *input = vam->input;
18678 vl_api_pg_capture_t *mp;
18683 u8 pcap_file_set = 0;
18686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18688 if (unformat (input, "if_id %d", &if_id))
18690 else if (unformat (input, "pcap %s", &pcap_file))
18692 else if (unformat (input, "count %d", &count))
18694 else if (unformat (input, "disable"))
18701 errmsg ("missing pg interface index");
18704 if (pcap_file_set > 0)
18706 if (vec_len (pcap_file) > 255)
18708 errmsg ("pcap file name is too long");
18713 /* Construct the API message */
18714 M (PG_CAPTURE, mp);
18716 mp->interface_id = ntohl (if_id);
18717 mp->is_enabled = enable;
18718 mp->count = ntohl (count);
18719 if (pcap_file_set != 0)
18721 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18723 vec_free (pcap_file);
18731 api_pg_enable_disable (vat_main_t * vam)
18733 unformat_input_t *input = vam->input;
18734 vl_api_pg_enable_disable_t *mp;
18737 u8 stream_name_set = 0;
18738 u8 *stream_name = 0;
18740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18742 if (unformat (input, "stream %s", &stream_name))
18743 stream_name_set = 1;
18744 else if (unformat (input, "disable"))
18750 if (stream_name_set > 0)
18752 if (vec_len (stream_name) > 255)
18754 errmsg ("stream name too long");
18759 /* Construct the API message */
18760 M (PG_ENABLE_DISABLE, mp);
18762 mp->is_enabled = enable;
18763 if (stream_name_set != 0)
18765 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18767 vec_free (stream_name);
18775 api_pg_interface_enable_disable_coalesce (vat_main_t * vam)
18777 unformat_input_t *input = vam->input;
18778 vl_api_pg_interface_enable_disable_coalesce_t *mp;
18780 u32 sw_if_index = ~0;
18783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18785 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18787 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18789 else if (unformat (input, "disable"))
18795 if (sw_if_index == ~0)
18797 errmsg ("Interface required but not specified");
18801 /* Construct the API message */
18802 M (PG_INTERFACE_ENABLE_DISABLE_COALESCE, mp);
18804 mp->coalesce_enabled = enable;
18805 mp->sw_if_index = htonl (sw_if_index);
18813 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18815 unformat_input_t *input = vam->input;
18816 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18818 u16 *low_ports = 0;
18819 u16 *high_ports = 0;
18822 vl_api_prefix_t prefix;
18829 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18831 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18833 else if (unformat (input, "vrf %d", &vrf_id))
18835 else if (unformat (input, "del"))
18837 else if (unformat (input, "port %d", &tmp))
18839 if (tmp == 0 || tmp > 65535)
18841 errmsg ("port %d out of range", tmp);
18845 this_hi = this_low + 1;
18846 vec_add1 (low_ports, this_low);
18847 vec_add1 (high_ports, this_hi);
18849 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18851 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18853 errmsg ("incorrect range parameters");
18857 /* Note: in debug CLI +1 is added to high before
18858 passing to real fn that does "the work"
18859 (ip_source_and_port_range_check_add_del).
18860 This fn is a wrapper around the binary API fn a
18861 control plane will call, which expects this increment
18862 to have occurred. Hence letting the binary API control
18863 plane fn do the increment for consistency between VAT
18864 and other control planes.
18867 vec_add1 (low_ports, this_low);
18868 vec_add1 (high_ports, this_hi);
18874 if (prefix_set == 0)
18876 errmsg ("<address>/<mask> not specified");
18882 errmsg ("VRF ID required, not specified");
18889 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18893 if (vec_len (low_ports) == 0)
18895 errmsg ("At least one port or port range required");
18899 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18901 mp->is_add = is_add;
18903 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18905 mp->number_of_ranges = vec_len (low_ports);
18907 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18908 vec_free (low_ports);
18910 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18911 vec_free (high_ports);
18913 mp->vrf_id = ntohl (vrf_id);
18921 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18923 unformat_input_t *input = vam->input;
18924 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18925 u32 sw_if_index = ~0;
18927 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18928 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18932 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18934 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18936 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18938 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18940 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18942 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18944 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18946 else if (unformat (input, "del"))
18952 if (sw_if_index == ~0)
18954 errmsg ("Interface required but not specified");
18960 errmsg ("VRF ID required but not specified");
18964 if (tcp_out_vrf_id == 0
18965 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18968 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18972 /* Construct the API message */
18973 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18975 mp->sw_if_index = ntohl (sw_if_index);
18976 mp->is_add = is_add;
18977 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18978 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18979 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18980 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18985 /* Wait for a reply... */
18991 api_set_punt (vat_main_t * vam)
18993 unformat_input_t *i = vam->input;
18994 vl_api_address_family_t af;
18995 vl_api_set_punt_t *mp;
19001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19003 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
19005 else if (unformat (i, "protocol %d", &protocol))
19007 else if (unformat (i, "port %d", &port))
19009 else if (unformat (i, "del"))
19013 clib_warning ("parse error '%U'", format_unformat_error, i);
19020 mp->is_add = (u8) is_add;
19021 mp->punt.type = PUNT_API_TYPE_L4;
19022 mp->punt.punt.l4.af = af;
19023 mp->punt.punt.l4.protocol = (u8) protocol;
19024 mp->punt.punt.l4.port = htons ((u16) port);
19032 api_delete_subif (vat_main_t * vam)
19034 unformat_input_t *i = vam->input;
19035 vl_api_delete_subif_t *mp;
19036 u32 sw_if_index = ~0;
19039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19043 if (unformat (i, "sw_if_index %d", &sw_if_index))
19049 if (sw_if_index == ~0)
19051 errmsg ("missing sw_if_index");
19055 /* Construct the API message */
19056 M (DELETE_SUBIF, mp);
19057 mp->sw_if_index = ntohl (sw_if_index);
19064 #define foreach_pbb_vtr_op \
19065 _("disable", L2_VTR_DISABLED) \
19066 _("pop", L2_VTR_POP_2) \
19067 _("push", L2_VTR_PUSH_2)
19070 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19072 unformat_input_t *i = vam->input;
19073 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19074 u32 sw_if_index = ~0, vtr_op = ~0;
19075 u16 outer_tag = ~0;
19076 u8 dmac[6], smac[6];
19077 u8 dmac_set = 0, smac_set = 0;
19083 /* Shut up coverity */
19084 clib_memset (dmac, 0, sizeof (dmac));
19085 clib_memset (smac, 0, sizeof (smac));
19087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19093 else if (unformat (i, "vtr_op %d", &vtr_op))
19095 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19098 else if (unformat (i, "translate_pbb_stag"))
19100 if (unformat (i, "%d", &tmp))
19102 vtr_op = L2_VTR_TRANSLATE_2_1;
19108 ("translate_pbb_stag operation requires outer tag definition");
19112 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19114 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19116 else if (unformat (i, "sid %d", &sid))
19118 else if (unformat (i, "vlanid %d", &tmp))
19122 clib_warning ("parse error '%U'", format_unformat_error, i);
19127 if ((sw_if_index == ~0) || (vtr_op == ~0))
19129 errmsg ("missing sw_if_index or vtr operation");
19132 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19133 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19136 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19140 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19141 mp->sw_if_index = ntohl (sw_if_index);
19142 mp->vtr_op = ntohl (vtr_op);
19143 mp->outer_tag = ntohs (outer_tag);
19144 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19145 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19146 mp->b_vlanid = ntohs (vlanid);
19147 mp->i_sid = ntohl (sid);
19155 api_flow_classify_set_interface (vat_main_t * vam)
19157 unformat_input_t *i = vam->input;
19158 vl_api_flow_classify_set_interface_t *mp;
19160 int sw_if_index_set;
19161 u32 ip4_table_index = ~0;
19162 u32 ip6_table_index = ~0;
19166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19168 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19169 sw_if_index_set = 1;
19170 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19171 sw_if_index_set = 1;
19172 else if (unformat (i, "del"))
19174 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19176 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19180 clib_warning ("parse error '%U'", format_unformat_error, i);
19185 if (sw_if_index_set == 0)
19187 errmsg ("missing interface name or sw_if_index");
19191 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19193 mp->sw_if_index = ntohl (sw_if_index);
19194 mp->ip4_table_index = ntohl (ip4_table_index);
19195 mp->ip6_table_index = ntohl (ip6_table_index);
19196 mp->is_add = is_add;
19204 api_flow_classify_dump (vat_main_t * vam)
19206 unformat_input_t *i = vam->input;
19207 vl_api_flow_classify_dump_t *mp;
19208 vl_api_control_ping_t *mp_ping;
19209 u8 type = FLOW_CLASSIFY_N_TABLES;
19212 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19216 errmsg ("classify table type must be specified");
19220 if (!vam->json_output)
19222 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19225 M (FLOW_CLASSIFY_DUMP, mp);
19230 /* Use a control ping for synchronization */
19231 MPING (CONTROL_PING, mp_ping);
19234 /* Wait for a reply... */
19240 api_feature_enable_disable (vat_main_t * vam)
19242 unformat_input_t *i = vam->input;
19243 vl_api_feature_enable_disable_t *mp;
19245 u8 *feature_name = 0;
19246 u32 sw_if_index = ~0;
19250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19252 if (unformat (i, "arc_name %s", &arc_name))
19254 else if (unformat (i, "feature_name %s", &feature_name))
19257 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19259 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19261 else if (unformat (i, "disable"))
19269 errmsg ("missing arc name");
19272 if (vec_len (arc_name) > 63)
19274 errmsg ("arc name too long");
19277 if (feature_name == 0)
19279 errmsg ("missing feature name");
19282 if (vec_len (feature_name) > 63)
19284 errmsg ("feature name too long");
19287 if (sw_if_index == ~0)
19289 errmsg ("missing interface name or sw_if_index");
19293 /* Construct the API message */
19294 M (FEATURE_ENABLE_DISABLE, mp);
19295 mp->sw_if_index = ntohl (sw_if_index);
19296 mp->enable = enable;
19297 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19298 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19299 vec_free (arc_name);
19300 vec_free (feature_name);
19308 api_feature_gso_enable_disable (vat_main_t * vam)
19310 unformat_input_t *i = vam->input;
19311 vl_api_feature_gso_enable_disable_t *mp;
19312 u32 sw_if_index = ~0;
19316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19318 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19320 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19322 else if (unformat (i, "enable"))
19324 else if (unformat (i, "disable"))
19330 if (sw_if_index == ~0)
19332 errmsg ("missing interface name or sw_if_index");
19336 /* Construct the API message */
19337 M (FEATURE_GSO_ENABLE_DISABLE, mp);
19338 mp->sw_if_index = ntohl (sw_if_index);
19339 mp->enable_disable = enable;
19347 api_sw_interface_tag_add_del (vat_main_t * vam)
19349 unformat_input_t *i = vam->input;
19350 vl_api_sw_interface_tag_add_del_t *mp;
19351 u32 sw_if_index = ~0;
19356 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19358 if (unformat (i, "tag %s", &tag))
19360 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19362 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19364 else if (unformat (i, "del"))
19370 if (sw_if_index == ~0)
19372 errmsg ("missing interface name or sw_if_index");
19376 if (enable && (tag == 0))
19378 errmsg ("no tag specified");
19382 /* Construct the API message */
19383 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19384 mp->sw_if_index = ntohl (sw_if_index);
19385 mp->is_add = enable;
19387 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19396 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19398 unformat_input_t *i = vam->input;
19399 vl_api_mac_address_t mac = { 0 };
19400 vl_api_sw_interface_add_del_mac_address_t *mp;
19401 u32 sw_if_index = ~0;
19406 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19408 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19410 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19412 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19414 else if (unformat (i, "del"))
19420 if (sw_if_index == ~0)
19422 errmsg ("missing interface name or sw_if_index");
19428 errmsg ("missing MAC address");
19432 /* Construct the API message */
19433 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19434 mp->sw_if_index = ntohl (sw_if_index);
19435 mp->is_add = is_add;
19436 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19443 static void vl_api_l2_xconnect_details_t_handler
19444 (vl_api_l2_xconnect_details_t * mp)
19446 vat_main_t *vam = &vat_main;
19448 print (vam->ofp, "%15d%15d",
19449 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19452 static void vl_api_l2_xconnect_details_t_handler_json
19453 (vl_api_l2_xconnect_details_t * mp)
19455 vat_main_t *vam = &vat_main;
19456 vat_json_node_t *node = NULL;
19458 if (VAT_JSON_ARRAY != vam->json_tree.type)
19460 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19461 vat_json_init_array (&vam->json_tree);
19463 node = vat_json_array_add (&vam->json_tree);
19465 vat_json_init_object (node);
19466 vat_json_object_add_uint (node, "rx_sw_if_index",
19467 ntohl (mp->rx_sw_if_index));
19468 vat_json_object_add_uint (node, "tx_sw_if_index",
19469 ntohl (mp->tx_sw_if_index));
19473 api_l2_xconnect_dump (vat_main_t * vam)
19475 vl_api_l2_xconnect_dump_t *mp;
19476 vl_api_control_ping_t *mp_ping;
19479 if (!vam->json_output)
19481 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19484 M (L2_XCONNECT_DUMP, mp);
19488 /* Use a control ping for synchronization */
19489 MPING (CONTROL_PING, mp_ping);
19497 api_hw_interface_set_mtu (vat_main_t * vam)
19499 unformat_input_t *i = vam->input;
19500 vl_api_hw_interface_set_mtu_t *mp;
19501 u32 sw_if_index = ~0;
19505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19507 if (unformat (i, "mtu %d", &mtu))
19509 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19511 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19517 if (sw_if_index == ~0)
19519 errmsg ("missing interface name or sw_if_index");
19525 errmsg ("no mtu specified");
19529 /* Construct the API message */
19530 M (HW_INTERFACE_SET_MTU, mp);
19531 mp->sw_if_index = ntohl (sw_if_index);
19532 mp->mtu = ntohs ((u16) mtu);
19540 api_p2p_ethernet_add (vat_main_t * vam)
19542 unformat_input_t *i = vam->input;
19543 vl_api_p2p_ethernet_add_t *mp;
19544 u32 parent_if_index = ~0;
19550 clib_memset (remote_mac, 0, sizeof (remote_mac));
19551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19553 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19555 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19559 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19561 else if (unformat (i, "sub_id %d", &sub_id))
19565 clib_warning ("parse error '%U'", format_unformat_error, i);
19570 if (parent_if_index == ~0)
19572 errmsg ("missing interface name or sw_if_index");
19577 errmsg ("missing remote mac address");
19582 errmsg ("missing sub-interface id");
19586 M (P2P_ETHERNET_ADD, mp);
19587 mp->parent_if_index = ntohl (parent_if_index);
19588 mp->subif_id = ntohl (sub_id);
19589 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19597 api_p2p_ethernet_del (vat_main_t * vam)
19599 unformat_input_t *i = vam->input;
19600 vl_api_p2p_ethernet_del_t *mp;
19601 u32 parent_if_index = ~0;
19606 clib_memset (remote_mac, 0, sizeof (remote_mac));
19607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19609 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19611 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19615 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19619 clib_warning ("parse error '%U'", format_unformat_error, i);
19624 if (parent_if_index == ~0)
19626 errmsg ("missing interface name or sw_if_index");
19631 errmsg ("missing remote mac address");
19635 M (P2P_ETHERNET_DEL, mp);
19636 mp->parent_if_index = ntohl (parent_if_index);
19637 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19645 api_lldp_config (vat_main_t * vam)
19647 unformat_input_t *i = vam->input;
19648 vl_api_lldp_config_t *mp;
19650 int tx_interval = 0;
19651 u8 *sys_name = NULL;
19654 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19656 if (unformat (i, "system-name %s", &sys_name))
19658 else if (unformat (i, "tx-hold %d", &tx_hold))
19660 else if (unformat (i, "tx-interval %d", &tx_interval))
19664 clib_warning ("parse error '%U'", format_unformat_error, i);
19669 vec_add1 (sys_name, 0);
19671 M (LLDP_CONFIG, mp);
19672 mp->tx_hold = htonl (tx_hold);
19673 mp->tx_interval = htonl (tx_interval);
19674 vl_api_vec_to_api_string (sys_name, &mp->system_name);
19675 vec_free (sys_name);
19683 api_sw_interface_set_lldp (vat_main_t * vam)
19685 unformat_input_t *i = vam->input;
19686 vl_api_sw_interface_set_lldp_t *mp;
19687 u32 sw_if_index = ~0;
19689 u8 *port_desc = NULL, *mgmt_oid = NULL;
19690 ip4_address_t ip4_addr;
19691 ip6_address_t ip6_addr;
19694 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19695 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19699 if (unformat (i, "disable"))
19702 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19704 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19706 else if (unformat (i, "port-desc %s", &port_desc))
19708 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19710 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19712 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19718 if (sw_if_index == ~0)
19720 errmsg ("missing interface name or sw_if_index");
19724 /* Construct the API message */
19725 vec_add1 (port_desc, 0);
19726 vec_add1 (mgmt_oid, 0);
19727 M (SW_INTERFACE_SET_LLDP, mp);
19728 mp->sw_if_index = ntohl (sw_if_index);
19729 mp->enable = enable;
19730 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
19731 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19732 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19733 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19734 vec_free (port_desc);
19735 vec_free (mgmt_oid);
19743 api_tcp_configure_src_addresses (vat_main_t * vam)
19745 vl_api_tcp_configure_src_addresses_t *mp;
19746 unformat_input_t *i = vam->input;
19747 vl_api_address_t first, last;
19752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19754 if (unformat (i, "%U - %U",
19755 unformat_vl_api_address, &first,
19756 unformat_vl_api_address, &last))
19760 errmsg ("one range per message (range already set)");
19765 else if (unformat (i, "vrf %d", &vrf_id))
19771 if (range_set == 0)
19773 errmsg ("address range not set");
19777 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19779 mp->vrf_id = ntohl (vrf_id);
19780 clib_memcpy (&mp->first_address, &first, sizeof (first));
19781 clib_memcpy (&mp->last_address, &last, sizeof (last));
19788 static void vl_api_app_namespace_add_del_reply_t_handler
19789 (vl_api_app_namespace_add_del_reply_t * mp)
19791 vat_main_t *vam = &vat_main;
19792 i32 retval = ntohl (mp->retval);
19793 if (vam->async_mode)
19795 vam->async_errors += (retval < 0);
19799 vam->retval = retval;
19801 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19802 vam->result_ready = 1;
19806 static void vl_api_app_namespace_add_del_reply_t_handler_json
19807 (vl_api_app_namespace_add_del_reply_t * mp)
19809 vat_main_t *vam = &vat_main;
19810 vat_json_node_t node;
19812 vat_json_init_object (&node);
19813 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19814 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19816 vat_json_print (vam->ofp, &node);
19817 vat_json_free (&node);
19819 vam->retval = ntohl (mp->retval);
19820 vam->result_ready = 1;
19824 api_app_namespace_add_del (vat_main_t * vam)
19826 vl_api_app_namespace_add_del_t *mp;
19827 unformat_input_t *i = vam->input;
19828 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19829 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19835 if (unformat (i, "id %_%v%_", &ns_id))
19837 else if (unformat (i, "secret %lu", &secret))
19839 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19840 sw_if_index_set = 1;
19841 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19843 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19848 if (!ns_id || !secret_set || !sw_if_index_set)
19850 errmsg ("namespace id, secret and sw_if_index must be set");
19853 if (vec_len (ns_id) > 64)
19855 errmsg ("namespace id too long");
19858 M (APP_NAMESPACE_ADD_DEL, mp);
19860 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19861 mp->secret = clib_host_to_net_u64 (secret);
19862 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19863 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19864 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19872 api_sock_init_shm (vat_main_t * vam)
19874 #if VPP_API_TEST_BUILTIN == 0
19875 unformat_input_t *i = vam->input;
19876 vl_api_shm_elem_config_t *config = 0;
19877 u64 size = 64 << 20;
19880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19882 if (unformat (i, "size %U", unformat_memory_size, &size))
19889 * Canned custom ring allocator config.
19890 * Should probably parse all of this
19892 vec_validate (config, 6);
19893 config[0].type = VL_API_VLIB_RING;
19894 config[0].size = 256;
19895 config[0].count = 32;
19897 config[1].type = VL_API_VLIB_RING;
19898 config[1].size = 1024;
19899 config[1].count = 16;
19901 config[2].type = VL_API_VLIB_RING;
19902 config[2].size = 4096;
19903 config[2].count = 2;
19905 config[3].type = VL_API_CLIENT_RING;
19906 config[3].size = 256;
19907 config[3].count = 32;
19909 config[4].type = VL_API_CLIENT_RING;
19910 config[4].size = 1024;
19911 config[4].count = 16;
19913 config[5].type = VL_API_CLIENT_RING;
19914 config[5].size = 4096;
19915 config[5].count = 2;
19917 config[6].type = VL_API_QUEUE;
19918 config[6].count = 128;
19919 config[6].size = sizeof (uword);
19921 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19923 vam->client_index_invalid = 1;
19931 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19933 vat_main_t *vam = &vat_main;
19934 fib_prefix_t lcl, rmt;
19936 ip_prefix_decode (&mp->lcl, &lcl);
19937 ip_prefix_decode (&mp->rmt, &rmt);
19939 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19942 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19943 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19944 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19945 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19946 &rmt.fp_addr.ip4, rmt.fp_len,
19947 clib_net_to_host_u16 (mp->rmt_port),
19948 clib_net_to_host_u32 (mp->action_index), mp->tag);
19953 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19954 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19955 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19956 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19957 &rmt.fp_addr.ip6, rmt.fp_len,
19958 clib_net_to_host_u16 (mp->rmt_port),
19959 clib_net_to_host_u32 (mp->action_index), mp->tag);
19964 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19967 vat_main_t *vam = &vat_main;
19968 vat_json_node_t *node = NULL;
19969 struct in6_addr ip6;
19970 struct in_addr ip4;
19972 fib_prefix_t lcl, rmt;
19974 ip_prefix_decode (&mp->lcl, &lcl);
19975 ip_prefix_decode (&mp->rmt, &rmt);
19977 if (VAT_JSON_ARRAY != vam->json_tree.type)
19979 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19980 vat_json_init_array (&vam->json_tree);
19982 node = vat_json_array_add (&vam->json_tree);
19983 vat_json_init_object (node);
19985 vat_json_object_add_uint (node, "appns_index",
19986 clib_net_to_host_u32 (mp->appns_index));
19987 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19988 vat_json_object_add_uint (node, "scope", mp->scope);
19989 vat_json_object_add_uint (node, "action_index",
19990 clib_net_to_host_u32 (mp->action_index));
19991 vat_json_object_add_uint (node, "lcl_port",
19992 clib_net_to_host_u16 (mp->lcl_port));
19993 vat_json_object_add_uint (node, "rmt_port",
19994 clib_net_to_host_u16 (mp->rmt_port));
19995 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19996 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19997 vat_json_object_add_string_copy (node, "tag", mp->tag);
19998 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
20000 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
20001 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
20002 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
20003 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
20007 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
20008 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
20009 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
20010 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
20015 api_session_rule_add_del (vat_main_t * vam)
20017 vl_api_session_rule_add_del_t *mp;
20018 unformat_input_t *i = vam->input;
20019 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
20020 u32 appns_index = 0, scope = 0;
20021 ip4_address_t lcl_ip4, rmt_ip4;
20022 ip6_address_t lcl_ip6, rmt_ip6;
20023 u8 is_ip4 = 1, conn_set = 0;
20024 u8 is_add = 1, *tag = 0;
20026 fib_prefix_t lcl, rmt;
20028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20030 if (unformat (i, "del"))
20032 else if (unformat (i, "add"))
20034 else if (unformat (i, "proto tcp"))
20036 else if (unformat (i, "proto udp"))
20038 else if (unformat (i, "appns %d", &appns_index))
20040 else if (unformat (i, "scope %d", &scope))
20042 else if (unformat (i, "tag %_%v%_", &tag))
20046 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
20047 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
20055 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
20056 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
20062 else if (unformat (i, "action %d", &action))
20067 if (proto == ~0 || !conn_set || action == ~0)
20069 errmsg ("transport proto, connection and action must be set");
20075 errmsg ("scope should be 0-3");
20079 M (SESSION_RULE_ADD_DEL, mp);
20081 clib_memset (&lcl, 0, sizeof (lcl));
20082 clib_memset (&rmt, 0, sizeof (rmt));
20085 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
20086 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
20087 lcl.fp_len = lcl_plen;
20088 rmt.fp_len = rmt_plen;
20092 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
20093 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
20094 lcl.fp_len = lcl_plen;
20095 rmt.fp_len = rmt_plen;
20099 ip_prefix_encode (&lcl, &mp->lcl);
20100 ip_prefix_encode (&rmt, &mp->rmt);
20101 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
20102 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
20103 mp->transport_proto =
20104 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
20105 mp->action_index = clib_host_to_net_u32 (action);
20106 mp->appns_index = clib_host_to_net_u32 (appns_index);
20108 mp->is_add = is_add;
20111 clib_memcpy (mp->tag, tag, vec_len (tag));
20121 api_session_rules_dump (vat_main_t * vam)
20123 vl_api_session_rules_dump_t *mp;
20124 vl_api_control_ping_t *mp_ping;
20127 if (!vam->json_output)
20129 print (vam->ofp, "%=20s", "Session Rules");
20132 M (SESSION_RULES_DUMP, mp);
20136 /* Use a control ping for synchronization */
20137 MPING (CONTROL_PING, mp_ping);
20140 /* Wait for a reply... */
20146 api_ip_container_proxy_add_del (vat_main_t * vam)
20148 vl_api_ip_container_proxy_add_del_t *mp;
20149 unformat_input_t *i = vam->input;
20150 u32 sw_if_index = ~0;
20151 vl_api_prefix_t pfx = { };
20155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20157 if (unformat (i, "del"))
20159 else if (unformat (i, "add"))
20161 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
20163 else if (unformat (i, "sw_if_index %u", &sw_if_index))
20168 if (sw_if_index == ~0 || pfx.len == 0)
20170 errmsg ("address and sw_if_index must be set");
20174 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
20176 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
20177 mp->is_add = is_add;
20178 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
20186 api_qos_record_enable_disable (vat_main_t * vam)
20188 unformat_input_t *i = vam->input;
20189 vl_api_qos_record_enable_disable_t *mp;
20190 u32 sw_if_index, qs = 0xff;
20191 u8 sw_if_index_set = 0;
20195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20197 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20198 sw_if_index_set = 1;
20199 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20200 sw_if_index_set = 1;
20201 else if (unformat (i, "%U", unformat_qos_source, &qs))
20203 else if (unformat (i, "disable"))
20207 clib_warning ("parse error '%U'", format_unformat_error, i);
20212 if (sw_if_index_set == 0)
20214 errmsg ("missing interface name or sw_if_index");
20219 errmsg ("input location must be specified");
20223 M (QOS_RECORD_ENABLE_DISABLE, mp);
20225 mp->record.sw_if_index = ntohl (sw_if_index);
20226 mp->record.input_source = qs;
20227 mp->enable = enable;
20236 q_or_quit (vat_main_t * vam)
20238 #if VPP_API_TEST_BUILTIN == 0
20239 longjmp (vam->jump_buf, 1);
20241 return 0; /* not so much */
20245 q (vat_main_t * vam)
20247 return q_or_quit (vam);
20251 quit (vat_main_t * vam)
20253 return q_or_quit (vam);
20257 comment (vat_main_t * vam)
20263 elog_save (vat_main_t * vam)
20265 #if VPP_API_TEST_BUILTIN == 0
20266 elog_main_t *em = &vam->elog_main;
20267 unformat_input_t *i = vam->input;
20268 char *file, *chroot_file;
20269 clib_error_t *error;
20271 if (!unformat (i, "%s", &file))
20273 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20277 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20278 if (strstr (file, "..") || index (file, '/'))
20280 errmsg ("illegal characters in filename '%s'", file);
20284 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20288 errmsg ("Saving %wd of %wd events to %s",
20289 elog_n_events_in_buffer (em),
20290 elog_buffer_capacity (em), chroot_file);
20292 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20293 vec_free (chroot_file);
20296 clib_error_report (error);
20298 errmsg ("Use the vpp event loger...");
20305 elog_setup (vat_main_t * vam)
20307 #if VPP_API_TEST_BUILTIN == 0
20308 elog_main_t *em = &vam->elog_main;
20309 unformat_input_t *i = vam->input;
20310 u32 nevents = 128 << 10;
20312 (void) unformat (i, "nevents %d", &nevents);
20314 elog_init (em, nevents);
20315 vl_api_set_elog_main (em);
20316 vl_api_set_elog_trace_api_messages (1);
20317 errmsg ("Event logger initialized with %u events", nevents);
20319 errmsg ("Use the vpp event loger...");
20325 elog_enable (vat_main_t * vam)
20327 #if VPP_API_TEST_BUILTIN == 0
20328 elog_main_t *em = &vam->elog_main;
20330 elog_enable_disable (em, 1 /* enable */ );
20331 vl_api_set_elog_trace_api_messages (1);
20332 errmsg ("Event logger enabled...");
20334 errmsg ("Use the vpp event loger...");
20340 elog_disable (vat_main_t * vam)
20342 #if VPP_API_TEST_BUILTIN == 0
20343 elog_main_t *em = &vam->elog_main;
20345 elog_enable_disable (em, 0 /* enable */ );
20346 vl_api_set_elog_trace_api_messages (1);
20347 errmsg ("Event logger disabled...");
20349 errmsg ("Use the vpp event loger...");
20355 statseg (vat_main_t * vam)
20357 ssvm_private_t *ssvmp = &vam->stat_segment;
20358 ssvm_shared_header_t *shared_header = ssvmp->sh;
20359 vlib_counter_t **counters;
20360 u64 thread0_index1_packets;
20361 u64 thread0_index1_bytes;
20362 f64 vector_rate, input_rate;
20365 uword *counter_vector_by_name;
20366 if (vam->stat_segment_lockp == 0)
20368 errmsg ("Stat segment not mapped...");
20372 /* look up "/if/rx for sw_if_index 1 as a test */
20374 clib_spinlock_lock (vam->stat_segment_lockp);
20376 counter_vector_by_name = (uword *) shared_header->opaque[1];
20378 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20381 clib_spinlock_unlock (vam->stat_segment_lockp);
20382 errmsg ("/if/tx not found?");
20386 /* Fish per-thread vector of combined counters from shared memory */
20387 counters = (vlib_counter_t **) p[0];
20389 if (vec_len (counters[0]) < 2)
20391 clib_spinlock_unlock (vam->stat_segment_lockp);
20392 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20396 /* Read thread 0 sw_if_index 1 counter */
20397 thread0_index1_packets = counters[0][1].packets;
20398 thread0_index1_bytes = counters[0][1].bytes;
20400 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20403 clib_spinlock_unlock (vam->stat_segment_lockp);
20404 errmsg ("vector_rate not found?");
20408 vector_rate = *(f64 *) (p[0]);
20409 p = hash_get_mem (counter_vector_by_name, "input_rate");
20412 clib_spinlock_unlock (vam->stat_segment_lockp);
20413 errmsg ("input_rate not found?");
20416 input_rate = *(f64 *) (p[0]);
20418 clib_spinlock_unlock (vam->stat_segment_lockp);
20420 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20421 vector_rate, input_rate);
20422 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20423 thread0_index1_packets, thread0_index1_bytes);
20429 cmd_cmp (void *a1, void *a2)
20434 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20438 help (vat_main_t * vam)
20443 unformat_input_t *i = vam->input;
20446 if (unformat (i, "%s", &name))
20450 vec_add1 (name, 0);
20452 hs = hash_get_mem (vam->help_by_name, name);
20454 print (vam->ofp, "usage: %s %s", name, hs[0]);
20456 print (vam->ofp, "No such msg / command '%s'", name);
20461 print (vam->ofp, "Help is available for the following:");
20464 hash_foreach_pair (p, vam->function_by_name,
20466 vec_add1 (cmds, (u8 *)(p->key));
20470 vec_sort_with_function (cmds, cmd_cmp);
20472 for (j = 0; j < vec_len (cmds); j++)
20473 print (vam->ofp, "%s", cmds[j]);
20480 set (vat_main_t * vam)
20482 u8 *name = 0, *value = 0;
20483 unformat_input_t *i = vam->input;
20485 if (unformat (i, "%s", &name))
20487 /* The input buffer is a vector, not a string. */
20488 value = vec_dup (i->buffer);
20489 vec_delete (value, i->index, 0);
20490 /* Almost certainly has a trailing newline */
20491 if (value[vec_len (value) - 1] == '\n')
20492 value[vec_len (value) - 1] = 0;
20493 /* Make sure it's a proper string, one way or the other */
20494 vec_add1 (value, 0);
20495 (void) clib_macro_set_value (&vam->macro_main,
20496 (char *) name, (char *) value);
20499 errmsg ("usage: set <name> <value>");
20507 unset (vat_main_t * vam)
20511 if (unformat (vam->input, "%s", &name))
20512 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20513 errmsg ("unset: %s wasn't set", name);
20526 macro_sort_cmp (void *a1, void *a2)
20528 macro_sort_t *s1 = a1;
20529 macro_sort_t *s2 = a2;
20531 return strcmp ((char *) (s1->name), (char *) (s2->name));
20535 dump_macro_table (vat_main_t * vam)
20537 macro_sort_t *sort_me = 0, *sm;
20542 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20544 vec_add2 (sort_me, sm, 1);
20545 sm->name = (u8 *)(p->key);
20546 sm->value = (u8 *) (p->value[0]);
20550 vec_sort_with_function (sort_me, macro_sort_cmp);
20552 if (vec_len (sort_me))
20553 print (vam->ofp, "%-15s%s", "Name", "Value");
20555 print (vam->ofp, "The macro table is empty...");
20557 for (i = 0; i < vec_len (sort_me); i++)
20558 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20563 dump_node_table (vat_main_t * vam)
20566 vlib_node_t *node, *next_node;
20568 if (vec_len (vam->graph_nodes) == 0)
20570 print (vam->ofp, "Node table empty, issue get_node_graph...");
20574 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20576 node = vam->graph_nodes[0][i];
20577 print (vam->ofp, "[%d] %s", i, node->name);
20578 for (j = 0; j < vec_len (node->next_nodes); j++)
20580 if (node->next_nodes[j] != ~0)
20582 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20583 print (vam->ofp, " [%d] %s", j, next_node->name);
20591 value_sort_cmp (void *a1, void *a2)
20593 name_sort_t *n1 = a1;
20594 name_sort_t *n2 = a2;
20596 if (n1->value < n2->value)
20598 if (n1->value > n2->value)
20605 dump_msg_api_table (vat_main_t * vam)
20607 api_main_t *am = vlibapi_get_main ();
20608 name_sort_t *nses = 0, *ns;
20613 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20615 vec_add2 (nses, ns, 1);
20616 ns->name = (u8 *)(hp->key);
20617 ns->value = (u32) hp->value[0];
20621 vec_sort_with_function (nses, value_sort_cmp);
20623 for (i = 0; i < vec_len (nses); i++)
20624 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20630 get_msg_id (vat_main_t * vam)
20635 if (unformat (vam->input, "%s", &name_and_crc))
20637 message_index = vl_msg_api_get_msg_index (name_and_crc);
20638 if (message_index == ~0)
20640 print (vam->ofp, " '%s' not found", name_and_crc);
20643 print (vam->ofp, " '%s' has message index %d",
20644 name_and_crc, message_index);
20647 errmsg ("name_and_crc required...");
20652 search_node_table (vat_main_t * vam)
20654 unformat_input_t *line_input = vam->input;
20657 vlib_node_t *node, *next_node;
20660 if (vam->graph_node_index_by_name == 0)
20662 print (vam->ofp, "Node table empty, issue get_node_graph...");
20666 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20668 if (unformat (line_input, "%s", &node_to_find))
20670 vec_add1 (node_to_find, 0);
20671 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20674 print (vam->ofp, "%s not found...", node_to_find);
20677 node = vam->graph_nodes[0][p[0]];
20678 print (vam->ofp, "[%d] %s", p[0], node->name);
20679 for (j = 0; j < vec_len (node->next_nodes); j++)
20681 if (node->next_nodes[j] != ~0)
20683 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20684 print (vam->ofp, " [%d] %s", j, next_node->name);
20691 clib_warning ("parse error '%U'", format_unformat_error,
20697 vec_free (node_to_find);
20706 script (vat_main_t * vam)
20708 #if (VPP_API_TEST_BUILTIN==0)
20710 char *save_current_file;
20711 unformat_input_t save_input;
20712 jmp_buf save_jump_buf;
20713 u32 save_line_number;
20715 FILE *new_fp, *save_ifp;
20717 if (unformat (vam->input, "%s", &s))
20719 new_fp = fopen ((char *) s, "r");
20722 errmsg ("Couldn't open script file %s", s);
20729 errmsg ("Missing script name");
20733 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20734 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20735 save_ifp = vam->ifp;
20736 save_line_number = vam->input_line_number;
20737 save_current_file = (char *) vam->current_file;
20739 vam->input_line_number = 0;
20741 vam->current_file = s;
20744 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20745 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20746 vam->ifp = save_ifp;
20747 vam->input_line_number = save_line_number;
20748 vam->current_file = (u8 *) save_current_file;
20753 clib_warning ("use the exec command...");
20759 echo (vat_main_t * vam)
20761 print (vam->ofp, "%v", vam->input->buffer);
20765 /* List of API message constructors, CLI names map to api_xxx */
20766 #define foreach_vpe_api_msg \
20767 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20768 _(sw_interface_dump,"") \
20769 _(sw_interface_set_flags, \
20770 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20771 _(sw_interface_add_del_address, \
20772 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20773 _(sw_interface_set_rx_mode, \
20774 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20775 _(sw_interface_set_rx_placement, \
20776 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20777 _(sw_interface_rx_placement_dump, \
20778 "[<intfc> | sw_if_index <id>]") \
20779 _(sw_interface_set_table, \
20780 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20781 _(sw_interface_set_mpls_enable, \
20782 "<intfc> | sw_if_index [disable | dis]") \
20783 _(sw_interface_set_vpath, \
20784 "<intfc> | sw_if_index <id> enable | disable") \
20785 _(sw_interface_set_vxlan_bypass, \
20786 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20787 _(sw_interface_set_geneve_bypass, \
20788 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20789 _(sw_interface_set_l2_xconnect, \
20790 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20791 "enable | disable") \
20792 _(sw_interface_set_l2_bridge, \
20793 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20794 "[shg <split-horizon-group>] [bvi]\n" \
20795 "enable | disable") \
20796 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20797 _(bridge_domain_add_del, \
20798 "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") \
20799 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20801 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20802 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20803 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20805 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20807 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20809 "id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload | gro-coalesce] [persist] [attach] [tun] [packed] [in-order]") \
20811 "<vpp-if-name> | sw_if_index <id>") \
20812 _(sw_interface_tap_v2_dump, "") \
20813 _(virtio_pci_create_v2, \
20814 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order]") \
20815 _(virtio_pci_delete, \
20816 "<vpp-if-name> | sw_if_index <id>") \
20817 _(sw_interface_virtio_pci_dump, "") \
20819 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20820 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20823 "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
20824 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20825 "[id <if-id>] [gso]") \
20827 "<vpp-if-name> | sw_if_index <id>") \
20828 _(bond_add_member, \
20829 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20830 _(bond_detach_member, \
20831 "sw_if_index <n>") \
20832 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20833 _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
20834 _(sw_member_interface_dump, \
20835 "<vpp-if-name> | sw_if_index <id>") \
20836 _(ip_table_add_del, \
20837 "table <n> [ipv6] [add | del]\n") \
20838 _(ip_route_add_del, \
20839 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20840 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20841 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20842 "[multipath] [count <n>] [del]") \
20843 _(ip_mroute_add_del, \
20844 "<src> <grp>/<mask> [table-id <n>]\n" \
20845 "[<intfc> | sw_if_index <id>] [local] [del]") \
20846 _(mpls_table_add_del, \
20847 "table <n> [add | del]\n") \
20848 _(mpls_route_add_del, \
20849 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20850 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20851 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20852 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20853 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20854 "[count <n>] [del]") \
20855 _(mpls_ip_bind_unbind, \
20856 "<label> <addr/len>") \
20857 _(mpls_tunnel_add_del, \
20858 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20859 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20860 "[l2-only] [out-label <n>]") \
20861 _(sr_mpls_policy_add, \
20862 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20863 _(sr_mpls_policy_del, \
20865 _(bier_table_add_del, \
20866 "<label> <sub-domain> <set> <bsl> [del]") \
20867 _(bier_route_add_del, \
20868 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20869 "[<intfc> | sw_if_index <id>]" \
20870 "[weight <n>] [del] [multipath]") \
20871 _(sw_interface_set_unnumbered, \
20872 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20873 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20874 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20875 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20876 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20877 "[outer_vlan_id_any][inner_vlan_id_any]") \
20878 _(ip_table_replace_begin, "table <n> [ipv6]") \
20879 _(ip_table_flush, "table <n> [ipv6]") \
20880 _(ip_table_replace_end, "table <n> [ipv6]") \
20881 _(set_ip_flow_hash, \
20882 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20883 _(sw_interface_ip6_enable_disable, \
20884 "<intfc> | sw_if_index <id> enable | disable") \
20885 _(l2_patch_add_del, \
20886 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20887 "enable | disable") \
20888 _(sr_localsid_add_del, \
20889 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20890 "fib-table <num> (end.psp) sw_if_index <num>") \
20891 _(classify_add_del_table, \
20892 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20893 " [del] [del-chain] mask <mask-value>\n" \
20894 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20895 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20896 _(classify_add_del_session, \
20897 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20898 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20899 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20900 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20901 _(classify_set_interface_ip_table, \
20902 "<intfc> | sw_if_index <nn> table <nn>") \
20903 _(classify_set_interface_l2_tables, \
20904 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20905 " [other-table <nn>]") \
20906 _(get_node_index, "node <node-name") \
20907 _(add_node_next, "node <node-name> next <next-node-name>") \
20908 _(l2tpv3_create_tunnel, \
20909 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20910 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20911 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20912 _(l2tpv3_set_tunnel_cookies, \
20913 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20914 "[new_remote_cookie <nn>]\n") \
20915 _(l2tpv3_interface_enable_disable, \
20916 "<intfc> | sw_if_index <nn> enable | disable") \
20917 _(l2tpv3_set_lookup_key, \
20918 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20919 _(sw_if_l2tpv3_tunnel_dump, "") \
20920 _(vxlan_offload_rx, \
20921 "hw { <interface name> | hw_if_index <nn>} " \
20922 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20923 _(vxlan_add_del_tunnel, \
20924 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20925 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20926 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20927 _(geneve_add_del_tunnel, \
20928 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20929 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20930 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20931 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20932 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20933 _(gre_tunnel_add_del, \
20934 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20935 "[teb | erspan <session-id>] [del]") \
20936 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20937 _(l2_fib_clear_table, "") \
20938 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20939 _(l2_interface_vlan_tag_rewrite, \
20940 "<intfc> | sw_if_index <nn> \n" \
20941 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20942 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20943 _(create_vhost_user_if, \
20944 "socket <filename> [server] [renumber <dev_instance>] " \
20945 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20946 "[mac <mac_address>] [packed]") \
20947 _(modify_vhost_user_if, \
20948 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20949 "[server] [renumber <dev_instance>] [gso] [packed]") \
20950 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20951 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
20952 _(show_version, "") \
20953 _(show_threads, "") \
20954 _(vxlan_gpe_add_del_tunnel, \
20955 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20956 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20957 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20958 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20959 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20960 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20961 _(interface_name_renumber, \
20962 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20963 _(input_acl_set_interface, \
20964 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20965 " [l2-table <nn>] [del]") \
20966 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20967 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20968 _(ip_dump, "ipv4 | ipv6") \
20969 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20970 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20972 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20973 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20974 " integ_alg <alg> integ_key <hex>") \
20975 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20976 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20977 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20978 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20979 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20980 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20981 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20982 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20983 " [instance <n>]") \
20984 _(ipsec_sa_dump, "[sa_id <n>]") \
20985 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20986 _(delete_loopback,"sw_if_index <nn>") \
20987 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20988 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20989 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20990 _(want_interface_events, "enable|disable") \
20991 _(get_first_msg_id, "client <name>") \
20992 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20993 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20994 "fib-id <nn> [ip4][ip6][default]") \
20995 _(get_node_graph, " ") \
20996 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20997 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20998 _(ioam_disable, "") \
20999 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
21000 " sw_if_index <sw_if_index> p <priority> " \
21001 "w <weight>] [del]") \
21002 _(one_add_del_locator, "locator-set <locator_name> " \
21003 "iface <intf> | sw_if_index <sw_if_index> " \
21004 "p <priority> w <weight> [del]") \
21005 _(one_add_del_local_eid,"vni <vni> eid " \
21006 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21007 "locator-set <locator_name> [del]" \
21008 "[key-id sha1|sha256 secret-key <secret-key>]")\
21009 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
21010 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
21011 _(one_enable_disable, "enable|disable") \
21012 _(one_map_register_enable_disable, "enable|disable") \
21013 _(one_map_register_fallback_threshold, "<value>") \
21014 _(one_rloc_probe_enable_disable, "enable|disable") \
21015 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21017 "rloc <locator> p <prio> " \
21018 "w <weight> [rloc <loc> ... ] " \
21019 "action <action> [del-all]") \
21020 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21022 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21023 _(one_use_petr, "ip-address> | disable") \
21024 _(one_map_request_mode, "src-dst|dst-only") \
21025 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21026 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21027 _(one_locator_set_dump, "[local | remote]") \
21028 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
21029 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21030 "[local] | [remote]") \
21031 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
21032 _(one_ndp_bd_get, "") \
21033 _(one_ndp_entries_get, "bd <bridge-domain>") \
21034 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip <ip4>") \
21035 _(one_l2_arp_bd_get, "") \
21036 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
21037 _(one_stats_enable_disable, "enable|disable") \
21038 _(show_one_stats_enable_disable, "") \
21039 _(one_eid_table_vni_dump, "") \
21040 _(one_eid_table_map_dump, "l2|l3") \
21041 _(one_map_resolver_dump, "") \
21042 _(one_map_server_dump, "") \
21043 _(one_adjacencies_get, "vni <vni>") \
21044 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
21045 _(show_one_rloc_probe_state, "") \
21046 _(show_one_map_register_state, "") \
21047 _(show_one_status, "") \
21048 _(one_stats_dump, "") \
21049 _(one_stats_flush, "") \
21050 _(one_get_map_request_itr_rlocs, "") \
21051 _(one_map_register_set_ttl, "<ttl>") \
21052 _(one_set_transport_protocol, "udp|api") \
21053 _(one_get_transport_protocol, "") \
21054 _(one_enable_disable_xtr_mode, "enable|disable") \
21055 _(one_show_xtr_mode, "") \
21056 _(one_enable_disable_pitr_mode, "enable|disable") \
21057 _(one_show_pitr_mode, "") \
21058 _(one_enable_disable_petr_mode, "enable|disable") \
21059 _(one_show_petr_mode, "") \
21060 _(show_one_nsh_mapping, "") \
21061 _(show_one_pitr, "") \
21062 _(show_one_use_petr, "") \
21063 _(show_one_map_request_mode, "") \
21064 _(show_one_map_register_ttl, "") \
21065 _(show_one_map_register_fallback_threshold, "") \
21066 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
21067 " sw_if_index <sw_if_index> p <priority> " \
21068 "w <weight>] [del]") \
21069 _(lisp_add_del_locator, "locator-set <locator_name> " \
21070 "iface <intf> | sw_if_index <sw_if_index> " \
21071 "p <priority> w <weight> [del]") \
21072 _(lisp_add_del_local_eid,"vni <vni> eid " \
21073 "<ipv4|ipv6>/<prefix> | <L2 address> " \
21074 "locator-set <locator_name> [del]" \
21075 "[key-id sha1|sha256 secret-key <secret-key>]") \
21076 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
21077 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
21078 _(lisp_enable_disable, "enable|disable") \
21079 _(lisp_map_register_enable_disable, "enable|disable") \
21080 _(lisp_rloc_probe_enable_disable, "enable|disable") \
21081 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
21083 "rloc <locator> p <prio> " \
21084 "w <weight> [rloc <loc> ... ] " \
21085 "action <action> [del-all]") \
21086 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
21088 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
21089 _(lisp_use_petr, "<ip-address> | disable") \
21090 _(lisp_map_request_mode, "src-dst|dst-only") \
21091 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
21092 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
21093 _(lisp_locator_set_dump, "[local | remote]") \
21094 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
21095 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
21096 "[local] | [remote]") \
21097 _(lisp_eid_table_vni_dump, "") \
21098 _(lisp_eid_table_map_dump, "l2|l3") \
21099 _(lisp_map_resolver_dump, "") \
21100 _(lisp_map_server_dump, "") \
21101 _(lisp_adjacencies_get, "vni <vni>") \
21102 _(gpe_fwd_entry_vnis_get, "") \
21103 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
21104 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
21105 "[table <table-id>]") \
21106 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
21107 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
21108 _(gpe_set_encap_mode, "lisp|vxlan") \
21109 _(gpe_get_encap_mode, "") \
21110 _(lisp_gpe_add_del_iface, "up|down") \
21111 _(lisp_gpe_enable_disable, "enable|disable") \
21112 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
21113 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
21114 _(show_lisp_rloc_probe_state, "") \
21115 _(show_lisp_map_register_state, "") \
21116 _(show_lisp_status, "") \
21117 _(lisp_get_map_request_itr_rlocs, "") \
21118 _(show_lisp_pitr, "") \
21119 _(show_lisp_use_petr, "") \
21120 _(show_lisp_map_request_mode, "") \
21121 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
21122 _(af_packet_delete, "name <host interface name>") \
21123 _(af_packet_dump, "") \
21124 _(policer_add_del, "name <policer name> <params> [del]") \
21125 _(policer_dump, "[name <policer name>]") \
21126 _(policer_classify_set_interface, \
21127 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21128 " [l2-table <nn>] [del]") \
21129 _(policer_classify_dump, "type [ip4|ip6|l2]") \
21130 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
21131 _(mpls_table_dump, "") \
21132 _(mpls_route_dump, "table-id <ID>") \
21133 _(classify_table_ids, "") \
21134 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
21135 _(classify_table_info, "table_id <nn>") \
21136 _(classify_session_dump, "table_id <nn>") \
21137 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
21138 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
21139 "[template_interval <nn>] [udp_checksum]") \
21140 _(ipfix_exporter_dump, "") \
21141 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
21142 _(ipfix_classify_stream_dump, "") \
21143 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
21144 _(ipfix_classify_table_dump, "") \
21145 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
21146 _(sw_interface_span_dump, "[l2]") \
21147 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
21148 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
21149 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
21150 _(pg_enable_disable, "[stream <id>] disable") \
21151 _(pg_interface_enable_disable_coalesce, "<intf> | sw_if_index <nn> enable | disable") \
21152 _(ip_source_and_port_range_check_add_del, \
21153 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
21154 _(ip_source_and_port_range_check_interface_add_del, \
21155 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
21156 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
21157 _(delete_subif,"<intfc> | sw_if_index <nn>") \
21158 _(l2_interface_pbb_tag_rewrite, \
21159 "<intfc> | sw_if_index <nn> \n" \
21160 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
21161 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
21162 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
21163 _(flow_classify_set_interface, \
21164 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
21165 _(flow_classify_dump, "type [ip4|ip6]") \
21166 _(ip_table_dump, "") \
21167 _(ip_route_dump, "table-id [ip4|ip6]") \
21168 _(ip_mtable_dump, "") \
21169 _(ip_mroute_dump, "table-id [ip4|ip6]") \
21170 _(feature_enable_disable, "arc_name <arc_name> " \
21171 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
21172 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
21173 "[enable | disable] ") \
21174 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
21176 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
21177 "mac <mac-address> [del]") \
21178 _(l2_xconnect_dump, "") \
21179 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
21180 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
21181 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
21182 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
21183 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
21184 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
21185 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
21186 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
21187 _(sock_init_shm, "size <nnn>") \
21188 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
21189 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
21190 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
21191 _(session_rules_dump, "") \
21192 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
21193 _(output_acl_set_interface, \
21194 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21195 " [l2-table <nn>] [del]") \
21196 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21198 /* List of command functions, CLI names map directly to functions */
21199 #define foreach_cli_function \
21200 _(comment, "usage: comment <ignore-rest-of-line>") \
21201 _(dump_interface_table, "usage: dump_interface_table") \
21202 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21203 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21204 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21205 _(dump_macro_table, "usage: dump_macro_table ") \
21206 _(dump_node_table, "usage: dump_node_table") \
21207 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21208 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21209 _(elog_disable, "usage: elog_disable") \
21210 _(elog_enable, "usage: elog_enable") \
21211 _(elog_save, "usage: elog_save <filename>") \
21212 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21213 _(echo, "usage: echo <message>") \
21214 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21215 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21216 _(help, "usage: help") \
21217 _(q, "usage: quit") \
21218 _(quit, "usage: quit") \
21219 _(search_node_table, "usage: search_node_table <name>...") \
21220 _(set, "usage: set <variable-name> <value>") \
21221 _(script, "usage: script <file-name>") \
21222 _(statseg, "usage: statseg") \
21223 _(unset, "usage: unset <variable-name>")
21226 static void vl_api_##n##_t_handler_uni \
21227 (vl_api_##n##_t * mp) \
21229 vat_main_t * vam = &vat_main; \
21230 if (vam->json_output) { \
21231 vl_api_##n##_t_handler_json(mp); \
21233 vl_api_##n##_t_handler(mp); \
21236 foreach_vpe_api_reply_msg;
21237 #if VPP_API_TEST_BUILTIN == 0
21238 foreach_standalone_reply_msg;
21243 vat_api_hookup (vat_main_t * vam)
21246 vl_msg_api_set_handlers(VL_API_##N, #n, \
21247 vl_api_##n##_t_handler_uni, \
21249 vl_api_##n##_t_endian, \
21250 vl_api_##n##_t_print, \
21251 sizeof(vl_api_##n##_t), 1);
21252 foreach_vpe_api_reply_msg;
21253 #if VPP_API_TEST_BUILTIN == 0
21254 foreach_standalone_reply_msg;
21258 #if (VPP_API_TEST_BUILTIN==0)
21259 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21261 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21263 vam->function_by_name = hash_create_string (0, sizeof (uword));
21265 vam->help_by_name = hash_create_string (0, sizeof (uword));
21268 /* API messages we can send */
21269 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21270 foreach_vpe_api_msg;
21274 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21275 foreach_vpe_api_msg;
21278 /* CLI functions */
21279 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21280 foreach_cli_function;
21284 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21285 foreach_cli_function;
21289 #if VPP_API_TEST_BUILTIN
21290 static clib_error_t *
21291 vat_api_hookup_shim (vlib_main_t * vm)
21293 vat_api_hookup (&vat_main);
21297 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21301 * fd.io coding-style-patch-verification: ON
21304 * eval: (c-set-style "gnu")