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/vxlan/vxlan.h>
31 #include <vnet/vxlan-gpe/vxlan_gpe.h>
32 #include <vnet/udp/udp_local.h>
34 #include <vpp/api/vpe_msg_enum.h>
35 #include <vnet/l2/l2_classify.h>
36 #include <vnet/l2/l2_vtr.h>
37 #include <vnet/classify/in_out_acl.h>
38 #include <vnet/classify/policer_classify.h>
39 #include <vnet/classify/flow_classify.h>
40 #include <vnet/mpls/mpls.h>
41 #include <vnet/ipsec/ipsec.h>
43 #include <vnet/ip/ip6_hop_by_hop.h>
44 #include <vnet/ip/ip_source_and_port_range_check.h>
45 #include <vnet/policer/xlate.h>
46 #include <vnet/span/span.h>
47 #include <vnet/policer/policer.h>
48 #include <vnet/policer/police.h>
49 #include <vnet/mfib/mfib_types.h>
50 #include <vnet/bonding/node.h>
51 #include <vnet/qos/qos_types.h>
52 #include <vnet/ethernet/ethernet_types_api.h>
53 #include <vnet/ip/ip_types_api.h>
54 #include "vat/json_format.h"
55 #include <vnet/ip/ip_types_api.h>
56 #include <vnet/ethernet/ethernet_types_api.h>
61 #define vl_typedefs /* define message structures */
62 #include <vpp/api/vpe_all_api_h.h>
65 /* declare message handlers for each api */
67 #define vl_endianfun /* define message structures */
68 #include <vpp/api/vpe_all_api_h.h>
71 /* instantiate all the print functions we know about */
72 #if VPP_API_TEST_BUILTIN == 0
73 #define vl_print(handle, ...)
75 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
78 #include <vpp/api/vpe_all_api_h.h>
81 #define __plugin_msg_base 0
82 #include <vlibapi/vat_helper_macros.h>
84 #include <vnet/format_fns.h>
86 void vl_api_set_elog_main (elog_main_t * m);
87 int vl_api_set_elog_trace_api_messages (int enable);
89 #if VPP_API_TEST_BUILTIN == 0
99 vat_socket_connect (vat_main_t * vam)
102 api_main_t *am = vlibapi_get_main ();
103 vam->socket_client_main = &socket_client_main;
104 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
106 0 /* default socket rx, tx buffer */ )))
109 /* vpp expects the client index in network order */
110 vam->my_client_index = htonl (socket_client_main.client_index);
111 am->my_client_index = vam->my_client_index;
114 #else /* vpp built-in case, we don't do sockets... */
116 vat_socket_connect (vat_main_t * vam)
122 vl_socket_client_read (int wait)
128 vl_socket_client_write ()
134 vl_socket_client_msg_alloc (int nbytes)
142 vat_time_now (vat_main_t * vam)
144 #if VPP_API_TEST_BUILTIN
145 return vlib_time_now (vam->vlib_main);
147 return clib_time_now (&vam->clib_time);
152 errmsg (char *fmt, ...)
154 vat_main_t *vam = &vat_main;
159 s = va_format (0, fmt, &va);
164 #if VPP_API_TEST_BUILTIN
165 vlib_cli_output (vam->vlib_main, (char *) s);
168 if (vam->ifp != stdin)
169 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
170 vam->input_line_number);
172 fformat (vam->ofp, "%s\n", (char *) s);
180 #if VPP_API_TEST_BUILTIN == 0
182 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
184 vat_main_t *vam = va_arg (*args, vat_main_t *);
185 u32 *result = va_arg (*args, u32 *);
189 if (!unformat (input, "%s", &if_name))
192 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
200 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
205 /* Parse an IP4 address %d.%d.%d.%d. */
207 unformat_ip4_address (unformat_input_t * input, va_list * args)
209 u8 *result = va_arg (*args, u8 *);
212 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
215 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
227 unformat_ethernet_address (unformat_input_t * input, va_list * args)
229 u8 *result = va_arg (*args, u8 *);
232 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
233 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
237 for (i = 0; i < 6; i++)
238 if (a[i] >= (1 << 8))
241 for (i = 0; i < 6; i++)
247 /* Returns ethernet type as an int in host byte order. */
249 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
252 u16 *result = va_arg (*args, u16 *);
256 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
258 if (type >= (1 << 16))
266 /* Parse an IP46 address. */
268 unformat_ip46_address (unformat_input_t * input, va_list * args)
270 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
271 ip46_type_t type = va_arg (*args, ip46_type_t);
272 if ((type != IP46_TYPE_IP6) &&
273 unformat (input, "%U", unformat_ip4_address, &ip46->ip4))
275 ip46_address_mask_ip4 (ip46);
278 else if ((type != IP46_TYPE_IP4) &&
279 unformat (input, "%U", unformat_ip6_address, &ip46->ip6))
286 /* Parse an IP6 address. */
288 unformat_ip6_address (unformat_input_t * input, va_list * args)
290 ip6_address_t *result = va_arg (*args, ip6_address_t *);
292 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
293 uword c, n_colon, double_colon_index;
295 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
296 double_colon_index = ARRAY_LEN (hex_quads);
297 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
300 if (c >= '0' && c <= '9')
302 else if (c >= 'a' && c <= 'f')
303 hex_digit = c + 10 - 'a';
304 else if (c >= 'A' && c <= 'F')
305 hex_digit = c + 10 - 'A';
306 else if (c == ':' && n_colon < 2)
310 unformat_put_input (input);
314 /* Too many hex quads. */
315 if (n_hex_quads >= ARRAY_LEN (hex_quads))
320 hex_quad = (hex_quad << 4) | hex_digit;
322 /* Hex quad must fit in 16 bits. */
323 if (n_hex_digits >= 4)
330 /* Save position of :: */
333 /* More than one :: ? */
334 if (double_colon_index < ARRAY_LEN (hex_quads))
336 double_colon_index = n_hex_quads;
339 if (n_colon > 0 && n_hex_digits > 0)
341 hex_quads[n_hex_quads++] = hex_quad;
347 if (n_hex_digits > 0)
348 hex_quads[n_hex_quads++] = hex_quad;
353 /* Expand :: to appropriate number of zero hex quads. */
354 if (double_colon_index < ARRAY_LEN (hex_quads))
356 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
358 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
359 hex_quads[n_zero + i] = hex_quads[i];
361 for (i = 0; i < n_zero; i++)
362 hex_quads[double_colon_index + i] = 0;
364 n_hex_quads = ARRAY_LEN (hex_quads);
367 /* Too few hex quads given. */
368 if (n_hex_quads < ARRAY_LEN (hex_quads))
371 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
372 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
379 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
381 u32 *r = va_arg (*args, u32 *);
384 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
385 foreach_ipsec_policy_action
393 format_ipsec_crypto_alg (u8 * s, va_list * args)
395 u32 i = va_arg (*args, u32);
400 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
401 foreach_ipsec_crypto_alg
404 return format (s, "unknown");
406 return format (s, "%s", t);
410 format_ipsec_integ_alg (u8 * s, va_list * args)
412 u32 i = va_arg (*args, u32);
417 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
418 foreach_ipsec_integ_alg
421 return format (s, "unknown");
423 return format (s, "%s", t);
426 #else /* VPP_API_TEST_BUILTIN == 1 */
428 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
430 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
431 vnet_main_t *vnm = vnet_get_main ();
432 u32 *result = va_arg (*args, u32 *);
434 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
438 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
440 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
441 vnet_main_t *vnm = vnet_get_main ();
442 u32 *result = va_arg (*args, u32 *);
444 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
447 #endif /* VPP_API_TEST_BUILTIN */
450 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
452 u32 *r = va_arg (*args, u32 *);
455 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
456 foreach_ipsec_crypto_alg
464 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
466 u32 *r = va_arg (*args, u32 *);
469 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
470 foreach_ipsec_integ_alg
478 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
480 u8 *r = va_arg (*args, u8 *);
482 if (unformat (input, "kbps"))
483 *r = SSE2_QOS_RATE_KBPS;
484 else if (unformat (input, "pps"))
485 *r = SSE2_QOS_RATE_PPS;
492 unformat_policer_round_type (unformat_input_t * input, va_list * args)
494 u8 *r = va_arg (*args, u8 *);
496 if (unformat (input, "closest"))
497 *r = SSE2_QOS_ROUND_TO_CLOSEST;
498 else if (unformat (input, "up"))
499 *r = SSE2_QOS_ROUND_TO_UP;
500 else if (unformat (input, "down"))
501 *r = SSE2_QOS_ROUND_TO_DOWN;
508 unformat_policer_type (unformat_input_t * input, va_list * args)
510 u8 *r = va_arg (*args, u8 *);
512 if (unformat (input, "1r2c"))
513 *r = SSE2_QOS_POLICER_TYPE_1R2C;
514 else if (unformat (input, "1r3c"))
515 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
516 else if (unformat (input, "2r3c-2698"))
517 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
518 else if (unformat (input, "2r3c-4115"))
519 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
520 else if (unformat (input, "2r3c-mef5cf1"))
521 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
528 unformat_dscp (unformat_input_t * input, va_list * va)
530 u8 *r = va_arg (*va, u8 *);
533 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
542 unformat_policer_action_type (unformat_input_t * input, va_list * va)
544 sse2_qos_pol_action_params_st *a
545 = va_arg (*va, sse2_qos_pol_action_params_st *);
547 if (unformat (input, "drop"))
548 a->action_type = SSE2_QOS_ACTION_DROP;
549 else if (unformat (input, "transmit"))
550 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
551 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
552 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
559 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
561 u32 *r = va_arg (*va, u32 *);
564 if (unformat (input, "ip4"))
565 tid = POLICER_CLASSIFY_TABLE_IP4;
566 else if (unformat (input, "ip6"))
567 tid = POLICER_CLASSIFY_TABLE_IP6;
568 else if (unformat (input, "l2"))
569 tid = POLICER_CLASSIFY_TABLE_L2;
578 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
580 u32 *r = va_arg (*va, u32 *);
583 if (unformat (input, "ip4"))
584 tid = FLOW_CLASSIFY_TABLE_IP4;
585 else if (unformat (input, "ip6"))
586 tid = FLOW_CLASSIFY_TABLE_IP6;
594 #if (VPP_API_TEST_BUILTIN==0)
596 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
597 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
598 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
599 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
602 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
604 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
605 mfib_itf_attribute_t attr;
608 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
610 if (unformat (input, mfib_itf_flag_long_names[attr]))
611 *iflags |= (1 << attr);
613 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
615 if (unformat (input, mfib_itf_flag_names[attr]))
616 *iflags |= (1 << attr);
619 return (old == *iflags ? 0 : 1);
623 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
625 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
626 mfib_entry_attribute_t attr;
629 FOR_EACH_MFIB_ATTRIBUTE (attr)
631 if (unformat (input, mfib_flag_long_names[attr]))
632 *eflags |= (1 << attr);
634 FOR_EACH_MFIB_ATTRIBUTE (attr)
636 if (unformat (input, mfib_flag_names[attr]))
637 *eflags |= (1 << attr);
640 return (old == *eflags ? 0 : 1);
644 format_ip4_address (u8 * s, va_list * args)
646 u8 *a = va_arg (*args, u8 *);
647 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
651 format_ip6_address (u8 * s, va_list * args)
653 ip6_address_t *a = va_arg (*args, ip6_address_t *);
654 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
656 i_max_n_zero = ARRAY_LEN (a->as_u16);
658 i_first_zero = i_max_n_zero;
660 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
662 u32 is_zero = a->as_u16[i] == 0;
663 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
669 if ((!is_zero && n_zeros > max_n_zeros)
670 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
672 i_max_n_zero = i_first_zero;
673 max_n_zeros = n_zeros;
674 i_first_zero = ARRAY_LEN (a->as_u16);
679 last_double_colon = 0;
680 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
682 if (i == i_max_n_zero && max_n_zeros > 1)
684 s = format (s, "::");
685 i += max_n_zeros - 1;
686 last_double_colon = 1;
690 s = format (s, "%s%x",
691 (last_double_colon || i == 0) ? "" : ":",
692 clib_net_to_host_u16 (a->as_u16[i]));
693 last_double_colon = 0;
700 /* Format an IP46 address. */
702 format_ip46_address (u8 * s, va_list * args)
704 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
705 ip46_type_t type = va_arg (*args, ip46_type_t);
711 is_ip4 = ip46_address_is_ip4 (ip46);
722 format (s, "%U", format_ip4_address, &ip46->ip4) :
723 format (s, "%U", format_ip6_address, &ip46->ip6);
727 format_ethernet_address (u8 * s, va_list * args)
729 u8 *a = va_arg (*args, u8 *);
731 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
732 a[0], a[1], a[2], a[3], a[4], a[5]);
737 increment_v4_address (vl_api_ip4_address_t * i)
739 ip4_address_t *a = (ip4_address_t *) i;
742 v = ntohl (a->as_u32) + 1;
743 a->as_u32 = ntohl (v);
747 increment_v6_address (vl_api_ip6_address_t * i)
749 ip6_address_t *a = (ip6_address_t *) i;
752 v0 = clib_net_to_host_u64 (a->as_u64[0]);
753 v1 = clib_net_to_host_u64 (a->as_u64[1]);
758 a->as_u64[0] = clib_net_to_host_u64 (v0);
759 a->as_u64[1] = clib_net_to_host_u64 (v1);
763 increment_address (vl_api_address_t * a)
765 if (a->af == ADDRESS_IP4)
766 increment_v4_address (&a->un.ip4);
767 else if (a->af == ADDRESS_IP6)
768 increment_v6_address (&a->un.ip6);
772 set_ip4_address (vl_api_address_t * a, u32 v)
774 if (a->af == ADDRESS_IP4)
776 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
782 ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
785 dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
787 clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
788 sizeof (ip6_address_t));
792 increment_mac_address (u8 * mac)
794 u64 tmp = *((u64 *) mac);
795 tmp = clib_net_to_host_u64 (tmp);
796 tmp += 1 << 16; /* skip unused (least significant) octets */
797 tmp = clib_host_to_net_u64 (tmp);
799 clib_memcpy (mac, &tmp, 6);
803 vat_json_object_add_address (vat_json_node_t * node,
804 const char *str, const vl_api_address_t * addr)
806 if (ADDRESS_IP6 == addr->af)
810 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
811 vat_json_object_add_ip6 (node, str, ip6);
817 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
818 vat_json_object_add_ip4 (node, str, ip4);
823 vat_json_object_add_prefix (vat_json_node_t * node,
824 const vl_api_prefix_t * prefix)
826 vat_json_object_add_uint (node, "len", prefix->len);
827 vat_json_object_add_address (node, "address", &prefix->address);
830 static void vl_api_create_loopback_reply_t_handler
831 (vl_api_create_loopback_reply_t * mp)
833 vat_main_t *vam = &vat_main;
834 i32 retval = ntohl (mp->retval);
836 vam->retval = retval;
837 vam->regenerate_interface_table = 1;
838 vam->sw_if_index = ntohl (mp->sw_if_index);
839 vam->result_ready = 1;
842 static void vl_api_create_loopback_reply_t_handler_json
843 (vl_api_create_loopback_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 vat_json_node_t node;
848 vat_json_init_object (&node);
849 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
850 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
852 vat_json_print (vam->ofp, &node);
853 vat_json_free (&node);
854 vam->retval = ntohl (mp->retval);
855 vam->result_ready = 1;
858 static void vl_api_create_loopback_instance_reply_t_handler
859 (vl_api_create_loopback_instance_reply_t * mp)
861 vat_main_t *vam = &vat_main;
862 i32 retval = ntohl (mp->retval);
864 vam->retval = retval;
865 vam->regenerate_interface_table = 1;
866 vam->sw_if_index = ntohl (mp->sw_if_index);
867 vam->result_ready = 1;
870 static void vl_api_create_loopback_instance_reply_t_handler_json
871 (vl_api_create_loopback_instance_reply_t * mp)
873 vat_main_t *vam = &vat_main;
874 vat_json_node_t node;
876 vat_json_init_object (&node);
877 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
878 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
880 vat_json_print (vam->ofp, &node);
881 vat_json_free (&node);
882 vam->retval = ntohl (mp->retval);
883 vam->result_ready = 1;
886 static void vl_api_af_packet_create_reply_t_handler
887 (vl_api_af_packet_create_reply_t * mp)
889 vat_main_t *vam = &vat_main;
890 i32 retval = ntohl (mp->retval);
892 vam->retval = retval;
893 vam->regenerate_interface_table = 1;
894 vam->sw_if_index = ntohl (mp->sw_if_index);
895 vam->result_ready = 1;
898 static void vl_api_af_packet_create_reply_t_handler_json
899 (vl_api_af_packet_create_reply_t * mp)
901 vat_main_t *vam = &vat_main;
902 vat_json_node_t node;
904 vat_json_init_object (&node);
905 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
906 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
908 vat_json_print (vam->ofp, &node);
909 vat_json_free (&node);
911 vam->retval = ntohl (mp->retval);
912 vam->result_ready = 1;
915 static void vl_api_create_vlan_subif_reply_t_handler
916 (vl_api_create_vlan_subif_reply_t * mp)
918 vat_main_t *vam = &vat_main;
919 i32 retval = ntohl (mp->retval);
921 vam->retval = retval;
922 vam->regenerate_interface_table = 1;
923 vam->sw_if_index = ntohl (mp->sw_if_index);
924 vam->result_ready = 1;
927 static void vl_api_create_vlan_subif_reply_t_handler_json
928 (vl_api_create_vlan_subif_reply_t * mp)
930 vat_main_t *vam = &vat_main;
931 vat_json_node_t node;
933 vat_json_init_object (&node);
934 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
935 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
937 vat_json_print (vam->ofp, &node);
938 vat_json_free (&node);
940 vam->retval = ntohl (mp->retval);
941 vam->result_ready = 1;
944 static void vl_api_create_subif_reply_t_handler
945 (vl_api_create_subif_reply_t * mp)
947 vat_main_t *vam = &vat_main;
948 i32 retval = ntohl (mp->retval);
950 vam->retval = retval;
951 vam->regenerate_interface_table = 1;
952 vam->sw_if_index = ntohl (mp->sw_if_index);
953 vam->result_ready = 1;
956 static void vl_api_create_subif_reply_t_handler_json
957 (vl_api_create_subif_reply_t * mp)
959 vat_main_t *vam = &vat_main;
960 vat_json_node_t node;
962 vat_json_init_object (&node);
963 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
964 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
966 vat_json_print (vam->ofp, &node);
967 vat_json_free (&node);
969 vam->retval = ntohl (mp->retval);
970 vam->result_ready = 1;
973 static void vl_api_interface_name_renumber_reply_t_handler
974 (vl_api_interface_name_renumber_reply_t * mp)
976 vat_main_t *vam = &vat_main;
977 i32 retval = ntohl (mp->retval);
979 vam->retval = retval;
980 vam->regenerate_interface_table = 1;
981 vam->result_ready = 1;
984 static void vl_api_interface_name_renumber_reply_t_handler_json
985 (vl_api_interface_name_renumber_reply_t * mp)
987 vat_main_t *vam = &vat_main;
988 vat_json_node_t node;
990 vat_json_init_object (&node);
991 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
993 vat_json_print (vam->ofp, &node);
994 vat_json_free (&node);
996 vam->retval = ntohl (mp->retval);
997 vam->result_ready = 1;
1001 * Special-case: build the interface table, maintain
1002 * the next loopback sw_if_index vbl.
1004 static void vl_api_sw_interface_details_t_handler
1005 (vl_api_sw_interface_details_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 u8 *s = format (0, "%s%c", mp->interface_name, 0);
1010 hash_set_mem (vam->sw_if_index_by_interface_name, s,
1011 ntohl (mp->sw_if_index));
1013 /* In sub interface case, fill the sub interface table entry */
1014 if (mp->sw_if_index != mp->sup_sw_if_index)
1016 sw_interface_subif_t *sub = NULL;
1018 vec_add2 (vam->sw_if_subif_table, sub, 1);
1020 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
1021 strncpy ((char *) sub->interface_name, (char *) s,
1022 vec_len (sub->interface_name));
1023 sub->sw_if_index = ntohl (mp->sw_if_index);
1024 sub->sub_id = ntohl (mp->sub_id);
1026 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1028 sub->sub_number_of_tags = mp->sub_number_of_tags;
1029 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1030 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1032 /* vlan tag rewrite */
1033 sub->vtr_op = ntohl (mp->vtr_op);
1034 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1035 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1036 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1040 static void vl_api_sw_interface_details_t_handler_json
1041 (vl_api_sw_interface_details_t * mp)
1043 vat_main_t *vam = &vat_main;
1044 vat_json_node_t *node = NULL;
1046 if (VAT_JSON_ARRAY != vam->json_tree.type)
1048 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1049 vat_json_init_array (&vam->json_tree);
1051 node = vat_json_array_add (&vam->json_tree);
1053 vat_json_init_object (node);
1054 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1055 vat_json_object_add_uint (node, "sup_sw_if_index",
1056 ntohl (mp->sup_sw_if_index));
1057 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1058 sizeof (mp->l2_address));
1059 vat_json_object_add_string_copy (node, "interface_name",
1060 mp->interface_name);
1061 vat_json_object_add_string_copy (node, "interface_dev_type",
1062 mp->interface_dev_type);
1063 vat_json_object_add_uint (node, "flags", mp->flags);
1064 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1065 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1066 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1067 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1068 vat_json_object_add_uint (node, "sub_number_of_tags",
1069 mp->sub_number_of_tags);
1070 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1071 ntohs (mp->sub_outer_vlan_id));
1072 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1073 ntohs (mp->sub_inner_vlan_id));
1074 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1075 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1076 vat_json_object_add_uint (node, "vtr_push_dot1q",
1077 ntohl (mp->vtr_push_dot1q));
1078 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1079 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1080 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1082 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1084 format_ethernet_address,
1086 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1088 format_ethernet_address,
1090 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1091 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1095 #if VPP_API_TEST_BUILTIN == 0
1096 static void vl_api_sw_interface_event_t_handler
1097 (vl_api_sw_interface_event_t * mp)
1099 vat_main_t *vam = &vat_main;
1100 if (vam->interface_event_display)
1101 errmsg ("interface flags: sw_if_index %d %s %s",
1102 ntohl (mp->sw_if_index),
1103 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1104 "admin-up" : "admin-down",
1105 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1106 "link-up" : "link-down");
1110 __clib_unused static void
1111 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1113 /* JSON output not supported */
1117 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1119 vat_main_t *vam = &vat_main;
1120 i32 retval = ntohl (mp->retval);
1122 vam->retval = retval;
1123 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1124 vam->result_ready = 1;
1128 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1130 vat_main_t *vam = &vat_main;
1131 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "reply_in_shmem",
1138 ntohl (mp->reply_in_shmem));
1139 /* Toss the shared-memory original... */
1140 oldheap = vl_msg_push_heap ();
1142 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1145 vl_msg_pop_heap (oldheap);
1147 vat_json_print (vam->ofp, &node);
1148 vat_json_free (&node);
1150 vam->retval = ntohl (mp->retval);
1151 vam->result_ready = 1;
1155 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1157 vat_main_t *vam = &vat_main;
1158 i32 retval = ntohl (mp->retval);
1160 vec_reset_length (vam->cmd_reply);
1162 vam->retval = retval;
1164 vam->cmd_reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1165 vam->result_ready = 1;
1169 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1171 vat_main_t *vam = &vat_main;
1172 vat_json_node_t node;
1173 u8 *reply = 0; /* reply vector */
1175 reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1176 vec_reset_length (vam->cmd_reply);
1178 vat_json_init_object (&node);
1179 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1180 vat_json_object_add_string_copy (&node, "reply", reply);
1182 vat_json_print (vam->ofp, &node);
1183 vat_json_free (&node);
1186 vam->retval = ntohl (mp->retval);
1187 vam->result_ready = 1;
1190 static void vl_api_classify_add_del_table_reply_t_handler
1191 (vl_api_classify_add_del_table_reply_t * mp)
1193 vat_main_t *vam = &vat_main;
1194 i32 retval = ntohl (mp->retval);
1195 if (vam->async_mode)
1197 vam->async_errors += (retval < 0);
1201 vam->retval = retval;
1203 ((mp->new_table_index != 0xFFFFFFFF) ||
1204 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1205 (mp->match_n_vectors != 0xFFFFFFFF)))
1207 * Note: this is just barely thread-safe, depends on
1208 * the main thread spinning waiting for an answer...
1210 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1211 ntohl (mp->new_table_index),
1212 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1213 vam->result_ready = 1;
1217 static void vl_api_classify_add_del_table_reply_t_handler_json
1218 (vl_api_classify_add_del_table_reply_t * mp)
1220 vat_main_t *vam = &vat_main;
1221 vat_json_node_t node;
1223 vat_json_init_object (&node);
1224 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1225 vat_json_object_add_uint (&node, "new_table_index",
1226 ntohl (mp->new_table_index));
1227 vat_json_object_add_uint (&node, "skip_n_vectors",
1228 ntohl (mp->skip_n_vectors));
1229 vat_json_object_add_uint (&node, "match_n_vectors",
1230 ntohl (mp->match_n_vectors));
1232 vat_json_print (vam->ofp, &node);
1233 vat_json_free (&node);
1235 vam->retval = ntohl (mp->retval);
1236 vam->result_ready = 1;
1239 static void vl_api_get_node_index_reply_t_handler
1240 (vl_api_get_node_index_reply_t * mp)
1242 vat_main_t *vam = &vat_main;
1243 i32 retval = ntohl (mp->retval);
1244 if (vam->async_mode)
1246 vam->async_errors += (retval < 0);
1250 vam->retval = retval;
1252 errmsg ("node index %d", ntohl (mp->node_index));
1253 vam->result_ready = 1;
1257 static void vl_api_get_node_index_reply_t_handler_json
1258 (vl_api_get_node_index_reply_t * mp)
1260 vat_main_t *vam = &vat_main;
1261 vat_json_node_t node;
1263 vat_json_init_object (&node);
1264 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1265 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1267 vat_json_print (vam->ofp, &node);
1268 vat_json_free (&node);
1270 vam->retval = ntohl (mp->retval);
1271 vam->result_ready = 1;
1274 static void vl_api_get_next_index_reply_t_handler
1275 (vl_api_get_next_index_reply_t * mp)
1277 vat_main_t *vam = &vat_main;
1278 i32 retval = ntohl (mp->retval);
1279 if (vam->async_mode)
1281 vam->async_errors += (retval < 0);
1285 vam->retval = retval;
1287 errmsg ("next node index %d", ntohl (mp->next_index));
1288 vam->result_ready = 1;
1292 static void vl_api_get_next_index_reply_t_handler_json
1293 (vl_api_get_next_index_reply_t * mp)
1295 vat_main_t *vam = &vat_main;
1296 vat_json_node_t node;
1298 vat_json_init_object (&node);
1299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1300 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1302 vat_json_print (vam->ofp, &node);
1303 vat_json_free (&node);
1305 vam->retval = ntohl (mp->retval);
1306 vam->result_ready = 1;
1309 static void vl_api_add_node_next_reply_t_handler
1310 (vl_api_add_node_next_reply_t * mp)
1312 vat_main_t *vam = &vat_main;
1313 i32 retval = ntohl (mp->retval);
1314 if (vam->async_mode)
1316 vam->async_errors += (retval < 0);
1320 vam->retval = retval;
1322 errmsg ("next index %d", ntohl (mp->next_index));
1323 vam->result_ready = 1;
1327 static void vl_api_add_node_next_reply_t_handler_json
1328 (vl_api_add_node_next_reply_t * mp)
1330 vat_main_t *vam = &vat_main;
1331 vat_json_node_t node;
1333 vat_json_init_object (&node);
1334 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1335 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1337 vat_json_print (vam->ofp, &node);
1338 vat_json_free (&node);
1340 vam->retval = ntohl (mp->retval);
1341 vam->result_ready = 1;
1344 static void vl_api_show_version_reply_t_handler
1345 (vl_api_show_version_reply_t * mp)
1347 vat_main_t *vam = &vat_main;
1348 i32 retval = ntohl (mp->retval);
1352 errmsg (" program: %s", mp->program);
1353 errmsg (" version: %s", mp->version);
1354 errmsg (" build date: %s", mp->build_date);
1355 errmsg ("build directory: %s", mp->build_directory);
1357 vam->retval = retval;
1358 vam->result_ready = 1;
1361 static void vl_api_show_version_reply_t_handler_json
1362 (vl_api_show_version_reply_t * mp)
1364 vat_main_t *vam = &vat_main;
1365 vat_json_node_t node;
1367 vat_json_init_object (&node);
1368 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1369 vat_json_object_add_string_copy (&node, "program", mp->program);
1370 vat_json_object_add_string_copy (&node, "version", mp->version);
1371 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1372 vat_json_object_add_string_copy (&node, "build_directory",
1373 mp->build_directory);
1375 vat_json_print (vam->ofp, &node);
1376 vat_json_free (&node);
1378 vam->retval = ntohl (mp->retval);
1379 vam->result_ready = 1;
1382 static void vl_api_show_threads_reply_t_handler
1383 (vl_api_show_threads_reply_t * mp)
1385 vat_main_t *vam = &vat_main;
1386 i32 retval = ntohl (mp->retval);
1390 count = ntohl (mp->count);
1392 for (i = 0; i < count; i++)
1394 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1395 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1396 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1397 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1398 ntohl (mp->thread_data[i].cpu_socket));
1400 vam->retval = retval;
1401 vam->result_ready = 1;
1404 static void vl_api_show_threads_reply_t_handler_json
1405 (vl_api_show_threads_reply_t * mp)
1407 vat_main_t *vam = &vat_main;
1408 vat_json_node_t node;
1409 vl_api_thread_data_t *td;
1410 i32 retval = ntohl (mp->retval);
1414 count = ntohl (mp->count);
1416 vat_json_init_object (&node);
1417 vat_json_object_add_int (&node, "retval", retval);
1418 vat_json_object_add_uint (&node, "count", count);
1420 for (i = 0; i < count; i++)
1422 td = &mp->thread_data[i];
1423 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1424 vat_json_object_add_string_copy (&node, "name", td->name);
1425 vat_json_object_add_string_copy (&node, "type", td->type);
1426 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1427 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1428 vat_json_object_add_int (&node, "core", ntohl (td->id));
1429 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1432 vat_json_print (vam->ofp, &node);
1433 vat_json_free (&node);
1435 vam->retval = retval;
1436 vam->result_ready = 1;
1440 api_show_threads (vat_main_t * vam)
1442 vl_api_show_threads_t *mp;
1446 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1447 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1449 M (SHOW_THREADS, mp);
1457 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1459 u32 n_macs = ntohl (mp->n_macs);
1460 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1461 ntohl (mp->pid), mp->client_index, n_macs);
1463 for (i = 0; i < n_macs; i++)
1465 vl_api_mac_entry_t *mac = &mp->mac[i];
1466 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1467 i + 1, ntohl (mac->sw_if_index),
1468 format_ethernet_address, mac->mac_addr, mac->action);
1475 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1477 /* JSON output not supported */
1480 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1481 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1484 * Special-case: build the bridge domain table, maintain
1485 * the next bd id vbl.
1487 static void vl_api_bridge_domain_details_t_handler
1488 (vl_api_bridge_domain_details_t * mp)
1490 vat_main_t *vam = &vat_main;
1491 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1494 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1495 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1497 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1498 ntohl (mp->bd_id), mp->learn, mp->forward,
1499 mp->flood, ntohl (mp->bvi_sw_if_index),
1500 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1504 vl_api_bridge_domain_sw_if_t *sw_ifs;
1505 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1508 sw_ifs = mp->sw_if_details;
1509 for (i = 0; i < n_sw_ifs; i++)
1515 sw_if_index = ntohl (sw_ifs->sw_if_index);
1518 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1520 if ((u32) p->value[0] == sw_if_index)
1522 sw_if_name = (u8 *)(p->key);
1527 print (vam->ofp, "%7d %3d %s", sw_if_index,
1528 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1529 "sw_if_index not found!");
1536 static void vl_api_bridge_domain_details_t_handler_json
1537 (vl_api_bridge_domain_details_t * mp)
1539 vat_main_t *vam = &vat_main;
1540 vat_json_node_t *node, *array = NULL;
1541 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1543 if (VAT_JSON_ARRAY != vam->json_tree.type)
1545 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1546 vat_json_init_array (&vam->json_tree);
1548 node = vat_json_array_add (&vam->json_tree);
1550 vat_json_init_object (node);
1551 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1552 vat_json_object_add_uint (node, "flood", mp->flood);
1553 vat_json_object_add_uint (node, "forward", mp->forward);
1554 vat_json_object_add_uint (node, "learn", mp->learn);
1555 vat_json_object_add_uint (node, "bvi_sw_if_index",
1556 ntohl (mp->bvi_sw_if_index));
1557 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1558 array = vat_json_object_add (node, "sw_if");
1559 vat_json_init_array (array);
1565 vl_api_bridge_domain_sw_if_t *sw_ifs;
1568 sw_ifs = mp->sw_if_details;
1569 for (i = 0; i < n_sw_ifs; i++)
1571 node = vat_json_array_add (array);
1572 vat_json_init_object (node);
1573 vat_json_object_add_uint (node, "sw_if_index",
1574 ntohl (sw_ifs->sw_if_index));
1575 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1581 static void vl_api_control_ping_reply_t_handler
1582 (vl_api_control_ping_reply_t * mp)
1584 vat_main_t *vam = &vat_main;
1585 i32 retval = ntohl (mp->retval);
1586 if (vam->async_mode)
1588 vam->async_errors += (retval < 0);
1592 vam->retval = retval;
1593 vam->result_ready = 1;
1595 if (vam->socket_client_main)
1596 vam->socket_client_main->control_pings_outstanding--;
1599 static void vl_api_control_ping_reply_t_handler_json
1600 (vl_api_control_ping_reply_t * mp)
1602 vat_main_t *vam = &vat_main;
1603 i32 retval = ntohl (mp->retval);
1605 if (VAT_JSON_NONE != vam->json_tree.type)
1607 vat_json_print (vam->ofp, &vam->json_tree);
1608 vat_json_free (&vam->json_tree);
1609 vam->json_tree.type = VAT_JSON_NONE;
1614 vat_json_init_array (&vam->json_tree);
1615 vat_json_print (vam->ofp, &vam->json_tree);
1616 vam->json_tree.type = VAT_JSON_NONE;
1619 vam->retval = retval;
1620 vam->result_ready = 1;
1624 vl_api_bridge_domain_set_mac_age_reply_t_handler
1625 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1627 vat_main_t *vam = &vat_main;
1628 i32 retval = ntohl (mp->retval);
1629 if (vam->async_mode)
1631 vam->async_errors += (retval < 0);
1635 vam->retval = retval;
1636 vam->result_ready = 1;
1640 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1641 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 vat_json_node_t node;
1646 vat_json_init_object (&node);
1647 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1649 vat_json_print (vam->ofp, &node);
1650 vat_json_free (&node);
1652 vam->retval = ntohl (mp->retval);
1653 vam->result_ready = 1;
1657 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1659 vat_main_t *vam = &vat_main;
1660 i32 retval = ntohl (mp->retval);
1661 if (vam->async_mode)
1663 vam->async_errors += (retval < 0);
1667 vam->retval = retval;
1668 vam->result_ready = 1;
1672 static void vl_api_l2_flags_reply_t_handler_json
1673 (vl_api_l2_flags_reply_t * mp)
1675 vat_main_t *vam = &vat_main;
1676 vat_json_node_t node;
1678 vat_json_init_object (&node);
1679 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1680 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1681 ntohl (mp->resulting_feature_bitmap));
1683 vat_json_print (vam->ofp, &node);
1684 vat_json_free (&node);
1686 vam->retval = ntohl (mp->retval);
1687 vam->result_ready = 1;
1690 static void vl_api_bridge_flags_reply_t_handler
1691 (vl_api_bridge_flags_reply_t * mp)
1693 vat_main_t *vam = &vat_main;
1694 i32 retval = ntohl (mp->retval);
1695 if (vam->async_mode)
1697 vam->async_errors += (retval < 0);
1701 vam->retval = retval;
1702 vam->result_ready = 1;
1706 static void vl_api_bridge_flags_reply_t_handler_json
1707 (vl_api_bridge_flags_reply_t * mp)
1709 vat_main_t *vam = &vat_main;
1710 vat_json_node_t node;
1712 vat_json_init_object (&node);
1713 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1714 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1715 ntohl (mp->resulting_feature_bitmap));
1717 vat_json_print (vam->ofp, &node);
1718 vat_json_free (&node);
1720 vam->retval = ntohl (mp->retval);
1721 vam->result_ready = 1;
1725 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1727 vat_main_t *vam = &vat_main;
1728 i32 retval = ntohl (mp->retval);
1729 if (vam->async_mode)
1731 vam->async_errors += (retval < 0);
1735 vam->retval = retval;
1736 vam->sw_if_index = ntohl (mp->sw_if_index);
1737 vam->result_ready = 1;
1742 static void vl_api_tap_create_v2_reply_t_handler_json
1743 (vl_api_tap_create_v2_reply_t * mp)
1745 vat_main_t *vam = &vat_main;
1746 vat_json_node_t node;
1748 vat_json_init_object (&node);
1749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1750 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1752 vat_json_print (vam->ofp, &node);
1753 vat_json_free (&node);
1755 vam->retval = ntohl (mp->retval);
1756 vam->result_ready = 1;
1761 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1763 vat_main_t *vam = &vat_main;
1764 i32 retval = ntohl (mp->retval);
1765 if (vam->async_mode)
1767 vam->async_errors += (retval < 0);
1771 vam->retval = retval;
1772 vam->result_ready = 1;
1776 static void vl_api_tap_delete_v2_reply_t_handler_json
1777 (vl_api_tap_delete_v2_reply_t * mp)
1779 vat_main_t *vam = &vat_main;
1780 vat_json_node_t node;
1782 vat_json_init_object (&node);
1783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1785 vat_json_print (vam->ofp, &node);
1786 vat_json_free (&node);
1788 vam->retval = ntohl (mp->retval);
1789 vam->result_ready = 1;
1793 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1796 vat_main_t *vam = &vat_main;
1797 i32 retval = ntohl (mp->retval);
1798 if (vam->async_mode)
1800 vam->async_errors += (retval < 0);
1804 vam->retval = retval;
1805 vam->sw_if_index = ntohl (mp->sw_if_index);
1806 vam->result_ready = 1;
1810 static void vl_api_virtio_pci_create_reply_t_handler_json
1811 (vl_api_virtio_pci_create_reply_t * mp)
1813 vat_main_t *vam = &vat_main;
1814 vat_json_node_t node;
1816 vat_json_init_object (&node);
1817 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1818 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1820 vat_json_print (vam->ofp, &node);
1821 vat_json_free (&node);
1823 vam->retval = ntohl (mp->retval);
1824 vam->result_ready = 1;
1829 vl_api_virtio_pci_create_v2_reply_t_handler
1830 (vl_api_virtio_pci_create_v2_reply_t * mp)
1832 vat_main_t *vam = &vat_main;
1833 i32 retval = ntohl (mp->retval);
1834 if (vam->async_mode)
1836 vam->async_errors += (retval < 0);
1840 vam->retval = retval;
1841 vam->sw_if_index = ntohl (mp->sw_if_index);
1842 vam->result_ready = 1;
1846 static void vl_api_virtio_pci_create_v2_reply_t_handler_json
1847 (vl_api_virtio_pci_create_v2_reply_t * mp)
1849 vat_main_t *vam = &vat_main;
1850 vat_json_node_t node;
1852 vat_json_init_object (&node);
1853 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1854 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1856 vat_json_print (vam->ofp, &node);
1857 vat_json_free (&node);
1859 vam->retval = ntohl (mp->retval);
1860 vam->result_ready = 1;
1864 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1867 vat_main_t *vam = &vat_main;
1868 i32 retval = ntohl (mp->retval);
1869 if (vam->async_mode)
1871 vam->async_errors += (retval < 0);
1875 vam->retval = retval;
1876 vam->result_ready = 1;
1880 static void vl_api_virtio_pci_delete_reply_t_handler_json
1881 (vl_api_virtio_pci_delete_reply_t * mp)
1883 vat_main_t *vam = &vat_main;
1884 vat_json_node_t node;
1886 vat_json_init_object (&node);
1887 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1889 vat_json_print (vam->ofp, &node);
1890 vat_json_free (&node);
1892 vam->retval = ntohl (mp->retval);
1893 vam->result_ready = 1;
1897 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1899 vat_main_t *vam = &vat_main;
1900 i32 retval = ntohl (mp->retval);
1902 if (vam->async_mode)
1904 vam->async_errors += (retval < 0);
1908 vam->retval = retval;
1909 vam->sw_if_index = ntohl (mp->sw_if_index);
1910 vam->result_ready = 1;
1914 static void vl_api_bond_create_reply_t_handler_json
1915 (vl_api_bond_create_reply_t * mp)
1917 vat_main_t *vam = &vat_main;
1918 vat_json_node_t node;
1920 vat_json_init_object (&node);
1921 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1922 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1924 vat_json_print (vam->ofp, &node);
1925 vat_json_free (&node);
1927 vam->retval = ntohl (mp->retval);
1928 vam->result_ready = 1;
1932 vl_api_bond_create2_reply_t_handler (vl_api_bond_create2_reply_t * mp)
1934 vat_main_t *vam = &vat_main;
1935 i32 retval = ntohl (mp->retval);
1937 if (vam->async_mode)
1939 vam->async_errors += (retval < 0);
1943 vam->retval = retval;
1944 vam->sw_if_index = ntohl (mp->sw_if_index);
1945 vam->result_ready = 1;
1949 static void vl_api_bond_create2_reply_t_handler_json
1950 (vl_api_bond_create2_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));
1957 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1959 vat_json_print (vam->ofp, &node);
1960 vat_json_free (&node);
1962 vam->retval = ntohl (mp->retval);
1963 vam->result_ready = 1;
1967 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
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_delete_reply_t_handler_json
1984 (vl_api_bond_delete_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 vl_api_bond_add_member_reply_t_handler (vl_api_bond_add_member_reply_t * mp)
2002 vat_main_t *vam = &vat_main;
2003 i32 retval = ntohl (mp->retval);
2005 if (vam->async_mode)
2007 vam->async_errors += (retval < 0);
2011 vam->retval = retval;
2012 vam->result_ready = 1;
2016 static void vl_api_bond_add_member_reply_t_handler_json
2017 (vl_api_bond_add_member_reply_t * mp)
2019 vat_main_t *vam = &vat_main;
2020 vat_json_node_t node;
2022 vat_json_init_object (&node);
2023 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2025 vat_json_print (vam->ofp, &node);
2026 vat_json_free (&node);
2028 vam->retval = ntohl (mp->retval);
2029 vam->result_ready = 1;
2033 vl_api_bond_detach_member_reply_t_handler (vl_api_bond_detach_member_reply_t *
2036 vat_main_t *vam = &vat_main;
2037 i32 retval = ntohl (mp->retval);
2039 if (vam->async_mode)
2041 vam->async_errors += (retval < 0);
2045 vam->retval = retval;
2046 vam->result_ready = 1;
2050 static void vl_api_bond_detach_member_reply_t_handler_json
2051 (vl_api_bond_detach_member_reply_t * mp)
2053 vat_main_t *vam = &vat_main;
2054 vat_json_node_t node;
2056 vat_json_init_object (&node);
2057 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2059 vat_json_print (vam->ofp, &node);
2060 vat_json_free (&node);
2062 vam->retval = ntohl (mp->retval);
2063 vam->result_ready = 1;
2067 api_sw_interface_set_bond_weight (vat_main_t * vam)
2069 unformat_input_t *i = vam->input;
2070 vl_api_sw_interface_set_bond_weight_t *mp;
2071 u32 sw_if_index = ~0;
2073 u8 weight_enter = 0;
2076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2078 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2080 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2082 else if (unformat (i, "weight %u", &weight))
2088 if (sw_if_index == ~0)
2090 errmsg ("missing interface name or sw_if_index");
2093 if (weight_enter == 0)
2095 errmsg ("missing valid weight");
2099 /* Construct the API message */
2100 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2101 mp->sw_if_index = ntohl (sw_if_index);
2102 mp->weight = ntohl (weight);
2109 static void vl_api_sw_bond_interface_details_t_handler
2110 (vl_api_sw_bond_interface_details_t * mp)
2112 vat_main_t *vam = &vat_main;
2115 "%-16s %-12d %-12U %-13U %-14u %-14u",
2116 mp->interface_name, ntohl (mp->sw_if_index),
2117 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2118 ntohl (mp->lb), ntohl (mp->active_members), ntohl (mp->members));
2121 static void vl_api_sw_bond_interface_details_t_handler_json
2122 (vl_api_sw_bond_interface_details_t * mp)
2124 vat_main_t *vam = &vat_main;
2125 vat_json_node_t *node = NULL;
2127 if (VAT_JSON_ARRAY != vam->json_tree.type)
2129 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2130 vat_json_init_array (&vam->json_tree);
2132 node = vat_json_array_add (&vam->json_tree);
2134 vat_json_init_object (node);
2135 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2136 vat_json_object_add_string_copy (node, "interface_name",
2137 mp->interface_name);
2138 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2139 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2140 vat_json_object_add_uint (node, "active_members",
2141 ntohl (mp->active_members));
2142 vat_json_object_add_uint (node, "members", ntohl (mp->members));
2146 api_sw_bond_interface_dump (vat_main_t * vam)
2148 unformat_input_t *i = vam->input;
2149 vl_api_sw_bond_interface_dump_t *mp;
2150 vl_api_control_ping_t *mp_ping;
2152 u32 sw_if_index = ~0;
2154 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2156 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2158 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2165 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2166 "interface name", "sw_if_index", "mode", "load balance",
2167 "active members", "members");
2169 /* Get list of bond interfaces */
2170 M (SW_BOND_INTERFACE_DUMP, mp);
2171 mp->sw_if_index = ntohl (sw_if_index);
2174 /* Use a control ping for synchronization */
2175 MPING (CONTROL_PING, mp_ping);
2182 static void vl_api_sw_member_interface_details_t_handler
2183 (vl_api_sw_member_interface_details_t * mp)
2185 vat_main_t *vam = &vat_main;
2188 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2189 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2190 ntohl (mp->weight), mp->is_local_numa);
2193 static void vl_api_sw_member_interface_details_t_handler_json
2194 (vl_api_sw_member_interface_details_t * mp)
2196 vat_main_t *vam = &vat_main;
2197 vat_json_node_t *node = NULL;
2199 if (VAT_JSON_ARRAY != vam->json_tree.type)
2201 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2202 vat_json_init_array (&vam->json_tree);
2204 node = vat_json_array_add (&vam->json_tree);
2206 vat_json_init_object (node);
2207 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2208 vat_json_object_add_string_copy (node, "interface_name",
2209 mp->interface_name);
2210 vat_json_object_add_uint (node, "passive", mp->is_passive);
2211 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2212 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2213 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2217 api_sw_member_interface_dump (vat_main_t * vam)
2219 unformat_input_t *i = vam->input;
2220 vl_api_sw_member_interface_dump_t *mp;
2221 vl_api_control_ping_t *mp_ping;
2222 u32 sw_if_index = ~0;
2223 u8 sw_if_index_set = 0;
2226 /* Parse args required to build the message */
2227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2229 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2230 sw_if_index_set = 1;
2231 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2232 sw_if_index_set = 1;
2237 if (sw_if_index_set == 0)
2239 errmsg ("missing vpp interface name. ");
2244 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2245 "member interface name", "sw_if_index", "passive", "long_timeout",
2246 "weight", "local numa");
2248 /* Get list of bond interfaces */
2249 M (SW_MEMBER_INTERFACE_DUMP, mp);
2250 mp->sw_if_index = ntohl (sw_if_index);
2253 /* Use a control ping for synchronization */
2254 MPING (CONTROL_PING, mp_ping);
2261 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2262 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2264 vat_main_t *vam = &vat_main;
2265 i32 retval = ntohl (mp->retval);
2266 if (vam->async_mode)
2268 vam->async_errors += (retval < 0);
2272 vam->retval = retval;
2273 vam->sw_if_index = ntohl (mp->sw_if_index);
2274 vam->result_ready = 1;
2276 vam->regenerate_interface_table = 1;
2279 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2280 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2282 vat_main_t *vam = &vat_main;
2283 vat_json_node_t node;
2285 vat_json_init_object (&node);
2286 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2287 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2288 ntohl (mp->sw_if_index));
2290 vat_json_print (vam->ofp, &node);
2291 vat_json_free (&node);
2293 vam->retval = ntohl (mp->retval);
2294 vam->result_ready = 1;
2297 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2298 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2300 vat_main_t *vam = &vat_main;
2301 i32 retval = ntohl (mp->retval);
2302 if (vam->async_mode)
2304 vam->async_errors += (retval < 0);
2308 vam->retval = retval;
2309 vam->sw_if_index = ntohl (mp->sw_if_index);
2310 vam->result_ready = 1;
2312 vam->regenerate_interface_table = 1;
2315 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2316 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2318 vat_main_t *vam = &vat_main;
2319 vat_json_node_t node;
2321 vat_json_init_object (&node);
2322 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2323 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2325 vat_json_print (vam->ofp, &node);
2326 vat_json_free (&node);
2328 vam->retval = ntohl (mp->retval);
2329 vam->result_ready = 1;
2332 static void vl_api_vxlan_offload_rx_reply_t_handler
2333 (vl_api_vxlan_offload_rx_reply_t * mp)
2335 vat_main_t *vam = &vat_main;
2336 i32 retval = ntohl (mp->retval);
2337 if (vam->async_mode)
2339 vam->async_errors += (retval < 0);
2343 vam->retval = retval;
2344 vam->result_ready = 1;
2348 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2349 (vl_api_vxlan_offload_rx_reply_t * mp)
2351 vat_main_t *vam = &vat_main;
2352 vat_json_node_t node;
2354 vat_json_init_object (&node);
2355 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2357 vat_json_print (vam->ofp, &node);
2358 vat_json_free (&node);
2360 vam->retval = ntohl (mp->retval);
2361 vam->result_ready = 1;
2364 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2365 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2367 vat_main_t *vam = &vat_main;
2368 i32 retval = ntohl (mp->retval);
2369 if (vam->async_mode)
2371 vam->async_errors += (retval < 0);
2375 vam->retval = retval;
2376 vam->sw_if_index = ntohl (mp->sw_if_index);
2377 vam->result_ready = 1;
2379 vam->regenerate_interface_table = 1;
2382 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2383 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2385 vat_main_t *vam = &vat_main;
2386 vat_json_node_t node;
2388 vat_json_init_object (&node);
2389 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2390 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2392 vat_json_print (vam->ofp, &node);
2393 vat_json_free (&node);
2395 vam->retval = ntohl (mp->retval);
2396 vam->result_ready = 1;
2399 static void vl_api_create_vhost_user_if_reply_t_handler
2400 (vl_api_create_vhost_user_if_reply_t * mp)
2402 vat_main_t *vam = &vat_main;
2403 i32 retval = ntohl (mp->retval);
2404 if (vam->async_mode)
2406 vam->async_errors += (retval < 0);
2410 vam->retval = retval;
2411 vam->sw_if_index = ntohl (mp->sw_if_index);
2412 vam->result_ready = 1;
2414 vam->regenerate_interface_table = 1;
2417 static void vl_api_create_vhost_user_if_reply_t_handler_json
2418 (vl_api_create_vhost_user_if_reply_t * mp)
2420 vat_main_t *vam = &vat_main;
2421 vat_json_node_t node;
2423 vat_json_init_object (&node);
2424 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2425 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2427 vat_json_print (vam->ofp, &node);
2428 vat_json_free (&node);
2430 vam->retval = ntohl (mp->retval);
2431 vam->result_ready = 1;
2434 static void vl_api_ip_address_details_t_handler
2435 (vl_api_ip_address_details_t * mp)
2437 vat_main_t *vam = &vat_main;
2438 static ip_address_details_t empty_ip_address_details = { {0} };
2439 ip_address_details_t *address = NULL;
2440 ip_details_t *current_ip_details = NULL;
2441 ip_details_t *details = NULL;
2443 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2445 if (!details || vam->current_sw_if_index >= vec_len (details)
2446 || !details[vam->current_sw_if_index].present)
2448 errmsg ("ip address details arrived but not stored");
2449 errmsg ("ip_dump should be called first");
2453 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2455 #define addresses (current_ip_details->addr)
2457 vec_validate_init_empty (addresses, vec_len (addresses),
2458 empty_ip_address_details);
2460 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2462 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2463 address->prefix_length = mp->prefix.len;
2467 static void vl_api_ip_address_details_t_handler_json
2468 (vl_api_ip_address_details_t * mp)
2470 vat_main_t *vam = &vat_main;
2471 vat_json_node_t *node = NULL;
2473 if (VAT_JSON_ARRAY != vam->json_tree.type)
2475 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2476 vat_json_init_array (&vam->json_tree);
2478 node = vat_json_array_add (&vam->json_tree);
2480 vat_json_init_object (node);
2481 vat_json_object_add_prefix (node, &mp->prefix);
2485 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2487 vat_main_t *vam = &vat_main;
2488 static ip_details_t empty_ip_details = { 0 };
2489 ip_details_t *ip = NULL;
2490 u32 sw_if_index = ~0;
2492 sw_if_index = ntohl (mp->sw_if_index);
2494 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2495 sw_if_index, empty_ip_details);
2497 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2504 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2506 vat_main_t *vam = &vat_main;
2508 if (VAT_JSON_ARRAY != vam->json_tree.type)
2510 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2511 vat_json_init_array (&vam->json_tree);
2513 vat_json_array_add_uint (&vam->json_tree,
2514 clib_net_to_host_u32 (mp->sw_if_index));
2517 static void vl_api_get_first_msg_id_reply_t_handler
2518 (vl_api_get_first_msg_id_reply_t * mp)
2520 vat_main_t *vam = &vat_main;
2521 i32 retval = ntohl (mp->retval);
2523 if (vam->async_mode)
2525 vam->async_errors += (retval < 0);
2529 vam->retval = retval;
2530 vam->result_ready = 1;
2534 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2538 static void vl_api_get_first_msg_id_reply_t_handler_json
2539 (vl_api_get_first_msg_id_reply_t * mp)
2541 vat_main_t *vam = &vat_main;
2542 vat_json_node_t node;
2544 vat_json_init_object (&node);
2545 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2546 vat_json_object_add_uint (&node, "first_msg_id",
2547 (uint) ntohs (mp->first_msg_id));
2549 vat_json_print (vam->ofp, &node);
2550 vat_json_free (&node);
2552 vam->retval = ntohl (mp->retval);
2553 vam->result_ready = 1;
2556 static void vl_api_get_node_graph_reply_t_handler
2557 (vl_api_get_node_graph_reply_t * mp)
2559 vat_main_t *vam = &vat_main;
2560 i32 retval = ntohl (mp->retval);
2561 u8 *pvt_copy, *reply;
2566 if (vam->async_mode)
2568 vam->async_errors += (retval < 0);
2572 vam->retval = retval;
2573 vam->result_ready = 1;
2576 /* "Should never happen..." */
2580 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2581 pvt_copy = vec_dup (reply);
2583 /* Toss the shared-memory original... */
2584 oldheap = vl_msg_push_heap ();
2588 vl_msg_pop_heap (oldheap);
2590 if (vam->graph_nodes)
2592 hash_free (vam->graph_node_index_by_name);
2594 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2596 node = vam->graph_nodes[0][i];
2597 vec_free (node->name);
2598 vec_free (node->next_nodes);
2601 vec_free (vam->graph_nodes[0]);
2602 vec_free (vam->graph_nodes);
2605 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2606 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2607 vec_free (pvt_copy);
2609 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2611 node = vam->graph_nodes[0][i];
2612 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2616 static void vl_api_get_node_graph_reply_t_handler_json
2617 (vl_api_get_node_graph_reply_t * mp)
2619 vat_main_t *vam = &vat_main;
2621 vat_json_node_t node;
2624 /* $$$$ make this real? */
2625 vat_json_init_object (&node);
2626 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2627 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2629 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2631 /* Toss the shared-memory original... */
2632 oldheap = vl_msg_push_heap ();
2636 vl_msg_pop_heap (oldheap);
2638 vat_json_print (vam->ofp, &node);
2639 vat_json_free (&node);
2641 vam->retval = ntohl (mp->retval);
2642 vam->result_ready = 1;
2646 format_policer_type (u8 * s, va_list * va)
2648 u32 i = va_arg (*va, u32);
2650 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
2651 s = format (s, "1r2c");
2652 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
2653 s = format (s, "1r3c");
2654 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
2655 s = format (s, "2r3c-2698");
2656 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
2657 s = format (s, "2r3c-4115");
2658 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
2659 s = format (s, "2r3c-mef5cf1");
2661 s = format (s, "ILLEGAL");
2666 format_policer_rate_type (u8 * s, va_list * va)
2668 u32 i = va_arg (*va, u32);
2670 if (i == SSE2_QOS_RATE_KBPS)
2671 s = format (s, "kbps");
2672 else if (i == SSE2_QOS_RATE_PPS)
2673 s = format (s, "pps");
2675 s = format (s, "ILLEGAL");
2680 format_policer_round_type (u8 * s, va_list * va)
2682 u32 i = va_arg (*va, u32);
2684 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
2685 s = format (s, "closest");
2686 else if (i == SSE2_QOS_ROUND_TO_UP)
2687 s = format (s, "up");
2688 else if (i == SSE2_QOS_ROUND_TO_DOWN)
2689 s = format (s, "down");
2691 s = format (s, "ILLEGAL");
2696 format_policer_action_type (u8 * s, va_list * va)
2698 u32 i = va_arg (*va, u32);
2700 if (i == SSE2_QOS_ACTION_DROP)
2701 s = format (s, "drop");
2702 else if (i == SSE2_QOS_ACTION_TRANSMIT)
2703 s = format (s, "transmit");
2704 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
2705 s = format (s, "mark-and-transmit");
2707 s = format (s, "ILLEGAL");
2712 format_dscp (u8 * s, va_list * va)
2714 u32 i = va_arg (*va, u32);
2719 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
2723 return format (s, "ILLEGAL");
2725 s = format (s, "%s", t);
2730 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
2732 vat_main_t *vam = &vat_main;
2733 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
2735 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
2736 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
2738 conform_dscp_str = format (0, "");
2740 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
2741 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
2743 exceed_dscp_str = format (0, "");
2745 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
2746 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
2748 violate_dscp_str = format (0, "");
2750 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
2751 "rate type %U, round type %U, %s rate, %s color-aware, "
2752 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
2753 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
2754 "conform action %U%s, exceed action %U%s, violate action %U%s",
2756 format_policer_type, mp->type,
2759 clib_net_to_host_u64 (mp->cb),
2760 clib_net_to_host_u64 (mp->eb),
2761 format_policer_rate_type, mp->rate_type,
2762 format_policer_round_type, mp->round_type,
2763 mp->single_rate ? "single" : "dual",
2764 mp->color_aware ? "is" : "not",
2765 ntohl (mp->cir_tokens_per_period),
2766 ntohl (mp->pir_tokens_per_period),
2768 ntohl (mp->current_limit),
2769 ntohl (mp->current_bucket),
2770 ntohl (mp->extended_limit),
2771 ntohl (mp->extended_bucket),
2772 clib_net_to_host_u64 (mp->last_update_time),
2773 format_policer_action_type, mp->conform_action.type,
2775 format_policer_action_type, mp->exceed_action.type,
2777 format_policer_action_type, mp->violate_action.type,
2780 vec_free (conform_dscp_str);
2781 vec_free (exceed_dscp_str);
2782 vec_free (violate_dscp_str);
2785 static void vl_api_policer_details_t_handler_json
2786 (vl_api_policer_details_t * mp)
2788 vat_main_t *vam = &vat_main;
2789 vat_json_node_t *node;
2790 u8 *rate_type_str, *round_type_str, *type_str;
2791 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
2793 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
2795 format (0, "%U", format_policer_round_type, mp->round_type);
2796 type_str = format (0, "%U", format_policer_type, mp->type);
2797 conform_action_str = format (0, "%U", format_policer_action_type,
2798 mp->conform_action.type);
2799 exceed_action_str = format (0, "%U", format_policer_action_type,
2800 mp->exceed_action.type);
2801 violate_action_str = format (0, "%U", format_policer_action_type,
2802 mp->violate_action.type);
2804 if (VAT_JSON_ARRAY != vam->json_tree.type)
2806 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2807 vat_json_init_array (&vam->json_tree);
2809 node = vat_json_array_add (&vam->json_tree);
2811 vat_json_init_object (node);
2812 vat_json_object_add_string_copy (node, "name", mp->name);
2813 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
2814 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
2815 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
2816 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
2817 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
2818 vat_json_object_add_string_copy (node, "round_type", round_type_str);
2819 vat_json_object_add_string_copy (node, "type", type_str);
2820 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
2821 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
2822 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
2823 vat_json_object_add_uint (node, "cir_tokens_per_period",
2824 ntohl (mp->cir_tokens_per_period));
2825 vat_json_object_add_uint (node, "eir_tokens_per_period",
2826 ntohl (mp->pir_tokens_per_period));
2827 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
2828 vat_json_object_add_uint (node, "current_bucket",
2829 ntohl (mp->current_bucket));
2830 vat_json_object_add_uint (node, "extended_limit",
2831 ntohl (mp->extended_limit));
2832 vat_json_object_add_uint (node, "extended_bucket",
2833 ntohl (mp->extended_bucket));
2834 vat_json_object_add_uint (node, "last_update_time",
2835 ntohl (mp->last_update_time));
2836 vat_json_object_add_string_copy (node, "conform_action",
2837 conform_action_str);
2838 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
2840 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
2841 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
2842 vec_free (dscp_str);
2844 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
2845 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
2847 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
2848 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
2849 vec_free (dscp_str);
2851 vat_json_object_add_string_copy (node, "violate_action",
2852 violate_action_str);
2853 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
2855 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
2856 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
2857 vec_free (dscp_str);
2860 vec_free (rate_type_str);
2861 vec_free (round_type_str);
2862 vec_free (type_str);
2863 vec_free (conform_action_str);
2864 vec_free (exceed_action_str);
2865 vec_free (violate_action_str);
2869 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
2872 vat_main_t *vam = &vat_main;
2873 int i, count = ntohl (mp->count);
2876 print (vam->ofp, "classify table ids (%d) : ", count);
2877 for (i = 0; i < count; i++)
2879 print (vam->ofp, "%d", ntohl (mp->ids[i]));
2880 print (vam->ofp, (i < count - 1) ? "," : "");
2882 vam->retval = ntohl (mp->retval);
2883 vam->result_ready = 1;
2887 vl_api_classify_table_ids_reply_t_handler_json
2888 (vl_api_classify_table_ids_reply_t * mp)
2890 vat_main_t *vam = &vat_main;
2891 int i, count = ntohl (mp->count);
2895 vat_json_node_t node;
2897 vat_json_init_object (&node);
2898 for (i = 0; i < count; i++)
2900 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
2902 vat_json_print (vam->ofp, &node);
2903 vat_json_free (&node);
2905 vam->retval = ntohl (mp->retval);
2906 vam->result_ready = 1;
2910 vl_api_classify_table_by_interface_reply_t_handler
2911 (vl_api_classify_table_by_interface_reply_t * mp)
2913 vat_main_t *vam = &vat_main;
2916 table_id = ntohl (mp->l2_table_id);
2918 print (vam->ofp, "l2 table id : %d", table_id);
2920 print (vam->ofp, "l2 table id : No input ACL tables configured");
2921 table_id = ntohl (mp->ip4_table_id);
2923 print (vam->ofp, "ip4 table id : %d", table_id);
2925 print (vam->ofp, "ip4 table id : No input ACL tables configured");
2926 table_id = ntohl (mp->ip6_table_id);
2928 print (vam->ofp, "ip6 table id : %d", table_id);
2930 print (vam->ofp, "ip6 table id : No input ACL tables configured");
2931 vam->retval = ntohl (mp->retval);
2932 vam->result_ready = 1;
2936 vl_api_classify_table_by_interface_reply_t_handler_json
2937 (vl_api_classify_table_by_interface_reply_t * mp)
2939 vat_main_t *vam = &vat_main;
2940 vat_json_node_t node;
2942 vat_json_init_object (&node);
2944 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
2945 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
2946 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
2948 vat_json_print (vam->ofp, &node);
2949 vat_json_free (&node);
2951 vam->retval = ntohl (mp->retval);
2952 vam->result_ready = 1;
2955 static void vl_api_policer_add_del_reply_t_handler
2956 (vl_api_policer_add_del_reply_t * mp)
2958 vat_main_t *vam = &vat_main;
2959 i32 retval = ntohl (mp->retval);
2960 if (vam->async_mode)
2962 vam->async_errors += (retval < 0);
2966 vam->retval = retval;
2967 vam->result_ready = 1;
2968 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
2970 * Note: this is just barely thread-safe, depends on
2971 * the main thread spinning waiting for an answer...
2973 errmsg ("policer index %d", ntohl (mp->policer_index));
2977 static void vl_api_policer_add_del_reply_t_handler_json
2978 (vl_api_policer_add_del_reply_t * mp)
2980 vat_main_t *vam = &vat_main;
2981 vat_json_node_t node;
2983 vat_json_init_object (&node);
2984 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2985 vat_json_object_add_uint (&node, "policer_index",
2986 ntohl (mp->policer_index));
2988 vat_json_print (vam->ofp, &node);
2989 vat_json_free (&node);
2991 vam->retval = ntohl (mp->retval);
2992 vam->result_ready = 1;
2995 /* Format hex dump. */
2997 format_hex_bytes (u8 * s, va_list * va)
2999 u8 *bytes = va_arg (*va, u8 *);
3000 int n_bytes = va_arg (*va, int);
3003 /* Print short or long form depending on byte count. */
3004 uword short_form = n_bytes <= 32;
3005 u32 indent = format_get_indent (s);
3010 for (i = 0; i < n_bytes; i++)
3012 if (!short_form && (i % 32) == 0)
3013 s = format (s, "%08x: ", i);
3014 s = format (s, "%02x", bytes[i]);
3015 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3016 s = format (s, "\n%U", format_white_space, indent);
3023 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3026 vat_main_t *vam = &vat_main;
3027 i32 retval = ntohl (mp->retval);
3030 print (vam->ofp, "classify table info :");
3031 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3032 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3033 ntohl (mp->miss_next_index));
3034 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3035 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3036 ntohl (mp->match_n_vectors));
3037 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3038 ntohl (mp->mask_length));
3040 vam->retval = retval;
3041 vam->result_ready = 1;
3045 vl_api_classify_table_info_reply_t_handler_json
3046 (vl_api_classify_table_info_reply_t * mp)
3048 vat_main_t *vam = &vat_main;
3049 vat_json_node_t node;
3051 i32 retval = ntohl (mp->retval);
3054 vat_json_init_object (&node);
3056 vat_json_object_add_int (&node, "sessions",
3057 ntohl (mp->active_sessions));
3058 vat_json_object_add_int (&node, "nexttbl",
3059 ntohl (mp->next_table_index));
3060 vat_json_object_add_int (&node, "nextnode",
3061 ntohl (mp->miss_next_index));
3062 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3063 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3064 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3065 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3066 ntohl (mp->mask_length), 0);
3067 vat_json_object_add_string_copy (&node, "mask", s);
3069 vat_json_print (vam->ofp, &node);
3070 vat_json_free (&node);
3072 vam->retval = ntohl (mp->retval);
3073 vam->result_ready = 1;
3077 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3080 vat_main_t *vam = &vat_main;
3082 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3083 ntohl (mp->hit_next_index), ntohl (mp->advance),
3084 ntohl (mp->opaque_index));
3085 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3086 ntohl (mp->match_length));
3090 vl_api_classify_session_details_t_handler_json
3091 (vl_api_classify_session_details_t * mp)
3093 vat_main_t *vam = &vat_main;
3094 vat_json_node_t *node = NULL;
3096 if (VAT_JSON_ARRAY != vam->json_tree.type)
3098 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3099 vat_json_init_array (&vam->json_tree);
3101 node = vat_json_array_add (&vam->json_tree);
3103 vat_json_init_object (node);
3104 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3105 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3106 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3108 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3110 vat_json_object_add_string_copy (node, "match", s);
3113 static void vl_api_pg_create_interface_reply_t_handler
3114 (vl_api_pg_create_interface_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3118 vam->retval = ntohl (mp->retval);
3119 vam->result_ready = 1;
3122 static void vl_api_pg_create_interface_reply_t_handler_json
3123 (vl_api_pg_create_interface_reply_t * mp)
3125 vat_main_t *vam = &vat_main;
3126 vat_json_node_t node;
3128 i32 retval = ntohl (mp->retval);
3131 vat_json_init_object (&node);
3133 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3135 vat_json_print (vam->ofp, &node);
3136 vat_json_free (&node);
3138 vam->retval = ntohl (mp->retval);
3139 vam->result_ready = 1;
3142 static void vl_api_policer_classify_details_t_handler
3143 (vl_api_policer_classify_details_t * mp)
3145 vat_main_t *vam = &vat_main;
3147 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3148 ntohl (mp->table_index));
3151 static void vl_api_policer_classify_details_t_handler_json
3152 (vl_api_policer_classify_details_t * mp)
3154 vat_main_t *vam = &vat_main;
3155 vat_json_node_t *node;
3157 if (VAT_JSON_ARRAY != vam->json_tree.type)
3159 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3160 vat_json_init_array (&vam->json_tree);
3162 node = vat_json_array_add (&vam->json_tree);
3164 vat_json_init_object (node);
3165 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3166 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3169 static void vl_api_flow_classify_details_t_handler
3170 (vl_api_flow_classify_details_t * mp)
3172 vat_main_t *vam = &vat_main;
3174 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3175 ntohl (mp->table_index));
3178 static void vl_api_flow_classify_details_t_handler_json
3179 (vl_api_flow_classify_details_t * mp)
3181 vat_main_t *vam = &vat_main;
3182 vat_json_node_t *node;
3184 if (VAT_JSON_ARRAY != vam->json_tree.type)
3186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3187 vat_json_init_array (&vam->json_tree);
3189 node = vat_json_array_add (&vam->json_tree);
3191 vat_json_init_object (node);
3192 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3193 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3197 * Generate boilerplate reply handlers, which
3198 * dig the return value out of the xxx_reply_t API message,
3199 * stick it into vam->retval, and set vam->result_ready
3201 * Could also do this by pointing N message decode slots at
3202 * a single function, but that could break in subtle ways.
3205 #define foreach_standard_reply_retval_handler \
3206 _(sw_interface_set_flags_reply) \
3207 _(sw_interface_add_del_address_reply) \
3208 _(sw_interface_set_rx_mode_reply) \
3209 _(sw_interface_set_rx_placement_reply) \
3210 _(sw_interface_set_table_reply) \
3211 _(sw_interface_set_mpls_enable_reply) \
3212 _(sw_interface_set_vpath_reply) \
3213 _(sw_interface_set_vxlan_bypass_reply) \
3214 _(sw_interface_set_vxlan_gpe_bypass_reply) \
3215 _(sw_interface_set_l2_bridge_reply) \
3216 _(sw_interface_set_bond_weight_reply) \
3217 _(bridge_domain_add_del_reply) \
3218 _(sw_interface_set_l2_xconnect_reply) \
3219 _(l2fib_add_del_reply) \
3220 _(l2fib_flush_int_reply) \
3221 _(l2fib_flush_bd_reply) \
3222 _(ip_route_add_del_reply) \
3223 _(ip_table_add_del_reply) \
3224 _(ip_table_replace_begin_reply) \
3225 _(ip_table_flush_reply) \
3226 _(ip_table_replace_end_reply) \
3227 _(ip_mroute_add_del_reply) \
3228 _(mpls_route_add_del_reply) \
3229 _(mpls_table_add_del_reply) \
3230 _(mpls_ip_bind_unbind_reply) \
3231 _(bier_route_add_del_reply) \
3232 _(bier_table_add_del_reply) \
3233 _(sw_interface_set_unnumbered_reply) \
3234 _(set_ip_flow_hash_reply) \
3235 _(sw_interface_ip6_enable_disable_reply) \
3236 _(l2_patch_add_del_reply) \
3237 _(sr_mpls_policy_add_reply) \
3238 _(sr_mpls_policy_mod_reply) \
3239 _(sr_mpls_policy_del_reply) \
3240 _(sr_policy_add_reply) \
3241 _(sr_policy_mod_reply) \
3242 _(sr_policy_del_reply) \
3243 _(sr_localsid_add_del_reply) \
3244 _(sr_steering_add_del_reply) \
3245 _(classify_add_del_session_reply) \
3246 _(classify_set_interface_ip_table_reply) \
3247 _(classify_set_interface_l2_tables_reply) \
3248 _(l2_fib_clear_table_reply) \
3249 _(l2_interface_efp_filter_reply) \
3250 _(l2_interface_vlan_tag_rewrite_reply) \
3251 _(modify_vhost_user_if_reply) \
3252 _(delete_vhost_user_if_reply) \
3253 _(want_l2_macs_events_reply) \
3254 _(input_acl_set_interface_reply) \
3255 _(ipsec_spd_add_del_reply) \
3256 _(ipsec_interface_add_del_spd_reply) \
3257 _(ipsec_spd_entry_add_del_reply) \
3258 _(ipsec_sad_entry_add_del_reply) \
3259 _(delete_loopback_reply) \
3260 _(bd_ip_mac_add_del_reply) \
3261 _(bd_ip_mac_flush_reply) \
3262 _(want_interface_events_reply) \
3263 _(cop_interface_enable_disable_reply) \
3264 _(cop_whitelist_enable_disable_reply) \
3265 _(sw_interface_clear_stats_reply) \
3266 _(ioam_enable_reply) \
3267 _(ioam_disable_reply) \
3268 _(af_packet_delete_reply) \
3269 _(policer_classify_set_interface_reply) \
3270 _(set_ipfix_exporter_reply) \
3271 _(set_ipfix_classify_stream_reply) \
3272 _(ipfix_classify_table_add_del_reply) \
3273 _(flow_classify_set_interface_reply) \
3274 _(sw_interface_span_enable_disable_reply) \
3275 _(pg_capture_reply) \
3276 _(pg_enable_disable_reply) \
3277 _(pg_interface_enable_disable_coalesce_reply) \
3278 _(ip_source_and_port_range_check_add_del_reply) \
3279 _(ip_source_and_port_range_check_interface_add_del_reply)\
3280 _(delete_subif_reply) \
3281 _(l2_interface_pbb_tag_rewrite_reply) \
3283 _(feature_enable_disable_reply) \
3284 _(feature_gso_enable_disable_reply) \
3285 _(sw_interface_tag_add_del_reply) \
3286 _(sw_interface_add_del_mac_address_reply) \
3287 _(hw_interface_set_mtu_reply) \
3288 _(p2p_ethernet_add_reply) \
3289 _(p2p_ethernet_del_reply) \
3290 _(tcp_configure_src_addresses_reply) \
3291 _(session_rule_add_del_reply) \
3292 _(ip_container_proxy_add_del_reply) \
3293 _(output_acl_set_interface_reply) \
3294 _(qos_record_enable_disable_reply) \
3298 static void vl_api_##n##_t_handler \
3299 (vl_api_##n##_t * mp) \
3301 vat_main_t * vam = &vat_main; \
3302 i32 retval = ntohl(mp->retval); \
3303 if (vam->async_mode) { \
3304 vam->async_errors += (retval < 0); \
3306 vam->retval = retval; \
3307 vam->result_ready = 1; \
3310 foreach_standard_reply_retval_handler;
3314 static void vl_api_##n##_t_handler_json \
3315 (vl_api_##n##_t * mp) \
3317 vat_main_t * vam = &vat_main; \
3318 vat_json_node_t node; \
3319 vat_json_init_object(&node); \
3320 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
3321 vat_json_print(vam->ofp, &node); \
3322 vam->retval = ntohl(mp->retval); \
3323 vam->result_ready = 1; \
3325 foreach_standard_reply_retval_handler;
3329 * Table of message reply handlers, must include boilerplate handlers
3333 #define foreach_vpe_api_reply_msg \
3334 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
3335 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
3336 _(SW_INTERFACE_DETAILS, sw_interface_details) \
3337 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
3338 _(CONTROL_PING_REPLY, control_ping_reply) \
3339 _(CLI_REPLY, cli_reply) \
3340 _(CLI_INBAND_REPLY, cli_inband_reply) \
3341 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
3342 sw_interface_add_del_address_reply) \
3343 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
3344 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
3345 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
3346 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
3347 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
3348 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
3349 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
3350 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
3351 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
3352 sw_interface_set_l2_xconnect_reply) \
3353 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
3354 sw_interface_set_l2_bridge_reply) \
3355 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
3356 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
3357 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
3358 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
3359 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
3360 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
3361 _(L2_FLAGS_REPLY, l2_flags_reply) \
3362 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
3363 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
3364 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
3365 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
3366 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
3367 _(VIRTIO_PCI_CREATE_V2_REPLY, virtio_pci_create_v2_reply) \
3368 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
3369 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
3370 _(BOND_CREATE_REPLY, bond_create_reply) \
3371 _(BOND_CREATE2_REPLY, bond_create2_reply) \
3372 _(BOND_DELETE_REPLY, bond_delete_reply) \
3373 _(BOND_ADD_MEMBER_REPLY, bond_add_member_reply) \
3374 _(BOND_DETACH_MEMBER_REPLY, bond_detach_member_reply) \
3375 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
3376 _(SW_BOND_INTERFACE_DETAILS, sw_bond_interface_details) \
3377 _(SW_MEMBER_INTERFACE_DETAILS, sw_member_interface_details) \
3378 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
3379 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
3380 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
3381 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
3382 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
3383 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
3384 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
3385 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
3386 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
3387 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
3388 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
3389 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
3390 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
3391 sw_interface_set_unnumbered_reply) \
3392 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
3393 _(CREATE_SUBIF_REPLY, create_subif_reply) \
3394 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
3395 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
3396 sw_interface_ip6_enable_disable_reply) \
3397 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
3398 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
3399 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
3400 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
3401 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
3402 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
3403 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
3404 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
3405 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
3406 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
3407 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
3408 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
3409 classify_set_interface_ip_table_reply) \
3410 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
3411 classify_set_interface_l2_tables_reply) \
3412 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
3413 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
3414 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
3415 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
3416 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
3417 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
3418 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
3419 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
3420 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
3421 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
3422 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
3423 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
3424 _(SHOW_VERSION_REPLY, show_version_reply) \
3425 _(SHOW_THREADS_REPLY, show_threads_reply) \
3426 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
3427 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
3428 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
3429 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
3430 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
3431 _(L2_MACS_EVENT, l2_macs_event) \
3432 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
3433 _(IP_ADDRESS_DETAILS, ip_address_details) \
3434 _(IP_DETAILS, ip_details) \
3435 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
3436 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
3437 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
3438 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
3439 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
3440 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
3441 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
3442 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
3443 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
3444 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
3445 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
3446 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
3447 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
3448 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
3449 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
3450 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
3451 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
3452 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
3453 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
3454 _(AF_PACKET_DETAILS, af_packet_details) \
3455 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
3456 _(POLICER_DETAILS, policer_details) \
3457 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
3458 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
3459 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
3460 _(MPLS_TABLE_DETAILS, mpls_table_details) \
3461 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
3462 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
3463 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
3464 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
3465 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
3466 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
3467 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
3468 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
3469 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
3470 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
3471 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
3472 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
3473 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
3474 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
3475 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
3476 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
3477 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
3478 _(PG_CAPTURE_REPLY, pg_capture_reply) \
3479 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
3480 _(PG_INTERFACE_ENABLE_DISABLE_COALESCE_REPLY, pg_interface_enable_disable_coalesce_reply) \
3481 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
3482 ip_source_and_port_range_check_add_del_reply) \
3483 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
3484 ip_source_and_port_range_check_interface_add_del_reply) \
3485 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
3486 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
3487 _(SET_PUNT_REPLY, set_punt_reply) \
3488 _(IP_TABLE_DETAILS, ip_table_details) \
3489 _(IP_ROUTE_DETAILS, ip_route_details) \
3490 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
3491 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
3492 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
3493 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
3494 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
3495 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
3496 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
3497 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
3498 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
3499 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
3500 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
3501 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
3502 _(SESSION_RULES_DETAILS, session_rules_details) \
3503 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
3504 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
3505 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply) \
3506 _(FLOW_ADD_REPLY, flow_add_reply) \
3508 #define foreach_standalone_reply_msg \
3509 _(SW_INTERFACE_EVENT, sw_interface_event)
3517 #define STR_VTR_OP_CASE(op) \
3518 case L2_VTR_ ## op: \
3522 str_vtr_op (u32 vtr_op)
3526 STR_VTR_OP_CASE (DISABLED);
3527 STR_VTR_OP_CASE (PUSH_1);
3528 STR_VTR_OP_CASE (PUSH_2);
3529 STR_VTR_OP_CASE (POP_1);
3530 STR_VTR_OP_CASE (POP_2);
3531 STR_VTR_OP_CASE (TRANSLATE_1_1);
3532 STR_VTR_OP_CASE (TRANSLATE_1_2);
3533 STR_VTR_OP_CASE (TRANSLATE_2_1);
3534 STR_VTR_OP_CASE (TRANSLATE_2_2);
3541 dump_sub_interface_table (vat_main_t * vam)
3543 const sw_interface_subif_t *sub = NULL;
3545 if (vam->json_output)
3548 ("JSON output supported only for VPE API calls and dump_stats_table");
3553 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
3554 "Interface", "sw_if_index",
3555 "sub id", "dot1ad", "tags", "outer id",
3556 "inner id", "exact", "default", "outer any", "inner any");
3558 vec_foreach (sub, vam->sw_if_subif_table)
3561 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
3562 sub->interface_name,
3564 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
3565 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
3566 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
3567 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
3568 if (sub->vtr_op != L2_VTR_DISABLED)
3571 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
3572 "tag1: %d tag2: %d ]",
3573 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
3574 sub->vtr_tag1, sub->vtr_tag2);
3582 name_sort_cmp (void *a1, void *a2)
3584 name_sort_t *n1 = a1;
3585 name_sort_t *n2 = a2;
3587 return strcmp ((char *) n1->name, (char *) n2->name);
3591 dump_interface_table (vat_main_t * vam)
3594 name_sort_t *nses = 0, *ns;
3596 if (vam->json_output)
3599 ("JSON output supported only for VPE API calls and dump_stats_table");
3604 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3606 vec_add2 (nses, ns, 1);
3607 ns->name = (u8 *)(p->key);
3608 ns->value = (u32) p->value[0];
3612 vec_sort_with_function (nses, name_sort_cmp);
3614 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
3615 vec_foreach (ns, nses)
3617 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
3624 dump_ip_table (vat_main_t * vam, int is_ipv6)
3626 const ip_details_t *det = NULL;
3627 const ip_address_details_t *address = NULL;
3630 print (vam->ofp, "%-12s", "sw_if_index");
3632 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
3639 print (vam->ofp, "%-12d", i);
3640 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
3645 vec_foreach (address, det->addr)
3649 is_ipv6 ? format_ip6_address : format_ip4_address,
3650 address->ip, address->prefix_length);
3658 dump_ipv4_table (vat_main_t * vam)
3660 if (vam->json_output)
3663 ("JSON output supported only for VPE API calls and dump_stats_table");
3667 return dump_ip_table (vam, 0);
3671 dump_ipv6_table (vat_main_t * vam)
3673 if (vam->json_output)
3676 ("JSON output supported only for VPE API calls and dump_stats_table");
3680 return dump_ip_table (vam, 1);
3684 * Pass CLI buffers directly in the CLI_INBAND API message,
3685 * instead of an additional shared memory area.
3688 exec_inband (vat_main_t * vam)
3690 vl_api_cli_inband_t *mp;
3691 unformat_input_t *i = vam->input;
3694 if (vec_len (i->buffer) == 0)
3697 if (vam->exec_mode == 0 && unformat (i, "mode"))
3702 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
3709 * In order for the CLI command to work, it
3710 * must be a vector ending in \n, not a C-string ending
3713 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
3714 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
3718 /* json responses may or may not include a useful reply... */
3719 if (vec_len (vam->cmd_reply))
3720 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
3725 exec (vat_main_t * vam)
3727 return exec_inband (vam);
3731 api_create_loopback (vat_main_t * vam)
3733 unformat_input_t *i = vam->input;
3734 vl_api_create_loopback_t *mp;
3735 vl_api_create_loopback_instance_t *mp_lbi;
3738 u8 is_specified = 0;
3739 u32 user_instance = 0;
3742 clib_memset (mac_address, 0, sizeof (mac_address));
3744 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
3746 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
3748 if (unformat (i, "instance %d", &user_instance))
3756 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
3757 mp_lbi->is_specified = is_specified;
3759 mp_lbi->user_instance = htonl (user_instance);
3761 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
3766 /* Construct the API message */
3767 M (CREATE_LOOPBACK, mp);
3769 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
3778 api_delete_loopback (vat_main_t * vam)
3780 unformat_input_t *i = vam->input;
3781 vl_api_delete_loopback_t *mp;
3782 u32 sw_if_index = ~0;
3785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
3787 if (unformat (i, "sw_if_index %d", &sw_if_index))
3793 if (sw_if_index == ~0)
3795 errmsg ("missing sw_if_index");
3799 /* Construct the API message */
3800 M (DELETE_LOOPBACK, mp);
3801 mp->sw_if_index = ntohl (sw_if_index);
3809 api_want_interface_events (vat_main_t * vam)
3811 unformat_input_t *i = vam->input;
3812 vl_api_want_interface_events_t *mp;
3816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
3818 if (unformat (i, "enable"))
3820 else if (unformat (i, "disable"))
3828 errmsg ("missing enable|disable");
3832 M (WANT_INTERFACE_EVENTS, mp);
3833 mp->enable_disable = enable;
3835 vam->interface_event_display = enable;
3843 /* Note: non-static, called once to set up the initial intfc table */
3845 api_sw_interface_dump (vat_main_t * vam)
3847 vl_api_sw_interface_dump_t *mp;
3848 vl_api_control_ping_t *mp_ping;
3850 name_sort_t *nses = 0, *ns;
3851 sw_interface_subif_t *sub = NULL;
3854 /* Toss the old name table */
3856 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
3858 vec_add2 (nses, ns, 1);
3859 ns->name = (u8 *)(p->key);
3860 ns->value = (u32) p->value[0];
3864 hash_free (vam->sw_if_index_by_interface_name);
3866 vec_foreach (ns, nses) vec_free (ns->name);
3870 vec_foreach (sub, vam->sw_if_subif_table)
3872 vec_free (sub->interface_name);
3874 vec_free (vam->sw_if_subif_table);
3876 /* recreate the interface name hash table */
3877 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
3880 * Ask for all interface names. Otherwise, the epic catalog of
3881 * name filters becomes ridiculously long, and vat ends up needing
3882 * to be taught about new interface types.
3884 M (SW_INTERFACE_DUMP, mp);
3887 /* Use a control ping for synchronization */
3888 MPING (CONTROL_PING, mp_ping);
3896 api_sw_interface_set_flags (vat_main_t * vam)
3898 unformat_input_t *i = vam->input;
3899 vl_api_sw_interface_set_flags_t *mp;
3901 u8 sw_if_index_set = 0;
3905 /* Parse args required to build the message */
3906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
3908 if (unformat (i, "admin-up"))
3910 else if (unformat (i, "admin-down"))
3913 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
3914 sw_if_index_set = 1;
3915 else if (unformat (i, "sw_if_index %d", &sw_if_index))
3916 sw_if_index_set = 1;
3921 if (sw_if_index_set == 0)
3923 errmsg ("missing interface name or sw_if_index");
3927 /* Construct the API message */
3928 M (SW_INTERFACE_SET_FLAGS, mp);
3929 mp->sw_if_index = ntohl (sw_if_index);
3930 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
3935 /* Wait for a reply, return the good/bad news... */
3941 api_sw_interface_set_rx_mode (vat_main_t * vam)
3943 unformat_input_t *i = vam->input;
3944 vl_api_sw_interface_set_rx_mode_t *mp;
3946 u8 sw_if_index_set = 0;
3948 u8 queue_id_valid = 0;
3950 vnet_hw_if_rx_mode mode = VNET_HW_IF_RX_MODE_UNKNOWN;
3952 /* Parse args required to build the message */
3953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
3955 if (unformat (i, "queue %d", &queue_id))
3957 else if (unformat (i, "polling"))
3958 mode = VNET_HW_IF_RX_MODE_POLLING;
3959 else if (unformat (i, "interrupt"))
3960 mode = VNET_HW_IF_RX_MODE_INTERRUPT;
3961 else if (unformat (i, "adaptive"))
3962 mode = VNET_HW_IF_RX_MODE_ADAPTIVE;
3964 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
3965 sw_if_index_set = 1;
3966 else if (unformat (i, "sw_if_index %d", &sw_if_index))
3967 sw_if_index_set = 1;
3972 if (sw_if_index_set == 0)
3974 errmsg ("missing interface name or sw_if_index");
3977 if (mode == VNET_HW_IF_RX_MODE_UNKNOWN)
3979 errmsg ("missing rx-mode");
3983 /* Construct the API message */
3984 M (SW_INTERFACE_SET_RX_MODE, mp);
3985 mp->sw_if_index = ntohl (sw_if_index);
3986 mp->mode = (vl_api_rx_mode_t) mode;
3987 mp->queue_id_valid = queue_id_valid;
3988 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
3993 /* Wait for a reply, return the good/bad news... */
3999 api_sw_interface_set_rx_placement (vat_main_t * vam)
4001 unformat_input_t *i = vam->input;
4002 vl_api_sw_interface_set_rx_placement_t *mp;
4004 u8 sw_if_index_set = 0;
4007 u32 queue_id, thread_index;
4009 /* Parse args required to build the message */
4010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4012 if (unformat (i, "queue %d", &queue_id))
4014 else if (unformat (i, "main"))
4016 else if (unformat (i, "worker %d", &thread_index))
4019 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4020 sw_if_index_set = 1;
4021 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4022 sw_if_index_set = 1;
4027 if (sw_if_index_set == 0)
4029 errmsg ("missing interface name or sw_if_index");
4035 /* Construct the API message */
4036 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
4037 mp->sw_if_index = ntohl (sw_if_index);
4038 mp->worker_id = ntohl (thread_index);
4039 mp->queue_id = ntohl (queue_id);
4040 mp->is_main = is_main;
4044 /* Wait for a reply, return the good/bad news... */
4049 static void vl_api_sw_interface_rx_placement_details_t_handler
4050 (vl_api_sw_interface_rx_placement_details_t * mp)
4052 vat_main_t *vam = &vat_main;
4053 u32 worker_id = ntohl (mp->worker_id);
4056 "\n%-11d %-11s %-6d %-5d %-9s",
4057 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
4058 worker_id, ntohl (mp->queue_id),
4060 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
4063 static void vl_api_sw_interface_rx_placement_details_t_handler_json
4064 (vl_api_sw_interface_rx_placement_details_t * mp)
4066 vat_main_t *vam = &vat_main;
4067 vat_json_node_t *node = NULL;
4069 if (VAT_JSON_ARRAY != vam->json_tree.type)
4071 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4072 vat_json_init_array (&vam->json_tree);
4074 node = vat_json_array_add (&vam->json_tree);
4076 vat_json_init_object (node);
4077 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4078 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
4079 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
4080 vat_json_object_add_uint (node, "mode", mp->mode);
4084 api_sw_interface_rx_placement_dump (vat_main_t * vam)
4086 unformat_input_t *i = vam->input;
4087 vl_api_sw_interface_rx_placement_dump_t *mp;
4088 vl_api_control_ping_t *mp_ping;
4091 u8 sw_if_index_set = 0;
4093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4095 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4097 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4104 "\n%-11s %-11s %-6s %-5s %-4s",
4105 "sw_if_index", "main/worker", "thread", "queue", "mode");
4107 /* Dump Interface rx placement */
4108 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
4110 if (sw_if_index_set)
4111 mp->sw_if_index = htonl (sw_if_index);
4113 mp->sw_if_index = ~0;
4117 /* Use a control ping for synchronization */
4118 MPING (CONTROL_PING, mp_ping);
4126 api_sw_interface_clear_stats (vat_main_t * vam)
4128 unformat_input_t *i = vam->input;
4129 vl_api_sw_interface_clear_stats_t *mp;
4131 u8 sw_if_index_set = 0;
4134 /* Parse args required to build the message */
4135 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4137 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4138 sw_if_index_set = 1;
4139 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4140 sw_if_index_set = 1;
4145 /* Construct the API message */
4146 M (SW_INTERFACE_CLEAR_STATS, mp);
4148 if (sw_if_index_set == 1)
4149 mp->sw_if_index = ntohl (sw_if_index);
4151 mp->sw_if_index = ~0;
4156 /* Wait for a reply, return the good/bad news... */
4162 api_sw_interface_add_del_address (vat_main_t * vam)
4164 unformat_input_t *i = vam->input;
4165 vl_api_sw_interface_add_del_address_t *mp;
4167 u8 sw_if_index_set = 0;
4168 u8 is_add = 1, del_all = 0;
4169 u32 address_length = 0;
4170 u8 v4_address_set = 0;
4171 u8 v6_address_set = 0;
4172 ip4_address_t v4address;
4173 ip6_address_t v6address;
4176 /* Parse args required to build the message */
4177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4179 if (unformat (i, "del-all"))
4181 else if (unformat (i, "del"))
4184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4185 sw_if_index_set = 1;
4186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4187 sw_if_index_set = 1;
4188 else if (unformat (i, "%U/%d",
4189 unformat_ip4_address, &v4address, &address_length))
4191 else if (unformat (i, "%U/%d",
4192 unformat_ip6_address, &v6address, &address_length))
4198 if (sw_if_index_set == 0)
4200 errmsg ("missing interface name or sw_if_index");
4203 if (v4_address_set && v6_address_set)
4205 errmsg ("both v4 and v6 addresses set");
4208 if (!v4_address_set && !v6_address_set && !del_all)
4210 errmsg ("no addresses set");
4214 /* Construct the API message */
4215 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
4217 mp->sw_if_index = ntohl (sw_if_index);
4218 mp->is_add = is_add;
4219 mp->del_all = del_all;
4222 mp->prefix.address.af = ADDRESS_IP6;
4223 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
4227 mp->prefix.address.af = ADDRESS_IP4;
4228 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
4230 mp->prefix.len = address_length;
4235 /* Wait for a reply, return good/bad news */
4241 api_sw_interface_set_mpls_enable (vat_main_t * vam)
4243 unformat_input_t *i = vam->input;
4244 vl_api_sw_interface_set_mpls_enable_t *mp;
4246 u8 sw_if_index_set = 0;
4250 /* Parse args required to build the message */
4251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4253 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4254 sw_if_index_set = 1;
4255 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4256 sw_if_index_set = 1;
4257 else if (unformat (i, "disable"))
4259 else if (unformat (i, "dis"))
4265 if (sw_if_index_set == 0)
4267 errmsg ("missing interface name or sw_if_index");
4271 /* Construct the API message */
4272 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
4274 mp->sw_if_index = ntohl (sw_if_index);
4275 mp->enable = enable;
4280 /* Wait for a reply... */
4286 api_sw_interface_set_table (vat_main_t * vam)
4288 unformat_input_t *i = vam->input;
4289 vl_api_sw_interface_set_table_t *mp;
4290 u32 sw_if_index, vrf_id = 0;
4291 u8 sw_if_index_set = 0;
4295 /* Parse args required to build the message */
4296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4298 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4299 sw_if_index_set = 1;
4300 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4301 sw_if_index_set = 1;
4302 else if (unformat (i, "vrf %d", &vrf_id))
4304 else if (unformat (i, "ipv6"))
4310 if (sw_if_index_set == 0)
4312 errmsg ("missing interface name or sw_if_index");
4316 /* Construct the API message */
4317 M (SW_INTERFACE_SET_TABLE, mp);
4319 mp->sw_if_index = ntohl (sw_if_index);
4320 mp->is_ipv6 = is_ipv6;
4321 mp->vrf_id = ntohl (vrf_id);
4326 /* Wait for a reply... */
4331 static void vl_api_sw_interface_get_table_reply_t_handler
4332 (vl_api_sw_interface_get_table_reply_t * mp)
4334 vat_main_t *vam = &vat_main;
4336 print (vam->ofp, "%d", ntohl (mp->vrf_id));
4338 vam->retval = ntohl (mp->retval);
4339 vam->result_ready = 1;
4343 static void vl_api_sw_interface_get_table_reply_t_handler_json
4344 (vl_api_sw_interface_get_table_reply_t * mp)
4346 vat_main_t *vam = &vat_main;
4347 vat_json_node_t node;
4349 vat_json_init_object (&node);
4350 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4351 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
4353 vat_json_print (vam->ofp, &node);
4354 vat_json_free (&node);
4356 vam->retval = ntohl (mp->retval);
4357 vam->result_ready = 1;
4361 api_sw_interface_get_table (vat_main_t * vam)
4363 unformat_input_t *i = vam->input;
4364 vl_api_sw_interface_get_table_t *mp;
4366 u8 sw_if_index_set = 0;
4370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4373 sw_if_index_set = 1;
4374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4375 sw_if_index_set = 1;
4376 else if (unformat (i, "ipv6"))
4382 if (sw_if_index_set == 0)
4384 errmsg ("missing interface name or sw_if_index");
4388 M (SW_INTERFACE_GET_TABLE, mp);
4389 mp->sw_if_index = htonl (sw_if_index);
4390 mp->is_ipv6 = is_ipv6;
4398 api_sw_interface_set_vpath (vat_main_t * vam)
4400 unformat_input_t *i = vam->input;
4401 vl_api_sw_interface_set_vpath_t *mp;
4402 u32 sw_if_index = 0;
4403 u8 sw_if_index_set = 0;
4407 /* Parse args required to build the message */
4408 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4410 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4411 sw_if_index_set = 1;
4412 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4413 sw_if_index_set = 1;
4414 else if (unformat (i, "enable"))
4416 else if (unformat (i, "disable"))
4422 if (sw_if_index_set == 0)
4424 errmsg ("missing interface name or sw_if_index");
4428 /* Construct the API message */
4429 M (SW_INTERFACE_SET_VPATH, mp);
4431 mp->sw_if_index = ntohl (sw_if_index);
4432 mp->enable = is_enable;
4437 /* Wait for a reply... */
4443 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
4445 unformat_input_t *i = vam->input;
4446 vl_api_sw_interface_set_vxlan_bypass_t *mp;
4447 u32 sw_if_index = 0;
4448 u8 sw_if_index_set = 0;
4453 /* Parse args required to build the message */
4454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4456 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4457 sw_if_index_set = 1;
4458 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4459 sw_if_index_set = 1;
4460 else if (unformat (i, "enable"))
4462 else if (unformat (i, "disable"))
4464 else if (unformat (i, "ip4"))
4466 else if (unformat (i, "ip6"))
4472 if (sw_if_index_set == 0)
4474 errmsg ("missing interface name or sw_if_index");
4478 /* Construct the API message */
4479 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
4481 mp->sw_if_index = ntohl (sw_if_index);
4482 mp->enable = is_enable;
4483 mp->is_ipv6 = is_ipv6;
4488 /* Wait for a reply... */
4494 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
4496 unformat_input_t *i = vam->input;
4497 vl_api_sw_interface_set_l2_xconnect_t *mp;
4499 u8 rx_sw_if_index_set = 0;
4501 u8 tx_sw_if_index_set = 0;
4505 /* Parse args required to build the message */
4506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4508 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
4509 rx_sw_if_index_set = 1;
4510 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
4511 tx_sw_if_index_set = 1;
4512 else if (unformat (i, "rx"))
4514 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4516 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
4518 rx_sw_if_index_set = 1;
4523 else if (unformat (i, "tx"))
4525 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4527 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
4529 tx_sw_if_index_set = 1;
4534 else if (unformat (i, "enable"))
4536 else if (unformat (i, "disable"))
4542 if (rx_sw_if_index_set == 0)
4544 errmsg ("missing rx interface name or rx_sw_if_index");
4548 if (enable && (tx_sw_if_index_set == 0))
4550 errmsg ("missing tx interface name or tx_sw_if_index");
4554 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
4556 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4557 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
4558 mp->enable = enable;
4566 api_sw_interface_set_l2_bridge (vat_main_t * vam)
4568 unformat_input_t *i = vam->input;
4569 vl_api_sw_interface_set_l2_bridge_t *mp;
4570 vl_api_l2_port_type_t port_type;
4572 u8 rx_sw_if_index_set = 0;
4579 port_type = L2_API_PORT_TYPE_NORMAL;
4581 /* Parse args required to build the message */
4582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4584 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
4585 rx_sw_if_index_set = 1;
4586 else if (unformat (i, "bd_id %d", &bd_id))
4590 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
4591 rx_sw_if_index_set = 1;
4592 else if (unformat (i, "shg %d", &shg))
4594 else if (unformat (i, "bvi"))
4595 port_type = L2_API_PORT_TYPE_BVI;
4596 else if (unformat (i, "uu-fwd"))
4597 port_type = L2_API_PORT_TYPE_UU_FWD;
4598 else if (unformat (i, "enable"))
4600 else if (unformat (i, "disable"))
4606 if (rx_sw_if_index_set == 0)
4608 errmsg ("missing rx interface name or sw_if_index");
4612 if (enable && (bd_id_set == 0))
4614 errmsg ("missing bridge domain");
4618 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
4620 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
4621 mp->bd_id = ntohl (bd_id);
4623 mp->port_type = ntohl (port_type);
4624 mp->enable = enable;
4632 api_bridge_domain_dump (vat_main_t * vam)
4634 unformat_input_t *i = vam->input;
4635 vl_api_bridge_domain_dump_t *mp;
4636 vl_api_control_ping_t *mp_ping;
4640 /* Parse args required to build the message */
4641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4643 if (unformat (i, "bd_id %d", &bd_id))
4649 M (BRIDGE_DOMAIN_DUMP, mp);
4650 mp->bd_id = ntohl (bd_id);
4653 /* Use a control ping for synchronization */
4654 MPING (CONTROL_PING, mp_ping);
4662 api_bridge_domain_add_del (vat_main_t * vam)
4664 unformat_input_t *i = vam->input;
4665 vl_api_bridge_domain_add_del_t *mp;
4668 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
4673 /* Parse args required to build the message */
4674 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4676 if (unformat (i, "bd_id %d", &bd_id))
4678 else if (unformat (i, "flood %d", &flood))
4680 else if (unformat (i, "uu-flood %d", &uu_flood))
4682 else if (unformat (i, "forward %d", &forward))
4684 else if (unformat (i, "learn %d", &learn))
4686 else if (unformat (i, "arp-term %d", &arp_term))
4688 else if (unformat (i, "mac-age %d", &mac_age))
4690 else if (unformat (i, "bd-tag %s", &bd_tag))
4692 else if (unformat (i, "del"))
4695 flood = uu_flood = forward = learn = 0;
4703 errmsg ("missing bridge domain");
4710 errmsg ("mac age must be less than 256 ");
4715 if ((bd_tag) && (vec_len (bd_tag) > 63))
4717 errmsg ("bd-tag cannot be longer than 63");
4722 M (BRIDGE_DOMAIN_ADD_DEL, mp);
4724 mp->bd_id = ntohl (bd_id);
4726 mp->uu_flood = uu_flood;
4727 mp->forward = forward;
4729 mp->arp_term = arp_term;
4730 mp->is_add = is_add;
4731 mp->mac_age = (u8) mac_age;
4734 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
4735 mp->bd_tag[vec_len (bd_tag)] = 0;
4746 api_l2fib_flush_bd (vat_main_t * vam)
4748 unformat_input_t *i = vam->input;
4749 vl_api_l2fib_flush_bd_t *mp;
4753 /* Parse args required to build the message */
4754 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4756 if (unformat (i, "bd_id %d", &bd_id));
4763 errmsg ("missing bridge domain");
4767 M (L2FIB_FLUSH_BD, mp);
4769 mp->bd_id = htonl (bd_id);
4777 api_l2fib_flush_int (vat_main_t * vam)
4779 unformat_input_t *i = vam->input;
4780 vl_api_l2fib_flush_int_t *mp;
4781 u32 sw_if_index = ~0;
4784 /* Parse args required to build the message */
4785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4787 if (unformat (i, "sw_if_index %d", &sw_if_index));
4789 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
4794 if (sw_if_index == ~0)
4796 errmsg ("missing interface name or sw_if_index");
4800 M (L2FIB_FLUSH_INT, mp);
4802 mp->sw_if_index = ntohl (sw_if_index);
4810 api_l2fib_add_del (vat_main_t * vam)
4812 unformat_input_t *i = vam->input;
4813 vl_api_l2fib_add_del_t *mp;
4819 u32 sw_if_index = 0;
4820 u8 sw_if_index_set = 0;
4829 /* Parse args required to build the message */
4830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4832 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
4834 else if (unformat (i, "bd_id %d", &bd_id))
4836 else if (unformat (i, "sw_if_index %d", &sw_if_index))
4837 sw_if_index_set = 1;
4838 else if (unformat (i, "sw_if"))
4840 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4843 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
4844 sw_if_index_set = 1;
4849 else if (unformat (i, "static"))
4851 else if (unformat (i, "filter"))
4856 else if (unformat (i, "bvi"))
4861 else if (unformat (i, "del"))
4863 else if (unformat (i, "count %d", &count))
4871 errmsg ("missing mac address");
4877 errmsg ("missing bridge domain");
4881 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
4883 errmsg ("missing interface name or sw_if_index");
4889 /* Turn on async mode */
4890 vam->async_mode = 1;
4891 vam->async_errors = 0;
4892 before = vat_time_now (vam);
4895 for (j = 0; j < count; j++)
4897 M (L2FIB_ADD_DEL, mp);
4899 clib_memcpy (mp->mac, mac, 6);
4900 mp->bd_id = ntohl (bd_id);
4901 mp->is_add = is_add;
4902 mp->sw_if_index = ntohl (sw_if_index);
4906 mp->static_mac = static_mac;
4907 mp->filter_mac = filter_mac;
4908 mp->bvi_mac = bvi_mac;
4910 increment_mac_address (mac);
4917 vl_api_control_ping_t *mp_ping;
4920 /* Shut off async mode */
4921 vam->async_mode = 0;
4923 MPING (CONTROL_PING, mp_ping);
4926 timeout = vat_time_now (vam) + 1.0;
4927 while (vat_time_now (vam) < timeout)
4928 if (vam->result_ready == 1)
4933 if (vam->retval == -99)
4936 if (vam->async_errors > 0)
4938 errmsg ("%d asynchronous errors", vam->async_errors);
4941 vam->async_errors = 0;
4942 after = vat_time_now (vam);
4944 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
4945 count, after - before, count / (after - before));
4951 /* Wait for a reply... */
4955 /* Return the good/bad news */
4956 return (vam->retval);
4960 api_bridge_domain_set_mac_age (vat_main_t * vam)
4962 unformat_input_t *i = vam->input;
4963 vl_api_bridge_domain_set_mac_age_t *mp;
4968 /* Parse args required to build the message */
4969 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4971 if (unformat (i, "bd_id %d", &bd_id));
4972 else if (unformat (i, "mac-age %d", &mac_age));
4979 errmsg ("missing bridge domain");
4985 errmsg ("mac age must be less than 256 ");
4989 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
4991 mp->bd_id = htonl (bd_id);
4992 mp->mac_age = (u8) mac_age;
5000 api_l2_flags (vat_main_t * vam)
5002 unformat_input_t *i = vam->input;
5003 vl_api_l2_flags_t *mp;
5006 u8 sw_if_index_set = 0;
5010 /* Parse args required to build the message */
5011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5013 if (unformat (i, "sw_if_index %d", &sw_if_index))
5014 sw_if_index_set = 1;
5015 else if (unformat (i, "sw_if"))
5017 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5020 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5021 sw_if_index_set = 1;
5026 else if (unformat (i, "learn"))
5028 else if (unformat (i, "forward"))
5030 else if (unformat (i, "flood"))
5032 else if (unformat (i, "uu-flood"))
5033 flags |= L2_UU_FLOOD;
5034 else if (unformat (i, "arp-term"))
5035 flags |= L2_ARP_TERM;
5036 else if (unformat (i, "off"))
5038 else if (unformat (i, "disable"))
5044 if (sw_if_index_set == 0)
5046 errmsg ("missing interface name or sw_if_index");
5052 mp->sw_if_index = ntohl (sw_if_index);
5053 mp->feature_bitmap = ntohl (flags);
5054 mp->is_set = is_set;
5062 api_bridge_flags (vat_main_t * vam)
5064 unformat_input_t *i = vam->input;
5065 vl_api_bridge_flags_t *mp;
5069 bd_flags_t flags = 0;
5072 /* Parse args required to build the message */
5073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5075 if (unformat (i, "bd_id %d", &bd_id))
5077 else if (unformat (i, "learn"))
5078 flags |= BRIDGE_API_FLAG_LEARN;
5079 else if (unformat (i, "forward"))
5080 flags |= BRIDGE_API_FLAG_FWD;
5081 else if (unformat (i, "flood"))
5082 flags |= BRIDGE_API_FLAG_FLOOD;
5083 else if (unformat (i, "uu-flood"))
5084 flags |= BRIDGE_API_FLAG_UU_FLOOD;
5085 else if (unformat (i, "arp-term"))
5086 flags |= BRIDGE_API_FLAG_ARP_TERM;
5087 else if (unformat (i, "off"))
5089 else if (unformat (i, "disable"))
5097 errmsg ("missing bridge domain");
5101 M (BRIDGE_FLAGS, mp);
5103 mp->bd_id = ntohl (bd_id);
5104 mp->flags = ntohl (flags);
5105 mp->is_set = is_set;
5113 api_bd_ip_mac_add_del (vat_main_t * vam)
5115 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
5116 vl_api_mac_address_t mac = { 0 };
5117 unformat_input_t *i = vam->input;
5118 vl_api_bd_ip_mac_add_del_t *mp;
5127 /* Parse args required to build the message */
5128 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5130 if (unformat (i, "bd_id %d", &bd_id))
5134 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
5138 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
5142 else if (unformat (i, "del"))
5150 errmsg ("missing bridge domain");
5153 else if (ip_set == 0)
5155 errmsg ("missing IP address");
5158 else if (mac_set == 0)
5160 errmsg ("missing MAC address");
5164 M (BD_IP_MAC_ADD_DEL, mp);
5166 mp->entry.bd_id = ntohl (bd_id);
5167 mp->is_add = is_add;
5169 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
5170 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
5178 api_bd_ip_mac_flush (vat_main_t * vam)
5180 unformat_input_t *i = vam->input;
5181 vl_api_bd_ip_mac_flush_t *mp;
5186 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5188 if (unformat (i, "bd_id %d", &bd_id))
5198 errmsg ("missing bridge domain");
5202 M (BD_IP_MAC_FLUSH, mp);
5204 mp->bd_id = ntohl (bd_id);
5211 static void vl_api_bd_ip_mac_details_t_handler
5212 (vl_api_bd_ip_mac_details_t * mp)
5214 vat_main_t *vam = &vat_main;
5218 ntohl (mp->entry.bd_id),
5219 format_vl_api_mac_address, mp->entry.mac,
5220 format_vl_api_address, &mp->entry.ip);
5223 static void vl_api_bd_ip_mac_details_t_handler_json
5224 (vl_api_bd_ip_mac_details_t * mp)
5226 vat_main_t *vam = &vat_main;
5227 vat_json_node_t *node = NULL;
5229 if (VAT_JSON_ARRAY != vam->json_tree.type)
5231 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5232 vat_json_init_array (&vam->json_tree);
5234 node = vat_json_array_add (&vam->json_tree);
5236 vat_json_init_object (node);
5237 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
5238 vat_json_object_add_string_copy (node, "mac_address",
5239 format (0, "%U", format_vl_api_mac_address,
5243 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
5244 vat_json_object_add_string_copy (node, "ip_address", ip);
5249 api_bd_ip_mac_dump (vat_main_t * vam)
5251 unformat_input_t *i = vam->input;
5252 vl_api_bd_ip_mac_dump_t *mp;
5253 vl_api_control_ping_t *mp_ping;
5258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5260 if (unformat (i, "bd_id %d", &bd_id))
5269 "\n%-5s %-7s %-20s %-30s",
5270 "bd_id", "is_ipv6", "mac_address", "ip_address");
5272 /* Dump Bridge Domain Ip to Mac entries */
5273 M (BD_IP_MAC_DUMP, mp);
5276 mp->bd_id = htonl (bd_id);
5282 /* Use a control ping for synchronization */
5283 MPING (CONTROL_PING, mp_ping);
5291 api_tap_create_v2 (vat_main_t * vam)
5293 unformat_input_t *i = vam->input;
5294 vl_api_tap_create_v2_t *mp;
5298 u32 num_rx_queues = 0;
5299 u8 *host_if_name = 0;
5300 u8 host_if_name_set = 0;
5303 u8 host_mac_addr[6];
5304 u8 host_mac_addr_set = 0;
5305 u8 *host_bridge = 0;
5306 u8 host_bridge_set = 0;
5307 u8 host_ip4_prefix_set = 0;
5308 u8 host_ip6_prefix_set = 0;
5309 ip4_address_t host_ip4_addr;
5310 ip4_address_t host_ip4_gw;
5311 u8 host_ip4_gw_set = 0;
5312 u32 host_ip4_prefix_len = 0;
5313 ip6_address_t host_ip6_addr;
5314 ip6_address_t host_ip6_gw;
5315 u8 host_ip6_gw_set = 0;
5316 u32 host_ip6_prefix_len = 0;
5317 u32 host_mtu_size = 0;
5318 u8 host_mtu_set = 0;
5321 u32 rx_ring_sz = 0, tx_ring_sz = 0;
5323 clib_memset (mac_address, 0, sizeof (mac_address));
5325 /* Parse args required to build the message */
5326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5328 if (unformat (i, "id %u", &id))
5332 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
5334 else if (unformat (i, "host-if-name %s", &host_if_name))
5335 host_if_name_set = 1;
5336 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
5338 else if (unformat (i, "host-ns %s", &host_ns))
5340 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
5342 host_mac_addr_set = 1;
5343 else if (unformat (i, "host-bridge %s", &host_bridge))
5344 host_bridge_set = 1;
5345 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
5346 &host_ip4_addr, &host_ip4_prefix_len))
5347 host_ip4_prefix_set = 1;
5348 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
5349 &host_ip6_addr, &host_ip6_prefix_len))
5350 host_ip6_prefix_set = 1;
5351 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
5353 host_ip4_gw_set = 1;
5354 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
5356 host_ip6_gw_set = 1;
5357 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
5359 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
5361 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
5363 else if (unformat (i, "no-gso"))
5364 tap_flags &= ~TAP_API_FLAG_GSO;
5365 else if (unformat (i, "gso"))
5366 tap_flags |= TAP_API_FLAG_GSO;
5367 else if (unformat (i, "csum-offload"))
5368 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
5369 else if (unformat (i, "persist"))
5370 tap_flags |= TAP_API_FLAG_PERSIST;
5371 else if (unformat (i, "attach"))
5372 tap_flags |= TAP_API_FLAG_ATTACH;
5373 else if (unformat (i, "tun"))
5374 tap_flags |= TAP_API_FLAG_TUN;
5375 else if (unformat (i, "gro-coalesce"))
5376 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
5377 else if (unformat (i, "packed"))
5378 tap_flags |= TAP_API_FLAG_PACKED;
5379 else if (unformat (i, "in-order"))
5380 tap_flags |= TAP_API_FLAG_IN_ORDER;
5385 if (vec_len (host_if_name) > 63)
5387 errmsg ("tap name too long. ");
5390 if (vec_len (host_ns) > 63)
5392 errmsg ("host name space too long. ");
5395 if (vec_len (host_bridge) > 63)
5397 errmsg ("host bridge name too long. ");
5400 if (host_ip4_prefix_len > 32)
5402 errmsg ("host ip4 prefix length not valid. ");
5405 if (host_ip6_prefix_len > 128)
5407 errmsg ("host ip6 prefix length not valid. ");
5410 if (!is_pow2 (rx_ring_sz))
5412 errmsg ("rx ring size must be power of 2. ");
5415 if (rx_ring_sz > 32768)
5417 errmsg ("rx ring size must be 32768 or lower. ");
5420 if (!is_pow2 (tx_ring_sz))
5422 errmsg ("tx ring size must be power of 2. ");
5425 if (tx_ring_sz > 32768)
5427 errmsg ("tx ring size must be 32768 or lower. ");
5430 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
5432 errmsg ("host MTU size must be in between 64 and 65355. ");
5436 /* Construct the API message */
5437 M (TAP_CREATE_V2, mp);
5439 mp->id = ntohl (id);
5440 mp->use_random_mac = random_mac;
5441 mp->num_rx_queues = (u8) num_rx_queues;
5442 mp->tx_ring_sz = ntohs (tx_ring_sz);
5443 mp->rx_ring_sz = ntohs (rx_ring_sz);
5444 mp->host_mtu_set = host_mtu_set;
5445 mp->host_mtu_size = ntohl (host_mtu_size);
5446 mp->host_mac_addr_set = host_mac_addr_set;
5447 mp->host_ip4_prefix_set = host_ip4_prefix_set;
5448 mp->host_ip6_prefix_set = host_ip6_prefix_set;
5449 mp->host_ip4_gw_set = host_ip4_gw_set;
5450 mp->host_ip6_gw_set = host_ip6_gw_set;
5451 mp->tap_flags = ntohl (tap_flags);
5452 mp->host_namespace_set = host_ns_set;
5453 mp->host_if_name_set = host_if_name_set;
5454 mp->host_bridge_set = host_bridge_set;
5456 if (random_mac == 0)
5457 clib_memcpy (mp->mac_address, mac_address, 6);
5458 if (host_mac_addr_set)
5459 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
5460 if (host_if_name_set)
5461 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
5463 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
5464 if (host_bridge_set)
5465 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
5466 if (host_ip4_prefix_set)
5468 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
5469 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
5471 if (host_ip6_prefix_set)
5473 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
5474 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
5476 if (host_ip4_gw_set)
5477 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
5478 if (host_ip6_gw_set)
5479 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
5482 vec_free (host_if_name);
5483 vec_free (host_bridge);
5488 /* Wait for a reply... */
5494 api_tap_delete_v2 (vat_main_t * vam)
5496 unformat_input_t *i = vam->input;
5497 vl_api_tap_delete_v2_t *mp;
5498 u32 sw_if_index = ~0;
5499 u8 sw_if_index_set = 0;
5502 /* Parse args required to build the message */
5503 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5505 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5506 sw_if_index_set = 1;
5507 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5508 sw_if_index_set = 1;
5513 if (sw_if_index_set == 0)
5515 errmsg ("missing vpp interface name. ");
5519 /* Construct the API message */
5520 M (TAP_DELETE_V2, mp);
5522 mp->sw_if_index = ntohl (sw_if_index);
5527 /* Wait for a reply... */
5533 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
5535 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
5538 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
5541 addr->domain = x[0];
5544 addr->function = x[3];
5550 api_virtio_pci_create_v2 (vat_main_t * vam)
5552 unformat_input_t *i = vam->input;
5553 vl_api_virtio_pci_create_v2_t *mp;
5557 u64 features = (u64) ~ (0ULL);
5558 u32 virtio_flags = 0;
5561 clib_memset (mac_address, 0, sizeof (mac_address));
5563 /* Parse args required to build the message */
5564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5566 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
5570 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
5572 else if (unformat (i, "features 0x%llx", &features))
5574 else if (unformat (i, "gso-enabled"))
5575 virtio_flags |= VIRTIO_API_FLAG_GSO;
5576 else if (unformat (i, "csum-offload-enabled"))
5577 virtio_flags |= VIRTIO_API_FLAG_CSUM_OFFLOAD;
5578 else if (unformat (i, "gro-coalesce"))
5579 virtio_flags |= VIRTIO_API_FLAG_GRO_COALESCE;
5580 else if (unformat (i, "packed"))
5581 virtio_flags |= VIRTIO_API_FLAG_PACKED;
5582 else if (unformat (i, "in-order"))
5583 virtio_flags |= VIRTIO_API_FLAG_IN_ORDER;
5584 else if (unformat (i, "buffering"))
5585 virtio_flags |= VIRTIO_API_FLAG_BUFFERING;
5592 errmsg ("pci address must be non zero. ");
5596 /* Construct the API message */
5597 M (VIRTIO_PCI_CREATE_V2, mp);
5599 mp->use_random_mac = random_mac;
5601 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
5602 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
5603 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
5604 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
5606 mp->features = clib_host_to_net_u64 (features);
5607 mp->virtio_flags = clib_host_to_net_u32 (virtio_flags);
5609 if (random_mac == 0)
5610 clib_memcpy (mp->mac_address, mac_address, 6);
5615 /* Wait for a reply... */
5621 api_virtio_pci_delete (vat_main_t * vam)
5623 unformat_input_t *i = vam->input;
5624 vl_api_virtio_pci_delete_t *mp;
5625 u32 sw_if_index = ~0;
5626 u8 sw_if_index_set = 0;
5629 /* Parse args required to build the message */
5630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5633 sw_if_index_set = 1;
5634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5635 sw_if_index_set = 1;
5640 if (sw_if_index_set == 0)
5642 errmsg ("missing vpp interface name. ");
5646 /* Construct the API message */
5647 M (VIRTIO_PCI_DELETE, mp);
5649 mp->sw_if_index = htonl (sw_if_index);
5654 /* Wait for a reply... */
5660 api_bond_create (vat_main_t * vam)
5662 unformat_input_t *i = vam->input;
5663 vl_api_bond_create_t *mp;
5673 clib_memset (mac_address, 0, sizeof (mac_address));
5676 /* Parse args required to build the message */
5677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5679 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
5681 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
5682 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
5684 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
5687 else if (unformat (i, "numa-only"))
5689 else if (unformat (i, "id %u", &id))
5695 if (mode_is_set == 0)
5697 errmsg ("Missing bond mode. ");
5701 /* Construct the API message */
5702 M (BOND_CREATE, mp);
5704 mp->use_custom_mac = custom_mac;
5706 mp->mode = htonl (mode);
5707 mp->lb = htonl (lb);
5708 mp->id = htonl (id);
5709 mp->numa_only = numa_only;
5712 clib_memcpy (mp->mac_address, mac_address, 6);
5717 /* Wait for a reply... */
5723 api_bond_create2 (vat_main_t * vam)
5725 unformat_input_t *i = vam->input;
5726 vl_api_bond_create2_t *mp;
5737 clib_memset (mac_address, 0, sizeof (mac_address));
5740 /* Parse args required to build the message */
5741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5743 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
5745 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
5746 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
5748 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
5751 else if (unformat (i, "numa-only"))
5753 else if (unformat (i, "gso"))
5755 else if (unformat (i, "id %u", &id))
5761 if (mode_is_set == 0)
5763 errmsg ("Missing bond mode. ");
5767 /* Construct the API message */
5768 M (BOND_CREATE2, mp);
5770 mp->use_custom_mac = custom_mac;
5772 mp->mode = htonl (mode);
5773 mp->lb = htonl (lb);
5774 mp->id = htonl (id);
5775 mp->numa_only = numa_only;
5776 mp->enable_gso = gso;
5779 clib_memcpy (mp->mac_address, mac_address, 6);
5784 /* Wait for a reply... */
5790 api_bond_delete (vat_main_t * vam)
5792 unformat_input_t *i = vam->input;
5793 vl_api_bond_delete_t *mp;
5794 u32 sw_if_index = ~0;
5795 u8 sw_if_index_set = 0;
5798 /* Parse args required to build the message */
5799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5801 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5802 sw_if_index_set = 1;
5803 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5804 sw_if_index_set = 1;
5809 if (sw_if_index_set == 0)
5811 errmsg ("missing vpp interface name. ");
5815 /* Construct the API message */
5816 M (BOND_DELETE, mp);
5818 mp->sw_if_index = ntohl (sw_if_index);
5823 /* Wait for a reply... */
5829 api_bond_add_member (vat_main_t * vam)
5831 unformat_input_t *i = vam->input;
5832 vl_api_bond_add_member_t *mp;
5833 u32 bond_sw_if_index;
5837 u32 bond_sw_if_index_is_set = 0;
5839 u8 sw_if_index_is_set = 0;
5841 /* Parse args required to build the message */
5842 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5844 if (unformat (i, "sw_if_index %d", &sw_if_index))
5845 sw_if_index_is_set = 1;
5846 else if (unformat (i, "bond %u", &bond_sw_if_index))
5847 bond_sw_if_index_is_set = 1;
5848 else if (unformat (i, "passive %d", &is_passive))
5850 else if (unformat (i, "long-timeout %d", &is_long_timeout))
5856 if (bond_sw_if_index_is_set == 0)
5858 errmsg ("Missing bond sw_if_index. ");
5861 if (sw_if_index_is_set == 0)
5863 errmsg ("Missing member sw_if_index. ");
5867 /* Construct the API message */
5868 M (BOND_ADD_MEMBER, mp);
5870 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
5871 mp->sw_if_index = ntohl (sw_if_index);
5872 mp->is_long_timeout = is_long_timeout;
5873 mp->is_passive = is_passive;
5878 /* Wait for a reply... */
5884 api_bond_detach_member (vat_main_t * vam)
5886 unformat_input_t *i = vam->input;
5887 vl_api_bond_detach_member_t *mp;
5888 u32 sw_if_index = ~0;
5889 u8 sw_if_index_set = 0;
5892 /* Parse args required to build the message */
5893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5895 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5896 sw_if_index_set = 1;
5897 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5898 sw_if_index_set = 1;
5903 if (sw_if_index_set == 0)
5905 errmsg ("missing vpp interface name. ");
5909 /* Construct the API message */
5910 M (BOND_DETACH_MEMBER, mp);
5912 mp->sw_if_index = ntohl (sw_if_index);
5917 /* Wait for a reply... */
5923 api_ip_table_add_del (vat_main_t * vam)
5925 unformat_input_t *i = vam->input;
5926 vl_api_ip_table_add_del_t *mp;
5932 /* Parse args required to build the message */
5933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5935 if (unformat (i, "ipv6"))
5937 else if (unformat (i, "del"))
5939 else if (unformat (i, "add"))
5941 else if (unformat (i, "table %d", &table_id))
5945 clib_warning ("parse error '%U'", format_unformat_error, i);
5952 errmsg ("missing table-ID");
5956 /* Construct the API message */
5957 M (IP_TABLE_ADD_DEL, mp);
5959 mp->table.table_id = ntohl (table_id);
5960 mp->table.is_ip6 = is_ipv6;
5961 mp->is_add = is_add;
5966 /* Wait for a reply... */
5973 unformat_fib_path (unformat_input_t * input, va_list * args)
5975 vat_main_t *vam = va_arg (*args, vat_main_t *);
5976 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
5977 u32 weight, preference;
5978 mpls_label_t out_label;
5980 clib_memset (path, 0, sizeof (*path));
5982 path->sw_if_index = ~0;
5986 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
5988 if (unformat (input, "%U %U",
5989 unformat_vl_api_ip4_address,
5990 &path->nh.address.ip4,
5991 api_unformat_sw_if_index, vam, &path->sw_if_index))
5993 path->proto = FIB_API_PATH_NH_PROTO_IP4;
5995 else if (unformat (input, "%U %U",
5996 unformat_vl_api_ip6_address,
5997 &path->nh.address.ip6,
5998 api_unformat_sw_if_index, vam, &path->sw_if_index))
6000 path->proto = FIB_API_PATH_NH_PROTO_IP6;
6002 else if (unformat (input, "weight %u", &weight))
6004 path->weight = weight;
6006 else if (unformat (input, "preference %u", &preference))
6008 path->preference = preference;
6010 else if (unformat (input, "%U next-hop-table %d",
6011 unformat_vl_api_ip4_address,
6012 &path->nh.address.ip4, &path->table_id))
6014 path->proto = FIB_API_PATH_NH_PROTO_IP4;
6016 else if (unformat (input, "%U next-hop-table %d",
6017 unformat_vl_api_ip6_address,
6018 &path->nh.address.ip6, &path->table_id))
6020 path->proto = FIB_API_PATH_NH_PROTO_IP6;
6022 else if (unformat (input, "%U",
6023 unformat_vl_api_ip4_address, &path->nh.address.ip4))
6026 * the recursive next-hops are by default in the default table
6029 path->sw_if_index = ~0;
6030 path->proto = FIB_API_PATH_NH_PROTO_IP4;
6032 else if (unformat (input, "%U",
6033 unformat_vl_api_ip6_address, &path->nh.address.ip6))
6036 * the recursive next-hops are by default in the default table
6039 path->sw_if_index = ~0;
6040 path->proto = FIB_API_PATH_NH_PROTO_IP6;
6042 else if (unformat (input, "resolve-via-host"))
6044 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
6046 else if (unformat (input, "resolve-via-attached"))
6048 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
6050 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
6052 path->type = FIB_API_PATH_TYPE_LOCAL;
6053 path->sw_if_index = ~0;
6054 path->proto = FIB_API_PATH_NH_PROTO_IP4;
6056 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
6058 path->type = FIB_API_PATH_TYPE_LOCAL;
6059 path->sw_if_index = ~0;
6060 path->proto = FIB_API_PATH_NH_PROTO_IP6;
6062 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
6064 else if (unformat (input, "via-label %d", &path->nh.via_label))
6066 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
6067 path->sw_if_index = ~0;
6069 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
6071 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
6072 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
6074 else if (unformat (input, "local"))
6076 path->type = FIB_API_PATH_TYPE_LOCAL;
6078 else if (unformat (input, "out-labels"))
6080 while (unformat (input, "%d", &out_label))
6082 path->label_stack[path->n_labels].label = out_label;
6083 path->label_stack[path->n_labels].is_uniform = 0;
6084 path->label_stack[path->n_labels].ttl = 64;
6088 else if (unformat (input, "via"))
6090 /* new path, back up and return */
6091 unformat_put_input (input);
6092 unformat_put_input (input);
6093 unformat_put_input (input);
6094 unformat_put_input (input);
6103 path->proto = ntohl (path->proto);
6104 path->type = ntohl (path->type);
6105 path->flags = ntohl (path->flags);
6106 path->table_id = ntohl (path->table_id);
6107 path->sw_if_index = ntohl (path->sw_if_index);
6113 api_ip_route_add_del (vat_main_t * vam)
6115 unformat_input_t *i = vam->input;
6116 vl_api_ip_route_add_del_t *mp;
6119 u8 is_multipath = 0;
6122 vl_api_prefix_t pfx = { };
6123 vl_api_fib_path_t paths[8];
6127 u32 random_add_del = 0;
6128 u32 *random_vector = 0;
6129 u32 random_seed = 0xdeaddabe;
6131 /* Parse args required to build the message */
6132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6134 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
6136 else if (unformat (i, "del"))
6138 else if (unformat (i, "add"))
6140 else if (unformat (i, "vrf %d", &vrf_id))
6142 else if (unformat (i, "count %d", &count))
6144 else if (unformat (i, "random"))
6146 else if (unformat (i, "multipath"))
6148 else if (unformat (i, "seed %d", &random_seed))
6152 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
6155 if (8 == path_count)
6157 errmsg ("max 8 paths");
6163 clib_warning ("parse error '%U'", format_unformat_error, i);
6170 errmsg ("specify a path; via ...");
6173 if (prefix_set == 0)
6175 errmsg ("missing prefix");
6179 /* Generate a pile of unique, random routes */
6182 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
6183 u32 this_random_address;
6186 random_hash = hash_create (count, sizeof (uword));
6188 hash_set (random_hash, i->as_u32, 1);
6189 for (j = 0; j <= count; j++)
6193 this_random_address = random_u32 (&random_seed);
6194 this_random_address =
6195 clib_host_to_net_u32 (this_random_address);
6197 while (hash_get (random_hash, this_random_address));
6198 vec_add1 (random_vector, this_random_address);
6199 hash_set (random_hash, this_random_address, 1);
6201 hash_free (random_hash);
6202 set_ip4_address (&pfx.address, random_vector[0]);
6207 /* Turn on async mode */
6208 vam->async_mode = 1;
6209 vam->async_errors = 0;
6210 before = vat_time_now (vam);
6213 for (j = 0; j < count; j++)
6215 /* Construct the API message */
6216 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
6218 mp->is_add = is_add;
6219 mp->is_multipath = is_multipath;
6221 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
6222 mp->route.table_id = ntohl (vrf_id);
6223 mp->route.n_paths = path_count;
6225 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
6228 set_ip4_address (&pfx.address, random_vector[j + 1]);
6230 increment_address (&pfx.address);
6233 /* If we receive SIGTERM, stop now... */
6238 /* When testing multiple add/del ops, use a control-ping to sync */
6241 vl_api_control_ping_t *mp_ping;
6245 /* Shut off async mode */
6246 vam->async_mode = 0;
6248 MPING (CONTROL_PING, mp_ping);
6251 timeout = vat_time_now (vam) + 1.0;
6252 while (vat_time_now (vam) < timeout)
6253 if (vam->result_ready == 1)
6258 if (vam->retval == -99)
6261 if (vam->async_errors > 0)
6263 errmsg ("%d asynchronous errors", vam->async_errors);
6266 vam->async_errors = 0;
6267 after = vat_time_now (vam);
6269 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6273 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6274 count, after - before, count / (after - before));
6280 /* Wait for a reply... */
6285 /* Return the good/bad news */
6286 return (vam->retval);
6290 api_ip_mroute_add_del (vat_main_t * vam)
6292 unformat_input_t *i = vam->input;
6293 u8 path_set = 0, prefix_set = 0, is_add = 1;
6294 vl_api_ip_mroute_add_del_t *mp;
6295 mfib_entry_flags_t eflags = 0;
6296 vl_api_mfib_path_t path;
6297 vl_api_mprefix_t pfx = { };
6301 /* Parse args required to build the message */
6302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6304 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
6307 pfx.grp_address_length = htons (pfx.grp_address_length);
6309 else if (unformat (i, "del"))
6311 else if (unformat (i, "add"))
6313 else if (unformat (i, "vrf %d", &vrf_id))
6315 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
6316 path.itf_flags = htonl (path.itf_flags);
6317 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6319 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
6323 clib_warning ("parse error '%U'", format_unformat_error, i);
6328 if (prefix_set == 0)
6330 errmsg ("missing addresses\n");
6335 errmsg ("missing path\n");
6339 /* Construct the API message */
6340 M (IP_MROUTE_ADD_DEL, mp);
6342 mp->is_add = is_add;
6343 mp->is_multipath = 1;
6345 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
6346 mp->route.table_id = htonl (vrf_id);
6347 mp->route.n_paths = 1;
6348 mp->route.entry_flags = htonl (eflags);
6350 clib_memcpy (&mp->route.paths, &path, sizeof (path));
6354 /* Wait for a reply... */
6360 api_mpls_table_add_del (vat_main_t * vam)
6362 unformat_input_t *i = vam->input;
6363 vl_api_mpls_table_add_del_t *mp;
6368 /* Parse args required to build the message */
6369 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6371 if (unformat (i, "table %d", &table_id))
6373 else if (unformat (i, "del"))
6375 else if (unformat (i, "add"))
6379 clib_warning ("parse error '%U'", format_unformat_error, i);
6386 errmsg ("missing table-ID");
6390 /* Construct the API message */
6391 M (MPLS_TABLE_ADD_DEL, mp);
6393 mp->mt_table.mt_table_id = ntohl (table_id);
6394 mp->mt_is_add = is_add;
6399 /* Wait for a reply... */
6406 api_mpls_route_add_del (vat_main_t * vam)
6408 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
6409 mpls_label_t local_label = MPLS_LABEL_INVALID;
6410 unformat_input_t *i = vam->input;
6411 vl_api_mpls_route_add_del_t *mp;
6412 vl_api_fib_path_t paths[8];
6416 /* Parse args required to build the message */
6417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6419 if (unformat (i, "%d", &local_label))
6421 else if (unformat (i, "eos"))
6423 else if (unformat (i, "non-eos"))
6425 else if (unformat (i, "del"))
6427 else if (unformat (i, "add"))
6429 else if (unformat (i, "multipath"))
6431 else if (unformat (i, "count %d", &count))
6435 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
6438 if (8 == path_count)
6440 errmsg ("max 8 paths");
6446 clib_warning ("parse error '%U'", format_unformat_error, i);
6453 errmsg ("specify a path; via ...");
6457 if (MPLS_LABEL_INVALID == local_label)
6459 errmsg ("missing label");
6465 /* Turn on async mode */
6466 vam->async_mode = 1;
6467 vam->async_errors = 0;
6468 before = vat_time_now (vam);
6471 for (j = 0; j < count; j++)
6473 /* Construct the API message */
6474 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
6476 mp->mr_is_add = is_add;
6477 mp->mr_is_multipath = is_multipath;
6479 mp->mr_route.mr_label = local_label;
6480 mp->mr_route.mr_eos = is_eos;
6481 mp->mr_route.mr_table_id = 0;
6482 mp->mr_route.mr_n_paths = path_count;
6484 clib_memcpy (&mp->mr_route.mr_paths, paths,
6485 sizeof (paths[0]) * path_count);
6491 /* If we receive SIGTERM, stop now... */
6496 /* When testing multiple add/del ops, use a control-ping to sync */
6499 vl_api_control_ping_t *mp_ping;
6503 /* Shut off async mode */
6504 vam->async_mode = 0;
6506 MPING (CONTROL_PING, mp_ping);
6509 timeout = vat_time_now (vam) + 1.0;
6510 while (vat_time_now (vam) < timeout)
6511 if (vam->result_ready == 1)
6516 if (vam->retval == -99)
6519 if (vam->async_errors > 0)
6521 errmsg ("%d asynchronous errors", vam->async_errors);
6524 vam->async_errors = 0;
6525 after = vat_time_now (vam);
6527 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6531 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6532 count, after - before, count / (after - before));
6538 /* Wait for a reply... */
6543 /* Return the good/bad news */
6544 return (vam->retval);
6549 api_mpls_ip_bind_unbind (vat_main_t * vam)
6551 unformat_input_t *i = vam->input;
6552 vl_api_mpls_ip_bind_unbind_t *mp;
6553 u32 ip_table_id = 0;
6555 vl_api_prefix_t pfx;
6557 mpls_label_t local_label = MPLS_LABEL_INVALID;
6560 /* Parse args required to build the message */
6561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6563 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
6565 else if (unformat (i, "%d", &local_label))
6567 else if (unformat (i, "table-id %d", &ip_table_id))
6569 else if (unformat (i, "unbind"))
6571 else if (unformat (i, "bind"))
6575 clib_warning ("parse error '%U'", format_unformat_error, i);
6582 errmsg ("IP prefix not set");
6586 if (MPLS_LABEL_INVALID == local_label)
6588 errmsg ("missing label");
6592 /* Construct the API message */
6593 M (MPLS_IP_BIND_UNBIND, mp);
6595 mp->mb_is_bind = is_bind;
6596 mp->mb_ip_table_id = ntohl (ip_table_id);
6597 mp->mb_mpls_table_id = 0;
6598 mp->mb_label = ntohl (local_label);
6599 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
6604 /* Wait for a reply... */
6611 api_sr_mpls_policy_add (vat_main_t * vam)
6613 unformat_input_t *i = vam->input;
6614 vl_api_sr_mpls_policy_add_t *mp;
6620 u32 *segments = NULL;
6623 /* Parse args required to build the message */
6624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6626 if (unformat (i, "bsid %d", &bsid))
6628 else if (unformat (i, "weight %d", &weight))
6630 else if (unformat (i, "spray"))
6632 else if (unformat (i, "next %d", &sid))
6635 vec_add1 (segments, htonl (sid));
6639 clib_warning ("parse error '%U'", format_unformat_error, i);
6646 errmsg ("bsid not set");
6650 if (n_segments == 0)
6652 errmsg ("no sid in segment stack");
6656 /* Construct the API message */
6657 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
6659 mp->bsid = htonl (bsid);
6660 mp->weight = htonl (weight);
6661 mp->is_spray = type;
6662 mp->n_segments = n_segments;
6663 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
6664 vec_free (segments);
6669 /* Wait for a reply... */
6675 api_sr_mpls_policy_del (vat_main_t * vam)
6677 unformat_input_t *i = vam->input;
6678 vl_api_sr_mpls_policy_del_t *mp;
6682 /* Parse args required to build the message */
6683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6685 if (unformat (i, "bsid %d", &bsid))
6689 clib_warning ("parse error '%U'", format_unformat_error, i);
6696 errmsg ("bsid not set");
6700 /* Construct the API message */
6701 M (SR_MPLS_POLICY_DEL, mp);
6703 mp->bsid = htonl (bsid);
6708 /* Wait for a reply... */
6714 api_bier_table_add_del (vat_main_t * vam)
6716 unformat_input_t *i = vam->input;
6717 vl_api_bier_table_add_del_t *mp;
6719 u32 set = 0, sub_domain = 0, hdr_len = 3;
6720 mpls_label_t local_label = MPLS_LABEL_INVALID;
6723 /* Parse args required to build the message */
6724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6726 if (unformat (i, "sub-domain %d", &sub_domain))
6728 else if (unformat (i, "set %d", &set))
6730 else if (unformat (i, "label %d", &local_label))
6732 else if (unformat (i, "hdr-len %d", &hdr_len))
6734 else if (unformat (i, "add"))
6736 else if (unformat (i, "del"))
6740 clib_warning ("parse error '%U'", format_unformat_error, i);
6745 if (MPLS_LABEL_INVALID == local_label)
6747 errmsg ("missing label\n");
6751 /* Construct the API message */
6752 M (BIER_TABLE_ADD_DEL, mp);
6754 mp->bt_is_add = is_add;
6755 mp->bt_label = ntohl (local_label);
6756 mp->bt_tbl_id.bt_set = set;
6757 mp->bt_tbl_id.bt_sub_domain = sub_domain;
6758 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
6763 /* Wait for a reply... */
6770 api_bier_route_add_del (vat_main_t * vam)
6772 unformat_input_t *i = vam->input;
6773 vl_api_bier_route_add_del_t *mp;
6775 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
6776 ip4_address_t v4_next_hop_address;
6777 ip6_address_t v6_next_hop_address;
6778 u8 next_hop_set = 0;
6779 u8 next_hop_proto_is_ip4 = 1;
6780 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6783 /* Parse args required to build the message */
6784 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6786 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
6788 next_hop_proto_is_ip4 = 1;
6791 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
6793 next_hop_proto_is_ip4 = 0;
6796 if (unformat (i, "sub-domain %d", &sub_domain))
6798 else if (unformat (i, "set %d", &set))
6800 else if (unformat (i, "hdr-len %d", &hdr_len))
6802 else if (unformat (i, "bp %d", &bp))
6804 else if (unformat (i, "add"))
6806 else if (unformat (i, "del"))
6808 else if (unformat (i, "out-label %d", &next_hop_out_label))
6812 clib_warning ("parse error '%U'", format_unformat_error, i);
6817 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
6819 errmsg ("next hop / label set\n");
6824 errmsg ("bit=position not set\n");
6828 /* Construct the API message */
6829 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
6831 mp->br_is_add = is_add;
6832 mp->br_route.br_tbl_id.bt_set = set;
6833 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
6834 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
6835 mp->br_route.br_bp = ntohs (bp);
6836 mp->br_route.br_n_paths = 1;
6837 mp->br_route.br_paths[0].n_labels = 1;
6838 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
6839 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
6840 FIB_API_PATH_NH_PROTO_IP4 :
6841 FIB_API_PATH_NH_PROTO_IP6);
6843 if (next_hop_proto_is_ip4)
6845 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
6846 &v4_next_hop_address, sizeof (v4_next_hop_address));
6850 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
6851 &v6_next_hop_address, sizeof (v6_next_hop_address));
6857 /* Wait for a reply... */
6864 api_mpls_tunnel_add_del (vat_main_t * vam)
6866 unformat_input_t *i = vam->input;
6867 vl_api_mpls_tunnel_add_del_t *mp;
6869 vl_api_fib_path_t paths[8];
6870 u32 sw_if_index = ~0;
6876 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6878 if (unformat (i, "add"))
6882 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
6884 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
6886 else if (unformat (i, "l2-only"))
6890 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
6893 if (8 == path_count)
6895 errmsg ("max 8 paths");
6901 clib_warning ("parse error '%U'", format_unformat_error, i);
6906 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
6908 mp->mt_is_add = is_add;
6909 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
6910 mp->mt_tunnel.mt_l2_only = l2_only;
6911 mp->mt_tunnel.mt_is_multicast = 0;
6912 mp->mt_tunnel.mt_n_paths = path_count;
6914 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
6915 sizeof (paths[0]) * path_count);
6923 api_sw_interface_set_unnumbered (vat_main_t * vam)
6925 unformat_input_t *i = vam->input;
6926 vl_api_sw_interface_set_unnumbered_t *mp;
6928 u32 unnum_sw_index = ~0;
6930 u8 sw_if_index_set = 0;
6933 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6935 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6936 sw_if_index_set = 1;
6937 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6938 sw_if_index_set = 1;
6939 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
6941 else if (unformat (i, "del"))
6945 clib_warning ("parse error '%U'", format_unformat_error, i);
6950 if (sw_if_index_set == 0)
6952 errmsg ("missing interface name or sw_if_index");
6956 M (SW_INTERFACE_SET_UNNUMBERED, mp);
6958 mp->sw_if_index = ntohl (sw_if_index);
6959 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
6960 mp->is_add = is_add;
6969 api_create_vlan_subif (vat_main_t * vam)
6971 unformat_input_t *i = vam->input;
6972 vl_api_create_vlan_subif_t *mp;
6974 u8 sw_if_index_set = 0;
6979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6981 if (unformat (i, "sw_if_index %d", &sw_if_index))
6982 sw_if_index_set = 1;
6984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6985 sw_if_index_set = 1;
6986 else if (unformat (i, "vlan %d", &vlan_id))
6990 clib_warning ("parse error '%U'", format_unformat_error, i);
6995 if (sw_if_index_set == 0)
6997 errmsg ("missing interface name or sw_if_index");
7001 if (vlan_id_set == 0)
7003 errmsg ("missing vlan_id");
7006 M (CREATE_VLAN_SUBIF, mp);
7008 mp->sw_if_index = ntohl (sw_if_index);
7009 mp->vlan_id = ntohl (vlan_id);
7016 #define foreach_create_subif_bit \
7023 _(outer_vlan_id_any) \
7024 _(inner_vlan_id_any)
7026 #define foreach_create_subif_flag \
7031 _(4, "exact_match") \
7032 _(5, "default_sub") \
7033 _(6, "outer_vlan_id_any") \
7034 _(7, "inner_vlan_id_any")
7037 api_create_subif (vat_main_t * vam)
7039 unformat_input_t *i = vam->input;
7040 vl_api_create_subif_t *mp;
7042 u8 sw_if_index_set = 0;
7045 u32 __attribute__ ((unused)) no_tags = 0;
7046 u32 __attribute__ ((unused)) one_tag = 0;
7047 u32 __attribute__ ((unused)) two_tags = 0;
7048 u32 __attribute__ ((unused)) dot1ad = 0;
7049 u32 __attribute__ ((unused)) exact_match = 0;
7050 u32 __attribute__ ((unused)) default_sub = 0;
7051 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
7052 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
7054 u16 outer_vlan_id = 0;
7055 u16 inner_vlan_id = 0;
7058 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7060 if (unformat (i, "sw_if_index %d", &sw_if_index))
7061 sw_if_index_set = 1;
7063 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7064 sw_if_index_set = 1;
7065 else if (unformat (i, "sub_id %d", &sub_id))
7067 else if (unformat (i, "outer_vlan_id %d", &tmp))
7068 outer_vlan_id = tmp;
7069 else if (unformat (i, "inner_vlan_id %d", &tmp))
7070 inner_vlan_id = tmp;
7072 #define _(a) else if (unformat (i, #a)) a = 1 ;
7073 foreach_create_subif_bit
7077 clib_warning ("parse error '%U'", format_unformat_error, i);
7082 if (sw_if_index_set == 0)
7084 errmsg ("missing interface name or sw_if_index");
7088 if (sub_id_set == 0)
7090 errmsg ("missing sub_id");
7093 M (CREATE_SUBIF, mp);
7095 mp->sw_if_index = ntohl (sw_if_index);
7096 mp->sub_id = ntohl (sub_id);
7098 #define _(a,b) mp->sub_if_flags |= (1 << a);
7099 foreach_create_subif_flag;
7102 mp->outer_vlan_id = ntohs (outer_vlan_id);
7103 mp->inner_vlan_id = ntohs (inner_vlan_id);
7111 api_ip_table_replace_begin (vat_main_t * vam)
7113 unformat_input_t *i = vam->input;
7114 vl_api_ip_table_replace_begin_t *mp;
7119 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7121 if (unformat (i, "table %d", &table_id))
7123 else if (unformat (i, "ipv6"))
7127 clib_warning ("parse error '%U'", format_unformat_error, i);
7132 M (IP_TABLE_REPLACE_BEGIN, mp);
7134 mp->table.table_id = ntohl (table_id);
7135 mp->table.is_ip6 = is_ipv6;
7143 api_ip_table_flush (vat_main_t * vam)
7145 unformat_input_t *i = vam->input;
7146 vl_api_ip_table_flush_t *mp;
7151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7153 if (unformat (i, "table %d", &table_id))
7155 else if (unformat (i, "ipv6"))
7159 clib_warning ("parse error '%U'", format_unformat_error, i);
7164 M (IP_TABLE_FLUSH, mp);
7166 mp->table.table_id = ntohl (table_id);
7167 mp->table.is_ip6 = is_ipv6;
7175 api_ip_table_replace_end (vat_main_t * vam)
7177 unformat_input_t *i = vam->input;
7178 vl_api_ip_table_replace_end_t *mp;
7183 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7185 if (unformat (i, "table %d", &table_id))
7187 else if (unformat (i, "ipv6"))
7191 clib_warning ("parse error '%U'", format_unformat_error, i);
7196 M (IP_TABLE_REPLACE_END, mp);
7198 mp->table.table_id = ntohl (table_id);
7199 mp->table.is_ip6 = is_ipv6;
7207 api_set_ip_flow_hash (vat_main_t * vam)
7209 unformat_input_t *i = vam->input;
7210 vl_api_set_ip_flow_hash_t *mp;
7222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7224 if (unformat (i, "vrf %d", &vrf_id))
7226 else if (unformat (i, "ipv6"))
7228 else if (unformat (i, "src"))
7230 else if (unformat (i, "dst"))
7232 else if (unformat (i, "sport"))
7234 else if (unformat (i, "dport"))
7236 else if (unformat (i, "proto"))
7238 else if (unformat (i, "reverse"))
7243 clib_warning ("parse error '%U'", format_unformat_error, i);
7248 if (vrf_id_set == 0)
7250 errmsg ("missing vrf id");
7254 M (SET_IP_FLOW_HASH, mp);
7260 mp->reverse = reverse;
7261 mp->vrf_id = ntohl (vrf_id);
7262 mp->is_ipv6 = is_ipv6;
7270 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7272 unformat_input_t *i = vam->input;
7273 vl_api_sw_interface_ip6_enable_disable_t *mp;
7275 u8 sw_if_index_set = 0;
7279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7281 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7282 sw_if_index_set = 1;
7283 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7284 sw_if_index_set = 1;
7285 else if (unformat (i, "enable"))
7287 else if (unformat (i, "disable"))
7291 clib_warning ("parse error '%U'", format_unformat_error, i);
7296 if (sw_if_index_set == 0)
7298 errmsg ("missing interface name or sw_if_index");
7302 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7304 mp->sw_if_index = ntohl (sw_if_index);
7305 mp->enable = enable;
7314 api_l2_patch_add_del (vat_main_t * vam)
7316 unformat_input_t *i = vam->input;
7317 vl_api_l2_patch_add_del_t *mp;
7319 u8 rx_sw_if_index_set = 0;
7321 u8 tx_sw_if_index_set = 0;
7325 /* Parse args required to build the message */
7326 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7328 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
7329 rx_sw_if_index_set = 1;
7330 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
7331 tx_sw_if_index_set = 1;
7332 else if (unformat (i, "rx"))
7334 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7336 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7338 rx_sw_if_index_set = 1;
7343 else if (unformat (i, "tx"))
7345 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7347 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
7349 tx_sw_if_index_set = 1;
7354 else if (unformat (i, "del"))
7360 if (rx_sw_if_index_set == 0)
7362 errmsg ("missing rx interface name or rx_sw_if_index");
7366 if (tx_sw_if_index_set == 0)
7368 errmsg ("missing tx interface name or tx_sw_if_index");
7372 M (L2_PATCH_ADD_DEL, mp);
7374 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
7375 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
7376 mp->is_add = is_add;
7384 u8 localsid_addr[16];
7393 api_sr_localsid_add_del (vat_main_t * vam)
7395 unformat_input_t *i = vam->input;
7396 vl_api_sr_localsid_add_del_t *mp;
7399 ip6_address_t localsid;
7403 u32 fib_table = ~(u32) 0;
7404 ip46_address_t nh_addr;
7405 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
7407 bool nexthop_set = 0;
7411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7413 if (unformat (i, "del"))
7415 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
7416 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
7418 else if (unformat (i, "behavior %u", &behavior));
7419 else if (unformat (i, "sw_if_index %u", &sw_if_index));
7420 else if (unformat (i, "fib-table %u", &fib_table));
7421 else if (unformat (i, "end.psp %u", &behavior));
7426 M (SR_LOCALSID_ADD_DEL, mp);
7428 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
7432 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
7434 mp->behavior = behavior;
7435 mp->sw_if_index = ntohl (sw_if_index);
7436 mp->fib_table = ntohl (fib_table);
7437 mp->end_psp = end_psp;
7438 mp->is_del = is_del;
7446 api_ioam_enable (vat_main_t * vam)
7448 unformat_input_t *input = vam->input;
7449 vl_api_ioam_enable_t *mp;
7451 int has_trace_option = 0;
7452 int has_pot_option = 0;
7453 int has_seqno_option = 0;
7454 int has_analyse_option = 0;
7457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7459 if (unformat (input, "trace"))
7460 has_trace_option = 1;
7461 else if (unformat (input, "pot"))
7463 else if (unformat (input, "seqno"))
7464 has_seqno_option = 1;
7465 else if (unformat (input, "analyse"))
7466 has_analyse_option = 1;
7470 M (IOAM_ENABLE, mp);
7471 mp->id = htons (id);
7472 mp->seqno = has_seqno_option;
7473 mp->analyse = has_analyse_option;
7474 mp->pot_enable = has_pot_option;
7475 mp->trace_enable = has_trace_option;
7484 api_ioam_disable (vat_main_t * vam)
7486 vl_api_ioam_disable_t *mp;
7489 M (IOAM_DISABLE, mp);
7495 #define foreach_tcp_proto_field \
7499 #define foreach_udp_proto_field \
7503 #define foreach_ip4_proto_field \
7515 u16 src_port, dst_port;
7518 #if VPP_API_TEST_BUILTIN == 0
7520 unformat_tcp_mask (unformat_input_t * input, va_list * args)
7522 u8 **maskp = va_arg (*args, u8 **);
7524 u8 found_something = 0;
7527 #define _(a) u8 a=0;
7528 foreach_tcp_proto_field;
7531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7534 #define _(a) else if (unformat (input, #a)) a=1;
7535 foreach_tcp_proto_field
7541 #define _(a) found_something += a;
7542 foreach_tcp_proto_field;
7545 if (found_something == 0)
7548 vec_validate (mask, sizeof (*tcp) - 1);
7550 tcp = (tcp_header_t *) mask;
7552 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
7553 foreach_tcp_proto_field;
7561 unformat_udp_mask (unformat_input_t * input, va_list * args)
7563 u8 **maskp = va_arg (*args, u8 **);
7565 u8 found_something = 0;
7568 #define _(a) u8 a=0;
7569 foreach_udp_proto_field;
7572 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7575 #define _(a) else if (unformat (input, #a)) a=1;
7576 foreach_udp_proto_field
7582 #define _(a) found_something += a;
7583 foreach_udp_proto_field;
7586 if (found_something == 0)
7589 vec_validate (mask, sizeof (*udp) - 1);
7591 udp = (udp_header_t *) mask;
7593 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
7594 foreach_udp_proto_field;
7602 unformat_l4_mask (unformat_input_t * input, va_list * args)
7604 u8 **maskp = va_arg (*args, u8 **);
7605 u16 src_port = 0, dst_port = 0;
7606 tcpudp_header_t *tcpudp;
7608 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7610 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
7612 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
7614 else if (unformat (input, "src_port"))
7616 else if (unformat (input, "dst_port"))
7622 if (!src_port && !dst_port)
7626 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
7628 tcpudp = (tcpudp_header_t *) mask;
7629 tcpudp->src_port = src_port;
7630 tcpudp->dst_port = dst_port;
7638 unformat_ip4_mask (unformat_input_t * input, va_list * args)
7640 u8 **maskp = va_arg (*args, u8 **);
7642 u8 found_something = 0;
7645 #define _(a) u8 a=0;
7646 foreach_ip4_proto_field;
7652 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7654 if (unformat (input, "version"))
7656 else if (unformat (input, "hdr_length"))
7658 else if (unformat (input, "src"))
7660 else if (unformat (input, "dst"))
7662 else if (unformat (input, "proto"))
7665 #define _(a) else if (unformat (input, #a)) a=1;
7666 foreach_ip4_proto_field
7672 #define _(a) found_something += a;
7673 foreach_ip4_proto_field;
7676 if (found_something == 0)
7679 vec_validate (mask, sizeof (*ip) - 1);
7681 ip = (ip4_header_t *) mask;
7683 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
7684 foreach_ip4_proto_field;
7687 ip->ip_version_and_header_length = 0;
7690 ip->ip_version_and_header_length |= 0xF0;
7693 ip->ip_version_and_header_length |= 0x0F;
7699 #define foreach_ip6_proto_field \
7707 unformat_ip6_mask (unformat_input_t * input, va_list * args)
7709 u8 **maskp = va_arg (*args, u8 **);
7711 u8 found_something = 0;
7713 u32 ip_version_traffic_class_and_flow_label;
7715 #define _(a) u8 a=0;
7716 foreach_ip6_proto_field;
7719 u8 traffic_class = 0;
7722 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7724 if (unformat (input, "version"))
7726 else if (unformat (input, "traffic-class"))
7728 else if (unformat (input, "flow-label"))
7730 else if (unformat (input, "src"))
7732 else if (unformat (input, "dst"))
7734 else if (unformat (input, "proto"))
7737 #define _(a) else if (unformat (input, #a)) a=1;
7738 foreach_ip6_proto_field
7744 #define _(a) found_something += a;
7745 foreach_ip6_proto_field;
7748 if (found_something == 0)
7751 vec_validate (mask, sizeof (*ip) - 1);
7753 ip = (ip6_header_t *) mask;
7755 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
7756 foreach_ip6_proto_field;
7759 ip_version_traffic_class_and_flow_label = 0;
7762 ip_version_traffic_class_and_flow_label |= 0xF0000000;
7765 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
7768 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
7770 ip->ip_version_traffic_class_and_flow_label =
7771 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
7778 unformat_l3_mask (unformat_input_t * input, va_list * args)
7780 u8 **maskp = va_arg (*args, u8 **);
7782 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7784 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
7786 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
7795 unformat_l2_mask (unformat_input_t * input, va_list * args)
7797 u8 **maskp = va_arg (*args, u8 **);
7812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7814 if (unformat (input, "src"))
7816 else if (unformat (input, "dst"))
7818 else if (unformat (input, "proto"))
7820 else if (unformat (input, "tag1"))
7822 else if (unformat (input, "tag2"))
7824 else if (unformat (input, "ignore-tag1"))
7826 else if (unformat (input, "ignore-tag2"))
7828 else if (unformat (input, "cos1"))
7830 else if (unformat (input, "cos2"))
7832 else if (unformat (input, "dot1q"))
7834 else if (unformat (input, "dot1ad"))
7839 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
7840 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
7843 if (tag1 || ignore_tag1 || cos1 || dot1q)
7845 if (tag2 || ignore_tag2 || cos2 || dot1ad)
7848 vec_validate (mask, len - 1);
7851 clib_memset (mask, 0xff, 6);
7854 clib_memset (mask + 6, 0xff, 6);
7858 /* inner vlan tag */
7867 mask[21] = mask[20] = 0xff;
7888 mask[16] = mask[17] = 0xff;
7898 mask[12] = mask[13] = 0xff;
7905 unformat_classify_mask (unformat_input_t * input, va_list * args)
7907 u8 **maskp = va_arg (*args, u8 **);
7908 u32 *skipp = va_arg (*args, u32 *);
7909 u32 *matchp = va_arg (*args, u32 *);
7917 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7919 if (unformat (input, "hex %U", unformat_hex_string, &mask))
7921 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
7923 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
7925 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
7939 if (mask || l2 || l3 || l4)
7943 /* "With a free Ethernet header in every package" */
7945 vec_validate (l2, 13);
7949 vec_append (mask, l3);
7954 vec_append (mask, l4);
7959 /* Scan forward looking for the first significant mask octet */
7960 for (i = 0; i < vec_len (mask); i++)
7964 /* compute (skip, match) params */
7965 *skipp = i / sizeof (u32x4);
7966 vec_delete (mask, *skipp * sizeof (u32x4), 0);
7968 /* Pad mask to an even multiple of the vector size */
7969 while (vec_len (mask) % sizeof (u32x4))
7972 match = vec_len (mask) / sizeof (u32x4);
7974 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
7976 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
7977 if (*tmp || *(tmp + 1))
7982 clib_warning ("BUG: match 0");
7984 _vec_len (mask) = match * sizeof (u32x4);
7994 #endif /* VPP_API_TEST_BUILTIN */
7996 #define foreach_l2_next \
7998 _(ethernet, ETHERNET_INPUT) \
8003 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8005 u32 *miss_next_indexp = va_arg (*args, u32 *);
8010 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8014 if (unformat (input, "%d", &tmp))
8023 *miss_next_indexp = next_index;
8027 #define foreach_ip_next \
8033 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
8035 u32 *miss_next_indexp = va_arg (*args, u32 *);
8040 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8044 if (unformat (input, "%d", &tmp))
8053 *miss_next_indexp = next_index;
8057 #define foreach_acl_next \
8061 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
8063 u32 *miss_next_indexp = va_arg (*args, u32 *);
8068 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8072 if (unformat (input, "permit"))
8077 else if (unformat (input, "%d", &tmp))
8086 *miss_next_indexp = next_index;
8091 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8093 u32 *r = va_arg (*args, u32 *);
8095 if (unformat (input, "conform-color"))
8096 *r = POLICE_CONFORM;
8097 else if (unformat (input, "exceed-color"))
8106 api_classify_add_del_table (vat_main_t * vam)
8108 unformat_input_t *i = vam->input;
8109 vl_api_classify_add_del_table_t *mp;
8116 u32 table_index = ~0;
8117 u32 next_table_index = ~0;
8118 u32 miss_next_index = ~0;
8119 u32 memory_size = 32 << 20;
8121 u32 current_data_flag = 0;
8122 int current_data_offset = 0;
8125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8127 if (unformat (i, "del"))
8129 else if (unformat (i, "del-chain"))
8134 else if (unformat (i, "buckets %d", &nbuckets))
8136 else if (unformat (i, "memory_size %d", &memory_size))
8138 else if (unformat (i, "skip %d", &skip))
8140 else if (unformat (i, "match %d", &match))
8142 else if (unformat (i, "table %d", &table_index))
8144 else if (unformat (i, "mask %U", unformat_classify_mask,
8145 &mask, &skip, &match))
8147 else if (unformat (i, "next-table %d", &next_table_index))
8149 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
8152 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
8155 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
8158 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
8160 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
8166 if (is_add && mask == 0)
8168 errmsg ("Mask required");
8172 if (is_add && skip == ~0)
8174 errmsg ("skip count required");
8178 if (is_add && match == ~0)
8180 errmsg ("match count required");
8184 if (!is_add && table_index == ~0)
8186 errmsg ("table index required for delete");
8190 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
8192 mp->is_add = is_add;
8193 mp->del_chain = del_chain;
8194 mp->table_index = ntohl (table_index);
8195 mp->nbuckets = ntohl (nbuckets);
8196 mp->memory_size = ntohl (memory_size);
8197 mp->skip_n_vectors = ntohl (skip);
8198 mp->match_n_vectors = ntohl (match);
8199 mp->next_table_index = ntohl (next_table_index);
8200 mp->miss_next_index = ntohl (miss_next_index);
8201 mp->current_data_flag = ntohl (current_data_flag);
8202 mp->current_data_offset = ntohl (current_data_offset);
8203 mp->mask_len = ntohl (vec_len (mask));
8204 clib_memcpy (mp->mask, mask, vec_len (mask));
8213 #if VPP_API_TEST_BUILTIN == 0
8215 unformat_l4_match (unformat_input_t * input, va_list * args)
8217 u8 **matchp = va_arg (*args, u8 **);
8219 u8 *proto_header = 0;
8225 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8227 if (unformat (input, "src_port %d", &src_port))
8229 else if (unformat (input, "dst_port %d", &dst_port))
8235 h.src_port = clib_host_to_net_u16 (src_port);
8236 h.dst_port = clib_host_to_net_u16 (dst_port);
8237 vec_validate (proto_header, sizeof (h) - 1);
8238 memcpy (proto_header, &h, sizeof (h));
8240 *matchp = proto_header;
8246 unformat_ip4_match (unformat_input_t * input, va_list * args)
8248 u8 **matchp = va_arg (*args, u8 **);
8255 int src = 0, dst = 0;
8256 ip4_address_t src_val, dst_val;
8263 int fragment_id = 0;
8264 u32 fragment_id_val;
8270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8272 if (unformat (input, "version %d", &version_val))
8274 else if (unformat (input, "hdr_length %d", &hdr_length_val))
8276 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
8278 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
8280 else if (unformat (input, "proto %d", &proto_val))
8282 else if (unformat (input, "tos %d", &tos_val))
8284 else if (unformat (input, "length %d", &length_val))
8286 else if (unformat (input, "fragment_id %d", &fragment_id_val))
8288 else if (unformat (input, "ttl %d", &ttl_val))
8290 else if (unformat (input, "checksum %d", &checksum_val))
8296 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
8297 + ttl + checksum == 0)
8301 * Aligned because we use the real comparison functions
8303 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8305 ip = (ip4_header_t *) match;
8307 /* These are realistically matched in practice */
8309 ip->src_address.as_u32 = src_val.as_u32;
8312 ip->dst_address.as_u32 = dst_val.as_u32;
8315 ip->protocol = proto_val;
8318 /* These are not, but they're included for completeness */
8320 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
8323 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
8329 ip->length = clib_host_to_net_u16 (length_val);
8335 ip->checksum = clib_host_to_net_u16 (checksum_val);
8342 unformat_ip6_match (unformat_input_t * input, va_list * args)
8344 u8 **matchp = va_arg (*args, u8 **);
8349 u8 traffic_class = 0;
8350 u32 traffic_class_val = 0;
8353 int src = 0, dst = 0;
8354 ip6_address_t src_val, dst_val;
8357 int payload_length = 0;
8358 u32 payload_length_val;
8361 u32 ip_version_traffic_class_and_flow_label;
8363 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8365 if (unformat (input, "version %d", &version_val))
8367 else if (unformat (input, "traffic_class %d", &traffic_class_val))
8369 else if (unformat (input, "flow_label %d", &flow_label_val))
8371 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
8373 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
8375 else if (unformat (input, "proto %d", &proto_val))
8377 else if (unformat (input, "payload_length %d", &payload_length_val))
8379 else if (unformat (input, "hop_limit %d", &hop_limit_val))
8385 if (version + traffic_class + flow_label + src + dst + proto +
8386 payload_length + hop_limit == 0)
8390 * Aligned because we use the real comparison functions
8392 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
8394 ip = (ip6_header_t *) match;
8397 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
8400 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
8403 ip->protocol = proto_val;
8405 ip_version_traffic_class_and_flow_label = 0;
8408 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
8411 ip_version_traffic_class_and_flow_label |=
8412 (traffic_class_val & 0xFF) << 20;
8415 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
8417 ip->ip_version_traffic_class_and_flow_label =
8418 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8421 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
8424 ip->hop_limit = hop_limit_val;
8431 unformat_l3_match (unformat_input_t * input, va_list * args)
8433 u8 **matchp = va_arg (*args, u8 **);
8435 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8437 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
8439 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
8448 unformat_vlan_tag (unformat_input_t * input, va_list * args)
8450 u8 *tagp = va_arg (*args, u8 *);
8453 if (unformat (input, "%d", &tag))
8455 tagp[0] = (tag >> 8) & 0x0F;
8456 tagp[1] = tag & 0xFF;
8464 unformat_l2_match (unformat_input_t * input, va_list * args)
8466 u8 **matchp = va_arg (*args, u8 **);
8486 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8488 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
8491 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
8493 else if (unformat (input, "proto %U",
8494 unformat_ethernet_type_host_byte_order, &proto_val))
8496 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
8498 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
8500 else if (unformat (input, "ignore-tag1"))
8502 else if (unformat (input, "ignore-tag2"))
8504 else if (unformat (input, "cos1 %d", &cos1_val))
8506 else if (unformat (input, "cos2 %d", &cos2_val))
8511 if ((src + dst + proto + tag1 + tag2 +
8512 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8515 if (tag1 || ignore_tag1 || cos1)
8517 if (tag2 || ignore_tag2 || cos2)
8520 vec_validate_aligned (match, len - 1, sizeof (u32x4));
8523 clib_memcpy (match, dst_val, 6);
8526 clib_memcpy (match + 6, src_val, 6);
8530 /* inner vlan tag */
8531 match[19] = tag2_val[1];
8532 match[18] = tag2_val[0];
8534 match[18] |= (cos2_val & 0x7) << 5;
8537 match[21] = proto_val & 0xff;
8538 match[20] = proto_val >> 8;
8542 match[15] = tag1_val[1];
8543 match[14] = tag1_val[0];
8546 match[14] |= (cos1_val & 0x7) << 5;
8552 match[15] = tag1_val[1];
8553 match[14] = tag1_val[0];
8556 match[17] = proto_val & 0xff;
8557 match[16] = proto_val >> 8;
8560 match[14] |= (cos1_val & 0x7) << 5;
8566 match[18] |= (cos2_val & 0x7) << 5;
8568 match[14] |= (cos1_val & 0x7) << 5;
8571 match[13] = proto_val & 0xff;
8572 match[12] = proto_val >> 8;
8580 unformat_qos_source (unformat_input_t * input, va_list * args)
8582 int *qs = va_arg (*args, int *);
8584 if (unformat (input, "ip"))
8585 *qs = QOS_SOURCE_IP;
8586 else if (unformat (input, "mpls"))
8587 *qs = QOS_SOURCE_MPLS;
8588 else if (unformat (input, "ext"))
8589 *qs = QOS_SOURCE_EXT;
8590 else if (unformat (input, "vlan"))
8591 *qs = QOS_SOURCE_VLAN;
8600 api_unformat_classify_match (unformat_input_t * input, va_list * args)
8602 u8 **matchp = va_arg (*args, u8 **);
8603 u32 skip_n_vectors = va_arg (*args, u32);
8604 u32 match_n_vectors = va_arg (*args, u32);
8611 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8613 if (unformat (input, "hex %U", unformat_hex_string, &match))
8615 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
8617 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
8619 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
8633 if (match || l2 || l3 || l4)
8637 /* "Win a free Ethernet header in every packet" */
8639 vec_validate_aligned (l2, 13, sizeof (u32x4));
8643 vec_append_aligned (match, l3, sizeof (u32x4));
8648 vec_append_aligned (match, l4, sizeof (u32x4));
8653 /* Make sure the vector is big enough even if key is all 0's */
8654 vec_validate_aligned
8655 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
8658 /* Set size, include skipped vectors */
8659 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
8670 api_classify_add_del_session (vat_main_t * vam)
8672 unformat_input_t *i = vam->input;
8673 vl_api_classify_add_del_session_t *mp;
8675 u32 table_index = ~0;
8676 u32 hit_next_index = ~0;
8677 u32 opaque_index = ~0;
8680 u32 skip_n_vectors = 0;
8681 u32 match_n_vectors = 0;
8687 * Warning: you have to supply skip_n and match_n
8688 * because the API client cant simply look at the classify
8692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8694 if (unformat (i, "del"))
8696 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
8699 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
8702 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
8705 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
8707 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
8709 else if (unformat (i, "opaque-index %d", &opaque_index))
8711 else if (unformat (i, "skip_n %d", &skip_n_vectors))
8713 else if (unformat (i, "match_n %d", &match_n_vectors))
8715 else if (unformat (i, "match %U", api_unformat_classify_match,
8716 &match, skip_n_vectors, match_n_vectors))
8718 else if (unformat (i, "advance %d", &advance))
8720 else if (unformat (i, "table-index %d", &table_index))
8722 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
8724 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
8726 else if (unformat (i, "action %d", &action))
8728 else if (unformat (i, "metadata %d", &metadata))
8734 if (table_index == ~0)
8736 errmsg ("Table index required");
8740 if (is_add && match == 0)
8742 errmsg ("Match value required");
8746 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
8748 mp->is_add = is_add;
8749 mp->table_index = ntohl (table_index);
8750 mp->hit_next_index = ntohl (hit_next_index);
8751 mp->opaque_index = ntohl (opaque_index);
8752 mp->advance = ntohl (advance);
8753 mp->action = action;
8754 mp->metadata = ntohl (metadata);
8755 mp->match_len = ntohl (vec_len (match));
8756 clib_memcpy (mp->match, match, vec_len (match));
8765 api_classify_set_interface_ip_table (vat_main_t * vam)
8767 unformat_input_t *i = vam->input;
8768 vl_api_classify_set_interface_ip_table_t *mp;
8770 int sw_if_index_set;
8771 u32 table_index = ~0;
8775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8777 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8778 sw_if_index_set = 1;
8779 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8780 sw_if_index_set = 1;
8781 else if (unformat (i, "table %d", &table_index))
8785 clib_warning ("parse error '%U'", format_unformat_error, i);
8790 if (sw_if_index_set == 0)
8792 errmsg ("missing interface name or sw_if_index");
8797 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
8799 mp->sw_if_index = ntohl (sw_if_index);
8800 mp->table_index = ntohl (table_index);
8801 mp->is_ipv6 = is_ipv6;
8809 api_classify_set_interface_l2_tables (vat_main_t * vam)
8811 unformat_input_t *i = vam->input;
8812 vl_api_classify_set_interface_l2_tables_t *mp;
8814 int sw_if_index_set;
8815 u32 ip4_table_index = ~0;
8816 u32 ip6_table_index = ~0;
8817 u32 other_table_index = ~0;
8821 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8823 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8824 sw_if_index_set = 1;
8825 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8826 sw_if_index_set = 1;
8827 else if (unformat (i, "ip4-table %d", &ip4_table_index))
8829 else if (unformat (i, "ip6-table %d", &ip6_table_index))
8831 else if (unformat (i, "other-table %d", &other_table_index))
8833 else if (unformat (i, "is-input %d", &is_input))
8837 clib_warning ("parse error '%U'", format_unformat_error, i);
8842 if (sw_if_index_set == 0)
8844 errmsg ("missing interface name or sw_if_index");
8849 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
8851 mp->sw_if_index = ntohl (sw_if_index);
8852 mp->ip4_table_index = ntohl (ip4_table_index);
8853 mp->ip6_table_index = ntohl (ip6_table_index);
8854 mp->other_table_index = ntohl (other_table_index);
8855 mp->is_input = (u8) is_input;
8863 api_set_ipfix_exporter (vat_main_t * vam)
8865 unformat_input_t *i = vam->input;
8866 vl_api_set_ipfix_exporter_t *mp;
8867 ip4_address_t collector_address;
8868 u8 collector_address_set = 0;
8869 u32 collector_port = ~0;
8870 ip4_address_t src_address;
8871 u8 src_address_set = 0;
8874 u32 template_interval = ~0;
8875 u8 udp_checksum = 0;
8878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8880 if (unformat (i, "collector_address %U", unformat_ip4_address,
8881 &collector_address))
8882 collector_address_set = 1;
8883 else if (unformat (i, "collector_port %d", &collector_port))
8885 else if (unformat (i, "src_address %U", unformat_ip4_address,
8887 src_address_set = 1;
8888 else if (unformat (i, "vrf_id %d", &vrf_id))
8890 else if (unformat (i, "path_mtu %d", &path_mtu))
8892 else if (unformat (i, "template_interval %d", &template_interval))
8894 else if (unformat (i, "udp_checksum"))
8900 if (collector_address_set == 0)
8902 errmsg ("collector_address required");
8906 if (src_address_set == 0)
8908 errmsg ("src_address required");
8912 M (SET_IPFIX_EXPORTER, mp);
8914 memcpy (mp->collector_address.un.ip4, collector_address.data,
8915 sizeof (collector_address.data));
8916 mp->collector_port = htons ((u16) collector_port);
8917 memcpy (mp->src_address.un.ip4, src_address.data,
8918 sizeof (src_address.data));
8919 mp->vrf_id = htonl (vrf_id);
8920 mp->path_mtu = htonl (path_mtu);
8921 mp->template_interval = htonl (template_interval);
8922 mp->udp_checksum = udp_checksum;
8930 api_set_ipfix_classify_stream (vat_main_t * vam)
8932 unformat_input_t *i = vam->input;
8933 vl_api_set_ipfix_classify_stream_t *mp;
8935 u32 src_port = UDP_DST_PORT_ipfix;
8938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8940 if (unformat (i, "domain %d", &domain_id))
8942 else if (unformat (i, "src_port %d", &src_port))
8946 errmsg ("unknown input `%U'", format_unformat_error, i);
8951 M (SET_IPFIX_CLASSIFY_STREAM, mp);
8953 mp->domain_id = htonl (domain_id);
8954 mp->src_port = htons ((u16) src_port);
8962 api_ipfix_classify_table_add_del (vat_main_t * vam)
8964 unformat_input_t *i = vam->input;
8965 vl_api_ipfix_classify_table_add_del_t *mp;
8967 u32 classify_table_index = ~0;
8969 u8 transport_protocol = 255;
8972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8974 if (unformat (i, "add"))
8976 else if (unformat (i, "del"))
8978 else if (unformat (i, "table %d", &classify_table_index))
8980 else if (unformat (i, "ip4"))
8982 else if (unformat (i, "ip6"))
8984 else if (unformat (i, "tcp"))
8985 transport_protocol = 6;
8986 else if (unformat (i, "udp"))
8987 transport_protocol = 17;
8990 errmsg ("unknown input `%U'", format_unformat_error, i);
8997 errmsg ("expecting: add|del");
9000 if (classify_table_index == ~0)
9002 errmsg ("classifier table not specified");
9005 if (ip_version == 0)
9007 errmsg ("IP version not specified");
9011 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
9013 mp->is_add = is_add;
9014 mp->table_id = htonl (classify_table_index);
9015 mp->ip_version = ip_version;
9016 mp->transport_protocol = transport_protocol;
9024 api_get_node_index (vat_main_t * vam)
9026 unformat_input_t *i = vam->input;
9027 vl_api_get_node_index_t *mp;
9031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9033 if (unformat (i, "node %s", &name))
9040 errmsg ("node name required");
9043 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9045 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9049 M (GET_NODE_INDEX, mp);
9050 clib_memcpy (mp->node_name, name, vec_len (name));
9059 api_get_next_index (vat_main_t * vam)
9061 unformat_input_t *i = vam->input;
9062 vl_api_get_next_index_t *mp;
9063 u8 *node_name = 0, *next_node_name = 0;
9066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9068 if (unformat (i, "node-name %s", &node_name))
9070 else if (unformat (i, "next-node-name %s", &next_node_name))
9076 errmsg ("node name required");
9079 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9081 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9085 if (next_node_name == 0)
9087 errmsg ("next node name required");
9090 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9092 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9096 M (GET_NEXT_INDEX, mp);
9097 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9098 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9099 vec_free (node_name);
9100 vec_free (next_node_name);
9108 api_add_node_next (vat_main_t * vam)
9110 unformat_input_t *i = vam->input;
9111 vl_api_add_node_next_t *mp;
9116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9118 if (unformat (i, "node %s", &name))
9120 else if (unformat (i, "next %s", &next))
9127 errmsg ("node name required");
9130 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9132 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9137 errmsg ("next node required");
9140 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9142 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9146 M (ADD_NODE_NEXT, mp);
9147 clib_memcpy (mp->node_name, name, vec_len (name));
9148 clib_memcpy (mp->next_name, next, vec_len (next));
9157 static void vl_api_sw_interface_tap_v2_details_t_handler
9158 (vl_api_sw_interface_tap_v2_details_t * mp)
9160 vat_main_t *vam = &vat_main;
9163 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
9164 mp->host_ip4_prefix.len);
9166 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
9167 mp->host_ip6_prefix.len);
9170 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
9171 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
9172 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
9173 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
9174 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
9180 static void vl_api_sw_interface_tap_v2_details_t_handler_json
9181 (vl_api_sw_interface_tap_v2_details_t * mp)
9183 vat_main_t *vam = &vat_main;
9184 vat_json_node_t *node = NULL;
9186 if (VAT_JSON_ARRAY != vam->json_tree.type)
9188 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9189 vat_json_init_array (&vam->json_tree);
9191 node = vat_json_array_add (&vam->json_tree);
9193 vat_json_init_object (node);
9194 vat_json_object_add_uint (node, "id", ntohl (mp->id));
9195 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9196 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
9197 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
9198 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
9199 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
9200 vat_json_object_add_string_copy (node, "host_mac_addr",
9201 format (0, "%U", format_ethernet_address,
9202 &mp->host_mac_addr));
9203 vat_json_object_add_string_copy (node, "host_namespace",
9204 mp->host_namespace);
9205 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
9206 vat_json_object_add_string_copy (node, "host_ip4_addr",
9207 format (0, "%U/%d", format_ip4_address,
9208 mp->host_ip4_prefix.address,
9209 mp->host_ip4_prefix.len));
9210 vat_json_object_add_string_copy (node, "host_ip6_prefix",
9211 format (0, "%U/%d", format_ip6_address,
9212 mp->host_ip6_prefix.address,
9213 mp->host_ip6_prefix.len));
9218 api_sw_interface_tap_v2_dump (vat_main_t * vam)
9220 vl_api_sw_interface_tap_v2_dump_t *mp;
9221 vl_api_control_ping_t *mp_ping;
9225 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
9226 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
9227 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
9230 /* Get list of tap interfaces */
9231 M (SW_INTERFACE_TAP_V2_DUMP, mp);
9234 /* Use a control ping for synchronization */
9235 MPING (CONTROL_PING, mp_ping);
9242 static void vl_api_sw_interface_virtio_pci_details_t_handler
9243 (vl_api_sw_interface_virtio_pci_details_t * mp)
9245 vat_main_t *vam = &vat_main;
9260 addr.domain = ntohs (mp->pci_addr.domain);
9261 addr.bus = mp->pci_addr.bus;
9262 addr.slot = mp->pci_addr.slot;
9263 addr.function = mp->pci_addr.function;
9265 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
9266 addr.slot, addr.function);
9269 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
9270 pci_addr, ntohl (mp->sw_if_index),
9271 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
9272 format_ethernet_address, mp->mac_addr,
9273 clib_net_to_host_u64 (mp->features));
9274 vec_free (pci_addr);
9277 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
9278 (vl_api_sw_interface_virtio_pci_details_t * mp)
9280 vat_main_t *vam = &vat_main;
9281 vat_json_node_t *node = NULL;
9282 vlib_pci_addr_t pci_addr;
9284 if (VAT_JSON_ARRAY != vam->json_tree.type)
9286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9287 vat_json_init_array (&vam->json_tree);
9289 node = vat_json_array_add (&vam->json_tree);
9291 pci_addr.domain = ntohs (mp->pci_addr.domain);
9292 pci_addr.bus = mp->pci_addr.bus;
9293 pci_addr.slot = mp->pci_addr.slot;
9294 pci_addr.function = mp->pci_addr.function;
9296 vat_json_init_object (node);
9297 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
9298 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9299 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
9300 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
9301 vat_json_object_add_uint (node, "features",
9302 clib_net_to_host_u64 (mp->features));
9303 vat_json_object_add_string_copy (node, "mac_addr",
9304 format (0, "%U", format_ethernet_address,
9309 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
9311 vl_api_sw_interface_virtio_pci_dump_t *mp;
9312 vl_api_control_ping_t *mp_ping;
9316 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
9317 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
9318 "mac_addr", "features");
9320 /* Get list of tap interfaces */
9321 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
9324 /* Use a control ping for synchronization */
9325 MPING (CONTROL_PING, mp_ping);
9333 api_vxlan_offload_rx (vat_main_t * vam)
9335 unformat_input_t *line_input = vam->input;
9336 vl_api_vxlan_offload_rx_t *mp;
9337 u32 hw_if_index = ~0, rx_if_index = ~0;
9341 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9343 if (unformat (line_input, "del"))
9345 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
9348 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
9350 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
9353 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
9357 errmsg ("parse error '%U'", format_unformat_error, line_input);
9362 if (hw_if_index == ~0)
9364 errmsg ("no hw interface");
9368 if (rx_if_index == ~0)
9370 errmsg ("no rx tunnel");
9374 M (VXLAN_OFFLOAD_RX, mp);
9376 mp->hw_if_index = ntohl (hw_if_index);
9377 mp->sw_if_index = ntohl (rx_if_index);
9378 mp->enable = is_add;
9385 static uword unformat_vxlan_decap_next
9386 (unformat_input_t * input, va_list * args)
9388 u32 *result = va_arg (*args, u32 *);
9391 if (unformat (input, "l2"))
9392 *result = VXLAN_INPUT_NEXT_L2_INPUT;
9393 else if (unformat (input, "%d", &tmp))
9401 api_vxlan_add_del_tunnel (vat_main_t * vam)
9403 unformat_input_t *line_input = vam->input;
9404 vl_api_vxlan_add_del_tunnel_t *mp;
9405 ip46_address_t src, dst;
9407 u8 ipv4_set = 0, ipv6_set = 0;
9412 u32 mcast_sw_if_index = ~0;
9413 u32 encap_vrf_id = 0;
9414 u32 decap_next_index = ~0;
9418 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
9419 clib_memset (&src, 0, sizeof src);
9420 clib_memset (&dst, 0, sizeof dst);
9422 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
9424 if (unformat (line_input, "del"))
9426 else if (unformat (line_input, "instance %d", &instance))
9429 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
9435 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
9441 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
9447 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
9452 else if (unformat (line_input, "group %U %U",
9453 unformat_ip4_address, &dst.ip4,
9454 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
9456 grp_set = dst_set = 1;
9459 else if (unformat (line_input, "group %U",
9460 unformat_ip4_address, &dst.ip4))
9462 grp_set = dst_set = 1;
9465 else if (unformat (line_input, "group %U %U",
9466 unformat_ip6_address, &dst.ip6,
9467 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
9469 grp_set = dst_set = 1;
9472 else if (unformat (line_input, "group %U",
9473 unformat_ip6_address, &dst.ip6))
9475 grp_set = dst_set = 1;
9479 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
9481 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
9483 else if (unformat (line_input, "decap-next %U",
9484 unformat_vxlan_decap_next, &decap_next_index))
9486 else if (unformat (line_input, "vni %d", &vni))
9490 errmsg ("parse error '%U'", format_unformat_error, line_input);
9497 errmsg ("tunnel src address not specified");
9502 errmsg ("tunnel dst address not specified");
9506 if (grp_set && !ip46_address_is_multicast (&dst))
9508 errmsg ("tunnel group address not multicast");
9511 if (grp_set && mcast_sw_if_index == ~0)
9513 errmsg ("tunnel nonexistent multicast device");
9516 if (grp_set == 0 && ip46_address_is_multicast (&dst))
9518 errmsg ("tunnel dst address must be unicast");
9523 if (ipv4_set && ipv6_set)
9525 errmsg ("both IPv4 and IPv6 addresses specified");
9529 if ((vni == 0) || (vni >> 24))
9531 errmsg ("vni not specified or out of range");
9535 M (VXLAN_ADD_DEL_TUNNEL, mp);
9539 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
9540 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
9544 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
9545 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
9547 mp->src_address.af = ipv6_set;
9548 mp->dst_address.af = ipv6_set;
9550 mp->instance = htonl (instance);
9551 mp->encap_vrf_id = ntohl (encap_vrf_id);
9552 mp->decap_next_index = ntohl (decap_next_index);
9553 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
9554 mp->vni = ntohl (vni);
9555 mp->is_add = is_add;
9562 static void vl_api_vxlan_tunnel_details_t_handler
9563 (vl_api_vxlan_tunnel_details_t * mp)
9565 vat_main_t *vam = &vat_main;
9566 ip46_address_t src =
9567 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
9568 ip46_address_t dst =
9569 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
9571 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
9572 ntohl (mp->sw_if_index),
9573 ntohl (mp->instance),
9574 format_ip46_address, &src, IP46_TYPE_ANY,
9575 format_ip46_address, &dst, IP46_TYPE_ANY,
9576 ntohl (mp->encap_vrf_id),
9577 ntohl (mp->decap_next_index), ntohl (mp->vni),
9578 ntohl (mp->mcast_sw_if_index));
9581 static void vl_api_vxlan_tunnel_details_t_handler_json
9582 (vl_api_vxlan_tunnel_details_t * mp)
9584 vat_main_t *vam = &vat_main;
9585 vat_json_node_t *node = NULL;
9587 if (VAT_JSON_ARRAY != vam->json_tree.type)
9589 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9590 vat_json_init_array (&vam->json_tree);
9592 node = vat_json_array_add (&vam->json_tree);
9594 vat_json_init_object (node);
9595 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9597 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
9599 if (mp->src_address.af)
9601 struct in6_addr ip6;
9603 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
9604 vat_json_object_add_ip6 (node, "src_address", ip6);
9605 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
9606 vat_json_object_add_ip6 (node, "dst_address", ip6);
9612 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
9613 vat_json_object_add_ip4 (node, "src_address", ip4);
9614 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
9615 vat_json_object_add_ip4 (node, "dst_address", ip4);
9617 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
9618 vat_json_object_add_uint (node, "decap_next_index",
9619 ntohl (mp->decap_next_index));
9620 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
9621 vat_json_object_add_uint (node, "mcast_sw_if_index",
9622 ntohl (mp->mcast_sw_if_index));
9626 api_vxlan_tunnel_dump (vat_main_t * vam)
9628 unformat_input_t *i = vam->input;
9629 vl_api_vxlan_tunnel_dump_t *mp;
9630 vl_api_control_ping_t *mp_ping;
9632 u8 sw_if_index_set = 0;
9635 /* Parse args required to build the message */
9636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9638 if (unformat (i, "sw_if_index %d", &sw_if_index))
9639 sw_if_index_set = 1;
9644 if (sw_if_index_set == 0)
9649 if (!vam->json_output)
9651 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
9652 "sw_if_index", "instance", "src_address", "dst_address",
9653 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
9656 /* Get list of vxlan-tunnel interfaces */
9657 M (VXLAN_TUNNEL_DUMP, mp);
9659 mp->sw_if_index = htonl (sw_if_index);
9663 /* Use a control ping for synchronization */
9664 MPING (CONTROL_PING, mp_ping);
9672 api_l2_fib_clear_table (vat_main_t * vam)
9674 // unformat_input_t * i = vam->input;
9675 vl_api_l2_fib_clear_table_t *mp;
9678 M (L2_FIB_CLEAR_TABLE, mp);
9686 api_l2_interface_efp_filter (vat_main_t * vam)
9688 unformat_input_t *i = vam->input;
9689 vl_api_l2_interface_efp_filter_t *mp;
9692 u8 sw_if_index_set = 0;
9695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9697 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9698 sw_if_index_set = 1;
9699 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9700 sw_if_index_set = 1;
9701 else if (unformat (i, "enable"))
9703 else if (unformat (i, "disable"))
9707 clib_warning ("parse error '%U'", format_unformat_error, i);
9712 if (sw_if_index_set == 0)
9714 errmsg ("missing sw_if_index");
9718 M (L2_INTERFACE_EFP_FILTER, mp);
9720 mp->sw_if_index = ntohl (sw_if_index);
9721 mp->enable_disable = enable;
9728 #define foreach_vtr_op \
9729 _("disable", L2_VTR_DISABLED) \
9730 _("push-1", L2_VTR_PUSH_1) \
9731 _("push-2", L2_VTR_PUSH_2) \
9732 _("pop-1", L2_VTR_POP_1) \
9733 _("pop-2", L2_VTR_POP_2) \
9734 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
9735 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
9736 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
9737 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
9740 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
9742 unformat_input_t *i = vam->input;
9743 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
9745 u8 sw_if_index_set = 0;
9753 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9755 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9756 sw_if_index_set = 1;
9757 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9758 sw_if_index_set = 1;
9759 else if (unformat (i, "vtr_op %d", &vtr_op))
9761 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
9764 else if (unformat (i, "push_dot1q %d", &push_dot1q))
9766 else if (unformat (i, "tag1 %d", &tag1))
9768 else if (unformat (i, "tag2 %d", &tag2))
9772 clib_warning ("parse error '%U'", format_unformat_error, i);
9777 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
9779 errmsg ("missing vtr operation or sw_if_index");
9783 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
9784 mp->sw_if_index = ntohl (sw_if_index);
9785 mp->vtr_op = ntohl (vtr_op);
9786 mp->push_dot1q = ntohl (push_dot1q);
9787 mp->tag1 = ntohl (tag1);
9788 mp->tag2 = ntohl (tag2);
9796 api_create_vhost_user_if (vat_main_t * vam)
9798 unformat_input_t *i = vam->input;
9799 vl_api_create_vhost_user_if_t *mp;
9802 u8 file_name_set = 0;
9803 u32 custom_dev_instance = ~0;
9805 u8 use_custom_mac = 0;
9806 u8 disable_mrg_rxbuf = 0;
9807 u8 disable_indirect_desc = 0;
9810 u8 enable_packed = 0;
9813 /* Shut up coverity */
9814 clib_memset (hwaddr, 0, sizeof (hwaddr));
9816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9818 if (unformat (i, "socket %s", &file_name))
9822 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9824 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
9826 else if (unformat (i, "server"))
9828 else if (unformat (i, "disable_mrg_rxbuf"))
9829 disable_mrg_rxbuf = 1;
9830 else if (unformat (i, "disable_indirect_desc"))
9831 disable_indirect_desc = 1;
9832 else if (unformat (i, "gso"))
9834 else if (unformat (i, "packed"))
9836 else if (unformat (i, "tag %s", &tag))
9842 if (file_name_set == 0)
9844 errmsg ("missing socket file name");
9848 if (vec_len (file_name) > 255)
9850 errmsg ("socket file name too long");
9853 vec_add1 (file_name, 0);
9855 M (CREATE_VHOST_USER_IF, mp);
9857 mp->is_server = is_server;
9858 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
9859 mp->disable_indirect_desc = disable_indirect_desc;
9860 mp->enable_gso = enable_gso;
9861 mp->enable_packed = enable_packed;
9862 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9863 vec_free (file_name);
9864 if (custom_dev_instance != ~0)
9867 mp->custom_dev_instance = ntohl (custom_dev_instance);
9870 mp->use_custom_mac = use_custom_mac;
9871 clib_memcpy (mp->mac_address, hwaddr, 6);
9873 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
9882 api_modify_vhost_user_if (vat_main_t * vam)
9884 unformat_input_t *i = vam->input;
9885 vl_api_modify_vhost_user_if_t *mp;
9888 u8 file_name_set = 0;
9889 u32 custom_dev_instance = ~0;
9890 u8 sw_if_index_set = 0;
9891 u32 sw_if_index = (u32) ~ 0;
9893 u8 enable_packed = 0;
9896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9898 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9899 sw_if_index_set = 1;
9900 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9901 sw_if_index_set = 1;
9902 else if (unformat (i, "socket %s", &file_name))
9906 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
9908 else if (unformat (i, "server"))
9910 else if (unformat (i, "gso"))
9912 else if (unformat (i, "packed"))
9918 if (sw_if_index_set == 0)
9920 errmsg ("missing sw_if_index or interface name");
9924 if (file_name_set == 0)
9926 errmsg ("missing socket file name");
9930 if (vec_len (file_name) > 255)
9932 errmsg ("socket file name too long");
9935 vec_add1 (file_name, 0);
9937 M (MODIFY_VHOST_USER_IF, mp);
9939 mp->sw_if_index = ntohl (sw_if_index);
9940 mp->is_server = is_server;
9941 mp->enable_gso = enable_gso;
9942 mp->enable_packed = enable_packed;
9943 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
9944 vec_free (file_name);
9945 if (custom_dev_instance != ~0)
9948 mp->custom_dev_instance = ntohl (custom_dev_instance);
9957 api_delete_vhost_user_if (vat_main_t * vam)
9959 unformat_input_t *i = vam->input;
9960 vl_api_delete_vhost_user_if_t *mp;
9961 u32 sw_if_index = ~0;
9962 u8 sw_if_index_set = 0;
9965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9967 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9968 sw_if_index_set = 1;
9969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9970 sw_if_index_set = 1;
9975 if (sw_if_index_set == 0)
9977 errmsg ("missing sw_if_index or interface name");
9982 M (DELETE_VHOST_USER_IF, mp);
9984 mp->sw_if_index = ntohl (sw_if_index);
9991 static void vl_api_sw_interface_vhost_user_details_t_handler
9992 (vl_api_sw_interface_vhost_user_details_t * mp)
9994 vat_main_t *vam = &vat_main;
9998 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
9999 clib_net_to_host_u32
10000 (mp->features_last_32) <<
10003 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
10004 (char *) mp->interface_name,
10005 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
10006 features, mp->is_server,
10007 ntohl (mp->num_regions), (char *) mp->sock_filename);
10008 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
10011 static void vl_api_sw_interface_vhost_user_details_t_handler_json
10012 (vl_api_sw_interface_vhost_user_details_t * mp)
10014 vat_main_t *vam = &vat_main;
10015 vat_json_node_t *node = NULL;
10017 if (VAT_JSON_ARRAY != vam->json_tree.type)
10019 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10020 vat_json_init_array (&vam->json_tree);
10022 node = vat_json_array_add (&vam->json_tree);
10024 vat_json_init_object (node);
10025 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10026 vat_json_object_add_string_copy (node, "interface_name",
10027 mp->interface_name);
10028 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
10029 ntohl (mp->virtio_net_hdr_sz));
10030 vat_json_object_add_uint (node, "features_first_32",
10031 clib_net_to_host_u32 (mp->features_first_32));
10032 vat_json_object_add_uint (node, "features_last_32",
10033 clib_net_to_host_u32 (mp->features_last_32));
10034 vat_json_object_add_uint (node, "is_server", mp->is_server);
10035 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
10036 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
10037 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
10041 api_sw_interface_vhost_user_dump (vat_main_t * vam)
10043 unformat_input_t *i = vam->input;
10044 vl_api_sw_interface_vhost_user_dump_t *mp;
10045 vl_api_control_ping_t *mp_ping;
10047 u32 sw_if_index = ~0;
10049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10060 "Interface name idx hdr_sz features server regions filename");
10062 /* Get list of vhost-user interfaces */
10063 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
10064 mp->sw_if_index = ntohl (sw_if_index);
10067 /* Use a control ping for synchronization */
10068 MPING (CONTROL_PING, mp_ping);
10076 api_show_version (vat_main_t * vam)
10078 vl_api_show_version_t *mp;
10081 M (SHOW_VERSION, mp);
10090 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
10092 unformat_input_t *line_input = vam->input;
10093 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
10094 ip46_address_t local, remote;
10099 u32 mcast_sw_if_index = ~0;
10100 u32 encap_vrf_id = 0;
10101 u32 decap_vrf_id = 0;
10107 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10109 if (unformat (line_input, "del"))
10111 else if (unformat (line_input, "local %U",
10112 unformat_ip46_address, &local))
10116 else if (unformat (line_input, "remote %U",
10117 unformat_ip46_address, &remote))
10121 else if (unformat (line_input, "group %U %U",
10122 unformat_ip46_address, &remote,
10123 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10125 grp_set = remote_set = 1;
10127 else if (unformat (line_input, "group %U",
10128 unformat_ip46_address, &remote))
10130 grp_set = remote_set = 1;
10133 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10135 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10137 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
10139 else if (unformat (line_input, "vni %d", &vni))
10141 else if (unformat (line_input, "next-ip4"))
10143 else if (unformat (line_input, "next-ip6"))
10145 else if (unformat (line_input, "next-ethernet"))
10147 else if (unformat (line_input, "next-nsh"))
10151 errmsg ("parse error '%U'", format_unformat_error, line_input);
10156 if (local_set == 0)
10158 errmsg ("tunnel local address not specified");
10161 if (remote_set == 0)
10163 errmsg ("tunnel remote address not specified");
10166 if (grp_set && mcast_sw_if_index == ~0)
10168 errmsg ("tunnel nonexistent multicast device");
10171 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
10173 errmsg ("both IPv4 and IPv6 addresses specified");
10179 errmsg ("vni not specified");
10183 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
10185 ip_address_encode (&local,
10186 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
10187 IP46_TYPE_IP6, &mp->local);
10188 ip_address_encode (&remote,
10189 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
10190 IP46_TYPE_IP6, &mp->remote);
10192 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10193 mp->encap_vrf_id = ntohl (encap_vrf_id);
10194 mp->decap_vrf_id = ntohl (decap_vrf_id);
10195 mp->protocol = protocol;
10196 mp->vni = ntohl (vni);
10197 mp->is_add = is_add;
10204 static void vl_api_vxlan_gpe_tunnel_details_t_handler
10205 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10207 vat_main_t *vam = &vat_main;
10208 ip46_address_t local, remote;
10210 ip_address_decode (&mp->local, &local);
10211 ip_address_decode (&mp->remote, &remote);
10213 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
10214 ntohl (mp->sw_if_index),
10215 format_ip46_address, &local, IP46_TYPE_ANY,
10216 format_ip46_address, &remote, IP46_TYPE_ANY,
10217 ntohl (mp->vni), mp->protocol,
10218 ntohl (mp->mcast_sw_if_index),
10219 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
10223 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
10224 (vl_api_vxlan_gpe_tunnel_details_t * mp)
10226 vat_main_t *vam = &vat_main;
10227 vat_json_node_t *node = NULL;
10228 struct in_addr ip4;
10229 struct in6_addr ip6;
10230 ip46_address_t local, remote;
10232 ip_address_decode (&mp->local, &local);
10233 ip_address_decode (&mp->remote, &remote);
10235 if (VAT_JSON_ARRAY != vam->json_tree.type)
10237 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10238 vat_json_init_array (&vam->json_tree);
10240 node = vat_json_array_add (&vam->json_tree);
10242 vat_json_init_object (node);
10243 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10244 if (ip46_address_is_ip4 (&local))
10246 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
10247 vat_json_object_add_ip4 (node, "local", ip4);
10248 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
10249 vat_json_object_add_ip4 (node, "remote", ip4);
10253 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
10254 vat_json_object_add_ip6 (node, "local", ip6);
10255 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
10256 vat_json_object_add_ip6 (node, "remote", ip6);
10258 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10259 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
10260 vat_json_object_add_uint (node, "mcast_sw_if_index",
10261 ntohl (mp->mcast_sw_if_index));
10262 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10263 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
10264 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10268 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
10270 unformat_input_t *i = vam->input;
10271 vl_api_vxlan_gpe_tunnel_dump_t *mp;
10272 vl_api_control_ping_t *mp_ping;
10274 u8 sw_if_index_set = 0;
10277 /* Parse args required to build the message */
10278 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10280 if (unformat (i, "sw_if_index %d", &sw_if_index))
10281 sw_if_index_set = 1;
10286 if (sw_if_index_set == 0)
10291 if (!vam->json_output)
10293 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
10294 "sw_if_index", "local", "remote", "vni",
10295 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
10298 /* Get list of vxlan-tunnel interfaces */
10299 M (VXLAN_GPE_TUNNEL_DUMP, mp);
10301 mp->sw_if_index = htonl (sw_if_index);
10305 /* Use a control ping for synchronization */
10306 MPING (CONTROL_PING, mp_ping);
10313 static void vl_api_l2_fib_table_details_t_handler
10314 (vl_api_l2_fib_table_details_t * mp)
10316 vat_main_t *vam = &vat_main;
10318 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
10320 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
10321 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
10325 static void vl_api_l2_fib_table_details_t_handler_json
10326 (vl_api_l2_fib_table_details_t * mp)
10328 vat_main_t *vam = &vat_main;
10329 vat_json_node_t *node = NULL;
10331 if (VAT_JSON_ARRAY != vam->json_tree.type)
10333 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10334 vat_json_init_array (&vam->json_tree);
10336 node = vat_json_array_add (&vam->json_tree);
10338 vat_json_init_object (node);
10339 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
10340 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
10341 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10342 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
10343 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
10344 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
10348 api_l2_fib_table_dump (vat_main_t * vam)
10350 unformat_input_t *i = vam->input;
10351 vl_api_l2_fib_table_dump_t *mp;
10352 vl_api_control_ping_t *mp_ping;
10357 /* Parse args required to build the message */
10358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10360 if (unformat (i, "bd_id %d", &bd_id))
10366 if (bd_id_set == 0)
10368 errmsg ("missing bridge domain");
10372 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
10374 /* Get list of l2 fib entries */
10375 M (L2_FIB_TABLE_DUMP, mp);
10377 mp->bd_id = ntohl (bd_id);
10380 /* Use a control ping for synchronization */
10381 MPING (CONTROL_PING, mp_ping);
10390 api_interface_name_renumber (vat_main_t * vam)
10392 unformat_input_t *line_input = vam->input;
10393 vl_api_interface_name_renumber_t *mp;
10394 u32 sw_if_index = ~0;
10395 u32 new_show_dev_instance = ~0;
10398 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10400 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
10403 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
10405 else if (unformat (line_input, "new_show_dev_instance %d",
10406 &new_show_dev_instance))
10412 if (sw_if_index == ~0)
10414 errmsg ("missing interface name or sw_if_index");
10418 if (new_show_dev_instance == ~0)
10420 errmsg ("missing new_show_dev_instance");
10424 M (INTERFACE_NAME_RENUMBER, mp);
10426 mp->sw_if_index = ntohl (sw_if_index);
10427 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
10435 api_want_l2_macs_events (vat_main_t * vam)
10437 unformat_input_t *line_input = vam->input;
10438 vl_api_want_l2_macs_events_t *mp;
10439 u8 enable_disable = 1;
10440 u32 scan_delay = 0;
10441 u32 max_macs_in_event = 0;
10442 u32 learn_limit = 0;
10445 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10447 if (unformat (line_input, "learn-limit %d", &learn_limit))
10449 else if (unformat (line_input, "scan-delay %d", &scan_delay))
10451 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
10453 else if (unformat (line_input, "disable"))
10454 enable_disable = 0;
10459 M (WANT_L2_MACS_EVENTS, mp);
10460 mp->enable_disable = enable_disable;
10461 mp->pid = htonl (getpid ());
10462 mp->learn_limit = htonl (learn_limit);
10463 mp->scan_delay = (u8) scan_delay;
10464 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
10471 api_input_acl_set_interface (vat_main_t * vam)
10473 unformat_input_t *i = vam->input;
10474 vl_api_input_acl_set_interface_t *mp;
10476 int sw_if_index_set;
10477 u32 ip4_table_index = ~0;
10478 u32 ip6_table_index = ~0;
10479 u32 l2_table_index = ~0;
10483 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10486 sw_if_index_set = 1;
10487 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10488 sw_if_index_set = 1;
10489 else if (unformat (i, "del"))
10491 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10493 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10495 else if (unformat (i, "l2-table %d", &l2_table_index))
10499 clib_warning ("parse error '%U'", format_unformat_error, i);
10504 if (sw_if_index_set == 0)
10506 errmsg ("missing interface name or sw_if_index");
10510 M (INPUT_ACL_SET_INTERFACE, mp);
10512 mp->sw_if_index = ntohl (sw_if_index);
10513 mp->ip4_table_index = ntohl (ip4_table_index);
10514 mp->ip6_table_index = ntohl (ip6_table_index);
10515 mp->l2_table_index = ntohl (l2_table_index);
10516 mp->is_add = is_add;
10524 api_output_acl_set_interface (vat_main_t * vam)
10526 unformat_input_t *i = vam->input;
10527 vl_api_output_acl_set_interface_t *mp;
10529 int sw_if_index_set;
10530 u32 ip4_table_index = ~0;
10531 u32 ip6_table_index = ~0;
10532 u32 l2_table_index = ~0;
10536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10538 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10539 sw_if_index_set = 1;
10540 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10541 sw_if_index_set = 1;
10542 else if (unformat (i, "del"))
10544 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10546 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10548 else if (unformat (i, "l2-table %d", &l2_table_index))
10552 clib_warning ("parse error '%U'", format_unformat_error, i);
10557 if (sw_if_index_set == 0)
10559 errmsg ("missing interface name or sw_if_index");
10563 M (OUTPUT_ACL_SET_INTERFACE, mp);
10565 mp->sw_if_index = ntohl (sw_if_index);
10566 mp->ip4_table_index = ntohl (ip4_table_index);
10567 mp->ip6_table_index = ntohl (ip6_table_index);
10568 mp->l2_table_index = ntohl (l2_table_index);
10569 mp->is_add = is_add;
10577 api_ip_address_dump (vat_main_t * vam)
10579 unformat_input_t *i = vam->input;
10580 vl_api_ip_address_dump_t *mp;
10581 vl_api_control_ping_t *mp_ping;
10582 u32 sw_if_index = ~0;
10583 u8 sw_if_index_set = 0;
10588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10590 if (unformat (i, "sw_if_index %d", &sw_if_index))
10591 sw_if_index_set = 1;
10593 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10594 sw_if_index_set = 1;
10595 else if (unformat (i, "ipv4"))
10597 else if (unformat (i, "ipv6"))
10603 if (ipv4_set && ipv6_set)
10605 errmsg ("ipv4 and ipv6 flags cannot be both set");
10609 if ((!ipv4_set) && (!ipv6_set))
10611 errmsg ("no ipv4 nor ipv6 flag set");
10615 if (sw_if_index_set == 0)
10617 errmsg ("missing interface name or sw_if_index");
10621 vam->current_sw_if_index = sw_if_index;
10622 vam->is_ipv6 = ipv6_set;
10624 M (IP_ADDRESS_DUMP, mp);
10625 mp->sw_if_index = ntohl (sw_if_index);
10626 mp->is_ipv6 = ipv6_set;
10629 /* Use a control ping for synchronization */
10630 MPING (CONTROL_PING, mp_ping);
10638 api_ip_dump (vat_main_t * vam)
10640 vl_api_ip_dump_t *mp;
10641 vl_api_control_ping_t *mp_ping;
10642 unformat_input_t *in = vam->input;
10649 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
10651 if (unformat (in, "ipv4"))
10653 else if (unformat (in, "ipv6"))
10659 if (ipv4_set && ipv6_set)
10661 errmsg ("ipv4 and ipv6 flags cannot be both set");
10665 if ((!ipv4_set) && (!ipv6_set))
10667 errmsg ("no ipv4 nor ipv6 flag set");
10671 is_ipv6 = ipv6_set;
10672 vam->is_ipv6 = is_ipv6;
10674 /* free old data */
10675 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
10677 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
10679 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
10682 mp->is_ipv6 = ipv6_set;
10685 /* Use a control ping for synchronization */
10686 MPING (CONTROL_PING, mp_ping);
10694 api_ipsec_spd_add_del (vat_main_t * vam)
10696 unformat_input_t *i = vam->input;
10697 vl_api_ipsec_spd_add_del_t *mp;
10702 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10704 if (unformat (i, "spd_id %d", &spd_id))
10706 else if (unformat (i, "del"))
10710 clib_warning ("parse error '%U'", format_unformat_error, i);
10716 errmsg ("spd_id must be set");
10720 M (IPSEC_SPD_ADD_DEL, mp);
10722 mp->spd_id = ntohl (spd_id);
10723 mp->is_add = is_add;
10731 api_ipsec_interface_add_del_spd (vat_main_t * vam)
10733 unformat_input_t *i = vam->input;
10734 vl_api_ipsec_interface_add_del_spd_t *mp;
10736 u8 sw_if_index_set = 0;
10737 u32 spd_id = (u32) ~ 0;
10741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10743 if (unformat (i, "del"))
10745 else if (unformat (i, "spd_id %d", &spd_id))
10748 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10749 sw_if_index_set = 1;
10750 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10751 sw_if_index_set = 1;
10754 clib_warning ("parse error '%U'", format_unformat_error, i);
10760 if (spd_id == (u32) ~ 0)
10762 errmsg ("spd_id must be set");
10766 if (sw_if_index_set == 0)
10768 errmsg ("missing interface name or sw_if_index");
10772 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
10774 mp->spd_id = ntohl (spd_id);
10775 mp->sw_if_index = ntohl (sw_if_index);
10776 mp->is_add = is_add;
10784 api_ipsec_spd_entry_add_del (vat_main_t * vam)
10786 unformat_input_t *i = vam->input;
10787 vl_api_ipsec_spd_entry_add_del_t *mp;
10788 u8 is_add = 1, is_outbound = 0;
10789 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
10791 u32 rport_start = 0, rport_stop = (u32) ~ 0;
10792 u32 lport_start = 0, lport_stop = (u32) ~ 0;
10793 vl_api_address_t laddr_start = { }, laddr_stop =
10802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10804 if (unformat (i, "del"))
10806 if (unformat (i, "outbound"))
10808 if (unformat (i, "inbound"))
10810 else if (unformat (i, "spd_id %d", &spd_id))
10812 else if (unformat (i, "sa_id %d", &sa_id))
10814 else if (unformat (i, "priority %d", &priority))
10816 else if (unformat (i, "protocol %d", &protocol))
10818 else if (unformat (i, "lport_start %d", &lport_start))
10820 else if (unformat (i, "lport_stop %d", &lport_stop))
10822 else if (unformat (i, "rport_start %d", &rport_start))
10824 else if (unformat (i, "rport_stop %d", &rport_stop))
10826 else if (unformat (i, "laddr_start %U",
10827 unformat_vl_api_address, &laddr_start))
10829 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
10832 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
10835 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
10839 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
10841 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
10843 clib_warning ("unsupported action: 'resolve'");
10849 clib_warning ("parse error '%U'", format_unformat_error, i);
10855 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
10857 mp->is_add = is_add;
10859 mp->entry.spd_id = ntohl (spd_id);
10860 mp->entry.priority = ntohl (priority);
10861 mp->entry.is_outbound = is_outbound;
10863 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
10864 sizeof (vl_api_address_t));
10865 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
10866 sizeof (vl_api_address_t));
10867 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
10868 sizeof (vl_api_address_t));
10869 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
10870 sizeof (vl_api_address_t));
10872 mp->entry.protocol = (u8) protocol;
10873 mp->entry.local_port_start = ntohs ((u16) lport_start);
10874 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
10875 mp->entry.remote_port_start = ntohs ((u16) rport_start);
10876 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
10877 mp->entry.policy = (u8) policy;
10878 mp->entry.sa_id = ntohl (sa_id);
10886 api_ipsec_sad_entry_add_del (vat_main_t * vam)
10888 unformat_input_t *i = vam->input;
10889 vl_api_ipsec_sad_entry_add_del_t *mp;
10890 u32 sad_id = 0, spi = 0;
10891 u8 *ck = 0, *ik = 0;
10894 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
10895 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
10896 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
10897 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
10898 vl_api_address_t tun_src, tun_dst;
10901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10903 if (unformat (i, "del"))
10905 else if (unformat (i, "sad_id %d", &sad_id))
10907 else if (unformat (i, "spi %d", &spi))
10909 else if (unformat (i, "esp"))
10910 protocol = IPSEC_API_PROTO_ESP;
10912 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
10914 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
10915 if (ADDRESS_IP6 == tun_src.af)
10916 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
10919 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
10921 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
10922 if (ADDRESS_IP6 == tun_src.af)
10923 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
10926 if (unformat (i, "crypto_alg %U",
10927 unformat_ipsec_api_crypto_alg, &crypto_alg))
10929 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
10931 else if (unformat (i, "integ_alg %U",
10932 unformat_ipsec_api_integ_alg, &integ_alg))
10934 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
10938 clib_warning ("parse error '%U'", format_unformat_error, i);
10944 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
10946 mp->is_add = is_add;
10947 mp->entry.sad_id = ntohl (sad_id);
10948 mp->entry.protocol = protocol;
10949 mp->entry.spi = ntohl (spi);
10950 mp->entry.flags = flags;
10952 mp->entry.crypto_algorithm = crypto_alg;
10953 mp->entry.integrity_algorithm = integ_alg;
10954 mp->entry.crypto_key.length = vec_len (ck);
10955 mp->entry.integrity_key.length = vec_len (ik);
10957 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
10958 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
10960 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
10961 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
10964 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
10966 clib_memcpy (mp->entry.integrity_key.data, ik,
10967 mp->entry.integrity_key.length);
10969 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
10971 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
10972 sizeof (mp->entry.tunnel_src));
10973 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
10974 sizeof (mp->entry.tunnel_dst));
10983 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
10985 vat_main_t *vam = &vat_main;
10987 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
10988 "crypto_key %U integ_alg %u integ_key %U flags %x "
10989 "tunnel_src_addr %U tunnel_dst_addr %U "
10990 "salt %u seq_outbound %lu last_seq_inbound %lu "
10991 "replay_window %lu stat_index %u\n",
10992 ntohl (mp->entry.sad_id),
10993 ntohl (mp->sw_if_index),
10994 ntohl (mp->entry.spi),
10995 ntohl (mp->entry.protocol),
10996 ntohl (mp->entry.crypto_algorithm),
10997 format_hex_bytes, mp->entry.crypto_key.data,
10998 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
10999 format_hex_bytes, mp->entry.integrity_key.data,
11000 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
11001 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
11002 &mp->entry.tunnel_dst, ntohl (mp->salt),
11003 clib_net_to_host_u64 (mp->seq_outbound),
11004 clib_net_to_host_u64 (mp->last_seq_inbound),
11005 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
11008 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
11009 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
11011 static void vl_api_ipsec_sa_details_t_handler_json
11012 (vl_api_ipsec_sa_details_t * mp)
11014 vat_main_t *vam = &vat_main;
11015 vat_json_node_t *node = NULL;
11016 vl_api_ipsec_sad_flags_t flags;
11018 if (VAT_JSON_ARRAY != vam->json_tree.type)
11020 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11021 vat_json_init_array (&vam->json_tree);
11023 node = vat_json_array_add (&vam->json_tree);
11025 vat_json_init_object (node);
11026 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
11027 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11028 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
11029 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
11030 vat_json_object_add_uint (node, "crypto_alg",
11031 ntohl (mp->entry.crypto_algorithm));
11032 vat_json_object_add_uint (node, "integ_alg",
11033 ntohl (mp->entry.integrity_algorithm));
11034 flags = ntohl (mp->entry.flags);
11035 vat_json_object_add_uint (node, "use_esn",
11036 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
11037 vat_json_object_add_uint (node, "use_anti_replay",
11038 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
11039 vat_json_object_add_uint (node, "is_tunnel",
11040 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
11041 vat_json_object_add_uint (node, "is_tunnel_ip6",
11042 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
11043 vat_json_object_add_uint (node, "udp_encap",
11044 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
11045 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
11046 mp->entry.crypto_key.length);
11047 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
11048 mp->entry.integrity_key.length);
11049 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
11050 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
11051 vat_json_object_add_uint (node, "replay_window",
11052 clib_net_to_host_u64 (mp->replay_window));
11053 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
11057 api_ipsec_sa_dump (vat_main_t * vam)
11059 unformat_input_t *i = vam->input;
11060 vl_api_ipsec_sa_dump_t *mp;
11061 vl_api_control_ping_t *mp_ping;
11065 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11067 if (unformat (i, "sa_id %d", &sa_id))
11071 clib_warning ("parse error '%U'", format_unformat_error, i);
11076 M (IPSEC_SA_DUMP, mp);
11078 mp->sa_id = ntohl (sa_id);
11082 /* Use a control ping for synchronization */
11083 M (CONTROL_PING, mp_ping);
11091 api_get_first_msg_id (vat_main_t * vam)
11093 vl_api_get_first_msg_id_t *mp;
11094 unformat_input_t *i = vam->input;
11099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11101 if (unformat (i, "client %s", &name))
11109 errmsg ("missing client name");
11112 vec_add1 (name, 0);
11114 if (vec_len (name) > 63)
11116 errmsg ("client name too long");
11120 M (GET_FIRST_MSG_ID, mp);
11121 clib_memcpy (mp->name, name, vec_len (name));
11128 api_cop_interface_enable_disable (vat_main_t * vam)
11130 unformat_input_t *line_input = vam->input;
11131 vl_api_cop_interface_enable_disable_t *mp;
11132 u32 sw_if_index = ~0;
11133 u8 enable_disable = 1;
11136 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11138 if (unformat (line_input, "disable"))
11139 enable_disable = 0;
11140 if (unformat (line_input, "enable"))
11141 enable_disable = 1;
11142 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
11143 vam, &sw_if_index))
11145 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11151 if (sw_if_index == ~0)
11153 errmsg ("missing interface name or sw_if_index");
11157 /* Construct the API message */
11158 M (COP_INTERFACE_ENABLE_DISABLE, mp);
11159 mp->sw_if_index = ntohl (sw_if_index);
11160 mp->enable_disable = enable_disable;
11164 /* Wait for the reply */
11170 api_cop_whitelist_enable_disable (vat_main_t * vam)
11172 unformat_input_t *line_input = vam->input;
11173 vl_api_cop_whitelist_enable_disable_t *mp;
11174 u32 sw_if_index = ~0;
11175 u8 ip4 = 0, ip6 = 0, default_cop = 0;
11179 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11181 if (unformat (line_input, "ip4"))
11183 else if (unformat (line_input, "ip6"))
11185 else if (unformat (line_input, "default"))
11187 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
11188 vam, &sw_if_index))
11190 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11192 else if (unformat (line_input, "fib-id %d", &fib_id))
11198 if (sw_if_index == ~0)
11200 errmsg ("missing interface name or sw_if_index");
11204 /* Construct the API message */
11205 M (COP_WHITELIST_ENABLE_DISABLE, mp);
11206 mp->sw_if_index = ntohl (sw_if_index);
11207 mp->fib_id = ntohl (fib_id);
11210 mp->default_cop = default_cop;
11214 /* Wait for the reply */
11220 api_get_node_graph (vat_main_t * vam)
11222 vl_api_get_node_graph_t *mp;
11225 M (GET_NODE_GRAPH, mp);
11229 /* Wait for the reply */
11235 api_af_packet_create (vat_main_t * vam)
11237 unformat_input_t *i = vam->input;
11238 vl_api_af_packet_create_t *mp;
11239 u8 *host_if_name = 0;
11241 u8 random_hw_addr = 1;
11244 clib_memset (hw_addr, 0, sizeof (hw_addr));
11246 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11248 if (unformat (i, "name %s", &host_if_name))
11249 vec_add1 (host_if_name, 0);
11250 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
11251 random_hw_addr = 0;
11256 if (!vec_len (host_if_name))
11258 errmsg ("host-interface name must be specified");
11262 if (vec_len (host_if_name) > 64)
11264 errmsg ("host-interface name too long");
11268 M (AF_PACKET_CREATE, mp);
11270 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
11271 clib_memcpy (mp->hw_addr, hw_addr, 6);
11272 mp->use_random_hw_addr = random_hw_addr;
11273 vec_free (host_if_name);
11281 fprintf (vam->ofp ? vam->ofp : stderr,
11282 " new sw_if_index = %d\n", vam->sw_if_index);
11289 api_af_packet_delete (vat_main_t * vam)
11291 unformat_input_t *i = vam->input;
11292 vl_api_af_packet_delete_t *mp;
11293 u8 *host_if_name = 0;
11296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11298 if (unformat (i, "name %s", &host_if_name))
11299 vec_add1 (host_if_name, 0);
11304 if (!vec_len (host_if_name))
11306 errmsg ("host-interface name must be specified");
11310 if (vec_len (host_if_name) > 64)
11312 errmsg ("host-interface name too long");
11316 M (AF_PACKET_DELETE, mp);
11318 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
11319 vec_free (host_if_name);
11326 static void vl_api_af_packet_details_t_handler
11327 (vl_api_af_packet_details_t * mp)
11329 vat_main_t *vam = &vat_main;
11331 print (vam->ofp, "%-16s %d",
11332 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
11335 static void vl_api_af_packet_details_t_handler_json
11336 (vl_api_af_packet_details_t * mp)
11338 vat_main_t *vam = &vat_main;
11339 vat_json_node_t *node = NULL;
11341 if (VAT_JSON_ARRAY != vam->json_tree.type)
11343 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11344 vat_json_init_array (&vam->json_tree);
11346 node = vat_json_array_add (&vam->json_tree);
11348 vat_json_init_object (node);
11349 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11350 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
11354 api_af_packet_dump (vat_main_t * vam)
11356 vl_api_af_packet_dump_t *mp;
11357 vl_api_control_ping_t *mp_ping;
11360 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11361 /* Get list of tap interfaces */
11362 M (AF_PACKET_DUMP, mp);
11365 /* Use a control ping for synchronization */
11366 MPING (CONTROL_PING, mp_ping);
11374 api_policer_add_del (vat_main_t * vam)
11376 unformat_input_t *i = vam->input;
11377 vl_api_policer_add_del_t *mp;
11387 u8 color_aware = 0;
11388 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
11391 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
11392 conform_action.dscp = 0;
11393 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
11394 exceed_action.dscp = 0;
11395 violate_action.action_type = SSE2_QOS_ACTION_DROP;
11396 violate_action.dscp = 0;
11398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11400 if (unformat (i, "del"))
11402 else if (unformat (i, "name %s", &name))
11403 vec_add1 (name, 0);
11404 else if (unformat (i, "cir %u", &cir))
11406 else if (unformat (i, "eir %u", &eir))
11408 else if (unformat (i, "cb %u", &cb))
11410 else if (unformat (i, "eb %u", &eb))
11412 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
11415 else if (unformat (i, "round_type %U", unformat_policer_round_type,
11418 else if (unformat (i, "type %U", unformat_policer_type, &type))
11420 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
11423 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
11426 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
11429 else if (unformat (i, "color-aware"))
11435 if (!vec_len (name))
11437 errmsg ("policer name must be specified");
11441 if (vec_len (name) > 64)
11443 errmsg ("policer name too long");
11447 M (POLICER_ADD_DEL, mp);
11449 clib_memcpy (mp->name, name, vec_len (name));
11451 mp->is_add = is_add;
11452 mp->cir = ntohl (cir);
11453 mp->eir = ntohl (eir);
11454 mp->cb = clib_net_to_host_u64 (cb);
11455 mp->eb = clib_net_to_host_u64 (eb);
11456 mp->rate_type = rate_type;
11457 mp->round_type = round_type;
11459 mp->conform_action.type = conform_action.action_type;
11460 mp->conform_action.dscp = conform_action.dscp;
11461 mp->exceed_action.type = exceed_action.action_type;
11462 mp->exceed_action.dscp = exceed_action.dscp;
11463 mp->violate_action.type = violate_action.action_type;
11464 mp->violate_action.dscp = violate_action.dscp;
11465 mp->color_aware = color_aware;
11473 api_policer_dump (vat_main_t * vam)
11475 unformat_input_t *i = vam->input;
11476 vl_api_policer_dump_t *mp;
11477 vl_api_control_ping_t *mp_ping;
11478 u8 *match_name = 0;
11479 u8 match_name_valid = 0;
11482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11484 if (unformat (i, "name %s", &match_name))
11486 vec_add1 (match_name, 0);
11487 match_name_valid = 1;
11493 M (POLICER_DUMP, mp);
11494 mp->match_name_valid = match_name_valid;
11495 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
11496 vec_free (match_name);
11500 /* Use a control ping for synchronization */
11501 MPING (CONTROL_PING, mp_ping);
11504 /* Wait for a reply... */
11510 api_policer_classify_set_interface (vat_main_t * vam)
11512 unformat_input_t *i = vam->input;
11513 vl_api_policer_classify_set_interface_t *mp;
11515 int sw_if_index_set;
11516 u32 ip4_table_index = ~0;
11517 u32 ip6_table_index = ~0;
11518 u32 l2_table_index = ~0;
11522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11524 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11525 sw_if_index_set = 1;
11526 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11527 sw_if_index_set = 1;
11528 else if (unformat (i, "del"))
11530 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11532 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11534 else if (unformat (i, "l2-table %d", &l2_table_index))
11538 clib_warning ("parse error '%U'", format_unformat_error, i);
11543 if (sw_if_index_set == 0)
11545 errmsg ("missing interface name or sw_if_index");
11549 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
11551 mp->sw_if_index = ntohl (sw_if_index);
11552 mp->ip4_table_index = ntohl (ip4_table_index);
11553 mp->ip6_table_index = ntohl (ip6_table_index);
11554 mp->l2_table_index = ntohl (l2_table_index);
11555 mp->is_add = is_add;
11563 api_policer_classify_dump (vat_main_t * vam)
11565 unformat_input_t *i = vam->input;
11566 vl_api_policer_classify_dump_t *mp;
11567 vl_api_control_ping_t *mp_ping;
11568 u8 type = POLICER_CLASSIFY_N_TABLES;
11571 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
11575 errmsg ("classify table type must be specified");
11579 if (!vam->json_output)
11581 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
11584 M (POLICER_CLASSIFY_DUMP, mp);
11589 /* Use a control ping for synchronization */
11590 MPING (CONTROL_PING, mp_ping);
11593 /* Wait for a reply... */
11599 format_fib_api_path_nh_proto (u8 * s, va_list * args)
11601 vl_api_fib_path_nh_proto_t proto =
11602 va_arg (*args, vl_api_fib_path_nh_proto_t);
11606 case FIB_API_PATH_NH_PROTO_IP4:
11607 s = format (s, "ip4");
11609 case FIB_API_PATH_NH_PROTO_IP6:
11610 s = format (s, "ip6");
11612 case FIB_API_PATH_NH_PROTO_MPLS:
11613 s = format (s, "mpls");
11615 case FIB_API_PATH_NH_PROTO_BIER:
11616 s = format (s, "bier");
11618 case FIB_API_PATH_NH_PROTO_ETHERNET:
11619 s = format (s, "ethernet");
11627 format_vl_api_ip_address_union (u8 * s, va_list * args)
11629 vl_api_address_family_t af = va_arg (*args, int);
11630 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
11635 s = format (s, "%U", format_ip4_address, u->ip4);
11638 s = format (s, "%U", format_ip6_address, u->ip6);
11645 format_vl_api_fib_path_type (u8 * s, va_list * args)
11647 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
11651 case FIB_API_PATH_TYPE_NORMAL:
11652 s = format (s, "normal");
11654 case FIB_API_PATH_TYPE_LOCAL:
11655 s = format (s, "local");
11657 case FIB_API_PATH_TYPE_DROP:
11658 s = format (s, "drop");
11660 case FIB_API_PATH_TYPE_UDP_ENCAP:
11661 s = format (s, "udp-encap");
11663 case FIB_API_PATH_TYPE_BIER_IMP:
11664 s = format (s, "bier-imp");
11666 case FIB_API_PATH_TYPE_ICMP_UNREACH:
11667 s = format (s, "unreach");
11669 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
11670 s = format (s, "prohibit");
11672 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
11673 s = format (s, "src-lookup");
11675 case FIB_API_PATH_TYPE_DVR:
11676 s = format (s, "dvr");
11678 case FIB_API_PATH_TYPE_INTERFACE_RX:
11679 s = format (s, "interface-rx");
11681 case FIB_API_PATH_TYPE_CLASSIFY:
11682 s = format (s, "classify");
11690 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
11693 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
11694 ntohl (fp->weight), ntohl (fp->sw_if_index),
11695 format_vl_api_fib_path_type, fp->type,
11696 format_fib_api_path_nh_proto, fp->proto,
11697 format_vl_api_ip_address_union, &fp->nh.address);
11701 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
11702 vl_api_fib_path_t * fp)
11704 struct in_addr ip4;
11705 struct in6_addr ip6;
11707 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
11708 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
11709 vat_json_object_add_uint (node, "type", fp->type);
11710 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
11711 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
11713 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
11714 vat_json_object_add_ip4 (node, "next_hop", ip4);
11716 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
11718 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
11719 vat_json_object_add_ip6 (node, "next_hop", ip6);
11724 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
11726 vat_main_t *vam = &vat_main;
11727 int count = ntohl (mp->mt_tunnel.mt_n_paths);
11728 vl_api_fib_path_t *fp;
11731 print (vam->ofp, "sw_if_index %d via:",
11732 ntohl (mp->mt_tunnel.mt_sw_if_index));
11733 fp = mp->mt_tunnel.mt_paths;
11734 for (i = 0; i < count; i++)
11736 vl_api_fib_path_print (vam, fp);
11740 print (vam->ofp, "");
11743 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
11744 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
11747 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
11749 vat_main_t *vam = &vat_main;
11750 vat_json_node_t *node = NULL;
11751 int count = ntohl (mp->mt_tunnel.mt_n_paths);
11752 vl_api_fib_path_t *fp;
11755 if (VAT_JSON_ARRAY != vam->json_tree.type)
11757 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11758 vat_json_init_array (&vam->json_tree);
11760 node = vat_json_array_add (&vam->json_tree);
11762 vat_json_init_object (node);
11763 vat_json_object_add_uint (node, "sw_if_index",
11764 ntohl (mp->mt_tunnel.mt_sw_if_index));
11766 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
11768 fp = mp->mt_tunnel.mt_paths;
11769 for (i = 0; i < count; i++)
11771 vl_api_mpls_fib_path_json_print (node, fp);
11777 api_mpls_tunnel_dump (vat_main_t * vam)
11779 vl_api_mpls_tunnel_dump_t *mp;
11780 vl_api_control_ping_t *mp_ping;
11783 M (MPLS_TUNNEL_DUMP, mp);
11787 /* Use a control ping for synchronization */
11788 MPING (CONTROL_PING, mp_ping);
11795 #define vl_api_mpls_table_details_t_endian vl_noop_handler
11796 #define vl_api_mpls_table_details_t_print vl_noop_handler
11800 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
11802 vat_main_t *vam = &vat_main;
11804 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
11807 static void vl_api_mpls_table_details_t_handler_json
11808 (vl_api_mpls_table_details_t * mp)
11810 vat_main_t *vam = &vat_main;
11811 vat_json_node_t *node = NULL;
11813 if (VAT_JSON_ARRAY != vam->json_tree.type)
11815 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11816 vat_json_init_array (&vam->json_tree);
11818 node = vat_json_array_add (&vam->json_tree);
11820 vat_json_init_object (node);
11821 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
11825 api_mpls_table_dump (vat_main_t * vam)
11827 vl_api_mpls_table_dump_t *mp;
11828 vl_api_control_ping_t *mp_ping;
11831 M (MPLS_TABLE_DUMP, mp);
11834 /* Use a control ping for synchronization */
11835 MPING (CONTROL_PING, mp_ping);
11842 #define vl_api_mpls_route_details_t_endian vl_noop_handler
11843 #define vl_api_mpls_route_details_t_print vl_noop_handler
11846 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
11848 vat_main_t *vam = &vat_main;
11849 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
11850 vl_api_fib_path_t *fp;
11854 "table-id %d, label %u, ess_bit %u",
11855 ntohl (mp->mr_route.mr_table_id),
11856 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
11857 fp = mp->mr_route.mr_paths;
11858 for (i = 0; i < count; i++)
11860 vl_api_fib_path_print (vam, fp);
11865 static void vl_api_mpls_route_details_t_handler_json
11866 (vl_api_mpls_route_details_t * mp)
11868 vat_main_t *vam = &vat_main;
11869 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
11870 vat_json_node_t *node = NULL;
11871 vl_api_fib_path_t *fp;
11874 if (VAT_JSON_ARRAY != vam->json_tree.type)
11876 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11877 vat_json_init_array (&vam->json_tree);
11879 node = vat_json_array_add (&vam->json_tree);
11881 vat_json_init_object (node);
11882 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
11883 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
11884 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
11885 vat_json_object_add_uint (node, "path_count", count);
11886 fp = mp->mr_route.mr_paths;
11887 for (i = 0; i < count; i++)
11889 vl_api_mpls_fib_path_json_print (node, fp);
11895 api_mpls_route_dump (vat_main_t * vam)
11897 unformat_input_t *input = vam->input;
11898 vl_api_mpls_route_dump_t *mp;
11899 vl_api_control_ping_t *mp_ping;
11903 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11905 if (unformat (input, "table_id %d", &table_id))
11910 if (table_id == ~0)
11912 errmsg ("missing table id");
11916 M (MPLS_ROUTE_DUMP, mp);
11918 mp->table.mt_table_id = ntohl (table_id);
11921 /* Use a control ping for synchronization */
11922 MPING (CONTROL_PING, mp_ping);
11929 #define vl_api_ip_table_details_t_endian vl_noop_handler
11930 #define vl_api_ip_table_details_t_print vl_noop_handler
11933 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
11935 vat_main_t *vam = &vat_main;
11938 "%s; table-id %d, prefix %U/%d",
11939 mp->table.name, ntohl (mp->table.table_id));
11943 static void vl_api_ip_table_details_t_handler_json
11944 (vl_api_ip_table_details_t * mp)
11946 vat_main_t *vam = &vat_main;
11947 vat_json_node_t *node = NULL;
11949 if (VAT_JSON_ARRAY != vam->json_tree.type)
11951 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11952 vat_json_init_array (&vam->json_tree);
11954 node = vat_json_array_add (&vam->json_tree);
11956 vat_json_init_object (node);
11957 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
11961 api_ip_table_dump (vat_main_t * vam)
11963 vl_api_ip_table_dump_t *mp;
11964 vl_api_control_ping_t *mp_ping;
11967 M (IP_TABLE_DUMP, mp);
11970 /* Use a control ping for synchronization */
11971 MPING (CONTROL_PING, mp_ping);
11979 api_ip_mtable_dump (vat_main_t * vam)
11981 vl_api_ip_mtable_dump_t *mp;
11982 vl_api_control_ping_t *mp_ping;
11985 M (IP_MTABLE_DUMP, mp);
11988 /* Use a control ping for synchronization */
11989 MPING (CONTROL_PING, mp_ping);
11997 api_ip_mroute_dump (vat_main_t * vam)
11999 unformat_input_t *input = vam->input;
12000 vl_api_control_ping_t *mp_ping;
12001 vl_api_ip_mroute_dump_t *mp;
12006 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12008 if (unformat (input, "table_id %d", &table_id))
12010 else if (unformat (input, "ip6"))
12012 else if (unformat (input, "ip4"))
12017 if (table_id == ~0)
12019 errmsg ("missing table id");
12023 M (IP_MROUTE_DUMP, mp);
12024 mp->table.table_id = table_id;
12025 mp->table.is_ip6 = is_ip6;
12028 /* Use a control ping for synchronization */
12029 MPING (CONTROL_PING, mp_ping);
12036 #define vl_api_ip_route_details_t_endian vl_noop_handler
12037 #define vl_api_ip_route_details_t_print vl_noop_handler
12040 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
12042 vat_main_t *vam = &vat_main;
12043 u8 count = mp->route.n_paths;
12044 vl_api_fib_path_t *fp;
12048 "table-id %d, prefix %U/%d",
12049 ntohl (mp->route.table_id),
12050 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
12051 for (i = 0; i < count; i++)
12053 fp = &mp->route.paths[i];
12055 vl_api_fib_path_print (vam, fp);
12060 static void vl_api_ip_route_details_t_handler_json
12061 (vl_api_ip_route_details_t * mp)
12063 vat_main_t *vam = &vat_main;
12064 u8 count = mp->route.n_paths;
12065 vat_json_node_t *node = NULL;
12066 struct in_addr ip4;
12067 struct in6_addr ip6;
12068 vl_api_fib_path_t *fp;
12071 if (VAT_JSON_ARRAY != vam->json_tree.type)
12073 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12074 vat_json_init_array (&vam->json_tree);
12076 node = vat_json_array_add (&vam->json_tree);
12078 vat_json_init_object (node);
12079 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
12080 if (ADDRESS_IP6 == mp->route.prefix.address.af)
12082 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
12083 vat_json_object_add_ip6 (node, "prefix", ip6);
12087 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
12088 vat_json_object_add_ip4 (node, "prefix", ip4);
12090 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
12091 vat_json_object_add_uint (node, "path_count", count);
12092 for (i = 0; i < count; i++)
12094 fp = &mp->route.paths[i];
12095 vl_api_mpls_fib_path_json_print (node, fp);
12100 api_ip_route_dump (vat_main_t * vam)
12102 unformat_input_t *input = vam->input;
12103 vl_api_ip_route_dump_t *mp;
12104 vl_api_control_ping_t *mp_ping;
12110 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12112 if (unformat (input, "table_id %d", &table_id))
12114 else if (unformat (input, "ip6"))
12116 else if (unformat (input, "ip4"))
12121 if (table_id == ~0)
12123 errmsg ("missing table id");
12127 M (IP_ROUTE_DUMP, mp);
12129 mp->table.table_id = table_id;
12130 mp->table.is_ip6 = is_ip6;
12134 /* Use a control ping for synchronization */
12135 MPING (CONTROL_PING, mp_ping);
12143 api_classify_table_ids (vat_main_t * vam)
12145 vl_api_classify_table_ids_t *mp;
12148 /* Construct the API message */
12149 M (CLASSIFY_TABLE_IDS, mp);
12158 api_classify_table_by_interface (vat_main_t * vam)
12160 unformat_input_t *input = vam->input;
12161 vl_api_classify_table_by_interface_t *mp;
12163 u32 sw_if_index = ~0;
12165 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12167 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12169 else if (unformat (input, "sw_if_index %d", &sw_if_index))
12174 if (sw_if_index == ~0)
12176 errmsg ("missing interface name or sw_if_index");
12180 /* Construct the API message */
12181 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
12183 mp->sw_if_index = ntohl (sw_if_index);
12191 api_classify_table_info (vat_main_t * vam)
12193 unformat_input_t *input = vam->input;
12194 vl_api_classify_table_info_t *mp;
12198 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12200 if (unformat (input, "table_id %d", &table_id))
12205 if (table_id == ~0)
12207 errmsg ("missing table id");
12211 /* Construct the API message */
12212 M (CLASSIFY_TABLE_INFO, mp);
12214 mp->table_id = ntohl (table_id);
12222 api_classify_session_dump (vat_main_t * vam)
12224 unformat_input_t *input = vam->input;
12225 vl_api_classify_session_dump_t *mp;
12226 vl_api_control_ping_t *mp_ping;
12230 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12232 if (unformat (input, "table_id %d", &table_id))
12237 if (table_id == ~0)
12239 errmsg ("missing table id");
12243 /* Construct the API message */
12244 M (CLASSIFY_SESSION_DUMP, mp);
12246 mp->table_id = ntohl (table_id);
12249 /* Use a control ping for synchronization */
12250 MPING (CONTROL_PING, mp_ping);
12258 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
12260 vat_main_t *vam = &vat_main;
12262 print (vam->ofp, "collector_address %U, collector_port %d, "
12263 "src_address %U, vrf_id %d, path_mtu %u, "
12264 "template_interval %u, udp_checksum %d",
12265 format_ip4_address, mp->collector_address,
12266 ntohs (mp->collector_port),
12267 format_ip4_address, mp->src_address,
12268 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
12269 ntohl (mp->template_interval), mp->udp_checksum);
12272 vam->result_ready = 1;
12276 vl_api_ipfix_exporter_details_t_handler_json
12277 (vl_api_ipfix_exporter_details_t * mp)
12279 vat_main_t *vam = &vat_main;
12280 vat_json_node_t node;
12281 struct in_addr collector_address;
12282 struct in_addr src_address;
12284 vat_json_init_object (&node);
12285 clib_memcpy (&collector_address, &mp->collector_address,
12286 sizeof (collector_address));
12287 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
12288 vat_json_object_add_uint (&node, "collector_port",
12289 ntohs (mp->collector_port));
12290 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
12291 vat_json_object_add_ip4 (&node, "src_address", src_address);
12292 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
12293 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
12294 vat_json_object_add_uint (&node, "template_interval",
12295 ntohl (mp->template_interval));
12296 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
12298 vat_json_print (vam->ofp, &node);
12299 vat_json_free (&node);
12301 vam->result_ready = 1;
12305 api_ipfix_exporter_dump (vat_main_t * vam)
12307 vl_api_ipfix_exporter_dump_t *mp;
12310 /* Construct the API message */
12311 M (IPFIX_EXPORTER_DUMP, mp);
12320 api_ipfix_classify_stream_dump (vat_main_t * vam)
12322 vl_api_ipfix_classify_stream_dump_t *mp;
12325 /* Construct the API message */
12326 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
12337 vl_api_ipfix_classify_stream_details_t_handler
12338 (vl_api_ipfix_classify_stream_details_t * mp)
12340 vat_main_t *vam = &vat_main;
12341 print (vam->ofp, "domain_id %d, src_port %d",
12342 ntohl (mp->domain_id), ntohs (mp->src_port));
12344 vam->result_ready = 1;
12348 vl_api_ipfix_classify_stream_details_t_handler_json
12349 (vl_api_ipfix_classify_stream_details_t * mp)
12351 vat_main_t *vam = &vat_main;
12352 vat_json_node_t node;
12354 vat_json_init_object (&node);
12355 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
12356 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
12358 vat_json_print (vam->ofp, &node);
12359 vat_json_free (&node);
12361 vam->result_ready = 1;
12365 api_ipfix_classify_table_dump (vat_main_t * vam)
12367 vl_api_ipfix_classify_table_dump_t *mp;
12368 vl_api_control_ping_t *mp_ping;
12371 if (!vam->json_output)
12373 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
12374 "transport_protocol");
12377 /* Construct the API message */
12378 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
12383 /* Use a control ping for synchronization */
12384 MPING (CONTROL_PING, mp_ping);
12392 vl_api_ipfix_classify_table_details_t_handler
12393 (vl_api_ipfix_classify_table_details_t * mp)
12395 vat_main_t *vam = &vat_main;
12396 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
12397 mp->transport_protocol);
12401 vl_api_ipfix_classify_table_details_t_handler_json
12402 (vl_api_ipfix_classify_table_details_t * mp)
12404 vat_json_node_t *node = NULL;
12405 vat_main_t *vam = &vat_main;
12407 if (VAT_JSON_ARRAY != vam->json_tree.type)
12409 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12410 vat_json_init_array (&vam->json_tree);
12413 node = vat_json_array_add (&vam->json_tree);
12414 vat_json_init_object (node);
12416 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
12417 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
12418 vat_json_object_add_uint (node, "transport_protocol",
12419 mp->transport_protocol);
12423 api_sw_interface_span_enable_disable (vat_main_t * vam)
12425 unformat_input_t *i = vam->input;
12426 vl_api_sw_interface_span_enable_disable_t *mp;
12427 u32 src_sw_if_index = ~0;
12428 u32 dst_sw_if_index = ~0;
12433 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12436 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
12438 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
12442 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
12444 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
12446 else if (unformat (i, "disable"))
12448 else if (unformat (i, "rx"))
12450 else if (unformat (i, "tx"))
12452 else if (unformat (i, "both"))
12454 else if (unformat (i, "l2"))
12460 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
12462 mp->sw_if_index_from = htonl (src_sw_if_index);
12463 mp->sw_if_index_to = htonl (dst_sw_if_index);
12473 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
12476 vat_main_t *vam = &vat_main;
12477 u8 *sw_if_from_name = 0;
12478 u8 *sw_if_to_name = 0;
12479 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
12480 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
12481 char *states[] = { "none", "rx", "tx", "both" };
12485 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
12487 if ((u32) p->value[0] == sw_if_index_from)
12489 sw_if_from_name = (u8 *)(p->key);
12493 if ((u32) p->value[0] == sw_if_index_to)
12495 sw_if_to_name = (u8 *)(p->key);
12496 if (sw_if_from_name)
12501 print (vam->ofp, "%20s => %20s (%s) %s",
12502 sw_if_from_name, sw_if_to_name, states[mp->state],
12503 mp->is_l2 ? "l2" : "device");
12507 vl_api_sw_interface_span_details_t_handler_json
12508 (vl_api_sw_interface_span_details_t * mp)
12510 vat_main_t *vam = &vat_main;
12511 vat_json_node_t *node = NULL;
12512 u8 *sw_if_from_name = 0;
12513 u8 *sw_if_to_name = 0;
12514 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
12515 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
12519 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
12521 if ((u32) p->value[0] == sw_if_index_from)
12523 sw_if_from_name = (u8 *)(p->key);
12527 if ((u32) p->value[0] == sw_if_index_to)
12529 sw_if_to_name = (u8 *)(p->key);
12530 if (sw_if_from_name)
12536 if (VAT_JSON_ARRAY != vam->json_tree.type)
12538 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12539 vat_json_init_array (&vam->json_tree);
12541 node = vat_json_array_add (&vam->json_tree);
12543 vat_json_init_object (node);
12544 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
12545 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
12546 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
12547 if (0 != sw_if_to_name)
12549 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
12551 vat_json_object_add_uint (node, "state", mp->state);
12552 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
12556 api_sw_interface_span_dump (vat_main_t * vam)
12558 unformat_input_t *input = vam->input;
12559 vl_api_sw_interface_span_dump_t *mp;
12560 vl_api_control_ping_t *mp_ping;
12564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12566 if (unformat (input, "l2"))
12572 M (SW_INTERFACE_SPAN_DUMP, mp);
12576 /* Use a control ping for synchronization */
12577 MPING (CONTROL_PING, mp_ping);
12585 api_pg_create_interface (vat_main_t * vam)
12587 unformat_input_t *input = vam->input;
12588 vl_api_pg_create_interface_t *mp;
12590 u32 if_id = ~0, gso_size = 0;
12591 u8 gso_enabled = 0;
12593 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12595 if (unformat (input, "if_id %d", &if_id))
12597 else if (unformat (input, "gso-enabled"))
12600 if (unformat (input, "gso-size %u", &gso_size))
12604 errmsg ("missing gso-size");
12613 errmsg ("missing pg interface index");
12617 /* Construct the API message */
12618 M (PG_CREATE_INTERFACE, mp);
12620 mp->interface_id = ntohl (if_id);
12621 mp->gso_enabled = gso_enabled;
12629 api_pg_capture (vat_main_t * vam)
12631 unformat_input_t *input = vam->input;
12632 vl_api_pg_capture_t *mp;
12637 u8 pcap_file_set = 0;
12640 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12642 if (unformat (input, "if_id %d", &if_id))
12644 else if (unformat (input, "pcap %s", &pcap_file))
12646 else if (unformat (input, "count %d", &count))
12648 else if (unformat (input, "disable"))
12655 errmsg ("missing pg interface index");
12658 if (pcap_file_set > 0)
12660 if (vec_len (pcap_file) > 255)
12662 errmsg ("pcap file name is too long");
12667 /* Construct the API message */
12668 M (PG_CAPTURE, mp);
12670 mp->interface_id = ntohl (if_id);
12671 mp->is_enabled = enable;
12672 mp->count = ntohl (count);
12673 if (pcap_file_set != 0)
12675 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
12677 vec_free (pcap_file);
12685 api_pg_enable_disable (vat_main_t * vam)
12687 unformat_input_t *input = vam->input;
12688 vl_api_pg_enable_disable_t *mp;
12691 u8 stream_name_set = 0;
12692 u8 *stream_name = 0;
12694 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12696 if (unformat (input, "stream %s", &stream_name))
12697 stream_name_set = 1;
12698 else if (unformat (input, "disable"))
12704 if (stream_name_set > 0)
12706 if (vec_len (stream_name) > 255)
12708 errmsg ("stream name too long");
12713 /* Construct the API message */
12714 M (PG_ENABLE_DISABLE, mp);
12716 mp->is_enabled = enable;
12717 if (stream_name_set != 0)
12719 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
12721 vec_free (stream_name);
12729 api_pg_interface_enable_disable_coalesce (vat_main_t * vam)
12731 unformat_input_t *input = vam->input;
12732 vl_api_pg_interface_enable_disable_coalesce_t *mp;
12734 u32 sw_if_index = ~0;
12737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12739 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12741 else if (unformat (input, "sw_if_index %d", &sw_if_index))
12743 else if (unformat (input, "disable"))
12749 if (sw_if_index == ~0)
12751 errmsg ("Interface required but not specified");
12755 /* Construct the API message */
12756 M (PG_INTERFACE_ENABLE_DISABLE_COALESCE, mp);
12758 mp->coalesce_enabled = enable;
12759 mp->sw_if_index = htonl (sw_if_index);
12767 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
12769 unformat_input_t *input = vam->input;
12770 vl_api_ip_source_and_port_range_check_add_del_t *mp;
12772 u16 *low_ports = 0;
12773 u16 *high_ports = 0;
12776 vl_api_prefix_t prefix;
12783 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12785 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
12787 else if (unformat (input, "vrf %d", &vrf_id))
12789 else if (unformat (input, "del"))
12791 else if (unformat (input, "port %d", &tmp))
12793 if (tmp == 0 || tmp > 65535)
12795 errmsg ("port %d out of range", tmp);
12799 this_hi = this_low + 1;
12800 vec_add1 (low_ports, this_low);
12801 vec_add1 (high_ports, this_hi);
12803 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
12805 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
12807 errmsg ("incorrect range parameters");
12811 /* Note: in debug CLI +1 is added to high before
12812 passing to real fn that does "the work"
12813 (ip_source_and_port_range_check_add_del).
12814 This fn is a wrapper around the binary API fn a
12815 control plane will call, which expects this increment
12816 to have occurred. Hence letting the binary API control
12817 plane fn do the increment for consistency between VAT
12818 and other control planes.
12821 vec_add1 (low_ports, this_low);
12822 vec_add1 (high_ports, this_hi);
12828 if (prefix_set == 0)
12830 errmsg ("<address>/<mask> not specified");
12836 errmsg ("VRF ID required, not specified");
12843 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
12847 if (vec_len (low_ports) == 0)
12849 errmsg ("At least one port or port range required");
12853 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
12855 mp->is_add = is_add;
12857 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
12859 mp->number_of_ranges = vec_len (low_ports);
12861 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
12862 vec_free (low_ports);
12864 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
12865 vec_free (high_ports);
12867 mp->vrf_id = ntohl (vrf_id);
12875 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
12877 unformat_input_t *input = vam->input;
12878 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
12879 u32 sw_if_index = ~0;
12881 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
12882 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
12886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
12888 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12890 else if (unformat (input, "sw_if_index %d", &sw_if_index))
12892 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
12894 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
12896 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
12898 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
12900 else if (unformat (input, "del"))
12906 if (sw_if_index == ~0)
12908 errmsg ("Interface required but not specified");
12914 errmsg ("VRF ID required but not specified");
12918 if (tcp_out_vrf_id == 0
12919 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
12922 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
12926 /* Construct the API message */
12927 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
12929 mp->sw_if_index = ntohl (sw_if_index);
12930 mp->is_add = is_add;
12931 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
12932 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
12933 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
12934 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
12939 /* Wait for a reply... */
12945 api_set_punt (vat_main_t * vam)
12947 unformat_input_t *i = vam->input;
12948 vl_api_address_family_t af;
12949 vl_api_set_punt_t *mp;
12955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12957 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
12959 else if (unformat (i, "protocol %d", &protocol))
12961 else if (unformat (i, "port %d", &port))
12963 else if (unformat (i, "del"))
12967 clib_warning ("parse error '%U'", format_unformat_error, i);
12974 mp->is_add = (u8) is_add;
12975 mp->punt.type = PUNT_API_TYPE_L4;
12976 mp->punt.punt.l4.af = af;
12977 mp->punt.punt.l4.protocol = (u8) protocol;
12978 mp->punt.punt.l4.port = htons ((u16) port);
12986 api_delete_subif (vat_main_t * vam)
12988 unformat_input_t *i = vam->input;
12989 vl_api_delete_subif_t *mp;
12990 u32 sw_if_index = ~0;
12993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12997 if (unformat (i, "sw_if_index %d", &sw_if_index))
13003 if (sw_if_index == ~0)
13005 errmsg ("missing sw_if_index");
13009 /* Construct the API message */
13010 M (DELETE_SUBIF, mp);
13011 mp->sw_if_index = ntohl (sw_if_index);
13018 #define foreach_pbb_vtr_op \
13019 _("disable", L2_VTR_DISABLED) \
13020 _("pop", L2_VTR_POP_2) \
13021 _("push", L2_VTR_PUSH_2)
13024 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
13026 unformat_input_t *i = vam->input;
13027 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
13028 u32 sw_if_index = ~0, vtr_op = ~0;
13029 u16 outer_tag = ~0;
13030 u8 dmac[6], smac[6];
13031 u8 dmac_set = 0, smac_set = 0;
13037 /* Shut up coverity */
13038 clib_memset (dmac, 0, sizeof (dmac));
13039 clib_memset (smac, 0, sizeof (smac));
13041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13043 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13045 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13047 else if (unformat (i, "vtr_op %d", &vtr_op))
13049 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
13052 else if (unformat (i, "translate_pbb_stag"))
13054 if (unformat (i, "%d", &tmp))
13056 vtr_op = L2_VTR_TRANSLATE_2_1;
13062 ("translate_pbb_stag operation requires outer tag definition");
13066 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
13068 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
13070 else if (unformat (i, "sid %d", &sid))
13072 else if (unformat (i, "vlanid %d", &tmp))
13076 clib_warning ("parse error '%U'", format_unformat_error, i);
13081 if ((sw_if_index == ~0) || (vtr_op == ~0))
13083 errmsg ("missing sw_if_index or vtr operation");
13086 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
13087 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
13090 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
13094 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
13095 mp->sw_if_index = ntohl (sw_if_index);
13096 mp->vtr_op = ntohl (vtr_op);
13097 mp->outer_tag = ntohs (outer_tag);
13098 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
13099 clib_memcpy (mp->b_smac, smac, sizeof (smac));
13100 mp->b_vlanid = ntohs (vlanid);
13101 mp->i_sid = ntohl (sid);
13109 api_flow_classify_set_interface (vat_main_t * vam)
13111 unformat_input_t *i = vam->input;
13112 vl_api_flow_classify_set_interface_t *mp;
13114 int sw_if_index_set;
13115 u32 ip4_table_index = ~0;
13116 u32 ip6_table_index = ~0;
13120 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13123 sw_if_index_set = 1;
13124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13125 sw_if_index_set = 1;
13126 else if (unformat (i, "del"))
13128 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13130 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13134 clib_warning ("parse error '%U'", format_unformat_error, i);
13139 if (sw_if_index_set == 0)
13141 errmsg ("missing interface name or sw_if_index");
13145 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
13147 mp->sw_if_index = ntohl (sw_if_index);
13148 mp->ip4_table_index = ntohl (ip4_table_index);
13149 mp->ip6_table_index = ntohl (ip6_table_index);
13150 mp->is_add = is_add;
13158 api_flow_classify_dump (vat_main_t * vam)
13160 unformat_input_t *i = vam->input;
13161 vl_api_flow_classify_dump_t *mp;
13162 vl_api_control_ping_t *mp_ping;
13163 u8 type = FLOW_CLASSIFY_N_TABLES;
13166 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
13170 errmsg ("classify table type must be specified");
13174 if (!vam->json_output)
13176 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
13179 M (FLOW_CLASSIFY_DUMP, mp);
13184 /* Use a control ping for synchronization */
13185 MPING (CONTROL_PING, mp_ping);
13188 /* Wait for a reply... */
13194 api_feature_enable_disable (vat_main_t * vam)
13196 unformat_input_t *i = vam->input;
13197 vl_api_feature_enable_disable_t *mp;
13199 u8 *feature_name = 0;
13200 u32 sw_if_index = ~0;
13204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13206 if (unformat (i, "arc_name %s", &arc_name))
13208 else if (unformat (i, "feature_name %s", &feature_name))
13211 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13213 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13215 else if (unformat (i, "disable"))
13223 errmsg ("missing arc name");
13226 if (vec_len (arc_name) > 63)
13228 errmsg ("arc name too long");
13231 if (feature_name == 0)
13233 errmsg ("missing feature name");
13236 if (vec_len (feature_name) > 63)
13238 errmsg ("feature name too long");
13241 if (sw_if_index == ~0)
13243 errmsg ("missing interface name or sw_if_index");
13247 /* Construct the API message */
13248 M (FEATURE_ENABLE_DISABLE, mp);
13249 mp->sw_if_index = ntohl (sw_if_index);
13250 mp->enable = enable;
13251 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
13252 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
13253 vec_free (arc_name);
13254 vec_free (feature_name);
13262 api_feature_gso_enable_disable (vat_main_t * vam)
13264 unformat_input_t *i = vam->input;
13265 vl_api_feature_gso_enable_disable_t *mp;
13266 u32 sw_if_index = ~0;
13270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13272 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13274 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13276 else if (unformat (i, "enable"))
13278 else if (unformat (i, "disable"))
13284 if (sw_if_index == ~0)
13286 errmsg ("missing interface name or sw_if_index");
13290 /* Construct the API message */
13291 M (FEATURE_GSO_ENABLE_DISABLE, mp);
13292 mp->sw_if_index = ntohl (sw_if_index);
13293 mp->enable_disable = enable;
13301 api_sw_interface_tag_add_del (vat_main_t * vam)
13303 unformat_input_t *i = vam->input;
13304 vl_api_sw_interface_tag_add_del_t *mp;
13305 u32 sw_if_index = ~0;
13310 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13312 if (unformat (i, "tag %s", &tag))
13314 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13316 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13318 else if (unformat (i, "del"))
13324 if (sw_if_index == ~0)
13326 errmsg ("missing interface name or sw_if_index");
13330 if (enable && (tag == 0))
13332 errmsg ("no tag specified");
13336 /* Construct the API message */
13337 M (SW_INTERFACE_TAG_ADD_DEL, mp);
13338 mp->sw_if_index = ntohl (sw_if_index);
13339 mp->is_add = enable;
13341 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13350 api_sw_interface_add_del_mac_address (vat_main_t * vam)
13352 unformat_input_t *i = vam->input;
13353 vl_api_mac_address_t mac = { 0 };
13354 vl_api_sw_interface_add_del_mac_address_t *mp;
13355 u32 sw_if_index = ~0;
13360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13362 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13364 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13366 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
13368 else if (unformat (i, "del"))
13374 if (sw_if_index == ~0)
13376 errmsg ("missing interface name or sw_if_index");
13382 errmsg ("missing MAC address");
13386 /* Construct the API message */
13387 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
13388 mp->sw_if_index = ntohl (sw_if_index);
13389 mp->is_add = is_add;
13390 clib_memcpy (&mp->addr, &mac, sizeof (mac));
13397 static void vl_api_l2_xconnect_details_t_handler
13398 (vl_api_l2_xconnect_details_t * mp)
13400 vat_main_t *vam = &vat_main;
13402 print (vam->ofp, "%15d%15d",
13403 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
13406 static void vl_api_l2_xconnect_details_t_handler_json
13407 (vl_api_l2_xconnect_details_t * mp)
13409 vat_main_t *vam = &vat_main;
13410 vat_json_node_t *node = NULL;
13412 if (VAT_JSON_ARRAY != vam->json_tree.type)
13414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13415 vat_json_init_array (&vam->json_tree);
13417 node = vat_json_array_add (&vam->json_tree);
13419 vat_json_init_object (node);
13420 vat_json_object_add_uint (node, "rx_sw_if_index",
13421 ntohl (mp->rx_sw_if_index));
13422 vat_json_object_add_uint (node, "tx_sw_if_index",
13423 ntohl (mp->tx_sw_if_index));
13427 api_l2_xconnect_dump (vat_main_t * vam)
13429 vl_api_l2_xconnect_dump_t *mp;
13430 vl_api_control_ping_t *mp_ping;
13433 if (!vam->json_output)
13435 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
13438 M (L2_XCONNECT_DUMP, mp);
13442 /* Use a control ping for synchronization */
13443 MPING (CONTROL_PING, mp_ping);
13451 api_hw_interface_set_mtu (vat_main_t * vam)
13453 unformat_input_t *i = vam->input;
13454 vl_api_hw_interface_set_mtu_t *mp;
13455 u32 sw_if_index = ~0;
13459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13461 if (unformat (i, "mtu %d", &mtu))
13463 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13465 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13471 if (sw_if_index == ~0)
13473 errmsg ("missing interface name or sw_if_index");
13479 errmsg ("no mtu specified");
13483 /* Construct the API message */
13484 M (HW_INTERFACE_SET_MTU, mp);
13485 mp->sw_if_index = ntohl (sw_if_index);
13486 mp->mtu = ntohs ((u16) mtu);
13494 api_p2p_ethernet_add (vat_main_t * vam)
13496 unformat_input_t *i = vam->input;
13497 vl_api_p2p_ethernet_add_t *mp;
13498 u32 parent_if_index = ~0;
13504 clib_memset (remote_mac, 0, sizeof (remote_mac));
13505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13507 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
13509 else if (unformat (i, "sw_if_index %d", &parent_if_index))
13513 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
13515 else if (unformat (i, "sub_id %d", &sub_id))
13519 clib_warning ("parse error '%U'", format_unformat_error, i);
13524 if (parent_if_index == ~0)
13526 errmsg ("missing interface name or sw_if_index");
13531 errmsg ("missing remote mac address");
13536 errmsg ("missing sub-interface id");
13540 M (P2P_ETHERNET_ADD, mp);
13541 mp->parent_if_index = ntohl (parent_if_index);
13542 mp->subif_id = ntohl (sub_id);
13543 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
13551 api_p2p_ethernet_del (vat_main_t * vam)
13553 unformat_input_t *i = vam->input;
13554 vl_api_p2p_ethernet_del_t *mp;
13555 u32 parent_if_index = ~0;
13560 clib_memset (remote_mac, 0, sizeof (remote_mac));
13561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13563 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
13565 else if (unformat (i, "sw_if_index %d", &parent_if_index))
13569 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
13573 clib_warning ("parse error '%U'", format_unformat_error, i);
13578 if (parent_if_index == ~0)
13580 errmsg ("missing interface name or sw_if_index");
13585 errmsg ("missing remote mac address");
13589 M (P2P_ETHERNET_DEL, mp);
13590 mp->parent_if_index = ntohl (parent_if_index);
13591 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
13599 api_tcp_configure_src_addresses (vat_main_t * vam)
13601 vl_api_tcp_configure_src_addresses_t *mp;
13602 unformat_input_t *i = vam->input;
13603 vl_api_address_t first, last;
13608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13610 if (unformat (i, "%U - %U",
13611 unformat_vl_api_address, &first,
13612 unformat_vl_api_address, &last))
13616 errmsg ("one range per message (range already set)");
13621 else if (unformat (i, "vrf %d", &vrf_id))
13627 if (range_set == 0)
13629 errmsg ("address range not set");
13633 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
13635 mp->vrf_id = ntohl (vrf_id);
13636 clib_memcpy (&mp->first_address, &first, sizeof (first));
13637 clib_memcpy (&mp->last_address, &last, sizeof (last));
13644 static void vl_api_app_namespace_add_del_reply_t_handler
13645 (vl_api_app_namespace_add_del_reply_t * mp)
13647 vat_main_t *vam = &vat_main;
13648 i32 retval = ntohl (mp->retval);
13649 if (vam->async_mode)
13651 vam->async_errors += (retval < 0);
13655 vam->retval = retval;
13657 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
13658 vam->result_ready = 1;
13662 static void vl_api_app_namespace_add_del_reply_t_handler_json
13663 (vl_api_app_namespace_add_del_reply_t * mp)
13665 vat_main_t *vam = &vat_main;
13666 vat_json_node_t node;
13668 vat_json_init_object (&node);
13669 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13670 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
13672 vat_json_print (vam->ofp, &node);
13673 vat_json_free (&node);
13675 vam->retval = ntohl (mp->retval);
13676 vam->result_ready = 1;
13680 api_app_namespace_add_del (vat_main_t * vam)
13682 vl_api_app_namespace_add_del_t *mp;
13683 unformat_input_t *i = vam->input;
13684 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
13685 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
13689 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13691 if (unformat (i, "id %_%v%_", &ns_id))
13693 else if (unformat (i, "secret %lu", &secret))
13695 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13696 sw_if_index_set = 1;
13697 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
13699 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
13704 if (!ns_id || !secret_set || !sw_if_index_set)
13706 errmsg ("namespace id, secret and sw_if_index must be set");
13709 if (vec_len (ns_id) > 64)
13711 errmsg ("namespace id too long");
13714 M (APP_NAMESPACE_ADD_DEL, mp);
13716 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
13717 mp->secret = clib_host_to_net_u64 (secret);
13718 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
13719 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
13720 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
13728 api_sock_init_shm (vat_main_t * vam)
13730 #if VPP_API_TEST_BUILTIN == 0
13731 unformat_input_t *i = vam->input;
13732 vl_api_shm_elem_config_t *config = 0;
13733 u64 size = 64 << 20;
13736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13738 if (unformat (i, "size %U", unformat_memory_size, &size))
13745 * Canned custom ring allocator config.
13746 * Should probably parse all of this
13748 vec_validate (config, 6);
13749 config[0].type = VL_API_VLIB_RING;
13750 config[0].size = 256;
13751 config[0].count = 32;
13753 config[1].type = VL_API_VLIB_RING;
13754 config[1].size = 1024;
13755 config[1].count = 16;
13757 config[2].type = VL_API_VLIB_RING;
13758 config[2].size = 4096;
13759 config[2].count = 2;
13761 config[3].type = VL_API_CLIENT_RING;
13762 config[3].size = 256;
13763 config[3].count = 32;
13765 config[4].type = VL_API_CLIENT_RING;
13766 config[4].size = 1024;
13767 config[4].count = 16;
13769 config[5].type = VL_API_CLIENT_RING;
13770 config[5].size = 4096;
13771 config[5].count = 2;
13773 config[6].type = VL_API_QUEUE;
13774 config[6].count = 128;
13775 config[6].size = sizeof (uword);
13777 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
13779 vam->client_index_invalid = 1;
13787 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
13789 vat_main_t *vam = &vat_main;
13790 fib_prefix_t lcl, rmt;
13792 ip_prefix_decode (&mp->lcl, &lcl);
13793 ip_prefix_decode (&mp->rmt, &rmt);
13795 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
13798 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
13799 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
13800 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
13801 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
13802 &rmt.fp_addr.ip4, rmt.fp_len,
13803 clib_net_to_host_u16 (mp->rmt_port),
13804 clib_net_to_host_u32 (mp->action_index), mp->tag);
13809 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
13810 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
13811 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
13812 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
13813 &rmt.fp_addr.ip6, rmt.fp_len,
13814 clib_net_to_host_u16 (mp->rmt_port),
13815 clib_net_to_host_u32 (mp->action_index), mp->tag);
13820 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
13823 vat_main_t *vam = &vat_main;
13824 vat_json_node_t *node = NULL;
13825 struct in6_addr ip6;
13826 struct in_addr ip4;
13828 fib_prefix_t lcl, rmt;
13830 ip_prefix_decode (&mp->lcl, &lcl);
13831 ip_prefix_decode (&mp->rmt, &rmt);
13833 if (VAT_JSON_ARRAY != vam->json_tree.type)
13835 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13836 vat_json_init_array (&vam->json_tree);
13838 node = vat_json_array_add (&vam->json_tree);
13839 vat_json_init_object (node);
13841 vat_json_object_add_uint (node, "appns_index",
13842 clib_net_to_host_u32 (mp->appns_index));
13843 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
13844 vat_json_object_add_uint (node, "scope", mp->scope);
13845 vat_json_object_add_uint (node, "action_index",
13846 clib_net_to_host_u32 (mp->action_index));
13847 vat_json_object_add_uint (node, "lcl_port",
13848 clib_net_to_host_u16 (mp->lcl_port));
13849 vat_json_object_add_uint (node, "rmt_port",
13850 clib_net_to_host_u16 (mp->rmt_port));
13851 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
13852 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
13853 vat_json_object_add_string_copy (node, "tag", mp->tag);
13854 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
13856 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
13857 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
13858 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
13859 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
13863 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
13864 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
13865 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
13866 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
13871 api_session_rule_add_del (vat_main_t * vam)
13873 vl_api_session_rule_add_del_t *mp;
13874 unformat_input_t *i = vam->input;
13875 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
13876 u32 appns_index = 0, scope = 0;
13877 ip4_address_t lcl_ip4, rmt_ip4;
13878 ip6_address_t lcl_ip6, rmt_ip6;
13879 u8 is_ip4 = 1, conn_set = 0;
13880 u8 is_add = 1, *tag = 0;
13882 fib_prefix_t lcl, rmt;
13884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13886 if (unformat (i, "del"))
13888 else if (unformat (i, "add"))
13890 else if (unformat (i, "proto tcp"))
13892 else if (unformat (i, "proto udp"))
13894 else if (unformat (i, "appns %d", &appns_index))
13896 else if (unformat (i, "scope %d", &scope))
13898 else if (unformat (i, "tag %_%v%_", &tag))
13902 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
13903 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
13911 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
13912 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
13918 else if (unformat (i, "action %d", &action))
13923 if (proto == ~0 || !conn_set || action == ~0)
13925 errmsg ("transport proto, connection and action must be set");
13931 errmsg ("scope should be 0-3");
13935 M (SESSION_RULE_ADD_DEL, mp);
13937 clib_memset (&lcl, 0, sizeof (lcl));
13938 clib_memset (&rmt, 0, sizeof (rmt));
13941 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
13942 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
13943 lcl.fp_len = lcl_plen;
13944 rmt.fp_len = rmt_plen;
13948 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
13949 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
13950 lcl.fp_len = lcl_plen;
13951 rmt.fp_len = rmt_plen;
13955 ip_prefix_encode (&lcl, &mp->lcl);
13956 ip_prefix_encode (&rmt, &mp->rmt);
13957 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
13958 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
13959 mp->transport_proto =
13960 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
13961 mp->action_index = clib_host_to_net_u32 (action);
13962 mp->appns_index = clib_host_to_net_u32 (appns_index);
13964 mp->is_add = is_add;
13967 clib_memcpy (mp->tag, tag, vec_len (tag));
13977 api_session_rules_dump (vat_main_t * vam)
13979 vl_api_session_rules_dump_t *mp;
13980 vl_api_control_ping_t *mp_ping;
13983 if (!vam->json_output)
13985 print (vam->ofp, "%=20s", "Session Rules");
13988 M (SESSION_RULES_DUMP, mp);
13992 /* Use a control ping for synchronization */
13993 MPING (CONTROL_PING, mp_ping);
13996 /* Wait for a reply... */
14002 api_ip_container_proxy_add_del (vat_main_t * vam)
14004 vl_api_ip_container_proxy_add_del_t *mp;
14005 unformat_input_t *i = vam->input;
14006 u32 sw_if_index = ~0;
14007 vl_api_prefix_t pfx = { };
14011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14013 if (unformat (i, "del"))
14015 else if (unformat (i, "add"))
14017 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
14019 else if (unformat (i, "sw_if_index %u", &sw_if_index))
14024 if (sw_if_index == ~0 || pfx.len == 0)
14026 errmsg ("address and sw_if_index must be set");
14030 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
14032 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
14033 mp->is_add = is_add;
14034 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
14042 api_qos_record_enable_disable (vat_main_t * vam)
14044 unformat_input_t *i = vam->input;
14045 vl_api_qos_record_enable_disable_t *mp;
14046 u32 sw_if_index, qs = 0xff;
14047 u8 sw_if_index_set = 0;
14051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14053 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14054 sw_if_index_set = 1;
14055 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14056 sw_if_index_set = 1;
14057 else if (unformat (i, "%U", unformat_qos_source, &qs))
14059 else if (unformat (i, "disable"))
14063 clib_warning ("parse error '%U'", format_unformat_error, i);
14068 if (sw_if_index_set == 0)
14070 errmsg ("missing interface name or sw_if_index");
14075 errmsg ("input location must be specified");
14079 M (QOS_RECORD_ENABLE_DISABLE, mp);
14081 mp->record.sw_if_index = ntohl (sw_if_index);
14082 mp->record.input_source = qs;
14083 mp->enable = enable;
14092 q_or_quit (vat_main_t * vam)
14094 #if VPP_API_TEST_BUILTIN == 0
14095 longjmp (vam->jump_buf, 1);
14097 return 0; /* not so much */
14101 q (vat_main_t * vam)
14103 return q_or_quit (vam);
14107 quit (vat_main_t * vam)
14109 return q_or_quit (vam);
14113 comment (vat_main_t * vam)
14119 elog_save (vat_main_t * vam)
14121 #if VPP_API_TEST_BUILTIN == 0
14122 elog_main_t *em = &vam->elog_main;
14123 unformat_input_t *i = vam->input;
14124 char *file, *chroot_file;
14125 clib_error_t *error;
14127 if (!unformat (i, "%s", &file))
14129 errmsg ("expected file name, got `%U'", format_unformat_error, i);
14133 /* It's fairly hard to get "../oopsie" through unformat; just in case */
14134 if (strstr (file, "..") || index (file, '/'))
14136 errmsg ("illegal characters in filename '%s'", file);
14140 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
14144 errmsg ("Saving %wd of %wd events to %s",
14145 elog_n_events_in_buffer (em),
14146 elog_buffer_capacity (em), chroot_file);
14148 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
14149 vec_free (chroot_file);
14152 clib_error_report (error);
14154 errmsg ("Use the vpp event loger...");
14161 elog_setup (vat_main_t * vam)
14163 #if VPP_API_TEST_BUILTIN == 0
14164 elog_main_t *em = &vam->elog_main;
14165 unformat_input_t *i = vam->input;
14166 u32 nevents = 128 << 10;
14168 (void) unformat (i, "nevents %d", &nevents);
14170 elog_init (em, nevents);
14171 vl_api_set_elog_main (em);
14172 vl_api_set_elog_trace_api_messages (1);
14173 errmsg ("Event logger initialized with %u events", nevents);
14175 errmsg ("Use the vpp event loger...");
14181 elog_enable (vat_main_t * vam)
14183 #if VPP_API_TEST_BUILTIN == 0
14184 elog_main_t *em = &vam->elog_main;
14186 elog_enable_disable (em, 1 /* enable */ );
14187 vl_api_set_elog_trace_api_messages (1);
14188 errmsg ("Event logger enabled...");
14190 errmsg ("Use the vpp event loger...");
14196 elog_disable (vat_main_t * vam)
14198 #if VPP_API_TEST_BUILTIN == 0
14199 elog_main_t *em = &vam->elog_main;
14201 elog_enable_disable (em, 0 /* enable */ );
14202 vl_api_set_elog_trace_api_messages (1);
14203 errmsg ("Event logger disabled...");
14205 errmsg ("Use the vpp event loger...");
14211 statseg (vat_main_t * vam)
14213 ssvm_private_t *ssvmp = &vam->stat_segment;
14214 ssvm_shared_header_t *shared_header = ssvmp->sh;
14215 vlib_counter_t **counters;
14216 u64 thread0_index1_packets;
14217 u64 thread0_index1_bytes;
14218 f64 vector_rate, input_rate;
14221 uword *counter_vector_by_name;
14222 if (vam->stat_segment_lockp == 0)
14224 errmsg ("Stat segment not mapped...");
14228 /* look up "/if/rx for sw_if_index 1 as a test */
14230 clib_spinlock_lock (vam->stat_segment_lockp);
14232 counter_vector_by_name = (uword *) shared_header->opaque[1];
14234 p = hash_get_mem (counter_vector_by_name, "/if/rx");
14237 clib_spinlock_unlock (vam->stat_segment_lockp);
14238 errmsg ("/if/tx not found?");
14242 /* Fish per-thread vector of combined counters from shared memory */
14243 counters = (vlib_counter_t **) p[0];
14245 if (vec_len (counters[0]) < 2)
14247 clib_spinlock_unlock (vam->stat_segment_lockp);
14248 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
14252 /* Read thread 0 sw_if_index 1 counter */
14253 thread0_index1_packets = counters[0][1].packets;
14254 thread0_index1_bytes = counters[0][1].bytes;
14256 p = hash_get_mem (counter_vector_by_name, "vector_rate");
14259 clib_spinlock_unlock (vam->stat_segment_lockp);
14260 errmsg ("vector_rate not found?");
14264 vector_rate = *(f64 *) (p[0]);
14265 p = hash_get_mem (counter_vector_by_name, "input_rate");
14268 clib_spinlock_unlock (vam->stat_segment_lockp);
14269 errmsg ("input_rate not found?");
14272 input_rate = *(f64 *) (p[0]);
14274 clib_spinlock_unlock (vam->stat_segment_lockp);
14276 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
14277 vector_rate, input_rate);
14278 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
14279 thread0_index1_packets, thread0_index1_bytes);
14285 cmd_cmp (void *a1, void *a2)
14290 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
14294 help (vat_main_t * vam)
14299 unformat_input_t *i = vam->input;
14302 if (unformat (i, "%s", &name))
14306 vec_add1 (name, 0);
14308 hs = hash_get_mem (vam->help_by_name, name);
14310 print (vam->ofp, "usage: %s %s", name, hs[0]);
14312 print (vam->ofp, "No such msg / command '%s'", name);
14317 print (vam->ofp, "Help is available for the following:");
14320 hash_foreach_pair (p, vam->function_by_name,
14322 vec_add1 (cmds, (u8 *)(p->key));
14326 vec_sort_with_function (cmds, cmd_cmp);
14328 for (j = 0; j < vec_len (cmds); j++)
14329 print (vam->ofp, "%s", cmds[j]);
14336 set (vat_main_t * vam)
14338 u8 *name = 0, *value = 0;
14339 unformat_input_t *i = vam->input;
14341 if (unformat (i, "%s", &name))
14343 /* The input buffer is a vector, not a string. */
14344 value = vec_dup (i->buffer);
14345 vec_delete (value, i->index, 0);
14346 /* Almost certainly has a trailing newline */
14347 if (value[vec_len (value) - 1] == '\n')
14348 value[vec_len (value) - 1] = 0;
14349 /* Make sure it's a proper string, one way or the other */
14350 vec_add1 (value, 0);
14351 (void) clib_macro_set_value (&vam->macro_main,
14352 (char *) name, (char *) value);
14355 errmsg ("usage: set <name> <value>");
14363 unset (vat_main_t * vam)
14367 if (unformat (vam->input, "%s", &name))
14368 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
14369 errmsg ("unset: %s wasn't set", name);
14382 macro_sort_cmp (void *a1, void *a2)
14384 macro_sort_t *s1 = a1;
14385 macro_sort_t *s2 = a2;
14387 return strcmp ((char *) (s1->name), (char *) (s2->name));
14391 dump_macro_table (vat_main_t * vam)
14393 macro_sort_t *sort_me = 0, *sm;
14398 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
14400 vec_add2 (sort_me, sm, 1);
14401 sm->name = (u8 *)(p->key);
14402 sm->value = (u8 *) (p->value[0]);
14406 vec_sort_with_function (sort_me, macro_sort_cmp);
14408 if (vec_len (sort_me))
14409 print (vam->ofp, "%-15s%s", "Name", "Value");
14411 print (vam->ofp, "The macro table is empty...");
14413 for (i = 0; i < vec_len (sort_me); i++)
14414 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
14419 dump_node_table (vat_main_t * vam)
14422 vlib_node_t *node, *next_node;
14424 if (vec_len (vam->graph_nodes) == 0)
14426 print (vam->ofp, "Node table empty, issue get_node_graph...");
14430 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
14432 node = vam->graph_nodes[0][i];
14433 print (vam->ofp, "[%d] %s", i, node->name);
14434 for (j = 0; j < vec_len (node->next_nodes); j++)
14436 if (node->next_nodes[j] != ~0)
14438 next_node = vam->graph_nodes[0][node->next_nodes[j]];
14439 print (vam->ofp, " [%d] %s", j, next_node->name);
14447 value_sort_cmp (void *a1, void *a2)
14449 name_sort_t *n1 = a1;
14450 name_sort_t *n2 = a2;
14452 if (n1->value < n2->value)
14454 if (n1->value > n2->value)
14461 dump_msg_api_table (vat_main_t * vam)
14463 api_main_t *am = vlibapi_get_main ();
14464 name_sort_t *nses = 0, *ns;
14469 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
14471 vec_add2 (nses, ns, 1);
14472 ns->name = (u8 *)(hp->key);
14473 ns->value = (u32) hp->value[0];
14477 vec_sort_with_function (nses, value_sort_cmp);
14479 for (i = 0; i < vec_len (nses); i++)
14480 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
14486 get_msg_id (vat_main_t * vam)
14491 if (unformat (vam->input, "%s", &name_and_crc))
14493 message_index = vl_msg_api_get_msg_index (name_and_crc);
14494 if (message_index == ~0)
14496 print (vam->ofp, " '%s' not found", name_and_crc);
14499 print (vam->ofp, " '%s' has message index %d",
14500 name_and_crc, message_index);
14503 errmsg ("name_and_crc required...");
14508 search_node_table (vat_main_t * vam)
14510 unformat_input_t *line_input = vam->input;
14513 vlib_node_t *node, *next_node;
14516 if (vam->graph_node_index_by_name == 0)
14518 print (vam->ofp, "Node table empty, issue get_node_graph...");
14522 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14524 if (unformat (line_input, "%s", &node_to_find))
14526 vec_add1 (node_to_find, 0);
14527 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
14530 print (vam->ofp, "%s not found...", node_to_find);
14533 node = vam->graph_nodes[0][p[0]];
14534 print (vam->ofp, "[%d] %s", p[0], node->name);
14535 for (j = 0; j < vec_len (node->next_nodes); j++)
14537 if (node->next_nodes[j] != ~0)
14539 next_node = vam->graph_nodes[0][node->next_nodes[j]];
14540 print (vam->ofp, " [%d] %s", j, next_node->name);
14547 clib_warning ("parse error '%U'", format_unformat_error,
14553 vec_free (node_to_find);
14562 script (vat_main_t * vam)
14564 #if (VPP_API_TEST_BUILTIN==0)
14566 char *save_current_file;
14567 unformat_input_t save_input;
14568 jmp_buf save_jump_buf;
14569 u32 save_line_number;
14571 FILE *new_fp, *save_ifp;
14573 if (unformat (vam->input, "%s", &s))
14575 new_fp = fopen ((char *) s, "r");
14578 errmsg ("Couldn't open script file %s", s);
14585 errmsg ("Missing script name");
14589 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
14590 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
14591 save_ifp = vam->ifp;
14592 save_line_number = vam->input_line_number;
14593 save_current_file = (char *) vam->current_file;
14595 vam->input_line_number = 0;
14597 vam->current_file = s;
14600 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
14601 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
14602 vam->ifp = save_ifp;
14603 vam->input_line_number = save_line_number;
14604 vam->current_file = (u8 *) save_current_file;
14609 clib_warning ("use the exec command...");
14615 echo (vat_main_t * vam)
14617 print (vam->ofp, "%v", vam->input->buffer);
14621 /* List of API message constructors, CLI names map to api_xxx */
14622 #define foreach_vpe_api_msg \
14623 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
14624 _(sw_interface_dump,"") \
14625 _(sw_interface_set_flags, \
14626 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
14627 _(sw_interface_add_del_address, \
14628 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
14629 _(sw_interface_set_rx_mode, \
14630 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
14631 _(sw_interface_set_rx_placement, \
14632 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
14633 _(sw_interface_rx_placement_dump, \
14634 "[<intfc> | sw_if_index <id>]") \
14635 _(sw_interface_set_table, \
14636 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
14637 _(sw_interface_set_mpls_enable, \
14638 "<intfc> | sw_if_index [disable | dis]") \
14639 _(sw_interface_set_vpath, \
14640 "<intfc> | sw_if_index <id> enable | disable") \
14641 _(sw_interface_set_vxlan_bypass, \
14642 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
14643 _(sw_interface_set_l2_xconnect, \
14644 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
14645 "enable | disable") \
14646 _(sw_interface_set_l2_bridge, \
14647 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
14648 "[shg <split-horizon-group>] [bvi]\n" \
14649 "enable | disable") \
14650 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
14651 _(bridge_domain_add_del, \
14652 "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") \
14653 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
14655 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
14656 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
14657 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
14659 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
14661 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
14663 "id <num> [hw-addr <mac-addr>] [host-if-name <name>] [host-ns <name>] [num-rx-queues <num>] [rx-ring-size <num>] [tx-ring-size <num>] [host-bridge <name>] [host-mac-addr <mac-addr>] [host-ip4-addr <ip4addr/mask>] [host-ip6-addr <ip6addr/mask>] [host-mtu-size <mtu>] [gso | no-gso | csum-offload | gro-coalesce] [persist] [attach] [tun] [packed] [in-order]") \
14665 "<vpp-if-name> | sw_if_index <id>") \
14666 _(sw_interface_tap_v2_dump, "") \
14667 _(virtio_pci_create_v2, \
14668 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled [gro-coalesce] | csum-offload-enabled] [packed] [in-order] [buffering]") \
14669 _(virtio_pci_delete, \
14670 "<vpp-if-name> | sw_if_index <id>") \
14671 _(sw_interface_virtio_pci_dump, "") \
14673 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
14674 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
14677 "[hw-addr <mac-addr>] {mode round-robin | active-backup | " \
14678 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
14679 "[id <if-id>] [gso]") \
14681 "<vpp-if-name> | sw_if_index <id>") \
14682 _(bond_add_member, \
14683 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
14684 _(bond_detach_member, \
14685 "sw_if_index <n>") \
14686 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
14687 _(sw_bond_interface_dump, "<intfc> | sw_if_index <nn>") \
14688 _(sw_member_interface_dump, \
14689 "<vpp-if-name> | sw_if_index <id>") \
14690 _(ip_table_add_del, \
14691 "table <n> [ipv6] [add | del]\n") \
14692 _(ip_route_add_del, \
14693 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
14694 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
14695 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
14696 "[multipath] [count <n>] [del]") \
14697 _(ip_mroute_add_del, \
14698 "<src> <grp>/<mask> [table-id <n>]\n" \
14699 "[<intfc> | sw_if_index <id>] [local] [del]") \
14700 _(mpls_table_add_del, \
14701 "table <n> [add | del]\n") \
14702 _(mpls_route_add_del, \
14703 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
14704 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
14705 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
14706 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
14707 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
14708 "[count <n>] [del]") \
14709 _(mpls_ip_bind_unbind, \
14710 "<label> <addr/len>") \
14711 _(mpls_tunnel_add_del, \
14712 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
14713 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
14714 "[l2-only] [out-label <n>]") \
14715 _(sr_mpls_policy_add, \
14716 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
14717 _(sr_mpls_policy_del, \
14719 _(bier_table_add_del, \
14720 "<label> <sub-domain> <set> <bsl> [del]") \
14721 _(bier_route_add_del, \
14722 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
14723 "[<intfc> | sw_if_index <id>]" \
14724 "[weight <n>] [del] [multipath]") \
14725 _(sw_interface_set_unnumbered, \
14726 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
14727 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
14728 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
14729 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
14730 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
14731 "[outer_vlan_id_any][inner_vlan_id_any]") \
14732 _(ip_table_replace_begin, "table <n> [ipv6]") \
14733 _(ip_table_flush, "table <n> [ipv6]") \
14734 _(ip_table_replace_end, "table <n> [ipv6]") \
14735 _(set_ip_flow_hash, \
14736 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
14737 _(sw_interface_ip6_enable_disable, \
14738 "<intfc> | sw_if_index <id> enable | disable") \
14739 _(l2_patch_add_del, \
14740 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
14741 "enable | disable") \
14742 _(sr_localsid_add_del, \
14743 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
14744 "fib-table <num> (end.psp) sw_if_index <num>") \
14745 _(classify_add_del_table, \
14746 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
14747 " [del] [del-chain] mask <mask-value>\n" \
14748 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
14749 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
14750 _(classify_add_del_session, \
14751 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
14752 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
14753 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
14754 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
14755 _(classify_set_interface_ip_table, \
14756 "<intfc> | sw_if_index <nn> table <nn>") \
14757 _(classify_set_interface_l2_tables, \
14758 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
14759 " [other-table <nn>]") \
14760 _(get_node_index, "node <node-name") \
14761 _(add_node_next, "node <node-name> next <next-node-name>") \
14762 _(vxlan_offload_rx, \
14763 "hw { <interface name> | hw_if_index <nn>} " \
14764 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
14765 _(vxlan_add_del_tunnel, \
14766 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
14767 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
14768 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
14769 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
14770 _(l2_fib_clear_table, "") \
14771 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
14772 _(l2_interface_vlan_tag_rewrite, \
14773 "<intfc> | sw_if_index <nn> \n" \
14774 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
14775 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
14776 _(create_vhost_user_if, \
14777 "socket <filename> [server] [renumber <dev_instance>] " \
14778 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
14779 "[mac <mac_address>] [packed]") \
14780 _(modify_vhost_user_if, \
14781 "<intfc> | sw_if_index <nn> socket <filename>\n" \
14782 "[server] [renumber <dev_instance>] [gso] [packed]") \
14783 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
14784 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
14785 _(show_version, "") \
14786 _(show_threads, "") \
14787 _(vxlan_gpe_add_del_tunnel, \
14788 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
14789 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
14790 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
14791 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
14792 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
14793 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
14794 _(interface_name_renumber, \
14795 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
14796 _(input_acl_set_interface, \
14797 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
14798 " [l2-table <nn>] [del]") \
14799 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
14800 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
14801 _(ip_dump, "ipv4 | ipv6") \
14802 _(ipsec_spd_add_del, "spd_id <n> [del]") \
14803 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
14805 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
14806 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
14807 " integ_alg <alg> integ_key <hex>") \
14808 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
14809 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
14810 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
14811 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
14812 _(ipsec_sa_dump, "[sa_id <n>]") \
14813 _(delete_loopback,"sw_if_index <nn>") \
14814 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
14815 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
14816 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
14817 _(want_interface_events, "enable|disable") \
14818 _(get_first_msg_id, "client <name>") \
14819 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
14820 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
14821 "fib-id <nn> [ip4][ip6][default]") \
14822 _(get_node_graph, " ") \
14823 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
14824 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
14825 _(ioam_disable, "") \
14826 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
14827 _(af_packet_delete, "name <host interface name>") \
14828 _(af_packet_dump, "") \
14829 _(policer_add_del, "name <policer name> <params> [del]") \
14830 _(policer_dump, "[name <policer name>]") \
14831 _(policer_classify_set_interface, \
14832 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
14833 " [l2-table <nn>] [del]") \
14834 _(policer_classify_dump, "type [ip4|ip6|l2]") \
14835 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
14836 _(mpls_table_dump, "") \
14837 _(mpls_route_dump, "table-id <ID>") \
14838 _(classify_table_ids, "") \
14839 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
14840 _(classify_table_info, "table_id <nn>") \
14841 _(classify_session_dump, "table_id <nn>") \
14842 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
14843 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
14844 "[template_interval <nn>] [udp_checksum]") \
14845 _(ipfix_exporter_dump, "") \
14846 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
14847 _(ipfix_classify_stream_dump, "") \
14848 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
14849 _(ipfix_classify_table_dump, "") \
14850 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
14851 _(sw_interface_span_dump, "[l2]") \
14852 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
14853 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
14854 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
14855 _(pg_enable_disable, "[stream <id>] disable") \
14856 _(pg_interface_enable_disable_coalesce, "<intf> | sw_if_index <nn> enable | disable") \
14857 _(ip_source_and_port_range_check_add_del, \
14858 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
14859 _(ip_source_and_port_range_check_interface_add_del, \
14860 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
14861 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
14862 _(delete_subif,"<intfc> | sw_if_index <nn>") \
14863 _(l2_interface_pbb_tag_rewrite, \
14864 "<intfc> | sw_if_index <nn> \n" \
14865 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
14866 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
14867 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
14868 _(flow_classify_set_interface, \
14869 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
14870 _(flow_classify_dump, "type [ip4|ip6]") \
14871 _(ip_table_dump, "") \
14872 _(ip_route_dump, "table-id [ip4|ip6]") \
14873 _(ip_mtable_dump, "") \
14874 _(ip_mroute_dump, "table-id [ip4|ip6]") \
14875 _(feature_enable_disable, "arc_name <arc_name> " \
14876 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
14877 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
14878 "[enable | disable] ") \
14879 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
14881 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
14882 "mac <mac-address> [del]") \
14883 _(l2_xconnect_dump, "") \
14884 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
14885 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
14886 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
14887 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
14888 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
14889 _(sock_init_shm, "size <nnn>") \
14890 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
14891 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
14892 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
14893 _(session_rules_dump, "") \
14894 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
14895 _(output_acl_set_interface, \
14896 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
14897 " [l2-table <nn>] [del]") \
14898 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
14900 /* List of command functions, CLI names map directly to functions */
14901 #define foreach_cli_function \
14902 _(comment, "usage: comment <ignore-rest-of-line>") \
14903 _(dump_interface_table, "usage: dump_interface_table") \
14904 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
14905 _(dump_ipv4_table, "usage: dump_ipv4_table") \
14906 _(dump_ipv6_table, "usage: dump_ipv6_table") \
14907 _(dump_macro_table, "usage: dump_macro_table ") \
14908 _(dump_node_table, "usage: dump_node_table") \
14909 _(dump_msg_api_table, "usage: dump_msg_api_table") \
14910 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
14911 _(elog_disable, "usage: elog_disable") \
14912 _(elog_enable, "usage: elog_enable") \
14913 _(elog_save, "usage: elog_save <filename>") \
14914 _(get_msg_id, "usage: get_msg_id name_and_crc") \
14915 _(echo, "usage: echo <message>") \
14916 _(exec, "usage: exec <vpe-debug-CLI-command>") \
14917 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
14918 _(help, "usage: help") \
14919 _(q, "usage: quit") \
14920 _(quit, "usage: quit") \
14921 _(search_node_table, "usage: search_node_table <name>...") \
14922 _(set, "usage: set <variable-name> <value>") \
14923 _(script, "usage: script <file-name>") \
14924 _(statseg, "usage: statseg") \
14925 _(unset, "usage: unset <variable-name>")
14928 static void vl_api_##n##_t_handler_uni \
14929 (vl_api_##n##_t * mp) \
14931 vat_main_t * vam = &vat_main; \
14932 if (vam->json_output) { \
14933 vl_api_##n##_t_handler_json(mp); \
14935 vl_api_##n##_t_handler(mp); \
14938 foreach_vpe_api_reply_msg;
14939 #if VPP_API_TEST_BUILTIN == 0
14940 foreach_standalone_reply_msg;
14945 vat_api_hookup (vat_main_t * vam)
14948 vl_msg_api_set_handlers(VL_API_##N, #n, \
14949 vl_api_##n##_t_handler_uni, \
14951 vl_api_##n##_t_endian, \
14952 vl_api_##n##_t_print, \
14953 sizeof(vl_api_##n##_t), 1);
14954 foreach_vpe_api_reply_msg;
14955 #if VPP_API_TEST_BUILTIN == 0
14956 foreach_standalone_reply_msg;
14960 #if (VPP_API_TEST_BUILTIN==0)
14961 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
14963 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
14965 vam->function_by_name = hash_create_string (0, sizeof (uword));
14967 vam->help_by_name = hash_create_string (0, sizeof (uword));
14970 /* API messages we can send */
14971 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
14972 foreach_vpe_api_msg;
14976 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
14977 foreach_vpe_api_msg;
14980 /* CLI functions */
14981 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
14982 foreach_cli_function;
14986 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
14987 foreach_cli_function;
14991 #if VPP_API_TEST_BUILTIN
14992 static clib_error_t *
14993 vat_api_hookup_shim (vlib_main_t * vm)
14995 vat_api_hookup (&vat_main);
14999 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
15003 * fd.io coding-style-patch-verification: ON
15006 * eval: (c-set-style "gnu")