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_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
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->result_ready = 1;
1848 static void vl_api_virtio_pci_delete_reply_t_handler_json
1849 (vl_api_virtio_pci_delete_reply_t * mp)
1851 vat_main_t *vam = &vat_main;
1852 vat_json_node_t node;
1854 vat_json_init_object (&node);
1855 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_print (vam->ofp, &node);
1858 vat_json_free (&node);
1860 vam->retval = ntohl (mp->retval);
1861 vam->result_ready = 1;
1865 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1867 vat_main_t *vam = &vat_main;
1868 i32 retval = ntohl (mp->retval);
1870 if (vam->async_mode)
1872 vam->async_errors += (retval < 0);
1876 vam->retval = retval;
1877 vam->sw_if_index = ntohl (mp->sw_if_index);
1878 vam->result_ready = 1;
1882 static void vl_api_bond_create_reply_t_handler_json
1883 (vl_api_bond_create_reply_t * mp)
1885 vat_main_t *vam = &vat_main;
1886 vat_json_node_t node;
1888 vat_json_init_object (&node);
1889 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1890 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
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_delete_reply_t_handler (vl_api_bond_delete_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->result_ready = 1;
1916 static void vl_api_bond_delete_reply_t_handler_json
1917 (vl_api_bond_delete_reply_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 vat_json_node_t node;
1922 vat_json_init_object (&node);
1923 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1925 vat_json_print (vam->ofp, &node);
1926 vat_json_free (&node);
1928 vam->retval = ntohl (mp->retval);
1929 vam->result_ready = 1;
1933 vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp)
1935 vat_main_t *vam = &vat_main;
1936 i32 retval = ntohl (mp->retval);
1938 if (vam->async_mode)
1940 vam->async_errors += (retval < 0);
1944 vam->retval = retval;
1945 vam->result_ready = 1;
1949 static void vl_api_bond_add_member_reply_t_handler_json
1950 (vl_api_bond_add_member_reply_t * mp)
1952 vat_main_t *vam = &vat_main;
1953 vat_json_node_t node;
1955 vat_json_init_object (&node);
1956 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1958 vat_json_print (vam->ofp, &node);
1959 vat_json_free (&node);
1961 vam->retval = ntohl (mp->retval);
1962 vam->result_ready = 1;
1966 vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t *
1969 vat_main_t *vam = &vat_main;
1970 i32 retval = ntohl (mp->retval);
1972 if (vam->async_mode)
1974 vam->async_errors += (retval < 0);
1978 vam->retval = retval;
1979 vam->result_ready = 1;
1983 static void vl_api_bond_detach_member_reply_t_handler_json
1984 (vl_api_bond_detach_member_reply_t * mp)
1986 vat_main_t *vam = &vat_main;
1987 vat_json_node_t node;
1989 vat_json_init_object (&node);
1990 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1992 vat_json_print (vam->ofp, &node);
1993 vat_json_free (&node);
1995 vam->retval = ntohl (mp->retval);
1996 vam->result_ready = 1;
2000 api_sw_interface_set_bond_weight (vat_main_t * vam)
2002 unformat_input_t *i = vam->input;
2003 vl_api_sw_interface_set_bond_weight_t *mp;
2004 u32 sw_if_index = ~0;
2006 u8 weight_enter = 0;
2009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2015 else if (unformat (i, "weight %u", &weight))
2021 if (sw_if_index == ~0)
2023 errmsg ("missing interface name or sw_if_index");
2026 if (weight_enter == 0)
2028 errmsg ("missing valid weight");
2032 /* Construct the API message */
2033 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2034 mp->sw_if_index = ntohl (sw_if_index);
2035 mp->weight = ntohl (weight);
2042 static void vl_api_sw_bond_interface_details_t_handler
2043 (vl_api_sw_bond_interface_details_t * mp)
2045 vat_main_t *vam = &vat_main;
2048 "%-16s %-12d %-12U %-13U %-14u %-14u",
2049 mp->interface_name, ntohl (mp->sw_if_index),
2050 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2051 ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members));
2054 static void vl_api_sw_bond_interface_details_t_handler_json
2055 (vl_api_sw_bond_interface_details_t * mp)
2057 vat_main_t *vam = &vat_main;
2058 vat_json_node_t *node = NULL;
2060 if (VAT_JSON_ARRAY != vam->json_tree.type)
2062 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2063 vat_json_init_array (&vam->json_tree);
2065 node = vat_json_array_add (&vam->json_tree);
2067 vat_json_init_object (node);
2068 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2069 vat_json_object_add_string_copy (node, "interface_name",
2070 mp->interface_name);
2071 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2072 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2073 vat_json_object_add_uint (node, "active_members",
2074 ntohl (mp->active_members));
2075 vat_json_object_add_uint (node, "members", ntohl (mp->members));
2079 api_sw_bond_interface_dump (vat_main_t * vam)
2081 unformat_input_t *i = vam->input;
2082 vl_api_sw_bond_interface_dump_t *mp;
2083 vl_api_control_ping_t *mp_ping;
2085 u32 sw_if_index = ~0;
2087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2098 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2099 "interface name", "sw_if_index", "mode", "load balance",
2100 "active members", "members");
2102 /* Get list of bond interfaces */
2103 M (SW_BOND_INTERFACE_DUMP, mp);
2104 mp->sw_if_index = ntohl (sw_if_index);
2107 /* Use a control ping for synchronization */
2108 MPING (CONTROL_PING, mp_ping);
2115 static void vl_api_sw_member_interface_details_t_handler
2116 (vl_api_sw_member_interface_details_t * mp)
2118 vat_main_t *vam = &vat_main;
2121 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2122 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2123 ntohl (mp->weight), mp->is_local_numa);
2126 static void vl_api_sw_member_interface_details_t_handler_json
2127 (vl_api_sw_member_interface_details_t * mp)
2129 vat_main_t *vam = &vat_main;
2130 vat_json_node_t *node = NULL;
2132 if (VAT_JSON_ARRAY != vam->json_tree.type)
2134 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2135 vat_json_init_array (&vam->json_tree);
2137 node = vat_json_array_add (&vam->json_tree);
2139 vat_json_init_object (node);
2140 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2141 vat_json_object_add_string_copy (node, "interface_name",
2142 mp->interface_name);
2143 vat_json_object_add_uint (node, "passive", mp->is_passive);
2144 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2145 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2146 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2150 api_sw_member_interface_dump (vat_main_t * vam)
2152 unformat_input_t *i = vam->input;
2153 vl_api_sw_member_interface_dump_t *mp;
2154 vl_api_control_ping_t *mp_ping;
2155 u32 sw_if_index = ~0;
2156 u8 sw_if_index_set = 0;
2159 /* Parse args required to build the message */
2160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2163 sw_if_index_set = 1;
2164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2165 sw_if_index_set = 1;
2170 if (sw_if_index_set == 0)
2172 errmsg ("missing vpp interface name. ");
2177 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2178 "member interface name", "sw_if_index", "passive", "long_timeout",
2179 "weight", "local numa");
2181 /* Get list of bond interfaces */
2182 M (SW_MEMBER_INTERFACE_DUMP, mp);
2183 mp->sw_if_index = ntohl (sw_if_index);
2186 /* Use a control ping for synchronization */
2187 MPING (CONTROL_PING, mp_ping);
2194 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2195 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2197 vat_main_t *vam = &vat_main;
2198 i32 retval = ntohl (mp->retval);
2199 if (vam->async_mode)
2201 vam->async_errors += (retval < 0);
2205 vam->retval = retval;
2206 vam->sw_if_index = ntohl (mp->sw_if_index);
2207 vam->result_ready = 1;
2209 vam->regenerate_interface_table = 1;
2212 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2213 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2215 vat_main_t *vam = &vat_main;
2216 vat_json_node_t node;
2218 vat_json_init_object (&node);
2219 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2220 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2221 ntohl (mp->sw_if_index));
2223 vat_json_print (vam->ofp, &node);
2224 vat_json_free (&node);
2226 vam->retval = ntohl (mp->retval);
2227 vam->result_ready = 1;
2230 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2231 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2233 vat_main_t *vam = &vat_main;
2234 i32 retval = ntohl (mp->retval);
2235 if (vam->async_mode)
2237 vam->async_errors += (retval < 0);
2241 vam->retval = retval;
2242 vam->sw_if_index = ntohl (mp->sw_if_index);
2243 vam->result_ready = 1;
2247 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2248 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2250 vat_main_t *vam = &vat_main;
2251 vat_json_node_t node;
2253 vat_json_init_object (&node);
2254 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2255 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2257 vat_json_print (vam->ofp, &node);
2258 vat_json_free (&node);
2260 vam->retval = ntohl (mp->retval);
2261 vam->result_ready = 1;
2264 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2265 (vl_api_gpe_add_del_fwd_entry_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->result_ready = 1;
2280 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2281 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2283 vat_main_t *vam = &vat_main;
2284 vat_json_node_t node;
2286 vat_json_init_object (&node);
2287 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2288 vat_json_object_add_uint (&node, "fwd_entry_index",
2289 clib_net_to_host_u32 (mp->fwd_entry_index));
2291 vat_json_print (vam->ofp, &node);
2292 vat_json_free (&node);
2294 vam->retval = ntohl (mp->retval);
2295 vam->result_ready = 1;
2299 format_lisp_transport_protocol (u8 * s, va_list * args)
2301 u32 proto = va_arg (*args, u32);
2306 return format (s, "udp");
2308 return format (s, "api");
2315 static void vl_api_one_get_transport_protocol_reply_t_handler
2316 (vl_api_one_get_transport_protocol_reply_t * mp)
2318 vat_main_t *vam = &vat_main;
2319 i32 retval = ntohl (mp->retval);
2320 if (vam->async_mode)
2322 vam->async_errors += (retval < 0);
2326 u32 proto = mp->protocol;
2327 print (vam->ofp, "Transport protocol: %U",
2328 format_lisp_transport_protocol, proto);
2329 vam->retval = retval;
2330 vam->result_ready = 1;
2334 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2335 (vl_api_one_get_transport_protocol_reply_t * mp)
2337 vat_main_t *vam = &vat_main;
2338 vat_json_node_t node;
2341 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2344 vat_json_init_object (&node);
2345 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2346 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2349 vat_json_print (vam->ofp, &node);
2350 vat_json_free (&node);
2352 vam->retval = ntohl (mp->retval);
2353 vam->result_ready = 1;
2356 static void vl_api_one_add_del_locator_set_reply_t_handler
2357 (vl_api_one_add_del_locator_set_reply_t * mp)
2359 vat_main_t *vam = &vat_main;
2360 i32 retval = ntohl (mp->retval);
2361 if (vam->async_mode)
2363 vam->async_errors += (retval < 0);
2367 vam->retval = retval;
2368 vam->result_ready = 1;
2372 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2373 (vl_api_one_add_del_locator_set_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 vat_json_node_t node;
2378 vat_json_init_object (&node);
2379 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2380 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2382 vat_json_print (vam->ofp, &node);
2383 vat_json_free (&node);
2385 vam->retval = ntohl (mp->retval);
2386 vam->result_ready = 1;
2389 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2390 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2392 vat_main_t *vam = &vat_main;
2393 i32 retval = ntohl (mp->retval);
2394 if (vam->async_mode)
2396 vam->async_errors += (retval < 0);
2400 vam->retval = retval;
2401 vam->sw_if_index = ntohl (mp->sw_if_index);
2402 vam->result_ready = 1;
2404 vam->regenerate_interface_table = 1;
2407 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2408 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2410 vat_main_t *vam = &vat_main;
2411 vat_json_node_t node;
2413 vat_json_init_object (&node);
2414 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2415 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2417 vat_json_print (vam->ofp, &node);
2418 vat_json_free (&node);
2420 vam->retval = ntohl (mp->retval);
2421 vam->result_ready = 1;
2424 static void vl_api_vxlan_offload_rx_reply_t_handler
2425 (vl_api_vxlan_offload_rx_reply_t * mp)
2427 vat_main_t *vam = &vat_main;
2428 i32 retval = ntohl (mp->retval);
2429 if (vam->async_mode)
2431 vam->async_errors += (retval < 0);
2435 vam->retval = retval;
2436 vam->result_ready = 1;
2440 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2441 (vl_api_vxlan_offload_rx_reply_t * mp)
2443 vat_main_t *vam = &vat_main;
2444 vat_json_node_t node;
2446 vat_json_init_object (&node);
2447 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2449 vat_json_print (vam->ofp, &node);
2450 vat_json_free (&node);
2452 vam->retval = ntohl (mp->retval);
2453 vam->result_ready = 1;
2456 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2457 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2459 vat_main_t *vam = &vat_main;
2460 i32 retval = ntohl (mp->retval);
2461 if (vam->async_mode)
2463 vam->async_errors += (retval < 0);
2467 vam->retval = retval;
2468 vam->sw_if_index = ntohl (mp->sw_if_index);
2469 vam->result_ready = 1;
2473 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2474 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2476 vat_main_t *vam = &vat_main;
2477 vat_json_node_t node;
2479 vat_json_init_object (&node);
2480 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2481 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2483 vat_json_print (vam->ofp, &node);
2484 vat_json_free (&node);
2486 vam->retval = ntohl (mp->retval);
2487 vam->result_ready = 1;
2490 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2491 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2493 vat_main_t *vam = &vat_main;
2494 i32 retval = ntohl (mp->retval);
2495 if (vam->async_mode)
2497 vam->async_errors += (retval < 0);
2501 vam->retval = retval;
2502 vam->sw_if_index = ntohl (mp->sw_if_index);
2503 vam->result_ready = 1;
2505 vam->regenerate_interface_table = 1;
2508 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2509 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2511 vat_main_t *vam = &vat_main;
2512 vat_json_node_t node;
2514 vat_json_init_object (&node);
2515 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2516 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2518 vat_json_print (vam->ofp, &node);
2519 vat_json_free (&node);
2521 vam->retval = ntohl (mp->retval);
2522 vam->result_ready = 1;
2525 static void vl_api_gre_tunnel_add_del_reply_t_handler
2526 (vl_api_gre_tunnel_add_del_reply_t * mp)
2528 vat_main_t *vam = &vat_main;
2529 i32 retval = ntohl (mp->retval);
2530 if (vam->async_mode)
2532 vam->async_errors += (retval < 0);
2536 vam->retval = retval;
2537 vam->sw_if_index = ntohl (mp->sw_if_index);
2538 vam->result_ready = 1;
2542 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2543 (vl_api_gre_tunnel_add_del_reply_t * mp)
2545 vat_main_t *vam = &vat_main;
2546 vat_json_node_t node;
2548 vat_json_init_object (&node);
2549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2552 vat_json_print (vam->ofp, &node);
2553 vat_json_free (&node);
2555 vam->retval = ntohl (mp->retval);
2556 vam->result_ready = 1;
2559 static void vl_api_create_vhost_user_if_reply_t_handler
2560 (vl_api_create_vhost_user_if_reply_t * mp)
2562 vat_main_t *vam = &vat_main;
2563 i32 retval = ntohl (mp->retval);
2564 if (vam->async_mode)
2566 vam->async_errors += (retval < 0);
2570 vam->retval = retval;
2571 vam->sw_if_index = ntohl (mp->sw_if_index);
2572 vam->result_ready = 1;
2574 vam->regenerate_interface_table = 1;
2577 static void vl_api_create_vhost_user_if_reply_t_handler_json
2578 (vl_api_create_vhost_user_if_reply_t * mp)
2580 vat_main_t *vam = &vat_main;
2581 vat_json_node_t node;
2583 vat_json_init_object (&node);
2584 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2585 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2587 vat_json_print (vam->ofp, &node);
2588 vat_json_free (&node);
2590 vam->retval = ntohl (mp->retval);
2591 vam->result_ready = 1;
2594 static void vl_api_ip_address_details_t_handler
2595 (vl_api_ip_address_details_t * mp)
2597 vat_main_t *vam = &vat_main;
2598 static ip_address_details_t empty_ip_address_details = { {0} };
2599 ip_address_details_t *address = NULL;
2600 ip_details_t *current_ip_details = NULL;
2601 ip_details_t *details = NULL;
2603 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2605 if (!details || vam->current_sw_if_index >= vec_len (details)
2606 || !details[vam->current_sw_if_index].present)
2608 errmsg ("ip address details arrived but not stored");
2609 errmsg ("ip_dump should be called first");
2613 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2615 #define addresses (current_ip_details->addr)
2617 vec_validate_init_empty (addresses, vec_len (addresses),
2618 empty_ip_address_details);
2620 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2622 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2623 address->prefix_length = mp->prefix.len;
2627 static void vl_api_ip_address_details_t_handler_json
2628 (vl_api_ip_address_details_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vat_json_node_t *node = NULL;
2633 if (VAT_JSON_ARRAY != vam->json_tree.type)
2635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2636 vat_json_init_array (&vam->json_tree);
2638 node = vat_json_array_add (&vam->json_tree);
2640 vat_json_init_object (node);
2641 vat_json_object_add_prefix (node, &mp->prefix);
2645 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2647 vat_main_t *vam = &vat_main;
2648 static ip_details_t empty_ip_details = { 0 };
2649 ip_details_t *ip = NULL;
2650 u32 sw_if_index = ~0;
2652 sw_if_index = ntohl (mp->sw_if_index);
2654 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2655 sw_if_index, empty_ip_details);
2657 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2664 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2666 vat_main_t *vam = &vat_main;
2668 if (VAT_JSON_ARRAY != vam->json_tree.type)
2670 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2671 vat_json_init_array (&vam->json_tree);
2673 vat_json_array_add_uint (&vam->json_tree,
2674 clib_net_to_host_u32 (mp->sw_if_index));
2677 static void vl_api_get_first_msg_id_reply_t_handler
2678 (vl_api_get_first_msg_id_reply_t * mp)
2680 vat_main_t *vam = &vat_main;
2681 i32 retval = ntohl (mp->retval);
2683 if (vam->async_mode)
2685 vam->async_errors += (retval < 0);
2689 vam->retval = retval;
2690 vam->result_ready = 1;
2694 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2698 static void vl_api_get_first_msg_id_reply_t_handler_json
2699 (vl_api_get_first_msg_id_reply_t * mp)
2701 vat_main_t *vam = &vat_main;
2702 vat_json_node_t node;
2704 vat_json_init_object (&node);
2705 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2706 vat_json_object_add_uint (&node, "first_msg_id",
2707 (uint) ntohs (mp->first_msg_id));
2709 vat_json_print (vam->ofp, &node);
2710 vat_json_free (&node);
2712 vam->retval = ntohl (mp->retval);
2713 vam->result_ready = 1;
2716 static void vl_api_get_node_graph_reply_t_handler
2717 (vl_api_get_node_graph_reply_t * mp)
2719 vat_main_t *vam = &vat_main;
2720 i32 retval = ntohl (mp->retval);
2721 u8 *pvt_copy, *reply;
2726 if (vam->async_mode)
2728 vam->async_errors += (retval < 0);
2732 vam->retval = retval;
2733 vam->result_ready = 1;
2736 /* "Should never happen..." */
2740 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2741 pvt_copy = vec_dup (reply);
2743 /* Toss the shared-memory original... */
2744 oldheap = vl_msg_push_heap ();
2748 vl_msg_pop_heap (oldheap);
2750 if (vam->graph_nodes)
2752 hash_free (vam->graph_node_index_by_name);
2754 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2756 node = vam->graph_nodes[0][i];
2757 vec_free (node->name);
2758 vec_free (node->next_nodes);
2761 vec_free (vam->graph_nodes[0]);
2762 vec_free (vam->graph_nodes);
2765 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2766 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2767 vec_free (pvt_copy);
2769 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2771 node = vam->graph_nodes[0][i];
2772 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2776 static void vl_api_get_node_graph_reply_t_handler_json
2777 (vl_api_get_node_graph_reply_t * mp)
2779 vat_main_t *vam = &vat_main;
2781 vat_json_node_t node;
2784 /* $$$$ make this real? */
2785 vat_json_init_object (&node);
2786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2787 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2789 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2791 /* Toss the shared-memory original... */
2792 oldheap = vl_msg_push_heap ();
2796 vl_msg_pop_heap (oldheap);
2798 vat_json_print (vam->ofp, &node);
2799 vat_json_free (&node);
2801 vam->retval = ntohl (mp->retval);
2802 vam->result_ready = 1;
2806 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2808 vat_main_t *vam = &vat_main;
2813 s = format (s, "%=16d%=16d%=16d",
2814 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2818 s = format (s, "%=16U%=16d%=16d",
2819 format_ip46_address,
2820 mp->ip_address, mp->priority, mp->weight);
2823 print (vam->ofp, "%v", s);
2828 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2830 vat_main_t *vam = &vat_main;
2831 vat_json_node_t *node = NULL;
2832 struct in6_addr ip6;
2835 if (VAT_JSON_ARRAY != vam->json_tree.type)
2837 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2838 vat_json_init_array (&vam->json_tree);
2840 node = vat_json_array_add (&vam->json_tree);
2841 vat_json_init_object (node);
2843 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2844 vat_json_object_add_uint (node, "priority", mp->priority);
2845 vat_json_object_add_uint (node, "weight", mp->weight);
2848 vat_json_object_add_uint (node, "sw_if_index",
2849 clib_net_to_host_u32 (mp->sw_if_index));
2852 if (mp->ip_address.af)
2854 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
2855 vat_json_object_add_ip6 (node, "address", ip6);
2859 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
2860 vat_json_object_add_ip4 (node, "address", ip4);
2866 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2869 vat_main_t *vam = &vat_main;
2872 ls_name = format (0, "%s", mp->ls_name);
2874 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2880 vl_api_one_locator_set_details_t_handler_json
2881 (vl_api_one_locator_set_details_t * mp)
2883 vat_main_t *vam = &vat_main;
2884 vat_json_node_t *node = 0;
2887 ls_name = format (0, "%s", mp->ls_name);
2888 vec_add1 (ls_name, 0);
2890 if (VAT_JSON_ARRAY != vam->json_tree.type)
2892 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2893 vat_json_init_array (&vam->json_tree);
2895 node = vat_json_array_add (&vam->json_tree);
2897 vat_json_init_object (node);
2898 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2899 vat_json_object_add_uint (node, "ls_index",
2900 clib_net_to_host_u32 (mp->ls_index));
2908 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2911 unformat_nsh_address (unformat_input_t * input, va_list * args)
2913 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2914 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2918 format_nsh_address_vat (u8 * s, va_list * args)
2920 nsh_t *a = va_arg (*args, nsh_t *);
2921 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2925 format_lisp_flat_eid (u8 * s, va_list * args)
2927 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
2931 case EID_TYPE_API_PREFIX:
2932 if (eid->address.prefix.address.af)
2933 return format (s, "%U/%d", format_ip6_address,
2934 eid->address.prefix.address.un.ip6,
2935 eid->address.prefix.len);
2936 return format (s, "%U/%d", format_ip4_address,
2937 eid->address.prefix.address.un.ip4,
2938 eid->address.prefix.len);
2939 case EID_TYPE_API_MAC:
2940 return format (s, "%U", format_ethernet_address, eid->address.mac);
2941 case EID_TYPE_API_NSH:
2942 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
2948 format_lisp_eid_vat (u8 * s, va_list * args)
2950 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
2951 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
2952 u8 is_src_dst = (u8) va_arg (*args, int);
2955 s = format (s, "%U|", format_lisp_flat_eid, seid);
2957 s = format (s, "%U", format_lisp_flat_eid, deid);
2963 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2965 vat_main_t *vam = &vat_main;
2966 u8 *s = 0, *eid = 0;
2968 if (~0 == mp->locator_set_index)
2969 s = format (0, "action: %d", mp->action);
2971 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2973 eid = format (0, "%U", format_lisp_eid_vat,
2974 &mp->deid, &mp->seid, mp->is_src_dst);
2977 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2978 clib_net_to_host_u32 (mp->vni),
2980 mp->is_local ? "local" : "remote",
2981 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2982 clib_net_to_host_u16 (mp->key.id), mp->key.key);
2989 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2992 vat_main_t *vam = &vat_main;
2993 vat_json_node_t *node = 0;
2996 if (VAT_JSON_ARRAY != vam->json_tree.type)
2998 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2999 vat_json_init_array (&vam->json_tree);
3001 node = vat_json_array_add (&vam->json_tree);
3003 vat_json_init_object (node);
3004 if (~0 == mp->locator_set_index)
3005 vat_json_object_add_uint (node, "action", mp->action);
3007 vat_json_object_add_uint (node, "locator_set_index",
3008 clib_net_to_host_u32 (mp->locator_set_index));
3010 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3011 if (mp->deid.type == 3)
3013 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3014 vat_json_init_object (nsh_json);
3015 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh;
3016 vat_json_object_add_uint (nsh_json, "spi",
3017 clib_net_to_host_u32 (nsh->spi));
3018 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3022 eid = format (0, "%U", format_lisp_eid_vat,
3023 &mp->deid, &mp->seid, mp->is_src_dst);
3025 vat_json_object_add_string_copy (node, "eid", eid);
3028 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3029 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3030 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3034 vat_json_object_add_uint (node, "key_id",
3035 clib_net_to_host_u16 (mp->key.id));
3036 vat_json_object_add_string_copy (node, "key", mp->key.key);
3041 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3043 vat_main_t *vam = &vat_main;
3044 u8 *seid = 0, *deid = 0;
3045 ip46_address_t lloc, rloc;
3047 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3049 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3056 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
3057 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
3061 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
3062 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
3066 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3067 clib_net_to_host_u32 (mp->vni),
3069 format_ip46_address, lloc,
3070 format_ip46_address, rloc,
3071 clib_net_to_host_u32 (mp->pkt_count),
3072 clib_net_to_host_u32 (mp->bytes));
3079 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3081 struct in6_addr ip6;
3083 vat_main_t *vam = &vat_main;
3084 vat_json_node_t *node = 0;
3085 u8 *deid = 0, *seid = 0;
3087 if (VAT_JSON_ARRAY != vam->json_tree.type)
3089 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3090 vat_json_init_array (&vam->json_tree);
3092 node = vat_json_array_add (&vam->json_tree);
3094 vat_json_init_object (node);
3095 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3097 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3102 vat_json_object_add_string_copy (node, "seid", seid);
3103 vat_json_object_add_string_copy (node, "deid", deid);
3104 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3108 clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6));
3109 vat_json_object_add_ip6 (node, "lloc", ip6);
3110 clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6));
3111 vat_json_object_add_ip6 (node, "rloc", ip6);
3116 clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4));
3117 vat_json_object_add_ip4 (node, "lloc", ip4);
3118 clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4));
3119 vat_json_object_add_ip4 (node, "rloc", ip4);
3121 vat_json_object_add_uint (node, "pkt_count",
3122 clib_net_to_host_u32 (mp->pkt_count));
3123 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3130 vl_api_one_eid_table_map_details_t_handler
3131 (vl_api_one_eid_table_map_details_t * mp)
3133 vat_main_t *vam = &vat_main;
3135 u8 *line = format (0, "%=10d%=10d",
3136 clib_net_to_host_u32 (mp->vni),
3137 clib_net_to_host_u32 (mp->dp_table));
3138 print (vam->ofp, "%v", line);
3143 vl_api_one_eid_table_map_details_t_handler_json
3144 (vl_api_one_eid_table_map_details_t * mp)
3146 vat_main_t *vam = &vat_main;
3147 vat_json_node_t *node = NULL;
3149 if (VAT_JSON_ARRAY != vam->json_tree.type)
3151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3152 vat_json_init_array (&vam->json_tree);
3154 node = vat_json_array_add (&vam->json_tree);
3155 vat_json_init_object (node);
3156 vat_json_object_add_uint (node, "dp_table",
3157 clib_net_to_host_u32 (mp->dp_table));
3158 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3162 vl_api_one_eid_table_vni_details_t_handler
3163 (vl_api_one_eid_table_vni_details_t * mp)
3165 vat_main_t *vam = &vat_main;
3167 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3168 print (vam->ofp, "%v", line);
3173 vl_api_one_eid_table_vni_details_t_handler_json
3174 (vl_api_one_eid_table_vni_details_t * mp)
3176 vat_main_t *vam = &vat_main;
3177 vat_json_node_t *node = NULL;
3179 if (VAT_JSON_ARRAY != vam->json_tree.type)
3181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3182 vat_json_init_array (&vam->json_tree);
3184 node = vat_json_array_add (&vam->json_tree);
3185 vat_json_init_object (node);
3186 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3190 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3191 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3193 vat_main_t *vam = &vat_main;
3194 int retval = clib_net_to_host_u32 (mp->retval);
3196 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3197 print (vam->ofp, "fallback threshold value: %d", mp->value);
3199 vam->retval = retval;
3200 vam->result_ready = 1;
3204 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3205 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3207 vat_main_t *vam = &vat_main;
3208 vat_json_node_t _node, *node = &_node;
3209 int retval = clib_net_to_host_u32 (mp->retval);
3211 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3212 vat_json_init_object (node);
3213 vat_json_object_add_uint (node, "value", mp->value);
3215 vat_json_print (vam->ofp, node);
3216 vat_json_free (node);
3218 vam->retval = retval;
3219 vam->result_ready = 1;
3223 vl_api_show_one_map_register_state_reply_t_handler
3224 (vl_api_show_one_map_register_state_reply_t * mp)
3226 vat_main_t *vam = &vat_main;
3227 int retval = clib_net_to_host_u32 (mp->retval);
3229 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3231 vam->retval = retval;
3232 vam->result_ready = 1;
3236 vl_api_show_one_map_register_state_reply_t_handler_json
3237 (vl_api_show_one_map_register_state_reply_t * mp)
3239 vat_main_t *vam = &vat_main;
3240 vat_json_node_t _node, *node = &_node;
3241 int retval = clib_net_to_host_u32 (mp->retval);
3243 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3245 vat_json_init_object (node);
3246 vat_json_object_add_string_copy (node, "state", s);
3248 vat_json_print (vam->ofp, node);
3249 vat_json_free (node);
3251 vam->retval = retval;
3252 vam->result_ready = 1;
3257 vl_api_show_one_rloc_probe_state_reply_t_handler
3258 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3260 vat_main_t *vam = &vat_main;
3261 int retval = clib_net_to_host_u32 (mp->retval);
3266 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3268 vam->retval = retval;
3269 vam->result_ready = 1;
3273 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3274 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3276 vat_main_t *vam = &vat_main;
3277 vat_json_node_t _node, *node = &_node;
3278 int retval = clib_net_to_host_u32 (mp->retval);
3280 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3281 vat_json_init_object (node);
3282 vat_json_object_add_string_copy (node, "state", s);
3284 vat_json_print (vam->ofp, node);
3285 vat_json_free (node);
3287 vam->retval = retval;
3288 vam->result_ready = 1;
3293 vl_api_show_one_stats_enable_disable_reply_t_handler
3294 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 int retval = clib_net_to_host_u32 (mp->retval);
3302 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3304 vam->retval = retval;
3305 vam->result_ready = 1;
3309 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3310 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3312 vat_main_t *vam = &vat_main;
3313 vat_json_node_t _node, *node = &_node;
3314 int retval = clib_net_to_host_u32 (mp->retval);
3316 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3317 vat_json_init_object (node);
3318 vat_json_object_add_string_copy (node, "state", s);
3320 vat_json_print (vam->ofp, node);
3321 vat_json_free (node);
3323 vam->retval = retval;
3324 vam->result_ready = 1;
3329 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3331 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3332 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3333 e->vni = clib_net_to_host_u32 (e->vni);
3337 gpe_fwd_entries_get_reply_t_net_to_host
3338 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3342 mp->count = clib_net_to_host_u32 (mp->count);
3343 for (i = 0; i < mp->count; i++)
3345 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3350 format_gpe_encap_mode (u8 * s, va_list * args)
3352 u32 mode = va_arg (*args, u32);
3357 return format (s, "lisp");
3359 return format (s, "vxlan");
3365 vl_api_gpe_get_encap_mode_reply_t_handler
3366 (vl_api_gpe_get_encap_mode_reply_t * mp)
3368 vat_main_t *vam = &vat_main;
3370 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3371 vam->retval = ntohl (mp->retval);
3372 vam->result_ready = 1;
3376 vl_api_gpe_get_encap_mode_reply_t_handler_json
3377 (vl_api_gpe_get_encap_mode_reply_t * mp)
3379 vat_main_t *vam = &vat_main;
3380 vat_json_node_t node;
3382 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3383 vec_add1 (encap_mode, 0);
3385 vat_json_init_object (&node);
3386 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3388 vec_free (encap_mode);
3389 vat_json_print (vam->ofp, &node);
3390 vat_json_free (&node);
3392 vam->retval = ntohl (mp->retval);
3393 vam->result_ready = 1;
3397 vl_api_gpe_fwd_entry_path_details_t_handler
3398 (vl_api_gpe_fwd_entry_path_details_t * mp)
3400 vat_main_t *vam = &vat_main;
3401 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3403 if (mp->lcl_loc.addr.af)
3404 format_ip_address_fcn = format_ip6_address;
3406 format_ip_address_fcn = format_ip4_address;
3408 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3409 format_ip_address_fcn, &mp->lcl_loc.addr.un,
3410 format_ip_address_fcn, &mp->rmt_loc.addr.un);
3414 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3416 struct in6_addr ip6;
3421 clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6));
3422 vat_json_object_add_ip6 (n, "address", ip6);
3426 clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4));
3427 vat_json_object_add_ip4 (n, "address", ip4);
3429 vat_json_object_add_uint (n, "weight", loc->weight);
3433 vl_api_gpe_fwd_entry_path_details_t_handler_json
3434 (vl_api_gpe_fwd_entry_path_details_t * mp)
3436 vat_main_t *vam = &vat_main;
3437 vat_json_node_t *node = NULL;
3438 vat_json_node_t *loc_node;
3440 if (VAT_JSON_ARRAY != vam->json_tree.type)
3442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3443 vat_json_init_array (&vam->json_tree);
3445 node = vat_json_array_add (&vam->json_tree);
3446 vat_json_init_object (node);
3448 loc_node = vat_json_object_add (node, "local_locator");
3449 vat_json_init_object (loc_node);
3450 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3452 loc_node = vat_json_object_add (node, "remote_locator");
3453 vat_json_init_object (loc_node);
3454 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3458 vl_api_gpe_fwd_entries_get_reply_t_handler
3459 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3461 vat_main_t *vam = &vat_main;
3463 int retval = clib_net_to_host_u32 (mp->retval);
3464 vl_api_gpe_fwd_entry_t *e;
3469 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3471 for (i = 0; i < mp->count; i++)
3473 e = &mp->entries[i];
3474 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3475 format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid);
3479 vam->retval = retval;
3480 vam->result_ready = 1;
3484 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3485 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3488 vat_main_t *vam = &vat_main;
3489 vat_json_node_t *e = 0, root;
3491 int retval = clib_net_to_host_u32 (mp->retval);
3492 vl_api_gpe_fwd_entry_t *fwd;
3497 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3498 vat_json_init_array (&root);
3500 for (i = 0; i < mp->count; i++)
3502 e = vat_json_array_add (&root);
3503 fwd = &mp->entries[i];
3505 vat_json_init_object (e);
3506 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3507 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3508 vat_json_object_add_int (e, "vni", fwd->vni);
3509 vat_json_object_add_int (e, "action", fwd->action);
3511 s = format (0, "%U", format_lisp_flat_eid, fwd->leid);
3513 vat_json_object_add_string_copy (e, "leid", s);
3516 s = format (0, "%U", format_lisp_flat_eid, fwd->reid);
3518 vat_json_object_add_string_copy (e, "reid", s);
3522 vat_json_print (vam->ofp, &root);
3523 vat_json_free (&root);
3526 vam->retval = retval;
3527 vam->result_ready = 1;
3531 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3532 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3534 vat_main_t *vam = &vat_main;
3536 int retval = clib_net_to_host_u32 (mp->retval);
3537 vl_api_gpe_native_fwd_rpath_t *r;
3542 n = clib_net_to_host_u32 (mp->count);
3544 for (i = 0; i < n; i++)
3546 r = &mp->entries[i];
3547 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3548 clib_net_to_host_u32 (r->fib_index),
3549 clib_net_to_host_u32 (r->nh_sw_if_index),
3550 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3555 vam->retval = retval;
3556 vam->result_ready = 1;
3560 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3561 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3563 vat_main_t *vam = &vat_main;
3564 vat_json_node_t root, *e;
3566 int retval = clib_net_to_host_u32 (mp->retval);
3567 vl_api_gpe_native_fwd_rpath_t *r;
3573 n = clib_net_to_host_u32 (mp->count);
3574 vat_json_init_array (&root);
3576 for (i = 0; i < n; i++)
3578 e = vat_json_array_add (&root);
3579 vat_json_init_object (e);
3580 r = &mp->entries[i];
3583 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3586 vat_json_object_add_string_copy (e, "ip4", s);
3589 vat_json_object_add_uint (e, "fib_index",
3590 clib_net_to_host_u32 (r->fib_index));
3591 vat_json_object_add_uint (e, "nh_sw_if_index",
3592 clib_net_to_host_u32 (r->nh_sw_if_index));
3595 vat_json_print (vam->ofp, &root);
3596 vat_json_free (&root);
3599 vam->retval = retval;
3600 vam->result_ready = 1;
3604 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3605 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3607 vat_main_t *vam = &vat_main;
3609 int retval = clib_net_to_host_u32 (mp->retval);
3614 n = clib_net_to_host_u32 (mp->count);
3616 for (i = 0; i < n; i++)
3617 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3620 vam->retval = retval;
3621 vam->result_ready = 1;
3625 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3626 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3628 vat_main_t *vam = &vat_main;
3629 vat_json_node_t root;
3631 int retval = clib_net_to_host_u32 (mp->retval);
3636 n = clib_net_to_host_u32 (mp->count);
3637 vat_json_init_array (&root);
3639 for (i = 0; i < n; i++)
3640 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3642 vat_json_print (vam->ofp, &root);
3643 vat_json_free (&root);
3646 vam->retval = retval;
3647 vam->result_ready = 1;
3651 vl_api_one_ndp_entries_get_reply_t_handler
3652 (vl_api_one_ndp_entries_get_reply_t * mp)
3654 vat_main_t *vam = &vat_main;
3656 int retval = clib_net_to_host_u32 (mp->retval);
3661 n = clib_net_to_host_u32 (mp->count);
3663 for (i = 0; i < n; i++)
3664 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3665 format_ethernet_address, mp->entries[i].mac);
3668 vam->retval = retval;
3669 vam->result_ready = 1;
3673 vl_api_one_ndp_entries_get_reply_t_handler_json
3674 (vl_api_one_ndp_entries_get_reply_t * mp)
3677 vat_main_t *vam = &vat_main;
3678 vat_json_node_t *e = 0, root;
3680 int retval = clib_net_to_host_u32 (mp->retval);
3681 vl_api_one_ndp_entry_t *arp_entry;
3686 n = clib_net_to_host_u32 (mp->count);
3687 vat_json_init_array (&root);
3689 for (i = 0; i < n; i++)
3691 e = vat_json_array_add (&root);
3692 arp_entry = &mp->entries[i];
3694 vat_json_init_object (e);
3695 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3698 vat_json_object_add_string_copy (e, "mac", s);
3701 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3703 vat_json_object_add_string_copy (e, "ip6", s);
3707 vat_json_print (vam->ofp, &root);
3708 vat_json_free (&root);
3711 vam->retval = retval;
3712 vam->result_ready = 1;
3716 vl_api_one_l2_arp_entries_get_reply_t_handler
3717 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3719 vat_main_t *vam = &vat_main;
3721 int retval = clib_net_to_host_u32 (mp->retval);
3726 n = clib_net_to_host_u32 (mp->count);
3728 for (i = 0; i < n; i++)
3729 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3730 format_ethernet_address, mp->entries[i].mac);
3733 vam->retval = retval;
3734 vam->result_ready = 1;
3738 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3739 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3742 vat_main_t *vam = &vat_main;
3743 vat_json_node_t *e = 0, root;
3745 int retval = clib_net_to_host_u32 (mp->retval);
3746 vl_api_one_l2_arp_entry_t *arp_entry;
3751 n = clib_net_to_host_u32 (mp->count);
3752 vat_json_init_array (&root);
3754 for (i = 0; i < n; i++)
3756 e = vat_json_array_add (&root);
3757 arp_entry = &mp->entries[i];
3759 vat_json_init_object (e);
3760 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3763 vat_json_object_add_string_copy (e, "mac", s);
3766 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3768 vat_json_object_add_string_copy (e, "ip4", s);
3772 vat_json_print (vam->ofp, &root);
3773 vat_json_free (&root);
3776 vam->retval = retval;
3777 vam->result_ready = 1;
3781 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3783 vat_main_t *vam = &vat_main;
3785 int retval = clib_net_to_host_u32 (mp->retval);
3790 n = clib_net_to_host_u32 (mp->count);
3792 for (i = 0; i < n; i++)
3794 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3798 vam->retval = retval;
3799 vam->result_ready = 1;
3803 vl_api_one_ndp_bd_get_reply_t_handler_json
3804 (vl_api_one_ndp_bd_get_reply_t * mp)
3806 vat_main_t *vam = &vat_main;
3807 vat_json_node_t root;
3809 int retval = clib_net_to_host_u32 (mp->retval);
3814 n = clib_net_to_host_u32 (mp->count);
3815 vat_json_init_array (&root);
3817 for (i = 0; i < n; i++)
3819 vat_json_array_add_uint (&root,
3820 clib_net_to_host_u32 (mp->bridge_domains[i]));
3823 vat_json_print (vam->ofp, &root);
3824 vat_json_free (&root);
3827 vam->retval = retval;
3828 vam->result_ready = 1;
3832 vl_api_one_l2_arp_bd_get_reply_t_handler
3833 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3835 vat_main_t *vam = &vat_main;
3837 int retval = clib_net_to_host_u32 (mp->retval);
3842 n = clib_net_to_host_u32 (mp->count);
3844 for (i = 0; i < n; i++)
3846 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3850 vam->retval = retval;
3851 vam->result_ready = 1;
3855 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3856 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3858 vat_main_t *vam = &vat_main;
3859 vat_json_node_t root;
3861 int retval = clib_net_to_host_u32 (mp->retval);
3866 n = clib_net_to_host_u32 (mp->count);
3867 vat_json_init_array (&root);
3869 for (i = 0; i < n; i++)
3871 vat_json_array_add_uint (&root,
3872 clib_net_to_host_u32 (mp->bridge_domains[i]));
3875 vat_json_print (vam->ofp, &root);
3876 vat_json_free (&root);
3879 vam->retval = retval;
3880 vam->result_ready = 1;
3884 vl_api_one_adjacencies_get_reply_t_handler
3885 (vl_api_one_adjacencies_get_reply_t * mp)
3887 vat_main_t *vam = &vat_main;
3889 int retval = clib_net_to_host_u32 (mp->retval);
3890 vl_api_one_adjacency_t *a;
3895 n = clib_net_to_host_u32 (mp->count);
3897 for (i = 0; i < n; i++)
3899 a = &mp->adjacencies[i];
3900 print (vam->ofp, "%U %40U",
3901 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
3905 vam->retval = retval;
3906 vam->result_ready = 1;
3910 vl_api_one_adjacencies_get_reply_t_handler_json
3911 (vl_api_one_adjacencies_get_reply_t * mp)
3914 vat_main_t *vam = &vat_main;
3915 vat_json_node_t *e = 0, root;
3917 int retval = clib_net_to_host_u32 (mp->retval);
3918 vl_api_one_adjacency_t *a;
3923 n = clib_net_to_host_u32 (mp->count);
3924 vat_json_init_array (&root);
3926 for (i = 0; i < n; i++)
3928 e = vat_json_array_add (&root);
3929 a = &mp->adjacencies[i];
3931 vat_json_init_object (e);
3932 s = format (0, "%U", format_lisp_flat_eid, a->leid);
3934 vat_json_object_add_string_copy (e, "leid", s);
3937 s = format (0, "%U", format_lisp_flat_eid, a->reid);
3939 vat_json_object_add_string_copy (e, "reid", s);
3943 vat_json_print (vam->ofp, &root);
3944 vat_json_free (&root);
3947 vam->retval = retval;
3948 vam->result_ready = 1;
3952 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3954 vat_main_t *vam = &vat_main;
3956 print (vam->ofp, "%=20U",
3957 mp->ip_address.af ? format_ip6_address : format_ip4_address,
3962 vl_api_one_map_server_details_t_handler_json
3963 (vl_api_one_map_server_details_t * mp)
3965 vat_main_t *vam = &vat_main;
3966 vat_json_node_t *node = NULL;
3967 struct in6_addr ip6;
3970 if (VAT_JSON_ARRAY != vam->json_tree.type)
3972 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3973 vat_json_init_array (&vam->json_tree);
3975 node = vat_json_array_add (&vam->json_tree);
3977 vat_json_init_object (node);
3978 if (mp->ip_address.af)
3980 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
3981 vat_json_object_add_ip6 (node, "map-server", ip6);
3985 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
3986 vat_json_object_add_ip4 (node, "map-server", ip4);
3991 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3994 vat_main_t *vam = &vat_main;
3996 print (vam->ofp, "%=20U",
3997 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4002 vl_api_one_map_resolver_details_t_handler_json
4003 (vl_api_one_map_resolver_details_t * mp)
4005 vat_main_t *vam = &vat_main;
4006 vat_json_node_t *node = NULL;
4007 struct in6_addr ip6;
4010 if (VAT_JSON_ARRAY != vam->json_tree.type)
4012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4013 vat_json_init_array (&vam->json_tree);
4015 node = vat_json_array_add (&vam->json_tree);
4017 vat_json_init_object (node);
4018 if (mp->ip_address.af)
4020 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4021 vat_json_object_add_ip6 (node, "map resolver", ip6);
4025 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4026 vat_json_object_add_ip4 (node, "map resolver", ip4);
4031 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4033 vat_main_t *vam = &vat_main;
4034 i32 retval = ntohl (mp->retval);
4038 print (vam->ofp, "feature: %s\ngpe: %s",
4039 mp->feature_status ? "enabled" : "disabled",
4040 mp->gpe_status ? "enabled" : "disabled");
4043 vam->retval = retval;
4044 vam->result_ready = 1;
4048 vl_api_show_one_status_reply_t_handler_json
4049 (vl_api_show_one_status_reply_t * mp)
4051 vat_main_t *vam = &vat_main;
4052 vat_json_node_t node;
4053 u8 *gpe_status = NULL;
4054 u8 *feature_status = NULL;
4056 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4057 feature_status = format (0, "%s",
4058 mp->feature_status ? "enabled" : "disabled");
4059 vec_add1 (gpe_status, 0);
4060 vec_add1 (feature_status, 0);
4062 vat_json_init_object (&node);
4063 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4064 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4066 vec_free (gpe_status);
4067 vec_free (feature_status);
4069 vat_json_print (vam->ofp, &node);
4070 vat_json_free (&node);
4072 vam->retval = ntohl (mp->retval);
4073 vam->result_ready = 1;
4077 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4078 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4080 vat_main_t *vam = &vat_main;
4081 i32 retval = ntohl (mp->retval);
4085 print (vam->ofp, "%=20s", mp->locator_set_name);
4088 vam->retval = retval;
4089 vam->result_ready = 1;
4093 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4094 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4096 vat_main_t *vam = &vat_main;
4097 vat_json_node_t *node = NULL;
4099 if (VAT_JSON_ARRAY != vam->json_tree.type)
4101 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4102 vat_json_init_array (&vam->json_tree);
4104 node = vat_json_array_add (&vam->json_tree);
4106 vat_json_init_object (node);
4107 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4109 vat_json_print (vam->ofp, node);
4110 vat_json_free (node);
4112 vam->retval = ntohl (mp->retval);
4113 vam->result_ready = 1;
4117 format_lisp_map_request_mode (u8 * s, va_list * args)
4119 u32 mode = va_arg (*args, u32);
4124 return format (0, "dst-only");
4126 return format (0, "src-dst");
4132 vl_api_show_one_map_request_mode_reply_t_handler
4133 (vl_api_show_one_map_request_mode_reply_t * mp)
4135 vat_main_t *vam = &vat_main;
4136 i32 retval = ntohl (mp->retval);
4140 u32 mode = mp->mode;
4141 print (vam->ofp, "map_request_mode: %U",
4142 format_lisp_map_request_mode, mode);
4145 vam->retval = retval;
4146 vam->result_ready = 1;
4150 vl_api_show_one_map_request_mode_reply_t_handler_json
4151 (vl_api_show_one_map_request_mode_reply_t * mp)
4153 vat_main_t *vam = &vat_main;
4154 vat_json_node_t node;
4159 s = format (0, "%U", format_lisp_map_request_mode, mode);
4162 vat_json_init_object (&node);
4163 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4164 vat_json_print (vam->ofp, &node);
4165 vat_json_free (&node);
4168 vam->retval = ntohl (mp->retval);
4169 vam->result_ready = 1;
4173 vl_api_one_show_xtr_mode_reply_t_handler
4174 (vl_api_one_show_xtr_mode_reply_t * mp)
4176 vat_main_t *vam = &vat_main;
4177 i32 retval = ntohl (mp->retval);
4181 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4184 vam->retval = retval;
4185 vam->result_ready = 1;
4189 vl_api_one_show_xtr_mode_reply_t_handler_json
4190 (vl_api_one_show_xtr_mode_reply_t * mp)
4192 vat_main_t *vam = &vat_main;
4193 vat_json_node_t node;
4196 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4197 vec_add1 (status, 0);
4199 vat_json_init_object (&node);
4200 vat_json_object_add_string_copy (&node, "status", status);
4204 vat_json_print (vam->ofp, &node);
4205 vat_json_free (&node);
4207 vam->retval = ntohl (mp->retval);
4208 vam->result_ready = 1;
4212 vl_api_one_show_pitr_mode_reply_t_handler
4213 (vl_api_one_show_pitr_mode_reply_t * mp)
4215 vat_main_t *vam = &vat_main;
4216 i32 retval = ntohl (mp->retval);
4220 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4223 vam->retval = retval;
4224 vam->result_ready = 1;
4228 vl_api_one_show_pitr_mode_reply_t_handler_json
4229 (vl_api_one_show_pitr_mode_reply_t * mp)
4231 vat_main_t *vam = &vat_main;
4232 vat_json_node_t node;
4235 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4236 vec_add1 (status, 0);
4238 vat_json_init_object (&node);
4239 vat_json_object_add_string_copy (&node, "status", status);
4243 vat_json_print (vam->ofp, &node);
4244 vat_json_free (&node);
4246 vam->retval = ntohl (mp->retval);
4247 vam->result_ready = 1;
4251 vl_api_one_show_petr_mode_reply_t_handler
4252 (vl_api_one_show_petr_mode_reply_t * mp)
4254 vat_main_t *vam = &vat_main;
4255 i32 retval = ntohl (mp->retval);
4259 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4262 vam->retval = retval;
4263 vam->result_ready = 1;
4267 vl_api_one_show_petr_mode_reply_t_handler_json
4268 (vl_api_one_show_petr_mode_reply_t * mp)
4270 vat_main_t *vam = &vat_main;
4271 vat_json_node_t node;
4274 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4275 vec_add1 (status, 0);
4277 vat_json_init_object (&node);
4278 vat_json_object_add_string_copy (&node, "status", status);
4282 vat_json_print (vam->ofp, &node);
4283 vat_json_free (&node);
4285 vam->retval = ntohl (mp->retval);
4286 vam->result_ready = 1;
4290 vl_api_show_one_use_petr_reply_t_handler
4291 (vl_api_show_one_use_petr_reply_t * mp)
4293 vat_main_t *vam = &vat_main;
4294 i32 retval = ntohl (mp->retval);
4298 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4301 print (vam->ofp, "Proxy-ETR address; %U",
4302 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4307 vam->retval = retval;
4308 vam->result_ready = 1;
4312 vl_api_show_one_use_petr_reply_t_handler_json
4313 (vl_api_show_one_use_petr_reply_t * mp)
4315 vat_main_t *vam = &vat_main;
4316 vat_json_node_t node;
4319 struct in6_addr ip6;
4321 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4322 vec_add1 (status, 0);
4324 vat_json_init_object (&node);
4325 vat_json_object_add_string_copy (&node, "status", status);
4328 if (mp->ip_address.af)
4330 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4331 vat_json_object_add_ip6 (&node, "address", ip6);
4335 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4336 vat_json_object_add_ip4 (&node, "address", ip4);
4342 vat_json_print (vam->ofp, &node);
4343 vat_json_free (&node);
4345 vam->retval = ntohl (mp->retval);
4346 vam->result_ready = 1;
4350 vl_api_show_one_nsh_mapping_reply_t_handler
4351 (vl_api_show_one_nsh_mapping_reply_t * mp)
4353 vat_main_t *vam = &vat_main;
4354 i32 retval = ntohl (mp->retval);
4358 print (vam->ofp, "%-20s%-16s",
4359 mp->is_set ? "set" : "not-set",
4360 mp->is_set ? (char *) mp->locator_set_name : "");
4363 vam->retval = retval;
4364 vam->result_ready = 1;
4368 vl_api_show_one_nsh_mapping_reply_t_handler_json
4369 (vl_api_show_one_nsh_mapping_reply_t * mp)
4371 vat_main_t *vam = &vat_main;
4372 vat_json_node_t node;
4375 status = format (0, "%s", mp->is_set ? "yes" : "no");
4376 vec_add1 (status, 0);
4378 vat_json_init_object (&node);
4379 vat_json_object_add_string_copy (&node, "is_set", status);
4382 vat_json_object_add_string_copy (&node, "locator_set",
4383 mp->locator_set_name);
4388 vat_json_print (vam->ofp, &node);
4389 vat_json_free (&node);
4391 vam->retval = ntohl (mp->retval);
4392 vam->result_ready = 1;
4396 vl_api_show_one_map_register_ttl_reply_t_handler
4397 (vl_api_show_one_map_register_ttl_reply_t * mp)
4399 vat_main_t *vam = &vat_main;
4400 i32 retval = ntohl (mp->retval);
4402 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4406 print (vam->ofp, "ttl: %u", mp->ttl);
4409 vam->retval = retval;
4410 vam->result_ready = 1;
4414 vl_api_show_one_map_register_ttl_reply_t_handler_json
4415 (vl_api_show_one_map_register_ttl_reply_t * mp)
4417 vat_main_t *vam = &vat_main;
4418 vat_json_node_t node;
4420 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4421 vat_json_init_object (&node);
4422 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4424 vat_json_print (vam->ofp, &node);
4425 vat_json_free (&node);
4427 vam->retval = ntohl (mp->retval);
4428 vam->result_ready = 1;
4432 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4434 vat_main_t *vam = &vat_main;
4435 i32 retval = ntohl (mp->retval);
4439 print (vam->ofp, "%-20s%-16s",
4440 mp->status ? "enabled" : "disabled",
4441 mp->status ? (char *) mp->locator_set_name : "");
4444 vam->retval = retval;
4445 vam->result_ready = 1;
4449 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4451 vat_main_t *vam = &vat_main;
4452 vat_json_node_t node;
4455 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4456 vec_add1 (status, 0);
4458 vat_json_init_object (&node);
4459 vat_json_object_add_string_copy (&node, "status", status);
4462 vat_json_object_add_string_copy (&node, "locator_set",
4463 mp->locator_set_name);
4468 vat_json_print (vam->ofp, &node);
4469 vat_json_free (&node);
4471 vam->retval = ntohl (mp->retval);
4472 vam->result_ready = 1;
4476 format_policer_type (u8 * s, va_list * va)
4478 u32 i = va_arg (*va, u32);
4480 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4481 s = format (s, "1r2c");
4482 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4483 s = format (s, "1r3c");
4484 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4485 s = format (s, "2r3c-2698");
4486 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4487 s = format (s, "2r3c-4115");
4488 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4489 s = format (s, "2r3c-mef5cf1");
4491 s = format (s, "ILLEGAL");
4496 format_policer_rate_type (u8 * s, va_list * va)
4498 u32 i = va_arg (*va, u32);
4500 if (i == SSE2_QOS_RATE_KBPS)
4501 s = format (s, "kbps");
4502 else if (i == SSE2_QOS_RATE_PPS)
4503 s = format (s, "pps");
4505 s = format (s, "ILLEGAL");
4510 format_policer_round_type (u8 * s, va_list * va)
4512 u32 i = va_arg (*va, u32);
4514 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4515 s = format (s, "closest");
4516 else if (i == SSE2_QOS_ROUND_TO_UP)
4517 s = format (s, "up");
4518 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4519 s = format (s, "down");
4521 s = format (s, "ILLEGAL");
4526 format_policer_action_type (u8 * s, va_list * va)
4528 u32 i = va_arg (*va, u32);
4530 if (i == SSE2_QOS_ACTION_DROP)
4531 s = format (s, "drop");
4532 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4533 s = format (s, "transmit");
4534 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4535 s = format (s, "mark-and-transmit");
4537 s = format (s, "ILLEGAL");
4542 format_dscp (u8 * s, va_list * va)
4544 u32 i = va_arg (*va, u32);
4549 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4553 return format (s, "ILLEGAL");
4555 s = format (s, "%s", t);
4560 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4562 vat_main_t *vam = &vat_main;
4563 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4565 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4566 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4568 conform_dscp_str = format (0, "");
4570 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4571 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4573 exceed_dscp_str = format (0, "");
4575 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4576 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4578 violate_dscp_str = format (0, "");
4580 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4581 "rate type %U, round type %U, %s rate, %s color-aware, "
4582 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4583 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4584 "conform action %U%s, exceed action %U%s, violate action %U%s",
4586 format_policer_type, mp->type,
4589 clib_net_to_host_u64 (mp->cb),
4590 clib_net_to_host_u64 (mp->eb),
4591 format_policer_rate_type, mp->rate_type,
4592 format_policer_round_type, mp->round_type,
4593 mp->single_rate ? "single" : "dual",
4594 mp->color_aware ? "is" : "not",
4595 ntohl (mp->cir_tokens_per_period),
4596 ntohl (mp->pir_tokens_per_period),
4598 ntohl (mp->current_limit),
4599 ntohl (mp->current_bucket),
4600 ntohl (mp->extended_limit),
4601 ntohl (mp->extended_bucket),
4602 clib_net_to_host_u64 (mp->last_update_time),
4603 format_policer_action_type, mp->conform_action.type,
4605 format_policer_action_type, mp->exceed_action.type,
4607 format_policer_action_type, mp->violate_action.type,
4610 vec_free (conform_dscp_str);
4611 vec_free (exceed_dscp_str);
4612 vec_free (violate_dscp_str);
4615 static void vl_api_policer_details_t_handler_json
4616 (vl_api_policer_details_t * mp)
4618 vat_main_t *vam = &vat_main;
4619 vat_json_node_t *node;
4620 u8 *rate_type_str, *round_type_str, *type_str;
4621 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4623 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4625 format (0, "%U", format_policer_round_type, mp->round_type);
4626 type_str = format (0, "%U", format_policer_type, mp->type);
4627 conform_action_str = format (0, "%U", format_policer_action_type,
4628 mp->conform_action.type);
4629 exceed_action_str = format (0, "%U", format_policer_action_type,
4630 mp->exceed_action.type);
4631 violate_action_str = format (0, "%U", format_policer_action_type,
4632 mp->violate_action.type);
4634 if (VAT_JSON_ARRAY != vam->json_tree.type)
4636 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4637 vat_json_init_array (&vam->json_tree);
4639 node = vat_json_array_add (&vam->json_tree);
4641 vat_json_init_object (node);
4642 vat_json_object_add_string_copy (node, "name", mp->name);
4643 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4644 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4645 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4646 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4647 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4648 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4649 vat_json_object_add_string_copy (node, "type", type_str);
4650 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4651 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4652 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4653 vat_json_object_add_uint (node, "cir_tokens_per_period",
4654 ntohl (mp->cir_tokens_per_period));
4655 vat_json_object_add_uint (node, "eir_tokens_per_period",
4656 ntohl (mp->pir_tokens_per_period));
4657 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4658 vat_json_object_add_uint (node, "current_bucket",
4659 ntohl (mp->current_bucket));
4660 vat_json_object_add_uint (node, "extended_limit",
4661 ntohl (mp->extended_limit));
4662 vat_json_object_add_uint (node, "extended_bucket",
4663 ntohl (mp->extended_bucket));
4664 vat_json_object_add_uint (node, "last_update_time",
4665 ntohl (mp->last_update_time));
4666 vat_json_object_add_string_copy (node, "conform_action",
4667 conform_action_str);
4668 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4670 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4671 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4672 vec_free (dscp_str);
4674 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4675 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4677 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4678 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4679 vec_free (dscp_str);
4681 vat_json_object_add_string_copy (node, "violate_action",
4682 violate_action_str);
4683 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4685 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4686 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4687 vec_free (dscp_str);
4690 vec_free (rate_type_str);
4691 vec_free (round_type_str);
4692 vec_free (type_str);
4693 vec_free (conform_action_str);
4694 vec_free (exceed_action_str);
4695 vec_free (violate_action_str);
4699 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4702 vat_main_t *vam = &vat_main;
4703 int i, count = ntohl (mp->count);
4706 print (vam->ofp, "classify table ids (%d) : ", count);
4707 for (i = 0; i < count; i++)
4709 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4710 print (vam->ofp, (i < count - 1) ? "," : "");
4712 vam->retval = ntohl (mp->retval);
4713 vam->result_ready = 1;
4717 vl_api_classify_table_ids_reply_t_handler_json
4718 (vl_api_classify_table_ids_reply_t * mp)
4720 vat_main_t *vam = &vat_main;
4721 int i, count = ntohl (mp->count);
4725 vat_json_node_t node;
4727 vat_json_init_object (&node);
4728 for (i = 0; i < count; i++)
4730 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4732 vat_json_print (vam->ofp, &node);
4733 vat_json_free (&node);
4735 vam->retval = ntohl (mp->retval);
4736 vam->result_ready = 1;
4740 vl_api_classify_table_by_interface_reply_t_handler
4741 (vl_api_classify_table_by_interface_reply_t * mp)
4743 vat_main_t *vam = &vat_main;
4746 table_id = ntohl (mp->l2_table_id);
4748 print (vam->ofp, "l2 table id : %d", table_id);
4750 print (vam->ofp, "l2 table id : No input ACL tables configured");
4751 table_id = ntohl (mp->ip4_table_id);
4753 print (vam->ofp, "ip4 table id : %d", table_id);
4755 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4756 table_id = ntohl (mp->ip6_table_id);
4758 print (vam->ofp, "ip6 table id : %d", table_id);
4760 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4761 vam->retval = ntohl (mp->retval);
4762 vam->result_ready = 1;
4766 vl_api_classify_table_by_interface_reply_t_handler_json
4767 (vl_api_classify_table_by_interface_reply_t * mp)
4769 vat_main_t *vam = &vat_main;
4770 vat_json_node_t node;
4772 vat_json_init_object (&node);
4774 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4775 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4776 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4778 vat_json_print (vam->ofp, &node);
4779 vat_json_free (&node);
4781 vam->retval = ntohl (mp->retval);
4782 vam->result_ready = 1;
4785 static void vl_api_policer_add_del_reply_t_handler
4786 (vl_api_policer_add_del_reply_t * mp)
4788 vat_main_t *vam = &vat_main;
4789 i32 retval = ntohl (mp->retval);
4790 if (vam->async_mode)
4792 vam->async_errors += (retval < 0);
4796 vam->retval = retval;
4797 vam->result_ready = 1;
4798 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4800 * Note: this is just barely thread-safe, depends on
4801 * the main thread spinning waiting for an answer...
4803 errmsg ("policer index %d", ntohl (mp->policer_index));
4807 static void vl_api_policer_add_del_reply_t_handler_json
4808 (vl_api_policer_add_del_reply_t * mp)
4810 vat_main_t *vam = &vat_main;
4811 vat_json_node_t node;
4813 vat_json_init_object (&node);
4814 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4815 vat_json_object_add_uint (&node, "policer_index",
4816 ntohl (mp->policer_index));
4818 vat_json_print (vam->ofp, &node);
4819 vat_json_free (&node);
4821 vam->retval = ntohl (mp->retval);
4822 vam->result_ready = 1;
4825 /* Format hex dump. */
4827 format_hex_bytes (u8 * s, va_list * va)
4829 u8 *bytes = va_arg (*va, u8 *);
4830 int n_bytes = va_arg (*va, int);
4833 /* Print short or long form depending on byte count. */
4834 uword short_form = n_bytes <= 32;
4835 u32 indent = format_get_indent (s);
4840 for (i = 0; i < n_bytes; i++)
4842 if (!short_form && (i % 32) == 0)
4843 s = format (s, "%08x: ", i);
4844 s = format (s, "%02x", bytes[i]);
4845 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4846 s = format (s, "\n%U", format_white_space, indent);
4853 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4856 vat_main_t *vam = &vat_main;
4857 i32 retval = ntohl (mp->retval);
4860 print (vam->ofp, "classify table info :");
4861 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4862 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4863 ntohl (mp->miss_next_index));
4864 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4865 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4866 ntohl (mp->match_n_vectors));
4867 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4868 ntohl (mp->mask_length));
4870 vam->retval = retval;
4871 vam->result_ready = 1;
4875 vl_api_classify_table_info_reply_t_handler_json
4876 (vl_api_classify_table_info_reply_t * mp)
4878 vat_main_t *vam = &vat_main;
4879 vat_json_node_t node;
4881 i32 retval = ntohl (mp->retval);
4884 vat_json_init_object (&node);
4886 vat_json_object_add_int (&node, "sessions",
4887 ntohl (mp->active_sessions));
4888 vat_json_object_add_int (&node, "nexttbl",
4889 ntohl (mp->next_table_index));
4890 vat_json_object_add_int (&node, "nextnode",
4891 ntohl (mp->miss_next_index));
4892 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4893 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4894 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4895 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4896 ntohl (mp->mask_length), 0);
4897 vat_json_object_add_string_copy (&node, "mask", s);
4899 vat_json_print (vam->ofp, &node);
4900 vat_json_free (&node);
4902 vam->retval = ntohl (mp->retval);
4903 vam->result_ready = 1;
4907 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4910 vat_main_t *vam = &vat_main;
4912 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4913 ntohl (mp->hit_next_index), ntohl (mp->advance),
4914 ntohl (mp->opaque_index));
4915 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4916 ntohl (mp->match_length));
4920 vl_api_classify_session_details_t_handler_json
4921 (vl_api_classify_session_details_t * mp)
4923 vat_main_t *vam = &vat_main;
4924 vat_json_node_t *node = NULL;
4926 if (VAT_JSON_ARRAY != vam->json_tree.type)
4928 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4929 vat_json_init_array (&vam->json_tree);
4931 node = vat_json_array_add (&vam->json_tree);
4933 vat_json_init_object (node);
4934 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4935 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4936 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4938 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4940 vat_json_object_add_string_copy (node, "match", s);
4943 static void vl_api_pg_create_interface_reply_t_handler
4944 (vl_api_pg_create_interface_reply_t * mp)
4946 vat_main_t *vam = &vat_main;
4948 vam->retval = ntohl (mp->retval);
4949 vam->result_ready = 1;
4952 static void vl_api_pg_create_interface_reply_t_handler_json
4953 (vl_api_pg_create_interface_reply_t * mp)
4955 vat_main_t *vam = &vat_main;
4956 vat_json_node_t node;
4958 i32 retval = ntohl (mp->retval);
4961 vat_json_init_object (&node);
4963 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4965 vat_json_print (vam->ofp, &node);
4966 vat_json_free (&node);
4968 vam->retval = ntohl (mp->retval);
4969 vam->result_ready = 1;
4972 static void vl_api_policer_classify_details_t_handler
4973 (vl_api_policer_classify_details_t * mp)
4975 vat_main_t *vam = &vat_main;
4977 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4978 ntohl (mp->table_index));
4981 static void vl_api_policer_classify_details_t_handler_json
4982 (vl_api_policer_classify_details_t * mp)
4984 vat_main_t *vam = &vat_main;
4985 vat_json_node_t *node;
4987 if (VAT_JSON_ARRAY != vam->json_tree.type)
4989 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4990 vat_json_init_array (&vam->json_tree);
4992 node = vat_json_array_add (&vam->json_tree);
4994 vat_json_init_object (node);
4995 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4996 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4999 static void vl_api_flow_classify_details_t_handler
5000 (vl_api_flow_classify_details_t * mp)
5002 vat_main_t *vam = &vat_main;
5004 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5005 ntohl (mp->table_index));
5008 static void vl_api_flow_classify_details_t_handler_json
5009 (vl_api_flow_classify_details_t * mp)
5011 vat_main_t *vam = &vat_main;
5012 vat_json_node_t *node;
5014 if (VAT_JSON_ARRAY != vam->json_tree.type)
5016 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5017 vat_json_init_array (&vam->json_tree);
5019 node = vat_json_array_add (&vam->json_tree);
5021 vat_json_init_object (node);
5022 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5023 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5026 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5027 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5028 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5029 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5030 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5031 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5032 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5033 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5034 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5035 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5038 * Generate boilerplate reply handlers, which
5039 * dig the return value out of the xxx_reply_t API message,
5040 * stick it into vam->retval, and set vam->result_ready
5042 * Could also do this by pointing N message decode slots at
5043 * a single function, but that could break in subtle ways.
5046 #define foreach_standard_reply_retval_handler \
5047 _(sw_interface_set_flags_reply) \
5048 _(sw_interface_add_del_address_reply) \
5049 _(sw_interface_set_rx_mode_reply) \
5050 _(sw_interface_set_rx_placement_reply) \
5051 _(sw_interface_set_table_reply) \
5052 _(sw_interface_set_mpls_enable_reply) \
5053 _(sw_interface_set_vpath_reply) \
5054 _(sw_interface_set_vxlan_bypass_reply) \
5055 _(sw_interface_set_geneve_bypass_reply) \
5056 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5057 _(sw_interface_set_l2_bridge_reply) \
5058 _(sw_interface_set_bond_weight_reply) \
5059 _(bridge_domain_add_del_reply) \
5060 _(sw_interface_set_l2_xconnect_reply) \
5061 _(l2fib_add_del_reply) \
5062 _(l2fib_flush_int_reply) \
5063 _(l2fib_flush_bd_reply) \
5064 _(ip_route_add_del_reply) \
5065 _(ip_table_add_del_reply) \
5066 _(ip_table_replace_begin_reply) \
5067 _(ip_table_flush_reply) \
5068 _(ip_table_replace_end_reply) \
5069 _(ip_mroute_add_del_reply) \
5070 _(mpls_route_add_del_reply) \
5071 _(mpls_table_add_del_reply) \
5072 _(mpls_ip_bind_unbind_reply) \
5073 _(bier_route_add_del_reply) \
5074 _(bier_table_add_del_reply) \
5075 _(sw_interface_set_unnumbered_reply) \
5076 _(set_ip_flow_hash_reply) \
5077 _(sw_interface_ip6_enable_disable_reply) \
5078 _(l2_patch_add_del_reply) \
5079 _(sr_mpls_policy_add_reply) \
5080 _(sr_mpls_policy_mod_reply) \
5081 _(sr_mpls_policy_del_reply) \
5082 _(sr_policy_add_reply) \
5083 _(sr_policy_mod_reply) \
5084 _(sr_policy_del_reply) \
5085 _(sr_localsid_add_del_reply) \
5086 _(sr_steering_add_del_reply) \
5087 _(classify_add_del_session_reply) \
5088 _(classify_set_interface_ip_table_reply) \
5089 _(classify_set_interface_l2_tables_reply) \
5090 _(l2tpv3_set_tunnel_cookies_reply) \
5091 _(l2tpv3_interface_enable_disable_reply) \
5092 _(l2tpv3_set_lookup_key_reply) \
5093 _(l2_fib_clear_table_reply) \
5094 _(l2_interface_efp_filter_reply) \
5095 _(l2_interface_vlan_tag_rewrite_reply) \
5096 _(modify_vhost_user_if_reply) \
5097 _(delete_vhost_user_if_reply) \
5098 _(want_l2_macs_events_reply) \
5099 _(input_acl_set_interface_reply) \
5100 _(ipsec_spd_add_del_reply) \
5101 _(ipsec_interface_add_del_spd_reply) \
5102 _(ipsec_spd_entry_add_del_reply) \
5103 _(ipsec_sad_entry_add_del_reply) \
5104 _(ipsec_tunnel_if_add_del_reply) \
5105 _(ipsec_tunnel_if_set_sa_reply) \
5106 _(delete_loopback_reply) \
5107 _(bd_ip_mac_add_del_reply) \
5108 _(bd_ip_mac_flush_reply) \
5109 _(want_interface_events_reply) \
5110 _(cop_interface_enable_disable_reply) \
5111 _(cop_whitelist_enable_disable_reply) \
5112 _(sw_interface_clear_stats_reply) \
5113 _(ioam_enable_reply) \
5114 _(ioam_disable_reply) \
5115 _(one_add_del_locator_reply) \
5116 _(one_add_del_local_eid_reply) \
5117 _(one_add_del_remote_mapping_reply) \
5118 _(one_add_del_adjacency_reply) \
5119 _(one_add_del_map_resolver_reply) \
5120 _(one_add_del_map_server_reply) \
5121 _(one_enable_disable_reply) \
5122 _(one_rloc_probe_enable_disable_reply) \
5123 _(one_map_register_enable_disable_reply) \
5124 _(one_map_register_set_ttl_reply) \
5125 _(one_set_transport_protocol_reply) \
5126 _(one_map_register_fallback_threshold_reply) \
5127 _(one_pitr_set_locator_set_reply) \
5128 _(one_map_request_mode_reply) \
5129 _(one_add_del_map_request_itr_rlocs_reply) \
5130 _(one_eid_table_add_del_map_reply) \
5131 _(one_use_petr_reply) \
5132 _(one_stats_enable_disable_reply) \
5133 _(one_add_del_l2_arp_entry_reply) \
5134 _(one_add_del_ndp_entry_reply) \
5135 _(one_stats_flush_reply) \
5136 _(one_enable_disable_xtr_mode_reply) \
5137 _(one_enable_disable_pitr_mode_reply) \
5138 _(one_enable_disable_petr_mode_reply) \
5139 _(gpe_enable_disable_reply) \
5140 _(gpe_set_encap_mode_reply) \
5141 _(gpe_add_del_iface_reply) \
5142 _(gpe_add_del_native_fwd_rpath_reply) \
5143 _(af_packet_delete_reply) \
5144 _(policer_classify_set_interface_reply) \
5145 _(set_ipfix_exporter_reply) \
5146 _(set_ipfix_classify_stream_reply) \
5147 _(ipfix_classify_table_add_del_reply) \
5148 _(flow_classify_set_interface_reply) \
5149 _(sw_interface_span_enable_disable_reply) \
5150 _(pg_capture_reply) \
5151 _(pg_enable_disable_reply) \
5152 _(ip_source_and_port_range_check_add_del_reply) \
5153 _(ip_source_and_port_range_check_interface_add_del_reply)\
5154 _(delete_subif_reply) \
5155 _(l2_interface_pbb_tag_rewrite_reply) \
5157 _(feature_enable_disable_reply) \
5158 _(feature_gso_enable_disable_reply) \
5159 _(sw_interface_tag_add_del_reply) \
5160 _(sw_interface_add_del_mac_address_reply) \
5161 _(hw_interface_set_mtu_reply) \
5162 _(p2p_ethernet_add_reply) \
5163 _(p2p_ethernet_del_reply) \
5164 _(lldp_config_reply) \
5165 _(sw_interface_set_lldp_reply) \
5166 _(tcp_configure_src_addresses_reply) \
5167 _(session_rule_add_del_reply) \
5168 _(ip_container_proxy_add_del_reply) \
5169 _(output_acl_set_interface_reply) \
5170 _(qos_record_enable_disable_reply)
5173 static void vl_api_##n##_t_handler \
5174 (vl_api_##n##_t * mp) \
5176 vat_main_t * vam = &vat_main; \
5177 i32 retval = ntohl(mp->retval); \
5178 if (vam->async_mode) { \
5179 vam->async_errors += (retval < 0); \
5181 vam->retval = retval; \
5182 vam->result_ready = 1; \
5185 foreach_standard_reply_retval_handler;
5189 static void vl_api_##n##_t_handler_json \
5190 (vl_api_##n##_t * mp) \
5192 vat_main_t * vam = &vat_main; \
5193 vat_json_node_t node; \
5194 vat_json_init_object(&node); \
5195 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5196 vat_json_print(vam->ofp, &node); \
5197 vam->retval = ntohl(mp->retval); \
5198 vam->result_ready = 1; \
5200 foreach_standard_reply_retval_handler;
5204 * Table of message reply handlers, must include boilerplate handlers
5208 #define foreach_vpe_api_reply_msg \
5209 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5210 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5211 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5212 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5213 _(CONTROL_PING_REPLY, control_ping_reply) \
5214 _(CLI_REPLY, cli_reply) \
5215 _(CLI_INBAND_REPLY, cli_inband_reply) \
5216 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5217 sw_interface_add_del_address_reply) \
5218 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5219 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5220 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5221 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5222 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5223 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5224 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5225 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5226 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5227 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5228 sw_interface_set_l2_xconnect_reply) \
5229 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5230 sw_interface_set_l2_bridge_reply) \
5231 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5232 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5233 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5234 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5235 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5236 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5237 _(L2_FLAGS_REPLY, l2_flags_reply) \
5238 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5239 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5240 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5241 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5242 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5243 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5244 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5245 _(BOND_CREATE_REPLY, bond_create_reply) \
5246 _(BOND_DELETE_REPLY, bond_delete_reply) \
5247 _(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
5248 _(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
5249 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5250 _(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
5251 _(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
5252 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5253 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5254 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5255 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5256 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5257 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5258 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5259 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5260 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5261 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5262 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5263 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5264 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5265 sw_interface_set_unnumbered_reply) \
5266 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5267 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5268 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5269 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5270 sw_interface_ip6_enable_disable_reply) \
5271 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5272 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5273 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5274 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5275 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5276 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5277 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5278 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5279 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5280 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5281 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5282 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5283 classify_set_interface_ip_table_reply) \
5284 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5285 classify_set_interface_l2_tables_reply) \
5286 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5287 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5288 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5289 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5290 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5291 l2tpv3_interface_enable_disable_reply) \
5292 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5293 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5294 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5295 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5296 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5297 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5298 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5299 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5300 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5301 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5302 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5303 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5304 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5305 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5306 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5307 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5308 _(SHOW_VERSION_REPLY, show_version_reply) \
5309 _(SHOW_THREADS_REPLY, show_threads_reply) \
5310 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5311 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5312 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5313 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5314 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5315 _(L2_MACS_EVENT, l2_macs_event) \
5316 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5317 _(IP_ADDRESS_DETAILS, ip_address_details) \
5318 _(IP_DETAILS, ip_details) \
5319 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5320 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5321 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5322 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5323 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5324 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5325 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5326 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5327 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5328 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5329 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5330 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5331 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5332 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5333 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5334 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5335 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5336 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5337 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5338 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5339 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5340 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5341 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5342 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5343 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5344 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5345 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5346 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5347 one_map_register_enable_disable_reply) \
5348 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5349 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5350 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5351 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5352 one_map_register_fallback_threshold_reply) \
5353 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5354 one_rloc_probe_enable_disable_reply) \
5355 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5356 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5357 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5358 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5359 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5360 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5361 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5362 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5363 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5364 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5365 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5366 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5367 _(ONE_STATS_DETAILS, one_stats_details) \
5368 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5369 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5370 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5371 show_one_stats_enable_disable_reply) \
5372 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5373 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5374 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5375 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5376 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5377 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5378 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5379 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5380 one_enable_disable_pitr_mode_reply) \
5381 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5382 one_enable_disable_petr_mode_reply) \
5383 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5384 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5385 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5386 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5387 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5388 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5389 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5390 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5391 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5392 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5393 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5394 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5395 gpe_add_del_native_fwd_rpath_reply) \
5396 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5397 gpe_fwd_entry_path_details) \
5398 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5399 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5400 one_add_del_map_request_itr_rlocs_reply) \
5401 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5402 one_get_map_request_itr_rlocs_reply) \
5403 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5404 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5405 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5406 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5407 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5408 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5409 show_one_map_register_state_reply) \
5410 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5411 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5412 show_one_map_register_fallback_threshold_reply) \
5413 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5414 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5415 _(AF_PACKET_DETAILS, af_packet_details) \
5416 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5417 _(POLICER_DETAILS, policer_details) \
5418 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5419 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5420 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5421 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5422 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5423 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5424 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5425 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5426 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5427 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5428 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5429 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5430 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5431 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5432 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5433 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5434 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5435 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5436 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5437 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5438 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5439 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5440 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5441 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5442 ip_source_and_port_range_check_add_del_reply) \
5443 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5444 ip_source_and_port_range_check_interface_add_del_reply) \
5445 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5446 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5447 _(SET_PUNT_REPLY, set_punt_reply) \
5448 _(IP_TABLE_DETAILS, ip_table_details) \
5449 _(IP_ROUTE_DETAILS, ip_route_details) \
5450 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5451 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5452 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5453 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5454 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5455 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5456 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5457 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5458 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5459 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5460 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5461 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5462 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5463 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5464 _(SESSION_RULES_DETAILS, session_rules_details) \
5465 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5466 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5467 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5469 #define foreach_standalone_reply_msg \
5470 _(SW_INTERFACE_EVENT, sw_interface_event)
5478 #define STR_VTR_OP_CASE(op) \
5479 case L2_VTR_ ## op: \
5483 str_vtr_op (u32 vtr_op)
5487 STR_VTR_OP_CASE (DISABLED);
5488 STR_VTR_OP_CASE (PUSH_1);
5489 STR_VTR_OP_CASE (PUSH_2);
5490 STR_VTR_OP_CASE (POP_1);
5491 STR_VTR_OP_CASE (POP_2);
5492 STR_VTR_OP_CASE (TRANSLATE_1_1);
5493 STR_VTR_OP_CASE (TRANSLATE_1_2);
5494 STR_VTR_OP_CASE (TRANSLATE_2_1);
5495 STR_VTR_OP_CASE (TRANSLATE_2_2);
5502 dump_sub_interface_table (vat_main_t * vam)
5504 const sw_interface_subif_t *sub = NULL;
5506 if (vam->json_output)
5509 ("JSON output supported only for VPE API calls and dump_stats_table");
5514 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5515 "Interface", "sw_if_index",
5516 "sub id", "dot1ad", "tags", "outer id",
5517 "inner id", "exact", "default", "outer any", "inner any");
5519 vec_foreach (sub, vam->sw_if_subif_table)
5522 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5523 sub->interface_name,
5525 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5526 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5527 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5528 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5529 if (sub->vtr_op != L2_VTR_DISABLED)
5532 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5533 "tag1: %d tag2: %d ]",
5534 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5535 sub->vtr_tag1, sub->vtr_tag2);
5543 name_sort_cmp (void *a1, void *a2)
5545 name_sort_t *n1 = a1;
5546 name_sort_t *n2 = a2;
5548 return strcmp ((char *) n1->name, (char *) n2->name);
5552 dump_interface_table (vat_main_t * vam)
5555 name_sort_t *nses = 0, *ns;
5557 if (vam->json_output)
5560 ("JSON output supported only for VPE API calls and dump_stats_table");
5565 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5567 vec_add2 (nses, ns, 1);
5568 ns->name = (u8 *)(p->key);
5569 ns->value = (u32) p->value[0];
5573 vec_sort_with_function (nses, name_sort_cmp);
5575 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5576 vec_foreach (ns, nses)
5578 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5585 dump_ip_table (vat_main_t * vam, int is_ipv6)
5587 const ip_details_t *det = NULL;
5588 const ip_address_details_t *address = NULL;
5591 print (vam->ofp, "%-12s", "sw_if_index");
5593 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5600 print (vam->ofp, "%-12d", i);
5601 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5606 vec_foreach (address, det->addr)
5610 is_ipv6 ? format_ip6_address : format_ip4_address,
5611 address->ip, address->prefix_length);
5619 dump_ipv4_table (vat_main_t * vam)
5621 if (vam->json_output)
5624 ("JSON output supported only for VPE API calls and dump_stats_table");
5628 return dump_ip_table (vam, 0);
5632 dump_ipv6_table (vat_main_t * vam)
5634 if (vam->json_output)
5637 ("JSON output supported only for VPE API calls and dump_stats_table");
5641 return dump_ip_table (vam, 1);
5645 * Pass CLI buffers directly in the CLI_INBAND API message,
5646 * instead of an additional shared memory area.
5649 exec_inband (vat_main_t * vam)
5651 vl_api_cli_inband_t *mp;
5652 unformat_input_t *i = vam->input;
5655 if (vec_len (i->buffer) == 0)
5658 if (vam->exec_mode == 0 && unformat (i, "mode"))
5663 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5670 * In order for the CLI command to work, it
5671 * must be a vector ending in \n, not a C-string ending
5674 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5675 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5679 /* json responses may or may not include a useful reply... */
5680 if (vec_len (vam->cmd_reply))
5681 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5686 exec (vat_main_t * vam)
5688 return exec_inband (vam);
5692 api_create_loopback (vat_main_t * vam)
5694 unformat_input_t *i = vam->input;
5695 vl_api_create_loopback_t *mp;
5696 vl_api_create_loopback_instance_t *mp_lbi;
5699 u8 is_specified = 0;
5700 u32 user_instance = 0;
5703 clib_memset (mac_address, 0, sizeof (mac_address));
5705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5707 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5709 if (unformat (i, "instance %d", &user_instance))
5717 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5718 mp_lbi->is_specified = is_specified;
5720 mp_lbi->user_instance = htonl (user_instance);
5722 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5727 /* Construct the API message */
5728 M (CREATE_LOOPBACK, mp);
5730 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5739 api_delete_loopback (vat_main_t * vam)
5741 unformat_input_t *i = vam->input;
5742 vl_api_delete_loopback_t *mp;
5743 u32 sw_if_index = ~0;
5746 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5748 if (unformat (i, "sw_if_index %d", &sw_if_index))
5754 if (sw_if_index == ~0)
5756 errmsg ("missing sw_if_index");
5760 /* Construct the API message */
5761 M (DELETE_LOOPBACK, mp);
5762 mp->sw_if_index = ntohl (sw_if_index);
5770 api_want_interface_events (vat_main_t * vam)
5772 unformat_input_t *i = vam->input;
5773 vl_api_want_interface_events_t *mp;
5777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5779 if (unformat (i, "enable"))
5781 else if (unformat (i, "disable"))
5789 errmsg ("missing enable|disable");
5793 M (WANT_INTERFACE_EVENTS, mp);
5794 mp->enable_disable = enable;
5796 vam->interface_event_display = enable;
5804 /* Note: non-static, called once to set up the initial intfc table */
5806 api_sw_interface_dump (vat_main_t * vam)
5808 vl_api_sw_interface_dump_t *mp;
5809 vl_api_control_ping_t *mp_ping;
5811 name_sort_t *nses = 0, *ns;
5812 sw_interface_subif_t *sub = NULL;
5815 /* Toss the old name table */
5817 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5819 vec_add2 (nses, ns, 1);
5820 ns->name = (u8 *)(p->key);
5821 ns->value = (u32) p->value[0];
5825 hash_free (vam->sw_if_index_by_interface_name);
5827 vec_foreach (ns, nses) vec_free (ns->name);
5831 vec_foreach (sub, vam->sw_if_subif_table)
5833 vec_free (sub->interface_name);
5835 vec_free (vam->sw_if_subif_table);
5837 /* recreate the interface name hash table */
5838 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5841 * Ask for all interface names. Otherwise, the epic catalog of
5842 * name filters becomes ridiculously long, and vat ends up needing
5843 * to be taught about new interface types.
5845 M (SW_INTERFACE_DUMP, mp);
5848 /* Use a control ping for synchronization */
5849 MPING (CONTROL_PING, mp_ping);
5857 api_sw_interface_set_flags (vat_main_t * vam)
5859 unformat_input_t *i = vam->input;
5860 vl_api_sw_interface_set_flags_t *mp;
5862 u8 sw_if_index_set = 0;
5866 /* Parse args required to build the message */
5867 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5869 if (unformat (i, "admin-up"))
5871 else if (unformat (i, "admin-down"))
5874 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5875 sw_if_index_set = 1;
5876 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5877 sw_if_index_set = 1;
5882 if (sw_if_index_set == 0)
5884 errmsg ("missing interface name or sw_if_index");
5888 /* Construct the API message */
5889 M (SW_INTERFACE_SET_FLAGS, mp);
5890 mp->sw_if_index = ntohl (sw_if_index);
5891 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5896 /* Wait for a reply, return the good/bad news... */
5902 api_sw_interface_set_rx_mode (vat_main_t * vam)
5904 unformat_input_t *i = vam->input;
5905 vl_api_sw_interface_set_rx_mode_t *mp;
5907 u8 sw_if_index_set = 0;
5909 u8 queue_id_valid = 0;
5911 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5913 /* Parse args required to build the message */
5914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5916 if (unformat (i, "queue %d", &queue_id))
5918 else if (unformat (i, "polling"))
5919 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5920 else if (unformat (i, "interrupt"))
5921 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5922 else if (unformat (i, "adaptive"))
5923 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5926 sw_if_index_set = 1;
5927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5928 sw_if_index_set = 1;
5933 if (sw_if_index_set == 0)
5935 errmsg ("missing interface name or sw_if_index");
5938 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5940 errmsg ("missing rx-mode");
5944 /* Construct the API message */
5945 M (SW_INTERFACE_SET_RX_MODE, mp);
5946 mp->sw_if_index = ntohl (sw_if_index);
5947 mp->mode = (vl_api_rx_mode_t) mode;
5948 mp->queue_id_valid = queue_id_valid;
5949 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5954 /* Wait for a reply, return the good/bad news... */
5960 api_sw_interface_set_rx_placement (vat_main_t * vam)
5962 unformat_input_t *i = vam->input;
5963 vl_api_sw_interface_set_rx_placement_t *mp;
5965 u8 sw_if_index_set = 0;
5968 u32 queue_id, thread_index;
5970 /* Parse args required to build the message */
5971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5973 if (unformat (i, "queue %d", &queue_id))
5975 else if (unformat (i, "main"))
5977 else if (unformat (i, "worker %d", &thread_index))
5980 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5981 sw_if_index_set = 1;
5982 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5983 sw_if_index_set = 1;
5988 if (sw_if_index_set == 0)
5990 errmsg ("missing interface name or sw_if_index");
5996 /* Construct the API message */
5997 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
5998 mp->sw_if_index = ntohl (sw_if_index);
5999 mp->worker_id = ntohl (thread_index);
6000 mp->queue_id = ntohl (queue_id);
6001 mp->is_main = is_main;
6005 /* Wait for a reply, return the good/bad news... */
6010 static void vl_api_sw_interface_rx_placement_details_t_handler
6011 (vl_api_sw_interface_rx_placement_details_t * mp)
6013 vat_main_t *vam = &vat_main;
6014 u32 worker_id = ntohl (mp->worker_id);
6017 "\n%-11d %-11s %-6d %-5d %-9s",
6018 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6019 worker_id, ntohl (mp->queue_id),
6021 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6024 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6025 (vl_api_sw_interface_rx_placement_details_t * mp)
6027 vat_main_t *vam = &vat_main;
6028 vat_json_node_t *node = NULL;
6030 if (VAT_JSON_ARRAY != vam->json_tree.type)
6032 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6033 vat_json_init_array (&vam->json_tree);
6035 node = vat_json_array_add (&vam->json_tree);
6037 vat_json_init_object (node);
6038 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6039 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6040 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6041 vat_json_object_add_uint (node, "mode", mp->mode);
6045 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6047 unformat_input_t *i = vam->input;
6048 vl_api_sw_interface_rx_placement_dump_t *mp;
6049 vl_api_control_ping_t *mp_ping;
6052 u8 sw_if_index_set = 0;
6054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6065 "\n%-11s %-11s %-6s %-5s %-4s",
6066 "sw_if_index", "main/worker", "thread", "queue", "mode");
6068 /* Dump Interface rx placement */
6069 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6071 if (sw_if_index_set)
6072 mp->sw_if_index = htonl (sw_if_index);
6074 mp->sw_if_index = ~0;
6078 /* Use a control ping for synchronization */
6079 MPING (CONTROL_PING, mp_ping);
6087 api_sw_interface_clear_stats (vat_main_t * vam)
6089 unformat_input_t *i = vam->input;
6090 vl_api_sw_interface_clear_stats_t *mp;
6092 u8 sw_if_index_set = 0;
6095 /* Parse args required to build the message */
6096 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6099 sw_if_index_set = 1;
6100 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6101 sw_if_index_set = 1;
6106 /* Construct the API message */
6107 M (SW_INTERFACE_CLEAR_STATS, mp);
6109 if (sw_if_index_set == 1)
6110 mp->sw_if_index = ntohl (sw_if_index);
6112 mp->sw_if_index = ~0;
6117 /* Wait for a reply, return the good/bad news... */
6123 api_sw_interface_add_del_address (vat_main_t * vam)
6125 unformat_input_t *i = vam->input;
6126 vl_api_sw_interface_add_del_address_t *mp;
6128 u8 sw_if_index_set = 0;
6129 u8 is_add = 1, del_all = 0;
6130 u32 address_length = 0;
6131 u8 v4_address_set = 0;
6132 u8 v6_address_set = 0;
6133 ip4_address_t v4address;
6134 ip6_address_t v6address;
6137 /* Parse args required to build the message */
6138 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6140 if (unformat (i, "del-all"))
6142 else if (unformat (i, "del"))
6145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6146 sw_if_index_set = 1;
6147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6148 sw_if_index_set = 1;
6149 else if (unformat (i, "%U/%d",
6150 unformat_ip4_address, &v4address, &address_length))
6152 else if (unformat (i, "%U/%d",
6153 unformat_ip6_address, &v6address, &address_length))
6159 if (sw_if_index_set == 0)
6161 errmsg ("missing interface name or sw_if_index");
6164 if (v4_address_set && v6_address_set)
6166 errmsg ("both v4 and v6 addresses set");
6169 if (!v4_address_set && !v6_address_set && !del_all)
6171 errmsg ("no addresses set");
6175 /* Construct the API message */
6176 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6178 mp->sw_if_index = ntohl (sw_if_index);
6179 mp->is_add = is_add;
6180 mp->del_all = del_all;
6183 mp->prefix.address.af = ADDRESS_IP6;
6184 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6188 mp->prefix.address.af = ADDRESS_IP4;
6189 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6191 mp->prefix.len = address_length;
6196 /* Wait for a reply, return good/bad news */
6202 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6204 unformat_input_t *i = vam->input;
6205 vl_api_sw_interface_set_mpls_enable_t *mp;
6207 u8 sw_if_index_set = 0;
6211 /* Parse args required to build the message */
6212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6215 sw_if_index_set = 1;
6216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6217 sw_if_index_set = 1;
6218 else if (unformat (i, "disable"))
6220 else if (unformat (i, "dis"))
6226 if (sw_if_index_set == 0)
6228 errmsg ("missing interface name or sw_if_index");
6232 /* Construct the API message */
6233 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6235 mp->sw_if_index = ntohl (sw_if_index);
6236 mp->enable = enable;
6241 /* Wait for a reply... */
6247 api_sw_interface_set_table (vat_main_t * vam)
6249 unformat_input_t *i = vam->input;
6250 vl_api_sw_interface_set_table_t *mp;
6251 u32 sw_if_index, vrf_id = 0;
6252 u8 sw_if_index_set = 0;
6256 /* Parse args required to build the message */
6257 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6260 sw_if_index_set = 1;
6261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6262 sw_if_index_set = 1;
6263 else if (unformat (i, "vrf %d", &vrf_id))
6265 else if (unformat (i, "ipv6"))
6271 if (sw_if_index_set == 0)
6273 errmsg ("missing interface name or sw_if_index");
6277 /* Construct the API message */
6278 M (SW_INTERFACE_SET_TABLE, mp);
6280 mp->sw_if_index = ntohl (sw_if_index);
6281 mp->is_ipv6 = is_ipv6;
6282 mp->vrf_id = ntohl (vrf_id);
6287 /* Wait for a reply... */
6292 static void vl_api_sw_interface_get_table_reply_t_handler
6293 (vl_api_sw_interface_get_table_reply_t * mp)
6295 vat_main_t *vam = &vat_main;
6297 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6299 vam->retval = ntohl (mp->retval);
6300 vam->result_ready = 1;
6304 static void vl_api_sw_interface_get_table_reply_t_handler_json
6305 (vl_api_sw_interface_get_table_reply_t * mp)
6307 vat_main_t *vam = &vat_main;
6308 vat_json_node_t node;
6310 vat_json_init_object (&node);
6311 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6312 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6314 vat_json_print (vam->ofp, &node);
6315 vat_json_free (&node);
6317 vam->retval = ntohl (mp->retval);
6318 vam->result_ready = 1;
6322 api_sw_interface_get_table (vat_main_t * vam)
6324 unformat_input_t *i = vam->input;
6325 vl_api_sw_interface_get_table_t *mp;
6327 u8 sw_if_index_set = 0;
6331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6334 sw_if_index_set = 1;
6335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6336 sw_if_index_set = 1;
6337 else if (unformat (i, "ipv6"))
6343 if (sw_if_index_set == 0)
6345 errmsg ("missing interface name or sw_if_index");
6349 M (SW_INTERFACE_GET_TABLE, mp);
6350 mp->sw_if_index = htonl (sw_if_index);
6351 mp->is_ipv6 = is_ipv6;
6359 api_sw_interface_set_vpath (vat_main_t * vam)
6361 unformat_input_t *i = vam->input;
6362 vl_api_sw_interface_set_vpath_t *mp;
6363 u32 sw_if_index = 0;
6364 u8 sw_if_index_set = 0;
6368 /* Parse args required to build the message */
6369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6371 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6372 sw_if_index_set = 1;
6373 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6374 sw_if_index_set = 1;
6375 else if (unformat (i, "enable"))
6377 else if (unformat (i, "disable"))
6383 if (sw_if_index_set == 0)
6385 errmsg ("missing interface name or sw_if_index");
6389 /* Construct the API message */
6390 M (SW_INTERFACE_SET_VPATH, mp);
6392 mp->sw_if_index = ntohl (sw_if_index);
6393 mp->enable = is_enable;
6398 /* Wait for a reply... */
6404 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6406 unformat_input_t *i = vam->input;
6407 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6408 u32 sw_if_index = 0;
6409 u8 sw_if_index_set = 0;
6414 /* Parse args required to build the message */
6415 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6417 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6418 sw_if_index_set = 1;
6419 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6420 sw_if_index_set = 1;
6421 else if (unformat (i, "enable"))
6423 else if (unformat (i, "disable"))
6425 else if (unformat (i, "ip4"))
6427 else if (unformat (i, "ip6"))
6433 if (sw_if_index_set == 0)
6435 errmsg ("missing interface name or sw_if_index");
6439 /* Construct the API message */
6440 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6442 mp->sw_if_index = ntohl (sw_if_index);
6443 mp->enable = is_enable;
6444 mp->is_ipv6 = is_ipv6;
6449 /* Wait for a reply... */
6455 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6457 unformat_input_t *i = vam->input;
6458 vl_api_sw_interface_set_geneve_bypass_t *mp;
6459 u32 sw_if_index = 0;
6460 u8 sw_if_index_set = 0;
6465 /* Parse args required to build the message */
6466 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6468 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6469 sw_if_index_set = 1;
6470 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6471 sw_if_index_set = 1;
6472 else if (unformat (i, "enable"))
6474 else if (unformat (i, "disable"))
6476 else if (unformat (i, "ip4"))
6478 else if (unformat (i, "ip6"))
6484 if (sw_if_index_set == 0)
6486 errmsg ("missing interface name or sw_if_index");
6490 /* Construct the API message */
6491 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6493 mp->sw_if_index = ntohl (sw_if_index);
6494 mp->enable = is_enable;
6495 mp->is_ipv6 = is_ipv6;
6500 /* Wait for a reply... */
6506 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6508 unformat_input_t *i = vam->input;
6509 vl_api_sw_interface_set_l2_xconnect_t *mp;
6511 u8 rx_sw_if_index_set = 0;
6513 u8 tx_sw_if_index_set = 0;
6517 /* Parse args required to build the message */
6518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6520 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6521 rx_sw_if_index_set = 1;
6522 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6523 tx_sw_if_index_set = 1;
6524 else if (unformat (i, "rx"))
6526 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6528 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6530 rx_sw_if_index_set = 1;
6535 else if (unformat (i, "tx"))
6537 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6539 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6541 tx_sw_if_index_set = 1;
6546 else if (unformat (i, "enable"))
6548 else if (unformat (i, "disable"))
6554 if (rx_sw_if_index_set == 0)
6556 errmsg ("missing rx interface name or rx_sw_if_index");
6560 if (enable && (tx_sw_if_index_set == 0))
6562 errmsg ("missing tx interface name or tx_sw_if_index");
6566 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6568 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6569 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6570 mp->enable = enable;
6578 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6580 unformat_input_t *i = vam->input;
6581 vl_api_sw_interface_set_l2_bridge_t *mp;
6582 vl_api_l2_port_type_t port_type;
6584 u8 rx_sw_if_index_set = 0;
6591 port_type = L2_API_PORT_TYPE_NORMAL;
6593 /* Parse args required to build the message */
6594 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6596 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6597 rx_sw_if_index_set = 1;
6598 else if (unformat (i, "bd_id %d", &bd_id))
6602 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6603 rx_sw_if_index_set = 1;
6604 else if (unformat (i, "shg %d", &shg))
6606 else if (unformat (i, "bvi"))
6607 port_type = L2_API_PORT_TYPE_BVI;
6608 else if (unformat (i, "uu-fwd"))
6609 port_type = L2_API_PORT_TYPE_UU_FWD;
6610 else if (unformat (i, "enable"))
6612 else if (unformat (i, "disable"))
6618 if (rx_sw_if_index_set == 0)
6620 errmsg ("missing rx interface name or sw_if_index");
6624 if (enable && (bd_id_set == 0))
6626 errmsg ("missing bridge domain");
6630 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6632 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6633 mp->bd_id = ntohl (bd_id);
6635 mp->port_type = ntohl (port_type);
6636 mp->enable = enable;
6644 api_bridge_domain_dump (vat_main_t * vam)
6646 unformat_input_t *i = vam->input;
6647 vl_api_bridge_domain_dump_t *mp;
6648 vl_api_control_ping_t *mp_ping;
6652 /* Parse args required to build the message */
6653 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6655 if (unformat (i, "bd_id %d", &bd_id))
6661 M (BRIDGE_DOMAIN_DUMP, mp);
6662 mp->bd_id = ntohl (bd_id);
6665 /* Use a control ping for synchronization */
6666 MPING (CONTROL_PING, mp_ping);
6674 api_bridge_domain_add_del (vat_main_t * vam)
6676 unformat_input_t *i = vam->input;
6677 vl_api_bridge_domain_add_del_t *mp;
6680 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6685 /* Parse args required to build the message */
6686 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6688 if (unformat (i, "bd_id %d", &bd_id))
6690 else if (unformat (i, "flood %d", &flood))
6692 else if (unformat (i, "uu-flood %d", &uu_flood))
6694 else if (unformat (i, "forward %d", &forward))
6696 else if (unformat (i, "learn %d", &learn))
6698 else if (unformat (i, "arp-term %d", &arp_term))
6700 else if (unformat (i, "mac-age %d", &mac_age))
6702 else if (unformat (i, "bd-tag %s", &bd_tag))
6704 else if (unformat (i, "del"))
6707 flood = uu_flood = forward = learn = 0;
6715 errmsg ("missing bridge domain");
6722 errmsg ("mac age must be less than 256 ");
6727 if ((bd_tag) && (vec_len (bd_tag) > 63))
6729 errmsg ("bd-tag cannot be longer than 63");
6734 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6736 mp->bd_id = ntohl (bd_id);
6738 mp->uu_flood = uu_flood;
6739 mp->forward = forward;
6741 mp->arp_term = arp_term;
6742 mp->is_add = is_add;
6743 mp->mac_age = (u8) mac_age;
6746 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6747 mp->bd_tag[vec_len (bd_tag)] = 0;
6758 api_l2fib_flush_bd (vat_main_t * vam)
6760 unformat_input_t *i = vam->input;
6761 vl_api_l2fib_flush_bd_t *mp;
6765 /* Parse args required to build the message */
6766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6768 if (unformat (i, "bd_id %d", &bd_id));
6775 errmsg ("missing bridge domain");
6779 M (L2FIB_FLUSH_BD, mp);
6781 mp->bd_id = htonl (bd_id);
6789 api_l2fib_flush_int (vat_main_t * vam)
6791 unformat_input_t *i = vam->input;
6792 vl_api_l2fib_flush_int_t *mp;
6793 u32 sw_if_index = ~0;
6796 /* Parse args required to build the message */
6797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6799 if (unformat (i, "sw_if_index %d", &sw_if_index));
6801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6806 if (sw_if_index == ~0)
6808 errmsg ("missing interface name or sw_if_index");
6812 M (L2FIB_FLUSH_INT, mp);
6814 mp->sw_if_index = ntohl (sw_if_index);
6822 api_l2fib_add_del (vat_main_t * vam)
6824 unformat_input_t *i = vam->input;
6825 vl_api_l2fib_add_del_t *mp;
6831 u32 sw_if_index = 0;
6832 u8 sw_if_index_set = 0;
6841 /* Parse args required to build the message */
6842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6844 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6846 else if (unformat (i, "bd_id %d", &bd_id))
6848 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6849 sw_if_index_set = 1;
6850 else if (unformat (i, "sw_if"))
6852 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6855 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6856 sw_if_index_set = 1;
6861 else if (unformat (i, "static"))
6863 else if (unformat (i, "filter"))
6868 else if (unformat (i, "bvi"))
6873 else if (unformat (i, "del"))
6875 else if (unformat (i, "count %d", &count))
6883 errmsg ("missing mac address");
6889 errmsg ("missing bridge domain");
6893 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6895 errmsg ("missing interface name or sw_if_index");
6901 /* Turn on async mode */
6902 vam->async_mode = 1;
6903 vam->async_errors = 0;
6904 before = vat_time_now (vam);
6907 for (j = 0; j < count; j++)
6909 M (L2FIB_ADD_DEL, mp);
6911 clib_memcpy (mp->mac, mac, 6);
6912 mp->bd_id = ntohl (bd_id);
6913 mp->is_add = is_add;
6914 mp->sw_if_index = ntohl (sw_if_index);
6918 mp->static_mac = static_mac;
6919 mp->filter_mac = filter_mac;
6920 mp->bvi_mac = bvi_mac;
6922 increment_mac_address (mac);
6929 vl_api_control_ping_t *mp_ping;
6932 /* Shut off async mode */
6933 vam->async_mode = 0;
6935 MPING (CONTROL_PING, mp_ping);
6938 timeout = vat_time_now (vam) + 1.0;
6939 while (vat_time_now (vam) < timeout)
6940 if (vam->result_ready == 1)
6945 if (vam->retval == -99)
6948 if (vam->async_errors > 0)
6950 errmsg ("%d asynchronous errors", vam->async_errors);
6953 vam->async_errors = 0;
6954 after = vat_time_now (vam);
6956 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6957 count, after - before, count / (after - before));
6963 /* Wait for a reply... */
6967 /* Return the good/bad news */
6968 return (vam->retval);
6972 api_bridge_domain_set_mac_age (vat_main_t * vam)
6974 unformat_input_t *i = vam->input;
6975 vl_api_bridge_domain_set_mac_age_t *mp;
6980 /* Parse args required to build the message */
6981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6983 if (unformat (i, "bd_id %d", &bd_id));
6984 else if (unformat (i, "mac-age %d", &mac_age));
6991 errmsg ("missing bridge domain");
6997 errmsg ("mac age must be less than 256 ");
7001 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7003 mp->bd_id = htonl (bd_id);
7004 mp->mac_age = (u8) mac_age;
7012 api_l2_flags (vat_main_t * vam)
7014 unformat_input_t *i = vam->input;
7015 vl_api_l2_flags_t *mp;
7018 u8 sw_if_index_set = 0;
7022 /* Parse args required to build the message */
7023 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7025 if (unformat (i, "sw_if_index %d", &sw_if_index))
7026 sw_if_index_set = 1;
7027 else if (unformat (i, "sw_if"))
7029 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7032 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7033 sw_if_index_set = 1;
7038 else if (unformat (i, "learn"))
7040 else if (unformat (i, "forward"))
7042 else if (unformat (i, "flood"))
7044 else if (unformat (i, "uu-flood"))
7045 flags |= L2_UU_FLOOD;
7046 else if (unformat (i, "arp-term"))
7047 flags |= L2_ARP_TERM;
7048 else if (unformat (i, "off"))
7050 else if (unformat (i, "disable"))
7056 if (sw_if_index_set == 0)
7058 errmsg ("missing interface name or sw_if_index");
7064 mp->sw_if_index = ntohl (sw_if_index);
7065 mp->feature_bitmap = ntohl (flags);
7066 mp->is_set = is_set;
7074 api_bridge_flags (vat_main_t * vam)
7076 unformat_input_t *i = vam->input;
7077 vl_api_bridge_flags_t *mp;
7081 bd_flags_t flags = 0;
7084 /* Parse args required to build the message */
7085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7087 if (unformat (i, "bd_id %d", &bd_id))
7089 else if (unformat (i, "learn"))
7090 flags |= BRIDGE_API_FLAG_LEARN;
7091 else if (unformat (i, "forward"))
7092 flags |= BRIDGE_API_FLAG_FWD;
7093 else if (unformat (i, "flood"))
7094 flags |= BRIDGE_API_FLAG_FLOOD;
7095 else if (unformat (i, "uu-flood"))
7096 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7097 else if (unformat (i, "arp-term"))
7098 flags |= BRIDGE_API_FLAG_ARP_TERM;
7099 else if (unformat (i, "off"))
7101 else if (unformat (i, "disable"))
7109 errmsg ("missing bridge domain");
7113 M (BRIDGE_FLAGS, mp);
7115 mp->bd_id = ntohl (bd_id);
7116 mp->flags = ntohl (flags);
7117 mp->is_set = is_set;
7125 api_bd_ip_mac_add_del (vat_main_t * vam)
7127 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7128 vl_api_mac_address_t mac = { 0 };
7129 unformat_input_t *i = vam->input;
7130 vl_api_bd_ip_mac_add_del_t *mp;
7139 /* Parse args required to build the message */
7140 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7142 if (unformat (i, "bd_id %d", &bd_id))
7146 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7150 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7154 else if (unformat (i, "del"))
7162 errmsg ("missing bridge domain");
7165 else if (ip_set == 0)
7167 errmsg ("missing IP address");
7170 else if (mac_set == 0)
7172 errmsg ("missing MAC address");
7176 M (BD_IP_MAC_ADD_DEL, mp);
7178 mp->entry.bd_id = ntohl (bd_id);
7179 mp->is_add = is_add;
7181 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7182 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7190 api_bd_ip_mac_flush (vat_main_t * vam)
7192 unformat_input_t *i = vam->input;
7193 vl_api_bd_ip_mac_flush_t *mp;
7198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7200 if (unformat (i, "bd_id %d", &bd_id))
7210 errmsg ("missing bridge domain");
7214 M (BD_IP_MAC_FLUSH, mp);
7216 mp->bd_id = ntohl (bd_id);
7223 static void vl_api_bd_ip_mac_details_t_handler
7224 (vl_api_bd_ip_mac_details_t * mp)
7226 vat_main_t *vam = &vat_main;
7230 ntohl (mp->entry.bd_id),
7231 format_vl_api_mac_address, mp->entry.mac,
7232 format_vl_api_address, &mp->entry.ip);
7235 static void vl_api_bd_ip_mac_details_t_handler_json
7236 (vl_api_bd_ip_mac_details_t * mp)
7238 vat_main_t *vam = &vat_main;
7239 vat_json_node_t *node = NULL;
7241 if (VAT_JSON_ARRAY != vam->json_tree.type)
7243 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7244 vat_json_init_array (&vam->json_tree);
7246 node = vat_json_array_add (&vam->json_tree);
7248 vat_json_init_object (node);
7249 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7250 vat_json_object_add_string_copy (node, "mac_address",
7251 format (0, "%U", format_vl_api_mac_address,
7255 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7256 vat_json_object_add_string_copy (node, "ip_address", ip);
7261 api_bd_ip_mac_dump (vat_main_t * vam)
7263 unformat_input_t *i = vam->input;
7264 vl_api_bd_ip_mac_dump_t *mp;
7265 vl_api_control_ping_t *mp_ping;
7270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7272 if (unformat (i, "bd_id %d", &bd_id))
7281 "\n%-5s %-7s %-20s %-30s",
7282 "bd_id", "is_ipv6", "mac_address", "ip_address");
7284 /* Dump Bridge Domain Ip to Mac entries */
7285 M (BD_IP_MAC_DUMP, mp);
7288 mp->bd_id = htonl (bd_id);
7294 /* Use a control ping for synchronization */
7295 MPING (CONTROL_PING, mp_ping);
7303 api_tap_create_v2 (vat_main_t * vam)
7305 unformat_input_t *i = vam->input;
7306 vl_api_tap_create_v2_t *mp;
7310 u32 num_rx_queues = 0;
7311 u8 *host_if_name = 0;
7312 u8 host_if_name_set = 0;
7315 u8 host_mac_addr[6];
7316 u8 host_mac_addr_set = 0;
7317 u8 *host_bridge = 0;
7318 u8 host_bridge_set = 0;
7319 u8 host_ip4_prefix_set = 0;
7320 u8 host_ip6_prefix_set = 0;
7321 ip4_address_t host_ip4_addr;
7322 ip4_address_t host_ip4_gw;
7323 u8 host_ip4_gw_set = 0;
7324 u32 host_ip4_prefix_len = 0;
7325 ip6_address_t host_ip6_addr;
7326 ip6_address_t host_ip6_gw;
7327 u8 host_ip6_gw_set = 0;
7328 u32 host_ip6_prefix_len = 0;
7329 u32 host_mtu_size = 0;
7330 u8 host_mtu_set = 0;
7333 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7335 clib_memset (mac_address, 0, sizeof (mac_address));
7337 /* Parse args required to build the message */
7338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7340 if (unformat (i, "id %u", &id))
7344 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7346 else if (unformat (i, "host-if-name %s", &host_if_name))
7347 host_if_name_set = 1;
7348 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7350 else if (unformat (i, "host-ns %s", &host_ns))
7352 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7354 host_mac_addr_set = 1;
7355 else if (unformat (i, "host-bridge %s", &host_bridge))
7356 host_bridge_set = 1;
7357 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7358 &host_ip4_addr, &host_ip4_prefix_len))
7359 host_ip4_prefix_set = 1;
7360 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7361 &host_ip6_addr, &host_ip6_prefix_len))
7362 host_ip6_prefix_set = 1;
7363 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7365 host_ip4_gw_set = 1;
7366 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7368 host_ip6_gw_set = 1;
7369 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7371 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7373 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7375 else if (unformat (i, "no-gso"))
7376 tap_flags &= ~TAP_API_FLAG_GSO;
7377 else if (unformat (i, "gso"))
7378 tap_flags |= TAP_API_FLAG_GSO;
7379 else if (unformat (i, "csum-offload"))
7380 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
7381 else if (unformat (i, "persist"))
7382 tap_flags |= TAP_API_FLAG_PERSIST;
7383 else if (unformat (i, "attach"))
7384 tap_flags |= TAP_API_FLAG_ATTACH;
7385 else if (unformat (i, "tun"))
7386 tap_flags |= TAP_API_FLAG_TUN;
7387 else if (unformat (i, "gro-coalesce"))
7388 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
7393 if (vec_len (host_if_name) > 63)
7395 errmsg ("tap name too long. ");
7398 if (vec_len (host_ns) > 63)
7400 errmsg ("host name space too long. ");
7403 if (vec_len (host_bridge) > 63)
7405 errmsg ("host bridge name too long. ");
7408 if (host_ip4_prefix_len > 32)
7410 errmsg ("host ip4 prefix length not valid. ");
7413 if (host_ip6_prefix_len > 128)
7415 errmsg ("host ip6 prefix length not valid. ");
7418 if (!is_pow2 (rx_ring_sz))
7420 errmsg ("rx ring size must be power of 2. ");
7423 if (rx_ring_sz > 32768)
7425 errmsg ("rx ring size must be 32768 or lower. ");
7428 if (!is_pow2 (tx_ring_sz))
7430 errmsg ("tx ring size must be power of 2. ");
7433 if (tx_ring_sz > 32768)
7435 errmsg ("tx ring size must be 32768 or lower. ");
7438 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7440 errmsg ("host MTU size must be in between 64 and 65355. ");
7444 /* Construct the API message */
7445 M (TAP_CREATE_V2, mp);
7447 mp->id = ntohl (id);
7448 mp->use_random_mac = random_mac;
7449 mp->num_rx_queues = (u8) num_rx_queues;
7450 mp->tx_ring_sz = ntohs (tx_ring_sz);
7451 mp->rx_ring_sz = ntohs (rx_ring_sz);
7452 mp->host_mtu_set = host_mtu_set;
7453 mp->host_mtu_size = ntohl (host_mtu_size);
7454 mp->host_mac_addr_set = host_mac_addr_set;
7455 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7456 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7457 mp->host_ip4_gw_set = host_ip4_gw_set;
7458 mp->host_ip6_gw_set = host_ip6_gw_set;
7459 mp->tap_flags = ntohl (tap_flags);
7460 mp->host_namespace_set = host_ns_set;
7461 mp->host_if_name_set = host_if_name_set;
7462 mp->host_bridge_set = host_bridge_set;
7464 if (random_mac == 0)
7465 clib_memcpy (mp->mac_address, mac_address, 6);
7466 if (host_mac_addr_set)
7467 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7468 if (host_if_name_set)
7469 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7471 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7472 if (host_bridge_set)
7473 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7474 if (host_ip4_prefix_set)
7476 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7477 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7479 if (host_ip6_prefix_set)
7481 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7482 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7484 if (host_ip4_gw_set)
7485 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7486 if (host_ip6_gw_set)
7487 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7490 vec_free (host_if_name);
7491 vec_free (host_bridge);
7496 /* Wait for a reply... */
7502 api_tap_delete_v2 (vat_main_t * vam)
7504 unformat_input_t *i = vam->input;
7505 vl_api_tap_delete_v2_t *mp;
7506 u32 sw_if_index = ~0;
7507 u8 sw_if_index_set = 0;
7510 /* Parse args required to build the message */
7511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7513 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7514 sw_if_index_set = 1;
7515 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7516 sw_if_index_set = 1;
7521 if (sw_if_index_set == 0)
7523 errmsg ("missing vpp interface name. ");
7527 /* Construct the API message */
7528 M (TAP_DELETE_V2, mp);
7530 mp->sw_if_index = ntohl (sw_if_index);
7535 /* Wait for a reply... */
7541 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7543 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7546 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7549 addr->domain = x[0];
7552 addr->function = x[3];
7558 api_virtio_pci_create (vat_main_t * vam)
7560 unformat_input_t *i = vam->input;
7561 vl_api_virtio_pci_create_t *mp;
7565 u8 checksum_offload_enabled = 0;
7567 u64 features = (u64) ~ (0ULL);
7570 clib_memset (mac_address, 0, sizeof (mac_address));
7572 /* Parse args required to build the message */
7573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7575 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7579 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7581 else if (unformat (i, "features 0x%llx", &features))
7583 else if (unformat (i, "gso-enabled"))
7585 else if (unformat (i, "csum-offload-enabled"))
7586 checksum_offload_enabled = 1;
7593 errmsg ("pci address must be non zero. ");
7597 /* Construct the API message */
7598 M (VIRTIO_PCI_CREATE, mp);
7600 mp->use_random_mac = random_mac;
7602 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7603 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7604 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7605 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7607 mp->features = clib_host_to_net_u64 (features);
7608 mp->gso_enabled = gso_enabled;
7609 mp->checksum_offload_enabled = checksum_offload_enabled;
7611 if (random_mac == 0)
7612 clib_memcpy (mp->mac_address, mac_address, 6);
7617 /* Wait for a reply... */
7623 api_virtio_pci_delete (vat_main_t * vam)
7625 unformat_input_t *i = vam->input;
7626 vl_api_virtio_pci_delete_t *mp;
7627 u32 sw_if_index = ~0;
7628 u8 sw_if_index_set = 0;
7631 /* Parse args required to build the message */
7632 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7634 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7635 sw_if_index_set = 1;
7636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7637 sw_if_index_set = 1;
7642 if (sw_if_index_set == 0)
7644 errmsg ("missing vpp interface name. ");
7648 /* Construct the API message */
7649 M (VIRTIO_PCI_DELETE, mp);
7651 mp->sw_if_index = htonl (sw_if_index);
7656 /* Wait for a reply... */
7662 api_bond_create (vat_main_t * vam)
7664 unformat_input_t *i = vam->input;
7665 vl_api_bond_create_t *mp;
7675 clib_memset (mac_address, 0, sizeof (mac_address));
7678 /* Parse args required to build the message */
7679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7681 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7683 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7684 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7686 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7689 else if (unformat (i, "numa-only"))
7691 else if (unformat (i, "id %u", &id))
7697 if (mode_is_set == 0)
7699 errmsg ("Missing bond mode. ");
7703 /* Construct the API message */
7704 M (BOND_CREATE, mp);
7706 mp->use_custom_mac = custom_mac;
7708 mp->mode = htonl (mode);
7709 mp->lb = htonl (lb);
7710 mp->id = htonl (id);
7711 mp->numa_only = numa_only;
7714 clib_memcpy (mp->mac_address, mac_address, 6);
7719 /* Wait for a reply... */
7725 api_bond_delete (vat_main_t * vam)
7727 unformat_input_t *i = vam->input;
7728 vl_api_bond_delete_t *mp;
7729 u32 sw_if_index = ~0;
7730 u8 sw_if_index_set = 0;
7733 /* Parse args required to build the message */
7734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7736 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7737 sw_if_index_set = 1;
7738 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7739 sw_if_index_set = 1;
7744 if (sw_if_index_set == 0)
7746 errmsg ("missing vpp interface name. ");
7750 /* Construct the API message */
7751 M (BOND_DELETE, mp);
7753 mp->sw_if_index = ntohl (sw_if_index);
7758 /* Wait for a reply... */
7764 api_bond_add_member (vat_main_t * vam)
7766 unformat_input_t *i = vam->input;
7767 vl_api_bond_add_member_t *mp;
7768 u32 bond_sw_if_index;
7772 u32 bond_sw_if_index_is_set = 0;
7774 u8 sw_if_index_is_set = 0;
7776 /* Parse args required to build the message */
7777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7779 if (unformat (i, "sw_if_index %d", &sw_if_index))
7780 sw_if_index_is_set = 1;
7781 else if (unformat (i, "bond %u", &bond_sw_if_index))
7782 bond_sw_if_index_is_set = 1;
7783 else if (unformat (i, "passive %d", &is_passive))
7785 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7791 if (bond_sw_if_index_is_set == 0)
7793 errmsg ("Missing bond sw_if_index. ");
7796 if (sw_if_index_is_set == 0)
7798 errmsg ("Missing member sw_if_index. ");
7802 /* Construct the API message */
7803 M (BOND_ADD_MEMBER, mp);
7805 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7806 mp->sw_if_index = ntohl (sw_if_index);
7807 mp->is_long_timeout = is_long_timeout;
7808 mp->is_passive = is_passive;
7813 /* Wait for a reply... */
7819 api_bond_detach_member (vat_main_t * vam)
7821 unformat_input_t *i = vam->input;
7822 vl_api_bond_detach_member_t *mp;
7823 u32 sw_if_index = ~0;
7824 u8 sw_if_index_set = 0;
7827 /* Parse args required to build the message */
7828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7830 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7831 sw_if_index_set = 1;
7832 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7833 sw_if_index_set = 1;
7838 if (sw_if_index_set == 0)
7840 errmsg ("missing vpp interface name. ");
7844 /* Construct the API message */
7845 M (BOND_DETACH_MEMBER, mp);
7847 mp->sw_if_index = ntohl (sw_if_index);
7852 /* Wait for a reply... */
7858 api_ip_table_add_del (vat_main_t * vam)
7860 unformat_input_t *i = vam->input;
7861 vl_api_ip_table_add_del_t *mp;
7867 /* Parse args required to build the message */
7868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7870 if (unformat (i, "ipv6"))
7872 else if (unformat (i, "del"))
7874 else if (unformat (i, "add"))
7876 else if (unformat (i, "table %d", &table_id))
7880 clib_warning ("parse error '%U'", format_unformat_error, i);
7887 errmsg ("missing table-ID");
7891 /* Construct the API message */
7892 M (IP_TABLE_ADD_DEL, mp);
7894 mp->table.table_id = ntohl (table_id);
7895 mp->table.is_ip6 = is_ipv6;
7896 mp->is_add = is_add;
7901 /* Wait for a reply... */
7908 unformat_fib_path (unformat_input_t * input, va_list * args)
7910 vat_main_t *vam = va_arg (*args, vat_main_t *);
7911 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7912 u32 weight, preference;
7913 mpls_label_t out_label;
7915 clib_memset (path, 0, sizeof (*path));
7917 path->sw_if_index = ~0;
7921 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7923 if (unformat (input, "%U %U",
7924 unformat_vl_api_ip4_address,
7925 &path->nh.address.ip4,
7926 api_unformat_sw_if_index, vam, &path->sw_if_index))
7928 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7930 else if (unformat (input, "%U %U",
7931 unformat_vl_api_ip6_address,
7932 &path->nh.address.ip6,
7933 api_unformat_sw_if_index, vam, &path->sw_if_index))
7935 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7937 else if (unformat (input, "weight %u", &weight))
7939 path->weight = weight;
7941 else if (unformat (input, "preference %u", &preference))
7943 path->preference = preference;
7945 else if (unformat (input, "%U next-hop-table %d",
7946 unformat_vl_api_ip4_address,
7947 &path->nh.address.ip4, &path->table_id))
7949 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7951 else if (unformat (input, "%U next-hop-table %d",
7952 unformat_vl_api_ip6_address,
7953 &path->nh.address.ip6, &path->table_id))
7955 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7957 else if (unformat (input, "%U",
7958 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7961 * the recursive next-hops are by default in the default table
7964 path->sw_if_index = ~0;
7965 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7967 else if (unformat (input, "%U",
7968 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7971 * the recursive next-hops are by default in the default table
7974 path->sw_if_index = ~0;
7975 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7977 else if (unformat (input, "resolve-via-host"))
7979 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7981 else if (unformat (input, "resolve-via-attached"))
7983 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7985 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7987 path->type = FIB_API_PATH_TYPE_LOCAL;
7988 path->sw_if_index = ~0;
7989 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7991 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7993 path->type = FIB_API_PATH_TYPE_LOCAL;
7994 path->sw_if_index = ~0;
7995 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7997 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
7999 else if (unformat (input, "via-label %d", &path->nh.via_label))
8001 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
8002 path->sw_if_index = ~0;
8004 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
8006 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
8007 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
8009 else if (unformat (input, "local"))
8011 path->type = FIB_API_PATH_TYPE_LOCAL;
8013 else if (unformat (input, "out-labels"))
8015 while (unformat (input, "%d", &out_label))
8017 path->label_stack[path->n_labels].label = out_label;
8018 path->label_stack[path->n_labels].is_uniform = 0;
8019 path->label_stack[path->n_labels].ttl = 64;
8023 else if (unformat (input, "via"))
8025 /* new path, back up and return */
8026 unformat_put_input (input);
8027 unformat_put_input (input);
8028 unformat_put_input (input);
8029 unformat_put_input (input);
8038 path->proto = ntohl (path->proto);
8039 path->type = ntohl (path->type);
8040 path->flags = ntohl (path->flags);
8041 path->table_id = ntohl (path->table_id);
8042 path->sw_if_index = ntohl (path->sw_if_index);
8048 api_ip_route_add_del (vat_main_t * vam)
8050 unformat_input_t *i = vam->input;
8051 vl_api_ip_route_add_del_t *mp;
8054 u8 is_multipath = 0;
8057 vl_api_prefix_t pfx = { };
8058 vl_api_fib_path_t paths[8];
8062 u32 random_add_del = 0;
8063 u32 *random_vector = 0;
8064 u32 random_seed = 0xdeaddabe;
8066 /* Parse args required to build the message */
8067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8069 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8071 else if (unformat (i, "del"))
8073 else if (unformat (i, "add"))
8075 else if (unformat (i, "vrf %d", &vrf_id))
8077 else if (unformat (i, "count %d", &count))
8079 else if (unformat (i, "random"))
8081 else if (unformat (i, "multipath"))
8083 else if (unformat (i, "seed %d", &random_seed))
8087 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8090 if (8 == path_count)
8092 errmsg ("max 8 paths");
8098 clib_warning ("parse error '%U'", format_unformat_error, i);
8105 errmsg ("specify a path; via ...");
8108 if (prefix_set == 0)
8110 errmsg ("missing prefix");
8114 /* Generate a pile of unique, random routes */
8117 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8118 u32 this_random_address;
8121 random_hash = hash_create (count, sizeof (uword));
8123 hash_set (random_hash, i->as_u32, 1);
8124 for (j = 0; j <= count; j++)
8128 this_random_address = random_u32 (&random_seed);
8129 this_random_address =
8130 clib_host_to_net_u32 (this_random_address);
8132 while (hash_get (random_hash, this_random_address));
8133 vec_add1 (random_vector, this_random_address);
8134 hash_set (random_hash, this_random_address, 1);
8136 hash_free (random_hash);
8137 set_ip4_address (&pfx.address, random_vector[0]);
8142 /* Turn on async mode */
8143 vam->async_mode = 1;
8144 vam->async_errors = 0;
8145 before = vat_time_now (vam);
8148 for (j = 0; j < count; j++)
8150 /* Construct the API message */
8151 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8153 mp->is_add = is_add;
8154 mp->is_multipath = is_multipath;
8156 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8157 mp->route.table_id = ntohl (vrf_id);
8158 mp->route.n_paths = path_count;
8160 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8163 set_ip4_address (&pfx.address, random_vector[j + 1]);
8165 increment_address (&pfx.address);
8168 /* If we receive SIGTERM, stop now... */
8173 /* When testing multiple add/del ops, use a control-ping to sync */
8176 vl_api_control_ping_t *mp_ping;
8180 /* Shut off async mode */
8181 vam->async_mode = 0;
8183 MPING (CONTROL_PING, mp_ping);
8186 timeout = vat_time_now (vam) + 1.0;
8187 while (vat_time_now (vam) < timeout)
8188 if (vam->result_ready == 1)
8193 if (vam->retval == -99)
8196 if (vam->async_errors > 0)
8198 errmsg ("%d asynchronous errors", vam->async_errors);
8201 vam->async_errors = 0;
8202 after = vat_time_now (vam);
8204 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8208 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8209 count, after - before, count / (after - before));
8215 /* Wait for a reply... */
8220 /* Return the good/bad news */
8221 return (vam->retval);
8225 api_ip_mroute_add_del (vat_main_t * vam)
8227 unformat_input_t *i = vam->input;
8228 u8 path_set = 0, prefix_set = 0, is_add = 1;
8229 vl_api_ip_mroute_add_del_t *mp;
8230 mfib_entry_flags_t eflags = 0;
8231 vl_api_mfib_path_t path;
8232 vl_api_mprefix_t pfx = { };
8236 /* Parse args required to build the message */
8237 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8239 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8242 pfx.grp_address_length = htons (pfx.grp_address_length);
8244 else if (unformat (i, "del"))
8246 else if (unformat (i, "add"))
8248 else if (unformat (i, "vrf %d", &vrf_id))
8250 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8251 path.itf_flags = htonl (path.itf_flags);
8252 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8254 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8258 clib_warning ("parse error '%U'", format_unformat_error, i);
8263 if (prefix_set == 0)
8265 errmsg ("missing addresses\n");
8270 errmsg ("missing path\n");
8274 /* Construct the API message */
8275 M (IP_MROUTE_ADD_DEL, mp);
8277 mp->is_add = is_add;
8278 mp->is_multipath = 1;
8280 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8281 mp->route.table_id = htonl (vrf_id);
8282 mp->route.n_paths = 1;
8283 mp->route.entry_flags = htonl (eflags);
8285 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8289 /* Wait for a reply... */
8295 api_mpls_table_add_del (vat_main_t * vam)
8297 unformat_input_t *i = vam->input;
8298 vl_api_mpls_table_add_del_t *mp;
8303 /* Parse args required to build the message */
8304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8306 if (unformat (i, "table %d", &table_id))
8308 else if (unformat (i, "del"))
8310 else if (unformat (i, "add"))
8314 clib_warning ("parse error '%U'", format_unformat_error, i);
8321 errmsg ("missing table-ID");
8325 /* Construct the API message */
8326 M (MPLS_TABLE_ADD_DEL, mp);
8328 mp->mt_table.mt_table_id = ntohl (table_id);
8329 mp->mt_is_add = is_add;
8334 /* Wait for a reply... */
8341 api_mpls_route_add_del (vat_main_t * vam)
8343 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8344 mpls_label_t local_label = MPLS_LABEL_INVALID;
8345 unformat_input_t *i = vam->input;
8346 vl_api_mpls_route_add_del_t *mp;
8347 vl_api_fib_path_t paths[8];
8351 /* Parse args required to build the message */
8352 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8354 if (unformat (i, "%d", &local_label))
8356 else if (unformat (i, "eos"))
8358 else if (unformat (i, "non-eos"))
8360 else if (unformat (i, "del"))
8362 else if (unformat (i, "add"))
8364 else if (unformat (i, "multipath"))
8366 else if (unformat (i, "count %d", &count))
8370 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8373 if (8 == path_count)
8375 errmsg ("max 8 paths");
8381 clib_warning ("parse error '%U'", format_unformat_error, i);
8388 errmsg ("specify a path; via ...");
8392 if (MPLS_LABEL_INVALID == local_label)
8394 errmsg ("missing label");
8400 /* Turn on async mode */
8401 vam->async_mode = 1;
8402 vam->async_errors = 0;
8403 before = vat_time_now (vam);
8406 for (j = 0; j < count; j++)
8408 /* Construct the API message */
8409 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8411 mp->mr_is_add = is_add;
8412 mp->mr_is_multipath = is_multipath;
8414 mp->mr_route.mr_label = local_label;
8415 mp->mr_route.mr_eos = is_eos;
8416 mp->mr_route.mr_table_id = 0;
8417 mp->mr_route.mr_n_paths = path_count;
8419 clib_memcpy (&mp->mr_route.mr_paths, paths,
8420 sizeof (paths[0]) * path_count);
8426 /* If we receive SIGTERM, stop now... */
8431 /* When testing multiple add/del ops, use a control-ping to sync */
8434 vl_api_control_ping_t *mp_ping;
8438 /* Shut off async mode */
8439 vam->async_mode = 0;
8441 MPING (CONTROL_PING, mp_ping);
8444 timeout = vat_time_now (vam) + 1.0;
8445 while (vat_time_now (vam) < timeout)
8446 if (vam->result_ready == 1)
8451 if (vam->retval == -99)
8454 if (vam->async_errors > 0)
8456 errmsg ("%d asynchronous errors", vam->async_errors);
8459 vam->async_errors = 0;
8460 after = vat_time_now (vam);
8462 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8466 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8467 count, after - before, count / (after - before));
8473 /* Wait for a reply... */
8478 /* Return the good/bad news */
8479 return (vam->retval);
8484 api_mpls_ip_bind_unbind (vat_main_t * vam)
8486 unformat_input_t *i = vam->input;
8487 vl_api_mpls_ip_bind_unbind_t *mp;
8488 u32 ip_table_id = 0;
8490 vl_api_prefix_t pfx;
8492 mpls_label_t local_label = MPLS_LABEL_INVALID;
8495 /* Parse args required to build the message */
8496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8498 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8500 else if (unformat (i, "%d", &local_label))
8502 else if (unformat (i, "table-id %d", &ip_table_id))
8504 else if (unformat (i, "unbind"))
8506 else if (unformat (i, "bind"))
8510 clib_warning ("parse error '%U'", format_unformat_error, i);
8517 errmsg ("IP prefix not set");
8521 if (MPLS_LABEL_INVALID == local_label)
8523 errmsg ("missing label");
8527 /* Construct the API message */
8528 M (MPLS_IP_BIND_UNBIND, mp);
8530 mp->mb_is_bind = is_bind;
8531 mp->mb_ip_table_id = ntohl (ip_table_id);
8532 mp->mb_mpls_table_id = 0;
8533 mp->mb_label = ntohl (local_label);
8534 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8539 /* Wait for a reply... */
8546 api_sr_mpls_policy_add (vat_main_t * vam)
8548 unformat_input_t *i = vam->input;
8549 vl_api_sr_mpls_policy_add_t *mp;
8555 u32 *segments = NULL;
8558 /* Parse args required to build the message */
8559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8561 if (unformat (i, "bsid %d", &bsid))
8563 else if (unformat (i, "weight %d", &weight))
8565 else if (unformat (i, "spray"))
8567 else if (unformat (i, "next %d", &sid))
8570 vec_add1 (segments, htonl (sid));
8574 clib_warning ("parse error '%U'", format_unformat_error, i);
8581 errmsg ("bsid not set");
8585 if (n_segments == 0)
8587 errmsg ("no sid in segment stack");
8591 /* Construct the API message */
8592 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8594 mp->bsid = htonl (bsid);
8595 mp->weight = htonl (weight);
8596 mp->is_spray = type;
8597 mp->n_segments = n_segments;
8598 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8599 vec_free (segments);
8604 /* Wait for a reply... */
8610 api_sr_mpls_policy_del (vat_main_t * vam)
8612 unformat_input_t *i = vam->input;
8613 vl_api_sr_mpls_policy_del_t *mp;
8617 /* Parse args required to build the message */
8618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8620 if (unformat (i, "bsid %d", &bsid))
8624 clib_warning ("parse error '%U'", format_unformat_error, i);
8631 errmsg ("bsid not set");
8635 /* Construct the API message */
8636 M (SR_MPLS_POLICY_DEL, mp);
8638 mp->bsid = htonl (bsid);
8643 /* Wait for a reply... */
8649 api_bier_table_add_del (vat_main_t * vam)
8651 unformat_input_t *i = vam->input;
8652 vl_api_bier_table_add_del_t *mp;
8654 u32 set = 0, sub_domain = 0, hdr_len = 3;
8655 mpls_label_t local_label = MPLS_LABEL_INVALID;
8658 /* Parse args required to build the message */
8659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8661 if (unformat (i, "sub-domain %d", &sub_domain))
8663 else if (unformat (i, "set %d", &set))
8665 else if (unformat (i, "label %d", &local_label))
8667 else if (unformat (i, "hdr-len %d", &hdr_len))
8669 else if (unformat (i, "add"))
8671 else if (unformat (i, "del"))
8675 clib_warning ("parse error '%U'", format_unformat_error, i);
8680 if (MPLS_LABEL_INVALID == local_label)
8682 errmsg ("missing label\n");
8686 /* Construct the API message */
8687 M (BIER_TABLE_ADD_DEL, mp);
8689 mp->bt_is_add = is_add;
8690 mp->bt_label = ntohl (local_label);
8691 mp->bt_tbl_id.bt_set = set;
8692 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8693 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8698 /* Wait for a reply... */
8705 api_bier_route_add_del (vat_main_t * vam)
8707 unformat_input_t *i = vam->input;
8708 vl_api_bier_route_add_del_t *mp;
8710 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8711 ip4_address_t v4_next_hop_address;
8712 ip6_address_t v6_next_hop_address;
8713 u8 next_hop_set = 0;
8714 u8 next_hop_proto_is_ip4 = 1;
8715 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8718 /* Parse args required to build the message */
8719 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8721 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8723 next_hop_proto_is_ip4 = 1;
8726 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8728 next_hop_proto_is_ip4 = 0;
8731 if (unformat (i, "sub-domain %d", &sub_domain))
8733 else if (unformat (i, "set %d", &set))
8735 else if (unformat (i, "hdr-len %d", &hdr_len))
8737 else if (unformat (i, "bp %d", &bp))
8739 else if (unformat (i, "add"))
8741 else if (unformat (i, "del"))
8743 else if (unformat (i, "out-label %d", &next_hop_out_label))
8747 clib_warning ("parse error '%U'", format_unformat_error, i);
8752 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8754 errmsg ("next hop / label set\n");
8759 errmsg ("bit=position not set\n");
8763 /* Construct the API message */
8764 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8766 mp->br_is_add = is_add;
8767 mp->br_route.br_tbl_id.bt_set = set;
8768 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8769 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8770 mp->br_route.br_bp = ntohs (bp);
8771 mp->br_route.br_n_paths = 1;
8772 mp->br_route.br_paths[0].n_labels = 1;
8773 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8774 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8775 FIB_API_PATH_NH_PROTO_IP4 :
8776 FIB_API_PATH_NH_PROTO_IP6);
8778 if (next_hop_proto_is_ip4)
8780 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8781 &v4_next_hop_address, sizeof (v4_next_hop_address));
8785 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8786 &v6_next_hop_address, sizeof (v6_next_hop_address));
8792 /* Wait for a reply... */
8799 api_mpls_tunnel_add_del (vat_main_t * vam)
8801 unformat_input_t *i = vam->input;
8802 vl_api_mpls_tunnel_add_del_t *mp;
8804 vl_api_fib_path_t paths[8];
8805 u32 sw_if_index = ~0;
8811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8813 if (unformat (i, "add"))
8817 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8819 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8821 else if (unformat (i, "l2-only"))
8825 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8828 if (8 == path_count)
8830 errmsg ("max 8 paths");
8836 clib_warning ("parse error '%U'", format_unformat_error, i);
8841 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8843 mp->mt_is_add = is_add;
8844 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8845 mp->mt_tunnel.mt_l2_only = l2_only;
8846 mp->mt_tunnel.mt_is_multicast = 0;
8847 mp->mt_tunnel.mt_n_paths = path_count;
8849 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8850 sizeof (paths[0]) * path_count);
8858 api_sw_interface_set_unnumbered (vat_main_t * vam)
8860 unformat_input_t *i = vam->input;
8861 vl_api_sw_interface_set_unnumbered_t *mp;
8863 u32 unnum_sw_index = ~0;
8865 u8 sw_if_index_set = 0;
8868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8870 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8871 sw_if_index_set = 1;
8872 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8873 sw_if_index_set = 1;
8874 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8876 else if (unformat (i, "del"))
8880 clib_warning ("parse error '%U'", format_unformat_error, i);
8885 if (sw_if_index_set == 0)
8887 errmsg ("missing interface name or sw_if_index");
8891 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8893 mp->sw_if_index = ntohl (sw_if_index);
8894 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8895 mp->is_add = is_add;
8904 api_create_vlan_subif (vat_main_t * vam)
8906 unformat_input_t *i = vam->input;
8907 vl_api_create_vlan_subif_t *mp;
8909 u8 sw_if_index_set = 0;
8914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8916 if (unformat (i, "sw_if_index %d", &sw_if_index))
8917 sw_if_index_set = 1;
8919 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8920 sw_if_index_set = 1;
8921 else if (unformat (i, "vlan %d", &vlan_id))
8925 clib_warning ("parse error '%U'", format_unformat_error, i);
8930 if (sw_if_index_set == 0)
8932 errmsg ("missing interface name or sw_if_index");
8936 if (vlan_id_set == 0)
8938 errmsg ("missing vlan_id");
8941 M (CREATE_VLAN_SUBIF, mp);
8943 mp->sw_if_index = ntohl (sw_if_index);
8944 mp->vlan_id = ntohl (vlan_id);
8951 #define foreach_create_subif_bit \
8958 _(outer_vlan_id_any) \
8959 _(inner_vlan_id_any)
8961 #define foreach_create_subif_flag \
8966 _(4, "exact_match") \
8967 _(5, "default_sub") \
8968 _(6, "outer_vlan_id_any") \
8969 _(7, "inner_vlan_id_any")
8972 api_create_subif (vat_main_t * vam)
8974 unformat_input_t *i = vam->input;
8975 vl_api_create_subif_t *mp;
8977 u8 sw_if_index_set = 0;
8980 u32 __attribute__ ((unused)) no_tags = 0;
8981 u32 __attribute__ ((unused)) one_tag = 0;
8982 u32 __attribute__ ((unused)) two_tags = 0;
8983 u32 __attribute__ ((unused)) dot1ad = 0;
8984 u32 __attribute__ ((unused)) exact_match = 0;
8985 u32 __attribute__ ((unused)) default_sub = 0;
8986 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
8987 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
8989 u16 outer_vlan_id = 0;
8990 u16 inner_vlan_id = 0;
8993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8995 if (unformat (i, "sw_if_index %d", &sw_if_index))
8996 sw_if_index_set = 1;
8998 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8999 sw_if_index_set = 1;
9000 else if (unformat (i, "sub_id %d", &sub_id))
9002 else if (unformat (i, "outer_vlan_id %d", &tmp))
9003 outer_vlan_id = tmp;
9004 else if (unformat (i, "inner_vlan_id %d", &tmp))
9005 inner_vlan_id = tmp;
9007 #define _(a) else if (unformat (i, #a)) a = 1 ;
9008 foreach_create_subif_bit
9012 clib_warning ("parse error '%U'", format_unformat_error, i);
9017 if (sw_if_index_set == 0)
9019 errmsg ("missing interface name or sw_if_index");
9023 if (sub_id_set == 0)
9025 errmsg ("missing sub_id");
9028 M (CREATE_SUBIF, mp);
9030 mp->sw_if_index = ntohl (sw_if_index);
9031 mp->sub_id = ntohl (sub_id);
9033 #define _(a,b) mp->sub_if_flags |= (1 << a);
9034 foreach_create_subif_flag;
9037 mp->outer_vlan_id = ntohs (outer_vlan_id);
9038 mp->inner_vlan_id = ntohs (inner_vlan_id);
9046 api_ip_table_replace_begin (vat_main_t * vam)
9048 unformat_input_t *i = vam->input;
9049 vl_api_ip_table_replace_begin_t *mp;
9054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9056 if (unformat (i, "table %d", &table_id))
9058 else if (unformat (i, "ipv6"))
9062 clib_warning ("parse error '%U'", format_unformat_error, i);
9067 M (IP_TABLE_REPLACE_BEGIN, mp);
9069 mp->table.table_id = ntohl (table_id);
9070 mp->table.is_ip6 = is_ipv6;
9078 api_ip_table_flush (vat_main_t * vam)
9080 unformat_input_t *i = vam->input;
9081 vl_api_ip_table_flush_t *mp;
9086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9088 if (unformat (i, "table %d", &table_id))
9090 else if (unformat (i, "ipv6"))
9094 clib_warning ("parse error '%U'", format_unformat_error, i);
9099 M (IP_TABLE_FLUSH, mp);
9101 mp->table.table_id = ntohl (table_id);
9102 mp->table.is_ip6 = is_ipv6;
9110 api_ip_table_replace_end (vat_main_t * vam)
9112 unformat_input_t *i = vam->input;
9113 vl_api_ip_table_replace_end_t *mp;
9118 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9120 if (unformat (i, "table %d", &table_id))
9122 else if (unformat (i, "ipv6"))
9126 clib_warning ("parse error '%U'", format_unformat_error, i);
9131 M (IP_TABLE_REPLACE_END, mp);
9133 mp->table.table_id = ntohl (table_id);
9134 mp->table.is_ip6 = is_ipv6;
9142 api_set_ip_flow_hash (vat_main_t * vam)
9144 unformat_input_t *i = vam->input;
9145 vl_api_set_ip_flow_hash_t *mp;
9157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9159 if (unformat (i, "vrf %d", &vrf_id))
9161 else if (unformat (i, "ipv6"))
9163 else if (unformat (i, "src"))
9165 else if (unformat (i, "dst"))
9167 else if (unformat (i, "sport"))
9169 else if (unformat (i, "dport"))
9171 else if (unformat (i, "proto"))
9173 else if (unformat (i, "reverse"))
9178 clib_warning ("parse error '%U'", format_unformat_error, i);
9183 if (vrf_id_set == 0)
9185 errmsg ("missing vrf id");
9189 M (SET_IP_FLOW_HASH, mp);
9195 mp->reverse = reverse;
9196 mp->vrf_id = ntohl (vrf_id);
9197 mp->is_ipv6 = is_ipv6;
9205 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9207 unformat_input_t *i = vam->input;
9208 vl_api_sw_interface_ip6_enable_disable_t *mp;
9210 u8 sw_if_index_set = 0;
9214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9217 sw_if_index_set = 1;
9218 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9219 sw_if_index_set = 1;
9220 else if (unformat (i, "enable"))
9222 else if (unformat (i, "disable"))
9226 clib_warning ("parse error '%U'", format_unformat_error, i);
9231 if (sw_if_index_set == 0)
9233 errmsg ("missing interface name or sw_if_index");
9237 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9239 mp->sw_if_index = ntohl (sw_if_index);
9240 mp->enable = enable;
9249 api_l2_patch_add_del (vat_main_t * vam)
9251 unformat_input_t *i = vam->input;
9252 vl_api_l2_patch_add_del_t *mp;
9254 u8 rx_sw_if_index_set = 0;
9256 u8 tx_sw_if_index_set = 0;
9260 /* Parse args required to build the message */
9261 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9263 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9264 rx_sw_if_index_set = 1;
9265 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9266 tx_sw_if_index_set = 1;
9267 else if (unformat (i, "rx"))
9269 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9271 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9273 rx_sw_if_index_set = 1;
9278 else if (unformat (i, "tx"))
9280 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9282 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9284 tx_sw_if_index_set = 1;
9289 else if (unformat (i, "del"))
9295 if (rx_sw_if_index_set == 0)
9297 errmsg ("missing rx interface name or rx_sw_if_index");
9301 if (tx_sw_if_index_set == 0)
9303 errmsg ("missing tx interface name or tx_sw_if_index");
9307 M (L2_PATCH_ADD_DEL, mp);
9309 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9310 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9311 mp->is_add = is_add;
9319 u8 localsid_addr[16];
9328 api_sr_localsid_add_del (vat_main_t * vam)
9330 unformat_input_t *i = vam->input;
9331 vl_api_sr_localsid_add_del_t *mp;
9334 ip6_address_t localsid;
9338 u32 fib_table = ~(u32) 0;
9339 ip46_address_t nh_addr;
9340 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9342 bool nexthop_set = 0;
9346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9348 if (unformat (i, "del"))
9350 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9351 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9353 else if (unformat (i, "behavior %u", &behavior));
9354 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9355 else if (unformat (i, "fib-table %u", &fib_table));
9356 else if (unformat (i, "end.psp %u", &behavior));
9361 M (SR_LOCALSID_ADD_DEL, mp);
9363 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9367 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9369 mp->behavior = behavior;
9370 mp->sw_if_index = ntohl (sw_if_index);
9371 mp->fib_table = ntohl (fib_table);
9372 mp->end_psp = end_psp;
9373 mp->is_del = is_del;
9381 api_ioam_enable (vat_main_t * vam)
9383 unformat_input_t *input = vam->input;
9384 vl_api_ioam_enable_t *mp;
9386 int has_trace_option = 0;
9387 int has_pot_option = 0;
9388 int has_seqno_option = 0;
9389 int has_analyse_option = 0;
9392 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9394 if (unformat (input, "trace"))
9395 has_trace_option = 1;
9396 else if (unformat (input, "pot"))
9398 else if (unformat (input, "seqno"))
9399 has_seqno_option = 1;
9400 else if (unformat (input, "analyse"))
9401 has_analyse_option = 1;
9405 M (IOAM_ENABLE, mp);
9406 mp->id = htons (id);
9407 mp->seqno = has_seqno_option;
9408 mp->analyse = has_analyse_option;
9409 mp->pot_enable = has_pot_option;
9410 mp->trace_enable = has_trace_option;
9419 api_ioam_disable (vat_main_t * vam)
9421 vl_api_ioam_disable_t *mp;
9424 M (IOAM_DISABLE, mp);
9430 #define foreach_tcp_proto_field \
9434 #define foreach_udp_proto_field \
9438 #define foreach_ip4_proto_field \
9450 u16 src_port, dst_port;
9453 #if VPP_API_TEST_BUILTIN == 0
9455 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9457 u8 **maskp = va_arg (*args, u8 **);
9459 u8 found_something = 0;
9462 #define _(a) u8 a=0;
9463 foreach_tcp_proto_field;
9466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9469 #define _(a) else if (unformat (input, #a)) a=1;
9470 foreach_tcp_proto_field
9476 #define _(a) found_something += a;
9477 foreach_tcp_proto_field;
9480 if (found_something == 0)
9483 vec_validate (mask, sizeof (*tcp) - 1);
9485 tcp = (tcp_header_t *) mask;
9487 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9488 foreach_tcp_proto_field;
9496 unformat_udp_mask (unformat_input_t * input, va_list * args)
9498 u8 **maskp = va_arg (*args, u8 **);
9500 u8 found_something = 0;
9503 #define _(a) u8 a=0;
9504 foreach_udp_proto_field;
9507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9510 #define _(a) else if (unformat (input, #a)) a=1;
9511 foreach_udp_proto_field
9517 #define _(a) found_something += a;
9518 foreach_udp_proto_field;
9521 if (found_something == 0)
9524 vec_validate (mask, sizeof (*udp) - 1);
9526 udp = (udp_header_t *) mask;
9528 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9529 foreach_udp_proto_field;
9537 unformat_l4_mask (unformat_input_t * input, va_list * args)
9539 u8 **maskp = va_arg (*args, u8 **);
9540 u16 src_port = 0, dst_port = 0;
9541 tcpudp_header_t *tcpudp;
9543 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9545 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9547 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9549 else if (unformat (input, "src_port"))
9551 else if (unformat (input, "dst_port"))
9557 if (!src_port && !dst_port)
9561 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9563 tcpudp = (tcpudp_header_t *) mask;
9564 tcpudp->src_port = src_port;
9565 tcpudp->dst_port = dst_port;
9573 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9575 u8 **maskp = va_arg (*args, u8 **);
9577 u8 found_something = 0;
9580 #define _(a) u8 a=0;
9581 foreach_ip4_proto_field;
9587 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9589 if (unformat (input, "version"))
9591 else if (unformat (input, "hdr_length"))
9593 else if (unformat (input, "src"))
9595 else if (unformat (input, "dst"))
9597 else if (unformat (input, "proto"))
9600 #define _(a) else if (unformat (input, #a)) a=1;
9601 foreach_ip4_proto_field
9607 #define _(a) found_something += a;
9608 foreach_ip4_proto_field;
9611 if (found_something == 0)
9614 vec_validate (mask, sizeof (*ip) - 1);
9616 ip = (ip4_header_t *) mask;
9618 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9619 foreach_ip4_proto_field;
9622 ip->ip_version_and_header_length = 0;
9625 ip->ip_version_and_header_length |= 0xF0;
9628 ip->ip_version_and_header_length |= 0x0F;
9634 #define foreach_ip6_proto_field \
9642 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9644 u8 **maskp = va_arg (*args, u8 **);
9646 u8 found_something = 0;
9648 u32 ip_version_traffic_class_and_flow_label;
9650 #define _(a) u8 a=0;
9651 foreach_ip6_proto_field;
9654 u8 traffic_class = 0;
9657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9659 if (unformat (input, "version"))
9661 else if (unformat (input, "traffic-class"))
9663 else if (unformat (input, "flow-label"))
9665 else if (unformat (input, "src"))
9667 else if (unformat (input, "dst"))
9669 else if (unformat (input, "proto"))
9672 #define _(a) else if (unformat (input, #a)) a=1;
9673 foreach_ip6_proto_field
9679 #define _(a) found_something += a;
9680 foreach_ip6_proto_field;
9683 if (found_something == 0)
9686 vec_validate (mask, sizeof (*ip) - 1);
9688 ip = (ip6_header_t *) mask;
9690 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9691 foreach_ip6_proto_field;
9694 ip_version_traffic_class_and_flow_label = 0;
9697 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9700 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9703 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9705 ip->ip_version_traffic_class_and_flow_label =
9706 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9713 unformat_l3_mask (unformat_input_t * input, va_list * args)
9715 u8 **maskp = va_arg (*args, u8 **);
9717 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9719 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9721 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9730 unformat_l2_mask (unformat_input_t * input, va_list * args)
9732 u8 **maskp = va_arg (*args, u8 **);
9747 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9749 if (unformat (input, "src"))
9751 else if (unformat (input, "dst"))
9753 else if (unformat (input, "proto"))
9755 else if (unformat (input, "tag1"))
9757 else if (unformat (input, "tag2"))
9759 else if (unformat (input, "ignore-tag1"))
9761 else if (unformat (input, "ignore-tag2"))
9763 else if (unformat (input, "cos1"))
9765 else if (unformat (input, "cos2"))
9767 else if (unformat (input, "dot1q"))
9769 else if (unformat (input, "dot1ad"))
9774 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9775 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9778 if (tag1 || ignore_tag1 || cos1 || dot1q)
9780 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9783 vec_validate (mask, len - 1);
9786 clib_memset (mask, 0xff, 6);
9789 clib_memset (mask + 6, 0xff, 6);
9793 /* inner vlan tag */
9802 mask[21] = mask[20] = 0xff;
9823 mask[16] = mask[17] = 0xff;
9833 mask[12] = mask[13] = 0xff;
9840 unformat_classify_mask (unformat_input_t * input, va_list * args)
9842 u8 **maskp = va_arg (*args, u8 **);
9843 u32 *skipp = va_arg (*args, u32 *);
9844 u32 *matchp = va_arg (*args, u32 *);
9852 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9854 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9856 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9858 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9860 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9874 if (mask || l2 || l3 || l4)
9878 /* "With a free Ethernet header in every package" */
9880 vec_validate (l2, 13);
9884 vec_append (mask, l3);
9889 vec_append (mask, l4);
9894 /* Scan forward looking for the first significant mask octet */
9895 for (i = 0; i < vec_len (mask); i++)
9899 /* compute (skip, match) params */
9900 *skipp = i / sizeof (u32x4);
9901 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9903 /* Pad mask to an even multiple of the vector size */
9904 while (vec_len (mask) % sizeof (u32x4))
9907 match = vec_len (mask) / sizeof (u32x4);
9909 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9911 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9912 if (*tmp || *(tmp + 1))
9917 clib_warning ("BUG: match 0");
9919 _vec_len (mask) = match * sizeof (u32x4);
9929 #endif /* VPP_API_TEST_BUILTIN */
9931 #define foreach_l2_next \
9933 _(ethernet, ETHERNET_INPUT) \
9938 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9940 u32 *miss_next_indexp = va_arg (*args, u32 *);
9945 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9949 if (unformat (input, "%d", &tmp))
9958 *miss_next_indexp = next_index;
9962 #define foreach_ip_next \
9968 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9970 u32 *miss_next_indexp = va_arg (*args, u32 *);
9975 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9979 if (unformat (input, "%d", &tmp))
9988 *miss_next_indexp = next_index;
9992 #define foreach_acl_next \
9996 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9998 u32 *miss_next_indexp = va_arg (*args, u32 *);
10003 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10007 if (unformat (input, "permit"))
10012 else if (unformat (input, "%d", &tmp))
10021 *miss_next_indexp = next_index;
10026 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10028 u32 *r = va_arg (*args, u32 *);
10030 if (unformat (input, "conform-color"))
10031 *r = POLICE_CONFORM;
10032 else if (unformat (input, "exceed-color"))
10033 *r = POLICE_EXCEED;
10041 api_classify_add_del_table (vat_main_t * vam)
10043 unformat_input_t *i = vam->input;
10044 vl_api_classify_add_del_table_t *mp;
10051 u32 table_index = ~0;
10052 u32 next_table_index = ~0;
10053 u32 miss_next_index = ~0;
10054 u32 memory_size = 32 << 20;
10056 u32 current_data_flag = 0;
10057 int current_data_offset = 0;
10060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10062 if (unformat (i, "del"))
10064 else if (unformat (i, "del-chain"))
10069 else if (unformat (i, "buckets %d", &nbuckets))
10071 else if (unformat (i, "memory_size %d", &memory_size))
10073 else if (unformat (i, "skip %d", &skip))
10075 else if (unformat (i, "match %d", &match))
10077 else if (unformat (i, "table %d", &table_index))
10079 else if (unformat (i, "mask %U", unformat_classify_mask,
10080 &mask, &skip, &match))
10082 else if (unformat (i, "next-table %d", &next_table_index))
10084 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10087 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10090 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10093 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10095 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10101 if (is_add && mask == 0)
10103 errmsg ("Mask required");
10107 if (is_add && skip == ~0)
10109 errmsg ("skip count required");
10113 if (is_add && match == ~0)
10115 errmsg ("match count required");
10119 if (!is_add && table_index == ~0)
10121 errmsg ("table index required for delete");
10125 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10127 mp->is_add = is_add;
10128 mp->del_chain = del_chain;
10129 mp->table_index = ntohl (table_index);
10130 mp->nbuckets = ntohl (nbuckets);
10131 mp->memory_size = ntohl (memory_size);
10132 mp->skip_n_vectors = ntohl (skip);
10133 mp->match_n_vectors = ntohl (match);
10134 mp->next_table_index = ntohl (next_table_index);
10135 mp->miss_next_index = ntohl (miss_next_index);
10136 mp->current_data_flag = ntohl (current_data_flag);
10137 mp->current_data_offset = ntohl (current_data_offset);
10138 mp->mask_len = ntohl (vec_len (mask));
10139 clib_memcpy (mp->mask, mask, vec_len (mask));
10148 #if VPP_API_TEST_BUILTIN == 0
10150 unformat_l4_match (unformat_input_t * input, va_list * args)
10152 u8 **matchp = va_arg (*args, u8 **);
10154 u8 *proto_header = 0;
10160 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10162 if (unformat (input, "src_port %d", &src_port))
10164 else if (unformat (input, "dst_port %d", &dst_port))
10170 h.src_port = clib_host_to_net_u16 (src_port);
10171 h.dst_port = clib_host_to_net_u16 (dst_port);
10172 vec_validate (proto_header, sizeof (h) - 1);
10173 memcpy (proto_header, &h, sizeof (h));
10175 *matchp = proto_header;
10181 unformat_ip4_match (unformat_input_t * input, va_list * args)
10183 u8 **matchp = va_arg (*args, u8 **);
10188 int hdr_length = 0;
10189 u32 hdr_length_val;
10190 int src = 0, dst = 0;
10191 ip4_address_t src_val, dst_val;
10198 int fragment_id = 0;
10199 u32 fragment_id_val;
10205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10207 if (unformat (input, "version %d", &version_val))
10209 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10211 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10213 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10215 else if (unformat (input, "proto %d", &proto_val))
10217 else if (unformat (input, "tos %d", &tos_val))
10219 else if (unformat (input, "length %d", &length_val))
10221 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10223 else if (unformat (input, "ttl %d", &ttl_val))
10225 else if (unformat (input, "checksum %d", &checksum_val))
10231 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10232 + ttl + checksum == 0)
10236 * Aligned because we use the real comparison functions
10238 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10240 ip = (ip4_header_t *) match;
10242 /* These are realistically matched in practice */
10244 ip->src_address.as_u32 = src_val.as_u32;
10247 ip->dst_address.as_u32 = dst_val.as_u32;
10250 ip->protocol = proto_val;
10253 /* These are not, but they're included for completeness */
10255 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10258 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10264 ip->length = clib_host_to_net_u16 (length_val);
10270 ip->checksum = clib_host_to_net_u16 (checksum_val);
10277 unformat_ip6_match (unformat_input_t * input, va_list * args)
10279 u8 **matchp = va_arg (*args, u8 **);
10284 u8 traffic_class = 0;
10285 u32 traffic_class_val = 0;
10288 int src = 0, dst = 0;
10289 ip6_address_t src_val, dst_val;
10292 int payload_length = 0;
10293 u32 payload_length_val;
10296 u32 ip_version_traffic_class_and_flow_label;
10298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10300 if (unformat (input, "version %d", &version_val))
10302 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10304 else if (unformat (input, "flow_label %d", &flow_label_val))
10306 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10308 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10310 else if (unformat (input, "proto %d", &proto_val))
10312 else if (unformat (input, "payload_length %d", &payload_length_val))
10313 payload_length = 1;
10314 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10320 if (version + traffic_class + flow_label + src + dst + proto +
10321 payload_length + hop_limit == 0)
10325 * Aligned because we use the real comparison functions
10327 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10329 ip = (ip6_header_t *) match;
10332 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10335 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10338 ip->protocol = proto_val;
10340 ip_version_traffic_class_and_flow_label = 0;
10343 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10346 ip_version_traffic_class_and_flow_label |=
10347 (traffic_class_val & 0xFF) << 20;
10350 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10352 ip->ip_version_traffic_class_and_flow_label =
10353 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10355 if (payload_length)
10356 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10359 ip->hop_limit = hop_limit_val;
10366 unformat_l3_match (unformat_input_t * input, va_list * args)
10368 u8 **matchp = va_arg (*args, u8 **);
10370 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10372 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10374 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10383 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10385 u8 *tagp = va_arg (*args, u8 *);
10388 if (unformat (input, "%d", &tag))
10390 tagp[0] = (tag >> 8) & 0x0F;
10391 tagp[1] = tag & 0xFF;
10399 unformat_l2_match (unformat_input_t * input, va_list * args)
10401 u8 **matchp = va_arg (*args, u8 **);
10414 u8 ignore_tag1 = 0;
10415 u8 ignore_tag2 = 0;
10421 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10423 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10426 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10428 else if (unformat (input, "proto %U",
10429 unformat_ethernet_type_host_byte_order, &proto_val))
10431 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10433 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10435 else if (unformat (input, "ignore-tag1"))
10437 else if (unformat (input, "ignore-tag2"))
10439 else if (unformat (input, "cos1 %d", &cos1_val))
10441 else if (unformat (input, "cos2 %d", &cos2_val))
10446 if ((src + dst + proto + tag1 + tag2 +
10447 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10450 if (tag1 || ignore_tag1 || cos1)
10452 if (tag2 || ignore_tag2 || cos2)
10455 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10458 clib_memcpy (match, dst_val, 6);
10461 clib_memcpy (match + 6, src_val, 6);
10465 /* inner vlan tag */
10466 match[19] = tag2_val[1];
10467 match[18] = tag2_val[0];
10469 match[18] |= (cos2_val & 0x7) << 5;
10472 match[21] = proto_val & 0xff;
10473 match[20] = proto_val >> 8;
10477 match[15] = tag1_val[1];
10478 match[14] = tag1_val[0];
10481 match[14] |= (cos1_val & 0x7) << 5;
10487 match[15] = tag1_val[1];
10488 match[14] = tag1_val[0];
10491 match[17] = proto_val & 0xff;
10492 match[16] = proto_val >> 8;
10495 match[14] |= (cos1_val & 0x7) << 5;
10501 match[18] |= (cos2_val & 0x7) << 5;
10503 match[14] |= (cos1_val & 0x7) << 5;
10506 match[13] = proto_val & 0xff;
10507 match[12] = proto_val >> 8;
10515 unformat_qos_source (unformat_input_t * input, va_list * args)
10517 int *qs = va_arg (*args, int *);
10519 if (unformat (input, "ip"))
10520 *qs = QOS_SOURCE_IP;
10521 else if (unformat (input, "mpls"))
10522 *qs = QOS_SOURCE_MPLS;
10523 else if (unformat (input, "ext"))
10524 *qs = QOS_SOURCE_EXT;
10525 else if (unformat (input, "vlan"))
10526 *qs = QOS_SOURCE_VLAN;
10535 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10537 u8 **matchp = va_arg (*args, u8 **);
10538 u32 skip_n_vectors = va_arg (*args, u32);
10539 u32 match_n_vectors = va_arg (*args, u32);
10546 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10548 if (unformat (input, "hex %U", unformat_hex_string, &match))
10550 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10552 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10554 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10568 if (match || l2 || l3 || l4)
10570 if (l2 || l3 || l4)
10572 /* "Win a free Ethernet header in every packet" */
10574 vec_validate_aligned (l2, 13, sizeof (u32x4));
10578 vec_append_aligned (match, l3, sizeof (u32x4));
10583 vec_append_aligned (match, l4, sizeof (u32x4));
10588 /* Make sure the vector is big enough even if key is all 0's */
10589 vec_validate_aligned
10590 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10593 /* Set size, include skipped vectors */
10594 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10605 api_classify_add_del_session (vat_main_t * vam)
10607 unformat_input_t *i = vam->input;
10608 vl_api_classify_add_del_session_t *mp;
10610 u32 table_index = ~0;
10611 u32 hit_next_index = ~0;
10612 u32 opaque_index = ~0;
10615 u32 skip_n_vectors = 0;
10616 u32 match_n_vectors = 0;
10622 * Warning: you have to supply skip_n and match_n
10623 * because the API client cant simply look at the classify
10627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10629 if (unformat (i, "del"))
10631 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10634 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10637 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10640 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10642 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10644 else if (unformat (i, "opaque-index %d", &opaque_index))
10646 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10648 else if (unformat (i, "match_n %d", &match_n_vectors))
10650 else if (unformat (i, "match %U", api_unformat_classify_match,
10651 &match, skip_n_vectors, match_n_vectors))
10653 else if (unformat (i, "advance %d", &advance))
10655 else if (unformat (i, "table-index %d", &table_index))
10657 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10659 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10661 else if (unformat (i, "action %d", &action))
10663 else if (unformat (i, "metadata %d", &metadata))
10669 if (table_index == ~0)
10671 errmsg ("Table index required");
10675 if (is_add && match == 0)
10677 errmsg ("Match value required");
10681 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10683 mp->is_add = is_add;
10684 mp->table_index = ntohl (table_index);
10685 mp->hit_next_index = ntohl (hit_next_index);
10686 mp->opaque_index = ntohl (opaque_index);
10687 mp->advance = ntohl (advance);
10688 mp->action = action;
10689 mp->metadata = ntohl (metadata);
10690 mp->match_len = ntohl (vec_len (match));
10691 clib_memcpy (mp->match, match, vec_len (match));
10700 api_classify_set_interface_ip_table (vat_main_t * vam)
10702 unformat_input_t *i = vam->input;
10703 vl_api_classify_set_interface_ip_table_t *mp;
10705 int sw_if_index_set;
10706 u32 table_index = ~0;
10710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10712 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10713 sw_if_index_set = 1;
10714 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10715 sw_if_index_set = 1;
10716 else if (unformat (i, "table %d", &table_index))
10720 clib_warning ("parse error '%U'", format_unformat_error, i);
10725 if (sw_if_index_set == 0)
10727 errmsg ("missing interface name or sw_if_index");
10732 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10734 mp->sw_if_index = ntohl (sw_if_index);
10735 mp->table_index = ntohl (table_index);
10736 mp->is_ipv6 = is_ipv6;
10744 api_classify_set_interface_l2_tables (vat_main_t * vam)
10746 unformat_input_t *i = vam->input;
10747 vl_api_classify_set_interface_l2_tables_t *mp;
10749 int sw_if_index_set;
10750 u32 ip4_table_index = ~0;
10751 u32 ip6_table_index = ~0;
10752 u32 other_table_index = ~0;
10756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10759 sw_if_index_set = 1;
10760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10761 sw_if_index_set = 1;
10762 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10764 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10766 else if (unformat (i, "other-table %d", &other_table_index))
10768 else if (unformat (i, "is-input %d", &is_input))
10772 clib_warning ("parse error '%U'", format_unformat_error, i);
10777 if (sw_if_index_set == 0)
10779 errmsg ("missing interface name or sw_if_index");
10784 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10786 mp->sw_if_index = ntohl (sw_if_index);
10787 mp->ip4_table_index = ntohl (ip4_table_index);
10788 mp->ip6_table_index = ntohl (ip6_table_index);
10789 mp->other_table_index = ntohl (other_table_index);
10790 mp->is_input = (u8) is_input;
10798 api_set_ipfix_exporter (vat_main_t * vam)
10800 unformat_input_t *i = vam->input;
10801 vl_api_set_ipfix_exporter_t *mp;
10802 ip4_address_t collector_address;
10803 u8 collector_address_set = 0;
10804 u32 collector_port = ~0;
10805 ip4_address_t src_address;
10806 u8 src_address_set = 0;
10809 u32 template_interval = ~0;
10810 u8 udp_checksum = 0;
10813 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10815 if (unformat (i, "collector_address %U", unformat_ip4_address,
10816 &collector_address))
10817 collector_address_set = 1;
10818 else if (unformat (i, "collector_port %d", &collector_port))
10820 else if (unformat (i, "src_address %U", unformat_ip4_address,
10822 src_address_set = 1;
10823 else if (unformat (i, "vrf_id %d", &vrf_id))
10825 else if (unformat (i, "path_mtu %d", &path_mtu))
10827 else if (unformat (i, "template_interval %d", &template_interval))
10829 else if (unformat (i, "udp_checksum"))
10835 if (collector_address_set == 0)
10837 errmsg ("collector_address required");
10841 if (src_address_set == 0)
10843 errmsg ("src_address required");
10847 M (SET_IPFIX_EXPORTER, mp);
10849 memcpy (mp->collector_address.un.ip4, collector_address.data,
10850 sizeof (collector_address.data));
10851 mp->collector_port = htons ((u16) collector_port);
10852 memcpy (mp->src_address.un.ip4, src_address.data,
10853 sizeof (src_address.data));
10854 mp->vrf_id = htonl (vrf_id);
10855 mp->path_mtu = htonl (path_mtu);
10856 mp->template_interval = htonl (template_interval);
10857 mp->udp_checksum = udp_checksum;
10865 api_set_ipfix_classify_stream (vat_main_t * vam)
10867 unformat_input_t *i = vam->input;
10868 vl_api_set_ipfix_classify_stream_t *mp;
10870 u32 src_port = UDP_DST_PORT_ipfix;
10873 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10875 if (unformat (i, "domain %d", &domain_id))
10877 else if (unformat (i, "src_port %d", &src_port))
10881 errmsg ("unknown input `%U'", format_unformat_error, i);
10886 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10888 mp->domain_id = htonl (domain_id);
10889 mp->src_port = htons ((u16) src_port);
10897 api_ipfix_classify_table_add_del (vat_main_t * vam)
10899 unformat_input_t *i = vam->input;
10900 vl_api_ipfix_classify_table_add_del_t *mp;
10902 u32 classify_table_index = ~0;
10904 u8 transport_protocol = 255;
10907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10909 if (unformat (i, "add"))
10911 else if (unformat (i, "del"))
10913 else if (unformat (i, "table %d", &classify_table_index))
10915 else if (unformat (i, "ip4"))
10917 else if (unformat (i, "ip6"))
10919 else if (unformat (i, "tcp"))
10920 transport_protocol = 6;
10921 else if (unformat (i, "udp"))
10922 transport_protocol = 17;
10925 errmsg ("unknown input `%U'", format_unformat_error, i);
10932 errmsg ("expecting: add|del");
10935 if (classify_table_index == ~0)
10937 errmsg ("classifier table not specified");
10940 if (ip_version == 0)
10942 errmsg ("IP version not specified");
10946 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10948 mp->is_add = is_add;
10949 mp->table_id = htonl (classify_table_index);
10950 mp->ip_version = ip_version;
10951 mp->transport_protocol = transport_protocol;
10959 api_get_node_index (vat_main_t * vam)
10961 unformat_input_t *i = vam->input;
10962 vl_api_get_node_index_t *mp;
10966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10968 if (unformat (i, "node %s", &name))
10975 errmsg ("node name required");
10978 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10980 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10984 M (GET_NODE_INDEX, mp);
10985 clib_memcpy (mp->node_name, name, vec_len (name));
10994 api_get_next_index (vat_main_t * vam)
10996 unformat_input_t *i = vam->input;
10997 vl_api_get_next_index_t *mp;
10998 u8 *node_name = 0, *next_node_name = 0;
11001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11003 if (unformat (i, "node-name %s", &node_name))
11005 else if (unformat (i, "next-node-name %s", &next_node_name))
11009 if (node_name == 0)
11011 errmsg ("node name required");
11014 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11016 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11020 if (next_node_name == 0)
11022 errmsg ("next node name required");
11025 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11027 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11031 M (GET_NEXT_INDEX, mp);
11032 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11033 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11034 vec_free (node_name);
11035 vec_free (next_node_name);
11043 api_add_node_next (vat_main_t * vam)
11045 unformat_input_t *i = vam->input;
11046 vl_api_add_node_next_t *mp;
11051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11053 if (unformat (i, "node %s", &name))
11055 else if (unformat (i, "next %s", &next))
11062 errmsg ("node name required");
11065 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11067 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11072 errmsg ("next node required");
11075 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11077 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11081 M (ADD_NODE_NEXT, mp);
11082 clib_memcpy (mp->node_name, name, vec_len (name));
11083 clib_memcpy (mp->next_name, next, vec_len (next));
11093 api_l2tpv3_create_tunnel (vat_main_t * vam)
11095 unformat_input_t *i = vam->input;
11096 ip6_address_t client_address, our_address;
11097 int client_address_set = 0;
11098 int our_address_set = 0;
11099 u32 local_session_id = 0;
11100 u32 remote_session_id = 0;
11101 u64 local_cookie = 0;
11102 u64 remote_cookie = 0;
11103 u8 l2_sublayer_present = 0;
11104 vl_api_l2tpv3_create_tunnel_t *mp;
11107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11109 if (unformat (i, "client_address %U", unformat_ip6_address,
11111 client_address_set = 1;
11112 else if (unformat (i, "our_address %U", unformat_ip6_address,
11114 our_address_set = 1;
11115 else if (unformat (i, "local_session_id %d", &local_session_id))
11117 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11119 else if (unformat (i, "local_cookie %lld", &local_cookie))
11121 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11123 else if (unformat (i, "l2-sublayer-present"))
11124 l2_sublayer_present = 1;
11129 if (client_address_set == 0)
11131 errmsg ("client_address required");
11135 if (our_address_set == 0)
11137 errmsg ("our_address required");
11141 M (L2TPV3_CREATE_TUNNEL, mp);
11143 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11144 sizeof (ip6_address_t));
11146 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11147 sizeof (ip6_address_t));
11149 mp->local_session_id = ntohl (local_session_id);
11150 mp->remote_session_id = ntohl (remote_session_id);
11151 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11152 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11153 mp->l2_sublayer_present = l2_sublayer_present;
11161 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11163 unformat_input_t *i = vam->input;
11165 u8 sw_if_index_set = 0;
11166 u64 new_local_cookie = 0;
11167 u64 new_remote_cookie = 0;
11168 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11171 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11173 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11174 sw_if_index_set = 1;
11175 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11176 sw_if_index_set = 1;
11177 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11179 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11185 if (sw_if_index_set == 0)
11187 errmsg ("missing interface name or sw_if_index");
11191 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11193 mp->sw_if_index = ntohl (sw_if_index);
11194 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11195 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11203 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11205 unformat_input_t *i = vam->input;
11206 vl_api_l2tpv3_interface_enable_disable_t *mp;
11208 u8 sw_if_index_set = 0;
11209 u8 enable_disable = 1;
11212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11214 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11215 sw_if_index_set = 1;
11216 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11217 sw_if_index_set = 1;
11218 else if (unformat (i, "enable"))
11219 enable_disable = 1;
11220 else if (unformat (i, "disable"))
11221 enable_disable = 0;
11226 if (sw_if_index_set == 0)
11228 errmsg ("missing interface name or sw_if_index");
11232 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11234 mp->sw_if_index = ntohl (sw_if_index);
11235 mp->enable_disable = enable_disable;
11243 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11245 unformat_input_t *i = vam->input;
11246 vl_api_l2tpv3_set_lookup_key_t *mp;
11250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11252 if (unformat (i, "lookup_v6_src"))
11253 key = L2T_LOOKUP_SRC_ADDRESS;
11254 else if (unformat (i, "lookup_v6_dst"))
11255 key = L2T_LOOKUP_DST_ADDRESS;
11256 else if (unformat (i, "lookup_session_id"))
11257 key = L2T_LOOKUP_SESSION_ID;
11262 if (key == (u8) ~ 0)
11264 errmsg ("l2tp session lookup key unset");
11268 M (L2TPV3_SET_LOOKUP_KEY, mp);
11277 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11278 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11280 vat_main_t *vam = &vat_main;
11282 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11283 format_ip6_address, mp->our_address,
11284 format_ip6_address, mp->client_address,
11285 clib_net_to_host_u32 (mp->sw_if_index));
11288 " local cookies %016llx %016llx remote cookie %016llx",
11289 clib_net_to_host_u64 (mp->local_cookie[0]),
11290 clib_net_to_host_u64 (mp->local_cookie[1]),
11291 clib_net_to_host_u64 (mp->remote_cookie));
11293 print (vam->ofp, " local session-id %d remote session-id %d",
11294 clib_net_to_host_u32 (mp->local_session_id),
11295 clib_net_to_host_u32 (mp->remote_session_id));
11297 print (vam->ofp, " l2 specific sublayer %s\n",
11298 mp->l2_sublayer_present ? "preset" : "absent");
11302 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11303 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11305 vat_main_t *vam = &vat_main;
11306 vat_json_node_t *node = NULL;
11307 struct in6_addr addr;
11309 if (VAT_JSON_ARRAY != vam->json_tree.type)
11311 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11312 vat_json_init_array (&vam->json_tree);
11314 node = vat_json_array_add (&vam->json_tree);
11316 vat_json_init_object (node);
11318 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11319 vat_json_object_add_ip6 (node, "our_address", addr);
11320 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11321 vat_json_object_add_ip6 (node, "client_address", addr);
11323 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11324 vat_json_init_array (lc);
11325 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11326 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11327 vat_json_object_add_uint (node, "remote_cookie",
11328 clib_net_to_host_u64 (mp->remote_cookie));
11330 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11331 vat_json_object_add_uint (node, "local_session_id",
11332 clib_net_to_host_u32 (mp->local_session_id));
11333 vat_json_object_add_uint (node, "remote_session_id",
11334 clib_net_to_host_u32 (mp->remote_session_id));
11335 vat_json_object_add_string_copy (node, "l2_sublayer",
11336 mp->l2_sublayer_present ? (u8 *) "present"
11337 : (u8 *) "absent");
11341 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11343 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11344 vl_api_control_ping_t *mp_ping;
11347 /* Get list of l2tpv3-tunnel interfaces */
11348 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11351 /* Use a control ping for synchronization */
11352 MPING (CONTROL_PING, mp_ping);
11360 static void vl_api_sw_interface_tap_v2_details_t_handler
11361 (vl_api_sw_interface_tap_v2_details_t * mp)
11363 vat_main_t *vam = &vat_main;
11366 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11367 mp->host_ip4_prefix.len);
11369 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11370 mp->host_ip6_prefix.len);
11373 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11374 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11375 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11376 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11377 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11383 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11384 (vl_api_sw_interface_tap_v2_details_t * mp)
11386 vat_main_t *vam = &vat_main;
11387 vat_json_node_t *node = NULL;
11389 if (VAT_JSON_ARRAY != vam->json_tree.type)
11391 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11392 vat_json_init_array (&vam->json_tree);
11394 node = vat_json_array_add (&vam->json_tree);
11396 vat_json_init_object (node);
11397 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11398 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11399 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11400 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11401 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11402 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11403 vat_json_object_add_string_copy (node, "host_mac_addr",
11404 format (0, "%U", format_ethernet_address,
11405 &mp->host_mac_addr));
11406 vat_json_object_add_string_copy (node, "host_namespace",
11407 mp->host_namespace);
11408 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11409 vat_json_object_add_string_copy (node, "host_ip4_addr",
11410 format (0, "%U/%d", format_ip4_address,
11411 mp->host_ip4_prefix.address,
11412 mp->host_ip4_prefix.len));
11413 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11414 format (0, "%U/%d", format_ip6_address,
11415 mp->host_ip6_prefix.address,
11416 mp->host_ip6_prefix.len));
11421 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11423 vl_api_sw_interface_tap_v2_dump_t *mp;
11424 vl_api_control_ping_t *mp_ping;
11428 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11429 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11430 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11433 /* Get list of tap interfaces */
11434 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11437 /* Use a control ping for synchronization */
11438 MPING (CONTROL_PING, mp_ping);
11445 static void vl_api_sw_interface_virtio_pci_details_t_handler
11446 (vl_api_sw_interface_virtio_pci_details_t * mp)
11448 vat_main_t *vam = &vat_main;
11463 addr.domain = ntohs (mp->pci_addr.domain);
11464 addr.bus = mp->pci_addr.bus;
11465 addr.slot = mp->pci_addr.slot;
11466 addr.function = mp->pci_addr.function;
11468 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11469 addr.slot, addr.function);
11472 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11473 pci_addr, ntohl (mp->sw_if_index),
11474 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11475 format_ethernet_address, mp->mac_addr,
11476 clib_net_to_host_u64 (mp->features));
11477 vec_free (pci_addr);
11480 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11481 (vl_api_sw_interface_virtio_pci_details_t * mp)
11483 vat_main_t *vam = &vat_main;
11484 vat_json_node_t *node = NULL;
11485 vlib_pci_addr_t pci_addr;
11487 if (VAT_JSON_ARRAY != vam->json_tree.type)
11489 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11490 vat_json_init_array (&vam->json_tree);
11492 node = vat_json_array_add (&vam->json_tree);
11494 pci_addr.domain = ntohs (mp->pci_addr.domain);
11495 pci_addr.bus = mp->pci_addr.bus;
11496 pci_addr.slot = mp->pci_addr.slot;
11497 pci_addr.function = mp->pci_addr.function;
11499 vat_json_init_object (node);
11500 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11501 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11502 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11503 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11504 vat_json_object_add_uint (node, "features",
11505 clib_net_to_host_u64 (mp->features));
11506 vat_json_object_add_string_copy (node, "mac_addr",
11507 format (0, "%U", format_ethernet_address,
11512 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11514 vl_api_sw_interface_virtio_pci_dump_t *mp;
11515 vl_api_control_ping_t *mp_ping;
11519 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11520 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11521 "mac_addr", "features");
11523 /* Get list of tap interfaces */
11524 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11527 /* Use a control ping for synchronization */
11528 MPING (CONTROL_PING, mp_ping);
11536 api_vxlan_offload_rx (vat_main_t * vam)
11538 unformat_input_t *line_input = vam->input;
11539 vl_api_vxlan_offload_rx_t *mp;
11540 u32 hw_if_index = ~0, rx_if_index = ~0;
11544 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11546 if (unformat (line_input, "del"))
11548 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11551 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11553 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11556 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11560 errmsg ("parse error '%U'", format_unformat_error, line_input);
11565 if (hw_if_index == ~0)
11567 errmsg ("no hw interface");
11571 if (rx_if_index == ~0)
11573 errmsg ("no rx tunnel");
11577 M (VXLAN_OFFLOAD_RX, mp);
11579 mp->hw_if_index = ntohl (hw_if_index);
11580 mp->sw_if_index = ntohl (rx_if_index);
11581 mp->enable = is_add;
11588 static uword unformat_vxlan_decap_next
11589 (unformat_input_t * input, va_list * args)
11591 u32 *result = va_arg (*args, u32 *);
11594 if (unformat (input, "l2"))
11595 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11596 else if (unformat (input, "%d", &tmp))
11604 api_vxlan_add_del_tunnel (vat_main_t * vam)
11606 unformat_input_t *line_input = vam->input;
11607 vl_api_vxlan_add_del_tunnel_t *mp;
11608 ip46_address_t src, dst;
11610 u8 ipv4_set = 0, ipv6_set = 0;
11615 u32 mcast_sw_if_index = ~0;
11616 u32 encap_vrf_id = 0;
11617 u32 decap_next_index = ~0;
11621 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11622 clib_memset (&src, 0, sizeof src);
11623 clib_memset (&dst, 0, sizeof dst);
11625 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11627 if (unformat (line_input, "del"))
11629 else if (unformat (line_input, "instance %d", &instance))
11632 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11638 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11644 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11650 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11655 else if (unformat (line_input, "group %U %U",
11656 unformat_ip4_address, &dst.ip4,
11657 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11659 grp_set = dst_set = 1;
11662 else if (unformat (line_input, "group %U",
11663 unformat_ip4_address, &dst.ip4))
11665 grp_set = dst_set = 1;
11668 else if (unformat (line_input, "group %U %U",
11669 unformat_ip6_address, &dst.ip6,
11670 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11672 grp_set = dst_set = 1;
11675 else if (unformat (line_input, "group %U",
11676 unformat_ip6_address, &dst.ip6))
11678 grp_set = dst_set = 1;
11682 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11684 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11686 else if (unformat (line_input, "decap-next %U",
11687 unformat_vxlan_decap_next, &decap_next_index))
11689 else if (unformat (line_input, "vni %d", &vni))
11693 errmsg ("parse error '%U'", format_unformat_error, line_input);
11700 errmsg ("tunnel src address not specified");
11705 errmsg ("tunnel dst address not specified");
11709 if (grp_set && !ip46_address_is_multicast (&dst))
11711 errmsg ("tunnel group address not multicast");
11714 if (grp_set && mcast_sw_if_index == ~0)
11716 errmsg ("tunnel nonexistent multicast device");
11719 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11721 errmsg ("tunnel dst address must be unicast");
11726 if (ipv4_set && ipv6_set)
11728 errmsg ("both IPv4 and IPv6 addresses specified");
11732 if ((vni == 0) || (vni >> 24))
11734 errmsg ("vni not specified or out of range");
11738 M (VXLAN_ADD_DEL_TUNNEL, mp);
11742 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11743 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11747 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11748 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11750 mp->src_address.af = ipv6_set;
11751 mp->dst_address.af = ipv6_set;
11753 mp->instance = htonl (instance);
11754 mp->encap_vrf_id = ntohl (encap_vrf_id);
11755 mp->decap_next_index = ntohl (decap_next_index);
11756 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11757 mp->vni = ntohl (vni);
11758 mp->is_add = is_add;
11765 static void vl_api_vxlan_tunnel_details_t_handler
11766 (vl_api_vxlan_tunnel_details_t * mp)
11768 vat_main_t *vam = &vat_main;
11769 ip46_address_t src =
11770 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11771 ip46_address_t dst =
11772 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11774 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11775 ntohl (mp->sw_if_index),
11776 ntohl (mp->instance),
11777 format_ip46_address, &src, IP46_TYPE_ANY,
11778 format_ip46_address, &dst, IP46_TYPE_ANY,
11779 ntohl (mp->encap_vrf_id),
11780 ntohl (mp->decap_next_index), ntohl (mp->vni),
11781 ntohl (mp->mcast_sw_if_index));
11784 static void vl_api_vxlan_tunnel_details_t_handler_json
11785 (vl_api_vxlan_tunnel_details_t * mp)
11787 vat_main_t *vam = &vat_main;
11788 vat_json_node_t *node = NULL;
11790 if (VAT_JSON_ARRAY != vam->json_tree.type)
11792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11793 vat_json_init_array (&vam->json_tree);
11795 node = vat_json_array_add (&vam->json_tree);
11797 vat_json_init_object (node);
11798 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11800 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11802 if (mp->src_address.af)
11804 struct in6_addr ip6;
11806 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11807 vat_json_object_add_ip6 (node, "src_address", ip6);
11808 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11809 vat_json_object_add_ip6 (node, "dst_address", ip6);
11813 struct in_addr ip4;
11815 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11816 vat_json_object_add_ip4 (node, "src_address", ip4);
11817 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11818 vat_json_object_add_ip4 (node, "dst_address", ip4);
11820 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11821 vat_json_object_add_uint (node, "decap_next_index",
11822 ntohl (mp->decap_next_index));
11823 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11824 vat_json_object_add_uint (node, "mcast_sw_if_index",
11825 ntohl (mp->mcast_sw_if_index));
11829 api_vxlan_tunnel_dump (vat_main_t * vam)
11831 unformat_input_t *i = vam->input;
11832 vl_api_vxlan_tunnel_dump_t *mp;
11833 vl_api_control_ping_t *mp_ping;
11835 u8 sw_if_index_set = 0;
11838 /* Parse args required to build the message */
11839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11841 if (unformat (i, "sw_if_index %d", &sw_if_index))
11842 sw_if_index_set = 1;
11847 if (sw_if_index_set == 0)
11852 if (!vam->json_output)
11854 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11855 "sw_if_index", "instance", "src_address", "dst_address",
11856 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11859 /* Get list of vxlan-tunnel interfaces */
11860 M (VXLAN_TUNNEL_DUMP, mp);
11862 mp->sw_if_index = htonl (sw_if_index);
11866 /* Use a control ping for synchronization */
11867 MPING (CONTROL_PING, mp_ping);
11874 static uword unformat_geneve_decap_next
11875 (unformat_input_t * input, va_list * args)
11877 u32 *result = va_arg (*args, u32 *);
11880 if (unformat (input, "l2"))
11881 *result = GENEVE_INPUT_NEXT_L2_INPUT;
11882 else if (unformat (input, "%d", &tmp))
11890 api_geneve_add_del_tunnel (vat_main_t * vam)
11892 unformat_input_t *line_input = vam->input;
11893 vl_api_geneve_add_del_tunnel_t *mp;
11894 ip46_address_t src, dst;
11896 u8 ipv4_set = 0, ipv6_set = 0;
11900 u32 mcast_sw_if_index = ~0;
11901 u32 encap_vrf_id = 0;
11902 u32 decap_next_index = ~0;
11906 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11907 clib_memset (&src, 0, sizeof src);
11908 clib_memset (&dst, 0, sizeof dst);
11910 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11912 if (unformat (line_input, "del"))
11915 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11921 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11927 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11933 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11938 else if (unformat (line_input, "group %U %U",
11939 unformat_ip4_address, &dst.ip4,
11940 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11942 grp_set = dst_set = 1;
11945 else if (unformat (line_input, "group %U",
11946 unformat_ip4_address, &dst.ip4))
11948 grp_set = dst_set = 1;
11951 else if (unformat (line_input, "group %U %U",
11952 unformat_ip6_address, &dst.ip6,
11953 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11955 grp_set = dst_set = 1;
11958 else if (unformat (line_input, "group %U",
11959 unformat_ip6_address, &dst.ip6))
11961 grp_set = dst_set = 1;
11965 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11967 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11969 else if (unformat (line_input, "decap-next %U",
11970 unformat_geneve_decap_next, &decap_next_index))
11972 else if (unformat (line_input, "vni %d", &vni))
11976 errmsg ("parse error '%U'", format_unformat_error, line_input);
11983 errmsg ("tunnel src address not specified");
11988 errmsg ("tunnel dst address not specified");
11992 if (grp_set && !ip46_address_is_multicast (&dst))
11994 errmsg ("tunnel group address not multicast");
11997 if (grp_set && mcast_sw_if_index == ~0)
11999 errmsg ("tunnel nonexistent multicast device");
12002 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12004 errmsg ("tunnel dst address must be unicast");
12009 if (ipv4_set && ipv6_set)
12011 errmsg ("both IPv4 and IPv6 addresses specified");
12015 if ((vni == 0) || (vni >> 24))
12017 errmsg ("vni not specified or out of range");
12021 M (GENEVE_ADD_DEL_TUNNEL, mp);
12025 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12026 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12030 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12031 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12033 mp->encap_vrf_id = ntohl (encap_vrf_id);
12034 mp->decap_next_index = ntohl (decap_next_index);
12035 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12036 mp->vni = ntohl (vni);
12037 mp->is_add = is_add;
12044 static void vl_api_geneve_tunnel_details_t_handler
12045 (vl_api_geneve_tunnel_details_t * mp)
12047 vat_main_t *vam = &vat_main;
12048 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12049 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12051 if (mp->src_address.af == ADDRESS_IP6)
12053 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12054 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12058 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12059 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12062 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12063 ntohl (mp->sw_if_index),
12064 format_ip46_address, &src, IP46_TYPE_ANY,
12065 format_ip46_address, &dst, IP46_TYPE_ANY,
12066 ntohl (mp->encap_vrf_id),
12067 ntohl (mp->decap_next_index), ntohl (mp->vni),
12068 ntohl (mp->mcast_sw_if_index));
12071 static void vl_api_geneve_tunnel_details_t_handler_json
12072 (vl_api_geneve_tunnel_details_t * mp)
12074 vat_main_t *vam = &vat_main;
12075 vat_json_node_t *node = NULL;
12078 if (VAT_JSON_ARRAY != vam->json_tree.type)
12080 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12081 vat_json_init_array (&vam->json_tree);
12083 node = vat_json_array_add (&vam->json_tree);
12085 vat_json_init_object (node);
12086 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12087 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12090 struct in6_addr ip6;
12092 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12093 vat_json_object_add_ip6 (node, "src_address", ip6);
12094 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12095 vat_json_object_add_ip6 (node, "dst_address", ip6);
12099 struct in_addr ip4;
12101 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12102 vat_json_object_add_ip4 (node, "src_address", ip4);
12103 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12104 vat_json_object_add_ip4 (node, "dst_address", ip4);
12106 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12107 vat_json_object_add_uint (node, "decap_next_index",
12108 ntohl (mp->decap_next_index));
12109 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12110 vat_json_object_add_uint (node, "mcast_sw_if_index",
12111 ntohl (mp->mcast_sw_if_index));
12115 api_geneve_tunnel_dump (vat_main_t * vam)
12117 unformat_input_t *i = vam->input;
12118 vl_api_geneve_tunnel_dump_t *mp;
12119 vl_api_control_ping_t *mp_ping;
12121 u8 sw_if_index_set = 0;
12124 /* Parse args required to build the message */
12125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12127 if (unformat (i, "sw_if_index %d", &sw_if_index))
12128 sw_if_index_set = 1;
12133 if (sw_if_index_set == 0)
12138 if (!vam->json_output)
12140 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12141 "sw_if_index", "local_address", "remote_address",
12142 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12145 /* Get list of geneve-tunnel interfaces */
12146 M (GENEVE_TUNNEL_DUMP, mp);
12148 mp->sw_if_index = htonl (sw_if_index);
12152 /* Use a control ping for synchronization */
12153 M (CONTROL_PING, mp_ping);
12161 api_gre_tunnel_add_del (vat_main_t * vam)
12163 unformat_input_t *line_input = vam->input;
12164 vl_api_address_t src = { }, dst =
12167 vl_api_gre_tunnel_add_del_t *mp;
12168 vl_api_gre_tunnel_type_t t_type;
12172 u32 outer_table_id = 0;
12173 u32 session_id = 0;
12177 t_type = GRE_API_TUNNEL_TYPE_L3;
12179 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12181 if (unformat (line_input, "del"))
12183 else if (unformat (line_input, "instance %d", &instance))
12185 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12189 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12193 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12195 else if (unformat (line_input, "teb"))
12196 t_type = GRE_API_TUNNEL_TYPE_TEB;
12197 else if (unformat (line_input, "erspan %d", &session_id))
12198 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12201 errmsg ("parse error '%U'", format_unformat_error, line_input);
12208 errmsg ("tunnel src address not specified");
12213 errmsg ("tunnel dst address not specified");
12217 M (GRE_TUNNEL_ADD_DEL, mp);
12219 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12220 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12222 mp->tunnel.instance = htonl (instance);
12223 mp->tunnel.outer_table_id = htonl (outer_table_id);
12224 mp->is_add = is_add;
12225 mp->tunnel.session_id = htons ((u16) session_id);
12226 mp->tunnel.type = htonl (t_type);
12233 static void vl_api_gre_tunnel_details_t_handler
12234 (vl_api_gre_tunnel_details_t * mp)
12236 vat_main_t *vam = &vat_main;
12238 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12239 ntohl (mp->tunnel.sw_if_index),
12240 ntohl (mp->tunnel.instance),
12241 format_vl_api_address, &mp->tunnel.src,
12242 format_vl_api_address, &mp->tunnel.dst,
12243 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12244 ntohl (mp->tunnel.session_id));
12247 static void vl_api_gre_tunnel_details_t_handler_json
12248 (vl_api_gre_tunnel_details_t * mp)
12250 vat_main_t *vam = &vat_main;
12251 vat_json_node_t *node = NULL;
12253 if (VAT_JSON_ARRAY != vam->json_tree.type)
12255 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12256 vat_json_init_array (&vam->json_tree);
12258 node = vat_json_array_add (&vam->json_tree);
12260 vat_json_init_object (node);
12261 vat_json_object_add_uint (node, "sw_if_index",
12262 ntohl (mp->tunnel.sw_if_index));
12263 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12265 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12266 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12267 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12268 vat_json_object_add_uint (node, "outer_table_id",
12269 ntohl (mp->tunnel.outer_table_id));
12270 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12274 api_gre_tunnel_dump (vat_main_t * vam)
12276 unformat_input_t *i = vam->input;
12277 vl_api_gre_tunnel_dump_t *mp;
12278 vl_api_control_ping_t *mp_ping;
12280 u8 sw_if_index_set = 0;
12283 /* Parse args required to build the message */
12284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12286 if (unformat (i, "sw_if_index %d", &sw_if_index))
12287 sw_if_index_set = 1;
12292 if (sw_if_index_set == 0)
12297 if (!vam->json_output)
12299 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12300 "sw_if_index", "instance", "src_address", "dst_address",
12301 "tunnel_type", "outer_fib_id", "session_id");
12304 /* Get list of gre-tunnel interfaces */
12305 M (GRE_TUNNEL_DUMP, mp);
12307 mp->sw_if_index = htonl (sw_if_index);
12311 /* Use a control ping for synchronization */
12312 MPING (CONTROL_PING, mp_ping);
12320 api_l2_fib_clear_table (vat_main_t * vam)
12322 // unformat_input_t * i = vam->input;
12323 vl_api_l2_fib_clear_table_t *mp;
12326 M (L2_FIB_CLEAR_TABLE, mp);
12334 api_l2_interface_efp_filter (vat_main_t * vam)
12336 unformat_input_t *i = vam->input;
12337 vl_api_l2_interface_efp_filter_t *mp;
12340 u8 sw_if_index_set = 0;
12343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12345 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12346 sw_if_index_set = 1;
12347 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12348 sw_if_index_set = 1;
12349 else if (unformat (i, "enable"))
12351 else if (unformat (i, "disable"))
12355 clib_warning ("parse error '%U'", format_unformat_error, i);
12360 if (sw_if_index_set == 0)
12362 errmsg ("missing sw_if_index");
12366 M (L2_INTERFACE_EFP_FILTER, mp);
12368 mp->sw_if_index = ntohl (sw_if_index);
12369 mp->enable_disable = enable;
12376 #define foreach_vtr_op \
12377 _("disable", L2_VTR_DISABLED) \
12378 _("push-1", L2_VTR_PUSH_1) \
12379 _("push-2", L2_VTR_PUSH_2) \
12380 _("pop-1", L2_VTR_POP_1) \
12381 _("pop-2", L2_VTR_POP_2) \
12382 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12383 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12384 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12385 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12388 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12390 unformat_input_t *i = vam->input;
12391 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12393 u8 sw_if_index_set = 0;
12396 u32 push_dot1q = 1;
12401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12403 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12404 sw_if_index_set = 1;
12405 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12406 sw_if_index_set = 1;
12407 else if (unformat (i, "vtr_op %d", &vtr_op))
12409 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12412 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12414 else if (unformat (i, "tag1 %d", &tag1))
12416 else if (unformat (i, "tag2 %d", &tag2))
12420 clib_warning ("parse error '%U'", format_unformat_error, i);
12425 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12427 errmsg ("missing vtr operation or sw_if_index");
12431 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12432 mp->sw_if_index = ntohl (sw_if_index);
12433 mp->vtr_op = ntohl (vtr_op);
12434 mp->push_dot1q = ntohl (push_dot1q);
12435 mp->tag1 = ntohl (tag1);
12436 mp->tag2 = ntohl (tag2);
12444 api_create_vhost_user_if (vat_main_t * vam)
12446 unformat_input_t *i = vam->input;
12447 vl_api_create_vhost_user_if_t *mp;
12450 u8 file_name_set = 0;
12451 u32 custom_dev_instance = ~0;
12453 u8 use_custom_mac = 0;
12454 u8 disable_mrg_rxbuf = 0;
12455 u8 disable_indirect_desc = 0;
12458 u8 enable_packed = 0;
12461 /* Shut up coverity */
12462 clib_memset (hwaddr, 0, sizeof (hwaddr));
12464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12466 if (unformat (i, "socket %s", &file_name))
12470 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12472 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12473 use_custom_mac = 1;
12474 else if (unformat (i, "server"))
12476 else if (unformat (i, "disable_mrg_rxbuf"))
12477 disable_mrg_rxbuf = 1;
12478 else if (unformat (i, "disable_indirect_desc"))
12479 disable_indirect_desc = 1;
12480 else if (unformat (i, "gso"))
12482 else if (unformat (i, "packed"))
12484 else if (unformat (i, "tag %s", &tag))
12490 if (file_name_set == 0)
12492 errmsg ("missing socket file name");
12496 if (vec_len (file_name) > 255)
12498 errmsg ("socket file name too long");
12501 vec_add1 (file_name, 0);
12503 M (CREATE_VHOST_USER_IF, mp);
12505 mp->is_server = is_server;
12506 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12507 mp->disable_indirect_desc = disable_indirect_desc;
12508 mp->enable_gso = enable_gso;
12509 mp->enable_packed = enable_packed;
12510 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12511 vec_free (file_name);
12512 if (custom_dev_instance != ~0)
12515 mp->custom_dev_instance = ntohl (custom_dev_instance);
12518 mp->use_custom_mac = use_custom_mac;
12519 clib_memcpy (mp->mac_address, hwaddr, 6);
12521 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12530 api_modify_vhost_user_if (vat_main_t * vam)
12532 unformat_input_t *i = vam->input;
12533 vl_api_modify_vhost_user_if_t *mp;
12536 u8 file_name_set = 0;
12537 u32 custom_dev_instance = ~0;
12538 u8 sw_if_index_set = 0;
12539 u32 sw_if_index = (u32) ~ 0;
12541 u8 enable_packed = 0;
12544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12546 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12547 sw_if_index_set = 1;
12548 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12549 sw_if_index_set = 1;
12550 else if (unformat (i, "socket %s", &file_name))
12554 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12556 else if (unformat (i, "server"))
12558 else if (unformat (i, "gso"))
12560 else if (unformat (i, "packed"))
12566 if (sw_if_index_set == 0)
12568 errmsg ("missing sw_if_index or interface name");
12572 if (file_name_set == 0)
12574 errmsg ("missing socket file name");
12578 if (vec_len (file_name) > 255)
12580 errmsg ("socket file name too long");
12583 vec_add1 (file_name, 0);
12585 M (MODIFY_VHOST_USER_IF, mp);
12587 mp->sw_if_index = ntohl (sw_if_index);
12588 mp->is_server = is_server;
12589 mp->enable_gso = enable_gso;
12590 mp->enable_packed = enable_packed;
12591 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12592 vec_free (file_name);
12593 if (custom_dev_instance != ~0)
12596 mp->custom_dev_instance = ntohl (custom_dev_instance);
12605 api_delete_vhost_user_if (vat_main_t * vam)
12607 unformat_input_t *i = vam->input;
12608 vl_api_delete_vhost_user_if_t *mp;
12609 u32 sw_if_index = ~0;
12610 u8 sw_if_index_set = 0;
12613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12615 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12616 sw_if_index_set = 1;
12617 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12618 sw_if_index_set = 1;
12623 if (sw_if_index_set == 0)
12625 errmsg ("missing sw_if_index or interface name");
12630 M (DELETE_VHOST_USER_IF, mp);
12632 mp->sw_if_index = ntohl (sw_if_index);
12639 static void vl_api_sw_interface_vhost_user_details_t_handler
12640 (vl_api_sw_interface_vhost_user_details_t * mp)
12642 vat_main_t *vam = &vat_main;
12646 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12647 clib_net_to_host_u32
12648 (mp->features_last_32) <<
12651 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12652 (char *) mp->interface_name,
12653 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12654 features, mp->is_server,
12655 ntohl (mp->num_regions), (char *) mp->sock_filename);
12656 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12659 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12660 (vl_api_sw_interface_vhost_user_details_t * mp)
12662 vat_main_t *vam = &vat_main;
12663 vat_json_node_t *node = NULL;
12665 if (VAT_JSON_ARRAY != vam->json_tree.type)
12667 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12668 vat_json_init_array (&vam->json_tree);
12670 node = vat_json_array_add (&vam->json_tree);
12672 vat_json_init_object (node);
12673 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12674 vat_json_object_add_string_copy (node, "interface_name",
12675 mp->interface_name);
12676 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12677 ntohl (mp->virtio_net_hdr_sz));
12678 vat_json_object_add_uint (node, "features_first_32",
12679 clib_net_to_host_u32 (mp->features_first_32));
12680 vat_json_object_add_uint (node, "features_last_32",
12681 clib_net_to_host_u32 (mp->features_last_32));
12682 vat_json_object_add_uint (node, "is_server", mp->is_server);
12683 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12684 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12685 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12689 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12691 unformat_input_t *i = vam->input;
12692 vl_api_sw_interface_vhost_user_dump_t *mp;
12693 vl_api_control_ping_t *mp_ping;
12695 u32 sw_if_index = ~0;
12697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12699 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12701 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12708 "Interface name idx hdr_sz features server regions filename");
12710 /* Get list of vhost-user interfaces */
12711 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12712 mp->sw_if_index = ntohl (sw_if_index);
12715 /* Use a control ping for synchronization */
12716 MPING (CONTROL_PING, mp_ping);
12724 api_show_version (vat_main_t * vam)
12726 vl_api_show_version_t *mp;
12729 M (SHOW_VERSION, mp);
12738 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12740 unformat_input_t *line_input = vam->input;
12741 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12742 ip46_address_t local, remote;
12747 u32 mcast_sw_if_index = ~0;
12748 u32 encap_vrf_id = 0;
12749 u32 decap_vrf_id = 0;
12755 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12757 if (unformat (line_input, "del"))
12759 else if (unformat (line_input, "local %U",
12760 unformat_ip46_address, &local))
12764 else if (unformat (line_input, "remote %U",
12765 unformat_ip46_address, &remote))
12769 else if (unformat (line_input, "group %U %U",
12770 unformat_ip46_address, &remote,
12771 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12773 grp_set = remote_set = 1;
12775 else if (unformat (line_input, "group %U",
12776 unformat_ip46_address, &remote))
12778 grp_set = remote_set = 1;
12781 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12783 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12785 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12787 else if (unformat (line_input, "vni %d", &vni))
12789 else if (unformat (line_input, "next-ip4"))
12791 else if (unformat (line_input, "next-ip6"))
12793 else if (unformat (line_input, "next-ethernet"))
12795 else if (unformat (line_input, "next-nsh"))
12799 errmsg ("parse error '%U'", format_unformat_error, line_input);
12804 if (local_set == 0)
12806 errmsg ("tunnel local address not specified");
12809 if (remote_set == 0)
12811 errmsg ("tunnel remote address not specified");
12814 if (grp_set && mcast_sw_if_index == ~0)
12816 errmsg ("tunnel nonexistent multicast device");
12819 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12821 errmsg ("both IPv4 and IPv6 addresses specified");
12827 errmsg ("vni not specified");
12831 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12833 ip_address_encode (&local,
12834 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12835 IP46_TYPE_IP6, &mp->local);
12836 ip_address_encode (&remote,
12837 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12838 IP46_TYPE_IP6, &mp->remote);
12840 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12841 mp->encap_vrf_id = ntohl (encap_vrf_id);
12842 mp->decap_vrf_id = ntohl (decap_vrf_id);
12843 mp->protocol = protocol;
12844 mp->vni = ntohl (vni);
12845 mp->is_add = is_add;
12852 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12853 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12855 vat_main_t *vam = &vat_main;
12856 ip46_address_t local, remote;
12858 ip_address_decode (&mp->local, &local);
12859 ip_address_decode (&mp->remote, &remote);
12861 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12862 ntohl (mp->sw_if_index),
12863 format_ip46_address, &local, IP46_TYPE_ANY,
12864 format_ip46_address, &remote, IP46_TYPE_ANY,
12865 ntohl (mp->vni), mp->protocol,
12866 ntohl (mp->mcast_sw_if_index),
12867 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12871 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12872 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12874 vat_main_t *vam = &vat_main;
12875 vat_json_node_t *node = NULL;
12876 struct in_addr ip4;
12877 struct in6_addr ip6;
12878 ip46_address_t local, remote;
12880 ip_address_decode (&mp->local, &local);
12881 ip_address_decode (&mp->remote, &remote);
12883 if (VAT_JSON_ARRAY != vam->json_tree.type)
12885 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12886 vat_json_init_array (&vam->json_tree);
12888 node = vat_json_array_add (&vam->json_tree);
12890 vat_json_init_object (node);
12891 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12892 if (ip46_address_is_ip4 (&local))
12894 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12895 vat_json_object_add_ip4 (node, "local", ip4);
12896 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12897 vat_json_object_add_ip4 (node, "remote", ip4);
12901 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12902 vat_json_object_add_ip6 (node, "local", ip6);
12903 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12904 vat_json_object_add_ip6 (node, "remote", ip6);
12906 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12907 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12908 vat_json_object_add_uint (node, "mcast_sw_if_index",
12909 ntohl (mp->mcast_sw_if_index));
12910 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12911 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12912 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12916 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12918 unformat_input_t *i = vam->input;
12919 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12920 vl_api_control_ping_t *mp_ping;
12922 u8 sw_if_index_set = 0;
12925 /* Parse args required to build the message */
12926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12928 if (unformat (i, "sw_if_index %d", &sw_if_index))
12929 sw_if_index_set = 1;
12934 if (sw_if_index_set == 0)
12939 if (!vam->json_output)
12941 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12942 "sw_if_index", "local", "remote", "vni",
12943 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12946 /* Get list of vxlan-tunnel interfaces */
12947 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12949 mp->sw_if_index = htonl (sw_if_index);
12953 /* Use a control ping for synchronization */
12954 MPING (CONTROL_PING, mp_ping);
12961 static void vl_api_l2_fib_table_details_t_handler
12962 (vl_api_l2_fib_table_details_t * mp)
12964 vat_main_t *vam = &vat_main;
12966 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12968 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12969 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12973 static void vl_api_l2_fib_table_details_t_handler_json
12974 (vl_api_l2_fib_table_details_t * mp)
12976 vat_main_t *vam = &vat_main;
12977 vat_json_node_t *node = NULL;
12979 if (VAT_JSON_ARRAY != vam->json_tree.type)
12981 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12982 vat_json_init_array (&vam->json_tree);
12984 node = vat_json_array_add (&vam->json_tree);
12986 vat_json_init_object (node);
12987 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12988 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12989 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12990 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12991 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12992 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12996 api_l2_fib_table_dump (vat_main_t * vam)
12998 unformat_input_t *i = vam->input;
12999 vl_api_l2_fib_table_dump_t *mp;
13000 vl_api_control_ping_t *mp_ping;
13005 /* Parse args required to build the message */
13006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13008 if (unformat (i, "bd_id %d", &bd_id))
13014 if (bd_id_set == 0)
13016 errmsg ("missing bridge domain");
13020 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13022 /* Get list of l2 fib entries */
13023 M (L2_FIB_TABLE_DUMP, mp);
13025 mp->bd_id = ntohl (bd_id);
13028 /* Use a control ping for synchronization */
13029 MPING (CONTROL_PING, mp_ping);
13038 api_interface_name_renumber (vat_main_t * vam)
13040 unformat_input_t *line_input = vam->input;
13041 vl_api_interface_name_renumber_t *mp;
13042 u32 sw_if_index = ~0;
13043 u32 new_show_dev_instance = ~0;
13046 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13048 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13051 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13053 else if (unformat (line_input, "new_show_dev_instance %d",
13054 &new_show_dev_instance))
13060 if (sw_if_index == ~0)
13062 errmsg ("missing interface name or sw_if_index");
13066 if (new_show_dev_instance == ~0)
13068 errmsg ("missing new_show_dev_instance");
13072 M (INTERFACE_NAME_RENUMBER, mp);
13074 mp->sw_if_index = ntohl (sw_if_index);
13075 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13083 api_want_l2_macs_events (vat_main_t * vam)
13085 unformat_input_t *line_input = vam->input;
13086 vl_api_want_l2_macs_events_t *mp;
13087 u8 enable_disable = 1;
13088 u32 scan_delay = 0;
13089 u32 max_macs_in_event = 0;
13090 u32 learn_limit = 0;
13093 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13095 if (unformat (line_input, "learn-limit %d", &learn_limit))
13097 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13099 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13101 else if (unformat (line_input, "disable"))
13102 enable_disable = 0;
13107 M (WANT_L2_MACS_EVENTS, mp);
13108 mp->enable_disable = enable_disable;
13109 mp->pid = htonl (getpid ());
13110 mp->learn_limit = htonl (learn_limit);
13111 mp->scan_delay = (u8) scan_delay;
13112 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13119 api_input_acl_set_interface (vat_main_t * vam)
13121 unformat_input_t *i = vam->input;
13122 vl_api_input_acl_set_interface_t *mp;
13124 int sw_if_index_set;
13125 u32 ip4_table_index = ~0;
13126 u32 ip6_table_index = ~0;
13127 u32 l2_table_index = ~0;
13131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13133 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13134 sw_if_index_set = 1;
13135 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13136 sw_if_index_set = 1;
13137 else if (unformat (i, "del"))
13139 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13141 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13143 else if (unformat (i, "l2-table %d", &l2_table_index))
13147 clib_warning ("parse error '%U'", format_unformat_error, i);
13152 if (sw_if_index_set == 0)
13154 errmsg ("missing interface name or sw_if_index");
13158 M (INPUT_ACL_SET_INTERFACE, mp);
13160 mp->sw_if_index = ntohl (sw_if_index);
13161 mp->ip4_table_index = ntohl (ip4_table_index);
13162 mp->ip6_table_index = ntohl (ip6_table_index);
13163 mp->l2_table_index = ntohl (l2_table_index);
13164 mp->is_add = is_add;
13172 api_output_acl_set_interface (vat_main_t * vam)
13174 unformat_input_t *i = vam->input;
13175 vl_api_output_acl_set_interface_t *mp;
13177 int sw_if_index_set;
13178 u32 ip4_table_index = ~0;
13179 u32 ip6_table_index = ~0;
13180 u32 l2_table_index = ~0;
13184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13186 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13187 sw_if_index_set = 1;
13188 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13189 sw_if_index_set = 1;
13190 else if (unformat (i, "del"))
13192 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13194 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13196 else if (unformat (i, "l2-table %d", &l2_table_index))
13200 clib_warning ("parse error '%U'", format_unformat_error, i);
13205 if (sw_if_index_set == 0)
13207 errmsg ("missing interface name or sw_if_index");
13211 M (OUTPUT_ACL_SET_INTERFACE, mp);
13213 mp->sw_if_index = ntohl (sw_if_index);
13214 mp->ip4_table_index = ntohl (ip4_table_index);
13215 mp->ip6_table_index = ntohl (ip6_table_index);
13216 mp->l2_table_index = ntohl (l2_table_index);
13217 mp->is_add = is_add;
13225 api_ip_address_dump (vat_main_t * vam)
13227 unformat_input_t *i = vam->input;
13228 vl_api_ip_address_dump_t *mp;
13229 vl_api_control_ping_t *mp_ping;
13230 u32 sw_if_index = ~0;
13231 u8 sw_if_index_set = 0;
13236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13238 if (unformat (i, "sw_if_index %d", &sw_if_index))
13239 sw_if_index_set = 1;
13241 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13242 sw_if_index_set = 1;
13243 else if (unformat (i, "ipv4"))
13245 else if (unformat (i, "ipv6"))
13251 if (ipv4_set && ipv6_set)
13253 errmsg ("ipv4 and ipv6 flags cannot be both set");
13257 if ((!ipv4_set) && (!ipv6_set))
13259 errmsg ("no ipv4 nor ipv6 flag set");
13263 if (sw_if_index_set == 0)
13265 errmsg ("missing interface name or sw_if_index");
13269 vam->current_sw_if_index = sw_if_index;
13270 vam->is_ipv6 = ipv6_set;
13272 M (IP_ADDRESS_DUMP, mp);
13273 mp->sw_if_index = ntohl (sw_if_index);
13274 mp->is_ipv6 = ipv6_set;
13277 /* Use a control ping for synchronization */
13278 MPING (CONTROL_PING, mp_ping);
13286 api_ip_dump (vat_main_t * vam)
13288 vl_api_ip_dump_t *mp;
13289 vl_api_control_ping_t *mp_ping;
13290 unformat_input_t *in = vam->input;
13297 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13299 if (unformat (in, "ipv4"))
13301 else if (unformat (in, "ipv6"))
13307 if (ipv4_set && ipv6_set)
13309 errmsg ("ipv4 and ipv6 flags cannot be both set");
13313 if ((!ipv4_set) && (!ipv6_set))
13315 errmsg ("no ipv4 nor ipv6 flag set");
13319 is_ipv6 = ipv6_set;
13320 vam->is_ipv6 = is_ipv6;
13322 /* free old data */
13323 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13325 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13327 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13330 mp->is_ipv6 = ipv6_set;
13333 /* Use a control ping for synchronization */
13334 MPING (CONTROL_PING, mp_ping);
13342 api_ipsec_spd_add_del (vat_main_t * vam)
13344 unformat_input_t *i = vam->input;
13345 vl_api_ipsec_spd_add_del_t *mp;
13350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13352 if (unformat (i, "spd_id %d", &spd_id))
13354 else if (unformat (i, "del"))
13358 clib_warning ("parse error '%U'", format_unformat_error, i);
13364 errmsg ("spd_id must be set");
13368 M (IPSEC_SPD_ADD_DEL, mp);
13370 mp->spd_id = ntohl (spd_id);
13371 mp->is_add = is_add;
13379 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13381 unformat_input_t *i = vam->input;
13382 vl_api_ipsec_interface_add_del_spd_t *mp;
13384 u8 sw_if_index_set = 0;
13385 u32 spd_id = (u32) ~ 0;
13389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13391 if (unformat (i, "del"))
13393 else if (unformat (i, "spd_id %d", &spd_id))
13396 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13397 sw_if_index_set = 1;
13398 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13399 sw_if_index_set = 1;
13402 clib_warning ("parse error '%U'", format_unformat_error, i);
13408 if (spd_id == (u32) ~ 0)
13410 errmsg ("spd_id must be set");
13414 if (sw_if_index_set == 0)
13416 errmsg ("missing interface name or sw_if_index");
13420 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13422 mp->spd_id = ntohl (spd_id);
13423 mp->sw_if_index = ntohl (sw_if_index);
13424 mp->is_add = is_add;
13432 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13434 unformat_input_t *i = vam->input;
13435 vl_api_ipsec_spd_entry_add_del_t *mp;
13436 u8 is_add = 1, is_outbound = 0;
13437 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13439 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13440 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13441 vl_api_address_t laddr_start = { }, laddr_stop =
13450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13452 if (unformat (i, "del"))
13454 if (unformat (i, "outbound"))
13456 if (unformat (i, "inbound"))
13458 else if (unformat (i, "spd_id %d", &spd_id))
13460 else if (unformat (i, "sa_id %d", &sa_id))
13462 else if (unformat (i, "priority %d", &priority))
13464 else if (unformat (i, "protocol %d", &protocol))
13466 else if (unformat (i, "lport_start %d", &lport_start))
13468 else if (unformat (i, "lport_stop %d", &lport_stop))
13470 else if (unformat (i, "rport_start %d", &rport_start))
13472 else if (unformat (i, "rport_stop %d", &rport_stop))
13474 else if (unformat (i, "laddr_start %U",
13475 unformat_vl_api_address, &laddr_start))
13477 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13480 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13483 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13487 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13489 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13491 clib_warning ("unsupported action: 'resolve'");
13497 clib_warning ("parse error '%U'", format_unformat_error, i);
13503 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13505 mp->is_add = is_add;
13507 mp->entry.spd_id = ntohl (spd_id);
13508 mp->entry.priority = ntohl (priority);
13509 mp->entry.is_outbound = is_outbound;
13511 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13512 sizeof (vl_api_address_t));
13513 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13514 sizeof (vl_api_address_t));
13515 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13516 sizeof (vl_api_address_t));
13517 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13518 sizeof (vl_api_address_t));
13520 mp->entry.protocol = (u8) protocol;
13521 mp->entry.local_port_start = ntohs ((u16) lport_start);
13522 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13523 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13524 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13525 mp->entry.policy = (u8) policy;
13526 mp->entry.sa_id = ntohl (sa_id);
13534 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13536 unformat_input_t *i = vam->input;
13537 vl_api_ipsec_sad_entry_add_del_t *mp;
13538 u32 sad_id = 0, spi = 0;
13539 u8 *ck = 0, *ik = 0;
13542 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13543 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13544 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13545 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13546 vl_api_address_t tun_src, tun_dst;
13549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13551 if (unformat (i, "del"))
13553 else if (unformat (i, "sad_id %d", &sad_id))
13555 else if (unformat (i, "spi %d", &spi))
13557 else if (unformat (i, "esp"))
13558 protocol = IPSEC_API_PROTO_ESP;
13560 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13562 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13563 if (ADDRESS_IP6 == tun_src.af)
13564 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13567 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13569 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13570 if (ADDRESS_IP6 == tun_src.af)
13571 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13574 if (unformat (i, "crypto_alg %U",
13575 unformat_ipsec_api_crypto_alg, &crypto_alg))
13577 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13579 else if (unformat (i, "integ_alg %U",
13580 unformat_ipsec_api_integ_alg, &integ_alg))
13582 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13586 clib_warning ("parse error '%U'", format_unformat_error, i);
13592 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13594 mp->is_add = is_add;
13595 mp->entry.sad_id = ntohl (sad_id);
13596 mp->entry.protocol = protocol;
13597 mp->entry.spi = ntohl (spi);
13598 mp->entry.flags = flags;
13600 mp->entry.crypto_algorithm = crypto_alg;
13601 mp->entry.integrity_algorithm = integ_alg;
13602 mp->entry.crypto_key.length = vec_len (ck);
13603 mp->entry.integrity_key.length = vec_len (ik);
13605 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13606 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13608 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13609 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13612 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13614 clib_memcpy (mp->entry.integrity_key.data, ik,
13615 mp->entry.integrity_key.length);
13617 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13619 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13620 sizeof (mp->entry.tunnel_src));
13621 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13622 sizeof (mp->entry.tunnel_dst));
13631 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13633 unformat_input_t *i = vam->input;
13634 vl_api_ipsec_tunnel_if_add_del_t *mp;
13635 u32 local_spi = 0, remote_spi = 0;
13636 u32 crypto_alg = 0, integ_alg = 0;
13637 u8 *lck = NULL, *rck = NULL;
13638 u8 *lik = NULL, *rik = NULL;
13639 vl_api_address_t local_ip = { 0 };
13640 vl_api_address_t remote_ip = { 0 };
13644 u8 anti_replay = 0;
13650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13652 if (unformat (i, "del"))
13654 else if (unformat (i, "esn"))
13656 else if (unformat (i, "anti-replay"))
13658 else if (unformat (i, "count %d", &count))
13660 else if (unformat (i, "local_spi %d", &local_spi))
13662 else if (unformat (i, "remote_spi %d", &remote_spi))
13665 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13668 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13670 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13673 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13675 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13677 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13681 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13683 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13685 errmsg ("unsupported crypto-alg: '%U'\n",
13686 format_ipsec_crypto_alg, crypto_alg);
13692 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13694 if (integ_alg >= IPSEC_INTEG_N_ALG)
13696 errmsg ("unsupported integ-alg: '%U'\n",
13697 format_ipsec_integ_alg, integ_alg);
13701 else if (unformat (i, "instance %u", &instance))
13705 errmsg ("parse error '%U'\n", format_unformat_error, i);
13712 /* Turn on async mode */
13713 vam->async_mode = 1;
13714 vam->async_errors = 0;
13715 before = vat_time_now (vam);
13718 for (jj = 0; jj < count; jj++)
13720 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13722 mp->is_add = is_add;
13724 mp->anti_replay = anti_replay;
13727 increment_address (&remote_ip);
13729 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13730 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13732 mp->local_spi = htonl (local_spi + jj);
13733 mp->remote_spi = htonl (remote_spi + jj);
13734 mp->crypto_alg = (u8) crypto_alg;
13736 mp->local_crypto_key_len = 0;
13739 mp->local_crypto_key_len = vec_len (lck);
13740 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13741 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13742 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13745 mp->remote_crypto_key_len = 0;
13748 mp->remote_crypto_key_len = vec_len (rck);
13749 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13750 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13751 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13754 mp->integ_alg = (u8) integ_alg;
13756 mp->local_integ_key_len = 0;
13759 mp->local_integ_key_len = vec_len (lik);
13760 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13761 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13762 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13765 mp->remote_integ_key_len = 0;
13768 mp->remote_integ_key_len = vec_len (rik);
13769 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13770 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13771 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13776 mp->renumber = renumber;
13777 mp->show_instance = ntohl (instance);
13782 /* When testing multiple add/del ops, use a control-ping to sync */
13785 vl_api_control_ping_t *mp_ping;
13789 /* Shut off async mode */
13790 vam->async_mode = 0;
13792 MPING (CONTROL_PING, mp_ping);
13795 timeout = vat_time_now (vam) + 1.0;
13796 while (vat_time_now (vam) < timeout)
13797 if (vam->result_ready == 1)
13802 if (vam->retval == -99)
13803 errmsg ("timeout");
13805 if (vam->async_errors > 0)
13807 errmsg ("%d asynchronous errors", vam->async_errors);
13810 vam->async_errors = 0;
13811 after = vat_time_now (vam);
13813 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13817 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13818 count, after - before, count / (after - before));
13822 /* Wait for a reply... */
13831 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13833 vat_main_t *vam = &vat_main;
13835 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13836 "crypto_key %U integ_alg %u integ_key %U flags %x "
13837 "tunnel_src_addr %U tunnel_dst_addr %U "
13838 "salt %u seq_outbound %lu last_seq_inbound %lu "
13839 "replay_window %lu stat_index %u\n",
13840 ntohl (mp->entry.sad_id),
13841 ntohl (mp->sw_if_index),
13842 ntohl (mp->entry.spi),
13843 ntohl (mp->entry.protocol),
13844 ntohl (mp->entry.crypto_algorithm),
13845 format_hex_bytes, mp->entry.crypto_key.data,
13846 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13847 format_hex_bytes, mp->entry.integrity_key.data,
13848 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13849 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13850 &mp->entry.tunnel_dst, ntohl (mp->salt),
13851 clib_net_to_host_u64 (mp->seq_outbound),
13852 clib_net_to_host_u64 (mp->last_seq_inbound),
13853 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13856 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13857 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13859 static void vl_api_ipsec_sa_details_t_handler_json
13860 (vl_api_ipsec_sa_details_t * mp)
13862 vat_main_t *vam = &vat_main;
13863 vat_json_node_t *node = NULL;
13864 vl_api_ipsec_sad_flags_t flags;
13866 if (VAT_JSON_ARRAY != vam->json_tree.type)
13868 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13869 vat_json_init_array (&vam->json_tree);
13871 node = vat_json_array_add (&vam->json_tree);
13873 vat_json_init_object (node);
13874 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13875 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13876 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13877 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13878 vat_json_object_add_uint (node, "crypto_alg",
13879 ntohl (mp->entry.crypto_algorithm));
13880 vat_json_object_add_uint (node, "integ_alg",
13881 ntohl (mp->entry.integrity_algorithm));
13882 flags = ntohl (mp->entry.flags);
13883 vat_json_object_add_uint (node, "use_esn",
13884 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13885 vat_json_object_add_uint (node, "use_anti_replay",
13886 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13887 vat_json_object_add_uint (node, "is_tunnel",
13888 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13889 vat_json_object_add_uint (node, "is_tunnel_ip6",
13890 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13891 vat_json_object_add_uint (node, "udp_encap",
13892 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13893 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13894 mp->entry.crypto_key.length);
13895 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13896 mp->entry.integrity_key.length);
13897 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13898 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13899 vat_json_object_add_uint (node, "replay_window",
13900 clib_net_to_host_u64 (mp->replay_window));
13901 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13905 api_ipsec_sa_dump (vat_main_t * vam)
13907 unformat_input_t *i = vam->input;
13908 vl_api_ipsec_sa_dump_t *mp;
13909 vl_api_control_ping_t *mp_ping;
13913 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13915 if (unformat (i, "sa_id %d", &sa_id))
13919 clib_warning ("parse error '%U'", format_unformat_error, i);
13924 M (IPSEC_SA_DUMP, mp);
13926 mp->sa_id = ntohl (sa_id);
13930 /* Use a control ping for synchronization */
13931 M (CONTROL_PING, mp_ping);
13939 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13941 unformat_input_t *i = vam->input;
13942 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13943 u32 sw_if_index = ~0;
13945 u8 is_outbound = (u8) ~ 0;
13948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13952 else if (unformat (i, "sa_id %d", &sa_id))
13954 else if (unformat (i, "outbound"))
13956 else if (unformat (i, "inbound"))
13960 clib_warning ("parse error '%U'", format_unformat_error, i);
13965 if (sw_if_index == ~0)
13967 errmsg ("interface must be specified");
13973 errmsg ("SA ID must be specified");
13977 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13979 mp->sw_if_index = htonl (sw_if_index);
13980 mp->sa_id = htonl (sa_id);
13981 mp->is_outbound = is_outbound;
13990 api_get_first_msg_id (vat_main_t * vam)
13992 vl_api_get_first_msg_id_t *mp;
13993 unformat_input_t *i = vam->input;
13998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14000 if (unformat (i, "client %s", &name))
14008 errmsg ("missing client name");
14011 vec_add1 (name, 0);
14013 if (vec_len (name) > 63)
14015 errmsg ("client name too long");
14019 M (GET_FIRST_MSG_ID, mp);
14020 clib_memcpy (mp->name, name, vec_len (name));
14027 api_cop_interface_enable_disable (vat_main_t * vam)
14029 unformat_input_t *line_input = vam->input;
14030 vl_api_cop_interface_enable_disable_t *mp;
14031 u32 sw_if_index = ~0;
14032 u8 enable_disable = 1;
14035 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14037 if (unformat (line_input, "disable"))
14038 enable_disable = 0;
14039 if (unformat (line_input, "enable"))
14040 enable_disable = 1;
14041 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14042 vam, &sw_if_index))
14044 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14050 if (sw_if_index == ~0)
14052 errmsg ("missing interface name or sw_if_index");
14056 /* Construct the API message */
14057 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14058 mp->sw_if_index = ntohl (sw_if_index);
14059 mp->enable_disable = enable_disable;
14063 /* Wait for the reply */
14069 api_cop_whitelist_enable_disable (vat_main_t * vam)
14071 unformat_input_t *line_input = vam->input;
14072 vl_api_cop_whitelist_enable_disable_t *mp;
14073 u32 sw_if_index = ~0;
14074 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14078 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14080 if (unformat (line_input, "ip4"))
14082 else if (unformat (line_input, "ip6"))
14084 else if (unformat (line_input, "default"))
14086 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14087 vam, &sw_if_index))
14089 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14091 else if (unformat (line_input, "fib-id %d", &fib_id))
14097 if (sw_if_index == ~0)
14099 errmsg ("missing interface name or sw_if_index");
14103 /* Construct the API message */
14104 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14105 mp->sw_if_index = ntohl (sw_if_index);
14106 mp->fib_id = ntohl (fib_id);
14109 mp->default_cop = default_cop;
14113 /* Wait for the reply */
14119 api_get_node_graph (vat_main_t * vam)
14121 vl_api_get_node_graph_t *mp;
14124 M (GET_NODE_GRAPH, mp);
14128 /* Wait for the reply */
14134 /** Used for parsing LISP eids */
14135 typedef CLIB_PACKED(struct{
14139 lisp_nsh_api_t nsh;
14141 u32 len; /**< prefix length if IP */
14142 u8 type; /**< type of eid */
14147 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14149 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14151 clib_memset (a, 0, sizeof (a[0]));
14153 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
14155 a->type = 0; /* ip prefix type */
14157 else if (unformat (input, "%U", unformat_ethernet_address, a->addr.mac))
14159 a->type = 1; /* mac type */
14161 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
14163 a->type = 2; /* NSH type */
14164 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
14173 if (ip46_address_is_ip4 (&a->addr.ip))
14174 return a->len > 32 ? 1 : 0;
14176 return a->len > 128 ? 1 : 0;
14183 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
14185 eid->type = vat_eid->type;
14188 case EID_TYPE_API_PREFIX:
14189 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
14191 clib_memcpy (&eid->address.prefix.address.un.ip4,
14192 &vat_eid->addr.ip.ip4, 4);
14193 eid->address.prefix.address.af = ADDRESS_IP4;
14194 eid->address.prefix.len = vat_eid->len;
14198 clib_memcpy (&eid->address.prefix.address.un.ip6,
14199 &vat_eid->addr.ip.ip6, 16);
14200 eid->address.prefix.address.af = ADDRESS_IP6;
14201 eid->address.prefix.len = vat_eid->len;
14204 case EID_TYPE_API_MAC:
14205 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
14206 sizeof (eid->address.mac));
14208 case EID_TYPE_API_NSH:
14209 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
14210 sizeof (eid->address.nsh));
14219 api_one_add_del_locator_set (vat_main_t * vam)
14221 unformat_input_t *input = vam->input;
14222 vl_api_one_add_del_locator_set_t *mp;
14224 u8 *locator_set_name = NULL;
14225 u8 locator_set_name_set = 0;
14226 vl_api_local_locator_t locator, *locators = 0;
14227 u32 sw_if_index, priority, weight;
14231 /* Parse args required to build the message */
14232 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14234 if (unformat (input, "del"))
14238 else if (unformat (input, "locator-set %s", &locator_set_name))
14240 locator_set_name_set = 1;
14242 else if (unformat (input, "sw_if_index %u p %u w %u",
14243 &sw_if_index, &priority, &weight))
14245 locator.sw_if_index = htonl (sw_if_index);
14246 locator.priority = priority;
14247 locator.weight = weight;
14248 vec_add1 (locators, locator);
14252 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14253 &sw_if_index, &priority, &weight))
14255 locator.sw_if_index = htonl (sw_if_index);
14256 locator.priority = priority;
14257 locator.weight = weight;
14258 vec_add1 (locators, locator);
14264 if (locator_set_name_set == 0)
14266 errmsg ("missing locator-set name");
14267 vec_free (locators);
14271 if (vec_len (locator_set_name) > 64)
14273 errmsg ("locator-set name too long");
14274 vec_free (locator_set_name);
14275 vec_free (locators);
14278 vec_add1 (locator_set_name, 0);
14280 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14282 /* Construct the API message */
14283 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14285 mp->is_add = is_add;
14286 clib_memcpy (mp->locator_set_name, locator_set_name,
14287 vec_len (locator_set_name));
14288 vec_free (locator_set_name);
14290 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14292 clib_memcpy (mp->locators, locators, data_len);
14293 vec_free (locators);
14298 /* Wait for a reply... */
14303 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14306 api_one_add_del_locator (vat_main_t * vam)
14308 unformat_input_t *input = vam->input;
14309 vl_api_one_add_del_locator_t *mp;
14310 u32 tmp_if_index = ~0;
14311 u32 sw_if_index = ~0;
14312 u8 sw_if_index_set = 0;
14313 u8 sw_if_index_if_name_set = 0;
14315 u8 priority_set = 0;
14319 u8 *locator_set_name = NULL;
14320 u8 locator_set_name_set = 0;
14323 /* Parse args required to build the message */
14324 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14326 if (unformat (input, "del"))
14330 else if (unformat (input, "locator-set %s", &locator_set_name))
14332 locator_set_name_set = 1;
14334 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14337 sw_if_index_if_name_set = 1;
14338 sw_if_index = tmp_if_index;
14340 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14342 sw_if_index_set = 1;
14343 sw_if_index = tmp_if_index;
14345 else if (unformat (input, "p %d", &priority))
14349 else if (unformat (input, "w %d", &weight))
14357 if (locator_set_name_set == 0)
14359 errmsg ("missing locator-set name");
14363 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14365 errmsg ("missing sw_if_index");
14366 vec_free (locator_set_name);
14370 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14372 errmsg ("cannot use both params interface name and sw_if_index");
14373 vec_free (locator_set_name);
14377 if (priority_set == 0)
14379 errmsg ("missing locator-set priority");
14380 vec_free (locator_set_name);
14384 if (weight_set == 0)
14386 errmsg ("missing locator-set weight");
14387 vec_free (locator_set_name);
14391 if (vec_len (locator_set_name) > 64)
14393 errmsg ("locator-set name too long");
14394 vec_free (locator_set_name);
14397 vec_add1 (locator_set_name, 0);
14399 /* Construct the API message */
14400 M (ONE_ADD_DEL_LOCATOR, mp);
14402 mp->is_add = is_add;
14403 mp->sw_if_index = ntohl (sw_if_index);
14404 mp->priority = priority;
14405 mp->weight = weight;
14406 clib_memcpy (mp->locator_set_name, locator_set_name,
14407 vec_len (locator_set_name));
14408 vec_free (locator_set_name);
14413 /* Wait for a reply... */
14418 #define api_lisp_add_del_locator api_one_add_del_locator
14421 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14423 u32 *key_id = va_arg (*args, u32 *);
14426 if (unformat (input, "%s", &s))
14428 if (!strcmp ((char *) s, "sha1"))
14429 key_id[0] = HMAC_SHA_1_96;
14430 else if (!strcmp ((char *) s, "sha256"))
14431 key_id[0] = HMAC_SHA_256_128;
14434 clib_warning ("invalid key_id: '%s'", s);
14435 key_id[0] = HMAC_NO_KEY;
14446 api_one_add_del_local_eid (vat_main_t * vam)
14448 unformat_input_t *input = vam->input;
14449 vl_api_one_add_del_local_eid_t *mp;
14452 lisp_eid_vat_t _eid, *eid = &_eid;
14453 u8 *locator_set_name = 0;
14454 u8 locator_set_name_set = 0;
14460 /* Parse args required to build the message */
14461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14463 if (unformat (input, "del"))
14467 else if (unformat (input, "vni %d", &vni))
14471 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14475 else if (unformat (input, "locator-set %s", &locator_set_name))
14477 locator_set_name_set = 1;
14479 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14481 else if (unformat (input, "secret-key %_%v%_", &key))
14487 if (locator_set_name_set == 0)
14489 errmsg ("missing locator-set name");
14495 errmsg ("EID address not set!");
14496 vec_free (locator_set_name);
14500 if (key && (0 == key_id))
14502 errmsg ("invalid key_id!");
14506 if (vec_len (key) > 64)
14508 errmsg ("key too long");
14513 if (vec_len (locator_set_name) > 64)
14515 errmsg ("locator-set name too long");
14516 vec_free (locator_set_name);
14519 vec_add1 (locator_set_name, 0);
14521 /* Construct the API message */
14522 M (ONE_ADD_DEL_LOCAL_EID, mp);
14524 mp->is_add = is_add;
14525 lisp_eid_put_vat (&mp->eid, eid);
14526 mp->vni = clib_host_to_net_u32 (vni);
14527 mp->key.id = key_id;
14528 clib_memcpy (mp->locator_set_name, locator_set_name,
14529 vec_len (locator_set_name));
14530 clib_memcpy (mp->key.key, key, vec_len (key));
14532 vec_free (locator_set_name);
14538 /* Wait for a reply... */
14543 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14546 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14548 u32 dp_table = 0, vni = 0;;
14549 unformat_input_t *input = vam->input;
14550 vl_api_gpe_add_del_fwd_entry_t *mp;
14552 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14553 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14554 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14555 u32 action = ~0, w;
14556 ip4_address_t rmt_rloc4, lcl_rloc4;
14557 ip6_address_t rmt_rloc6, lcl_rloc6;
14558 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14561 clib_memset (&rloc, 0, sizeof (rloc));
14563 /* Parse args required to build the message */
14564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14566 if (unformat (input, "del"))
14568 else if (unformat (input, "add"))
14570 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14574 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14578 else if (unformat (input, "vrf %d", &dp_table))
14580 else if (unformat (input, "bd %d", &dp_table))
14582 else if (unformat (input, "vni %d", &vni))
14584 else if (unformat (input, "w %d", &w))
14588 errmsg ("No RLOC configured for setting priority/weight!");
14591 curr_rloc->weight = w;
14593 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14594 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14597 clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
14599 vec_add1 (lcl_locs, rloc);
14601 clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
14602 vec_add1 (rmt_locs, rloc);
14603 /* weight saved in rmt loc */
14604 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14606 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14607 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14610 clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
14612 vec_add1 (lcl_locs, rloc);
14614 clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
14615 vec_add1 (rmt_locs, rloc);
14616 /* weight saved in rmt loc */
14617 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14619 else if (unformat (input, "action %d", &action))
14625 clib_warning ("parse error '%U'", format_unformat_error, input);
14632 errmsg ("remote eid addresses not set");
14636 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14638 errmsg ("eid types don't match");
14642 if (0 == rmt_locs && (u32) ~ 0 == action)
14644 errmsg ("action not set for negative mapping");
14648 /* Construct the API message */
14649 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14650 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14652 mp->is_add = is_add;
14653 lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
14654 lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
14655 mp->dp_table = clib_host_to_net_u32 (dp_table);
14656 mp->vni = clib_host_to_net_u32 (vni);
14657 mp->action = action;
14659 if (0 != rmt_locs && 0 != lcl_locs)
14661 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14662 clib_memcpy (mp->locs, lcl_locs,
14663 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14665 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14666 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14667 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14669 vec_free (lcl_locs);
14670 vec_free (rmt_locs);
14675 /* Wait for a reply... */
14681 api_one_add_del_map_server (vat_main_t * vam)
14683 unformat_input_t *input = vam->input;
14684 vl_api_one_add_del_map_server_t *mp;
14688 ip4_address_t ipv4;
14689 ip6_address_t ipv6;
14692 /* Parse args required to build the message */
14693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14695 if (unformat (input, "del"))
14699 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14703 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14711 if (ipv4_set && ipv6_set)
14713 errmsg ("both eid v4 and v6 addresses set");
14717 if (!ipv4_set && !ipv6_set)
14719 errmsg ("eid addresses not set");
14723 /* Construct the API message */
14724 M (ONE_ADD_DEL_MAP_SERVER, mp);
14726 mp->is_add = is_add;
14729 mp->ip_address.af = 1;
14730 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14734 mp->ip_address.af = 0;
14735 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
14741 /* Wait for a reply... */
14746 #define api_lisp_add_del_map_server api_one_add_del_map_server
14749 api_one_add_del_map_resolver (vat_main_t * vam)
14751 unformat_input_t *input = vam->input;
14752 vl_api_one_add_del_map_resolver_t *mp;
14756 ip4_address_t ipv4;
14757 ip6_address_t ipv6;
14760 /* Parse args required to build the message */
14761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14763 if (unformat (input, "del"))
14767 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14771 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14779 if (ipv4_set && ipv6_set)
14781 errmsg ("both eid v4 and v6 addresses set");
14785 if (!ipv4_set && !ipv6_set)
14787 errmsg ("eid addresses not set");
14791 /* Construct the API message */
14792 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14794 mp->is_add = is_add;
14797 mp->ip_address.af = 1;
14798 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14802 mp->ip_address.af = 0;
14803 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
14809 /* Wait for a reply... */
14814 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14817 api_lisp_gpe_enable_disable (vat_main_t * vam)
14819 unformat_input_t *input = vam->input;
14820 vl_api_gpe_enable_disable_t *mp;
14825 /* Parse args required to build the message */
14826 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14828 if (unformat (input, "enable"))
14833 else if (unformat (input, "disable"))
14844 errmsg ("Value not set");
14848 /* Construct the API message */
14849 M (GPE_ENABLE_DISABLE, mp);
14851 mp->is_enable = is_enable;
14856 /* Wait for a reply... */
14862 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14864 unformat_input_t *input = vam->input;
14865 vl_api_one_rloc_probe_enable_disable_t *mp;
14870 /* Parse args required to build the message */
14871 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14873 if (unformat (input, "enable"))
14878 else if (unformat (input, "disable"))
14886 errmsg ("Value not set");
14890 /* Construct the API message */
14891 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14893 mp->is_enable = is_enable;
14898 /* Wait for a reply... */
14903 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14906 api_one_map_register_enable_disable (vat_main_t * vam)
14908 unformat_input_t *input = vam->input;
14909 vl_api_one_map_register_enable_disable_t *mp;
14914 /* Parse args required to build the message */
14915 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14917 if (unformat (input, "enable"))
14922 else if (unformat (input, "disable"))
14930 errmsg ("Value not set");
14934 /* Construct the API message */
14935 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14937 mp->is_enable = is_enable;
14942 /* Wait for a reply... */
14947 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14950 api_one_enable_disable (vat_main_t * vam)
14952 unformat_input_t *input = vam->input;
14953 vl_api_one_enable_disable_t *mp;
14958 /* Parse args required to build the message */
14959 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14961 if (unformat (input, "enable"))
14966 else if (unformat (input, "disable"))
14976 errmsg ("Value not set");
14980 /* Construct the API message */
14981 M (ONE_ENABLE_DISABLE, mp);
14983 mp->is_enable = is_enable;
14988 /* Wait for a reply... */
14993 #define api_lisp_enable_disable api_one_enable_disable
14996 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14998 unformat_input_t *input = vam->input;
14999 vl_api_one_enable_disable_xtr_mode_t *mp;
15004 /* Parse args required to build the message */
15005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15007 if (unformat (input, "enable"))
15012 else if (unformat (input, "disable"))
15022 errmsg ("Value not set");
15026 /* Construct the API message */
15027 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15029 mp->is_enable = is_enable;
15034 /* Wait for a reply... */
15040 api_one_show_xtr_mode (vat_main_t * vam)
15042 vl_api_one_show_xtr_mode_t *mp;
15045 /* Construct the API message */
15046 M (ONE_SHOW_XTR_MODE, mp);
15051 /* Wait for a reply... */
15057 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15059 unformat_input_t *input = vam->input;
15060 vl_api_one_enable_disable_pitr_mode_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"))
15083 errmsg ("Value not set");
15087 /* Construct the API message */
15088 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15090 mp->is_enable = is_enable;
15095 /* Wait for a reply... */
15101 api_one_show_pitr_mode (vat_main_t * vam)
15103 vl_api_one_show_pitr_mode_t *mp;
15106 /* Construct the API message */
15107 M (ONE_SHOW_PITR_MODE, mp);
15112 /* Wait for a reply... */
15118 api_one_enable_disable_petr_mode (vat_main_t * vam)
15120 unformat_input_t *input = vam->input;
15121 vl_api_one_enable_disable_petr_mode_t *mp;
15126 /* Parse args required to build the message */
15127 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15129 if (unformat (input, "enable"))
15134 else if (unformat (input, "disable"))
15144 errmsg ("Value not set");
15148 /* Construct the API message */
15149 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15151 mp->is_enable = is_enable;
15156 /* Wait for a reply... */
15162 api_one_show_petr_mode (vat_main_t * vam)
15164 vl_api_one_show_petr_mode_t *mp;
15167 /* Construct the API message */
15168 M (ONE_SHOW_PETR_MODE, mp);
15173 /* Wait for a reply... */
15179 api_show_one_map_register_state (vat_main_t * vam)
15181 vl_api_show_one_map_register_state_t *mp;
15184 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15189 /* wait for reply */
15194 #define api_show_lisp_map_register_state api_show_one_map_register_state
15197 api_show_one_rloc_probe_state (vat_main_t * vam)
15199 vl_api_show_one_rloc_probe_state_t *mp;
15202 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15207 /* wait for reply */
15212 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15215 api_one_add_del_ndp_entry (vat_main_t * vam)
15217 vl_api_one_add_del_ndp_entry_t *mp;
15218 unformat_input_t *input = vam->input;
15223 u8 mac[6] = { 0, };
15224 u8 ip6[16] = { 0, };
15228 /* Parse args required to build the message */
15229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15231 if (unformat (input, "del"))
15233 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15235 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15237 else if (unformat (input, "bd %d", &bd))
15241 errmsg ("parse error '%U'", format_unformat_error, input);
15246 if (!bd_set || !ip_set || (!mac_set && is_add))
15248 errmsg ("Missing BD, IP or MAC!");
15252 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15253 mp->is_add = is_add;
15254 clib_memcpy (&mp->entry.mac, mac, 6);
15255 mp->bd = clib_host_to_net_u32 (bd);
15256 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
15261 /* wait for reply */
15267 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15269 vl_api_one_add_del_l2_arp_entry_t *mp;
15270 unformat_input_t *input = vam->input;
15275 u8 mac[6] = { 0, };
15276 u32 ip4 = 0, bd = ~0;
15279 /* Parse args required to build the message */
15280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15282 if (unformat (input, "del"))
15284 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15286 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15288 else if (unformat (input, "bd %d", &bd))
15292 errmsg ("parse error '%U'", format_unformat_error, input);
15297 if (!bd_set || !ip_set || (!mac_set && is_add))
15299 errmsg ("Missing BD, IP or MAC!");
15303 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15304 mp->is_add = is_add;
15305 clib_memcpy (&mp->entry.mac, mac, 6);
15306 mp->bd = clib_host_to_net_u32 (bd);
15307 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
15312 /* wait for reply */
15318 api_one_ndp_bd_get (vat_main_t * vam)
15320 vl_api_one_ndp_bd_get_t *mp;
15323 M (ONE_NDP_BD_GET, mp);
15328 /* wait for reply */
15334 api_one_ndp_entries_get (vat_main_t * vam)
15336 vl_api_one_ndp_entries_get_t *mp;
15337 unformat_input_t *input = vam->input;
15342 /* Parse args required to build the message */
15343 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15345 if (unformat (input, "bd %d", &bd))
15349 errmsg ("parse error '%U'", format_unformat_error, input);
15356 errmsg ("Expected bridge domain!");
15360 M (ONE_NDP_ENTRIES_GET, mp);
15361 mp->bd = clib_host_to_net_u32 (bd);
15366 /* wait for reply */
15372 api_one_l2_arp_bd_get (vat_main_t * vam)
15374 vl_api_one_l2_arp_bd_get_t *mp;
15377 M (ONE_L2_ARP_BD_GET, mp);
15382 /* wait for reply */
15388 api_one_l2_arp_entries_get (vat_main_t * vam)
15390 vl_api_one_l2_arp_entries_get_t *mp;
15391 unformat_input_t *input = vam->input;
15396 /* Parse args required to build the message */
15397 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15399 if (unformat (input, "bd %d", &bd))
15403 errmsg ("parse error '%U'", format_unformat_error, input);
15410 errmsg ("Expected bridge domain!");
15414 M (ONE_L2_ARP_ENTRIES_GET, mp);
15415 mp->bd = clib_host_to_net_u32 (bd);
15420 /* wait for reply */
15426 api_one_stats_enable_disable (vat_main_t * vam)
15428 vl_api_one_stats_enable_disable_t *mp;
15429 unformat_input_t *input = vam->input;
15434 /* Parse args required to build the message */
15435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15437 if (unformat (input, "enable"))
15442 else if (unformat (input, "disable"))
15452 errmsg ("Value not set");
15456 M (ONE_STATS_ENABLE_DISABLE, mp);
15457 mp->is_enable = is_enable;
15462 /* wait for reply */
15468 api_show_one_stats_enable_disable (vat_main_t * vam)
15470 vl_api_show_one_stats_enable_disable_t *mp;
15473 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15478 /* wait for reply */
15484 api_show_one_map_request_mode (vat_main_t * vam)
15486 vl_api_show_one_map_request_mode_t *mp;
15489 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15494 /* wait for reply */
15499 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15502 api_one_map_request_mode (vat_main_t * vam)
15504 unformat_input_t *input = vam->input;
15505 vl_api_one_map_request_mode_t *mp;
15509 /* Parse args required to build the message */
15510 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15512 if (unformat (input, "dst-only"))
15514 else if (unformat (input, "src-dst"))
15518 errmsg ("parse error '%U'", format_unformat_error, input);
15523 M (ONE_MAP_REQUEST_MODE, mp);
15530 /* wait for reply */
15535 #define api_lisp_map_request_mode api_one_map_request_mode
15538 * Enable/disable ONE proxy ITR.
15540 * @param vam vpp API test context
15541 * @return return code
15544 api_one_pitr_set_locator_set (vat_main_t * vam)
15546 u8 ls_name_set = 0;
15547 unformat_input_t *input = vam->input;
15548 vl_api_one_pitr_set_locator_set_t *mp;
15553 /* Parse args required to build the message */
15554 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15556 if (unformat (input, "del"))
15558 else if (unformat (input, "locator-set %s", &ls_name))
15562 errmsg ("parse error '%U'", format_unformat_error, input);
15569 errmsg ("locator-set name not set!");
15573 M (ONE_PITR_SET_LOCATOR_SET, mp);
15575 mp->is_add = is_add;
15576 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15577 vec_free (ls_name);
15582 /* wait for reply */
15587 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15590 api_one_nsh_set_locator_set (vat_main_t * vam)
15592 u8 ls_name_set = 0;
15593 unformat_input_t *input = vam->input;
15594 vl_api_one_nsh_set_locator_set_t *mp;
15599 /* Parse args required to build the message */
15600 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15602 if (unformat (input, "del"))
15604 else if (unformat (input, "ls %s", &ls_name))
15608 errmsg ("parse error '%U'", format_unformat_error, input);
15613 if (!ls_name_set && is_add)
15615 errmsg ("locator-set name not set!");
15619 M (ONE_NSH_SET_LOCATOR_SET, mp);
15621 mp->is_add = is_add;
15622 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15623 vec_free (ls_name);
15628 /* wait for reply */
15634 api_show_one_pitr (vat_main_t * vam)
15636 vl_api_show_one_pitr_t *mp;
15639 if (!vam->json_output)
15641 print (vam->ofp, "%=20s", "lisp status:");
15644 M (SHOW_ONE_PITR, mp);
15648 /* Wait for a reply... */
15653 #define api_show_lisp_pitr api_show_one_pitr
15656 api_one_use_petr (vat_main_t * vam)
15658 unformat_input_t *input = vam->input;
15659 vl_api_one_use_petr_t *mp;
15664 clib_memset (&ip, 0, sizeof (ip));
15666 /* Parse args required to build the message */
15667 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15669 if (unformat (input, "disable"))
15672 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15675 ip_addr_version (&ip) = AF_IP4;
15678 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15681 ip_addr_version (&ip) = AF_IP6;
15685 errmsg ("parse error '%U'", format_unformat_error, input);
15690 M (ONE_USE_PETR, mp);
15692 mp->is_add = is_add;
15695 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
15696 if (mp->ip_address.af)
15697 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
15699 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
15705 /* wait for reply */
15710 #define api_lisp_use_petr api_one_use_petr
15713 api_show_one_nsh_mapping (vat_main_t * vam)
15715 vl_api_show_one_use_petr_t *mp;
15718 if (!vam->json_output)
15720 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15723 M (SHOW_ONE_NSH_MAPPING, mp);
15727 /* Wait for a reply... */
15733 api_show_one_use_petr (vat_main_t * vam)
15735 vl_api_show_one_use_petr_t *mp;
15738 if (!vam->json_output)
15740 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15743 M (SHOW_ONE_USE_PETR, mp);
15747 /* Wait for a reply... */
15752 #define api_show_lisp_use_petr api_show_one_use_petr
15755 * Add/delete mapping between vni and vrf
15758 api_one_eid_table_add_del_map (vat_main_t * vam)
15760 unformat_input_t *input = vam->input;
15761 vl_api_one_eid_table_add_del_map_t *mp;
15762 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15763 u32 vni, vrf, bd_index;
15766 /* Parse args required to build the message */
15767 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15769 if (unformat (input, "del"))
15771 else if (unformat (input, "vrf %d", &vrf))
15773 else if (unformat (input, "bd_index %d", &bd_index))
15775 else if (unformat (input, "vni %d", &vni))
15781 if (!vni_set || (!vrf_set && !bd_index_set))
15783 errmsg ("missing arguments!");
15787 if (vrf_set && bd_index_set)
15789 errmsg ("error: both vrf and bd entered!");
15793 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15795 mp->is_add = is_add;
15796 mp->vni = htonl (vni);
15797 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15798 mp->is_l2 = bd_index_set;
15803 /* wait for reply */
15808 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15811 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15813 u32 *action = va_arg (*args, u32 *);
15816 if (unformat (input, "%s", &s))
15818 if (!strcmp ((char *) s, "no-action"))
15820 else if (!strcmp ((char *) s, "natively-forward"))
15822 else if (!strcmp ((char *) s, "send-map-request"))
15824 else if (!strcmp ((char *) s, "drop"))
15828 clib_warning ("invalid action: '%s'", s);
15840 * Add/del remote mapping to/from ONE control plane
15842 * @param vam vpp API test context
15843 * @return return code
15846 api_one_add_del_remote_mapping (vat_main_t * vam)
15848 unformat_input_t *input = vam->input;
15849 vl_api_one_add_del_remote_mapping_t *mp;
15851 lisp_eid_vat_t _eid, *eid = &_eid;
15852 lisp_eid_vat_t _seid, *seid = &_seid;
15853 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15854 u32 action = ~0, p, w, data_len;
15855 ip4_address_t rloc4;
15856 ip6_address_t rloc6;
15857 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15860 clib_memset (&rloc, 0, sizeof (rloc));
15862 /* Parse args required to build the message */
15863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15865 if (unformat (input, "del-all"))
15869 else if (unformat (input, "del"))
15873 else if (unformat (input, "add"))
15877 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15881 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15885 else if (unformat (input, "vni %d", &vni))
15889 else if (unformat (input, "p %d w %d", &p, &w))
15893 errmsg ("No RLOC configured for setting priority/weight!");
15896 curr_rloc->priority = p;
15897 curr_rloc->weight = w;
15899 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15901 rloc.ip_address.af = 0;
15902 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
15903 vec_add1 (rlocs, rloc);
15904 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15906 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15908 rloc.ip_address.af = 1;
15909 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
15910 vec_add1 (rlocs, rloc);
15911 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15913 else if (unformat (input, "action %U",
15914 unformat_negative_mapping_action, &action))
15920 clib_warning ("parse error '%U'", format_unformat_error, input);
15927 errmsg ("missing params!");
15931 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15933 errmsg ("no action set for negative map-reply!");
15937 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15939 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15940 mp->is_add = is_add;
15941 mp->vni = htonl (vni);
15942 mp->action = (u8) action;
15943 mp->is_src_dst = seid_set;
15944 mp->del_all = del_all;
15945 lisp_eid_put_vat (&mp->deid, eid);
15946 lisp_eid_put_vat (&mp->seid, seid);
15948 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15949 clib_memcpy (mp->rlocs, rlocs, data_len);
15955 /* Wait for a reply... */
15960 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15963 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15964 * forwarding entries in data-plane accordingly.
15966 * @param vam vpp API test context
15967 * @return return code
15970 api_one_add_del_adjacency (vat_main_t * vam)
15972 unformat_input_t *input = vam->input;
15973 vl_api_one_add_del_adjacency_t *mp;
15977 lisp_eid_vat_t leid, reid;
15979 leid.type = reid.type = (u8) ~ 0;
15981 /* Parse args required to build the message */
15982 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15984 if (unformat (input, "del"))
15988 else if (unformat (input, "add"))
15992 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
15993 &reid.addr.ip, &reid.len))
15995 reid.type = 0; /* ipv4 */
15997 else if (unformat (input, "reid %U", unformat_ethernet_address,
16000 reid.type = 1; /* mac */
16002 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
16003 &leid.addr.ip, &leid.len))
16005 leid.type = 0; /* ipv4 */
16007 else if (unformat (input, "leid %U", unformat_ethernet_address,
16010 leid.type = 1; /* mac */
16012 else if (unformat (input, "vni %d", &vni))
16018 errmsg ("parse error '%U'", format_unformat_error, input);
16023 if ((u8) ~ 0 == reid.type)
16025 errmsg ("missing params!");
16029 if (leid.type != reid.type)
16031 errmsg ("remote and local EIDs are of different types!");
16035 M (ONE_ADD_DEL_ADJACENCY, mp);
16036 mp->is_add = is_add;
16037 mp->vni = htonl (vni);
16038 lisp_eid_put_vat (&mp->leid, &leid);
16039 lisp_eid_put_vat (&mp->reid, &reid);
16044 /* Wait for a reply... */
16049 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16052 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16054 u32 *mode = va_arg (*args, u32 *);
16056 if (unformat (input, "lisp"))
16058 else if (unformat (input, "vxlan"))
16067 api_gpe_get_encap_mode (vat_main_t * vam)
16069 vl_api_gpe_get_encap_mode_t *mp;
16072 /* Construct the API message */
16073 M (GPE_GET_ENCAP_MODE, mp);
16078 /* Wait for a reply... */
16084 api_gpe_set_encap_mode (vat_main_t * vam)
16086 unformat_input_t *input = vam->input;
16087 vl_api_gpe_set_encap_mode_t *mp;
16091 /* Parse args required to build the message */
16092 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16094 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16100 /* Construct the API message */
16101 M (GPE_SET_ENCAP_MODE, mp);
16103 mp->is_vxlan = mode;
16108 /* Wait for a reply... */
16114 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16116 unformat_input_t *input = vam->input;
16117 vl_api_gpe_add_del_iface_t *mp;
16118 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16119 u32 dp_table = 0, vni = 0;
16122 /* Parse args required to build the message */
16123 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16125 if (unformat (input, "up"))
16130 else if (unformat (input, "down"))
16135 else if (unformat (input, "table_id %d", &dp_table))
16139 else if (unformat (input, "bd_id %d", &dp_table))
16144 else if (unformat (input, "vni %d", &vni))
16152 if (action_set == 0)
16154 errmsg ("Action not set");
16157 if (dp_table_set == 0 || vni_set == 0)
16159 errmsg ("vni and dp_table must be set");
16163 /* Construct the API message */
16164 M (GPE_ADD_DEL_IFACE, mp);
16166 mp->is_add = is_add;
16167 mp->dp_table = clib_host_to_net_u32 (dp_table);
16169 mp->vni = clib_host_to_net_u32 (vni);
16174 /* Wait for a reply... */
16180 api_one_map_register_fallback_threshold (vat_main_t * vam)
16182 unformat_input_t *input = vam->input;
16183 vl_api_one_map_register_fallback_threshold_t *mp;
16188 /* Parse args required to build the message */
16189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16191 if (unformat (input, "%u", &value))
16195 clib_warning ("parse error '%U'", format_unformat_error, input);
16202 errmsg ("fallback threshold value is missing!");
16206 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16207 mp->value = clib_host_to_net_u32 (value);
16212 /* Wait for a reply... */
16218 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16220 vl_api_show_one_map_register_fallback_threshold_t *mp;
16223 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16228 /* Wait for a reply... */
16234 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16236 u32 *proto = va_arg (*args, u32 *);
16238 if (unformat (input, "udp"))
16240 else if (unformat (input, "api"))
16249 api_one_set_transport_protocol (vat_main_t * vam)
16251 unformat_input_t *input = vam->input;
16252 vl_api_one_set_transport_protocol_t *mp;
16257 /* Parse args required to build the message */
16258 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16260 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16264 clib_warning ("parse error '%U'", format_unformat_error, input);
16271 errmsg ("Transport protocol missing!");
16275 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16276 mp->protocol = (u8) protocol;
16281 /* Wait for a reply... */
16287 api_one_get_transport_protocol (vat_main_t * vam)
16289 vl_api_one_get_transport_protocol_t *mp;
16292 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16297 /* Wait for a reply... */
16303 api_one_map_register_set_ttl (vat_main_t * vam)
16305 unformat_input_t *input = vam->input;
16306 vl_api_one_map_register_set_ttl_t *mp;
16311 /* Parse args required to build the message */
16312 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16314 if (unformat (input, "%u", &ttl))
16318 clib_warning ("parse error '%U'", format_unformat_error, input);
16325 errmsg ("TTL value missing!");
16329 M (ONE_MAP_REGISTER_SET_TTL, mp);
16330 mp->ttl = clib_host_to_net_u32 (ttl);
16335 /* Wait for a reply... */
16341 api_show_one_map_register_ttl (vat_main_t * vam)
16343 vl_api_show_one_map_register_ttl_t *mp;
16346 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16351 /* Wait for a reply... */
16357 * Add/del map request itr rlocs from ONE control plane and updates
16359 * @param vam vpp API test context
16360 * @return return code
16363 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16365 unformat_input_t *input = vam->input;
16366 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16367 u8 *locator_set_name = 0;
16368 u8 locator_set_name_set = 0;
16372 /* Parse args required to build the message */
16373 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16375 if (unformat (input, "del"))
16379 else if (unformat (input, "%_%v%_", &locator_set_name))
16381 locator_set_name_set = 1;
16385 clib_warning ("parse error '%U'", format_unformat_error, input);
16390 if (is_add && !locator_set_name_set)
16392 errmsg ("itr-rloc is not set!");
16396 if (is_add && vec_len (locator_set_name) > 64)
16398 errmsg ("itr-rloc locator-set name too long");
16399 vec_free (locator_set_name);
16403 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16404 mp->is_add = is_add;
16407 clib_memcpy (mp->locator_set_name, locator_set_name,
16408 vec_len (locator_set_name));
16412 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16414 vec_free (locator_set_name);
16419 /* Wait for a reply... */
16424 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16427 api_one_locator_dump (vat_main_t * vam)
16429 unformat_input_t *input = vam->input;
16430 vl_api_one_locator_dump_t *mp;
16431 vl_api_control_ping_t *mp_ping;
16432 u8 is_index_set = 0, is_name_set = 0;
16437 /* Parse args required to build the message */
16438 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16440 if (unformat (input, "ls_name %_%v%_", &ls_name))
16444 else if (unformat (input, "ls_index %d", &ls_index))
16450 errmsg ("parse error '%U'", format_unformat_error, input);
16455 if (!is_index_set && !is_name_set)
16457 errmsg ("error: expected one of index or name!");
16461 if (is_index_set && is_name_set)
16463 errmsg ("error: only one param expected!");
16467 if (vec_len (ls_name) > 62)
16469 errmsg ("error: locator set name too long!");
16473 if (!vam->json_output)
16475 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16478 M (ONE_LOCATOR_DUMP, mp);
16479 mp->is_index_set = is_index_set;
16482 mp->ls_index = clib_host_to_net_u32 (ls_index);
16485 vec_add1 (ls_name, 0);
16486 strncpy ((char *) mp->ls_name, (char *) ls_name,
16487 sizeof (mp->ls_name) - 1);
16493 /* Use a control ping for synchronization */
16494 MPING (CONTROL_PING, mp_ping);
16497 /* Wait for a reply... */
16502 #define api_lisp_locator_dump api_one_locator_dump
16505 api_one_locator_set_dump (vat_main_t * vam)
16507 vl_api_one_locator_set_dump_t *mp;
16508 vl_api_control_ping_t *mp_ping;
16509 unformat_input_t *input = vam->input;
16513 /* Parse args required to build the message */
16514 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16516 if (unformat (input, "local"))
16520 else if (unformat (input, "remote"))
16526 errmsg ("parse error '%U'", format_unformat_error, input);
16531 if (!vam->json_output)
16533 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16536 M (ONE_LOCATOR_SET_DUMP, mp);
16538 mp->filter = filter;
16543 /* Use a control ping for synchronization */
16544 MPING (CONTROL_PING, mp_ping);
16547 /* Wait for a reply... */
16552 #define api_lisp_locator_set_dump api_one_locator_set_dump
16555 api_one_eid_table_map_dump (vat_main_t * vam)
16559 unformat_input_t *input = vam->input;
16560 vl_api_one_eid_table_map_dump_t *mp;
16561 vl_api_control_ping_t *mp_ping;
16564 /* Parse args required to build the message */
16565 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16567 if (unformat (input, "l2"))
16572 else if (unformat (input, "l3"))
16579 errmsg ("parse error '%U'", format_unformat_error, input);
16586 errmsg ("expected one of 'l2' or 'l3' parameter!");
16590 if (!vam->json_output)
16592 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16595 M (ONE_EID_TABLE_MAP_DUMP, mp);
16601 /* Use a control ping for synchronization */
16602 MPING (CONTROL_PING, mp_ping);
16605 /* Wait for a reply... */
16610 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16613 api_one_eid_table_vni_dump (vat_main_t * vam)
16615 vl_api_one_eid_table_vni_dump_t *mp;
16616 vl_api_control_ping_t *mp_ping;
16619 if (!vam->json_output)
16621 print (vam->ofp, "VNI");
16624 M (ONE_EID_TABLE_VNI_DUMP, mp);
16629 /* Use a control ping for synchronization */
16630 MPING (CONTROL_PING, mp_ping);
16633 /* Wait for a reply... */
16638 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16641 api_one_eid_table_dump (vat_main_t * vam)
16643 unformat_input_t *i = vam->input;
16644 vl_api_one_eid_table_dump_t *mp;
16645 vl_api_control_ping_t *mp_ping;
16649 lisp_eid_vat_t eid;
16652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16655 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
16661 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
16666 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
16671 else if (unformat (i, "vni %d", &t))
16675 else if (unformat (i, "local"))
16679 else if (unformat (i, "remote"))
16685 errmsg ("parse error '%U'", format_unformat_error, i);
16690 if (!vam->json_output)
16692 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16693 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16696 M (ONE_EID_TABLE_DUMP, mp);
16698 mp->filter = filter;
16702 mp->vni = htonl (vni);
16703 lisp_eid_put_vat (&mp->eid, &eid);
16709 /* Use a control ping for synchronization */
16710 MPING (CONTROL_PING, mp_ping);
16713 /* Wait for a reply... */
16718 #define api_lisp_eid_table_dump api_one_eid_table_dump
16721 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16723 unformat_input_t *i = vam->input;
16724 vl_api_gpe_fwd_entries_get_t *mp;
16729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16731 if (unformat (i, "vni %d", &vni))
16737 errmsg ("parse error '%U'", format_unformat_error, i);
16744 errmsg ("vni not set!");
16748 if (!vam->json_output)
16750 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16754 M (GPE_FWD_ENTRIES_GET, mp);
16755 mp->vni = clib_host_to_net_u32 (vni);
16760 /* Wait for a reply... */
16765 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16766 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16767 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16768 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16769 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16770 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16771 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16772 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16775 api_one_adjacencies_get (vat_main_t * vam)
16777 unformat_input_t *i = vam->input;
16778 vl_api_one_adjacencies_get_t *mp;
16783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16785 if (unformat (i, "vni %d", &vni))
16791 errmsg ("parse error '%U'", format_unformat_error, i);
16798 errmsg ("vni not set!");
16802 if (!vam->json_output)
16804 print (vam->ofp, "%s %40s", "leid", "reid");
16807 M (ONE_ADJACENCIES_GET, mp);
16808 mp->vni = clib_host_to_net_u32 (vni);
16813 /* Wait for a reply... */
16818 #define api_lisp_adjacencies_get api_one_adjacencies_get
16821 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16823 unformat_input_t *i = vam->input;
16824 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16826 u8 ip_family_set = 0, is_ip4 = 1;
16828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16830 if (unformat (i, "ip4"))
16835 else if (unformat (i, "ip6"))
16842 errmsg ("parse error '%U'", format_unformat_error, i);
16847 if (!ip_family_set)
16849 errmsg ("ip family not set!");
16853 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16854 mp->is_ip4 = is_ip4;
16859 /* Wait for a reply... */
16865 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16867 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16870 if (!vam->json_output)
16872 print (vam->ofp, "VNIs");
16875 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16880 /* Wait for a reply... */
16886 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16888 unformat_input_t *i = vam->input;
16889 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16891 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16892 struct in_addr ip4;
16893 struct in6_addr ip6;
16894 u32 table_id = 0, nh_sw_if_index = ~0;
16896 clib_memset (&ip4, 0, sizeof (ip4));
16897 clib_memset (&ip6, 0, sizeof (ip6));
16899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16901 if (unformat (i, "del"))
16903 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16904 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16909 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16910 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16915 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16919 nh_sw_if_index = ~0;
16921 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16925 nh_sw_if_index = ~0;
16927 else if (unformat (i, "table %d", &table_id))
16931 errmsg ("parse error '%U'", format_unformat_error, i);
16938 errmsg ("nh addr not set!");
16942 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16943 mp->is_add = is_add;
16944 mp->table_id = clib_host_to_net_u32 (table_id);
16945 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16946 mp->nh_addr.af = is_ip4 ? 0 : 1;
16948 clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
16950 clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
16955 /* Wait for a reply... */
16961 api_one_map_server_dump (vat_main_t * vam)
16963 vl_api_one_map_server_dump_t *mp;
16964 vl_api_control_ping_t *mp_ping;
16967 if (!vam->json_output)
16969 print (vam->ofp, "%=20s", "Map server");
16972 M (ONE_MAP_SERVER_DUMP, mp);
16976 /* Use a control ping for synchronization */
16977 MPING (CONTROL_PING, mp_ping);
16980 /* Wait for a reply... */
16985 #define api_lisp_map_server_dump api_one_map_server_dump
16988 api_one_map_resolver_dump (vat_main_t * vam)
16990 vl_api_one_map_resolver_dump_t *mp;
16991 vl_api_control_ping_t *mp_ping;
16994 if (!vam->json_output)
16996 print (vam->ofp, "%=20s", "Map resolver");
16999 M (ONE_MAP_RESOLVER_DUMP, mp);
17003 /* Use a control ping for synchronization */
17004 MPING (CONTROL_PING, mp_ping);
17007 /* Wait for a reply... */
17012 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17015 api_one_stats_flush (vat_main_t * vam)
17017 vl_api_one_stats_flush_t *mp;
17020 M (ONE_STATS_FLUSH, mp);
17027 api_one_stats_dump (vat_main_t * vam)
17029 vl_api_one_stats_dump_t *mp;
17030 vl_api_control_ping_t *mp_ping;
17033 M (ONE_STATS_DUMP, mp);
17037 /* Use a control ping for synchronization */
17038 MPING (CONTROL_PING, mp_ping);
17041 /* Wait for a reply... */
17047 api_show_one_status (vat_main_t * vam)
17049 vl_api_show_one_status_t *mp;
17052 if (!vam->json_output)
17054 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17057 M (SHOW_ONE_STATUS, mp);
17060 /* Wait for a reply... */
17065 #define api_show_lisp_status api_show_one_status
17068 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17070 vl_api_gpe_fwd_entry_path_dump_t *mp;
17071 vl_api_control_ping_t *mp_ping;
17072 unformat_input_t *i = vam->input;
17073 u32 fwd_entry_index = ~0;
17076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17078 if (unformat (i, "index %d", &fwd_entry_index))
17084 if (~0 == fwd_entry_index)
17086 errmsg ("no index specified!");
17090 if (!vam->json_output)
17092 print (vam->ofp, "first line");
17095 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17099 /* Use a control ping for synchronization */
17100 MPING (CONTROL_PING, mp_ping);
17103 /* Wait for a reply... */
17109 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17111 vl_api_one_get_map_request_itr_rlocs_t *mp;
17114 if (!vam->json_output)
17116 print (vam->ofp, "%=20s", "itr-rlocs:");
17119 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17122 /* Wait for a reply... */
17127 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17130 api_af_packet_create (vat_main_t * vam)
17132 unformat_input_t *i = vam->input;
17133 vl_api_af_packet_create_t *mp;
17134 u8 *host_if_name = 0;
17136 u8 random_hw_addr = 1;
17139 clib_memset (hw_addr, 0, sizeof (hw_addr));
17141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17143 if (unformat (i, "name %s", &host_if_name))
17144 vec_add1 (host_if_name, 0);
17145 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17146 random_hw_addr = 0;
17151 if (!vec_len (host_if_name))
17153 errmsg ("host-interface name must be specified");
17157 if (vec_len (host_if_name) > 64)
17159 errmsg ("host-interface name too long");
17163 M (AF_PACKET_CREATE, mp);
17165 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17166 clib_memcpy (mp->hw_addr, hw_addr, 6);
17167 mp->use_random_hw_addr = random_hw_addr;
17168 vec_free (host_if_name);
17176 fprintf (vam->ofp ? vam->ofp : stderr,
17177 " new sw_if_index = %d\n", vam->sw_if_index);
17184 api_af_packet_delete (vat_main_t * vam)
17186 unformat_input_t *i = vam->input;
17187 vl_api_af_packet_delete_t *mp;
17188 u8 *host_if_name = 0;
17191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17193 if (unformat (i, "name %s", &host_if_name))
17194 vec_add1 (host_if_name, 0);
17199 if (!vec_len (host_if_name))
17201 errmsg ("host-interface name must be specified");
17205 if (vec_len (host_if_name) > 64)
17207 errmsg ("host-interface name too long");
17211 M (AF_PACKET_DELETE, mp);
17213 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17214 vec_free (host_if_name);
17221 static void vl_api_af_packet_details_t_handler
17222 (vl_api_af_packet_details_t * mp)
17224 vat_main_t *vam = &vat_main;
17226 print (vam->ofp, "%-16s %d",
17227 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17230 static void vl_api_af_packet_details_t_handler_json
17231 (vl_api_af_packet_details_t * mp)
17233 vat_main_t *vam = &vat_main;
17234 vat_json_node_t *node = NULL;
17236 if (VAT_JSON_ARRAY != vam->json_tree.type)
17238 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17239 vat_json_init_array (&vam->json_tree);
17241 node = vat_json_array_add (&vam->json_tree);
17243 vat_json_init_object (node);
17244 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17245 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17249 api_af_packet_dump (vat_main_t * vam)
17251 vl_api_af_packet_dump_t *mp;
17252 vl_api_control_ping_t *mp_ping;
17255 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17256 /* Get list of tap interfaces */
17257 M (AF_PACKET_DUMP, mp);
17260 /* Use a control ping for synchronization */
17261 MPING (CONTROL_PING, mp_ping);
17269 api_policer_add_del (vat_main_t * vam)
17271 unformat_input_t *i = vam->input;
17272 vl_api_policer_add_del_t *mp;
17282 u8 color_aware = 0;
17283 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17286 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17287 conform_action.dscp = 0;
17288 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17289 exceed_action.dscp = 0;
17290 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17291 violate_action.dscp = 0;
17293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17295 if (unformat (i, "del"))
17297 else if (unformat (i, "name %s", &name))
17298 vec_add1 (name, 0);
17299 else if (unformat (i, "cir %u", &cir))
17301 else if (unformat (i, "eir %u", &eir))
17303 else if (unformat (i, "cb %u", &cb))
17305 else if (unformat (i, "eb %u", &eb))
17307 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17310 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17313 else if (unformat (i, "type %U", unformat_policer_type, &type))
17315 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17318 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17321 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17324 else if (unformat (i, "color-aware"))
17330 if (!vec_len (name))
17332 errmsg ("policer name must be specified");
17336 if (vec_len (name) > 64)
17338 errmsg ("policer name too long");
17342 M (POLICER_ADD_DEL, mp);
17344 clib_memcpy (mp->name, name, vec_len (name));
17346 mp->is_add = is_add;
17347 mp->cir = ntohl (cir);
17348 mp->eir = ntohl (eir);
17349 mp->cb = clib_net_to_host_u64 (cb);
17350 mp->eb = clib_net_to_host_u64 (eb);
17351 mp->rate_type = rate_type;
17352 mp->round_type = round_type;
17354 mp->conform_action.type = conform_action.action_type;
17355 mp->conform_action.dscp = conform_action.dscp;
17356 mp->exceed_action.type = exceed_action.action_type;
17357 mp->exceed_action.dscp = exceed_action.dscp;
17358 mp->violate_action.type = violate_action.action_type;
17359 mp->violate_action.dscp = violate_action.dscp;
17360 mp->color_aware = color_aware;
17368 api_policer_dump (vat_main_t * vam)
17370 unformat_input_t *i = vam->input;
17371 vl_api_policer_dump_t *mp;
17372 vl_api_control_ping_t *mp_ping;
17373 u8 *match_name = 0;
17374 u8 match_name_valid = 0;
17377 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17379 if (unformat (i, "name %s", &match_name))
17381 vec_add1 (match_name, 0);
17382 match_name_valid = 1;
17388 M (POLICER_DUMP, mp);
17389 mp->match_name_valid = match_name_valid;
17390 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17391 vec_free (match_name);
17395 /* Use a control ping for synchronization */
17396 MPING (CONTROL_PING, mp_ping);
17399 /* Wait for a reply... */
17405 api_policer_classify_set_interface (vat_main_t * vam)
17407 unformat_input_t *i = vam->input;
17408 vl_api_policer_classify_set_interface_t *mp;
17410 int sw_if_index_set;
17411 u32 ip4_table_index = ~0;
17412 u32 ip6_table_index = ~0;
17413 u32 l2_table_index = ~0;
17417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17419 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17420 sw_if_index_set = 1;
17421 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17422 sw_if_index_set = 1;
17423 else if (unformat (i, "del"))
17425 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17427 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17429 else if (unformat (i, "l2-table %d", &l2_table_index))
17433 clib_warning ("parse error '%U'", format_unformat_error, i);
17438 if (sw_if_index_set == 0)
17440 errmsg ("missing interface name or sw_if_index");
17444 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17446 mp->sw_if_index = ntohl (sw_if_index);
17447 mp->ip4_table_index = ntohl (ip4_table_index);
17448 mp->ip6_table_index = ntohl (ip6_table_index);
17449 mp->l2_table_index = ntohl (l2_table_index);
17450 mp->is_add = is_add;
17458 api_policer_classify_dump (vat_main_t * vam)
17460 unformat_input_t *i = vam->input;
17461 vl_api_policer_classify_dump_t *mp;
17462 vl_api_control_ping_t *mp_ping;
17463 u8 type = POLICER_CLASSIFY_N_TABLES;
17466 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17470 errmsg ("classify table type must be specified");
17474 if (!vam->json_output)
17476 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17479 M (POLICER_CLASSIFY_DUMP, mp);
17484 /* Use a control ping for synchronization */
17485 MPING (CONTROL_PING, mp_ping);
17488 /* Wait for a reply... */
17494 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17496 vl_api_fib_path_nh_proto_t proto =
17497 va_arg (*args, vl_api_fib_path_nh_proto_t);
17501 case FIB_API_PATH_NH_PROTO_IP4:
17502 s = format (s, "ip4");
17504 case FIB_API_PATH_NH_PROTO_IP6:
17505 s = format (s, "ip6");
17507 case FIB_API_PATH_NH_PROTO_MPLS:
17508 s = format (s, "mpls");
17510 case FIB_API_PATH_NH_PROTO_BIER:
17511 s = format (s, "bier");
17513 case FIB_API_PATH_NH_PROTO_ETHERNET:
17514 s = format (s, "ethernet");
17522 format_vl_api_ip_address_union (u8 * s, va_list * args)
17524 vl_api_address_family_t af = va_arg (*args, int);
17525 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17530 s = format (s, "%U", format_ip4_address, u->ip4);
17533 s = format (s, "%U", format_ip6_address, u->ip6);
17540 format_vl_api_fib_path_type (u8 * s, va_list * args)
17542 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17546 case FIB_API_PATH_TYPE_NORMAL:
17547 s = format (s, "normal");
17549 case FIB_API_PATH_TYPE_LOCAL:
17550 s = format (s, "local");
17552 case FIB_API_PATH_TYPE_DROP:
17553 s = format (s, "drop");
17555 case FIB_API_PATH_TYPE_UDP_ENCAP:
17556 s = format (s, "udp-encap");
17558 case FIB_API_PATH_TYPE_BIER_IMP:
17559 s = format (s, "bier-imp");
17561 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17562 s = format (s, "unreach");
17564 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17565 s = format (s, "prohibit");
17567 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17568 s = format (s, "src-lookup");
17570 case FIB_API_PATH_TYPE_DVR:
17571 s = format (s, "dvr");
17573 case FIB_API_PATH_TYPE_INTERFACE_RX:
17574 s = format (s, "interface-rx");
17576 case FIB_API_PATH_TYPE_CLASSIFY:
17577 s = format (s, "classify");
17585 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17588 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17589 ntohl (fp->weight), ntohl (fp->sw_if_index),
17590 format_vl_api_fib_path_type, fp->type,
17591 format_fib_api_path_nh_proto, fp->proto,
17592 format_vl_api_ip_address_union, &fp->nh.address);
17596 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17597 vl_api_fib_path_t * fp)
17599 struct in_addr ip4;
17600 struct in6_addr ip6;
17602 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17603 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17604 vat_json_object_add_uint (node, "type", fp->type);
17605 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17606 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17608 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17609 vat_json_object_add_ip4 (node, "next_hop", ip4);
17611 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17613 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17614 vat_json_object_add_ip6 (node, "next_hop", ip6);
17619 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17621 vat_main_t *vam = &vat_main;
17622 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17623 vl_api_fib_path_t *fp;
17626 print (vam->ofp, "sw_if_index %d via:",
17627 ntohl (mp->mt_tunnel.mt_sw_if_index));
17628 fp = mp->mt_tunnel.mt_paths;
17629 for (i = 0; i < count; i++)
17631 vl_api_fib_path_print (vam, fp);
17635 print (vam->ofp, "");
17638 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17639 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17642 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17644 vat_main_t *vam = &vat_main;
17645 vat_json_node_t *node = NULL;
17646 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17647 vl_api_fib_path_t *fp;
17650 if (VAT_JSON_ARRAY != vam->json_tree.type)
17652 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17653 vat_json_init_array (&vam->json_tree);
17655 node = vat_json_array_add (&vam->json_tree);
17657 vat_json_init_object (node);
17658 vat_json_object_add_uint (node, "sw_if_index",
17659 ntohl (mp->mt_tunnel.mt_sw_if_index));
17661 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17663 fp = mp->mt_tunnel.mt_paths;
17664 for (i = 0; i < count; i++)
17666 vl_api_mpls_fib_path_json_print (node, fp);
17672 api_mpls_tunnel_dump (vat_main_t * vam)
17674 vl_api_mpls_tunnel_dump_t *mp;
17675 vl_api_control_ping_t *mp_ping;
17678 M (MPLS_TUNNEL_DUMP, mp);
17682 /* Use a control ping for synchronization */
17683 MPING (CONTROL_PING, mp_ping);
17690 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17691 #define vl_api_mpls_table_details_t_print vl_noop_handler
17695 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17697 vat_main_t *vam = &vat_main;
17699 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17702 static void vl_api_mpls_table_details_t_handler_json
17703 (vl_api_mpls_table_details_t * mp)
17705 vat_main_t *vam = &vat_main;
17706 vat_json_node_t *node = NULL;
17708 if (VAT_JSON_ARRAY != vam->json_tree.type)
17710 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17711 vat_json_init_array (&vam->json_tree);
17713 node = vat_json_array_add (&vam->json_tree);
17715 vat_json_init_object (node);
17716 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17720 api_mpls_table_dump (vat_main_t * vam)
17722 vl_api_mpls_table_dump_t *mp;
17723 vl_api_control_ping_t *mp_ping;
17726 M (MPLS_TABLE_DUMP, mp);
17729 /* Use a control ping for synchronization */
17730 MPING (CONTROL_PING, mp_ping);
17737 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17738 #define vl_api_mpls_route_details_t_print vl_noop_handler
17741 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17743 vat_main_t *vam = &vat_main;
17744 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17745 vl_api_fib_path_t *fp;
17749 "table-id %d, label %u, ess_bit %u",
17750 ntohl (mp->mr_route.mr_table_id),
17751 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17752 fp = mp->mr_route.mr_paths;
17753 for (i = 0; i < count; i++)
17755 vl_api_fib_path_print (vam, fp);
17760 static void vl_api_mpls_route_details_t_handler_json
17761 (vl_api_mpls_route_details_t * mp)
17763 vat_main_t *vam = &vat_main;
17764 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17765 vat_json_node_t *node = NULL;
17766 vl_api_fib_path_t *fp;
17769 if (VAT_JSON_ARRAY != vam->json_tree.type)
17771 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17772 vat_json_init_array (&vam->json_tree);
17774 node = vat_json_array_add (&vam->json_tree);
17776 vat_json_init_object (node);
17777 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17778 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17779 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17780 vat_json_object_add_uint (node, "path_count", count);
17781 fp = mp->mr_route.mr_paths;
17782 for (i = 0; i < count; i++)
17784 vl_api_mpls_fib_path_json_print (node, fp);
17790 api_mpls_route_dump (vat_main_t * vam)
17792 unformat_input_t *input = vam->input;
17793 vl_api_mpls_route_dump_t *mp;
17794 vl_api_control_ping_t *mp_ping;
17798 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17800 if (unformat (input, "table_id %d", &table_id))
17805 if (table_id == ~0)
17807 errmsg ("missing table id");
17811 M (MPLS_ROUTE_DUMP, mp);
17813 mp->table.mt_table_id = ntohl (table_id);
17816 /* Use a control ping for synchronization */
17817 MPING (CONTROL_PING, mp_ping);
17824 #define vl_api_ip_table_details_t_endian vl_noop_handler
17825 #define vl_api_ip_table_details_t_print vl_noop_handler
17828 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17830 vat_main_t *vam = &vat_main;
17833 "%s; table-id %d, prefix %U/%d",
17834 mp->table.name, ntohl (mp->table.table_id));
17838 static void vl_api_ip_table_details_t_handler_json
17839 (vl_api_ip_table_details_t * mp)
17841 vat_main_t *vam = &vat_main;
17842 vat_json_node_t *node = NULL;
17844 if (VAT_JSON_ARRAY != vam->json_tree.type)
17846 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17847 vat_json_init_array (&vam->json_tree);
17849 node = vat_json_array_add (&vam->json_tree);
17851 vat_json_init_object (node);
17852 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17856 api_ip_table_dump (vat_main_t * vam)
17858 vl_api_ip_table_dump_t *mp;
17859 vl_api_control_ping_t *mp_ping;
17862 M (IP_TABLE_DUMP, mp);
17865 /* Use a control ping for synchronization */
17866 MPING (CONTROL_PING, mp_ping);
17874 api_ip_mtable_dump (vat_main_t * vam)
17876 vl_api_ip_mtable_dump_t *mp;
17877 vl_api_control_ping_t *mp_ping;
17880 M (IP_MTABLE_DUMP, mp);
17883 /* Use a control ping for synchronization */
17884 MPING (CONTROL_PING, mp_ping);
17892 api_ip_mroute_dump (vat_main_t * vam)
17894 unformat_input_t *input = vam->input;
17895 vl_api_control_ping_t *mp_ping;
17896 vl_api_ip_mroute_dump_t *mp;
17901 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17903 if (unformat (input, "table_id %d", &table_id))
17905 else if (unformat (input, "ip6"))
17907 else if (unformat (input, "ip4"))
17912 if (table_id == ~0)
17914 errmsg ("missing table id");
17918 M (IP_MROUTE_DUMP, mp);
17919 mp->table.table_id = table_id;
17920 mp->table.is_ip6 = is_ip6;
17923 /* Use a control ping for synchronization */
17924 MPING (CONTROL_PING, mp_ping);
17931 #define vl_api_ip_route_details_t_endian vl_noop_handler
17932 #define vl_api_ip_route_details_t_print vl_noop_handler
17935 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17937 vat_main_t *vam = &vat_main;
17938 u8 count = mp->route.n_paths;
17939 vl_api_fib_path_t *fp;
17943 "table-id %d, prefix %U/%d",
17944 ntohl (mp->route.table_id),
17945 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17946 for (i = 0; i < count; i++)
17948 fp = &mp->route.paths[i];
17950 vl_api_fib_path_print (vam, fp);
17955 static void vl_api_ip_route_details_t_handler_json
17956 (vl_api_ip_route_details_t * mp)
17958 vat_main_t *vam = &vat_main;
17959 u8 count = mp->route.n_paths;
17960 vat_json_node_t *node = NULL;
17961 struct in_addr ip4;
17962 struct in6_addr ip6;
17963 vl_api_fib_path_t *fp;
17966 if (VAT_JSON_ARRAY != vam->json_tree.type)
17968 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17969 vat_json_init_array (&vam->json_tree);
17971 node = vat_json_array_add (&vam->json_tree);
17973 vat_json_init_object (node);
17974 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
17975 if (ADDRESS_IP6 == mp->route.prefix.address.af)
17977 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
17978 vat_json_object_add_ip6 (node, "prefix", ip6);
17982 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
17983 vat_json_object_add_ip4 (node, "prefix", ip4);
17985 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
17986 vat_json_object_add_uint (node, "path_count", count);
17987 for (i = 0; i < count; i++)
17989 fp = &mp->route.paths[i];
17990 vl_api_mpls_fib_path_json_print (node, fp);
17995 api_ip_route_dump (vat_main_t * vam)
17997 unformat_input_t *input = vam->input;
17998 vl_api_ip_route_dump_t *mp;
17999 vl_api_control_ping_t *mp_ping;
18005 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18007 if (unformat (input, "table_id %d", &table_id))
18009 else if (unformat (input, "ip6"))
18011 else if (unformat (input, "ip4"))
18016 if (table_id == ~0)
18018 errmsg ("missing table id");
18022 M (IP_ROUTE_DUMP, mp);
18024 mp->table.table_id = table_id;
18025 mp->table.is_ip6 = is_ip6;
18029 /* Use a control ping for synchronization */
18030 MPING (CONTROL_PING, mp_ping);
18038 api_classify_table_ids (vat_main_t * vam)
18040 vl_api_classify_table_ids_t *mp;
18043 /* Construct the API message */
18044 M (CLASSIFY_TABLE_IDS, mp);
18053 api_classify_table_by_interface (vat_main_t * vam)
18055 unformat_input_t *input = vam->input;
18056 vl_api_classify_table_by_interface_t *mp;
18058 u32 sw_if_index = ~0;
18060 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18062 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18064 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18069 if (sw_if_index == ~0)
18071 errmsg ("missing interface name or sw_if_index");
18075 /* Construct the API message */
18076 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18078 mp->sw_if_index = ntohl (sw_if_index);
18086 api_classify_table_info (vat_main_t * vam)
18088 unformat_input_t *input = vam->input;
18089 vl_api_classify_table_info_t *mp;
18093 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18095 if (unformat (input, "table_id %d", &table_id))
18100 if (table_id == ~0)
18102 errmsg ("missing table id");
18106 /* Construct the API message */
18107 M (CLASSIFY_TABLE_INFO, mp);
18109 mp->table_id = ntohl (table_id);
18117 api_classify_session_dump (vat_main_t * vam)
18119 unformat_input_t *input = vam->input;
18120 vl_api_classify_session_dump_t *mp;
18121 vl_api_control_ping_t *mp_ping;
18125 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18127 if (unformat (input, "table_id %d", &table_id))
18132 if (table_id == ~0)
18134 errmsg ("missing table id");
18138 /* Construct the API message */
18139 M (CLASSIFY_SESSION_DUMP, mp);
18141 mp->table_id = ntohl (table_id);
18144 /* Use a control ping for synchronization */
18145 MPING (CONTROL_PING, mp_ping);
18153 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18155 vat_main_t *vam = &vat_main;
18157 print (vam->ofp, "collector_address %U, collector_port %d, "
18158 "src_address %U, vrf_id %d, path_mtu %u, "
18159 "template_interval %u, udp_checksum %d",
18160 format_ip4_address, mp->collector_address,
18161 ntohs (mp->collector_port),
18162 format_ip4_address, mp->src_address,
18163 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18164 ntohl (mp->template_interval), mp->udp_checksum);
18167 vam->result_ready = 1;
18171 vl_api_ipfix_exporter_details_t_handler_json
18172 (vl_api_ipfix_exporter_details_t * mp)
18174 vat_main_t *vam = &vat_main;
18175 vat_json_node_t node;
18176 struct in_addr collector_address;
18177 struct in_addr src_address;
18179 vat_json_init_object (&node);
18180 clib_memcpy (&collector_address, &mp->collector_address,
18181 sizeof (collector_address));
18182 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18183 vat_json_object_add_uint (&node, "collector_port",
18184 ntohs (mp->collector_port));
18185 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18186 vat_json_object_add_ip4 (&node, "src_address", src_address);
18187 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18188 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18189 vat_json_object_add_uint (&node, "template_interval",
18190 ntohl (mp->template_interval));
18191 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18193 vat_json_print (vam->ofp, &node);
18194 vat_json_free (&node);
18196 vam->result_ready = 1;
18200 api_ipfix_exporter_dump (vat_main_t * vam)
18202 vl_api_ipfix_exporter_dump_t *mp;
18205 /* Construct the API message */
18206 M (IPFIX_EXPORTER_DUMP, mp);
18215 api_ipfix_classify_stream_dump (vat_main_t * vam)
18217 vl_api_ipfix_classify_stream_dump_t *mp;
18220 /* Construct the API message */
18221 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18232 vl_api_ipfix_classify_stream_details_t_handler
18233 (vl_api_ipfix_classify_stream_details_t * mp)
18235 vat_main_t *vam = &vat_main;
18236 print (vam->ofp, "domain_id %d, src_port %d",
18237 ntohl (mp->domain_id), ntohs (mp->src_port));
18239 vam->result_ready = 1;
18243 vl_api_ipfix_classify_stream_details_t_handler_json
18244 (vl_api_ipfix_classify_stream_details_t * mp)
18246 vat_main_t *vam = &vat_main;
18247 vat_json_node_t node;
18249 vat_json_init_object (&node);
18250 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18251 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18253 vat_json_print (vam->ofp, &node);
18254 vat_json_free (&node);
18256 vam->result_ready = 1;
18260 api_ipfix_classify_table_dump (vat_main_t * vam)
18262 vl_api_ipfix_classify_table_dump_t *mp;
18263 vl_api_control_ping_t *mp_ping;
18266 if (!vam->json_output)
18268 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18269 "transport_protocol");
18272 /* Construct the API message */
18273 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18278 /* Use a control ping for synchronization */
18279 MPING (CONTROL_PING, mp_ping);
18287 vl_api_ipfix_classify_table_details_t_handler
18288 (vl_api_ipfix_classify_table_details_t * mp)
18290 vat_main_t *vam = &vat_main;
18291 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18292 mp->transport_protocol);
18296 vl_api_ipfix_classify_table_details_t_handler_json
18297 (vl_api_ipfix_classify_table_details_t * mp)
18299 vat_json_node_t *node = NULL;
18300 vat_main_t *vam = &vat_main;
18302 if (VAT_JSON_ARRAY != vam->json_tree.type)
18304 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18305 vat_json_init_array (&vam->json_tree);
18308 node = vat_json_array_add (&vam->json_tree);
18309 vat_json_init_object (node);
18311 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18312 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18313 vat_json_object_add_uint (node, "transport_protocol",
18314 mp->transport_protocol);
18318 api_sw_interface_span_enable_disable (vat_main_t * vam)
18320 unformat_input_t *i = vam->input;
18321 vl_api_sw_interface_span_enable_disable_t *mp;
18322 u32 src_sw_if_index = ~0;
18323 u32 dst_sw_if_index = ~0;
18328 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18331 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18333 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18337 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18339 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18341 else if (unformat (i, "disable"))
18343 else if (unformat (i, "rx"))
18345 else if (unformat (i, "tx"))
18347 else if (unformat (i, "both"))
18349 else if (unformat (i, "l2"))
18355 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18357 mp->sw_if_index_from = htonl (src_sw_if_index);
18358 mp->sw_if_index_to = htonl (dst_sw_if_index);
18368 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18371 vat_main_t *vam = &vat_main;
18372 u8 *sw_if_from_name = 0;
18373 u8 *sw_if_to_name = 0;
18374 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18375 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18376 char *states[] = { "none", "rx", "tx", "both" };
18380 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18382 if ((u32) p->value[0] == sw_if_index_from)
18384 sw_if_from_name = (u8 *)(p->key);
18388 if ((u32) p->value[0] == sw_if_index_to)
18390 sw_if_to_name = (u8 *)(p->key);
18391 if (sw_if_from_name)
18396 print (vam->ofp, "%20s => %20s (%s) %s",
18397 sw_if_from_name, sw_if_to_name, states[mp->state],
18398 mp->is_l2 ? "l2" : "device");
18402 vl_api_sw_interface_span_details_t_handler_json
18403 (vl_api_sw_interface_span_details_t * mp)
18405 vat_main_t *vam = &vat_main;
18406 vat_json_node_t *node = NULL;
18407 u8 *sw_if_from_name = 0;
18408 u8 *sw_if_to_name = 0;
18409 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18410 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18414 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18416 if ((u32) p->value[0] == sw_if_index_from)
18418 sw_if_from_name = (u8 *)(p->key);
18422 if ((u32) p->value[0] == sw_if_index_to)
18424 sw_if_to_name = (u8 *)(p->key);
18425 if (sw_if_from_name)
18431 if (VAT_JSON_ARRAY != vam->json_tree.type)
18433 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18434 vat_json_init_array (&vam->json_tree);
18436 node = vat_json_array_add (&vam->json_tree);
18438 vat_json_init_object (node);
18439 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18440 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18441 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18442 if (0 != sw_if_to_name)
18444 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18446 vat_json_object_add_uint (node, "state", mp->state);
18447 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18451 api_sw_interface_span_dump (vat_main_t * vam)
18453 unformat_input_t *input = vam->input;
18454 vl_api_sw_interface_span_dump_t *mp;
18455 vl_api_control_ping_t *mp_ping;
18459 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18461 if (unformat (input, "l2"))
18467 M (SW_INTERFACE_SPAN_DUMP, mp);
18471 /* Use a control ping for synchronization */
18472 MPING (CONTROL_PING, mp_ping);
18480 api_pg_create_interface (vat_main_t * vam)
18482 unformat_input_t *input = vam->input;
18483 vl_api_pg_create_interface_t *mp;
18485 u32 if_id = ~0, gso_size = 0;
18486 u8 gso_enabled = 0;
18488 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18490 if (unformat (input, "if_id %d", &if_id))
18492 else if (unformat (input, "gso-enabled"))
18495 if (unformat (input, "gso-size %u", &gso_size))
18499 errmsg ("missing gso-size");
18508 errmsg ("missing pg interface index");
18512 /* Construct the API message */
18513 M (PG_CREATE_INTERFACE, mp);
18515 mp->interface_id = ntohl (if_id);
18516 mp->gso_enabled = gso_enabled;
18524 api_pg_capture (vat_main_t * vam)
18526 unformat_input_t *input = vam->input;
18527 vl_api_pg_capture_t *mp;
18532 u8 pcap_file_set = 0;
18535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18537 if (unformat (input, "if_id %d", &if_id))
18539 else if (unformat (input, "pcap %s", &pcap_file))
18541 else if (unformat (input, "count %d", &count))
18543 else if (unformat (input, "disable"))
18550 errmsg ("missing pg interface index");
18553 if (pcap_file_set > 0)
18555 if (vec_len (pcap_file) > 255)
18557 errmsg ("pcap file name is too long");
18562 /* Construct the API message */
18563 M (PG_CAPTURE, mp);
18565 mp->interface_id = ntohl (if_id);
18566 mp->is_enabled = enable;
18567 mp->count = ntohl (count);
18568 if (pcap_file_set != 0)
18570 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18572 vec_free (pcap_file);
18580 api_pg_enable_disable (vat_main_t * vam)
18582 unformat_input_t *input = vam->input;
18583 vl_api_pg_enable_disable_t *mp;
18586 u8 stream_name_set = 0;
18587 u8 *stream_name = 0;
18589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18591 if (unformat (input, "stream %s", &stream_name))
18592 stream_name_set = 1;
18593 else if (unformat (input, "disable"))
18599 if (stream_name_set > 0)
18601 if (vec_len (stream_name) > 255)
18603 errmsg ("stream name too long");
18608 /* Construct the API message */
18609 M (PG_ENABLE_DISABLE, mp);
18611 mp->is_enabled = enable;
18612 if (stream_name_set != 0)
18614 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18616 vec_free (stream_name);
18624 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18626 unformat_input_t *input = vam->input;
18627 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18629 u16 *low_ports = 0;
18630 u16 *high_ports = 0;
18633 vl_api_prefix_t prefix;
18640 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18642 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18644 else if (unformat (input, "vrf %d", &vrf_id))
18646 else if (unformat (input, "del"))
18648 else if (unformat (input, "port %d", &tmp))
18650 if (tmp == 0 || tmp > 65535)
18652 errmsg ("port %d out of range", tmp);
18656 this_hi = this_low + 1;
18657 vec_add1 (low_ports, this_low);
18658 vec_add1 (high_ports, this_hi);
18660 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18662 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18664 errmsg ("incorrect range parameters");
18668 /* Note: in debug CLI +1 is added to high before
18669 passing to real fn that does "the work"
18670 (ip_source_and_port_range_check_add_del).
18671 This fn is a wrapper around the binary API fn a
18672 control plane will call, which expects this increment
18673 to have occurred. Hence letting the binary API control
18674 plane fn do the increment for consistency between VAT
18675 and other control planes.
18678 vec_add1 (low_ports, this_low);
18679 vec_add1 (high_ports, this_hi);
18685 if (prefix_set == 0)
18687 errmsg ("<address>/<mask> not specified");
18693 errmsg ("VRF ID required, not specified");
18700 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18704 if (vec_len (low_ports) == 0)
18706 errmsg ("At least one port or port range required");
18710 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18712 mp->is_add = is_add;
18714 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18716 mp->number_of_ranges = vec_len (low_ports);
18718 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18719 vec_free (low_ports);
18721 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18722 vec_free (high_ports);
18724 mp->vrf_id = ntohl (vrf_id);
18732 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18734 unformat_input_t *input = vam->input;
18735 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18736 u32 sw_if_index = ~0;
18738 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18739 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18743 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18745 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18747 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18749 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18751 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18753 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18755 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18757 else if (unformat (input, "del"))
18763 if (sw_if_index == ~0)
18765 errmsg ("Interface required but not specified");
18771 errmsg ("VRF ID required but not specified");
18775 if (tcp_out_vrf_id == 0
18776 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18779 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18783 /* Construct the API message */
18784 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18786 mp->sw_if_index = ntohl (sw_if_index);
18787 mp->is_add = is_add;
18788 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18789 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18790 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18791 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18796 /* Wait for a reply... */
18802 api_set_punt (vat_main_t * vam)
18804 unformat_input_t *i = vam->input;
18805 vl_api_address_family_t af;
18806 vl_api_set_punt_t *mp;
18812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18814 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18816 else if (unformat (i, "protocol %d", &protocol))
18818 else if (unformat (i, "port %d", &port))
18820 else if (unformat (i, "del"))
18824 clib_warning ("parse error '%U'", format_unformat_error, i);
18831 mp->is_add = (u8) is_add;
18832 mp->punt.type = PUNT_API_TYPE_L4;
18833 mp->punt.punt.l4.af = af;
18834 mp->punt.punt.l4.protocol = (u8) protocol;
18835 mp->punt.punt.l4.port = htons ((u16) port);
18843 api_delete_subif (vat_main_t * vam)
18845 unformat_input_t *i = vam->input;
18846 vl_api_delete_subif_t *mp;
18847 u32 sw_if_index = ~0;
18850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18852 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18854 if (unformat (i, "sw_if_index %d", &sw_if_index))
18860 if (sw_if_index == ~0)
18862 errmsg ("missing sw_if_index");
18866 /* Construct the API message */
18867 M (DELETE_SUBIF, mp);
18868 mp->sw_if_index = ntohl (sw_if_index);
18875 #define foreach_pbb_vtr_op \
18876 _("disable", L2_VTR_DISABLED) \
18877 _("pop", L2_VTR_POP_2) \
18878 _("push", L2_VTR_PUSH_2)
18881 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18883 unformat_input_t *i = vam->input;
18884 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18885 u32 sw_if_index = ~0, vtr_op = ~0;
18886 u16 outer_tag = ~0;
18887 u8 dmac[6], smac[6];
18888 u8 dmac_set = 0, smac_set = 0;
18894 /* Shut up coverity */
18895 clib_memset (dmac, 0, sizeof (dmac));
18896 clib_memset (smac, 0, sizeof (smac));
18898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18900 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18902 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18904 else if (unformat (i, "vtr_op %d", &vtr_op))
18906 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18909 else if (unformat (i, "translate_pbb_stag"))
18911 if (unformat (i, "%d", &tmp))
18913 vtr_op = L2_VTR_TRANSLATE_2_1;
18919 ("translate_pbb_stag operation requires outer tag definition");
18923 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18925 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18927 else if (unformat (i, "sid %d", &sid))
18929 else if (unformat (i, "vlanid %d", &tmp))
18933 clib_warning ("parse error '%U'", format_unformat_error, i);
18938 if ((sw_if_index == ~0) || (vtr_op == ~0))
18940 errmsg ("missing sw_if_index or vtr operation");
18943 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18944 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18947 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18951 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18952 mp->sw_if_index = ntohl (sw_if_index);
18953 mp->vtr_op = ntohl (vtr_op);
18954 mp->outer_tag = ntohs (outer_tag);
18955 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18956 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18957 mp->b_vlanid = ntohs (vlanid);
18958 mp->i_sid = ntohl (sid);
18966 api_flow_classify_set_interface (vat_main_t * vam)
18968 unformat_input_t *i = vam->input;
18969 vl_api_flow_classify_set_interface_t *mp;
18971 int sw_if_index_set;
18972 u32 ip4_table_index = ~0;
18973 u32 ip6_table_index = ~0;
18977 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18979 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18980 sw_if_index_set = 1;
18981 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18982 sw_if_index_set = 1;
18983 else if (unformat (i, "del"))
18985 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18987 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18991 clib_warning ("parse error '%U'", format_unformat_error, i);
18996 if (sw_if_index_set == 0)
18998 errmsg ("missing interface name or sw_if_index");
19002 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19004 mp->sw_if_index = ntohl (sw_if_index);
19005 mp->ip4_table_index = ntohl (ip4_table_index);
19006 mp->ip6_table_index = ntohl (ip6_table_index);
19007 mp->is_add = is_add;
19015 api_flow_classify_dump (vat_main_t * vam)
19017 unformat_input_t *i = vam->input;
19018 vl_api_flow_classify_dump_t *mp;
19019 vl_api_control_ping_t *mp_ping;
19020 u8 type = FLOW_CLASSIFY_N_TABLES;
19023 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19027 errmsg ("classify table type must be specified");
19031 if (!vam->json_output)
19033 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19036 M (FLOW_CLASSIFY_DUMP, mp);
19041 /* Use a control ping for synchronization */
19042 MPING (CONTROL_PING, mp_ping);
19045 /* Wait for a reply... */
19051 api_feature_enable_disable (vat_main_t * vam)
19053 unformat_input_t *i = vam->input;
19054 vl_api_feature_enable_disable_t *mp;
19056 u8 *feature_name = 0;
19057 u32 sw_if_index = ~0;
19061 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19063 if (unformat (i, "arc_name %s", &arc_name))
19065 else if (unformat (i, "feature_name %s", &feature_name))
19068 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19070 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19072 else if (unformat (i, "disable"))
19080 errmsg ("missing arc name");
19083 if (vec_len (arc_name) > 63)
19085 errmsg ("arc name too long");
19088 if (feature_name == 0)
19090 errmsg ("missing feature name");
19093 if (vec_len (feature_name) > 63)
19095 errmsg ("feature name too long");
19098 if (sw_if_index == ~0)
19100 errmsg ("missing interface name or sw_if_index");
19104 /* Construct the API message */
19105 M (FEATURE_ENABLE_DISABLE, mp);
19106 mp->sw_if_index = ntohl (sw_if_index);
19107 mp->enable = enable;
19108 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19109 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19110 vec_free (arc_name);
19111 vec_free (feature_name);
19119 api_feature_gso_enable_disable (vat_main_t * vam)
19121 unformat_input_t *i = vam->input;
19122 vl_api_feature_gso_enable_disable_t *mp;
19123 u32 sw_if_index = ~0;
19127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19129 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19131 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19133 else if (unformat (i, "enable"))
19135 else if (unformat (i, "disable"))
19141 if (sw_if_index == ~0)
19143 errmsg ("missing interface name or sw_if_index");
19147 /* Construct the API message */
19148 M (FEATURE_GSO_ENABLE_DISABLE, mp);
19149 mp->sw_if_index = ntohl (sw_if_index);
19150 mp->enable_disable = enable;
19158 api_sw_interface_tag_add_del (vat_main_t * vam)
19160 unformat_input_t *i = vam->input;
19161 vl_api_sw_interface_tag_add_del_t *mp;
19162 u32 sw_if_index = ~0;
19167 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19169 if (unformat (i, "tag %s", &tag))
19171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19175 else if (unformat (i, "del"))
19181 if (sw_if_index == ~0)
19183 errmsg ("missing interface name or sw_if_index");
19187 if (enable && (tag == 0))
19189 errmsg ("no tag specified");
19193 /* Construct the API message */
19194 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19195 mp->sw_if_index = ntohl (sw_if_index);
19196 mp->is_add = enable;
19198 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19207 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19209 unformat_input_t *i = vam->input;
19210 vl_api_mac_address_t mac = { 0 };
19211 vl_api_sw_interface_add_del_mac_address_t *mp;
19212 u32 sw_if_index = ~0;
19217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19219 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19221 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19223 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19225 else if (unformat (i, "del"))
19231 if (sw_if_index == ~0)
19233 errmsg ("missing interface name or sw_if_index");
19239 errmsg ("missing MAC address");
19243 /* Construct the API message */
19244 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19245 mp->sw_if_index = ntohl (sw_if_index);
19246 mp->is_add = is_add;
19247 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19254 static void vl_api_l2_xconnect_details_t_handler
19255 (vl_api_l2_xconnect_details_t * mp)
19257 vat_main_t *vam = &vat_main;
19259 print (vam->ofp, "%15d%15d",
19260 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19263 static void vl_api_l2_xconnect_details_t_handler_json
19264 (vl_api_l2_xconnect_details_t * mp)
19266 vat_main_t *vam = &vat_main;
19267 vat_json_node_t *node = NULL;
19269 if (VAT_JSON_ARRAY != vam->json_tree.type)
19271 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19272 vat_json_init_array (&vam->json_tree);
19274 node = vat_json_array_add (&vam->json_tree);
19276 vat_json_init_object (node);
19277 vat_json_object_add_uint (node, "rx_sw_if_index",
19278 ntohl (mp->rx_sw_if_index));
19279 vat_json_object_add_uint (node, "tx_sw_if_index",
19280 ntohl (mp->tx_sw_if_index));
19284 api_l2_xconnect_dump (vat_main_t * vam)
19286 vl_api_l2_xconnect_dump_t *mp;
19287 vl_api_control_ping_t *mp_ping;
19290 if (!vam->json_output)
19292 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19295 M (L2_XCONNECT_DUMP, mp);
19299 /* Use a control ping for synchronization */
19300 MPING (CONTROL_PING, mp_ping);
19308 api_hw_interface_set_mtu (vat_main_t * vam)
19310 unformat_input_t *i = vam->input;
19311 vl_api_hw_interface_set_mtu_t *mp;
19312 u32 sw_if_index = ~0;
19316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19318 if (unformat (i, "mtu %d", &mtu))
19320 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19322 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19328 if (sw_if_index == ~0)
19330 errmsg ("missing interface name or sw_if_index");
19336 errmsg ("no mtu specified");
19340 /* Construct the API message */
19341 M (HW_INTERFACE_SET_MTU, mp);
19342 mp->sw_if_index = ntohl (sw_if_index);
19343 mp->mtu = ntohs ((u16) mtu);
19351 api_p2p_ethernet_add (vat_main_t * vam)
19353 unformat_input_t *i = vam->input;
19354 vl_api_p2p_ethernet_add_t *mp;
19355 u32 parent_if_index = ~0;
19361 clib_memset (remote_mac, 0, sizeof (remote_mac));
19362 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19364 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19366 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19370 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19372 else if (unformat (i, "sub_id %d", &sub_id))
19376 clib_warning ("parse error '%U'", format_unformat_error, i);
19381 if (parent_if_index == ~0)
19383 errmsg ("missing interface name or sw_if_index");
19388 errmsg ("missing remote mac address");
19393 errmsg ("missing sub-interface id");
19397 M (P2P_ETHERNET_ADD, mp);
19398 mp->parent_if_index = ntohl (parent_if_index);
19399 mp->subif_id = ntohl (sub_id);
19400 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19408 api_p2p_ethernet_del (vat_main_t * vam)
19410 unformat_input_t *i = vam->input;
19411 vl_api_p2p_ethernet_del_t *mp;
19412 u32 parent_if_index = ~0;
19417 clib_memset (remote_mac, 0, sizeof (remote_mac));
19418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19420 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19422 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19426 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19430 clib_warning ("parse error '%U'", format_unformat_error, i);
19435 if (parent_if_index == ~0)
19437 errmsg ("missing interface name or sw_if_index");
19442 errmsg ("missing remote mac address");
19446 M (P2P_ETHERNET_DEL, mp);
19447 mp->parent_if_index = ntohl (parent_if_index);
19448 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19456 api_lldp_config (vat_main_t * vam)
19458 unformat_input_t *i = vam->input;
19459 vl_api_lldp_config_t *mp;
19461 int tx_interval = 0;
19462 u8 *sys_name = NULL;
19465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19467 if (unformat (i, "system-name %s", &sys_name))
19469 else if (unformat (i, "tx-hold %d", &tx_hold))
19471 else if (unformat (i, "tx-interval %d", &tx_interval))
19475 clib_warning ("parse error '%U'", format_unformat_error, i);
19480 vec_add1 (sys_name, 0);
19482 M (LLDP_CONFIG, mp);
19483 mp->tx_hold = htonl (tx_hold);
19484 mp->tx_interval = htonl (tx_interval);
19485 vl_api_vec_to_api_string (sys_name, &mp->system_name);
19486 vec_free (sys_name);
19494 api_sw_interface_set_lldp (vat_main_t * vam)
19496 unformat_input_t *i = vam->input;
19497 vl_api_sw_interface_set_lldp_t *mp;
19498 u32 sw_if_index = ~0;
19500 u8 *port_desc = NULL, *mgmt_oid = NULL;
19501 ip4_address_t ip4_addr;
19502 ip6_address_t ip6_addr;
19505 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19506 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19510 if (unformat (i, "disable"))
19513 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19515 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19517 else if (unformat (i, "port-desc %s", &port_desc))
19519 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19521 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19523 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19529 if (sw_if_index == ~0)
19531 errmsg ("missing interface name or sw_if_index");
19535 /* Construct the API message */
19536 vec_add1 (port_desc, 0);
19537 vec_add1 (mgmt_oid, 0);
19538 M (SW_INTERFACE_SET_LLDP, mp);
19539 mp->sw_if_index = ntohl (sw_if_index);
19540 mp->enable = enable;
19541 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
19542 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19543 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19544 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19545 vec_free (port_desc);
19546 vec_free (mgmt_oid);
19554 api_tcp_configure_src_addresses (vat_main_t * vam)
19556 vl_api_tcp_configure_src_addresses_t *mp;
19557 unformat_input_t *i = vam->input;
19558 vl_api_address_t first, last;
19563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19565 if (unformat (i, "%U - %U",
19566 unformat_vl_api_address, &first,
19567 unformat_vl_api_address, &last))
19571 errmsg ("one range per message (range already set)");
19576 else if (unformat (i, "vrf %d", &vrf_id))
19582 if (range_set == 0)
19584 errmsg ("address range not set");
19588 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19590 mp->vrf_id = ntohl (vrf_id);
19591 clib_memcpy (&mp->first_address, &first, sizeof (first));
19592 clib_memcpy (&mp->last_address, &last, sizeof (last));
19599 static void vl_api_app_namespace_add_del_reply_t_handler
19600 (vl_api_app_namespace_add_del_reply_t * mp)
19602 vat_main_t *vam = &vat_main;
19603 i32 retval = ntohl (mp->retval);
19604 if (vam->async_mode)
19606 vam->async_errors += (retval < 0);
19610 vam->retval = retval;
19612 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19613 vam->result_ready = 1;
19617 static void vl_api_app_namespace_add_del_reply_t_handler_json
19618 (vl_api_app_namespace_add_del_reply_t * mp)
19620 vat_main_t *vam = &vat_main;
19621 vat_json_node_t node;
19623 vat_json_init_object (&node);
19624 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19625 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19627 vat_json_print (vam->ofp, &node);
19628 vat_json_free (&node);
19630 vam->retval = ntohl (mp->retval);
19631 vam->result_ready = 1;
19635 api_app_namespace_add_del (vat_main_t * vam)
19637 vl_api_app_namespace_add_del_t *mp;
19638 unformat_input_t *i = vam->input;
19639 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19640 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19646 if (unformat (i, "id %_%v%_", &ns_id))
19648 else if (unformat (i, "secret %lu", &secret))
19650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19651 sw_if_index_set = 1;
19652 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19654 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19659 if (!ns_id || !secret_set || !sw_if_index_set)
19661 errmsg ("namespace id, secret and sw_if_index must be set");
19664 if (vec_len (ns_id) > 64)
19666 errmsg ("namespace id too long");
19669 M (APP_NAMESPACE_ADD_DEL, mp);
19671 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19672 mp->secret = clib_host_to_net_u64 (secret);
19673 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19674 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19675 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19683 api_sock_init_shm (vat_main_t * vam)
19685 #if VPP_API_TEST_BUILTIN == 0
19686 unformat_input_t *i = vam->input;
19687 vl_api_shm_elem_config_t *config = 0;
19688 u64 size = 64 << 20;
19691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19693 if (unformat (i, "size %U", unformat_memory_size, &size))
19700 * Canned custom ring allocator config.
19701 * Should probably parse all of this
19703 vec_validate (config, 6);
19704 config[0].type = VL_API_VLIB_RING;
19705 config[0].size = 256;
19706 config[0].count = 32;
19708 config[1].type = VL_API_VLIB_RING;
19709 config[1].size = 1024;
19710 config[1].count = 16;
19712 config[2].type = VL_API_VLIB_RING;
19713 config[2].size = 4096;
19714 config[2].count = 2;
19716 config[3].type = VL_API_CLIENT_RING;
19717 config[3].size = 256;
19718 config[3].count = 32;
19720 config[4].type = VL_API_CLIENT_RING;
19721 config[4].size = 1024;
19722 config[4].count = 16;
19724 config[5].type = VL_API_CLIENT_RING;
19725 config[5].size = 4096;
19726 config[5].count = 2;
19728 config[6].type = VL_API_QUEUE;
19729 config[6].count = 128;
19730 config[6].size = sizeof (uword);
19732 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19734 vam->client_index_invalid = 1;
19742 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19744 vat_main_t *vam = &vat_main;
19745 fib_prefix_t lcl, rmt;
19747 ip_prefix_decode (&mp->lcl, &lcl);
19748 ip_prefix_decode (&mp->rmt, &rmt);
19750 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19753 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19754 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19755 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19756 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19757 &rmt.fp_addr.ip4, rmt.fp_len,
19758 clib_net_to_host_u16 (mp->rmt_port),
19759 clib_net_to_host_u32 (mp->action_index), mp->tag);
19764 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19765 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19766 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19767 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19768 &rmt.fp_addr.ip6, rmt.fp_len,
19769 clib_net_to_host_u16 (mp->rmt_port),
19770 clib_net_to_host_u32 (mp->action_index), mp->tag);
19775 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19778 vat_main_t *vam = &vat_main;
19779 vat_json_node_t *node = NULL;
19780 struct in6_addr ip6;
19781 struct in_addr ip4;
19783 fib_prefix_t lcl, rmt;
19785 ip_prefix_decode (&mp->lcl, &lcl);
19786 ip_prefix_decode (&mp->rmt, &rmt);
19788 if (VAT_JSON_ARRAY != vam->json_tree.type)
19790 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19791 vat_json_init_array (&vam->json_tree);
19793 node = vat_json_array_add (&vam->json_tree);
19794 vat_json_init_object (node);
19796 vat_json_object_add_uint (node, "appns_index",
19797 clib_net_to_host_u32 (mp->appns_index));
19798 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19799 vat_json_object_add_uint (node, "scope", mp->scope);
19800 vat_json_object_add_uint (node, "action_index",
19801 clib_net_to_host_u32 (mp->action_index));
19802 vat_json_object_add_uint (node, "lcl_port",
19803 clib_net_to_host_u16 (mp->lcl_port));
19804 vat_json_object_add_uint (node, "rmt_port",
19805 clib_net_to_host_u16 (mp->rmt_port));
19806 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19807 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19808 vat_json_object_add_string_copy (node, "tag", mp->tag);
19809 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19811 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19812 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19813 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19814 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19818 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19819 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19820 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19821 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19826 api_session_rule_add_del (vat_main_t * vam)
19828 vl_api_session_rule_add_del_t *mp;
19829 unformat_input_t *i = vam->input;
19830 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19831 u32 appns_index = 0, scope = 0;
19832 ip4_address_t lcl_ip4, rmt_ip4;
19833 ip6_address_t lcl_ip6, rmt_ip6;
19834 u8 is_ip4 = 1, conn_set = 0;
19835 u8 is_add = 1, *tag = 0;
19837 fib_prefix_t lcl, rmt;
19839 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19841 if (unformat (i, "del"))
19843 else if (unformat (i, "add"))
19845 else if (unformat (i, "proto tcp"))
19847 else if (unformat (i, "proto udp"))
19849 else if (unformat (i, "appns %d", &appns_index))
19851 else if (unformat (i, "scope %d", &scope))
19853 else if (unformat (i, "tag %_%v%_", &tag))
19857 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19858 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19866 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19867 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19873 else if (unformat (i, "action %d", &action))
19878 if (proto == ~0 || !conn_set || action == ~0)
19880 errmsg ("transport proto, connection and action must be set");
19886 errmsg ("scope should be 0-3");
19890 M (SESSION_RULE_ADD_DEL, mp);
19892 clib_memset (&lcl, 0, sizeof (lcl));
19893 clib_memset (&rmt, 0, sizeof (rmt));
19896 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19897 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19898 lcl.fp_len = lcl_plen;
19899 rmt.fp_len = rmt_plen;
19903 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19904 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19905 lcl.fp_len = lcl_plen;
19906 rmt.fp_len = rmt_plen;
19910 ip_prefix_encode (&lcl, &mp->lcl);
19911 ip_prefix_encode (&rmt, &mp->rmt);
19912 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19913 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19914 mp->transport_proto =
19915 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19916 mp->action_index = clib_host_to_net_u32 (action);
19917 mp->appns_index = clib_host_to_net_u32 (appns_index);
19919 mp->is_add = is_add;
19922 clib_memcpy (mp->tag, tag, vec_len (tag));
19932 api_session_rules_dump (vat_main_t * vam)
19934 vl_api_session_rules_dump_t *mp;
19935 vl_api_control_ping_t *mp_ping;
19938 if (!vam->json_output)
19940 print (vam->ofp, "%=20s", "Session Rules");
19943 M (SESSION_RULES_DUMP, mp);
19947 /* Use a control ping for synchronization */
19948 MPING (CONTROL_PING, mp_ping);
19951 /* Wait for a reply... */
19957 api_ip_container_proxy_add_del (vat_main_t * vam)
19959 vl_api_ip_container_proxy_add_del_t *mp;
19960 unformat_input_t *i = vam->input;
19961 u32 sw_if_index = ~0;
19962 vl_api_prefix_t pfx = { };
19966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19968 if (unformat (i, "del"))
19970 else if (unformat (i, "add"))
19972 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
19974 else if (unformat (i, "sw_if_index %u", &sw_if_index))
19979 if (sw_if_index == ~0 || pfx.len == 0)
19981 errmsg ("address and sw_if_index must be set");
19985 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
19987 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19988 mp->is_add = is_add;
19989 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
19997 api_qos_record_enable_disable (vat_main_t * vam)
19999 unformat_input_t *i = vam->input;
20000 vl_api_qos_record_enable_disable_t *mp;
20001 u32 sw_if_index, qs = 0xff;
20002 u8 sw_if_index_set = 0;
20006 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20008 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20009 sw_if_index_set = 1;
20010 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20011 sw_if_index_set = 1;
20012 else if (unformat (i, "%U", unformat_qos_source, &qs))
20014 else if (unformat (i, "disable"))
20018 clib_warning ("parse error '%U'", format_unformat_error, i);
20023 if (sw_if_index_set == 0)
20025 errmsg ("missing interface name or sw_if_index");
20030 errmsg ("input location must be specified");
20034 M (QOS_RECORD_ENABLE_DISABLE, mp);
20036 mp->record.sw_if_index = ntohl (sw_if_index);
20037 mp->record.input_source = qs;
20038 mp->enable = enable;
20047 q_or_quit (vat_main_t * vam)
20049 #if VPP_API_TEST_BUILTIN == 0
20050 longjmp (vam->jump_buf, 1);
20052 return 0; /* not so much */
20056 q (vat_main_t * vam)
20058 return q_or_quit (vam);
20062 quit (vat_main_t * vam)
20064 return q_or_quit (vam);
20068 comment (vat_main_t * vam)
20074 elog_save (vat_main_t * vam)
20076 #if VPP_API_TEST_BUILTIN == 0
20077 elog_main_t *em = &vam->elog_main;
20078 unformat_input_t *i = vam->input;
20079 char *file, *chroot_file;
20080 clib_error_t *error;
20082 if (!unformat (i, "%s", &file))
20084 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20088 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20089 if (strstr (file, "..") || index (file, '/'))
20091 errmsg ("illegal characters in filename '%s'", file);
20095 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20099 errmsg ("Saving %wd of %wd events to %s",
20100 elog_n_events_in_buffer (em),
20101 elog_buffer_capacity (em), chroot_file);
20103 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20104 vec_free (chroot_file);
20107 clib_error_report (error);
20109 errmsg ("Use the vpp event loger...");
20116 elog_setup (vat_main_t * vam)
20118 #if VPP_API_TEST_BUILTIN == 0
20119 elog_main_t *em = &vam->elog_main;
20120 unformat_input_t *i = vam->input;
20121 u32 nevents = 128 << 10;
20123 (void) unformat (i, "nevents %d", &nevents);
20125 elog_init (em, nevents);
20126 vl_api_set_elog_main (em);
20127 vl_api_set_elog_trace_api_messages (1);
20128 errmsg ("Event logger initialized with %u events", nevents);
20130 errmsg ("Use the vpp event loger...");
20136 elog_enable (vat_main_t * vam)
20138 #if VPP_API_TEST_BUILTIN == 0
20139 elog_main_t *em = &vam->elog_main;
20141 elog_enable_disable (em, 1 /* enable */ );
20142 vl_api_set_elog_trace_api_messages (1);
20143 errmsg ("Event logger enabled...");
20145 errmsg ("Use the vpp event loger...");
20151 elog_disable (vat_main_t * vam)
20153 #if VPP_API_TEST_BUILTIN == 0
20154 elog_main_t *em = &vam->elog_main;
20156 elog_enable_disable (em, 0 /* enable */ );
20157 vl_api_set_elog_trace_api_messages (1);
20158 errmsg ("Event logger disabled...");
20160 errmsg ("Use the vpp event loger...");
20166 statseg (vat_main_t * vam)
20168 ssvm_private_t *ssvmp = &vam->stat_segment;
20169 ssvm_shared_header_t *shared_header = ssvmp->sh;
20170 vlib_counter_t **counters;
20171 u64 thread0_index1_packets;
20172 u64 thread0_index1_bytes;
20173 f64 vector_rate, input_rate;
20176 uword *counter_vector_by_name;
20177 if (vam->stat_segment_lockp == 0)
20179 errmsg ("Stat segment not mapped...");
20183 /* look up "/if/rx for sw_if_index 1 as a test */
20185 clib_spinlock_lock (vam->stat_segment_lockp);
20187 counter_vector_by_name = (uword *) shared_header->opaque[1];
20189 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20192 clib_spinlock_unlock (vam->stat_segment_lockp);
20193 errmsg ("/if/tx not found?");
20197 /* Fish per-thread vector of combined counters from shared memory */
20198 counters = (vlib_counter_t **) p[0];
20200 if (vec_len (counters[0]) < 2)
20202 clib_spinlock_unlock (vam->stat_segment_lockp);
20203 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20207 /* Read thread 0 sw_if_index 1 counter */
20208 thread0_index1_packets = counters[0][1].packets;
20209 thread0_index1_bytes = counters[0][1].bytes;
20211 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20214 clib_spinlock_unlock (vam->stat_segment_lockp);
20215 errmsg ("vector_rate not found?");
20219 vector_rate = *(f64 *) (p[0]);
20220 p = hash_get_mem (counter_vector_by_name, "input_rate");
20223 clib_spinlock_unlock (vam->stat_segment_lockp);
20224 errmsg ("input_rate not found?");
20227 input_rate = *(f64 *) (p[0]);
20229 clib_spinlock_unlock (vam->stat_segment_lockp);
20231 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20232 vector_rate, input_rate);
20233 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20234 thread0_index1_packets, thread0_index1_bytes);
20240 cmd_cmp (void *a1, void *a2)
20245 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20249 help (vat_main_t * vam)
20254 unformat_input_t *i = vam->input;
20257 if (unformat (i, "%s", &name))
20261 vec_add1 (name, 0);
20263 hs = hash_get_mem (vam->help_by_name, name);
20265 print (vam->ofp, "usage: %s %s", name, hs[0]);
20267 print (vam->ofp, "No such msg / command '%s'", name);
20272 print (vam->ofp, "Help is available for the following:");
20275 hash_foreach_pair (p, vam->function_by_name,
20277 vec_add1 (cmds, (u8 *)(p->key));
20281 vec_sort_with_function (cmds, cmd_cmp);
20283 for (j = 0; j < vec_len (cmds); j++)
20284 print (vam->ofp, "%s", cmds[j]);
20291 set (vat_main_t * vam)
20293 u8 *name = 0, *value = 0;
20294 unformat_input_t *i = vam->input;
20296 if (unformat (i, "%s", &name))
20298 /* The input buffer is a vector, not a string. */
20299 value = vec_dup (i->buffer);
20300 vec_delete (value, i->index, 0);
20301 /* Almost certainly has a trailing newline */
20302 if (value[vec_len (value) - 1] == '\n')
20303 value[vec_len (value) - 1] = 0;
20304 /* Make sure it's a proper string, one way or the other */
20305 vec_add1 (value, 0);
20306 (void) clib_macro_set_value (&vam->macro_main,
20307 (char *) name, (char *) value);
20310 errmsg ("usage: set <name> <value>");
20318 unset (vat_main_t * vam)
20322 if (unformat (vam->input, "%s", &name))
20323 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20324 errmsg ("unset: %s wasn't set", name);
20337 macro_sort_cmp (void *a1, void *a2)
20339 macro_sort_t *s1 = a1;
20340 macro_sort_t *s2 = a2;
20342 return strcmp ((char *) (s1->name), (char *) (s2->name));
20346 dump_macro_table (vat_main_t * vam)
20348 macro_sort_t *sort_me = 0, *sm;
20353 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20355 vec_add2 (sort_me, sm, 1);
20356 sm->name = (u8 *)(p->key);
20357 sm->value = (u8 *) (p->value[0]);
20361 vec_sort_with_function (sort_me, macro_sort_cmp);
20363 if (vec_len (sort_me))
20364 print (vam->ofp, "%-15s%s", "Name", "Value");
20366 print (vam->ofp, "The macro table is empty...");
20368 for (i = 0; i < vec_len (sort_me); i++)
20369 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20374 dump_node_table (vat_main_t * vam)
20377 vlib_node_t *node, *next_node;
20379 if (vec_len (vam->graph_nodes) == 0)
20381 print (vam->ofp, "Node table empty, issue get_node_graph...");
20385 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20387 node = vam->graph_nodes[0][i];
20388 print (vam->ofp, "[%d] %s", i, node->name);
20389 for (j = 0; j < vec_len (node->next_nodes); j++)
20391 if (node->next_nodes[j] != ~0)
20393 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20394 print (vam->ofp, " [%d] %s", j, next_node->name);
20402 value_sort_cmp (void *a1, void *a2)
20404 name_sort_t *n1 = a1;
20405 name_sort_t *n2 = a2;
20407 if (n1->value < n2->value)
20409 if (n1->value > n2->value)
20416 dump_msg_api_table (vat_main_t * vam)
20418 api_main_t *am = vlibapi_get_main ();
20419 name_sort_t *nses = 0, *ns;
20424 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20426 vec_add2 (nses, ns, 1);
20427 ns->name = (u8 *)(hp->key);
20428 ns->value = (u32) hp->value[0];
20432 vec_sort_with_function (nses, value_sort_cmp);
20434 for (i = 0; i < vec_len (nses); i++)
20435 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20441 get_msg_id (vat_main_t * vam)
20446 if (unformat (vam->input, "%s", &name_and_crc))
20448 message_index = vl_msg_api_get_msg_index (name_and_crc);
20449 if (message_index == ~0)
20451 print (vam->ofp, " '%s' not found", name_and_crc);
20454 print (vam->ofp, " '%s' has message index %d",
20455 name_and_crc, message_index);
20458 errmsg ("name_and_crc required...");
20463 search_node_table (vat_main_t * vam)
20465 unformat_input_t *line_input = vam->input;
20468 vlib_node_t *node, *next_node;
20471 if (vam->graph_node_index_by_name == 0)
20473 print (vam->ofp, "Node table empty, issue get_node_graph...");
20477 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20479 if (unformat (line_input, "%s", &node_to_find))
20481 vec_add1 (node_to_find, 0);
20482 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20485 print (vam->ofp, "%s not found...", node_to_find);
20488 node = vam->graph_nodes[0][p[0]];
20489 print (vam->ofp, "[%d] %s", p[0], node->name);
20490 for (j = 0; j < vec_len (node->next_nodes); j++)
20492 if (node->next_nodes[j] != ~0)
20494 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20495 print (vam->ofp, " [%d] %s", j, next_node->name);
20502 clib_warning ("parse error '%U'", format_unformat_error,
20508 vec_free (node_to_find);
20517 script (vat_main_t * vam)
20519 #if (VPP_API_TEST_BUILTIN==0)
20521 char *save_current_file;
20522 unformat_input_t save_input;
20523 jmp_buf save_jump_buf;
20524 u32 save_line_number;
20526 FILE *new_fp, *save_ifp;
20528 if (unformat (vam->input, "%s", &s))
20530 new_fp = fopen ((char *) s, "r");
20533 errmsg ("Couldn't open script file %s", s);
20540 errmsg ("Missing script name");
20544 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20545 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20546 save_ifp = vam->ifp;
20547 save_line_number = vam->input_line_number;
20548 save_current_file = (char *) vam->current_file;
20550 vam->input_line_number = 0;
20552 vam->current_file = s;
20555 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20556 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20557 vam->ifp = save_ifp;
20558 vam->input_line_number = save_line_number;
20559 vam->current_file = (u8 *) save_current_file;
20564 clib_warning ("use the exec command...");
20570 echo (vat_main_t * vam)
20572 print (vam->ofp, "%v", vam->input->buffer);
20576 /* List of API message constructors, CLI names map to api_xxx */
20577 #define foreach_vpe_api_msg \
20578 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20579 _(sw_interface_dump,"") \
20580 _(sw_interface_set_flags, \
20581 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20582 _(sw_interface_add_del_address, \
20583 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20584 _(sw_interface_set_rx_mode, \
20585 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20586 _(sw_interface_set_rx_placement, \
20587 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20588 _(sw_interface_rx_placement_dump, \
20589 "[<intfc> | sw_if_index <id>]") \
20590 _(sw_interface_set_table, \
20591 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20592 _(sw_interface_set_mpls_enable, \
20593 "<intfc> | sw_if_index [disable | dis]") \
20594 _(sw_interface_set_vpath, \
20595 "<intfc> | sw_if_index <id> enable | disable") \
20596 _(sw_interface_set_vxlan_bypass, \
20597 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20598 _(sw_interface_set_geneve_bypass, \
20599 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20600 _(sw_interface_set_l2_xconnect, \
20601 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20602 "enable | disable") \
20603 _(sw_interface_set_l2_bridge, \
20604 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20605 "[shg <split-horizon-group>] [bvi]\n" \
20606 "enable | disable") \
20607 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20608 _(bridge_domain_add_del, \
20609 "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") \
20610 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20612 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20613 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20614 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20616 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20618 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20620 "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]") \
20622 "<vpp-if-name> | sw_if_index <id>") \
20623 _(sw_interface_tap_v2_dump, "") \
20624 _(virtio_pci_create, \
20625 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled | csum-offload-enabled]") \
20626 _(virtio_pci_delete, \
20627 "<vpp-if-name> | sw_if_index <id>") \
20628 _(sw_interface_virtio_pci_dump, "") \
20630 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20631 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20634 "<vpp-if-name> | sw_if_index <id>") \
20635 _(bond_add_member, \
20636 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20637 _(bond_detach_member, \
20638 "sw_if_index <n>") \
20639 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20640 _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
20641 _(sw_member_interface_dump, \
20642 "<vpp-if-name> | sw_if_index <id>") \
20643 _(ip_table_add_del, \
20644 "table <n> [ipv6] [add | del]\n") \
20645 _(ip_route_add_del, \
20646 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20647 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20648 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20649 "[multipath] [count <n>] [del]") \
20650 _(ip_mroute_add_del, \
20651 "<src> <grp>/<mask> [table-id <n>]\n" \
20652 "[<intfc> | sw_if_index <id>] [local] [del]") \
20653 _(mpls_table_add_del, \
20654 "table <n> [add | del]\n") \
20655 _(mpls_route_add_del, \
20656 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20657 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20658 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20659 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20660 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20661 "[count <n>] [del]") \
20662 _(mpls_ip_bind_unbind, \
20663 "<label> <addr/len>") \
20664 _(mpls_tunnel_add_del, \
20665 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20666 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20667 "[l2-only] [out-label <n>]") \
20668 _(sr_mpls_policy_add, \
20669 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20670 _(sr_mpls_policy_del, \
20672 _(bier_table_add_del, \
20673 "<label> <sub-domain> <set> <bsl> [del]") \
20674 _(bier_route_add_del, \
20675 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20676 "[<intfc> | sw_if_index <id>]" \
20677 "[weight <n>] [del] [multipath]") \
20678 _(sw_interface_set_unnumbered, \
20679 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20680 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20681 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20682 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20683 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20684 "[outer_vlan_id_any][inner_vlan_id_any]") \
20685 _(ip_table_replace_begin, "table <n> [ipv6]") \
20686 _(ip_table_flush, "table <n> [ipv6]") \
20687 _(ip_table_replace_end, "table <n> [ipv6]") \
20688 _(set_ip_flow_hash, \
20689 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20690 _(sw_interface_ip6_enable_disable, \
20691 "<intfc> | sw_if_index <id> enable | disable") \
20692 _(l2_patch_add_del, \
20693 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20694 "enable | disable") \
20695 _(sr_localsid_add_del, \
20696 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20697 "fib-table <num> (end.psp) sw_if_index <num>") \
20698 _(classify_add_del_table, \
20699 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20700 " [del] [del-chain] mask <mask-value>\n" \
20701 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20702 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20703 _(classify_add_del_session, \
20704 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20705 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20706 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20707 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20708 _(classify_set_interface_ip_table, \
20709 "<intfc> | sw_if_index <nn> table <nn>") \
20710 _(classify_set_interface_l2_tables, \
20711 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20712 " [other-table <nn>]") \
20713 _(get_node_index, "node <node-name") \
20714 _(add_node_next, "node <node-name> next <next-node-name>") \
20715 _(l2tpv3_create_tunnel, \
20716 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20717 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20718 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20719 _(l2tpv3_set_tunnel_cookies, \
20720 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20721 "[new_remote_cookie <nn>]\n") \
20722 _(l2tpv3_interface_enable_disable, \
20723 "<intfc> | sw_if_index <nn> enable | disable") \
20724 _(l2tpv3_set_lookup_key, \
20725 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20726 _(sw_if_l2tpv3_tunnel_dump, "") \
20727 _(vxlan_offload_rx, \
20728 "hw { <interface name> | hw_if_index <nn>} " \
20729 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20730 _(vxlan_add_del_tunnel, \
20731 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20732 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20733 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20734 _(geneve_add_del_tunnel, \
20735 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20736 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20737 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20738 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20739 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20740 _(gre_tunnel_add_del, \
20741 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20742 "[teb | erspan <session-id>] [del]") \
20743 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20744 _(l2_fib_clear_table, "") \
20745 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20746 _(l2_interface_vlan_tag_rewrite, \
20747 "<intfc> | sw_if_index <nn> \n" \
20748 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20749 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20750 _(create_vhost_user_if, \
20751 "socket <filename> [server] [renumber <dev_instance>] " \
20752 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20753 "[mac <mac_address>] [packed]") \
20754 _(modify_vhost_user_if, \
20755 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20756 "[server] [renumber <dev_instance>] [gso] [packed]") \
20757 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20758 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
20759 _(show_version, "") \
20760 _(show_threads, "") \
20761 _(vxlan_gpe_add_del_tunnel, \
20762 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20763 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20764 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20765 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20766 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20767 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20768 _(interface_name_renumber, \
20769 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20770 _(input_acl_set_interface, \
20771 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20772 " [l2-table <nn>] [del]") \
20773 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20774 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20775 _(ip_dump, "ipv4 | ipv6") \
20776 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20777 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20779 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20780 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20781 " integ_alg <alg> integ_key <hex>") \
20782 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20783 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20784 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20785 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20786 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20787 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20788 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20789 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20790 " [instance <n>]") \
20791 _(ipsec_sa_dump, "[sa_id <n>]") \
20792 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20793 _(delete_loopback,"sw_if_index <nn>") \
20794 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20795 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20796 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20797 _(want_interface_events, "enable|disable") \
20798 _(get_first_msg_id, "client <name>") \
20799 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20800 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20801 "fib-id <nn> [ip4][ip6][default]") \
20802 _(get_node_graph, " ") \
20803 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20804 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20805 _(ioam_disable, "") \
20806 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20807 " sw_if_index <sw_if_index> p <priority> " \
20808 "w <weight>] [del]") \
20809 _(one_add_del_locator, "locator-set <locator_name> " \
20810 "iface <intf> | sw_if_index <sw_if_index> " \
20811 "p <priority> w <weight> [del]") \
20812 _(one_add_del_local_eid,"vni <vni> eid " \
20813 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20814 "locator-set <locator_name> [del]" \
20815 "[key-id sha1|sha256 secret-key <secret-key>]")\
20816 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20817 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20818 _(one_enable_disable, "enable|disable") \
20819 _(one_map_register_enable_disable, "enable|disable") \
20820 _(one_map_register_fallback_threshold, "<value>") \
20821 _(one_rloc_probe_enable_disable, "enable|disable") \
20822 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20824 "rloc <locator> p <prio> " \
20825 "w <weight> [rloc <loc> ... ] " \
20826 "action <action> [del-all]") \
20827 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20829 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20830 _(one_use_petr, "ip-address> | disable") \
20831 _(one_map_request_mode, "src-dst|dst-only") \
20832 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20833 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20834 _(one_locator_set_dump, "[local | remote]") \
20835 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20836 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20837 "[local] | [remote]") \
20838 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20839 _(one_ndp_bd_get, "") \
20840 _(one_ndp_entries_get, "bd <bridge-domain>") \
20841 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20842 _(one_l2_arp_bd_get, "") \
20843 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20844 _(one_stats_enable_disable, "enable|disable") \
20845 _(show_one_stats_enable_disable, "") \
20846 _(one_eid_table_vni_dump, "") \
20847 _(one_eid_table_map_dump, "l2|l3") \
20848 _(one_map_resolver_dump, "") \
20849 _(one_map_server_dump, "") \
20850 _(one_adjacencies_get, "vni <vni>") \
20851 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20852 _(show_one_rloc_probe_state, "") \
20853 _(show_one_map_register_state, "") \
20854 _(show_one_status, "") \
20855 _(one_stats_dump, "") \
20856 _(one_stats_flush, "") \
20857 _(one_get_map_request_itr_rlocs, "") \
20858 _(one_map_register_set_ttl, "<ttl>") \
20859 _(one_set_transport_protocol, "udp|api") \
20860 _(one_get_transport_protocol, "") \
20861 _(one_enable_disable_xtr_mode, "enable|disable") \
20862 _(one_show_xtr_mode, "") \
20863 _(one_enable_disable_pitr_mode, "enable|disable") \
20864 _(one_show_pitr_mode, "") \
20865 _(one_enable_disable_petr_mode, "enable|disable") \
20866 _(one_show_petr_mode, "") \
20867 _(show_one_nsh_mapping, "") \
20868 _(show_one_pitr, "") \
20869 _(show_one_use_petr, "") \
20870 _(show_one_map_request_mode, "") \
20871 _(show_one_map_register_ttl, "") \
20872 _(show_one_map_register_fallback_threshold, "") \
20873 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20874 " sw_if_index <sw_if_index> p <priority> " \
20875 "w <weight>] [del]") \
20876 _(lisp_add_del_locator, "locator-set <locator_name> " \
20877 "iface <intf> | sw_if_index <sw_if_index> " \
20878 "p <priority> w <weight> [del]") \
20879 _(lisp_add_del_local_eid,"vni <vni> eid " \
20880 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20881 "locator-set <locator_name> [del]" \
20882 "[key-id sha1|sha256 secret-key <secret-key>]") \
20883 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20884 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20885 _(lisp_enable_disable, "enable|disable") \
20886 _(lisp_map_register_enable_disable, "enable|disable") \
20887 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20888 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20890 "rloc <locator> p <prio> " \
20891 "w <weight> [rloc <loc> ... ] " \
20892 "action <action> [del-all]") \
20893 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20895 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20896 _(lisp_use_petr, "<ip-address> | disable") \
20897 _(lisp_map_request_mode, "src-dst|dst-only") \
20898 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20899 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20900 _(lisp_locator_set_dump, "[local | remote]") \
20901 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20902 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20903 "[local] | [remote]") \
20904 _(lisp_eid_table_vni_dump, "") \
20905 _(lisp_eid_table_map_dump, "l2|l3") \
20906 _(lisp_map_resolver_dump, "") \
20907 _(lisp_map_server_dump, "") \
20908 _(lisp_adjacencies_get, "vni <vni>") \
20909 _(gpe_fwd_entry_vnis_get, "") \
20910 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20911 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20912 "[table <table-id>]") \
20913 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20914 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20915 _(gpe_set_encap_mode, "lisp|vxlan") \
20916 _(gpe_get_encap_mode, "") \
20917 _(lisp_gpe_add_del_iface, "up|down") \
20918 _(lisp_gpe_enable_disable, "enable|disable") \
20919 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20920 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20921 _(show_lisp_rloc_probe_state, "") \
20922 _(show_lisp_map_register_state, "") \
20923 _(show_lisp_status, "") \
20924 _(lisp_get_map_request_itr_rlocs, "") \
20925 _(show_lisp_pitr, "") \
20926 _(show_lisp_use_petr, "") \
20927 _(show_lisp_map_request_mode, "") \
20928 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20929 _(af_packet_delete, "name <host interface name>") \
20930 _(af_packet_dump, "") \
20931 _(policer_add_del, "name <policer name> <params> [del]") \
20932 _(policer_dump, "[name <policer name>]") \
20933 _(policer_classify_set_interface, \
20934 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20935 " [l2-table <nn>] [del]") \
20936 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20937 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20938 _(mpls_table_dump, "") \
20939 _(mpls_route_dump, "table-id <ID>") \
20940 _(classify_table_ids, "") \
20941 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20942 _(classify_table_info, "table_id <nn>") \
20943 _(classify_session_dump, "table_id <nn>") \
20944 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20945 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20946 "[template_interval <nn>] [udp_checksum]") \
20947 _(ipfix_exporter_dump, "") \
20948 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20949 _(ipfix_classify_stream_dump, "") \
20950 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20951 _(ipfix_classify_table_dump, "") \
20952 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20953 _(sw_interface_span_dump, "[l2]") \
20954 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20955 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20956 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20957 _(pg_enable_disable, "[stream <id>] disable") \
20958 _(ip_source_and_port_range_check_add_del, \
20959 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20960 _(ip_source_and_port_range_check_interface_add_del, \
20961 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20962 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20963 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20964 _(l2_interface_pbb_tag_rewrite, \
20965 "<intfc> | sw_if_index <nn> \n" \
20966 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20967 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20968 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20969 _(flow_classify_set_interface, \
20970 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20971 _(flow_classify_dump, "type [ip4|ip6]") \
20972 _(ip_table_dump, "") \
20973 _(ip_route_dump, "table-id [ip4|ip6]") \
20974 _(ip_mtable_dump, "") \
20975 _(ip_mroute_dump, "table-id [ip4|ip6]") \
20976 _(feature_enable_disable, "arc_name <arc_name> " \
20977 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20978 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
20979 "[enable | disable] ") \
20980 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20982 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
20983 "mac <mac-address> [del]") \
20984 _(l2_xconnect_dump, "") \
20985 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
20986 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20987 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20988 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20989 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20990 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
20991 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
20992 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
20993 _(sock_init_shm, "size <nnn>") \
20994 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
20995 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
20996 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
20997 _(session_rules_dump, "") \
20998 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
20999 _(output_acl_set_interface, \
21000 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
21001 " [l2-table <nn>] [del]") \
21002 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
21004 /* List of command functions, CLI names map directly to functions */
21005 #define foreach_cli_function \
21006 _(comment, "usage: comment <ignore-rest-of-line>") \
21007 _(dump_interface_table, "usage: dump_interface_table") \
21008 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
21009 _(dump_ipv4_table, "usage: dump_ipv4_table") \
21010 _(dump_ipv6_table, "usage: dump_ipv6_table") \
21011 _(dump_macro_table, "usage: dump_macro_table ") \
21012 _(dump_node_table, "usage: dump_node_table") \
21013 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21014 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21015 _(elog_disable, "usage: elog_disable") \
21016 _(elog_enable, "usage: elog_enable") \
21017 _(elog_save, "usage: elog_save <filename>") \
21018 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21019 _(echo, "usage: echo <message>") \
21020 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21021 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21022 _(help, "usage: help") \
21023 _(q, "usage: quit") \
21024 _(quit, "usage: quit") \
21025 _(search_node_table, "usage: search_node_table <name>...") \
21026 _(set, "usage: set <variable-name> <value>") \
21027 _(script, "usage: script <file-name>") \
21028 _(statseg, "usage: statseg") \
21029 _(unset, "usage: unset <variable-name>")
21032 static void vl_api_##n##_t_handler_uni \
21033 (vl_api_##n##_t * mp) \
21035 vat_main_t * vam = &vat_main; \
21036 if (vam->json_output) { \
21037 vl_api_##n##_t_handler_json(mp); \
21039 vl_api_##n##_t_handler(mp); \
21042 foreach_vpe_api_reply_msg;
21043 #if VPP_API_TEST_BUILTIN == 0
21044 foreach_standalone_reply_msg;
21049 vat_api_hookup (vat_main_t * vam)
21052 vl_msg_api_set_handlers(VL_API_##N, #n, \
21053 vl_api_##n##_t_handler_uni, \
21055 vl_api_##n##_t_endian, \
21056 vl_api_##n##_t_print, \
21057 sizeof(vl_api_##n##_t), 1);
21058 foreach_vpe_api_reply_msg;
21059 #if VPP_API_TEST_BUILTIN == 0
21060 foreach_standalone_reply_msg;
21064 #if (VPP_API_TEST_BUILTIN==0)
21065 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21067 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21069 vam->function_by_name = hash_create_string (0, sizeof (uword));
21071 vam->help_by_name = hash_create_string (0, sizeof (uword));
21074 /* API messages we can send */
21075 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21076 foreach_vpe_api_msg;
21080 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21081 foreach_vpe_api_msg;
21084 /* CLI functions */
21085 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21086 foreach_cli_function;
21090 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21091 foreach_cli_function;
21095 #if VPP_API_TEST_BUILTIN
21096 static clib_error_t *
21097 vat_api_hookup_shim (vlib_main_t * vm)
21099 vat_api_hookup (&vat_main);
21103 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21107 * fd.io coding-style-patch-verification: ON
21110 * eval: (c-set-style "gnu")