2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2020 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlib/pci/pci.h>
22 #include <vpp/api/types.h>
23 #include <vppinfra/socket.h>
24 #include <vlibapi/api.h>
25 #include <vlibmemory/api.h>
26 #include <vnet/ip/ip.h>
27 #include <vnet/ip-neighbor/ip_neighbor.h>
28 #include <vnet/ip/ip_types_api.h>
29 #include <vnet/l2/l2_input.h>
30 #include <vnet/l2tp/l2tp.h>
31 #include <vnet/vxlan/vxlan.h>
32 #include <vnet/geneve/geneve.h>
33 #include <vnet/gre/gre.h>
34 #include <vnet/vxlan-gpe/vxlan_gpe.h>
35 #include <vnet/lisp-gpe/lisp_gpe.h>
37 #include <vpp/api/vpe_msg_enum.h>
38 #include <vnet/l2/l2_classify.h>
39 #include <vnet/l2/l2_vtr.h>
40 #include <vnet/classify/in_out_acl.h>
41 #include <vnet/classify/policer_classify.h>
42 #include <vnet/classify/flow_classify.h>
43 #include <vnet/mpls/mpls.h>
44 #include <vnet/ipsec/ipsec.h>
46 #include <vnet/ip/ip6_hop_by_hop.h>
47 #include <vnet/ip/ip_source_and_port_range_check.h>
48 #include <vnet/policer/xlate.h>
49 #include <vnet/span/span.h>
50 #include <vnet/policer/policer.h>
51 #include <vnet/policer/police.h>
52 #include <vnet/mfib/mfib_types.h>
53 #include <vnet/bonding/node.h>
54 #include <vnet/qos/qos_types.h>
55 #include <vnet/ethernet/ethernet_types_api.h>
56 #include <vnet/ip/ip_types_api.h>
57 #include "vat/json_format.h"
58 #include <vnet/ip/ip_types_api.h>
59 #include <vnet/ethernet/ethernet_types_api.h>
64 #define vl_typedefs /* define message structures */
65 #include <vpp/api/vpe_all_api_h.h>
68 /* declare message handlers for each api */
70 #define vl_endianfun /* define message structures */
71 #include <vpp/api/vpe_all_api_h.h>
74 /* instantiate all the print functions we know about */
75 #if VPP_API_TEST_BUILTIN == 0
76 #define vl_print(handle, ...)
78 #define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
81 #include <vpp/api/vpe_all_api_h.h>
84 #define __plugin_msg_base 0
85 #include <vlibapi/vat_helper_macros.h>
87 #include <vnet/format_fns.h>
89 void vl_api_set_elog_main (elog_main_t * m);
90 int vl_api_set_elog_trace_api_messages (int enable);
92 #if VPP_API_TEST_BUILTIN == 0
102 vat_socket_connect (vat_main_t * vam)
105 api_main_t *am = vlibapi_get_main ();
106 vam->socket_client_main = &socket_client_main;
107 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
109 0 /* default socket rx, tx buffer */ )))
112 /* vpp expects the client index in network order */
113 vam->my_client_index = htonl (socket_client_main.client_index);
114 am->my_client_index = vam->my_client_index;
117 #else /* vpp built-in case, we don't do sockets... */
119 vat_socket_connect (vat_main_t * vam)
125 vl_socket_client_read (int wait)
131 vl_socket_client_write ()
137 vl_socket_client_msg_alloc (int nbytes)
145 vat_time_now (vat_main_t * vam)
147 #if VPP_API_TEST_BUILTIN
148 return vlib_time_now (vam->vlib_main);
150 return clib_time_now (&vam->clib_time);
155 errmsg (char *fmt, ...)
157 vat_main_t *vam = &vat_main;
162 s = va_format (0, fmt, &va);
167 #if VPP_API_TEST_BUILTIN
168 vlib_cli_output (vam->vlib_main, (char *) s);
171 if (vam->ifp != stdin)
172 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
173 vam->input_line_number);
175 fformat (vam->ofp, "%s\n", (char *) s);
183 #if VPP_API_TEST_BUILTIN == 0
185 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
187 vat_main_t *vam = va_arg (*args, vat_main_t *);
188 u32 *result = va_arg (*args, u32 *);
192 if (!unformat (input, "%s", &if_name))
195 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
203 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
208 /* Parse an IP4 address %d.%d.%d.%d. */
210 unformat_ip4_address (unformat_input_t * input, va_list * args)
212 u8 *result = va_arg (*args, u8 *);
215 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
218 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
230 unformat_ethernet_address (unformat_input_t * input, va_list * args)
232 u8 *result = va_arg (*args, u8 *);
235 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
236 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
240 for (i = 0; i < 6; i++)
241 if (a[i] >= (1 << 8))
244 for (i = 0; i < 6; i++)
250 /* Returns ethernet type as an int in host byte order. */
252 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
255 u16 *result = va_arg (*args, u16 *);
259 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
261 if (type >= (1 << 16))
269 /* Parse an IP46 address. */
271 unformat_ip46_address (unformat_input_t * input, va_list * args)
273 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
274 ip46_type_t type = va_arg (*args, ip46_type_t);
275 if ((type != IP46_TYPE_IP6) &&
276 unformat (input, "%U", unformat_ip4_address, &ip46->ip4))
278 ip46_address_mask_ip4 (ip46);
281 else if ((type != IP46_TYPE_IP4) &&
282 unformat (input, "%U", unformat_ip6_address, &ip46->ip6))
289 /* Parse an IP6 address. */
291 unformat_ip6_address (unformat_input_t * input, va_list * args)
293 ip6_address_t *result = va_arg (*args, ip6_address_t *);
295 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
296 uword c, n_colon, double_colon_index;
298 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
299 double_colon_index = ARRAY_LEN (hex_quads);
300 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
303 if (c >= '0' && c <= '9')
305 else if (c >= 'a' && c <= 'f')
306 hex_digit = c + 10 - 'a';
307 else if (c >= 'A' && c <= 'F')
308 hex_digit = c + 10 - 'A';
309 else if (c == ':' && n_colon < 2)
313 unformat_put_input (input);
317 /* Too many hex quads. */
318 if (n_hex_quads >= ARRAY_LEN (hex_quads))
323 hex_quad = (hex_quad << 4) | hex_digit;
325 /* Hex quad must fit in 16 bits. */
326 if (n_hex_digits >= 4)
333 /* Save position of :: */
336 /* More than one :: ? */
337 if (double_colon_index < ARRAY_LEN (hex_quads))
339 double_colon_index = n_hex_quads;
342 if (n_colon > 0 && n_hex_digits > 0)
344 hex_quads[n_hex_quads++] = hex_quad;
350 if (n_hex_digits > 0)
351 hex_quads[n_hex_quads++] = hex_quad;
356 /* Expand :: to appropriate number of zero hex quads. */
357 if (double_colon_index < ARRAY_LEN (hex_quads))
359 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
361 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
362 hex_quads[n_zero + i] = hex_quads[i];
364 for (i = 0; i < n_zero; i++)
365 hex_quads[double_colon_index + i] = 0;
367 n_hex_quads = ARRAY_LEN (hex_quads);
370 /* Too few hex quads given. */
371 if (n_hex_quads < ARRAY_LEN (hex_quads))
374 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
375 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
382 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
384 u32 *r = va_arg (*args, u32 *);
387 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
388 foreach_ipsec_policy_action
396 format_ipsec_crypto_alg (u8 * s, va_list * args)
398 u32 i = va_arg (*args, u32);
403 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
404 foreach_ipsec_crypto_alg
407 return format (s, "unknown");
409 return format (s, "%s", t);
413 format_ipsec_integ_alg (u8 * s, va_list * args)
415 u32 i = va_arg (*args, u32);
420 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
421 foreach_ipsec_integ_alg
424 return format (s, "unknown");
426 return format (s, "%s", t);
429 #else /* VPP_API_TEST_BUILTIN == 1 */
431 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
433 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
434 vnet_main_t *vnm = vnet_get_main ();
435 u32 *result = va_arg (*args, u32 *);
437 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
441 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
443 vat_main_t *vam __clib_unused = va_arg (*args, vat_main_t *);
444 vnet_main_t *vnm = vnet_get_main ();
445 u32 *result = va_arg (*args, u32 *);
447 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
450 #endif /* VPP_API_TEST_BUILTIN */
453 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
455 u32 *r = va_arg (*args, u32 *);
458 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
459 foreach_ipsec_crypto_alg
467 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
469 u32 *r = va_arg (*args, u32 *);
472 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
473 foreach_ipsec_integ_alg
481 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
483 u8 *r = va_arg (*args, u8 *);
485 if (unformat (input, "kbps"))
486 *r = SSE2_QOS_RATE_KBPS;
487 else if (unformat (input, "pps"))
488 *r = SSE2_QOS_RATE_PPS;
495 unformat_policer_round_type (unformat_input_t * input, va_list * args)
497 u8 *r = va_arg (*args, u8 *);
499 if (unformat (input, "closest"))
500 *r = SSE2_QOS_ROUND_TO_CLOSEST;
501 else if (unformat (input, "up"))
502 *r = SSE2_QOS_ROUND_TO_UP;
503 else if (unformat (input, "down"))
504 *r = SSE2_QOS_ROUND_TO_DOWN;
511 unformat_policer_type (unformat_input_t * input, va_list * args)
513 u8 *r = va_arg (*args, u8 *);
515 if (unformat (input, "1r2c"))
516 *r = SSE2_QOS_POLICER_TYPE_1R2C;
517 else if (unformat (input, "1r3c"))
518 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
519 else if (unformat (input, "2r3c-2698"))
520 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
521 else if (unformat (input, "2r3c-4115"))
522 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
523 else if (unformat (input, "2r3c-mef5cf1"))
524 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
531 unformat_dscp (unformat_input_t * input, va_list * va)
533 u8 *r = va_arg (*va, u8 *);
536 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
545 unformat_policer_action_type (unformat_input_t * input, va_list * va)
547 sse2_qos_pol_action_params_st *a
548 = va_arg (*va, sse2_qos_pol_action_params_st *);
550 if (unformat (input, "drop"))
551 a->action_type = SSE2_QOS_ACTION_DROP;
552 else if (unformat (input, "transmit"))
553 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
554 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
555 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
562 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
564 u32 *r = va_arg (*va, u32 *);
567 if (unformat (input, "ip4"))
568 tid = POLICER_CLASSIFY_TABLE_IP4;
569 else if (unformat (input, "ip6"))
570 tid = POLICER_CLASSIFY_TABLE_IP6;
571 else if (unformat (input, "l2"))
572 tid = POLICER_CLASSIFY_TABLE_L2;
581 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
583 u32 *r = va_arg (*va, u32 *);
586 if (unformat (input, "ip4"))
587 tid = FLOW_CLASSIFY_TABLE_IP4;
588 else if (unformat (input, "ip6"))
589 tid = FLOW_CLASSIFY_TABLE_IP6;
597 #if (VPP_API_TEST_BUILTIN==0)
599 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
600 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
601 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
602 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
605 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
607 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
608 mfib_itf_attribute_t attr;
611 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
613 if (unformat (input, mfib_itf_flag_long_names[attr]))
614 *iflags |= (1 << attr);
616 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
618 if (unformat (input, mfib_itf_flag_names[attr]))
619 *iflags |= (1 << attr);
622 return (old == *iflags ? 0 : 1);
626 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
628 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
629 mfib_entry_attribute_t attr;
632 FOR_EACH_MFIB_ATTRIBUTE (attr)
634 if (unformat (input, mfib_flag_long_names[attr]))
635 *eflags |= (1 << attr);
637 FOR_EACH_MFIB_ATTRIBUTE (attr)
639 if (unformat (input, mfib_flag_names[attr]))
640 *eflags |= (1 << attr);
643 return (old == *eflags ? 0 : 1);
647 format_ip4_address (u8 * s, va_list * args)
649 u8 *a = va_arg (*args, u8 *);
650 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
654 format_ip6_address (u8 * s, va_list * args)
656 ip6_address_t *a = va_arg (*args, ip6_address_t *);
657 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
659 i_max_n_zero = ARRAY_LEN (a->as_u16);
661 i_first_zero = i_max_n_zero;
663 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
665 u32 is_zero = a->as_u16[i] == 0;
666 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
672 if ((!is_zero && n_zeros > max_n_zeros)
673 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
675 i_max_n_zero = i_first_zero;
676 max_n_zeros = n_zeros;
677 i_first_zero = ARRAY_LEN (a->as_u16);
682 last_double_colon = 0;
683 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
685 if (i == i_max_n_zero && max_n_zeros > 1)
687 s = format (s, "::");
688 i += max_n_zeros - 1;
689 last_double_colon = 1;
693 s = format (s, "%s%x",
694 (last_double_colon || i == 0) ? "" : ":",
695 clib_net_to_host_u16 (a->as_u16[i]));
696 last_double_colon = 0;
703 /* Format an IP46 address. */
705 format_ip46_address (u8 * s, va_list * args)
707 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
708 ip46_type_t type = va_arg (*args, ip46_type_t);
714 is_ip4 = ip46_address_is_ip4 (ip46);
725 format (s, "%U", format_ip4_address, &ip46->ip4) :
726 format (s, "%U", format_ip6_address, &ip46->ip6);
730 format_ethernet_address (u8 * s, va_list * args)
732 u8 *a = va_arg (*args, u8 *);
734 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
735 a[0], a[1], a[2], a[3], a[4], a[5]);
740 increment_v4_address (vl_api_ip4_address_t * i)
742 ip4_address_t *a = (ip4_address_t *) i;
745 v = ntohl (a->as_u32) + 1;
746 a->as_u32 = ntohl (v);
750 increment_v6_address (vl_api_ip6_address_t * i)
752 ip6_address_t *a = (ip6_address_t *) i;
755 v0 = clib_net_to_host_u64 (a->as_u64[0]);
756 v1 = clib_net_to_host_u64 (a->as_u64[1]);
761 a->as_u64[0] = clib_net_to_host_u64 (v0);
762 a->as_u64[1] = clib_net_to_host_u64 (v1);
766 increment_address (vl_api_address_t * a)
768 if (a->af == ADDRESS_IP4)
769 increment_v4_address (&a->un.ip4);
770 else if (a->af == ADDRESS_IP6)
771 increment_v6_address (&a->un.ip6);
775 set_ip4_address (vl_api_address_t * a, u32 v)
777 if (a->af == ADDRESS_IP4)
779 ip4_address_t *i = (ip4_address_t *) & a->un.ip4;
785 ip_set (ip46_address_t * dst, void *src, u8 is_ip4)
788 dst->ip4.as_u32 = ((ip4_address_t *) src)->as_u32;
790 clib_memcpy_fast (&dst->ip6, (ip6_address_t *) src,
791 sizeof (ip6_address_t));
795 increment_mac_address (u8 * mac)
797 u64 tmp = *((u64 *) mac);
798 tmp = clib_net_to_host_u64 (tmp);
799 tmp += 1 << 16; /* skip unused (least significant) octets */
800 tmp = clib_host_to_net_u64 (tmp);
802 clib_memcpy (mac, &tmp, 6);
806 vat_json_object_add_address (vat_json_node_t * node,
807 const char *str, const vl_api_address_t * addr)
809 if (ADDRESS_IP6 == addr->af)
813 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
814 vat_json_object_add_ip6 (node, str, ip6);
820 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
821 vat_json_object_add_ip4 (node, str, ip4);
826 vat_json_object_add_prefix (vat_json_node_t * node,
827 const vl_api_prefix_t * prefix)
829 vat_json_object_add_uint (node, "len", prefix->len);
830 vat_json_object_add_address (node, "address", &prefix->address);
833 static void vl_api_create_loopback_reply_t_handler
834 (vl_api_create_loopback_reply_t * mp)
836 vat_main_t *vam = &vat_main;
837 i32 retval = ntohl (mp->retval);
839 vam->retval = retval;
840 vam->regenerate_interface_table = 1;
841 vam->sw_if_index = ntohl (mp->sw_if_index);
842 vam->result_ready = 1;
845 static void vl_api_create_loopback_reply_t_handler_json
846 (vl_api_create_loopback_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 vat_json_node_t node;
851 vat_json_init_object (&node);
852 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
853 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
855 vat_json_print (vam->ofp, &node);
856 vat_json_free (&node);
857 vam->retval = ntohl (mp->retval);
858 vam->result_ready = 1;
861 static void vl_api_create_loopback_instance_reply_t_handler
862 (vl_api_create_loopback_instance_reply_t * mp)
864 vat_main_t *vam = &vat_main;
865 i32 retval = ntohl (mp->retval);
867 vam->retval = retval;
868 vam->regenerate_interface_table = 1;
869 vam->sw_if_index = ntohl (mp->sw_if_index);
870 vam->result_ready = 1;
873 static void vl_api_create_loopback_instance_reply_t_handler_json
874 (vl_api_create_loopback_instance_reply_t * mp)
876 vat_main_t *vam = &vat_main;
877 vat_json_node_t node;
879 vat_json_init_object (&node);
880 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
881 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
883 vat_json_print (vam->ofp, &node);
884 vat_json_free (&node);
885 vam->retval = ntohl (mp->retval);
886 vam->result_ready = 1;
889 static void vl_api_af_packet_create_reply_t_handler
890 (vl_api_af_packet_create_reply_t * mp)
892 vat_main_t *vam = &vat_main;
893 i32 retval = ntohl (mp->retval);
895 vam->retval = retval;
896 vam->regenerate_interface_table = 1;
897 vam->sw_if_index = ntohl (mp->sw_if_index);
898 vam->result_ready = 1;
901 static void vl_api_af_packet_create_reply_t_handler_json
902 (vl_api_af_packet_create_reply_t * mp)
904 vat_main_t *vam = &vat_main;
905 vat_json_node_t node;
907 vat_json_init_object (&node);
908 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
909 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
911 vat_json_print (vam->ofp, &node);
912 vat_json_free (&node);
914 vam->retval = ntohl (mp->retval);
915 vam->result_ready = 1;
918 static void vl_api_create_vlan_subif_reply_t_handler
919 (vl_api_create_vlan_subif_reply_t * mp)
921 vat_main_t *vam = &vat_main;
922 i32 retval = ntohl (mp->retval);
924 vam->retval = retval;
925 vam->regenerate_interface_table = 1;
926 vam->sw_if_index = ntohl (mp->sw_if_index);
927 vam->result_ready = 1;
930 static void vl_api_create_vlan_subif_reply_t_handler_json
931 (vl_api_create_vlan_subif_reply_t * mp)
933 vat_main_t *vam = &vat_main;
934 vat_json_node_t node;
936 vat_json_init_object (&node);
937 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
938 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
940 vat_json_print (vam->ofp, &node);
941 vat_json_free (&node);
943 vam->retval = ntohl (mp->retval);
944 vam->result_ready = 1;
947 static void vl_api_create_subif_reply_t_handler
948 (vl_api_create_subif_reply_t * mp)
950 vat_main_t *vam = &vat_main;
951 i32 retval = ntohl (mp->retval);
953 vam->retval = retval;
954 vam->regenerate_interface_table = 1;
955 vam->sw_if_index = ntohl (mp->sw_if_index);
956 vam->result_ready = 1;
959 static void vl_api_create_subif_reply_t_handler_json
960 (vl_api_create_subif_reply_t * mp)
962 vat_main_t *vam = &vat_main;
963 vat_json_node_t node;
965 vat_json_init_object (&node);
966 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
967 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
969 vat_json_print (vam->ofp, &node);
970 vat_json_free (&node);
972 vam->retval = ntohl (mp->retval);
973 vam->result_ready = 1;
976 static void vl_api_interface_name_renumber_reply_t_handler
977 (vl_api_interface_name_renumber_reply_t * mp)
979 vat_main_t *vam = &vat_main;
980 i32 retval = ntohl (mp->retval);
982 vam->retval = retval;
983 vam->regenerate_interface_table = 1;
984 vam->result_ready = 1;
987 static void vl_api_interface_name_renumber_reply_t_handler_json
988 (vl_api_interface_name_renumber_reply_t * mp)
990 vat_main_t *vam = &vat_main;
991 vat_json_node_t node;
993 vat_json_init_object (&node);
994 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
996 vat_json_print (vam->ofp, &node);
997 vat_json_free (&node);
999 vam->retval = ntohl (mp->retval);
1000 vam->result_ready = 1;
1004 * Special-case: build the interface table, maintain
1005 * the next loopback sw_if_index vbl.
1007 static void vl_api_sw_interface_details_t_handler
1008 (vl_api_sw_interface_details_t * mp)
1010 vat_main_t *vam = &vat_main;
1011 u8 *s = format (0, "%s%c", mp->interface_name, 0);
1013 hash_set_mem (vam->sw_if_index_by_interface_name, s,
1014 ntohl (mp->sw_if_index));
1016 /* In sub interface case, fill the sub interface table entry */
1017 if (mp->sw_if_index != mp->sup_sw_if_index)
1019 sw_interface_subif_t *sub = NULL;
1021 vec_add2 (vam->sw_if_subif_table, sub, 1);
1023 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
1024 strncpy ((char *) sub->interface_name, (char *) s,
1025 vec_len (sub->interface_name));
1026 sub->sw_if_index = ntohl (mp->sw_if_index);
1027 sub->sub_id = ntohl (mp->sub_id);
1029 sub->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
1031 sub->sub_number_of_tags = mp->sub_number_of_tags;
1032 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
1033 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
1035 /* vlan tag rewrite */
1036 sub->vtr_op = ntohl (mp->vtr_op);
1037 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
1038 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
1039 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
1043 static void vl_api_sw_interface_details_t_handler_json
1044 (vl_api_sw_interface_details_t * mp)
1046 vat_main_t *vam = &vat_main;
1047 vat_json_node_t *node = NULL;
1049 if (VAT_JSON_ARRAY != vam->json_tree.type)
1051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1052 vat_json_init_array (&vam->json_tree);
1054 node = vat_json_array_add (&vam->json_tree);
1056 vat_json_init_object (node);
1057 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1058 vat_json_object_add_uint (node, "sup_sw_if_index",
1059 ntohl (mp->sup_sw_if_index));
1060 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
1061 sizeof (mp->l2_address));
1062 vat_json_object_add_string_copy (node, "interface_name",
1063 mp->interface_name);
1064 vat_json_object_add_string_copy (node, "interface_dev_type",
1065 mp->interface_dev_type);
1066 vat_json_object_add_uint (node, "flags", mp->flags);
1067 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
1068 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1069 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1070 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1071 vat_json_object_add_uint (node, "sub_number_of_tags",
1072 mp->sub_number_of_tags);
1073 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1074 ntohs (mp->sub_outer_vlan_id));
1075 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1076 ntohs (mp->sub_inner_vlan_id));
1077 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
1078 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1079 vat_json_object_add_uint (node, "vtr_push_dot1q",
1080 ntohl (mp->vtr_push_dot1q));
1081 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1082 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1083 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
1085 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1087 format_ethernet_address,
1089 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1091 format_ethernet_address,
1093 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1094 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1098 #if VPP_API_TEST_BUILTIN == 0
1099 static void vl_api_sw_interface_event_t_handler
1100 (vl_api_sw_interface_event_t * mp)
1102 vat_main_t *vam = &vat_main;
1103 if (vam->interface_event_display)
1104 errmsg ("interface flags: sw_if_index %d %s %s",
1105 ntohl (mp->sw_if_index),
1106 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1107 "admin-up" : "admin-down",
1108 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1109 "link-up" : "link-down");
1113 __clib_unused static void
1114 vl_api_sw_interface_event_t_handler_json (vl_api_sw_interface_event_t * mp)
1116 /* JSON output not supported */
1120 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1122 vat_main_t *vam = &vat_main;
1123 i32 retval = ntohl (mp->retval);
1125 vam->retval = retval;
1126 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1127 vam->result_ready = 1;
1131 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1133 vat_main_t *vam = &vat_main;
1134 vat_json_node_t node;
1138 vat_json_init_object (&node);
1139 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1140 vat_json_object_add_uint (&node, "reply_in_shmem",
1141 ntohl (mp->reply_in_shmem));
1142 /* Toss the shared-memory original... */
1143 oldheap = vl_msg_push_heap ();
1145 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1148 vl_msg_pop_heap (oldheap);
1150 vat_json_print (vam->ofp, &node);
1151 vat_json_free (&node);
1153 vam->retval = ntohl (mp->retval);
1154 vam->result_ready = 1;
1158 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1160 vat_main_t *vam = &vat_main;
1161 i32 retval = ntohl (mp->retval);
1163 vec_reset_length (vam->cmd_reply);
1165 vam->retval = retval;
1167 vam->cmd_reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1168 vam->result_ready = 1;
1172 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1174 vat_main_t *vam = &vat_main;
1175 vat_json_node_t node;
1176 u8 *reply = 0; /* reply vector */
1178 reply = vl_api_from_api_to_new_vec (mp, &mp->reply);
1179 vec_reset_length (vam->cmd_reply);
1181 vat_json_init_object (&node);
1182 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1183 vat_json_object_add_string_copy (&node, "reply", reply);
1185 vat_json_print (vam->ofp, &node);
1186 vat_json_free (&node);
1189 vam->retval = ntohl (mp->retval);
1190 vam->result_ready = 1;
1193 static void vl_api_classify_add_del_table_reply_t_handler
1194 (vl_api_classify_add_del_table_reply_t * mp)
1196 vat_main_t *vam = &vat_main;
1197 i32 retval = ntohl (mp->retval);
1198 if (vam->async_mode)
1200 vam->async_errors += (retval < 0);
1204 vam->retval = retval;
1206 ((mp->new_table_index != 0xFFFFFFFF) ||
1207 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1208 (mp->match_n_vectors != 0xFFFFFFFF)))
1210 * Note: this is just barely thread-safe, depends on
1211 * the main thread spinning waiting for an answer...
1213 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1214 ntohl (mp->new_table_index),
1215 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1216 vam->result_ready = 1;
1220 static void vl_api_classify_add_del_table_reply_t_handler_json
1221 (vl_api_classify_add_del_table_reply_t * mp)
1223 vat_main_t *vam = &vat_main;
1224 vat_json_node_t node;
1226 vat_json_init_object (&node);
1227 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1228 vat_json_object_add_uint (&node, "new_table_index",
1229 ntohl (mp->new_table_index));
1230 vat_json_object_add_uint (&node, "skip_n_vectors",
1231 ntohl (mp->skip_n_vectors));
1232 vat_json_object_add_uint (&node, "match_n_vectors",
1233 ntohl (mp->match_n_vectors));
1235 vat_json_print (vam->ofp, &node);
1236 vat_json_free (&node);
1238 vam->retval = ntohl (mp->retval);
1239 vam->result_ready = 1;
1242 static void vl_api_get_node_index_reply_t_handler
1243 (vl_api_get_node_index_reply_t * mp)
1245 vat_main_t *vam = &vat_main;
1246 i32 retval = ntohl (mp->retval);
1247 if (vam->async_mode)
1249 vam->async_errors += (retval < 0);
1253 vam->retval = retval;
1255 errmsg ("node index %d", ntohl (mp->node_index));
1256 vam->result_ready = 1;
1260 static void vl_api_get_node_index_reply_t_handler_json
1261 (vl_api_get_node_index_reply_t * mp)
1263 vat_main_t *vam = &vat_main;
1264 vat_json_node_t node;
1266 vat_json_init_object (&node);
1267 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1268 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1270 vat_json_print (vam->ofp, &node);
1271 vat_json_free (&node);
1273 vam->retval = ntohl (mp->retval);
1274 vam->result_ready = 1;
1277 static void vl_api_get_next_index_reply_t_handler
1278 (vl_api_get_next_index_reply_t * mp)
1280 vat_main_t *vam = &vat_main;
1281 i32 retval = ntohl (mp->retval);
1282 if (vam->async_mode)
1284 vam->async_errors += (retval < 0);
1288 vam->retval = retval;
1290 errmsg ("next node index %d", ntohl (mp->next_index));
1291 vam->result_ready = 1;
1295 static void vl_api_get_next_index_reply_t_handler_json
1296 (vl_api_get_next_index_reply_t * mp)
1298 vat_main_t *vam = &vat_main;
1299 vat_json_node_t node;
1301 vat_json_init_object (&node);
1302 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1303 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1305 vat_json_print (vam->ofp, &node);
1306 vat_json_free (&node);
1308 vam->retval = ntohl (mp->retval);
1309 vam->result_ready = 1;
1312 static void vl_api_add_node_next_reply_t_handler
1313 (vl_api_add_node_next_reply_t * mp)
1315 vat_main_t *vam = &vat_main;
1316 i32 retval = ntohl (mp->retval);
1317 if (vam->async_mode)
1319 vam->async_errors += (retval < 0);
1323 vam->retval = retval;
1325 errmsg ("next index %d", ntohl (mp->next_index));
1326 vam->result_ready = 1;
1330 static void vl_api_add_node_next_reply_t_handler_json
1331 (vl_api_add_node_next_reply_t * mp)
1333 vat_main_t *vam = &vat_main;
1334 vat_json_node_t node;
1336 vat_json_init_object (&node);
1337 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1338 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1340 vat_json_print (vam->ofp, &node);
1341 vat_json_free (&node);
1343 vam->retval = ntohl (mp->retval);
1344 vam->result_ready = 1;
1347 static void vl_api_show_version_reply_t_handler
1348 (vl_api_show_version_reply_t * mp)
1350 vat_main_t *vam = &vat_main;
1351 i32 retval = ntohl (mp->retval);
1355 errmsg (" program: %s", mp->program);
1356 errmsg (" version: %s", mp->version);
1357 errmsg (" build date: %s", mp->build_date);
1358 errmsg ("build directory: %s", mp->build_directory);
1360 vam->retval = retval;
1361 vam->result_ready = 1;
1364 static void vl_api_show_version_reply_t_handler_json
1365 (vl_api_show_version_reply_t * mp)
1367 vat_main_t *vam = &vat_main;
1368 vat_json_node_t node;
1370 vat_json_init_object (&node);
1371 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1372 vat_json_object_add_string_copy (&node, "program", mp->program);
1373 vat_json_object_add_string_copy (&node, "version", mp->version);
1374 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1375 vat_json_object_add_string_copy (&node, "build_directory",
1376 mp->build_directory);
1378 vat_json_print (vam->ofp, &node);
1379 vat_json_free (&node);
1381 vam->retval = ntohl (mp->retval);
1382 vam->result_ready = 1;
1385 static void vl_api_show_threads_reply_t_handler
1386 (vl_api_show_threads_reply_t * mp)
1388 vat_main_t *vam = &vat_main;
1389 i32 retval = ntohl (mp->retval);
1393 count = ntohl (mp->count);
1395 for (i = 0; i < count; i++)
1397 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1398 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1399 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1400 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1401 ntohl (mp->thread_data[i].cpu_socket));
1403 vam->retval = retval;
1404 vam->result_ready = 1;
1407 static void vl_api_show_threads_reply_t_handler_json
1408 (vl_api_show_threads_reply_t * mp)
1410 vat_main_t *vam = &vat_main;
1411 vat_json_node_t node;
1412 vl_api_thread_data_t *td;
1413 i32 retval = ntohl (mp->retval);
1417 count = ntohl (mp->count);
1419 vat_json_init_object (&node);
1420 vat_json_object_add_int (&node, "retval", retval);
1421 vat_json_object_add_uint (&node, "count", count);
1423 for (i = 0; i < count; i++)
1425 td = &mp->thread_data[i];
1426 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1427 vat_json_object_add_string_copy (&node, "name", td->name);
1428 vat_json_object_add_string_copy (&node, "type", td->type);
1429 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1430 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1431 vat_json_object_add_int (&node, "core", ntohl (td->id));
1432 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1435 vat_json_print (vam->ofp, &node);
1436 vat_json_free (&node);
1438 vam->retval = retval;
1439 vam->result_ready = 1;
1443 api_show_threads (vat_main_t * vam)
1445 vl_api_show_threads_t *mp;
1449 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1450 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1452 M (SHOW_THREADS, mp);
1460 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1462 u32 n_macs = ntohl (mp->n_macs);
1463 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1464 ntohl (mp->pid), mp->client_index, n_macs);
1466 for (i = 0; i < n_macs; i++)
1468 vl_api_mac_entry_t *mac = &mp->mac[i];
1469 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1470 i + 1, ntohl (mac->sw_if_index),
1471 format_ethernet_address, mac->mac_addr, mac->action);
1478 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1480 /* JSON output not supported */
1483 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1484 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1487 * Special-case: build the bridge domain table, maintain
1488 * the next bd id vbl.
1490 static void vl_api_bridge_domain_details_t_handler
1491 (vl_api_bridge_domain_details_t * mp)
1493 vat_main_t *vam = &vat_main;
1494 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1497 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1498 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1500 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1501 ntohl (mp->bd_id), mp->learn, mp->forward,
1502 mp->flood, ntohl (mp->bvi_sw_if_index),
1503 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1507 vl_api_bridge_domain_sw_if_t *sw_ifs;
1508 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1511 sw_ifs = mp->sw_if_details;
1512 for (i = 0; i < n_sw_ifs; i++)
1518 sw_if_index = ntohl (sw_ifs->sw_if_index);
1521 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1523 if ((u32) p->value[0] == sw_if_index)
1525 sw_if_name = (u8 *)(p->key);
1530 print (vam->ofp, "%7d %3d %s", sw_if_index,
1531 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1532 "sw_if_index not found!");
1539 static void vl_api_bridge_domain_details_t_handler_json
1540 (vl_api_bridge_domain_details_t * mp)
1542 vat_main_t *vam = &vat_main;
1543 vat_json_node_t *node, *array = NULL;
1544 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1546 if (VAT_JSON_ARRAY != vam->json_tree.type)
1548 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1549 vat_json_init_array (&vam->json_tree);
1551 node = vat_json_array_add (&vam->json_tree);
1553 vat_json_init_object (node);
1554 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1555 vat_json_object_add_uint (node, "flood", mp->flood);
1556 vat_json_object_add_uint (node, "forward", mp->forward);
1557 vat_json_object_add_uint (node, "learn", mp->learn);
1558 vat_json_object_add_uint (node, "bvi_sw_if_index",
1559 ntohl (mp->bvi_sw_if_index));
1560 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1561 array = vat_json_object_add (node, "sw_if");
1562 vat_json_init_array (array);
1568 vl_api_bridge_domain_sw_if_t *sw_ifs;
1571 sw_ifs = mp->sw_if_details;
1572 for (i = 0; i < n_sw_ifs; i++)
1574 node = vat_json_array_add (array);
1575 vat_json_init_object (node);
1576 vat_json_object_add_uint (node, "sw_if_index",
1577 ntohl (sw_ifs->sw_if_index));
1578 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1584 static void vl_api_control_ping_reply_t_handler
1585 (vl_api_control_ping_reply_t * mp)
1587 vat_main_t *vam = &vat_main;
1588 i32 retval = ntohl (mp->retval);
1589 if (vam->async_mode)
1591 vam->async_errors += (retval < 0);
1595 vam->retval = retval;
1596 vam->result_ready = 1;
1598 if (vam->socket_client_main)
1599 vam->socket_client_main->control_pings_outstanding--;
1602 static void vl_api_control_ping_reply_t_handler_json
1603 (vl_api_control_ping_reply_t * mp)
1605 vat_main_t *vam = &vat_main;
1606 i32 retval = ntohl (mp->retval);
1608 if (VAT_JSON_NONE != vam->json_tree.type)
1610 vat_json_print (vam->ofp, &vam->json_tree);
1611 vat_json_free (&vam->json_tree);
1612 vam->json_tree.type = VAT_JSON_NONE;
1617 vat_json_init_array (&vam->json_tree);
1618 vat_json_print (vam->ofp, &vam->json_tree);
1619 vam->json_tree.type = VAT_JSON_NONE;
1622 vam->retval = retval;
1623 vam->result_ready = 1;
1627 vl_api_bridge_domain_set_mac_age_reply_t_handler
1628 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1630 vat_main_t *vam = &vat_main;
1631 i32 retval = ntohl (mp->retval);
1632 if (vam->async_mode)
1634 vam->async_errors += (retval < 0);
1638 vam->retval = retval;
1639 vam->result_ready = 1;
1643 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1644 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1646 vat_main_t *vam = &vat_main;
1647 vat_json_node_t node;
1649 vat_json_init_object (&node);
1650 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1662 vat_main_t *vam = &vat_main;
1663 i32 retval = ntohl (mp->retval);
1664 if (vam->async_mode)
1666 vam->async_errors += (retval < 0);
1670 vam->retval = retval;
1671 vam->result_ready = 1;
1675 static void vl_api_l2_flags_reply_t_handler_json
1676 (vl_api_l2_flags_reply_t * mp)
1678 vat_main_t *vam = &vat_main;
1679 vat_json_node_t node;
1681 vat_json_init_object (&node);
1682 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1683 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1684 ntohl (mp->resulting_feature_bitmap));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_bridge_flags_reply_t_handler
1694 (vl_api_bridge_flags_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->result_ready = 1;
1709 static void vl_api_bridge_flags_reply_t_handler_json
1710 (vl_api_bridge_flags_reply_t * mp)
1712 vat_main_t *vam = &vat_main;
1713 vat_json_node_t node;
1715 vat_json_init_object (&node);
1716 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1717 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1718 ntohl (mp->resulting_feature_bitmap));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1728 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1745 static void vl_api_tap_create_v2_reply_t_handler_json
1746 (vl_api_tap_create_v2_reply_t * mp)
1748 vat_main_t *vam = &vat_main;
1749 vat_json_node_t node;
1751 vat_json_init_object (&node);
1752 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1753 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1755 vat_json_print (vam->ofp, &node);
1756 vat_json_free (&node);
1758 vam->retval = ntohl (mp->retval);
1759 vam->result_ready = 1;
1764 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1766 vat_main_t *vam = &vat_main;
1767 i32 retval = ntohl (mp->retval);
1768 if (vam->async_mode)
1770 vam->async_errors += (retval < 0);
1774 vam->retval = retval;
1775 vam->result_ready = 1;
1779 static void vl_api_tap_delete_v2_reply_t_handler_json
1780 (vl_api_tap_delete_v2_reply_t * mp)
1782 vat_main_t *vam = &vat_main;
1783 vat_json_node_t node;
1785 vat_json_init_object (&node);
1786 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1796 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1799 vat_main_t *vam = &vat_main;
1800 i32 retval = ntohl (mp->retval);
1801 if (vam->async_mode)
1803 vam->async_errors += (retval < 0);
1807 vam->retval = retval;
1808 vam->sw_if_index = ntohl (mp->sw_if_index);
1809 vam->result_ready = 1;
1813 static void vl_api_virtio_pci_create_reply_t_handler_json
1814 (vl_api_virtio_pci_create_reply_t * mp)
1816 vat_main_t *vam = &vat_main;
1817 vat_json_node_t node;
1819 vat_json_init_object (&node);
1820 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1821 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1823 vat_json_print (vam->ofp, &node);
1824 vat_json_free (&node);
1826 vam->retval = ntohl (mp->retval);
1827 vam->result_ready = 1;
1832 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1835 vat_main_t *vam = &vat_main;
1836 i32 retval = ntohl (mp->retval);
1837 if (vam->async_mode)
1839 vam->async_errors += (retval < 0);
1843 vam->retval = retval;
1844 vam->result_ready = 1;
1848 static void vl_api_virtio_pci_delete_reply_t_handler_json
1849 (vl_api_virtio_pci_delete_reply_t * mp)
1851 vat_main_t *vam = &vat_main;
1852 vat_json_node_t node;
1854 vat_json_init_object (&node);
1855 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1857 vat_json_print (vam->ofp, &node);
1858 vat_json_free (&node);
1860 vam->retval = ntohl (mp->retval);
1861 vam->result_ready = 1;
1865 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1867 vat_main_t *vam = &vat_main;
1868 i32 retval = ntohl (mp->retval);
1870 if (vam->async_mode)
1872 vam->async_errors += (retval < 0);
1876 vam->retval = retval;
1877 vam->sw_if_index = ntohl (mp->sw_if_index);
1878 vam->result_ready = 1;
1882 static void vl_api_bond_create_reply_t_handler_json
1883 (vl_api_bond_create_reply_t * mp)
1885 vat_main_t *vam = &vat_main;
1886 vat_json_node_t node;
1888 vat_json_init_object (&node);
1889 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1890 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1892 vat_json_print (vam->ofp, &node);
1893 vat_json_free (&node);
1895 vam->retval = ntohl (mp->retval);
1896 vam->result_ready = 1;
1900 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1902 vat_main_t *vam = &vat_main;
1903 i32 retval = ntohl (mp->retval);
1905 if (vam->async_mode)
1907 vam->async_errors += (retval < 0);
1911 vam->retval = retval;
1912 vam->result_ready = 1;
1916 static void vl_api_bond_delete_reply_t_handler_json
1917 (vl_api_bond_delete_reply_t * mp)
1919 vat_main_t *vam = &vat_main;
1920 vat_json_node_t node;
1922 vat_json_init_object (&node);
1923 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1925 vat_json_print (vam->ofp, &node);
1926 vat_json_free (&node);
1928 vam->retval = ntohl (mp->retval);
1929 vam->result_ready = 1;
1933 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1935 vat_main_t *vam = &vat_main;
1936 i32 retval = ntohl (mp->retval);
1938 if (vam->async_mode)
1940 vam->async_errors += (retval < 0);
1944 vam->retval = retval;
1945 vam->result_ready = 1;
1949 static void vl_api_bond_enslave_reply_t_handler_json
1950 (vl_api_bond_enslave_reply_t * mp)
1952 vat_main_t *vam = &vat_main;
1953 vat_json_node_t node;
1955 vat_json_init_object (&node);
1956 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1958 vat_json_print (vam->ofp, &node);
1959 vat_json_free (&node);
1961 vam->retval = ntohl (mp->retval);
1962 vam->result_ready = 1;
1966 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1969 vat_main_t *vam = &vat_main;
1970 i32 retval = ntohl (mp->retval);
1972 if (vam->async_mode)
1974 vam->async_errors += (retval < 0);
1978 vam->retval = retval;
1979 vam->result_ready = 1;
1983 static void vl_api_bond_detach_slave_reply_t_handler_json
1984 (vl_api_bond_detach_slave_reply_t * mp)
1986 vat_main_t *vam = &vat_main;
1987 vat_json_node_t node;
1989 vat_json_init_object (&node);
1990 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1992 vat_json_print (vam->ofp, &node);
1993 vat_json_free (&node);
1995 vam->retval = ntohl (mp->retval);
1996 vam->result_ready = 1;
2000 api_sw_interface_set_bond_weight (vat_main_t * vam)
2002 unformat_input_t *i = vam->input;
2003 vl_api_sw_interface_set_bond_weight_t *mp;
2004 u32 sw_if_index = ~0;
2006 u8 weight_enter = 0;
2009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2015 else if (unformat (i, "weight %u", &weight))
2021 if (sw_if_index == ~0)
2023 errmsg ("missing interface name or sw_if_index");
2026 if (weight_enter == 0)
2028 errmsg ("missing valid weight");
2032 /* Construct the API message */
2033 M (SW_INTERFACE_SET_BOND_WEIGHT, mp);
2034 mp->sw_if_index = ntohl (sw_if_index);
2035 mp->weight = ntohl (weight);
2042 static void vl_api_sw_interface_bond_details_t_handler
2043 (vl_api_sw_interface_bond_details_t * mp)
2045 vat_main_t *vam = &vat_main;
2048 "%-16s %-12d %-12U %-13U %-14u %-14u",
2049 mp->interface_name, ntohl (mp->sw_if_index),
2050 format_bond_mode, ntohl (mp->mode), format_bond_load_balance,
2051 ntohl (mp->lb), ntohl (mp->active_slaves), ntohl (mp->slaves));
2054 static void vl_api_sw_interface_bond_details_t_handler_json
2055 (vl_api_sw_interface_bond_details_t * mp)
2057 vat_main_t *vam = &vat_main;
2058 vat_json_node_t *node = NULL;
2060 if (VAT_JSON_ARRAY != vam->json_tree.type)
2062 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2063 vat_json_init_array (&vam->json_tree);
2065 node = vat_json_array_add (&vam->json_tree);
2067 vat_json_init_object (node);
2068 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2069 vat_json_object_add_string_copy (node, "interface_name",
2070 mp->interface_name);
2071 vat_json_object_add_uint (node, "mode", ntohl (mp->mode));
2072 vat_json_object_add_uint (node, "load_balance", ntohl (mp->lb));
2073 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2074 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2078 api_sw_interface_bond_dump (vat_main_t * vam)
2080 vl_api_sw_interface_bond_dump_t *mp;
2081 vl_api_control_ping_t *mp_ping;
2085 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2086 "interface name", "sw_if_index", "mode", "load balance",
2087 "active slaves", "slaves");
2089 /* Get list of bond interfaces */
2090 M (SW_INTERFACE_BOND_DUMP, mp);
2093 /* Use a control ping for synchronization */
2094 MPING (CONTROL_PING, mp_ping);
2101 static void vl_api_sw_interface_slave_details_t_handler
2102 (vl_api_sw_interface_slave_details_t * mp)
2104 vat_main_t *vam = &vat_main;
2107 "%-25s %-12d %-7d %-12d %-10d %-10d", mp->interface_name,
2108 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout,
2109 ntohl (mp->weight), mp->is_local_numa);
2112 static void vl_api_sw_interface_slave_details_t_handler_json
2113 (vl_api_sw_interface_slave_details_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vat_json_node_t *node = NULL;
2118 if (VAT_JSON_ARRAY != vam->json_tree.type)
2120 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2121 vat_json_init_array (&vam->json_tree);
2123 node = vat_json_array_add (&vam->json_tree);
2125 vat_json_init_object (node);
2126 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2127 vat_json_object_add_string_copy (node, "interface_name",
2128 mp->interface_name);
2129 vat_json_object_add_uint (node, "passive", mp->is_passive);
2130 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2131 vat_json_object_add_uint (node, "weight", ntohl (mp->weight));
2132 vat_json_object_add_uint (node, "is_local_numa", mp->is_local_numa);
2136 api_sw_interface_slave_dump (vat_main_t * vam)
2138 unformat_input_t *i = vam->input;
2139 vl_api_sw_interface_slave_dump_t *mp;
2140 vl_api_control_ping_t *mp_ping;
2141 u32 sw_if_index = ~0;
2142 u8 sw_if_index_set = 0;
2145 /* Parse args required to build the message */
2146 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2148 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2149 sw_if_index_set = 1;
2150 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2151 sw_if_index_set = 1;
2156 if (sw_if_index_set == 0)
2158 errmsg ("missing vpp interface name. ");
2163 "\n%-25s %-12s %-7s %-12s %-10s %-10s",
2164 "slave interface name", "sw_if_index", "passive", "long_timeout",
2165 "weight", "local numa");
2167 /* Get list of bond interfaces */
2168 M (SW_INTERFACE_SLAVE_DUMP, mp);
2169 mp->sw_if_index = ntohl (sw_if_index);
2172 /* Use a control ping for synchronization */
2173 MPING (CONTROL_PING, mp_ping);
2180 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2181 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2183 vat_main_t *vam = &vat_main;
2184 i32 retval = ntohl (mp->retval);
2185 if (vam->async_mode)
2187 vam->async_errors += (retval < 0);
2191 vam->retval = retval;
2192 vam->sw_if_index = ntohl (mp->sw_if_index);
2193 vam->result_ready = 1;
2195 vam->regenerate_interface_table = 1;
2198 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2199 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2201 vat_main_t *vam = &vat_main;
2202 vat_json_node_t node;
2204 vat_json_init_object (&node);
2205 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2206 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2207 ntohl (mp->sw_if_index));
2209 vat_json_print (vam->ofp, &node);
2210 vat_json_free (&node);
2212 vam->retval = ntohl (mp->retval);
2213 vam->result_ready = 1;
2216 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2217 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2219 vat_main_t *vam = &vat_main;
2220 i32 retval = ntohl (mp->retval);
2221 if (vam->async_mode)
2223 vam->async_errors += (retval < 0);
2227 vam->retval = retval;
2228 vam->sw_if_index = ntohl (mp->sw_if_index);
2229 vam->result_ready = 1;
2233 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2234 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2236 vat_main_t *vam = &vat_main;
2237 vat_json_node_t node;
2239 vat_json_init_object (&node);
2240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2241 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2243 vat_json_print (vam->ofp, &node);
2244 vat_json_free (&node);
2246 vam->retval = ntohl (mp->retval);
2247 vam->result_ready = 1;
2250 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2251 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2253 vat_main_t *vam = &vat_main;
2254 i32 retval = ntohl (mp->retval);
2255 if (vam->async_mode)
2257 vam->async_errors += (retval < 0);
2261 vam->retval = retval;
2262 vam->result_ready = 1;
2266 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2267 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2269 vat_main_t *vam = &vat_main;
2270 vat_json_node_t node;
2272 vat_json_init_object (&node);
2273 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2274 vat_json_object_add_uint (&node, "fwd_entry_index",
2275 clib_net_to_host_u32 (mp->fwd_entry_index));
2277 vat_json_print (vam->ofp, &node);
2278 vat_json_free (&node);
2280 vam->retval = ntohl (mp->retval);
2281 vam->result_ready = 1;
2285 format_lisp_transport_protocol (u8 * s, va_list * args)
2287 u32 proto = va_arg (*args, u32);
2292 return format (s, "udp");
2294 return format (s, "api");
2301 static void vl_api_one_get_transport_protocol_reply_t_handler
2302 (vl_api_one_get_transport_protocol_reply_t * mp)
2304 vat_main_t *vam = &vat_main;
2305 i32 retval = ntohl (mp->retval);
2306 if (vam->async_mode)
2308 vam->async_errors += (retval < 0);
2312 u32 proto = mp->protocol;
2313 print (vam->ofp, "Transport protocol: %U",
2314 format_lisp_transport_protocol, proto);
2315 vam->retval = retval;
2316 vam->result_ready = 1;
2320 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2321 (vl_api_one_get_transport_protocol_reply_t * mp)
2323 vat_main_t *vam = &vat_main;
2324 vat_json_node_t node;
2327 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2330 vat_json_init_object (&node);
2331 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2332 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2335 vat_json_print (vam->ofp, &node);
2336 vat_json_free (&node);
2338 vam->retval = ntohl (mp->retval);
2339 vam->result_ready = 1;
2342 static void vl_api_one_add_del_locator_set_reply_t_handler
2343 (vl_api_one_add_del_locator_set_reply_t * mp)
2345 vat_main_t *vam = &vat_main;
2346 i32 retval = ntohl (mp->retval);
2347 if (vam->async_mode)
2349 vam->async_errors += (retval < 0);
2353 vam->retval = retval;
2354 vam->result_ready = 1;
2358 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2359 (vl_api_one_add_del_locator_set_reply_t * mp)
2361 vat_main_t *vam = &vat_main;
2362 vat_json_node_t node;
2364 vat_json_init_object (&node);
2365 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2366 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2368 vat_json_print (vam->ofp, &node);
2369 vat_json_free (&node);
2371 vam->retval = ntohl (mp->retval);
2372 vam->result_ready = 1;
2375 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2376 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2378 vat_main_t *vam = &vat_main;
2379 i32 retval = ntohl (mp->retval);
2380 if (vam->async_mode)
2382 vam->async_errors += (retval < 0);
2386 vam->retval = retval;
2387 vam->sw_if_index = ntohl (mp->sw_if_index);
2388 vam->result_ready = 1;
2390 vam->regenerate_interface_table = 1;
2393 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2394 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2396 vat_main_t *vam = &vat_main;
2397 vat_json_node_t node;
2399 vat_json_init_object (&node);
2400 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2401 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2403 vat_json_print (vam->ofp, &node);
2404 vat_json_free (&node);
2406 vam->retval = ntohl (mp->retval);
2407 vam->result_ready = 1;
2410 static void vl_api_vxlan_offload_rx_reply_t_handler
2411 (vl_api_vxlan_offload_rx_reply_t * mp)
2413 vat_main_t *vam = &vat_main;
2414 i32 retval = ntohl (mp->retval);
2415 if (vam->async_mode)
2417 vam->async_errors += (retval < 0);
2421 vam->retval = retval;
2422 vam->result_ready = 1;
2426 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2427 (vl_api_vxlan_offload_rx_reply_t * mp)
2429 vat_main_t *vam = &vat_main;
2430 vat_json_node_t node;
2432 vat_json_init_object (&node);
2433 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2435 vat_json_print (vam->ofp, &node);
2436 vat_json_free (&node);
2438 vam->retval = ntohl (mp->retval);
2439 vam->result_ready = 1;
2442 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2443 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2445 vat_main_t *vam = &vat_main;
2446 i32 retval = ntohl (mp->retval);
2447 if (vam->async_mode)
2449 vam->async_errors += (retval < 0);
2453 vam->retval = retval;
2454 vam->sw_if_index = ntohl (mp->sw_if_index);
2455 vam->result_ready = 1;
2459 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2460 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2462 vat_main_t *vam = &vat_main;
2463 vat_json_node_t node;
2465 vat_json_init_object (&node);
2466 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2467 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2469 vat_json_print (vam->ofp, &node);
2470 vat_json_free (&node);
2472 vam->retval = ntohl (mp->retval);
2473 vam->result_ready = 1;
2476 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2477 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2479 vat_main_t *vam = &vat_main;
2480 i32 retval = ntohl (mp->retval);
2481 if (vam->async_mode)
2483 vam->async_errors += (retval < 0);
2487 vam->retval = retval;
2488 vam->sw_if_index = ntohl (mp->sw_if_index);
2489 vam->result_ready = 1;
2491 vam->regenerate_interface_table = 1;
2494 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2495 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2497 vat_main_t *vam = &vat_main;
2498 vat_json_node_t node;
2500 vat_json_init_object (&node);
2501 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2502 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2504 vat_json_print (vam->ofp, &node);
2505 vat_json_free (&node);
2507 vam->retval = ntohl (mp->retval);
2508 vam->result_ready = 1;
2511 static void vl_api_gre_tunnel_add_del_reply_t_handler
2512 (vl_api_gre_tunnel_add_del_reply_t * mp)
2514 vat_main_t *vam = &vat_main;
2515 i32 retval = ntohl (mp->retval);
2516 if (vam->async_mode)
2518 vam->async_errors += (retval < 0);
2522 vam->retval = retval;
2523 vam->sw_if_index = ntohl (mp->sw_if_index);
2524 vam->result_ready = 1;
2528 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2529 (vl_api_gre_tunnel_add_del_reply_t * mp)
2531 vat_main_t *vam = &vat_main;
2532 vat_json_node_t node;
2534 vat_json_init_object (&node);
2535 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2536 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2538 vat_json_print (vam->ofp, &node);
2539 vat_json_free (&node);
2541 vam->retval = ntohl (mp->retval);
2542 vam->result_ready = 1;
2545 static void vl_api_create_vhost_user_if_reply_t_handler
2546 (vl_api_create_vhost_user_if_reply_t * mp)
2548 vat_main_t *vam = &vat_main;
2549 i32 retval = ntohl (mp->retval);
2550 if (vam->async_mode)
2552 vam->async_errors += (retval < 0);
2556 vam->retval = retval;
2557 vam->sw_if_index = ntohl (mp->sw_if_index);
2558 vam->result_ready = 1;
2560 vam->regenerate_interface_table = 1;
2563 static void vl_api_create_vhost_user_if_reply_t_handler_json
2564 (vl_api_create_vhost_user_if_reply_t * mp)
2566 vat_main_t *vam = &vat_main;
2567 vat_json_node_t node;
2569 vat_json_init_object (&node);
2570 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2571 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2573 vat_json_print (vam->ofp, &node);
2574 vat_json_free (&node);
2576 vam->retval = ntohl (mp->retval);
2577 vam->result_ready = 1;
2580 static void vl_api_ip_address_details_t_handler
2581 (vl_api_ip_address_details_t * mp)
2583 vat_main_t *vam = &vat_main;
2584 static ip_address_details_t empty_ip_address_details = { {0} };
2585 ip_address_details_t *address = NULL;
2586 ip_details_t *current_ip_details = NULL;
2587 ip_details_t *details = NULL;
2589 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2591 if (!details || vam->current_sw_if_index >= vec_len (details)
2592 || !details[vam->current_sw_if_index].present)
2594 errmsg ("ip address details arrived but not stored");
2595 errmsg ("ip_dump should be called first");
2599 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2601 #define addresses (current_ip_details->addr)
2603 vec_validate_init_empty (addresses, vec_len (addresses),
2604 empty_ip_address_details);
2606 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2608 clib_memcpy (&address->ip, &mp->prefix.address.un, sizeof (address->ip));
2609 address->prefix_length = mp->prefix.len;
2613 static void vl_api_ip_address_details_t_handler_json
2614 (vl_api_ip_address_details_t * mp)
2616 vat_main_t *vam = &vat_main;
2617 vat_json_node_t *node = NULL;
2619 if (VAT_JSON_ARRAY != vam->json_tree.type)
2621 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2622 vat_json_init_array (&vam->json_tree);
2624 node = vat_json_array_add (&vam->json_tree);
2626 vat_json_init_object (node);
2627 vat_json_object_add_prefix (node, &mp->prefix);
2631 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2633 vat_main_t *vam = &vat_main;
2634 static ip_details_t empty_ip_details = { 0 };
2635 ip_details_t *ip = NULL;
2636 u32 sw_if_index = ~0;
2638 sw_if_index = ntohl (mp->sw_if_index);
2640 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2641 sw_if_index, empty_ip_details);
2643 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2650 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2652 vat_main_t *vam = &vat_main;
2654 if (VAT_JSON_ARRAY != vam->json_tree.type)
2656 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2657 vat_json_init_array (&vam->json_tree);
2659 vat_json_array_add_uint (&vam->json_tree,
2660 clib_net_to_host_u32 (mp->sw_if_index));
2663 static void vl_api_get_first_msg_id_reply_t_handler
2664 (vl_api_get_first_msg_id_reply_t * mp)
2666 vat_main_t *vam = &vat_main;
2667 i32 retval = ntohl (mp->retval);
2669 if (vam->async_mode)
2671 vam->async_errors += (retval < 0);
2675 vam->retval = retval;
2676 vam->result_ready = 1;
2680 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2684 static void vl_api_get_first_msg_id_reply_t_handler_json
2685 (vl_api_get_first_msg_id_reply_t * mp)
2687 vat_main_t *vam = &vat_main;
2688 vat_json_node_t node;
2690 vat_json_init_object (&node);
2691 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2692 vat_json_object_add_uint (&node, "first_msg_id",
2693 (uint) ntohs (mp->first_msg_id));
2695 vat_json_print (vam->ofp, &node);
2696 vat_json_free (&node);
2698 vam->retval = ntohl (mp->retval);
2699 vam->result_ready = 1;
2702 static void vl_api_get_node_graph_reply_t_handler
2703 (vl_api_get_node_graph_reply_t * mp)
2705 vat_main_t *vam = &vat_main;
2706 i32 retval = ntohl (mp->retval);
2707 u8 *pvt_copy, *reply;
2712 if (vam->async_mode)
2714 vam->async_errors += (retval < 0);
2718 vam->retval = retval;
2719 vam->result_ready = 1;
2722 /* "Should never happen..." */
2726 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2727 pvt_copy = vec_dup (reply);
2729 /* Toss the shared-memory original... */
2730 oldheap = vl_msg_push_heap ();
2734 vl_msg_pop_heap (oldheap);
2736 if (vam->graph_nodes)
2738 hash_free (vam->graph_node_index_by_name);
2740 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2742 node = vam->graph_nodes[0][i];
2743 vec_free (node->name);
2744 vec_free (node->next_nodes);
2747 vec_free (vam->graph_nodes[0]);
2748 vec_free (vam->graph_nodes);
2751 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2752 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2753 vec_free (pvt_copy);
2755 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2757 node = vam->graph_nodes[0][i];
2758 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2762 static void vl_api_get_node_graph_reply_t_handler_json
2763 (vl_api_get_node_graph_reply_t * mp)
2765 vat_main_t *vam = &vat_main;
2767 vat_json_node_t node;
2770 /* $$$$ make this real? */
2771 vat_json_init_object (&node);
2772 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2773 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2775 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2777 /* Toss the shared-memory original... */
2778 oldheap = vl_msg_push_heap ();
2782 vl_msg_pop_heap (oldheap);
2784 vat_json_print (vam->ofp, &node);
2785 vat_json_free (&node);
2787 vam->retval = ntohl (mp->retval);
2788 vam->result_ready = 1;
2792 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2794 vat_main_t *vam = &vat_main;
2799 s = format (s, "%=16d%=16d%=16d",
2800 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2804 s = format (s, "%=16U%=16d%=16d",
2805 format_ip46_address,
2806 mp->ip_address, mp->priority, mp->weight);
2809 print (vam->ofp, "%v", s);
2814 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2816 vat_main_t *vam = &vat_main;
2817 vat_json_node_t *node = NULL;
2818 struct in6_addr ip6;
2821 if (VAT_JSON_ARRAY != vam->json_tree.type)
2823 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2824 vat_json_init_array (&vam->json_tree);
2826 node = vat_json_array_add (&vam->json_tree);
2827 vat_json_init_object (node);
2829 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2830 vat_json_object_add_uint (node, "priority", mp->priority);
2831 vat_json_object_add_uint (node, "weight", mp->weight);
2834 vat_json_object_add_uint (node, "sw_if_index",
2835 clib_net_to_host_u32 (mp->sw_if_index));
2838 if (mp->ip_address.af)
2840 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
2841 vat_json_object_add_ip6 (node, "address", ip6);
2845 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
2846 vat_json_object_add_ip4 (node, "address", ip4);
2852 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2855 vat_main_t *vam = &vat_main;
2858 ls_name = format (0, "%s", mp->ls_name);
2860 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2866 vl_api_one_locator_set_details_t_handler_json
2867 (vl_api_one_locator_set_details_t * mp)
2869 vat_main_t *vam = &vat_main;
2870 vat_json_node_t *node = 0;
2873 ls_name = format (0, "%s", mp->ls_name);
2874 vec_add1 (ls_name, 0);
2876 if (VAT_JSON_ARRAY != vam->json_tree.type)
2878 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2879 vat_json_init_array (&vam->json_tree);
2881 node = vat_json_array_add (&vam->json_tree);
2883 vat_json_init_object (node);
2884 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2885 vat_json_object_add_uint (node, "ls_index",
2886 clib_net_to_host_u32 (mp->ls_index));
2894 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2897 unformat_nsh_address (unformat_input_t * input, va_list * args)
2899 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2900 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2904 format_nsh_address_vat (u8 * s, va_list * args)
2906 nsh_t *a = va_arg (*args, nsh_t *);
2907 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2911 format_lisp_flat_eid (u8 * s, va_list * args)
2913 vl_api_eid_t *eid = va_arg (*args, vl_api_eid_t *);
2917 case EID_TYPE_API_PREFIX:
2918 if (eid->address.prefix.address.af)
2919 return format (s, "%U/%d", format_ip6_address,
2920 eid->address.prefix.address.un.ip6,
2921 eid->address.prefix.len);
2922 return format (s, "%U/%d", format_ip4_address,
2923 eid->address.prefix.address.un.ip4,
2924 eid->address.prefix.len);
2925 case EID_TYPE_API_MAC:
2926 return format (s, "%U", format_ethernet_address, eid->address.mac);
2927 case EID_TYPE_API_NSH:
2928 return format (s, "%U", format_nsh_address_vat, eid->address.nsh);
2934 format_lisp_eid_vat (u8 * s, va_list * args)
2936 vl_api_eid_t *deid = va_arg (*args, vl_api_eid_t *);
2937 vl_api_eid_t *seid = va_arg (*args, vl_api_eid_t *);
2938 u8 is_src_dst = (u8) va_arg (*args, int);
2941 s = format (s, "%U|", format_lisp_flat_eid, seid);
2943 s = format (s, "%U", format_lisp_flat_eid, deid);
2949 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2951 vat_main_t *vam = &vat_main;
2952 u8 *s = 0, *eid = 0;
2954 if (~0 == mp->locator_set_index)
2955 s = format (0, "action: %d", mp->action);
2957 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2959 eid = format (0, "%U", format_lisp_eid_vat,
2960 &mp->deid, &mp->seid, mp->is_src_dst);
2963 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2964 clib_net_to_host_u32 (mp->vni),
2966 mp->is_local ? "local" : "remote",
2967 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2968 clib_net_to_host_u16 (mp->key.id), mp->key.key);
2975 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2978 vat_main_t *vam = &vat_main;
2979 vat_json_node_t *node = 0;
2982 if (VAT_JSON_ARRAY != vam->json_tree.type)
2984 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2985 vat_json_init_array (&vam->json_tree);
2987 node = vat_json_array_add (&vam->json_tree);
2989 vat_json_init_object (node);
2990 if (~0 == mp->locator_set_index)
2991 vat_json_object_add_uint (node, "action", mp->action);
2993 vat_json_object_add_uint (node, "locator_set_index",
2994 clib_net_to_host_u32 (mp->locator_set_index));
2996 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2997 if (mp->deid.type == 3)
2999 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3000 vat_json_init_object (nsh_json);
3001 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) & mp->deid.address.nsh;
3002 vat_json_object_add_uint (nsh_json, "spi",
3003 clib_net_to_host_u32 (nsh->spi));
3004 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3008 eid = format (0, "%U", format_lisp_eid_vat,
3009 &mp->deid, &mp->seid, mp->is_src_dst);
3011 vat_json_object_add_string_copy (node, "eid", eid);
3014 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3015 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3016 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3020 vat_json_object_add_uint (node, "key_id",
3021 clib_net_to_host_u16 (mp->key.id));
3022 vat_json_object_add_string_copy (node, "key", mp->key.key);
3027 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3029 vat_main_t *vam = &vat_main;
3030 u8 *seid = 0, *deid = 0;
3031 ip46_address_t lloc, rloc;
3033 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3035 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3042 clib_memcpy (&lloc.ip6, mp->lloc.un.ip6, 16);
3043 clib_memcpy (&rloc.ip6, mp->rloc.un.ip6, 16);
3047 clib_memcpy (&lloc.ip4, mp->lloc.un.ip4, 4);
3048 clib_memcpy (&rloc.ip4, mp->rloc.un.ip4, 4);
3052 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3053 clib_net_to_host_u32 (mp->vni),
3055 format_ip46_address, lloc,
3056 format_ip46_address, rloc,
3057 clib_net_to_host_u32 (mp->pkt_count),
3058 clib_net_to_host_u32 (mp->bytes));
3065 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3067 struct in6_addr ip6;
3069 vat_main_t *vam = &vat_main;
3070 vat_json_node_t *node = 0;
3071 u8 *deid = 0, *seid = 0;
3073 if (VAT_JSON_ARRAY != vam->json_tree.type)
3075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3076 vat_json_init_array (&vam->json_tree);
3078 node = vat_json_array_add (&vam->json_tree);
3080 vat_json_init_object (node);
3081 deid = format (0, "%U", format_lisp_eid_vat, &mp->deid, 0, 0);
3083 seid = format (0, "%U", format_lisp_eid_vat, &mp->seid, 0, 0);
3088 vat_json_object_add_string_copy (node, "seid", seid);
3089 vat_json_object_add_string_copy (node, "deid", deid);
3090 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3094 clib_memcpy (&ip6, mp->lloc.un.ip6, sizeof (ip6));
3095 vat_json_object_add_ip6 (node, "lloc", ip6);
3096 clib_memcpy (&ip6, mp->rloc.un.ip6, sizeof (ip6));
3097 vat_json_object_add_ip6 (node, "rloc", ip6);
3102 clib_memcpy (&ip4, mp->lloc.un.ip4, sizeof (ip4));
3103 vat_json_object_add_ip4 (node, "lloc", ip4);
3104 clib_memcpy (&ip4, mp->rloc.un.ip4, sizeof (ip4));
3105 vat_json_object_add_ip4 (node, "rloc", ip4);
3107 vat_json_object_add_uint (node, "pkt_count",
3108 clib_net_to_host_u32 (mp->pkt_count));
3109 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3116 vl_api_one_eid_table_map_details_t_handler
3117 (vl_api_one_eid_table_map_details_t * mp)
3119 vat_main_t *vam = &vat_main;
3121 u8 *line = format (0, "%=10d%=10d",
3122 clib_net_to_host_u32 (mp->vni),
3123 clib_net_to_host_u32 (mp->dp_table));
3124 print (vam->ofp, "%v", line);
3129 vl_api_one_eid_table_map_details_t_handler_json
3130 (vl_api_one_eid_table_map_details_t * mp)
3132 vat_main_t *vam = &vat_main;
3133 vat_json_node_t *node = NULL;
3135 if (VAT_JSON_ARRAY != vam->json_tree.type)
3137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3138 vat_json_init_array (&vam->json_tree);
3140 node = vat_json_array_add (&vam->json_tree);
3141 vat_json_init_object (node);
3142 vat_json_object_add_uint (node, "dp_table",
3143 clib_net_to_host_u32 (mp->dp_table));
3144 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3148 vl_api_one_eid_table_vni_details_t_handler
3149 (vl_api_one_eid_table_vni_details_t * mp)
3151 vat_main_t *vam = &vat_main;
3153 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3154 print (vam->ofp, "%v", line);
3159 vl_api_one_eid_table_vni_details_t_handler_json
3160 (vl_api_one_eid_table_vni_details_t * mp)
3162 vat_main_t *vam = &vat_main;
3163 vat_json_node_t *node = NULL;
3165 if (VAT_JSON_ARRAY != vam->json_tree.type)
3167 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3168 vat_json_init_array (&vam->json_tree);
3170 node = vat_json_array_add (&vam->json_tree);
3171 vat_json_init_object (node);
3172 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3176 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3177 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3179 vat_main_t *vam = &vat_main;
3180 int retval = clib_net_to_host_u32 (mp->retval);
3182 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3183 print (vam->ofp, "fallback threshold value: %d", mp->value);
3185 vam->retval = retval;
3186 vam->result_ready = 1;
3190 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3191 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3193 vat_main_t *vam = &vat_main;
3194 vat_json_node_t _node, *node = &_node;
3195 int retval = clib_net_to_host_u32 (mp->retval);
3197 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3198 vat_json_init_object (node);
3199 vat_json_object_add_uint (node, "value", mp->value);
3201 vat_json_print (vam->ofp, node);
3202 vat_json_free (node);
3204 vam->retval = retval;
3205 vam->result_ready = 1;
3209 vl_api_show_one_map_register_state_reply_t_handler
3210 (vl_api_show_one_map_register_state_reply_t * mp)
3212 vat_main_t *vam = &vat_main;
3213 int retval = clib_net_to_host_u32 (mp->retval);
3215 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3217 vam->retval = retval;
3218 vam->result_ready = 1;
3222 vl_api_show_one_map_register_state_reply_t_handler_json
3223 (vl_api_show_one_map_register_state_reply_t * mp)
3225 vat_main_t *vam = &vat_main;
3226 vat_json_node_t _node, *node = &_node;
3227 int retval = clib_net_to_host_u32 (mp->retval);
3229 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3231 vat_json_init_object (node);
3232 vat_json_object_add_string_copy (node, "state", s);
3234 vat_json_print (vam->ofp, node);
3235 vat_json_free (node);
3237 vam->retval = retval;
3238 vam->result_ready = 1;
3243 vl_api_show_one_rloc_probe_state_reply_t_handler
3244 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3246 vat_main_t *vam = &vat_main;
3247 int retval = clib_net_to_host_u32 (mp->retval);
3252 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3254 vam->retval = retval;
3255 vam->result_ready = 1;
3259 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3260 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3262 vat_main_t *vam = &vat_main;
3263 vat_json_node_t _node, *node = &_node;
3264 int retval = clib_net_to_host_u32 (mp->retval);
3266 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3267 vat_json_init_object (node);
3268 vat_json_object_add_string_copy (node, "state", s);
3270 vat_json_print (vam->ofp, node);
3271 vat_json_free (node);
3273 vam->retval = retval;
3274 vam->result_ready = 1;
3279 vl_api_show_one_stats_enable_disable_reply_t_handler
3280 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3282 vat_main_t *vam = &vat_main;
3283 int retval = clib_net_to_host_u32 (mp->retval);
3288 print (vam->ofp, "%s", mp->is_enable ? "enabled" : "disabled");
3290 vam->retval = retval;
3291 vam->result_ready = 1;
3295 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3296 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3298 vat_main_t *vam = &vat_main;
3299 vat_json_node_t _node, *node = &_node;
3300 int retval = clib_net_to_host_u32 (mp->retval);
3302 u8 *s = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
3303 vat_json_init_object (node);
3304 vat_json_object_add_string_copy (node, "state", s);
3306 vat_json_print (vam->ofp, node);
3307 vat_json_free (node);
3309 vam->retval = retval;
3310 vam->result_ready = 1;
3315 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3317 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3318 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3319 e->vni = clib_net_to_host_u32 (e->vni);
3323 gpe_fwd_entries_get_reply_t_net_to_host
3324 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3328 mp->count = clib_net_to_host_u32 (mp->count);
3329 for (i = 0; i < mp->count; i++)
3331 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3336 format_gpe_encap_mode (u8 * s, va_list * args)
3338 u32 mode = va_arg (*args, u32);
3343 return format (s, "lisp");
3345 return format (s, "vxlan");
3351 vl_api_gpe_get_encap_mode_reply_t_handler
3352 (vl_api_gpe_get_encap_mode_reply_t * mp)
3354 vat_main_t *vam = &vat_main;
3356 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3357 vam->retval = ntohl (mp->retval);
3358 vam->result_ready = 1;
3362 vl_api_gpe_get_encap_mode_reply_t_handler_json
3363 (vl_api_gpe_get_encap_mode_reply_t * mp)
3365 vat_main_t *vam = &vat_main;
3366 vat_json_node_t node;
3368 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3369 vec_add1 (encap_mode, 0);
3371 vat_json_init_object (&node);
3372 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3374 vec_free (encap_mode);
3375 vat_json_print (vam->ofp, &node);
3376 vat_json_free (&node);
3378 vam->retval = ntohl (mp->retval);
3379 vam->result_ready = 1;
3383 vl_api_gpe_fwd_entry_path_details_t_handler
3384 (vl_api_gpe_fwd_entry_path_details_t * mp)
3386 vat_main_t *vam = &vat_main;
3387 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3389 if (mp->lcl_loc.addr.af)
3390 format_ip_address_fcn = format_ip6_address;
3392 format_ip_address_fcn = format_ip4_address;
3394 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3395 format_ip_address_fcn, &mp->lcl_loc.addr.un,
3396 format_ip_address_fcn, &mp->rmt_loc.addr.un);
3400 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3402 struct in6_addr ip6;
3407 clib_memcpy (&ip6, loc->addr.un.ip6, sizeof (ip6));
3408 vat_json_object_add_ip6 (n, "address", ip6);
3412 clib_memcpy (&ip4, loc->addr.un.ip4, sizeof (ip4));
3413 vat_json_object_add_ip4 (n, "address", ip4);
3415 vat_json_object_add_uint (n, "weight", loc->weight);
3419 vl_api_gpe_fwd_entry_path_details_t_handler_json
3420 (vl_api_gpe_fwd_entry_path_details_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 vat_json_node_t *node = NULL;
3424 vat_json_node_t *loc_node;
3426 if (VAT_JSON_ARRAY != vam->json_tree.type)
3428 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3429 vat_json_init_array (&vam->json_tree);
3431 node = vat_json_array_add (&vam->json_tree);
3432 vat_json_init_object (node);
3434 loc_node = vat_json_object_add (node, "local_locator");
3435 vat_json_init_object (loc_node);
3436 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3438 loc_node = vat_json_object_add (node, "remote_locator");
3439 vat_json_init_object (loc_node);
3440 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3444 vl_api_gpe_fwd_entries_get_reply_t_handler
3445 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3447 vat_main_t *vam = &vat_main;
3449 int retval = clib_net_to_host_u32 (mp->retval);
3450 vl_api_gpe_fwd_entry_t *e;
3455 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3457 for (i = 0; i < mp->count; i++)
3459 e = &mp->entries[i];
3460 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3461 format_lisp_flat_eid, e->leid, format_lisp_flat_eid, e->reid);
3465 vam->retval = retval;
3466 vam->result_ready = 1;
3470 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3471 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3474 vat_main_t *vam = &vat_main;
3475 vat_json_node_t *e = 0, root;
3477 int retval = clib_net_to_host_u32 (mp->retval);
3478 vl_api_gpe_fwd_entry_t *fwd;
3483 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3484 vat_json_init_array (&root);
3486 for (i = 0; i < mp->count; i++)
3488 e = vat_json_array_add (&root);
3489 fwd = &mp->entries[i];
3491 vat_json_init_object (e);
3492 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3493 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3494 vat_json_object_add_int (e, "vni", fwd->vni);
3495 vat_json_object_add_int (e, "action", fwd->action);
3497 s = format (0, "%U", format_lisp_flat_eid, fwd->leid);
3499 vat_json_object_add_string_copy (e, "leid", s);
3502 s = format (0, "%U", format_lisp_flat_eid, fwd->reid);
3504 vat_json_object_add_string_copy (e, "reid", s);
3508 vat_json_print (vam->ofp, &root);
3509 vat_json_free (&root);
3512 vam->retval = retval;
3513 vam->result_ready = 1;
3517 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3518 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3520 vat_main_t *vam = &vat_main;
3522 int retval = clib_net_to_host_u32 (mp->retval);
3523 vl_api_gpe_native_fwd_rpath_t *r;
3528 n = clib_net_to_host_u32 (mp->count);
3530 for (i = 0; i < n; i++)
3532 r = &mp->entries[i];
3533 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3534 clib_net_to_host_u32 (r->fib_index),
3535 clib_net_to_host_u32 (r->nh_sw_if_index),
3536 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3541 vam->retval = retval;
3542 vam->result_ready = 1;
3546 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3547 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3549 vat_main_t *vam = &vat_main;
3550 vat_json_node_t root, *e;
3552 int retval = clib_net_to_host_u32 (mp->retval);
3553 vl_api_gpe_native_fwd_rpath_t *r;
3559 n = clib_net_to_host_u32 (mp->count);
3560 vat_json_init_array (&root);
3562 for (i = 0; i < n; i++)
3564 e = vat_json_array_add (&root);
3565 vat_json_init_object (e);
3566 r = &mp->entries[i];
3569 r->nh_addr.af ? format_ip6_address : format_ip4_address,
3572 vat_json_object_add_string_copy (e, "ip4", s);
3575 vat_json_object_add_uint (e, "fib_index",
3576 clib_net_to_host_u32 (r->fib_index));
3577 vat_json_object_add_uint (e, "nh_sw_if_index",
3578 clib_net_to_host_u32 (r->nh_sw_if_index));
3581 vat_json_print (vam->ofp, &root);
3582 vat_json_free (&root);
3585 vam->retval = retval;
3586 vam->result_ready = 1;
3590 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3591 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3593 vat_main_t *vam = &vat_main;
3595 int retval = clib_net_to_host_u32 (mp->retval);
3600 n = clib_net_to_host_u32 (mp->count);
3602 for (i = 0; i < n; i++)
3603 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3606 vam->retval = retval;
3607 vam->result_ready = 1;
3611 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3612 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3614 vat_main_t *vam = &vat_main;
3615 vat_json_node_t root;
3617 int retval = clib_net_to_host_u32 (mp->retval);
3622 n = clib_net_to_host_u32 (mp->count);
3623 vat_json_init_array (&root);
3625 for (i = 0; i < n; i++)
3626 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3628 vat_json_print (vam->ofp, &root);
3629 vat_json_free (&root);
3632 vam->retval = retval;
3633 vam->result_ready = 1;
3637 vl_api_one_ndp_entries_get_reply_t_handler
3638 (vl_api_one_ndp_entries_get_reply_t * mp)
3640 vat_main_t *vam = &vat_main;
3642 int retval = clib_net_to_host_u32 (mp->retval);
3647 n = clib_net_to_host_u32 (mp->count);
3649 for (i = 0; i < n; i++)
3650 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3651 format_ethernet_address, mp->entries[i].mac);
3654 vam->retval = retval;
3655 vam->result_ready = 1;
3659 vl_api_one_ndp_entries_get_reply_t_handler_json
3660 (vl_api_one_ndp_entries_get_reply_t * mp)
3663 vat_main_t *vam = &vat_main;
3664 vat_json_node_t *e = 0, root;
3666 int retval = clib_net_to_host_u32 (mp->retval);
3667 vl_api_one_ndp_entry_t *arp_entry;
3672 n = clib_net_to_host_u32 (mp->count);
3673 vat_json_init_array (&root);
3675 for (i = 0; i < n; i++)
3677 e = vat_json_array_add (&root);
3678 arp_entry = &mp->entries[i];
3680 vat_json_init_object (e);
3681 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3684 vat_json_object_add_string_copy (e, "mac", s);
3687 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3689 vat_json_object_add_string_copy (e, "ip6", s);
3693 vat_json_print (vam->ofp, &root);
3694 vat_json_free (&root);
3697 vam->retval = retval;
3698 vam->result_ready = 1;
3702 vl_api_one_l2_arp_entries_get_reply_t_handler
3703 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3705 vat_main_t *vam = &vat_main;
3707 int retval = clib_net_to_host_u32 (mp->retval);
3712 n = clib_net_to_host_u32 (mp->count);
3714 for (i = 0; i < n; i++)
3715 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3716 format_ethernet_address, mp->entries[i].mac);
3719 vam->retval = retval;
3720 vam->result_ready = 1;
3724 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3725 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3728 vat_main_t *vam = &vat_main;
3729 vat_json_node_t *e = 0, root;
3731 int retval = clib_net_to_host_u32 (mp->retval);
3732 vl_api_one_l2_arp_entry_t *arp_entry;
3737 n = clib_net_to_host_u32 (mp->count);
3738 vat_json_init_array (&root);
3740 for (i = 0; i < n; i++)
3742 e = vat_json_array_add (&root);
3743 arp_entry = &mp->entries[i];
3745 vat_json_init_object (e);
3746 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3749 vat_json_object_add_string_copy (e, "mac", s);
3752 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3754 vat_json_object_add_string_copy (e, "ip4", s);
3758 vat_json_print (vam->ofp, &root);
3759 vat_json_free (&root);
3762 vam->retval = retval;
3763 vam->result_ready = 1;
3767 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3769 vat_main_t *vam = &vat_main;
3771 int retval = clib_net_to_host_u32 (mp->retval);
3776 n = clib_net_to_host_u32 (mp->count);
3778 for (i = 0; i < n; i++)
3780 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3784 vam->retval = retval;
3785 vam->result_ready = 1;
3789 vl_api_one_ndp_bd_get_reply_t_handler_json
3790 (vl_api_one_ndp_bd_get_reply_t * mp)
3792 vat_main_t *vam = &vat_main;
3793 vat_json_node_t root;
3795 int retval = clib_net_to_host_u32 (mp->retval);
3800 n = clib_net_to_host_u32 (mp->count);
3801 vat_json_init_array (&root);
3803 for (i = 0; i < n; i++)
3805 vat_json_array_add_uint (&root,
3806 clib_net_to_host_u32 (mp->bridge_domains[i]));
3809 vat_json_print (vam->ofp, &root);
3810 vat_json_free (&root);
3813 vam->retval = retval;
3814 vam->result_ready = 1;
3818 vl_api_one_l2_arp_bd_get_reply_t_handler
3819 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3821 vat_main_t *vam = &vat_main;
3823 int retval = clib_net_to_host_u32 (mp->retval);
3828 n = clib_net_to_host_u32 (mp->count);
3830 for (i = 0; i < n; i++)
3832 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3836 vam->retval = retval;
3837 vam->result_ready = 1;
3841 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3842 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3844 vat_main_t *vam = &vat_main;
3845 vat_json_node_t root;
3847 int retval = clib_net_to_host_u32 (mp->retval);
3852 n = clib_net_to_host_u32 (mp->count);
3853 vat_json_init_array (&root);
3855 for (i = 0; i < n; i++)
3857 vat_json_array_add_uint (&root,
3858 clib_net_to_host_u32 (mp->bridge_domains[i]));
3861 vat_json_print (vam->ofp, &root);
3862 vat_json_free (&root);
3865 vam->retval = retval;
3866 vam->result_ready = 1;
3870 vl_api_one_adjacencies_get_reply_t_handler
3871 (vl_api_one_adjacencies_get_reply_t * mp)
3873 vat_main_t *vam = &vat_main;
3875 int retval = clib_net_to_host_u32 (mp->retval);
3876 vl_api_one_adjacency_t *a;
3881 n = clib_net_to_host_u32 (mp->count);
3883 for (i = 0; i < n; i++)
3885 a = &mp->adjacencies[i];
3886 print (vam->ofp, "%U %40U",
3887 format_lisp_flat_eid, a->leid, format_lisp_flat_eid, a->reid);
3891 vam->retval = retval;
3892 vam->result_ready = 1;
3896 vl_api_one_adjacencies_get_reply_t_handler_json
3897 (vl_api_one_adjacencies_get_reply_t * mp)
3900 vat_main_t *vam = &vat_main;
3901 vat_json_node_t *e = 0, root;
3903 int retval = clib_net_to_host_u32 (mp->retval);
3904 vl_api_one_adjacency_t *a;
3909 n = clib_net_to_host_u32 (mp->count);
3910 vat_json_init_array (&root);
3912 for (i = 0; i < n; i++)
3914 e = vat_json_array_add (&root);
3915 a = &mp->adjacencies[i];
3917 vat_json_init_object (e);
3918 s = format (0, "%U", format_lisp_flat_eid, a->leid);
3920 vat_json_object_add_string_copy (e, "leid", s);
3923 s = format (0, "%U", format_lisp_flat_eid, a->reid);
3925 vat_json_object_add_string_copy (e, "reid", s);
3929 vat_json_print (vam->ofp, &root);
3930 vat_json_free (&root);
3933 vam->retval = retval;
3934 vam->result_ready = 1;
3938 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3940 vat_main_t *vam = &vat_main;
3942 print (vam->ofp, "%=20U",
3943 mp->ip_address.af ? format_ip6_address : format_ip4_address,
3948 vl_api_one_map_server_details_t_handler_json
3949 (vl_api_one_map_server_details_t * mp)
3951 vat_main_t *vam = &vat_main;
3952 vat_json_node_t *node = NULL;
3953 struct in6_addr ip6;
3956 if (VAT_JSON_ARRAY != vam->json_tree.type)
3958 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3959 vat_json_init_array (&vam->json_tree);
3961 node = vat_json_array_add (&vam->json_tree);
3963 vat_json_init_object (node);
3964 if (mp->ip_address.af)
3966 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
3967 vat_json_object_add_ip6 (node, "map-server", ip6);
3971 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
3972 vat_json_object_add_ip4 (node, "map-server", ip4);
3977 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3980 vat_main_t *vam = &vat_main;
3982 print (vam->ofp, "%=20U",
3983 mp->ip_address.af ? format_ip6_address : format_ip4_address,
3988 vl_api_one_map_resolver_details_t_handler_json
3989 (vl_api_one_map_resolver_details_t * mp)
3991 vat_main_t *vam = &vat_main;
3992 vat_json_node_t *node = NULL;
3993 struct in6_addr ip6;
3996 if (VAT_JSON_ARRAY != vam->json_tree.type)
3998 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3999 vat_json_init_array (&vam->json_tree);
4001 node = vat_json_array_add (&vam->json_tree);
4003 vat_json_init_object (node);
4004 if (mp->ip_address.af)
4006 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4007 vat_json_object_add_ip6 (node, "map resolver", ip6);
4011 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4012 vat_json_object_add_ip4 (node, "map resolver", ip4);
4017 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4019 vat_main_t *vam = &vat_main;
4020 i32 retval = ntohl (mp->retval);
4024 print (vam->ofp, "feature: %s\ngpe: %s",
4025 mp->feature_status ? "enabled" : "disabled",
4026 mp->gpe_status ? "enabled" : "disabled");
4029 vam->retval = retval;
4030 vam->result_ready = 1;
4034 vl_api_show_one_status_reply_t_handler_json
4035 (vl_api_show_one_status_reply_t * mp)
4037 vat_main_t *vam = &vat_main;
4038 vat_json_node_t node;
4039 u8 *gpe_status = NULL;
4040 u8 *feature_status = NULL;
4042 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4043 feature_status = format (0, "%s",
4044 mp->feature_status ? "enabled" : "disabled");
4045 vec_add1 (gpe_status, 0);
4046 vec_add1 (feature_status, 0);
4048 vat_json_init_object (&node);
4049 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4050 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4052 vec_free (gpe_status);
4053 vec_free (feature_status);
4055 vat_json_print (vam->ofp, &node);
4056 vat_json_free (&node);
4058 vam->retval = ntohl (mp->retval);
4059 vam->result_ready = 1;
4063 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4064 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4066 vat_main_t *vam = &vat_main;
4067 i32 retval = ntohl (mp->retval);
4071 print (vam->ofp, "%=20s", mp->locator_set_name);
4074 vam->retval = retval;
4075 vam->result_ready = 1;
4079 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4080 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4082 vat_main_t *vam = &vat_main;
4083 vat_json_node_t *node = NULL;
4085 if (VAT_JSON_ARRAY != vam->json_tree.type)
4087 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4088 vat_json_init_array (&vam->json_tree);
4090 node = vat_json_array_add (&vam->json_tree);
4092 vat_json_init_object (node);
4093 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4095 vat_json_print (vam->ofp, node);
4096 vat_json_free (node);
4098 vam->retval = ntohl (mp->retval);
4099 vam->result_ready = 1;
4103 format_lisp_map_request_mode (u8 * s, va_list * args)
4105 u32 mode = va_arg (*args, u32);
4110 return format (0, "dst-only");
4112 return format (0, "src-dst");
4118 vl_api_show_one_map_request_mode_reply_t_handler
4119 (vl_api_show_one_map_request_mode_reply_t * mp)
4121 vat_main_t *vam = &vat_main;
4122 i32 retval = ntohl (mp->retval);
4126 u32 mode = mp->mode;
4127 print (vam->ofp, "map_request_mode: %U",
4128 format_lisp_map_request_mode, mode);
4131 vam->retval = retval;
4132 vam->result_ready = 1;
4136 vl_api_show_one_map_request_mode_reply_t_handler_json
4137 (vl_api_show_one_map_request_mode_reply_t * mp)
4139 vat_main_t *vam = &vat_main;
4140 vat_json_node_t node;
4145 s = format (0, "%U", format_lisp_map_request_mode, mode);
4148 vat_json_init_object (&node);
4149 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4150 vat_json_print (vam->ofp, &node);
4151 vat_json_free (&node);
4154 vam->retval = ntohl (mp->retval);
4155 vam->result_ready = 1;
4159 vl_api_one_show_xtr_mode_reply_t_handler
4160 (vl_api_one_show_xtr_mode_reply_t * mp)
4162 vat_main_t *vam = &vat_main;
4163 i32 retval = ntohl (mp->retval);
4167 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4170 vam->retval = retval;
4171 vam->result_ready = 1;
4175 vl_api_one_show_xtr_mode_reply_t_handler_json
4176 (vl_api_one_show_xtr_mode_reply_t * mp)
4178 vat_main_t *vam = &vat_main;
4179 vat_json_node_t node;
4182 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4183 vec_add1 (status, 0);
4185 vat_json_init_object (&node);
4186 vat_json_object_add_string_copy (&node, "status", status);
4190 vat_json_print (vam->ofp, &node);
4191 vat_json_free (&node);
4193 vam->retval = ntohl (mp->retval);
4194 vam->result_ready = 1;
4198 vl_api_one_show_pitr_mode_reply_t_handler
4199 (vl_api_one_show_pitr_mode_reply_t * mp)
4201 vat_main_t *vam = &vat_main;
4202 i32 retval = ntohl (mp->retval);
4206 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4209 vam->retval = retval;
4210 vam->result_ready = 1;
4214 vl_api_one_show_pitr_mode_reply_t_handler_json
4215 (vl_api_one_show_pitr_mode_reply_t * mp)
4217 vat_main_t *vam = &vat_main;
4218 vat_json_node_t node;
4221 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4222 vec_add1 (status, 0);
4224 vat_json_init_object (&node);
4225 vat_json_object_add_string_copy (&node, "status", status);
4229 vat_json_print (vam->ofp, &node);
4230 vat_json_free (&node);
4232 vam->retval = ntohl (mp->retval);
4233 vam->result_ready = 1;
4237 vl_api_one_show_petr_mode_reply_t_handler
4238 (vl_api_one_show_petr_mode_reply_t * mp)
4240 vat_main_t *vam = &vat_main;
4241 i32 retval = ntohl (mp->retval);
4245 print (vam->ofp, "%s\n", mp->is_enable ? "enabled" : "disabled");
4248 vam->retval = retval;
4249 vam->result_ready = 1;
4253 vl_api_one_show_petr_mode_reply_t_handler_json
4254 (vl_api_one_show_petr_mode_reply_t * mp)
4256 vat_main_t *vam = &vat_main;
4257 vat_json_node_t node;
4260 status = format (0, "%s", mp->is_enable ? "enabled" : "disabled");
4261 vec_add1 (status, 0);
4263 vat_json_init_object (&node);
4264 vat_json_object_add_string_copy (&node, "status", status);
4268 vat_json_print (vam->ofp, &node);
4269 vat_json_free (&node);
4271 vam->retval = ntohl (mp->retval);
4272 vam->result_ready = 1;
4276 vl_api_show_one_use_petr_reply_t_handler
4277 (vl_api_show_one_use_petr_reply_t * mp)
4279 vat_main_t *vam = &vat_main;
4280 i32 retval = ntohl (mp->retval);
4284 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4287 print (vam->ofp, "Proxy-ETR address; %U",
4288 mp->ip_address.af ? format_ip6_address : format_ip4_address,
4293 vam->retval = retval;
4294 vam->result_ready = 1;
4298 vl_api_show_one_use_petr_reply_t_handler_json
4299 (vl_api_show_one_use_petr_reply_t * mp)
4301 vat_main_t *vam = &vat_main;
4302 vat_json_node_t node;
4305 struct in6_addr ip6;
4307 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4308 vec_add1 (status, 0);
4310 vat_json_init_object (&node);
4311 vat_json_object_add_string_copy (&node, "status", status);
4314 if (mp->ip_address.af)
4316 clib_memcpy (&ip6, mp->ip_address.un.ip6, sizeof (ip6));
4317 vat_json_object_add_ip6 (&node, "address", ip6);
4321 clib_memcpy (&ip4, mp->ip_address.un.ip4, sizeof (ip4));
4322 vat_json_object_add_ip4 (&node, "address", ip4);
4328 vat_json_print (vam->ofp, &node);
4329 vat_json_free (&node);
4331 vam->retval = ntohl (mp->retval);
4332 vam->result_ready = 1;
4336 vl_api_show_one_nsh_mapping_reply_t_handler
4337 (vl_api_show_one_nsh_mapping_reply_t * mp)
4339 vat_main_t *vam = &vat_main;
4340 i32 retval = ntohl (mp->retval);
4344 print (vam->ofp, "%-20s%-16s",
4345 mp->is_set ? "set" : "not-set",
4346 mp->is_set ? (char *) mp->locator_set_name : "");
4349 vam->retval = retval;
4350 vam->result_ready = 1;
4354 vl_api_show_one_nsh_mapping_reply_t_handler_json
4355 (vl_api_show_one_nsh_mapping_reply_t * mp)
4357 vat_main_t *vam = &vat_main;
4358 vat_json_node_t node;
4361 status = format (0, "%s", mp->is_set ? "yes" : "no");
4362 vec_add1 (status, 0);
4364 vat_json_init_object (&node);
4365 vat_json_object_add_string_copy (&node, "is_set", status);
4368 vat_json_object_add_string_copy (&node, "locator_set",
4369 mp->locator_set_name);
4374 vat_json_print (vam->ofp, &node);
4375 vat_json_free (&node);
4377 vam->retval = ntohl (mp->retval);
4378 vam->result_ready = 1;
4382 vl_api_show_one_map_register_ttl_reply_t_handler
4383 (vl_api_show_one_map_register_ttl_reply_t * mp)
4385 vat_main_t *vam = &vat_main;
4386 i32 retval = ntohl (mp->retval);
4388 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4392 print (vam->ofp, "ttl: %u", mp->ttl);
4395 vam->retval = retval;
4396 vam->result_ready = 1;
4400 vl_api_show_one_map_register_ttl_reply_t_handler_json
4401 (vl_api_show_one_map_register_ttl_reply_t * mp)
4403 vat_main_t *vam = &vat_main;
4404 vat_json_node_t node;
4406 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4407 vat_json_init_object (&node);
4408 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4410 vat_json_print (vam->ofp, &node);
4411 vat_json_free (&node);
4413 vam->retval = ntohl (mp->retval);
4414 vam->result_ready = 1;
4418 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4420 vat_main_t *vam = &vat_main;
4421 i32 retval = ntohl (mp->retval);
4425 print (vam->ofp, "%-20s%-16s",
4426 mp->status ? "enabled" : "disabled",
4427 mp->status ? (char *) mp->locator_set_name : "");
4430 vam->retval = retval;
4431 vam->result_ready = 1;
4435 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4437 vat_main_t *vam = &vat_main;
4438 vat_json_node_t node;
4441 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4442 vec_add1 (status, 0);
4444 vat_json_init_object (&node);
4445 vat_json_object_add_string_copy (&node, "status", status);
4448 vat_json_object_add_string_copy (&node, "locator_set",
4449 mp->locator_set_name);
4454 vat_json_print (vam->ofp, &node);
4455 vat_json_free (&node);
4457 vam->retval = ntohl (mp->retval);
4458 vam->result_ready = 1;
4462 format_policer_type (u8 * s, va_list * va)
4464 u32 i = va_arg (*va, u32);
4466 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4467 s = format (s, "1r2c");
4468 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4469 s = format (s, "1r3c");
4470 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4471 s = format (s, "2r3c-2698");
4472 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4473 s = format (s, "2r3c-4115");
4474 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4475 s = format (s, "2r3c-mef5cf1");
4477 s = format (s, "ILLEGAL");
4482 format_policer_rate_type (u8 * s, va_list * va)
4484 u32 i = va_arg (*va, u32);
4486 if (i == SSE2_QOS_RATE_KBPS)
4487 s = format (s, "kbps");
4488 else if (i == SSE2_QOS_RATE_PPS)
4489 s = format (s, "pps");
4491 s = format (s, "ILLEGAL");
4496 format_policer_round_type (u8 * s, va_list * va)
4498 u32 i = va_arg (*va, u32);
4500 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4501 s = format (s, "closest");
4502 else if (i == SSE2_QOS_ROUND_TO_UP)
4503 s = format (s, "up");
4504 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4505 s = format (s, "down");
4507 s = format (s, "ILLEGAL");
4512 format_policer_action_type (u8 * s, va_list * va)
4514 u32 i = va_arg (*va, u32);
4516 if (i == SSE2_QOS_ACTION_DROP)
4517 s = format (s, "drop");
4518 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4519 s = format (s, "transmit");
4520 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4521 s = format (s, "mark-and-transmit");
4523 s = format (s, "ILLEGAL");
4528 format_dscp (u8 * s, va_list * va)
4530 u32 i = va_arg (*va, u32);
4535 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4539 return format (s, "ILLEGAL");
4541 s = format (s, "%s", t);
4546 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4548 vat_main_t *vam = &vat_main;
4549 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4551 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4552 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4554 conform_dscp_str = format (0, "");
4556 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4557 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4559 exceed_dscp_str = format (0, "");
4561 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4562 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4564 violate_dscp_str = format (0, "");
4566 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4567 "rate type %U, round type %U, %s rate, %s color-aware, "
4568 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4569 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4570 "conform action %U%s, exceed action %U%s, violate action %U%s",
4572 format_policer_type, mp->type,
4575 clib_net_to_host_u64 (mp->cb),
4576 clib_net_to_host_u64 (mp->eb),
4577 format_policer_rate_type, mp->rate_type,
4578 format_policer_round_type, mp->round_type,
4579 mp->single_rate ? "single" : "dual",
4580 mp->color_aware ? "is" : "not",
4581 ntohl (mp->cir_tokens_per_period),
4582 ntohl (mp->pir_tokens_per_period),
4584 ntohl (mp->current_limit),
4585 ntohl (mp->current_bucket),
4586 ntohl (mp->extended_limit),
4587 ntohl (mp->extended_bucket),
4588 clib_net_to_host_u64 (mp->last_update_time),
4589 format_policer_action_type, mp->conform_action.type,
4591 format_policer_action_type, mp->exceed_action.type,
4593 format_policer_action_type, mp->violate_action.type,
4596 vec_free (conform_dscp_str);
4597 vec_free (exceed_dscp_str);
4598 vec_free (violate_dscp_str);
4601 static void vl_api_policer_details_t_handler_json
4602 (vl_api_policer_details_t * mp)
4604 vat_main_t *vam = &vat_main;
4605 vat_json_node_t *node;
4606 u8 *rate_type_str, *round_type_str, *type_str;
4607 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4609 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4611 format (0, "%U", format_policer_round_type, mp->round_type);
4612 type_str = format (0, "%U", format_policer_type, mp->type);
4613 conform_action_str = format (0, "%U", format_policer_action_type,
4614 mp->conform_action.type);
4615 exceed_action_str = format (0, "%U", format_policer_action_type,
4616 mp->exceed_action.type);
4617 violate_action_str = format (0, "%U", format_policer_action_type,
4618 mp->violate_action.type);
4620 if (VAT_JSON_ARRAY != vam->json_tree.type)
4622 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4623 vat_json_init_array (&vam->json_tree);
4625 node = vat_json_array_add (&vam->json_tree);
4627 vat_json_init_object (node);
4628 vat_json_object_add_string_copy (node, "name", mp->name);
4629 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4630 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4631 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4632 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4633 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4634 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4635 vat_json_object_add_string_copy (node, "type", type_str);
4636 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4637 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4638 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4639 vat_json_object_add_uint (node, "cir_tokens_per_period",
4640 ntohl (mp->cir_tokens_per_period));
4641 vat_json_object_add_uint (node, "eir_tokens_per_period",
4642 ntohl (mp->pir_tokens_per_period));
4643 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4644 vat_json_object_add_uint (node, "current_bucket",
4645 ntohl (mp->current_bucket));
4646 vat_json_object_add_uint (node, "extended_limit",
4647 ntohl (mp->extended_limit));
4648 vat_json_object_add_uint (node, "extended_bucket",
4649 ntohl (mp->extended_bucket));
4650 vat_json_object_add_uint (node, "last_update_time",
4651 ntohl (mp->last_update_time));
4652 vat_json_object_add_string_copy (node, "conform_action",
4653 conform_action_str);
4654 if (mp->conform_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4656 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_action.dscp);
4657 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4658 vec_free (dscp_str);
4660 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4661 if (mp->exceed_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4663 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_action.dscp);
4664 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4665 vec_free (dscp_str);
4667 vat_json_object_add_string_copy (node, "violate_action",
4668 violate_action_str);
4669 if (mp->violate_action.type == SSE2_QOS_ACTION_API_MARK_AND_TRANSMIT)
4671 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_action.dscp);
4672 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4673 vec_free (dscp_str);
4676 vec_free (rate_type_str);
4677 vec_free (round_type_str);
4678 vec_free (type_str);
4679 vec_free (conform_action_str);
4680 vec_free (exceed_action_str);
4681 vec_free (violate_action_str);
4685 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4688 vat_main_t *vam = &vat_main;
4689 int i, count = ntohl (mp->count);
4692 print (vam->ofp, "classify table ids (%d) : ", count);
4693 for (i = 0; i < count; i++)
4695 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4696 print (vam->ofp, (i < count - 1) ? "," : "");
4698 vam->retval = ntohl (mp->retval);
4699 vam->result_ready = 1;
4703 vl_api_classify_table_ids_reply_t_handler_json
4704 (vl_api_classify_table_ids_reply_t * mp)
4706 vat_main_t *vam = &vat_main;
4707 int i, count = ntohl (mp->count);
4711 vat_json_node_t node;
4713 vat_json_init_object (&node);
4714 for (i = 0; i < count; i++)
4716 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4718 vat_json_print (vam->ofp, &node);
4719 vat_json_free (&node);
4721 vam->retval = ntohl (mp->retval);
4722 vam->result_ready = 1;
4726 vl_api_classify_table_by_interface_reply_t_handler
4727 (vl_api_classify_table_by_interface_reply_t * mp)
4729 vat_main_t *vam = &vat_main;
4732 table_id = ntohl (mp->l2_table_id);
4734 print (vam->ofp, "l2 table id : %d", table_id);
4736 print (vam->ofp, "l2 table id : No input ACL tables configured");
4737 table_id = ntohl (mp->ip4_table_id);
4739 print (vam->ofp, "ip4 table id : %d", table_id);
4741 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4742 table_id = ntohl (mp->ip6_table_id);
4744 print (vam->ofp, "ip6 table id : %d", table_id);
4746 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4747 vam->retval = ntohl (mp->retval);
4748 vam->result_ready = 1;
4752 vl_api_classify_table_by_interface_reply_t_handler_json
4753 (vl_api_classify_table_by_interface_reply_t * mp)
4755 vat_main_t *vam = &vat_main;
4756 vat_json_node_t node;
4758 vat_json_init_object (&node);
4760 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4761 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4762 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4764 vat_json_print (vam->ofp, &node);
4765 vat_json_free (&node);
4767 vam->retval = ntohl (mp->retval);
4768 vam->result_ready = 1;
4771 static void vl_api_policer_add_del_reply_t_handler
4772 (vl_api_policer_add_del_reply_t * mp)
4774 vat_main_t *vam = &vat_main;
4775 i32 retval = ntohl (mp->retval);
4776 if (vam->async_mode)
4778 vam->async_errors += (retval < 0);
4782 vam->retval = retval;
4783 vam->result_ready = 1;
4784 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4786 * Note: this is just barely thread-safe, depends on
4787 * the main thread spinning waiting for an answer...
4789 errmsg ("policer index %d", ntohl (mp->policer_index));
4793 static void vl_api_policer_add_del_reply_t_handler_json
4794 (vl_api_policer_add_del_reply_t * mp)
4796 vat_main_t *vam = &vat_main;
4797 vat_json_node_t node;
4799 vat_json_init_object (&node);
4800 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4801 vat_json_object_add_uint (&node, "policer_index",
4802 ntohl (mp->policer_index));
4804 vat_json_print (vam->ofp, &node);
4805 vat_json_free (&node);
4807 vam->retval = ntohl (mp->retval);
4808 vam->result_ready = 1;
4811 /* Format hex dump. */
4813 format_hex_bytes (u8 * s, va_list * va)
4815 u8 *bytes = va_arg (*va, u8 *);
4816 int n_bytes = va_arg (*va, int);
4819 /* Print short or long form depending on byte count. */
4820 uword short_form = n_bytes <= 32;
4821 u32 indent = format_get_indent (s);
4826 for (i = 0; i < n_bytes; i++)
4828 if (!short_form && (i % 32) == 0)
4829 s = format (s, "%08x: ", i);
4830 s = format (s, "%02x", bytes[i]);
4831 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4832 s = format (s, "\n%U", format_white_space, indent);
4839 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4842 vat_main_t *vam = &vat_main;
4843 i32 retval = ntohl (mp->retval);
4846 print (vam->ofp, "classify table info :");
4847 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4848 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4849 ntohl (mp->miss_next_index));
4850 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4851 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4852 ntohl (mp->match_n_vectors));
4853 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4854 ntohl (mp->mask_length));
4856 vam->retval = retval;
4857 vam->result_ready = 1;
4861 vl_api_classify_table_info_reply_t_handler_json
4862 (vl_api_classify_table_info_reply_t * mp)
4864 vat_main_t *vam = &vat_main;
4865 vat_json_node_t node;
4867 i32 retval = ntohl (mp->retval);
4870 vat_json_init_object (&node);
4872 vat_json_object_add_int (&node, "sessions",
4873 ntohl (mp->active_sessions));
4874 vat_json_object_add_int (&node, "nexttbl",
4875 ntohl (mp->next_table_index));
4876 vat_json_object_add_int (&node, "nextnode",
4877 ntohl (mp->miss_next_index));
4878 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4879 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4880 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4881 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4882 ntohl (mp->mask_length), 0);
4883 vat_json_object_add_string_copy (&node, "mask", s);
4885 vat_json_print (vam->ofp, &node);
4886 vat_json_free (&node);
4888 vam->retval = ntohl (mp->retval);
4889 vam->result_ready = 1;
4893 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4896 vat_main_t *vam = &vat_main;
4898 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4899 ntohl (mp->hit_next_index), ntohl (mp->advance),
4900 ntohl (mp->opaque_index));
4901 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4902 ntohl (mp->match_length));
4906 vl_api_classify_session_details_t_handler_json
4907 (vl_api_classify_session_details_t * mp)
4909 vat_main_t *vam = &vat_main;
4910 vat_json_node_t *node = NULL;
4912 if (VAT_JSON_ARRAY != vam->json_tree.type)
4914 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4915 vat_json_init_array (&vam->json_tree);
4917 node = vat_json_array_add (&vam->json_tree);
4919 vat_json_init_object (node);
4920 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4921 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4922 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4924 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4926 vat_json_object_add_string_copy (node, "match", s);
4929 static void vl_api_pg_create_interface_reply_t_handler
4930 (vl_api_pg_create_interface_reply_t * mp)
4932 vat_main_t *vam = &vat_main;
4934 vam->retval = ntohl (mp->retval);
4935 vam->result_ready = 1;
4938 static void vl_api_pg_create_interface_reply_t_handler_json
4939 (vl_api_pg_create_interface_reply_t * mp)
4941 vat_main_t *vam = &vat_main;
4942 vat_json_node_t node;
4944 i32 retval = ntohl (mp->retval);
4947 vat_json_init_object (&node);
4949 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4951 vat_json_print (vam->ofp, &node);
4952 vat_json_free (&node);
4954 vam->retval = ntohl (mp->retval);
4955 vam->result_ready = 1;
4958 static void vl_api_policer_classify_details_t_handler
4959 (vl_api_policer_classify_details_t * mp)
4961 vat_main_t *vam = &vat_main;
4963 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4964 ntohl (mp->table_index));
4967 static void vl_api_policer_classify_details_t_handler_json
4968 (vl_api_policer_classify_details_t * mp)
4970 vat_main_t *vam = &vat_main;
4971 vat_json_node_t *node;
4973 if (VAT_JSON_ARRAY != vam->json_tree.type)
4975 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4976 vat_json_init_array (&vam->json_tree);
4978 node = vat_json_array_add (&vam->json_tree);
4980 vat_json_init_object (node);
4981 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4982 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4985 static void vl_api_flow_classify_details_t_handler
4986 (vl_api_flow_classify_details_t * mp)
4988 vat_main_t *vam = &vat_main;
4990 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4991 ntohl (mp->table_index));
4994 static void vl_api_flow_classify_details_t_handler_json
4995 (vl_api_flow_classify_details_t * mp)
4997 vat_main_t *vam = &vat_main;
4998 vat_json_node_t *node;
5000 if (VAT_JSON_ARRAY != vam->json_tree.type)
5002 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5003 vat_json_init_array (&vam->json_tree);
5005 node = vat_json_array_add (&vam->json_tree);
5007 vat_json_init_object (node);
5008 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5009 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5012 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5013 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5014 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5015 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5016 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5017 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5018 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5019 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5020 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5021 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5024 * Generate boilerplate reply handlers, which
5025 * dig the return value out of the xxx_reply_t API message,
5026 * stick it into vam->retval, and set vam->result_ready
5028 * Could also do this by pointing N message decode slots at
5029 * a single function, but that could break in subtle ways.
5032 #define foreach_standard_reply_retval_handler \
5033 _(sw_interface_set_flags_reply) \
5034 _(sw_interface_add_del_address_reply) \
5035 _(sw_interface_set_rx_mode_reply) \
5036 _(sw_interface_set_rx_placement_reply) \
5037 _(sw_interface_set_table_reply) \
5038 _(sw_interface_set_mpls_enable_reply) \
5039 _(sw_interface_set_vpath_reply) \
5040 _(sw_interface_set_vxlan_bypass_reply) \
5041 _(sw_interface_set_geneve_bypass_reply) \
5042 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5043 _(sw_interface_set_l2_bridge_reply) \
5044 _(sw_interface_set_bond_weight_reply) \
5045 _(bridge_domain_add_del_reply) \
5046 _(sw_interface_set_l2_xconnect_reply) \
5047 _(l2fib_add_del_reply) \
5048 _(l2fib_flush_int_reply) \
5049 _(l2fib_flush_bd_reply) \
5050 _(ip_route_add_del_reply) \
5051 _(ip_table_add_del_reply) \
5052 _(ip_table_replace_begin_reply) \
5053 _(ip_table_flush_reply) \
5054 _(ip_table_replace_end_reply) \
5055 _(ip_mroute_add_del_reply) \
5056 _(mpls_route_add_del_reply) \
5057 _(mpls_table_add_del_reply) \
5058 _(mpls_ip_bind_unbind_reply) \
5059 _(bier_route_add_del_reply) \
5060 _(bier_table_add_del_reply) \
5061 _(sw_interface_set_unnumbered_reply) \
5062 _(set_ip_flow_hash_reply) \
5063 _(sw_interface_ip6_enable_disable_reply) \
5064 _(l2_patch_add_del_reply) \
5065 _(sr_mpls_policy_add_reply) \
5066 _(sr_mpls_policy_mod_reply) \
5067 _(sr_mpls_policy_del_reply) \
5068 _(sr_policy_add_reply) \
5069 _(sr_policy_mod_reply) \
5070 _(sr_policy_del_reply) \
5071 _(sr_localsid_add_del_reply) \
5072 _(sr_steering_add_del_reply) \
5073 _(classify_add_del_session_reply) \
5074 _(classify_set_interface_ip_table_reply) \
5075 _(classify_set_interface_l2_tables_reply) \
5076 _(l2tpv3_set_tunnel_cookies_reply) \
5077 _(l2tpv3_interface_enable_disable_reply) \
5078 _(l2tpv3_set_lookup_key_reply) \
5079 _(l2_fib_clear_table_reply) \
5080 _(l2_interface_efp_filter_reply) \
5081 _(l2_interface_vlan_tag_rewrite_reply) \
5082 _(modify_vhost_user_if_reply) \
5083 _(delete_vhost_user_if_reply) \
5084 _(want_l2_macs_events_reply) \
5085 _(input_acl_set_interface_reply) \
5086 _(ipsec_spd_add_del_reply) \
5087 _(ipsec_interface_add_del_spd_reply) \
5088 _(ipsec_spd_entry_add_del_reply) \
5089 _(ipsec_sad_entry_add_del_reply) \
5090 _(ipsec_tunnel_if_add_del_reply) \
5091 _(ipsec_tunnel_if_set_sa_reply) \
5092 _(delete_loopback_reply) \
5093 _(bd_ip_mac_add_del_reply) \
5094 _(bd_ip_mac_flush_reply) \
5095 _(want_interface_events_reply) \
5096 _(cop_interface_enable_disable_reply) \
5097 _(cop_whitelist_enable_disable_reply) \
5098 _(sw_interface_clear_stats_reply) \
5099 _(ioam_enable_reply) \
5100 _(ioam_disable_reply) \
5101 _(one_add_del_locator_reply) \
5102 _(one_add_del_local_eid_reply) \
5103 _(one_add_del_remote_mapping_reply) \
5104 _(one_add_del_adjacency_reply) \
5105 _(one_add_del_map_resolver_reply) \
5106 _(one_add_del_map_server_reply) \
5107 _(one_enable_disable_reply) \
5108 _(one_rloc_probe_enable_disable_reply) \
5109 _(one_map_register_enable_disable_reply) \
5110 _(one_map_register_set_ttl_reply) \
5111 _(one_set_transport_protocol_reply) \
5112 _(one_map_register_fallback_threshold_reply) \
5113 _(one_pitr_set_locator_set_reply) \
5114 _(one_map_request_mode_reply) \
5115 _(one_add_del_map_request_itr_rlocs_reply) \
5116 _(one_eid_table_add_del_map_reply) \
5117 _(one_use_petr_reply) \
5118 _(one_stats_enable_disable_reply) \
5119 _(one_add_del_l2_arp_entry_reply) \
5120 _(one_add_del_ndp_entry_reply) \
5121 _(one_stats_flush_reply) \
5122 _(one_enable_disable_xtr_mode_reply) \
5123 _(one_enable_disable_pitr_mode_reply) \
5124 _(one_enable_disable_petr_mode_reply) \
5125 _(gpe_enable_disable_reply) \
5126 _(gpe_set_encap_mode_reply) \
5127 _(gpe_add_del_iface_reply) \
5128 _(gpe_add_del_native_fwd_rpath_reply) \
5129 _(af_packet_delete_reply) \
5130 _(policer_classify_set_interface_reply) \
5131 _(set_ipfix_exporter_reply) \
5132 _(set_ipfix_classify_stream_reply) \
5133 _(ipfix_classify_table_add_del_reply) \
5134 _(flow_classify_set_interface_reply) \
5135 _(sw_interface_span_enable_disable_reply) \
5136 _(pg_capture_reply) \
5137 _(pg_enable_disable_reply) \
5138 _(ip_source_and_port_range_check_add_del_reply) \
5139 _(ip_source_and_port_range_check_interface_add_del_reply)\
5140 _(delete_subif_reply) \
5141 _(l2_interface_pbb_tag_rewrite_reply) \
5143 _(feature_enable_disable_reply) \
5144 _(feature_gso_enable_disable_reply) \
5145 _(sw_interface_tag_add_del_reply) \
5146 _(sw_interface_add_del_mac_address_reply) \
5147 _(hw_interface_set_mtu_reply) \
5148 _(p2p_ethernet_add_reply) \
5149 _(p2p_ethernet_del_reply) \
5150 _(lldp_config_reply) \
5151 _(sw_interface_set_lldp_reply) \
5152 _(tcp_configure_src_addresses_reply) \
5153 _(session_rule_add_del_reply) \
5154 _(ip_container_proxy_add_del_reply) \
5155 _(output_acl_set_interface_reply) \
5156 _(qos_record_enable_disable_reply)
5159 static void vl_api_##n##_t_handler \
5160 (vl_api_##n##_t * mp) \
5162 vat_main_t * vam = &vat_main; \
5163 i32 retval = ntohl(mp->retval); \
5164 if (vam->async_mode) { \
5165 vam->async_errors += (retval < 0); \
5167 vam->retval = retval; \
5168 vam->result_ready = 1; \
5171 foreach_standard_reply_retval_handler;
5175 static void vl_api_##n##_t_handler_json \
5176 (vl_api_##n##_t * mp) \
5178 vat_main_t * vam = &vat_main; \
5179 vat_json_node_t node; \
5180 vat_json_init_object(&node); \
5181 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5182 vat_json_print(vam->ofp, &node); \
5183 vam->retval = ntohl(mp->retval); \
5184 vam->result_ready = 1; \
5186 foreach_standard_reply_retval_handler;
5190 * Table of message reply handlers, must include boilerplate handlers
5194 #define foreach_vpe_api_reply_msg \
5195 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5196 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5197 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5198 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5199 _(CONTROL_PING_REPLY, control_ping_reply) \
5200 _(CLI_REPLY, cli_reply) \
5201 _(CLI_INBAND_REPLY, cli_inband_reply) \
5202 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5203 sw_interface_add_del_address_reply) \
5204 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5205 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5206 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5207 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5208 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5209 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5210 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5211 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5212 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5213 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5214 sw_interface_set_l2_xconnect_reply) \
5215 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5216 sw_interface_set_l2_bridge_reply) \
5217 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5218 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5219 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5220 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5221 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5222 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5223 _(L2_FLAGS_REPLY, l2_flags_reply) \
5224 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5225 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5226 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5227 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5228 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5229 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5230 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5231 _(BOND_CREATE_REPLY, bond_create_reply) \
5232 _(BOND_DELETE_REPLY, bond_delete_reply) \
5233 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5234 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5235 _(SW_INTERFACE_SET_BOND_WEIGHT_REPLY, sw_interface_set_bond_weight_reply) \
5236 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5237 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5238 _(IP_ROUTE_ADD_DEL_REPLY, ip_route_add_del_reply) \
5239 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5240 _(IP_TABLE_REPLACE_BEGIN_REPLY, ip_table_replace_begin_reply) \
5241 _(IP_TABLE_FLUSH_REPLY, ip_table_flush_reply) \
5242 _(IP_TABLE_REPLACE_END_REPLY, ip_table_replace_end_reply) \
5243 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5244 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5245 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5246 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5247 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5248 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5249 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5250 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5251 sw_interface_set_unnumbered_reply) \
5252 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5253 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5254 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5255 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5256 sw_interface_ip6_enable_disable_reply) \
5257 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5258 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5259 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5260 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5261 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5262 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5263 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5264 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5265 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5266 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5267 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5268 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5269 classify_set_interface_ip_table_reply) \
5270 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5271 classify_set_interface_l2_tables_reply) \
5272 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5273 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5274 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5275 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5276 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5277 l2tpv3_interface_enable_disable_reply) \
5278 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5279 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5280 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5281 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5282 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5283 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5284 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5285 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5286 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5287 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5288 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5289 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5290 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5291 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5292 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5293 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5294 _(SHOW_VERSION_REPLY, show_version_reply) \
5295 _(SHOW_THREADS_REPLY, show_threads_reply) \
5296 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5297 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5298 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5299 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5300 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5301 _(L2_MACS_EVENT, l2_macs_event) \
5302 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5303 _(IP_ADDRESS_DETAILS, ip_address_details) \
5304 _(IP_DETAILS, ip_details) \
5305 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5306 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5307 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5308 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5309 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5310 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5311 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5312 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5313 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5314 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5315 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5316 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5317 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5318 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5319 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5320 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5321 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5322 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5323 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5324 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5325 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5326 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5327 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5328 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5329 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5330 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5331 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5332 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5333 one_map_register_enable_disable_reply) \
5334 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5335 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5336 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5337 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5338 one_map_register_fallback_threshold_reply) \
5339 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5340 one_rloc_probe_enable_disable_reply) \
5341 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5342 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5343 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5344 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5345 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5346 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5347 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5348 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5349 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5350 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5351 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5352 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5353 _(ONE_STATS_DETAILS, one_stats_details) \
5354 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5355 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5356 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5357 show_one_stats_enable_disable_reply) \
5358 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5359 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5360 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5361 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5362 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5363 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5364 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5365 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5366 one_enable_disable_pitr_mode_reply) \
5367 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5368 one_enable_disable_petr_mode_reply) \
5369 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5370 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5371 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5372 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5373 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5374 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5375 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5376 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5377 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5378 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5379 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5380 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5381 gpe_add_del_native_fwd_rpath_reply) \
5382 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5383 gpe_fwd_entry_path_details) \
5384 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5385 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5386 one_add_del_map_request_itr_rlocs_reply) \
5387 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5388 one_get_map_request_itr_rlocs_reply) \
5389 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5390 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5391 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5392 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5393 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5394 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5395 show_one_map_register_state_reply) \
5396 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5397 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5398 show_one_map_register_fallback_threshold_reply) \
5399 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5400 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5401 _(AF_PACKET_DETAILS, af_packet_details) \
5402 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5403 _(POLICER_DETAILS, policer_details) \
5404 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5405 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5406 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5407 _(MPLS_TABLE_DETAILS, mpls_table_details) \
5408 _(MPLS_ROUTE_DETAILS, mpls_route_details) \
5409 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5410 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5411 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5412 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5413 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5414 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5415 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5416 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5417 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5418 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5419 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5420 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5421 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5422 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5423 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5424 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5425 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5426 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5427 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5428 ip_source_and_port_range_check_add_del_reply) \
5429 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5430 ip_source_and_port_range_check_interface_add_del_reply) \
5431 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5432 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5433 _(SET_PUNT_REPLY, set_punt_reply) \
5434 _(IP_TABLE_DETAILS, ip_table_details) \
5435 _(IP_ROUTE_DETAILS, ip_route_details) \
5436 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5437 _(FEATURE_GSO_ENABLE_DISABLE_REPLY, feature_gso_enable_disable_reply) \
5438 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5439 _(SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY, sw_interface_add_del_mac_address_reply) \
5440 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5441 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5442 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5443 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5444 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5445 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5446 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5447 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5448 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5449 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5450 _(SESSION_RULES_DETAILS, session_rules_details) \
5451 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5452 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5453 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5455 #define foreach_standalone_reply_msg \
5456 _(SW_INTERFACE_EVENT, sw_interface_event)
5464 #define STR_VTR_OP_CASE(op) \
5465 case L2_VTR_ ## op: \
5469 str_vtr_op (u32 vtr_op)
5473 STR_VTR_OP_CASE (DISABLED);
5474 STR_VTR_OP_CASE (PUSH_1);
5475 STR_VTR_OP_CASE (PUSH_2);
5476 STR_VTR_OP_CASE (POP_1);
5477 STR_VTR_OP_CASE (POP_2);
5478 STR_VTR_OP_CASE (TRANSLATE_1_1);
5479 STR_VTR_OP_CASE (TRANSLATE_1_2);
5480 STR_VTR_OP_CASE (TRANSLATE_2_1);
5481 STR_VTR_OP_CASE (TRANSLATE_2_2);
5488 dump_sub_interface_table (vat_main_t * vam)
5490 const sw_interface_subif_t *sub = NULL;
5492 if (vam->json_output)
5495 ("JSON output supported only for VPE API calls and dump_stats_table");
5500 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5501 "Interface", "sw_if_index",
5502 "sub id", "dot1ad", "tags", "outer id",
5503 "inner id", "exact", "default", "outer any", "inner any");
5505 vec_foreach (sub, vam->sw_if_subif_table)
5508 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5509 sub->interface_name,
5511 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5512 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5513 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5514 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5515 if (sub->vtr_op != L2_VTR_DISABLED)
5518 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5519 "tag1: %d tag2: %d ]",
5520 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5521 sub->vtr_tag1, sub->vtr_tag2);
5529 name_sort_cmp (void *a1, void *a2)
5531 name_sort_t *n1 = a1;
5532 name_sort_t *n2 = a2;
5534 return strcmp ((char *) n1->name, (char *) n2->name);
5538 dump_interface_table (vat_main_t * vam)
5541 name_sort_t *nses = 0, *ns;
5543 if (vam->json_output)
5546 ("JSON output supported only for VPE API calls and dump_stats_table");
5551 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5553 vec_add2 (nses, ns, 1);
5554 ns->name = (u8 *)(p->key);
5555 ns->value = (u32) p->value[0];
5559 vec_sort_with_function (nses, name_sort_cmp);
5561 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5562 vec_foreach (ns, nses)
5564 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5571 dump_ip_table (vat_main_t * vam, int is_ipv6)
5573 const ip_details_t *det = NULL;
5574 const ip_address_details_t *address = NULL;
5577 print (vam->ofp, "%-12s", "sw_if_index");
5579 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5586 print (vam->ofp, "%-12d", i);
5587 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5592 vec_foreach (address, det->addr)
5596 is_ipv6 ? format_ip6_address : format_ip4_address,
5597 address->ip, address->prefix_length);
5605 dump_ipv4_table (vat_main_t * vam)
5607 if (vam->json_output)
5610 ("JSON output supported only for VPE API calls and dump_stats_table");
5614 return dump_ip_table (vam, 0);
5618 dump_ipv6_table (vat_main_t * vam)
5620 if (vam->json_output)
5623 ("JSON output supported only for VPE API calls and dump_stats_table");
5627 return dump_ip_table (vam, 1);
5631 * Pass CLI buffers directly in the CLI_INBAND API message,
5632 * instead of an additional shared memory area.
5635 exec_inband (vat_main_t * vam)
5637 vl_api_cli_inband_t *mp;
5638 unformat_input_t *i = vam->input;
5641 if (vec_len (i->buffer) == 0)
5644 if (vam->exec_mode == 0 && unformat (i, "mode"))
5649 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5656 * In order for the CLI command to work, it
5657 * must be a vector ending in \n, not a C-string ending
5660 M2 (CLI_INBAND, mp, vec_len (vam->input->buffer));
5661 vl_api_vec_to_api_string (vam->input->buffer, &mp->cmd);
5665 /* json responses may or may not include a useful reply... */
5666 if (vec_len (vam->cmd_reply))
5667 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5672 exec (vat_main_t * vam)
5674 return exec_inband (vam);
5678 api_create_loopback (vat_main_t * vam)
5680 unformat_input_t *i = vam->input;
5681 vl_api_create_loopback_t *mp;
5682 vl_api_create_loopback_instance_t *mp_lbi;
5685 u8 is_specified = 0;
5686 u32 user_instance = 0;
5689 clib_memset (mac_address, 0, sizeof (mac_address));
5691 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5693 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5695 if (unformat (i, "instance %d", &user_instance))
5703 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5704 mp_lbi->is_specified = is_specified;
5706 mp_lbi->user_instance = htonl (user_instance);
5708 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5713 /* Construct the API message */
5714 M (CREATE_LOOPBACK, mp);
5716 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5725 api_delete_loopback (vat_main_t * vam)
5727 unformat_input_t *i = vam->input;
5728 vl_api_delete_loopback_t *mp;
5729 u32 sw_if_index = ~0;
5732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5734 if (unformat (i, "sw_if_index %d", &sw_if_index))
5740 if (sw_if_index == ~0)
5742 errmsg ("missing sw_if_index");
5746 /* Construct the API message */
5747 M (DELETE_LOOPBACK, mp);
5748 mp->sw_if_index = ntohl (sw_if_index);
5756 api_want_interface_events (vat_main_t * vam)
5758 unformat_input_t *i = vam->input;
5759 vl_api_want_interface_events_t *mp;
5763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5765 if (unformat (i, "enable"))
5767 else if (unformat (i, "disable"))
5775 errmsg ("missing enable|disable");
5779 M (WANT_INTERFACE_EVENTS, mp);
5780 mp->enable_disable = enable;
5782 vam->interface_event_display = enable;
5790 /* Note: non-static, called once to set up the initial intfc table */
5792 api_sw_interface_dump (vat_main_t * vam)
5794 vl_api_sw_interface_dump_t *mp;
5795 vl_api_control_ping_t *mp_ping;
5797 name_sort_t *nses = 0, *ns;
5798 sw_interface_subif_t *sub = NULL;
5801 /* Toss the old name table */
5803 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5805 vec_add2 (nses, ns, 1);
5806 ns->name = (u8 *)(p->key);
5807 ns->value = (u32) p->value[0];
5811 hash_free (vam->sw_if_index_by_interface_name);
5813 vec_foreach (ns, nses) vec_free (ns->name);
5817 vec_foreach (sub, vam->sw_if_subif_table)
5819 vec_free (sub->interface_name);
5821 vec_free (vam->sw_if_subif_table);
5823 /* recreate the interface name hash table */
5824 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5827 * Ask for all interface names. Otherwise, the epic catalog of
5828 * name filters becomes ridiculously long, and vat ends up needing
5829 * to be taught about new interface types.
5831 M (SW_INTERFACE_DUMP, mp);
5834 /* Use a control ping for synchronization */
5835 MPING (CONTROL_PING, mp_ping);
5843 api_sw_interface_set_flags (vat_main_t * vam)
5845 unformat_input_t *i = vam->input;
5846 vl_api_sw_interface_set_flags_t *mp;
5848 u8 sw_if_index_set = 0;
5852 /* Parse args required to build the message */
5853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5855 if (unformat (i, "admin-up"))
5857 else if (unformat (i, "admin-down"))
5860 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5861 sw_if_index_set = 1;
5862 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5863 sw_if_index_set = 1;
5868 if (sw_if_index_set == 0)
5870 errmsg ("missing interface name or sw_if_index");
5874 /* Construct the API message */
5875 M (SW_INTERFACE_SET_FLAGS, mp);
5876 mp->sw_if_index = ntohl (sw_if_index);
5877 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
5882 /* Wait for a reply, return the good/bad news... */
5888 api_sw_interface_set_rx_mode (vat_main_t * vam)
5890 unformat_input_t *i = vam->input;
5891 vl_api_sw_interface_set_rx_mode_t *mp;
5893 u8 sw_if_index_set = 0;
5895 u8 queue_id_valid = 0;
5897 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
5899 /* Parse args required to build the message */
5900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5902 if (unformat (i, "queue %d", &queue_id))
5904 else if (unformat (i, "polling"))
5905 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
5906 else if (unformat (i, "interrupt"))
5907 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
5908 else if (unformat (i, "adaptive"))
5909 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
5911 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5912 sw_if_index_set = 1;
5913 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5914 sw_if_index_set = 1;
5919 if (sw_if_index_set == 0)
5921 errmsg ("missing interface name or sw_if_index");
5924 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
5926 errmsg ("missing rx-mode");
5930 /* Construct the API message */
5931 M (SW_INTERFACE_SET_RX_MODE, mp);
5932 mp->sw_if_index = ntohl (sw_if_index);
5933 mp->mode = (vl_api_rx_mode_t) mode;
5934 mp->queue_id_valid = queue_id_valid;
5935 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
5940 /* Wait for a reply, return the good/bad news... */
5946 api_sw_interface_set_rx_placement (vat_main_t * vam)
5948 unformat_input_t *i = vam->input;
5949 vl_api_sw_interface_set_rx_placement_t *mp;
5951 u8 sw_if_index_set = 0;
5954 u32 queue_id, thread_index;
5956 /* Parse args required to build the message */
5957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5959 if (unformat (i, "queue %d", &queue_id))
5961 else if (unformat (i, "main"))
5963 else if (unformat (i, "worker %d", &thread_index))
5966 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5967 sw_if_index_set = 1;
5968 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5969 sw_if_index_set = 1;
5974 if (sw_if_index_set == 0)
5976 errmsg ("missing interface name or sw_if_index");
5982 /* Construct the API message */
5983 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
5984 mp->sw_if_index = ntohl (sw_if_index);
5985 mp->worker_id = ntohl (thread_index);
5986 mp->queue_id = ntohl (queue_id);
5987 mp->is_main = is_main;
5991 /* Wait for a reply, return the good/bad news... */
5996 static void vl_api_sw_interface_rx_placement_details_t_handler
5997 (vl_api_sw_interface_rx_placement_details_t * mp)
5999 vat_main_t *vam = &vat_main;
6000 u32 worker_id = ntohl (mp->worker_id);
6003 "\n%-11d %-11s %-6d %-5d %-9s",
6004 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6005 worker_id, ntohl (mp->queue_id),
6007 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6010 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6011 (vl_api_sw_interface_rx_placement_details_t * mp)
6013 vat_main_t *vam = &vat_main;
6014 vat_json_node_t *node = NULL;
6016 if (VAT_JSON_ARRAY != vam->json_tree.type)
6018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6019 vat_json_init_array (&vam->json_tree);
6021 node = vat_json_array_add (&vam->json_tree);
6023 vat_json_init_object (node);
6024 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6025 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6026 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6027 vat_json_object_add_uint (node, "mode", mp->mode);
6031 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6033 unformat_input_t *i = vam->input;
6034 vl_api_sw_interface_rx_placement_dump_t *mp;
6035 vl_api_control_ping_t *mp_ping;
6038 u8 sw_if_index_set = 0;
6040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6042 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6044 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6051 "\n%-11s %-11s %-6s %-5s %-4s",
6052 "sw_if_index", "main/worker", "thread", "queue", "mode");
6054 /* Dump Interface rx placement */
6055 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6057 if (sw_if_index_set)
6058 mp->sw_if_index = htonl (sw_if_index);
6060 mp->sw_if_index = ~0;
6064 /* Use a control ping for synchronization */
6065 MPING (CONTROL_PING, mp_ping);
6073 api_sw_interface_clear_stats (vat_main_t * vam)
6075 unformat_input_t *i = vam->input;
6076 vl_api_sw_interface_clear_stats_t *mp;
6078 u8 sw_if_index_set = 0;
6081 /* Parse args required to build the message */
6082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6084 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6085 sw_if_index_set = 1;
6086 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6087 sw_if_index_set = 1;
6092 /* Construct the API message */
6093 M (SW_INTERFACE_CLEAR_STATS, mp);
6095 if (sw_if_index_set == 1)
6096 mp->sw_if_index = ntohl (sw_if_index);
6098 mp->sw_if_index = ~0;
6103 /* Wait for a reply, return the good/bad news... */
6109 api_sw_interface_add_del_address (vat_main_t * vam)
6111 unformat_input_t *i = vam->input;
6112 vl_api_sw_interface_add_del_address_t *mp;
6114 u8 sw_if_index_set = 0;
6115 u8 is_add = 1, del_all = 0;
6116 u32 address_length = 0;
6117 u8 v4_address_set = 0;
6118 u8 v6_address_set = 0;
6119 ip4_address_t v4address;
6120 ip6_address_t v6address;
6123 /* Parse args required to build the message */
6124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6126 if (unformat (i, "del-all"))
6128 else if (unformat (i, "del"))
6131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6132 sw_if_index_set = 1;
6133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6134 sw_if_index_set = 1;
6135 else if (unformat (i, "%U/%d",
6136 unformat_ip4_address, &v4address, &address_length))
6138 else if (unformat (i, "%U/%d",
6139 unformat_ip6_address, &v6address, &address_length))
6145 if (sw_if_index_set == 0)
6147 errmsg ("missing interface name or sw_if_index");
6150 if (v4_address_set && v6_address_set)
6152 errmsg ("both v4 and v6 addresses set");
6155 if (!v4_address_set && !v6_address_set && !del_all)
6157 errmsg ("no addresses set");
6161 /* Construct the API message */
6162 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6164 mp->sw_if_index = ntohl (sw_if_index);
6165 mp->is_add = is_add;
6166 mp->del_all = del_all;
6169 mp->prefix.address.af = ADDRESS_IP6;
6170 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6174 mp->prefix.address.af = ADDRESS_IP4;
6175 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6177 mp->prefix.len = address_length;
6182 /* Wait for a reply, return good/bad news */
6188 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6190 unformat_input_t *i = vam->input;
6191 vl_api_sw_interface_set_mpls_enable_t *mp;
6193 u8 sw_if_index_set = 0;
6197 /* Parse args required to build the message */
6198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6201 sw_if_index_set = 1;
6202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6203 sw_if_index_set = 1;
6204 else if (unformat (i, "disable"))
6206 else if (unformat (i, "dis"))
6212 if (sw_if_index_set == 0)
6214 errmsg ("missing interface name or sw_if_index");
6218 /* Construct the API message */
6219 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6221 mp->sw_if_index = ntohl (sw_if_index);
6222 mp->enable = enable;
6227 /* Wait for a reply... */
6233 api_sw_interface_set_table (vat_main_t * vam)
6235 unformat_input_t *i = vam->input;
6236 vl_api_sw_interface_set_table_t *mp;
6237 u32 sw_if_index, vrf_id = 0;
6238 u8 sw_if_index_set = 0;
6242 /* Parse args required to build the message */
6243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6246 sw_if_index_set = 1;
6247 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6248 sw_if_index_set = 1;
6249 else if (unformat (i, "vrf %d", &vrf_id))
6251 else if (unformat (i, "ipv6"))
6257 if (sw_if_index_set == 0)
6259 errmsg ("missing interface name or sw_if_index");
6263 /* Construct the API message */
6264 M (SW_INTERFACE_SET_TABLE, mp);
6266 mp->sw_if_index = ntohl (sw_if_index);
6267 mp->is_ipv6 = is_ipv6;
6268 mp->vrf_id = ntohl (vrf_id);
6273 /* Wait for a reply... */
6278 static void vl_api_sw_interface_get_table_reply_t_handler
6279 (vl_api_sw_interface_get_table_reply_t * mp)
6281 vat_main_t *vam = &vat_main;
6283 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6285 vam->retval = ntohl (mp->retval);
6286 vam->result_ready = 1;
6290 static void vl_api_sw_interface_get_table_reply_t_handler_json
6291 (vl_api_sw_interface_get_table_reply_t * mp)
6293 vat_main_t *vam = &vat_main;
6294 vat_json_node_t node;
6296 vat_json_init_object (&node);
6297 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6298 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6300 vat_json_print (vam->ofp, &node);
6301 vat_json_free (&node);
6303 vam->retval = ntohl (mp->retval);
6304 vam->result_ready = 1;
6308 api_sw_interface_get_table (vat_main_t * vam)
6310 unformat_input_t *i = vam->input;
6311 vl_api_sw_interface_get_table_t *mp;
6313 u8 sw_if_index_set = 0;
6317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6319 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6320 sw_if_index_set = 1;
6321 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6322 sw_if_index_set = 1;
6323 else if (unformat (i, "ipv6"))
6329 if (sw_if_index_set == 0)
6331 errmsg ("missing interface name or sw_if_index");
6335 M (SW_INTERFACE_GET_TABLE, mp);
6336 mp->sw_if_index = htonl (sw_if_index);
6337 mp->is_ipv6 = is_ipv6;
6345 api_sw_interface_set_vpath (vat_main_t * vam)
6347 unformat_input_t *i = vam->input;
6348 vl_api_sw_interface_set_vpath_t *mp;
6349 u32 sw_if_index = 0;
6350 u8 sw_if_index_set = 0;
6354 /* Parse args required to build the message */
6355 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6357 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6358 sw_if_index_set = 1;
6359 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6360 sw_if_index_set = 1;
6361 else if (unformat (i, "enable"))
6363 else if (unformat (i, "disable"))
6369 if (sw_if_index_set == 0)
6371 errmsg ("missing interface name or sw_if_index");
6375 /* Construct the API message */
6376 M (SW_INTERFACE_SET_VPATH, mp);
6378 mp->sw_if_index = ntohl (sw_if_index);
6379 mp->enable = is_enable;
6384 /* Wait for a reply... */
6390 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6392 unformat_input_t *i = vam->input;
6393 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6394 u32 sw_if_index = 0;
6395 u8 sw_if_index_set = 0;
6400 /* Parse args required to build the message */
6401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6403 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6404 sw_if_index_set = 1;
6405 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6406 sw_if_index_set = 1;
6407 else if (unformat (i, "enable"))
6409 else if (unformat (i, "disable"))
6411 else if (unformat (i, "ip4"))
6413 else if (unformat (i, "ip6"))
6419 if (sw_if_index_set == 0)
6421 errmsg ("missing interface name or sw_if_index");
6425 /* Construct the API message */
6426 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6428 mp->sw_if_index = ntohl (sw_if_index);
6429 mp->enable = is_enable;
6430 mp->is_ipv6 = is_ipv6;
6435 /* Wait for a reply... */
6441 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6443 unformat_input_t *i = vam->input;
6444 vl_api_sw_interface_set_geneve_bypass_t *mp;
6445 u32 sw_if_index = 0;
6446 u8 sw_if_index_set = 0;
6451 /* Parse args required to build the message */
6452 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6454 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6455 sw_if_index_set = 1;
6456 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6457 sw_if_index_set = 1;
6458 else if (unformat (i, "enable"))
6460 else if (unformat (i, "disable"))
6462 else if (unformat (i, "ip4"))
6464 else if (unformat (i, "ip6"))
6470 if (sw_if_index_set == 0)
6472 errmsg ("missing interface name or sw_if_index");
6476 /* Construct the API message */
6477 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6479 mp->sw_if_index = ntohl (sw_if_index);
6480 mp->enable = is_enable;
6481 mp->is_ipv6 = is_ipv6;
6486 /* Wait for a reply... */
6492 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6494 unformat_input_t *i = vam->input;
6495 vl_api_sw_interface_set_l2_xconnect_t *mp;
6497 u8 rx_sw_if_index_set = 0;
6499 u8 tx_sw_if_index_set = 0;
6503 /* Parse args required to build the message */
6504 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6506 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6507 rx_sw_if_index_set = 1;
6508 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6509 tx_sw_if_index_set = 1;
6510 else if (unformat (i, "rx"))
6512 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6514 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6516 rx_sw_if_index_set = 1;
6521 else if (unformat (i, "tx"))
6523 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6525 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6527 tx_sw_if_index_set = 1;
6532 else if (unformat (i, "enable"))
6534 else if (unformat (i, "disable"))
6540 if (rx_sw_if_index_set == 0)
6542 errmsg ("missing rx interface name or rx_sw_if_index");
6546 if (enable && (tx_sw_if_index_set == 0))
6548 errmsg ("missing tx interface name or tx_sw_if_index");
6552 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6554 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6555 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6556 mp->enable = enable;
6564 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6566 unformat_input_t *i = vam->input;
6567 vl_api_sw_interface_set_l2_bridge_t *mp;
6568 vl_api_l2_port_type_t port_type;
6570 u8 rx_sw_if_index_set = 0;
6577 port_type = L2_API_PORT_TYPE_NORMAL;
6579 /* Parse args required to build the message */
6580 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6582 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6583 rx_sw_if_index_set = 1;
6584 else if (unformat (i, "bd_id %d", &bd_id))
6588 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6589 rx_sw_if_index_set = 1;
6590 else if (unformat (i, "shg %d", &shg))
6592 else if (unformat (i, "bvi"))
6593 port_type = L2_API_PORT_TYPE_BVI;
6594 else if (unformat (i, "uu-fwd"))
6595 port_type = L2_API_PORT_TYPE_UU_FWD;
6596 else if (unformat (i, "enable"))
6598 else if (unformat (i, "disable"))
6604 if (rx_sw_if_index_set == 0)
6606 errmsg ("missing rx interface name or sw_if_index");
6610 if (enable && (bd_id_set == 0))
6612 errmsg ("missing bridge domain");
6616 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6618 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6619 mp->bd_id = ntohl (bd_id);
6621 mp->port_type = ntohl (port_type);
6622 mp->enable = enable;
6630 api_bridge_domain_dump (vat_main_t * vam)
6632 unformat_input_t *i = vam->input;
6633 vl_api_bridge_domain_dump_t *mp;
6634 vl_api_control_ping_t *mp_ping;
6638 /* Parse args required to build the message */
6639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6641 if (unformat (i, "bd_id %d", &bd_id))
6647 M (BRIDGE_DOMAIN_DUMP, mp);
6648 mp->bd_id = ntohl (bd_id);
6651 /* Use a control ping for synchronization */
6652 MPING (CONTROL_PING, mp_ping);
6660 api_bridge_domain_add_del (vat_main_t * vam)
6662 unformat_input_t *i = vam->input;
6663 vl_api_bridge_domain_add_del_t *mp;
6666 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6671 /* Parse args required to build the message */
6672 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6674 if (unformat (i, "bd_id %d", &bd_id))
6676 else if (unformat (i, "flood %d", &flood))
6678 else if (unformat (i, "uu-flood %d", &uu_flood))
6680 else if (unformat (i, "forward %d", &forward))
6682 else if (unformat (i, "learn %d", &learn))
6684 else if (unformat (i, "arp-term %d", &arp_term))
6686 else if (unformat (i, "mac-age %d", &mac_age))
6688 else if (unformat (i, "bd-tag %s", &bd_tag))
6690 else if (unformat (i, "del"))
6693 flood = uu_flood = forward = learn = 0;
6701 errmsg ("missing bridge domain");
6708 errmsg ("mac age must be less than 256 ");
6713 if ((bd_tag) && (vec_len (bd_tag) > 63))
6715 errmsg ("bd-tag cannot be longer than 63");
6720 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6722 mp->bd_id = ntohl (bd_id);
6724 mp->uu_flood = uu_flood;
6725 mp->forward = forward;
6727 mp->arp_term = arp_term;
6728 mp->is_add = is_add;
6729 mp->mac_age = (u8) mac_age;
6732 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6733 mp->bd_tag[vec_len (bd_tag)] = 0;
6744 api_l2fib_flush_bd (vat_main_t * vam)
6746 unformat_input_t *i = vam->input;
6747 vl_api_l2fib_flush_bd_t *mp;
6751 /* Parse args required to build the message */
6752 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6754 if (unformat (i, "bd_id %d", &bd_id));
6761 errmsg ("missing bridge domain");
6765 M (L2FIB_FLUSH_BD, mp);
6767 mp->bd_id = htonl (bd_id);
6775 api_l2fib_flush_int (vat_main_t * vam)
6777 unformat_input_t *i = vam->input;
6778 vl_api_l2fib_flush_int_t *mp;
6779 u32 sw_if_index = ~0;
6782 /* Parse args required to build the message */
6783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6785 if (unformat (i, "sw_if_index %d", &sw_if_index));
6787 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6792 if (sw_if_index == ~0)
6794 errmsg ("missing interface name or sw_if_index");
6798 M (L2FIB_FLUSH_INT, mp);
6800 mp->sw_if_index = ntohl (sw_if_index);
6808 api_l2fib_add_del (vat_main_t * vam)
6810 unformat_input_t *i = vam->input;
6811 vl_api_l2fib_add_del_t *mp;
6817 u32 sw_if_index = 0;
6818 u8 sw_if_index_set = 0;
6827 /* Parse args required to build the message */
6828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6830 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6832 else if (unformat (i, "bd_id %d", &bd_id))
6834 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6835 sw_if_index_set = 1;
6836 else if (unformat (i, "sw_if"))
6838 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6841 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6842 sw_if_index_set = 1;
6847 else if (unformat (i, "static"))
6849 else if (unformat (i, "filter"))
6854 else if (unformat (i, "bvi"))
6859 else if (unformat (i, "del"))
6861 else if (unformat (i, "count %d", &count))
6869 errmsg ("missing mac address");
6875 errmsg ("missing bridge domain");
6879 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6881 errmsg ("missing interface name or sw_if_index");
6887 /* Turn on async mode */
6888 vam->async_mode = 1;
6889 vam->async_errors = 0;
6890 before = vat_time_now (vam);
6893 for (j = 0; j < count; j++)
6895 M (L2FIB_ADD_DEL, mp);
6897 clib_memcpy (mp->mac, mac, 6);
6898 mp->bd_id = ntohl (bd_id);
6899 mp->is_add = is_add;
6900 mp->sw_if_index = ntohl (sw_if_index);
6904 mp->static_mac = static_mac;
6905 mp->filter_mac = filter_mac;
6906 mp->bvi_mac = bvi_mac;
6908 increment_mac_address (mac);
6915 vl_api_control_ping_t *mp_ping;
6918 /* Shut off async mode */
6919 vam->async_mode = 0;
6921 MPING (CONTROL_PING, mp_ping);
6924 timeout = vat_time_now (vam) + 1.0;
6925 while (vat_time_now (vam) < timeout)
6926 if (vam->result_ready == 1)
6931 if (vam->retval == -99)
6934 if (vam->async_errors > 0)
6936 errmsg ("%d asynchronous errors", vam->async_errors);
6939 vam->async_errors = 0;
6940 after = vat_time_now (vam);
6942 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6943 count, after - before, count / (after - before));
6949 /* Wait for a reply... */
6953 /* Return the good/bad news */
6954 return (vam->retval);
6958 api_bridge_domain_set_mac_age (vat_main_t * vam)
6960 unformat_input_t *i = vam->input;
6961 vl_api_bridge_domain_set_mac_age_t *mp;
6966 /* Parse args required to build the message */
6967 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6969 if (unformat (i, "bd_id %d", &bd_id));
6970 else if (unformat (i, "mac-age %d", &mac_age));
6977 errmsg ("missing bridge domain");
6983 errmsg ("mac age must be less than 256 ");
6987 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6989 mp->bd_id = htonl (bd_id);
6990 mp->mac_age = (u8) mac_age;
6998 api_l2_flags (vat_main_t * vam)
7000 unformat_input_t *i = vam->input;
7001 vl_api_l2_flags_t *mp;
7004 u8 sw_if_index_set = 0;
7008 /* Parse args required to build the message */
7009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7011 if (unformat (i, "sw_if_index %d", &sw_if_index))
7012 sw_if_index_set = 1;
7013 else if (unformat (i, "sw_if"))
7015 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7018 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7019 sw_if_index_set = 1;
7024 else if (unformat (i, "learn"))
7026 else if (unformat (i, "forward"))
7028 else if (unformat (i, "flood"))
7030 else if (unformat (i, "uu-flood"))
7031 flags |= L2_UU_FLOOD;
7032 else if (unformat (i, "arp-term"))
7033 flags |= L2_ARP_TERM;
7034 else if (unformat (i, "off"))
7036 else if (unformat (i, "disable"))
7042 if (sw_if_index_set == 0)
7044 errmsg ("missing interface name or sw_if_index");
7050 mp->sw_if_index = ntohl (sw_if_index);
7051 mp->feature_bitmap = ntohl (flags);
7052 mp->is_set = is_set;
7060 api_bridge_flags (vat_main_t * vam)
7062 unformat_input_t *i = vam->input;
7063 vl_api_bridge_flags_t *mp;
7067 bd_flags_t flags = 0;
7070 /* Parse args required to build the message */
7071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7073 if (unformat (i, "bd_id %d", &bd_id))
7075 else if (unformat (i, "learn"))
7076 flags |= BRIDGE_API_FLAG_LEARN;
7077 else if (unformat (i, "forward"))
7078 flags |= BRIDGE_API_FLAG_FWD;
7079 else if (unformat (i, "flood"))
7080 flags |= BRIDGE_API_FLAG_FLOOD;
7081 else if (unformat (i, "uu-flood"))
7082 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7083 else if (unformat (i, "arp-term"))
7084 flags |= BRIDGE_API_FLAG_ARP_TERM;
7085 else if (unformat (i, "off"))
7087 else if (unformat (i, "disable"))
7095 errmsg ("missing bridge domain");
7099 M (BRIDGE_FLAGS, mp);
7101 mp->bd_id = ntohl (bd_id);
7102 mp->flags = ntohl (flags);
7103 mp->is_set = is_set;
7111 api_bd_ip_mac_add_del (vat_main_t * vam)
7113 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7114 vl_api_mac_address_t mac = { 0 };
7115 unformat_input_t *i = vam->input;
7116 vl_api_bd_ip_mac_add_del_t *mp;
7125 /* Parse args required to build the message */
7126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7128 if (unformat (i, "bd_id %d", &bd_id))
7132 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7136 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7140 else if (unformat (i, "del"))
7148 errmsg ("missing bridge domain");
7151 else if (ip_set == 0)
7153 errmsg ("missing IP address");
7156 else if (mac_set == 0)
7158 errmsg ("missing MAC address");
7162 M (BD_IP_MAC_ADD_DEL, mp);
7164 mp->entry.bd_id = ntohl (bd_id);
7165 mp->is_add = is_add;
7167 clib_memcpy (&mp->entry.ip, &ip, sizeof (ip));
7168 clib_memcpy (&mp->entry.mac, &mac, sizeof (mac));
7176 api_bd_ip_mac_flush (vat_main_t * vam)
7178 unformat_input_t *i = vam->input;
7179 vl_api_bd_ip_mac_flush_t *mp;
7184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7186 if (unformat (i, "bd_id %d", &bd_id))
7196 errmsg ("missing bridge domain");
7200 M (BD_IP_MAC_FLUSH, mp);
7202 mp->bd_id = ntohl (bd_id);
7209 static void vl_api_bd_ip_mac_details_t_handler
7210 (vl_api_bd_ip_mac_details_t * mp)
7212 vat_main_t *vam = &vat_main;
7216 ntohl (mp->entry.bd_id),
7217 format_vl_api_mac_address, mp->entry.mac,
7218 format_vl_api_address, &mp->entry.ip);
7221 static void vl_api_bd_ip_mac_details_t_handler_json
7222 (vl_api_bd_ip_mac_details_t * mp)
7224 vat_main_t *vam = &vat_main;
7225 vat_json_node_t *node = NULL;
7227 if (VAT_JSON_ARRAY != vam->json_tree.type)
7229 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7230 vat_json_init_array (&vam->json_tree);
7232 node = vat_json_array_add (&vam->json_tree);
7234 vat_json_init_object (node);
7235 vat_json_object_add_uint (node, "bd_id", ntohl (mp->entry.bd_id));
7236 vat_json_object_add_string_copy (node, "mac_address",
7237 format (0, "%U", format_vl_api_mac_address,
7241 ip = format (0, "%U", format_vl_api_address, &mp->entry.ip);
7242 vat_json_object_add_string_copy (node, "ip_address", ip);
7247 api_bd_ip_mac_dump (vat_main_t * vam)
7249 unformat_input_t *i = vam->input;
7250 vl_api_bd_ip_mac_dump_t *mp;
7251 vl_api_control_ping_t *mp_ping;
7256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7258 if (unformat (i, "bd_id %d", &bd_id))
7267 "\n%-5s %-7s %-20s %-30s",
7268 "bd_id", "is_ipv6", "mac_address", "ip_address");
7270 /* Dump Bridge Domain Ip to Mac entries */
7271 M (BD_IP_MAC_DUMP, mp);
7274 mp->bd_id = htonl (bd_id);
7280 /* Use a control ping for synchronization */
7281 MPING (CONTROL_PING, mp_ping);
7289 api_tap_create_v2 (vat_main_t * vam)
7291 unformat_input_t *i = vam->input;
7292 vl_api_tap_create_v2_t *mp;
7296 u32 num_rx_queues = 0;
7297 u8 *host_if_name = 0;
7298 u8 host_if_name_set = 0;
7301 u8 host_mac_addr[6];
7302 u8 host_mac_addr_set = 0;
7303 u8 *host_bridge = 0;
7304 u8 host_bridge_set = 0;
7305 u8 host_ip4_prefix_set = 0;
7306 u8 host_ip6_prefix_set = 0;
7307 ip4_address_t host_ip4_addr;
7308 ip4_address_t host_ip4_gw;
7309 u8 host_ip4_gw_set = 0;
7310 u32 host_ip4_prefix_len = 0;
7311 ip6_address_t host_ip6_addr;
7312 ip6_address_t host_ip6_gw;
7313 u8 host_ip6_gw_set = 0;
7314 u32 host_ip6_prefix_len = 0;
7315 u32 host_mtu_size = 0;
7316 u8 host_mtu_set = 0;
7319 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7321 clib_memset (mac_address, 0, sizeof (mac_address));
7323 /* Parse args required to build the message */
7324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7326 if (unformat (i, "id %u", &id))
7330 (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7332 else if (unformat (i, "host-if-name %s", &host_if_name))
7333 host_if_name_set = 1;
7334 else if (unformat (i, "num-rx-queues %u", &num_rx_queues))
7336 else if (unformat (i, "host-ns %s", &host_ns))
7338 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7340 host_mac_addr_set = 1;
7341 else if (unformat (i, "host-bridge %s", &host_bridge))
7342 host_bridge_set = 1;
7343 else if (unformat (i, "host-ip4-addr %U/%u", unformat_ip4_address,
7344 &host_ip4_addr, &host_ip4_prefix_len))
7345 host_ip4_prefix_set = 1;
7346 else if (unformat (i, "host-ip6-addr %U/%u", unformat_ip6_address,
7347 &host_ip6_addr, &host_ip6_prefix_len))
7348 host_ip6_prefix_set = 1;
7349 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7351 host_ip4_gw_set = 1;
7352 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7354 host_ip6_gw_set = 1;
7355 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7357 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7359 else if (unformat (i, "host-mtu-size %u", &host_mtu_size))
7361 else if (unformat (i, "no-gso"))
7362 tap_flags &= ~TAP_API_FLAG_GSO;
7363 else if (unformat (i, "gso"))
7364 tap_flags |= TAP_API_FLAG_GSO;
7365 else if (unformat (i, "csum-offload"))
7366 tap_flags |= TAP_API_FLAG_CSUM_OFFLOAD;
7367 else if (unformat (i, "persist"))
7368 tap_flags |= TAP_API_FLAG_PERSIST;
7369 else if (unformat (i, "attach"))
7370 tap_flags |= TAP_API_FLAG_ATTACH;
7371 else if (unformat (i, "tun"))
7372 tap_flags |= TAP_API_FLAG_TUN;
7373 else if (unformat (i, "gro-coalesce"))
7374 tap_flags |= TAP_API_FLAG_GRO_COALESCE;
7379 if (vec_len (host_if_name) > 63)
7381 errmsg ("tap name too long. ");
7384 if (vec_len (host_ns) > 63)
7386 errmsg ("host name space too long. ");
7389 if (vec_len (host_bridge) > 63)
7391 errmsg ("host bridge name too long. ");
7394 if (host_ip4_prefix_len > 32)
7396 errmsg ("host ip4 prefix length not valid. ");
7399 if (host_ip6_prefix_len > 128)
7401 errmsg ("host ip6 prefix length not valid. ");
7404 if (!is_pow2 (rx_ring_sz))
7406 errmsg ("rx ring size must be power of 2. ");
7409 if (rx_ring_sz > 32768)
7411 errmsg ("rx ring size must be 32768 or lower. ");
7414 if (!is_pow2 (tx_ring_sz))
7416 errmsg ("tx ring size must be power of 2. ");
7419 if (tx_ring_sz > 32768)
7421 errmsg ("tx ring size must be 32768 or lower. ");
7424 if (host_mtu_set && (host_mtu_size < 64 || host_mtu_size > 65355))
7426 errmsg ("host MTU size must be in between 64 and 65355. ");
7430 /* Construct the API message */
7431 M (TAP_CREATE_V2, mp);
7433 mp->id = ntohl (id);
7434 mp->use_random_mac = random_mac;
7435 mp->num_rx_queues = (u8) num_rx_queues;
7436 mp->tx_ring_sz = ntohs (tx_ring_sz);
7437 mp->rx_ring_sz = ntohs (rx_ring_sz);
7438 mp->host_mtu_set = host_mtu_set;
7439 mp->host_mtu_size = ntohl (host_mtu_size);
7440 mp->host_mac_addr_set = host_mac_addr_set;
7441 mp->host_ip4_prefix_set = host_ip4_prefix_set;
7442 mp->host_ip6_prefix_set = host_ip6_prefix_set;
7443 mp->host_ip4_gw_set = host_ip4_gw_set;
7444 mp->host_ip6_gw_set = host_ip6_gw_set;
7445 mp->tap_flags = ntohl (tap_flags);
7446 mp->host_namespace_set = host_ns_set;
7447 mp->host_if_name_set = host_if_name_set;
7448 mp->host_bridge_set = host_bridge_set;
7450 if (random_mac == 0)
7451 clib_memcpy (mp->mac_address, mac_address, 6);
7452 if (host_mac_addr_set)
7453 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7454 if (host_if_name_set)
7455 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7457 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7458 if (host_bridge_set)
7459 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7460 if (host_ip4_prefix_set)
7462 clib_memcpy (mp->host_ip4_prefix.address, &host_ip4_addr, 4);
7463 mp->host_ip4_prefix.len = (u8) host_ip4_prefix_len;
7465 if (host_ip6_prefix_set)
7467 clib_memcpy (mp->host_ip6_prefix.address, &host_ip6_addr, 16);
7468 mp->host_ip6_prefix.len = (u8) host_ip6_prefix_len;
7470 if (host_ip4_gw_set)
7471 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7472 if (host_ip6_gw_set)
7473 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7476 vec_free (host_if_name);
7477 vec_free (host_bridge);
7482 /* Wait for a reply... */
7488 api_tap_delete_v2 (vat_main_t * vam)
7490 unformat_input_t *i = vam->input;
7491 vl_api_tap_delete_v2_t *mp;
7492 u32 sw_if_index = ~0;
7493 u8 sw_if_index_set = 0;
7496 /* Parse args required to build the message */
7497 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7500 sw_if_index_set = 1;
7501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7502 sw_if_index_set = 1;
7507 if (sw_if_index_set == 0)
7509 errmsg ("missing vpp interface name. ");
7513 /* Construct the API message */
7514 M (TAP_DELETE_V2, mp);
7516 mp->sw_if_index = ntohl (sw_if_index);
7521 /* Wait for a reply... */
7527 unformat_vlib_pci_addr (unformat_input_t * input, va_list * args)
7529 vlib_pci_addr_t *addr = va_arg (*args, vlib_pci_addr_t *);
7532 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7535 addr->domain = x[0];
7538 addr->function = x[3];
7544 api_virtio_pci_create (vat_main_t * vam)
7546 unformat_input_t *i = vam->input;
7547 vl_api_virtio_pci_create_t *mp;
7551 u8 checksum_offload_enabled = 0;
7553 u64 features = (u64) ~ (0ULL);
7556 clib_memset (mac_address, 0, sizeof (mac_address));
7558 /* Parse args required to build the message */
7559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7561 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7565 else if (unformat (i, "pci-addr %U", unformat_vlib_pci_addr, &pci_addr))
7567 else if (unformat (i, "features 0x%llx", &features))
7569 else if (unformat (i, "gso-enabled"))
7571 else if (unformat (i, "csum-offload-enabled"))
7572 checksum_offload_enabled = 1;
7579 errmsg ("pci address must be non zero. ");
7583 /* Construct the API message */
7584 M (VIRTIO_PCI_CREATE, mp);
7586 mp->use_random_mac = random_mac;
7588 mp->pci_addr.domain = htons (((vlib_pci_addr_t) pci_addr).domain);
7589 mp->pci_addr.bus = ((vlib_pci_addr_t) pci_addr).bus;
7590 mp->pci_addr.slot = ((vlib_pci_addr_t) pci_addr).slot;
7591 mp->pci_addr.function = ((vlib_pci_addr_t) pci_addr).function;
7593 mp->features = clib_host_to_net_u64 (features);
7594 mp->gso_enabled = gso_enabled;
7595 mp->checksum_offload_enabled = checksum_offload_enabled;
7597 if (random_mac == 0)
7598 clib_memcpy (mp->mac_address, mac_address, 6);
7603 /* Wait for a reply... */
7609 api_virtio_pci_delete (vat_main_t * vam)
7611 unformat_input_t *i = vam->input;
7612 vl_api_virtio_pci_delete_t *mp;
7613 u32 sw_if_index = ~0;
7614 u8 sw_if_index_set = 0;
7617 /* Parse args required to build the message */
7618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7621 sw_if_index_set = 1;
7622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7623 sw_if_index_set = 1;
7628 if (sw_if_index_set == 0)
7630 errmsg ("missing vpp interface name. ");
7634 /* Construct the API message */
7635 M (VIRTIO_PCI_DELETE, mp);
7637 mp->sw_if_index = htonl (sw_if_index);
7642 /* Wait for a reply... */
7648 api_bond_create (vat_main_t * vam)
7650 unformat_input_t *i = vam->input;
7651 vl_api_bond_create_t *mp;
7661 clib_memset (mac_address, 0, sizeof (mac_address));
7664 /* Parse args required to build the message */
7665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7667 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7669 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7670 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7672 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7675 else if (unformat (i, "numa-only"))
7677 else if (unformat (i, "id %u", &id))
7683 if (mode_is_set == 0)
7685 errmsg ("Missing bond mode. ");
7689 /* Construct the API message */
7690 M (BOND_CREATE, mp);
7692 mp->use_custom_mac = custom_mac;
7694 mp->mode = htonl (mode);
7695 mp->lb = htonl (lb);
7696 mp->id = htonl (id);
7697 mp->numa_only = numa_only;
7700 clib_memcpy (mp->mac_address, mac_address, 6);
7705 /* Wait for a reply... */
7711 api_bond_delete (vat_main_t * vam)
7713 unformat_input_t *i = vam->input;
7714 vl_api_bond_delete_t *mp;
7715 u32 sw_if_index = ~0;
7716 u8 sw_if_index_set = 0;
7719 /* Parse args required to build the message */
7720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7723 sw_if_index_set = 1;
7724 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7725 sw_if_index_set = 1;
7730 if (sw_if_index_set == 0)
7732 errmsg ("missing vpp interface name. ");
7736 /* Construct the API message */
7737 M (BOND_DELETE, mp);
7739 mp->sw_if_index = ntohl (sw_if_index);
7744 /* Wait for a reply... */
7750 api_bond_enslave (vat_main_t * vam)
7752 unformat_input_t *i = vam->input;
7753 vl_api_bond_enslave_t *mp;
7754 u32 bond_sw_if_index;
7758 u32 bond_sw_if_index_is_set = 0;
7760 u8 sw_if_index_is_set = 0;
7762 /* Parse args required to build the message */
7763 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7765 if (unformat (i, "sw_if_index %d", &sw_if_index))
7766 sw_if_index_is_set = 1;
7767 else if (unformat (i, "bond %u", &bond_sw_if_index))
7768 bond_sw_if_index_is_set = 1;
7769 else if (unformat (i, "passive %d", &is_passive))
7771 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7777 if (bond_sw_if_index_is_set == 0)
7779 errmsg ("Missing bond sw_if_index. ");
7782 if (sw_if_index_is_set == 0)
7784 errmsg ("Missing slave sw_if_index. ");
7788 /* Construct the API message */
7789 M (BOND_ENSLAVE, mp);
7791 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7792 mp->sw_if_index = ntohl (sw_if_index);
7793 mp->is_long_timeout = is_long_timeout;
7794 mp->is_passive = is_passive;
7799 /* Wait for a reply... */
7805 api_bond_detach_slave (vat_main_t * vam)
7807 unformat_input_t *i = vam->input;
7808 vl_api_bond_detach_slave_t *mp;
7809 u32 sw_if_index = ~0;
7810 u8 sw_if_index_set = 0;
7813 /* Parse args required to build the message */
7814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7816 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7817 sw_if_index_set = 1;
7818 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7819 sw_if_index_set = 1;
7824 if (sw_if_index_set == 0)
7826 errmsg ("missing vpp interface name. ");
7830 /* Construct the API message */
7831 M (BOND_DETACH_SLAVE, mp);
7833 mp->sw_if_index = ntohl (sw_if_index);
7838 /* Wait for a reply... */
7844 api_ip_table_add_del (vat_main_t * vam)
7846 unformat_input_t *i = vam->input;
7847 vl_api_ip_table_add_del_t *mp;
7853 /* Parse args required to build the message */
7854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7856 if (unformat (i, "ipv6"))
7858 else if (unformat (i, "del"))
7860 else if (unformat (i, "add"))
7862 else if (unformat (i, "table %d", &table_id))
7866 clib_warning ("parse error '%U'", format_unformat_error, i);
7873 errmsg ("missing table-ID");
7877 /* Construct the API message */
7878 M (IP_TABLE_ADD_DEL, mp);
7880 mp->table.table_id = ntohl (table_id);
7881 mp->table.is_ip6 = is_ipv6;
7882 mp->is_add = is_add;
7887 /* Wait for a reply... */
7894 unformat_fib_path (unformat_input_t * input, va_list * args)
7896 vat_main_t *vam = va_arg (*args, vat_main_t *);
7897 vl_api_fib_path_t *path = va_arg (*args, vl_api_fib_path_t *);
7898 u32 weight, preference;
7899 mpls_label_t out_label;
7901 clib_memset (path, 0, sizeof (*path));
7903 path->sw_if_index = ~0;
7907 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
7909 if (unformat (input, "%U %U",
7910 unformat_vl_api_ip4_address,
7911 &path->nh.address.ip4,
7912 api_unformat_sw_if_index, vam, &path->sw_if_index))
7914 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7916 else if (unformat (input, "%U %U",
7917 unformat_vl_api_ip6_address,
7918 &path->nh.address.ip6,
7919 api_unformat_sw_if_index, vam, &path->sw_if_index))
7921 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7923 else if (unformat (input, "weight %u", &weight))
7925 path->weight = weight;
7927 else if (unformat (input, "preference %u", &preference))
7929 path->preference = preference;
7931 else if (unformat (input, "%U next-hop-table %d",
7932 unformat_vl_api_ip4_address,
7933 &path->nh.address.ip4, &path->table_id))
7935 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7937 else if (unformat (input, "%U next-hop-table %d",
7938 unformat_vl_api_ip6_address,
7939 &path->nh.address.ip6, &path->table_id))
7941 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7943 else if (unformat (input, "%U",
7944 unformat_vl_api_ip4_address, &path->nh.address.ip4))
7947 * the recursive next-hops are by default in the default table
7950 path->sw_if_index = ~0;
7951 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7953 else if (unformat (input, "%U",
7954 unformat_vl_api_ip6_address, &path->nh.address.ip6))
7957 * the recursive next-hops are by default in the default table
7960 path->sw_if_index = ~0;
7961 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7963 else if (unformat (input, "resolve-via-host"))
7965 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_HOST;
7967 else if (unformat (input, "resolve-via-attached"))
7969 path->flags |= FIB_API_PATH_FLAG_RESOLVE_VIA_ATTACHED;
7971 else if (unformat (input, "ip4-lookup-in-table %d", &path->table_id))
7973 path->type = FIB_API_PATH_TYPE_LOCAL;
7974 path->sw_if_index = ~0;
7975 path->proto = FIB_API_PATH_NH_PROTO_IP4;
7977 else if (unformat (input, "ip6-lookup-in-table %d", &path->table_id))
7979 path->type = FIB_API_PATH_TYPE_LOCAL;
7980 path->sw_if_index = ~0;
7981 path->proto = FIB_API_PATH_NH_PROTO_IP6;
7983 else if (unformat (input, "sw_if_index %d", &path->sw_if_index))
7985 else if (unformat (input, "via-label %d", &path->nh.via_label))
7987 path->proto = FIB_API_PATH_NH_PROTO_MPLS;
7988 path->sw_if_index = ~0;
7990 else if (unformat (input, "l2-input-on %d", &path->sw_if_index))
7992 path->proto = FIB_API_PATH_NH_PROTO_ETHERNET;
7993 path->type = FIB_API_PATH_TYPE_INTERFACE_RX;
7995 else if (unformat (input, "local"))
7997 path->type = FIB_API_PATH_TYPE_LOCAL;
7999 else if (unformat (input, "out-labels"))
8001 while (unformat (input, "%d", &out_label))
8003 path->label_stack[path->n_labels].label = out_label;
8004 path->label_stack[path->n_labels].is_uniform = 0;
8005 path->label_stack[path->n_labels].ttl = 64;
8009 else if (unformat (input, "via"))
8011 /* new path, back up and return */
8012 unformat_put_input (input);
8013 unformat_put_input (input);
8014 unformat_put_input (input);
8015 unformat_put_input (input);
8024 path->proto = ntohl (path->proto);
8025 path->type = ntohl (path->type);
8026 path->flags = ntohl (path->flags);
8027 path->table_id = ntohl (path->table_id);
8028 path->sw_if_index = ntohl (path->sw_if_index);
8034 api_ip_route_add_del (vat_main_t * vam)
8036 unformat_input_t *i = vam->input;
8037 vl_api_ip_route_add_del_t *mp;
8040 u8 is_multipath = 0;
8043 vl_api_prefix_t pfx = { };
8044 vl_api_fib_path_t paths[8];
8048 u32 random_add_del = 0;
8049 u32 *random_vector = 0;
8050 u32 random_seed = 0xdeaddabe;
8052 /* Parse args required to build the message */
8053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8055 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8057 else if (unformat (i, "del"))
8059 else if (unformat (i, "add"))
8061 else if (unformat (i, "vrf %d", &vrf_id))
8063 else if (unformat (i, "count %d", &count))
8065 else if (unformat (i, "random"))
8067 else if (unformat (i, "multipath"))
8069 else if (unformat (i, "seed %d", &random_seed))
8073 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8076 if (8 == path_count)
8078 errmsg ("max 8 paths");
8084 clib_warning ("parse error '%U'", format_unformat_error, i);
8091 errmsg ("specify a path; via ...");
8094 if (prefix_set == 0)
8096 errmsg ("missing prefix");
8100 /* Generate a pile of unique, random routes */
8103 ip4_address_t *i = (ip4_address_t *) & paths[0].nh.address.ip4;
8104 u32 this_random_address;
8107 random_hash = hash_create (count, sizeof (uword));
8109 hash_set (random_hash, i->as_u32, 1);
8110 for (j = 0; j <= count; j++)
8114 this_random_address = random_u32 (&random_seed);
8115 this_random_address =
8116 clib_host_to_net_u32 (this_random_address);
8118 while (hash_get (random_hash, this_random_address));
8119 vec_add1 (random_vector, this_random_address);
8120 hash_set (random_hash, this_random_address, 1);
8122 hash_free (random_hash);
8123 set_ip4_address (&pfx.address, random_vector[0]);
8128 /* Turn on async mode */
8129 vam->async_mode = 1;
8130 vam->async_errors = 0;
8131 before = vat_time_now (vam);
8134 for (j = 0; j < count; j++)
8136 /* Construct the API message */
8137 M2 (IP_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8139 mp->is_add = is_add;
8140 mp->is_multipath = is_multipath;
8142 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8143 mp->route.table_id = ntohl (vrf_id);
8144 mp->route.n_paths = path_count;
8146 clib_memcpy (&mp->route.paths, &paths, sizeof (paths[0]) * path_count);
8149 set_ip4_address (&pfx.address, random_vector[j + 1]);
8151 increment_address (&pfx.address);
8154 /* If we receive SIGTERM, stop now... */
8159 /* When testing multiple add/del ops, use a control-ping to sync */
8162 vl_api_control_ping_t *mp_ping;
8166 /* Shut off async mode */
8167 vam->async_mode = 0;
8169 MPING (CONTROL_PING, mp_ping);
8172 timeout = vat_time_now (vam) + 1.0;
8173 while (vat_time_now (vam) < timeout)
8174 if (vam->result_ready == 1)
8179 if (vam->retval == -99)
8182 if (vam->async_errors > 0)
8184 errmsg ("%d asynchronous errors", vam->async_errors);
8187 vam->async_errors = 0;
8188 after = vat_time_now (vam);
8190 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8194 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8195 count, after - before, count / (after - before));
8201 /* Wait for a reply... */
8206 /* Return the good/bad news */
8207 return (vam->retval);
8211 api_ip_mroute_add_del (vat_main_t * vam)
8213 unformat_input_t *i = vam->input;
8214 u8 path_set = 0, prefix_set = 0, is_add = 1;
8215 vl_api_ip_mroute_add_del_t *mp;
8216 mfib_entry_flags_t eflags = 0;
8217 vl_api_mfib_path_t path;
8218 vl_api_mprefix_t pfx = { };
8222 /* Parse args required to build the message */
8223 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8225 if (unformat (i, "%U", unformat_vl_api_mprefix, &pfx))
8228 pfx.grp_address_length = htons (pfx.grp_address_length);
8230 else if (unformat (i, "del"))
8232 else if (unformat (i, "add"))
8234 else if (unformat (i, "vrf %d", &vrf_id))
8236 else if (unformat (i, "%U", unformat_mfib_itf_flags, &path.itf_flags))
8237 path.itf_flags = htonl (path.itf_flags);
8238 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8240 else if (unformat (i, "via %U", unformat_fib_path, vam, &path.path))
8244 clib_warning ("parse error '%U'", format_unformat_error, i);
8249 if (prefix_set == 0)
8251 errmsg ("missing addresses\n");
8256 errmsg ("missing path\n");
8260 /* Construct the API message */
8261 M (IP_MROUTE_ADD_DEL, mp);
8263 mp->is_add = is_add;
8264 mp->is_multipath = 1;
8266 clib_memcpy (&mp->route.prefix, &pfx, sizeof (pfx));
8267 mp->route.table_id = htonl (vrf_id);
8268 mp->route.n_paths = 1;
8269 mp->route.entry_flags = htonl (eflags);
8271 clib_memcpy (&mp->route.paths, &path, sizeof (path));
8275 /* Wait for a reply... */
8281 api_mpls_table_add_del (vat_main_t * vam)
8283 unformat_input_t *i = vam->input;
8284 vl_api_mpls_table_add_del_t *mp;
8289 /* Parse args required to build the message */
8290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8292 if (unformat (i, "table %d", &table_id))
8294 else if (unformat (i, "del"))
8296 else if (unformat (i, "add"))
8300 clib_warning ("parse error '%U'", format_unformat_error, i);
8307 errmsg ("missing table-ID");
8311 /* Construct the API message */
8312 M (MPLS_TABLE_ADD_DEL, mp);
8314 mp->mt_table.mt_table_id = ntohl (table_id);
8315 mp->mt_is_add = is_add;
8320 /* Wait for a reply... */
8327 api_mpls_route_add_del (vat_main_t * vam)
8329 u8 is_add = 1, path_count = 0, is_multipath = 0, is_eos = 0;
8330 mpls_label_t local_label = MPLS_LABEL_INVALID;
8331 unformat_input_t *i = vam->input;
8332 vl_api_mpls_route_add_del_t *mp;
8333 vl_api_fib_path_t paths[8];
8337 /* Parse args required to build the message */
8338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8340 if (unformat (i, "%d", &local_label))
8342 else if (unformat (i, "eos"))
8344 else if (unformat (i, "non-eos"))
8346 else if (unformat (i, "del"))
8348 else if (unformat (i, "add"))
8350 else if (unformat (i, "multipath"))
8352 else if (unformat (i, "count %d", &count))
8356 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8359 if (8 == path_count)
8361 errmsg ("max 8 paths");
8367 clib_warning ("parse error '%U'", format_unformat_error, i);
8374 errmsg ("specify a path; via ...");
8378 if (MPLS_LABEL_INVALID == local_label)
8380 errmsg ("missing label");
8386 /* Turn on async mode */
8387 vam->async_mode = 1;
8388 vam->async_errors = 0;
8389 before = vat_time_now (vam);
8392 for (j = 0; j < count; j++)
8394 /* Construct the API message */
8395 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8397 mp->mr_is_add = is_add;
8398 mp->mr_is_multipath = is_multipath;
8400 mp->mr_route.mr_label = local_label;
8401 mp->mr_route.mr_eos = is_eos;
8402 mp->mr_route.mr_table_id = 0;
8403 mp->mr_route.mr_n_paths = path_count;
8405 clib_memcpy (&mp->mr_route.mr_paths, paths,
8406 sizeof (paths[0]) * path_count);
8412 /* If we receive SIGTERM, stop now... */
8417 /* When testing multiple add/del ops, use a control-ping to sync */
8420 vl_api_control_ping_t *mp_ping;
8424 /* Shut off async mode */
8425 vam->async_mode = 0;
8427 MPING (CONTROL_PING, mp_ping);
8430 timeout = vat_time_now (vam) + 1.0;
8431 while (vat_time_now (vam) < timeout)
8432 if (vam->result_ready == 1)
8437 if (vam->retval == -99)
8440 if (vam->async_errors > 0)
8442 errmsg ("%d asynchronous errors", vam->async_errors);
8445 vam->async_errors = 0;
8446 after = vat_time_now (vam);
8448 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8452 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8453 count, after - before, count / (after - before));
8459 /* Wait for a reply... */
8464 /* Return the good/bad news */
8465 return (vam->retval);
8470 api_mpls_ip_bind_unbind (vat_main_t * vam)
8472 unformat_input_t *i = vam->input;
8473 vl_api_mpls_ip_bind_unbind_t *mp;
8474 u32 ip_table_id = 0;
8476 vl_api_prefix_t pfx;
8478 mpls_label_t local_label = MPLS_LABEL_INVALID;
8481 /* Parse args required to build the message */
8482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8484 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
8486 else if (unformat (i, "%d", &local_label))
8488 else if (unformat (i, "table-id %d", &ip_table_id))
8490 else if (unformat (i, "unbind"))
8492 else if (unformat (i, "bind"))
8496 clib_warning ("parse error '%U'", format_unformat_error, i);
8503 errmsg ("IP prefix not set");
8507 if (MPLS_LABEL_INVALID == local_label)
8509 errmsg ("missing label");
8513 /* Construct the API message */
8514 M (MPLS_IP_BIND_UNBIND, mp);
8516 mp->mb_is_bind = is_bind;
8517 mp->mb_ip_table_id = ntohl (ip_table_id);
8518 mp->mb_mpls_table_id = 0;
8519 mp->mb_label = ntohl (local_label);
8520 clib_memcpy (&mp->mb_prefix, &pfx, sizeof (pfx));
8525 /* Wait for a reply... */
8532 api_sr_mpls_policy_add (vat_main_t * vam)
8534 unformat_input_t *i = vam->input;
8535 vl_api_sr_mpls_policy_add_t *mp;
8541 u32 *segments = NULL;
8544 /* Parse args required to build the message */
8545 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8547 if (unformat (i, "bsid %d", &bsid))
8549 else if (unformat (i, "weight %d", &weight))
8551 else if (unformat (i, "spray"))
8553 else if (unformat (i, "next %d", &sid))
8556 vec_add1 (segments, htonl (sid));
8560 clib_warning ("parse error '%U'", format_unformat_error, i);
8567 errmsg ("bsid not set");
8571 if (n_segments == 0)
8573 errmsg ("no sid in segment stack");
8577 /* Construct the API message */
8578 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8580 mp->bsid = htonl (bsid);
8581 mp->weight = htonl (weight);
8582 mp->is_spray = type;
8583 mp->n_segments = n_segments;
8584 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8585 vec_free (segments);
8590 /* Wait for a reply... */
8596 api_sr_mpls_policy_del (vat_main_t * vam)
8598 unformat_input_t *i = vam->input;
8599 vl_api_sr_mpls_policy_del_t *mp;
8603 /* Parse args required to build the message */
8604 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8606 if (unformat (i, "bsid %d", &bsid))
8610 clib_warning ("parse error '%U'", format_unformat_error, i);
8617 errmsg ("bsid not set");
8621 /* Construct the API message */
8622 M (SR_MPLS_POLICY_DEL, mp);
8624 mp->bsid = htonl (bsid);
8629 /* Wait for a reply... */
8635 api_bier_table_add_del (vat_main_t * vam)
8637 unformat_input_t *i = vam->input;
8638 vl_api_bier_table_add_del_t *mp;
8640 u32 set = 0, sub_domain = 0, hdr_len = 3;
8641 mpls_label_t local_label = MPLS_LABEL_INVALID;
8644 /* Parse args required to build the message */
8645 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8647 if (unformat (i, "sub-domain %d", &sub_domain))
8649 else if (unformat (i, "set %d", &set))
8651 else if (unformat (i, "label %d", &local_label))
8653 else if (unformat (i, "hdr-len %d", &hdr_len))
8655 else if (unformat (i, "add"))
8657 else if (unformat (i, "del"))
8661 clib_warning ("parse error '%U'", format_unformat_error, i);
8666 if (MPLS_LABEL_INVALID == local_label)
8668 errmsg ("missing label\n");
8672 /* Construct the API message */
8673 M (BIER_TABLE_ADD_DEL, mp);
8675 mp->bt_is_add = is_add;
8676 mp->bt_label = ntohl (local_label);
8677 mp->bt_tbl_id.bt_set = set;
8678 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8679 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8684 /* Wait for a reply... */
8691 api_bier_route_add_del (vat_main_t * vam)
8693 unformat_input_t *i = vam->input;
8694 vl_api_bier_route_add_del_t *mp;
8696 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8697 ip4_address_t v4_next_hop_address;
8698 ip6_address_t v6_next_hop_address;
8699 u8 next_hop_set = 0;
8700 u8 next_hop_proto_is_ip4 = 1;
8701 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8704 /* Parse args required to build the message */
8705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8707 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8709 next_hop_proto_is_ip4 = 1;
8712 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8714 next_hop_proto_is_ip4 = 0;
8717 if (unformat (i, "sub-domain %d", &sub_domain))
8719 else if (unformat (i, "set %d", &set))
8721 else if (unformat (i, "hdr-len %d", &hdr_len))
8723 else if (unformat (i, "bp %d", &bp))
8725 else if (unformat (i, "add"))
8727 else if (unformat (i, "del"))
8729 else if (unformat (i, "out-label %d", &next_hop_out_label))
8733 clib_warning ("parse error '%U'", format_unformat_error, i);
8738 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
8740 errmsg ("next hop / label set\n");
8745 errmsg ("bit=position not set\n");
8749 /* Construct the API message */
8750 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
8752 mp->br_is_add = is_add;
8753 mp->br_route.br_tbl_id.bt_set = set;
8754 mp->br_route.br_tbl_id.bt_sub_domain = sub_domain;
8755 mp->br_route.br_tbl_id.bt_hdr_len_id = hdr_len;
8756 mp->br_route.br_bp = ntohs (bp);
8757 mp->br_route.br_n_paths = 1;
8758 mp->br_route.br_paths[0].n_labels = 1;
8759 mp->br_route.br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
8760 mp->br_route.br_paths[0].proto = (next_hop_proto_is_ip4 ?
8761 FIB_API_PATH_NH_PROTO_IP4 :
8762 FIB_API_PATH_NH_PROTO_IP6);
8764 if (next_hop_proto_is_ip4)
8766 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip4,
8767 &v4_next_hop_address, sizeof (v4_next_hop_address));
8771 clib_memcpy (&mp->br_route.br_paths[0].nh.address.ip6,
8772 &v6_next_hop_address, sizeof (v6_next_hop_address));
8778 /* Wait for a reply... */
8785 api_mpls_tunnel_add_del (vat_main_t * vam)
8787 unformat_input_t *i = vam->input;
8788 vl_api_mpls_tunnel_add_del_t *mp;
8790 vl_api_fib_path_t paths[8];
8791 u32 sw_if_index = ~0;
8797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8799 if (unformat (i, "add"))
8803 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
8805 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8807 else if (unformat (i, "l2-only"))
8811 (i, "via %U", unformat_fib_path, vam, &paths[path_count]))
8814 if (8 == path_count)
8816 errmsg ("max 8 paths");
8822 clib_warning ("parse error '%U'", format_unformat_error, i);
8827 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_path_t) * path_count);
8829 mp->mt_is_add = is_add;
8830 mp->mt_tunnel.mt_sw_if_index = ntohl (sw_if_index);
8831 mp->mt_tunnel.mt_l2_only = l2_only;
8832 mp->mt_tunnel.mt_is_multicast = 0;
8833 mp->mt_tunnel.mt_n_paths = path_count;
8835 clib_memcpy (&mp->mt_tunnel.mt_paths, &paths,
8836 sizeof (paths[0]) * path_count);
8844 api_sw_interface_set_unnumbered (vat_main_t * vam)
8846 unformat_input_t *i = vam->input;
8847 vl_api_sw_interface_set_unnumbered_t *mp;
8849 u32 unnum_sw_index = ~0;
8851 u8 sw_if_index_set = 0;
8854 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8856 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8857 sw_if_index_set = 1;
8858 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8859 sw_if_index_set = 1;
8860 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8862 else if (unformat (i, "del"))
8866 clib_warning ("parse error '%U'", format_unformat_error, i);
8871 if (sw_if_index_set == 0)
8873 errmsg ("missing interface name or sw_if_index");
8877 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8879 mp->sw_if_index = ntohl (sw_if_index);
8880 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8881 mp->is_add = is_add;
8890 api_create_vlan_subif (vat_main_t * vam)
8892 unformat_input_t *i = vam->input;
8893 vl_api_create_vlan_subif_t *mp;
8895 u8 sw_if_index_set = 0;
8900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8902 if (unformat (i, "sw_if_index %d", &sw_if_index))
8903 sw_if_index_set = 1;
8905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8906 sw_if_index_set = 1;
8907 else if (unformat (i, "vlan %d", &vlan_id))
8911 clib_warning ("parse error '%U'", format_unformat_error, i);
8916 if (sw_if_index_set == 0)
8918 errmsg ("missing interface name or sw_if_index");
8922 if (vlan_id_set == 0)
8924 errmsg ("missing vlan_id");
8927 M (CREATE_VLAN_SUBIF, mp);
8929 mp->sw_if_index = ntohl (sw_if_index);
8930 mp->vlan_id = ntohl (vlan_id);
8937 #define foreach_create_subif_bit \
8944 _(outer_vlan_id_any) \
8945 _(inner_vlan_id_any)
8947 #define foreach_create_subif_flag \
8952 _(4, "exact_match") \
8953 _(5, "default_sub") \
8954 _(6, "outer_vlan_id_any") \
8955 _(7, "inner_vlan_id_any")
8958 api_create_subif (vat_main_t * vam)
8960 unformat_input_t *i = vam->input;
8961 vl_api_create_subif_t *mp;
8963 u8 sw_if_index_set = 0;
8966 u32 __attribute__ ((unused)) no_tags = 0;
8967 u32 __attribute__ ((unused)) one_tag = 0;
8968 u32 __attribute__ ((unused)) two_tags = 0;
8969 u32 __attribute__ ((unused)) dot1ad = 0;
8970 u32 __attribute__ ((unused)) exact_match = 0;
8971 u32 __attribute__ ((unused)) default_sub = 0;
8972 u32 __attribute__ ((unused)) outer_vlan_id_any = 0;
8973 u32 __attribute__ ((unused)) inner_vlan_id_any = 0;
8975 u16 outer_vlan_id = 0;
8976 u16 inner_vlan_id = 0;
8979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8981 if (unformat (i, "sw_if_index %d", &sw_if_index))
8982 sw_if_index_set = 1;
8984 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8985 sw_if_index_set = 1;
8986 else if (unformat (i, "sub_id %d", &sub_id))
8988 else if (unformat (i, "outer_vlan_id %d", &tmp))
8989 outer_vlan_id = tmp;
8990 else if (unformat (i, "inner_vlan_id %d", &tmp))
8991 inner_vlan_id = tmp;
8993 #define _(a) else if (unformat (i, #a)) a = 1 ;
8994 foreach_create_subif_bit
8998 clib_warning ("parse error '%U'", format_unformat_error, i);
9003 if (sw_if_index_set == 0)
9005 errmsg ("missing interface name or sw_if_index");
9009 if (sub_id_set == 0)
9011 errmsg ("missing sub_id");
9014 M (CREATE_SUBIF, mp);
9016 mp->sw_if_index = ntohl (sw_if_index);
9017 mp->sub_id = ntohl (sub_id);
9019 #define _(a,b) mp->sub_if_flags |= (1 << a);
9020 foreach_create_subif_flag;
9023 mp->outer_vlan_id = ntohs (outer_vlan_id);
9024 mp->inner_vlan_id = ntohs (inner_vlan_id);
9032 api_ip_table_replace_begin (vat_main_t * vam)
9034 unformat_input_t *i = vam->input;
9035 vl_api_ip_table_replace_begin_t *mp;
9040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9042 if (unformat (i, "table %d", &table_id))
9044 else if (unformat (i, "ipv6"))
9048 clib_warning ("parse error '%U'", format_unformat_error, i);
9053 M (IP_TABLE_REPLACE_BEGIN, mp);
9055 mp->table.table_id = ntohl (table_id);
9056 mp->table.is_ip6 = is_ipv6;
9064 api_ip_table_flush (vat_main_t * vam)
9066 unformat_input_t *i = vam->input;
9067 vl_api_ip_table_flush_t *mp;
9072 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9074 if (unformat (i, "table %d", &table_id))
9076 else if (unformat (i, "ipv6"))
9080 clib_warning ("parse error '%U'", format_unformat_error, i);
9085 M (IP_TABLE_FLUSH, mp);
9087 mp->table.table_id = ntohl (table_id);
9088 mp->table.is_ip6 = is_ipv6;
9096 api_ip_table_replace_end (vat_main_t * vam)
9098 unformat_input_t *i = vam->input;
9099 vl_api_ip_table_replace_end_t *mp;
9104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9106 if (unformat (i, "table %d", &table_id))
9108 else if (unformat (i, "ipv6"))
9112 clib_warning ("parse error '%U'", format_unformat_error, i);
9117 M (IP_TABLE_REPLACE_END, mp);
9119 mp->table.table_id = ntohl (table_id);
9120 mp->table.is_ip6 = is_ipv6;
9128 api_set_ip_flow_hash (vat_main_t * vam)
9130 unformat_input_t *i = vam->input;
9131 vl_api_set_ip_flow_hash_t *mp;
9143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9145 if (unformat (i, "vrf %d", &vrf_id))
9147 else if (unformat (i, "ipv6"))
9149 else if (unformat (i, "src"))
9151 else if (unformat (i, "dst"))
9153 else if (unformat (i, "sport"))
9155 else if (unformat (i, "dport"))
9157 else if (unformat (i, "proto"))
9159 else if (unformat (i, "reverse"))
9164 clib_warning ("parse error '%U'", format_unformat_error, i);
9169 if (vrf_id_set == 0)
9171 errmsg ("missing vrf id");
9175 M (SET_IP_FLOW_HASH, mp);
9181 mp->reverse = reverse;
9182 mp->vrf_id = ntohl (vrf_id);
9183 mp->is_ipv6 = is_ipv6;
9191 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9193 unformat_input_t *i = vam->input;
9194 vl_api_sw_interface_ip6_enable_disable_t *mp;
9196 u8 sw_if_index_set = 0;
9200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9203 sw_if_index_set = 1;
9204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9205 sw_if_index_set = 1;
9206 else if (unformat (i, "enable"))
9208 else if (unformat (i, "disable"))
9212 clib_warning ("parse error '%U'", format_unformat_error, i);
9217 if (sw_if_index_set == 0)
9219 errmsg ("missing interface name or sw_if_index");
9223 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9225 mp->sw_if_index = ntohl (sw_if_index);
9226 mp->enable = enable;
9235 api_l2_patch_add_del (vat_main_t * vam)
9237 unformat_input_t *i = vam->input;
9238 vl_api_l2_patch_add_del_t *mp;
9240 u8 rx_sw_if_index_set = 0;
9242 u8 tx_sw_if_index_set = 0;
9246 /* Parse args required to build the message */
9247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9249 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9250 rx_sw_if_index_set = 1;
9251 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9252 tx_sw_if_index_set = 1;
9253 else if (unformat (i, "rx"))
9255 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9257 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9259 rx_sw_if_index_set = 1;
9264 else if (unformat (i, "tx"))
9266 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9268 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9270 tx_sw_if_index_set = 1;
9275 else if (unformat (i, "del"))
9281 if (rx_sw_if_index_set == 0)
9283 errmsg ("missing rx interface name or rx_sw_if_index");
9287 if (tx_sw_if_index_set == 0)
9289 errmsg ("missing tx interface name or tx_sw_if_index");
9293 M (L2_PATCH_ADD_DEL, mp);
9295 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9296 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9297 mp->is_add = is_add;
9305 u8 localsid_addr[16];
9314 api_sr_localsid_add_del (vat_main_t * vam)
9316 unformat_input_t *i = vam->input;
9317 vl_api_sr_localsid_add_del_t *mp;
9320 ip6_address_t localsid;
9324 u32 fib_table = ~(u32) 0;
9325 ip46_address_t nh_addr;
9326 clib_memset (&nh_addr, 0, sizeof (ip46_address_t));
9328 bool nexthop_set = 0;
9332 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9334 if (unformat (i, "del"))
9336 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9337 else if (unformat (i, "next-hop %U", unformat_ip46_address, &nh_addr))
9339 else if (unformat (i, "behavior %u", &behavior));
9340 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9341 else if (unformat (i, "fib-table %u", &fib_table));
9342 else if (unformat (i, "end.psp %u", &behavior));
9347 M (SR_LOCALSID_ADD_DEL, mp);
9349 clib_memcpy (mp->localsid, &localsid, sizeof (mp->localsid));
9353 clib_memcpy (&mp->nh_addr.un, &nh_addr, sizeof (mp->nh_addr.un));
9355 mp->behavior = behavior;
9356 mp->sw_if_index = ntohl (sw_if_index);
9357 mp->fib_table = ntohl (fib_table);
9358 mp->end_psp = end_psp;
9359 mp->is_del = is_del;
9367 api_ioam_enable (vat_main_t * vam)
9369 unformat_input_t *input = vam->input;
9370 vl_api_ioam_enable_t *mp;
9372 int has_trace_option = 0;
9373 int has_pot_option = 0;
9374 int has_seqno_option = 0;
9375 int has_analyse_option = 0;
9378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9380 if (unformat (input, "trace"))
9381 has_trace_option = 1;
9382 else if (unformat (input, "pot"))
9384 else if (unformat (input, "seqno"))
9385 has_seqno_option = 1;
9386 else if (unformat (input, "analyse"))
9387 has_analyse_option = 1;
9391 M (IOAM_ENABLE, mp);
9392 mp->id = htons (id);
9393 mp->seqno = has_seqno_option;
9394 mp->analyse = has_analyse_option;
9395 mp->pot_enable = has_pot_option;
9396 mp->trace_enable = has_trace_option;
9405 api_ioam_disable (vat_main_t * vam)
9407 vl_api_ioam_disable_t *mp;
9410 M (IOAM_DISABLE, mp);
9416 #define foreach_tcp_proto_field \
9420 #define foreach_udp_proto_field \
9424 #define foreach_ip4_proto_field \
9436 u16 src_port, dst_port;
9439 #if VPP_API_TEST_BUILTIN == 0
9441 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9443 u8 **maskp = va_arg (*args, u8 **);
9445 u8 found_something = 0;
9448 #define _(a) u8 a=0;
9449 foreach_tcp_proto_field;
9452 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9455 #define _(a) else if (unformat (input, #a)) a=1;
9456 foreach_tcp_proto_field
9462 #define _(a) found_something += a;
9463 foreach_tcp_proto_field;
9466 if (found_something == 0)
9469 vec_validate (mask, sizeof (*tcp) - 1);
9471 tcp = (tcp_header_t *) mask;
9473 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
9474 foreach_tcp_proto_field;
9482 unformat_udp_mask (unformat_input_t * input, va_list * args)
9484 u8 **maskp = va_arg (*args, u8 **);
9486 u8 found_something = 0;
9489 #define _(a) u8 a=0;
9490 foreach_udp_proto_field;
9493 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9496 #define _(a) else if (unformat (input, #a)) a=1;
9497 foreach_udp_proto_field
9503 #define _(a) found_something += a;
9504 foreach_udp_proto_field;
9507 if (found_something == 0)
9510 vec_validate (mask, sizeof (*udp) - 1);
9512 udp = (udp_header_t *) mask;
9514 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
9515 foreach_udp_proto_field;
9523 unformat_l4_mask (unformat_input_t * input, va_list * args)
9525 u8 **maskp = va_arg (*args, u8 **);
9526 u16 src_port = 0, dst_port = 0;
9527 tcpudp_header_t *tcpudp;
9529 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9531 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9533 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9535 else if (unformat (input, "src_port"))
9537 else if (unformat (input, "dst_port"))
9543 if (!src_port && !dst_port)
9547 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9549 tcpudp = (tcpudp_header_t *) mask;
9550 tcpudp->src_port = src_port;
9551 tcpudp->dst_port = dst_port;
9559 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9561 u8 **maskp = va_arg (*args, u8 **);
9563 u8 found_something = 0;
9566 #define _(a) u8 a=0;
9567 foreach_ip4_proto_field;
9573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9575 if (unformat (input, "version"))
9577 else if (unformat (input, "hdr_length"))
9579 else if (unformat (input, "src"))
9581 else if (unformat (input, "dst"))
9583 else if (unformat (input, "proto"))
9586 #define _(a) else if (unformat (input, #a)) a=1;
9587 foreach_ip4_proto_field
9593 #define _(a) found_something += a;
9594 foreach_ip4_proto_field;
9597 if (found_something == 0)
9600 vec_validate (mask, sizeof (*ip) - 1);
9602 ip = (ip4_header_t *) mask;
9604 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9605 foreach_ip4_proto_field;
9608 ip->ip_version_and_header_length = 0;
9611 ip->ip_version_and_header_length |= 0xF0;
9614 ip->ip_version_and_header_length |= 0x0F;
9620 #define foreach_ip6_proto_field \
9628 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9630 u8 **maskp = va_arg (*args, u8 **);
9632 u8 found_something = 0;
9634 u32 ip_version_traffic_class_and_flow_label;
9636 #define _(a) u8 a=0;
9637 foreach_ip6_proto_field;
9640 u8 traffic_class = 0;
9643 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9645 if (unformat (input, "version"))
9647 else if (unformat (input, "traffic-class"))
9649 else if (unformat (input, "flow-label"))
9651 else if (unformat (input, "src"))
9653 else if (unformat (input, "dst"))
9655 else if (unformat (input, "proto"))
9658 #define _(a) else if (unformat (input, #a)) a=1;
9659 foreach_ip6_proto_field
9665 #define _(a) found_something += a;
9666 foreach_ip6_proto_field;
9669 if (found_something == 0)
9672 vec_validate (mask, sizeof (*ip) - 1);
9674 ip = (ip6_header_t *) mask;
9676 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
9677 foreach_ip6_proto_field;
9680 ip_version_traffic_class_and_flow_label = 0;
9683 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9686 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9689 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9691 ip->ip_version_traffic_class_and_flow_label =
9692 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9699 unformat_l3_mask (unformat_input_t * input, va_list * args)
9701 u8 **maskp = va_arg (*args, u8 **);
9703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9705 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9707 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9716 unformat_l2_mask (unformat_input_t * input, va_list * args)
9718 u8 **maskp = va_arg (*args, u8 **);
9733 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9735 if (unformat (input, "src"))
9737 else if (unformat (input, "dst"))
9739 else if (unformat (input, "proto"))
9741 else if (unformat (input, "tag1"))
9743 else if (unformat (input, "tag2"))
9745 else if (unformat (input, "ignore-tag1"))
9747 else if (unformat (input, "ignore-tag2"))
9749 else if (unformat (input, "cos1"))
9751 else if (unformat (input, "cos2"))
9753 else if (unformat (input, "dot1q"))
9755 else if (unformat (input, "dot1ad"))
9760 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9761 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9764 if (tag1 || ignore_tag1 || cos1 || dot1q)
9766 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9769 vec_validate (mask, len - 1);
9772 clib_memset (mask, 0xff, 6);
9775 clib_memset (mask + 6, 0xff, 6);
9779 /* inner vlan tag */
9788 mask[21] = mask[20] = 0xff;
9809 mask[16] = mask[17] = 0xff;
9819 mask[12] = mask[13] = 0xff;
9826 unformat_classify_mask (unformat_input_t * input, va_list * args)
9828 u8 **maskp = va_arg (*args, u8 **);
9829 u32 *skipp = va_arg (*args, u32 *);
9830 u32 *matchp = va_arg (*args, u32 *);
9838 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9840 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9842 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9844 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9846 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9860 if (mask || l2 || l3 || l4)
9864 /* "With a free Ethernet header in every package" */
9866 vec_validate (l2, 13);
9870 vec_append (mask, l3);
9875 vec_append (mask, l4);
9880 /* Scan forward looking for the first significant mask octet */
9881 for (i = 0; i < vec_len (mask); i++)
9885 /* compute (skip, match) params */
9886 *skipp = i / sizeof (u32x4);
9887 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9889 /* Pad mask to an even multiple of the vector size */
9890 while (vec_len (mask) % sizeof (u32x4))
9893 match = vec_len (mask) / sizeof (u32x4);
9895 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9897 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9898 if (*tmp || *(tmp + 1))
9903 clib_warning ("BUG: match 0");
9905 _vec_len (mask) = match * sizeof (u32x4);
9915 #endif /* VPP_API_TEST_BUILTIN */
9917 #define foreach_l2_next \
9919 _(ethernet, ETHERNET_INPUT) \
9924 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9926 u32 *miss_next_indexp = va_arg (*args, u32 *);
9931 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9935 if (unformat (input, "%d", &tmp))
9944 *miss_next_indexp = next_index;
9948 #define foreach_ip_next \
9954 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
9956 u32 *miss_next_indexp = va_arg (*args, u32 *);
9961 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
9965 if (unformat (input, "%d", &tmp))
9974 *miss_next_indexp = next_index;
9978 #define foreach_acl_next \
9982 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
9984 u32 *miss_next_indexp = va_arg (*args, u32 *);
9989 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
9993 if (unformat (input, "permit"))
9998 else if (unformat (input, "%d", &tmp))
10007 *miss_next_indexp = next_index;
10012 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10014 u32 *r = va_arg (*args, u32 *);
10016 if (unformat (input, "conform-color"))
10017 *r = POLICE_CONFORM;
10018 else if (unformat (input, "exceed-color"))
10019 *r = POLICE_EXCEED;
10027 api_classify_add_del_table (vat_main_t * vam)
10029 unformat_input_t *i = vam->input;
10030 vl_api_classify_add_del_table_t *mp;
10037 u32 table_index = ~0;
10038 u32 next_table_index = ~0;
10039 u32 miss_next_index = ~0;
10040 u32 memory_size = 32 << 20;
10042 u32 current_data_flag = 0;
10043 int current_data_offset = 0;
10046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10048 if (unformat (i, "del"))
10050 else if (unformat (i, "del-chain"))
10055 else if (unformat (i, "buckets %d", &nbuckets))
10057 else if (unformat (i, "memory_size %d", &memory_size))
10059 else if (unformat (i, "skip %d", &skip))
10061 else if (unformat (i, "match %d", &match))
10063 else if (unformat (i, "table %d", &table_index))
10065 else if (unformat (i, "mask %U", unformat_classify_mask,
10066 &mask, &skip, &match))
10068 else if (unformat (i, "next-table %d", &next_table_index))
10070 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10073 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10076 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10079 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10081 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10087 if (is_add && mask == 0)
10089 errmsg ("Mask required");
10093 if (is_add && skip == ~0)
10095 errmsg ("skip count required");
10099 if (is_add && match == ~0)
10101 errmsg ("match count required");
10105 if (!is_add && table_index == ~0)
10107 errmsg ("table index required for delete");
10111 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10113 mp->is_add = is_add;
10114 mp->del_chain = del_chain;
10115 mp->table_index = ntohl (table_index);
10116 mp->nbuckets = ntohl (nbuckets);
10117 mp->memory_size = ntohl (memory_size);
10118 mp->skip_n_vectors = ntohl (skip);
10119 mp->match_n_vectors = ntohl (match);
10120 mp->next_table_index = ntohl (next_table_index);
10121 mp->miss_next_index = ntohl (miss_next_index);
10122 mp->current_data_flag = ntohl (current_data_flag);
10123 mp->current_data_offset = ntohl (current_data_offset);
10124 mp->mask_len = ntohl (vec_len (mask));
10125 clib_memcpy (mp->mask, mask, vec_len (mask));
10134 #if VPP_API_TEST_BUILTIN == 0
10136 unformat_l4_match (unformat_input_t * input, va_list * args)
10138 u8 **matchp = va_arg (*args, u8 **);
10140 u8 *proto_header = 0;
10146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10148 if (unformat (input, "src_port %d", &src_port))
10150 else if (unformat (input, "dst_port %d", &dst_port))
10156 h.src_port = clib_host_to_net_u16 (src_port);
10157 h.dst_port = clib_host_to_net_u16 (dst_port);
10158 vec_validate (proto_header, sizeof (h) - 1);
10159 memcpy (proto_header, &h, sizeof (h));
10161 *matchp = proto_header;
10167 unformat_ip4_match (unformat_input_t * input, va_list * args)
10169 u8 **matchp = va_arg (*args, u8 **);
10174 int hdr_length = 0;
10175 u32 hdr_length_val;
10176 int src = 0, dst = 0;
10177 ip4_address_t src_val, dst_val;
10184 int fragment_id = 0;
10185 u32 fragment_id_val;
10191 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10193 if (unformat (input, "version %d", &version_val))
10195 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10197 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10199 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10201 else if (unformat (input, "proto %d", &proto_val))
10203 else if (unformat (input, "tos %d", &tos_val))
10205 else if (unformat (input, "length %d", &length_val))
10207 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10209 else if (unformat (input, "ttl %d", &ttl_val))
10211 else if (unformat (input, "checksum %d", &checksum_val))
10217 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10218 + ttl + checksum == 0)
10222 * Aligned because we use the real comparison functions
10224 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10226 ip = (ip4_header_t *) match;
10228 /* These are realistically matched in practice */
10230 ip->src_address.as_u32 = src_val.as_u32;
10233 ip->dst_address.as_u32 = dst_val.as_u32;
10236 ip->protocol = proto_val;
10239 /* These are not, but they're included for completeness */
10241 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10244 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10250 ip->length = clib_host_to_net_u16 (length_val);
10256 ip->checksum = clib_host_to_net_u16 (checksum_val);
10263 unformat_ip6_match (unformat_input_t * input, va_list * args)
10265 u8 **matchp = va_arg (*args, u8 **);
10270 u8 traffic_class = 0;
10271 u32 traffic_class_val = 0;
10274 int src = 0, dst = 0;
10275 ip6_address_t src_val, dst_val;
10278 int payload_length = 0;
10279 u32 payload_length_val;
10282 u32 ip_version_traffic_class_and_flow_label;
10284 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10286 if (unformat (input, "version %d", &version_val))
10288 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10290 else if (unformat (input, "flow_label %d", &flow_label_val))
10292 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10294 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10296 else if (unformat (input, "proto %d", &proto_val))
10298 else if (unformat (input, "payload_length %d", &payload_length_val))
10299 payload_length = 1;
10300 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10306 if (version + traffic_class + flow_label + src + dst + proto +
10307 payload_length + hop_limit == 0)
10311 * Aligned because we use the real comparison functions
10313 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10315 ip = (ip6_header_t *) match;
10318 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10321 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10324 ip->protocol = proto_val;
10326 ip_version_traffic_class_and_flow_label = 0;
10329 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10332 ip_version_traffic_class_and_flow_label |=
10333 (traffic_class_val & 0xFF) << 20;
10336 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10338 ip->ip_version_traffic_class_and_flow_label =
10339 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10341 if (payload_length)
10342 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10345 ip->hop_limit = hop_limit_val;
10352 unformat_l3_match (unformat_input_t * input, va_list * args)
10354 u8 **matchp = va_arg (*args, u8 **);
10356 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10358 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10360 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10369 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10371 u8 *tagp = va_arg (*args, u8 *);
10374 if (unformat (input, "%d", &tag))
10376 tagp[0] = (tag >> 8) & 0x0F;
10377 tagp[1] = tag & 0xFF;
10385 unformat_l2_match (unformat_input_t * input, va_list * args)
10387 u8 **matchp = va_arg (*args, u8 **);
10400 u8 ignore_tag1 = 0;
10401 u8 ignore_tag2 = 0;
10407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10409 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10412 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10414 else if (unformat (input, "proto %U",
10415 unformat_ethernet_type_host_byte_order, &proto_val))
10417 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10419 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10421 else if (unformat (input, "ignore-tag1"))
10423 else if (unformat (input, "ignore-tag2"))
10425 else if (unformat (input, "cos1 %d", &cos1_val))
10427 else if (unformat (input, "cos2 %d", &cos2_val))
10432 if ((src + dst + proto + tag1 + tag2 +
10433 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10436 if (tag1 || ignore_tag1 || cos1)
10438 if (tag2 || ignore_tag2 || cos2)
10441 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10444 clib_memcpy (match, dst_val, 6);
10447 clib_memcpy (match + 6, src_val, 6);
10451 /* inner vlan tag */
10452 match[19] = tag2_val[1];
10453 match[18] = tag2_val[0];
10455 match[18] |= (cos2_val & 0x7) << 5;
10458 match[21] = proto_val & 0xff;
10459 match[20] = proto_val >> 8;
10463 match[15] = tag1_val[1];
10464 match[14] = tag1_val[0];
10467 match[14] |= (cos1_val & 0x7) << 5;
10473 match[15] = tag1_val[1];
10474 match[14] = tag1_val[0];
10477 match[17] = proto_val & 0xff;
10478 match[16] = proto_val >> 8;
10481 match[14] |= (cos1_val & 0x7) << 5;
10487 match[18] |= (cos2_val & 0x7) << 5;
10489 match[14] |= (cos1_val & 0x7) << 5;
10492 match[13] = proto_val & 0xff;
10493 match[12] = proto_val >> 8;
10501 unformat_qos_source (unformat_input_t * input, va_list * args)
10503 int *qs = va_arg (*args, int *);
10505 if (unformat (input, "ip"))
10506 *qs = QOS_SOURCE_IP;
10507 else if (unformat (input, "mpls"))
10508 *qs = QOS_SOURCE_MPLS;
10509 else if (unformat (input, "ext"))
10510 *qs = QOS_SOURCE_EXT;
10511 else if (unformat (input, "vlan"))
10512 *qs = QOS_SOURCE_VLAN;
10521 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10523 u8 **matchp = va_arg (*args, u8 **);
10524 u32 skip_n_vectors = va_arg (*args, u32);
10525 u32 match_n_vectors = va_arg (*args, u32);
10532 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10534 if (unformat (input, "hex %U", unformat_hex_string, &match))
10536 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10538 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10540 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10554 if (match || l2 || l3 || l4)
10556 if (l2 || l3 || l4)
10558 /* "Win a free Ethernet header in every packet" */
10560 vec_validate_aligned (l2, 13, sizeof (u32x4));
10564 vec_append_aligned (match, l3, sizeof (u32x4));
10569 vec_append_aligned (match, l4, sizeof (u32x4));
10574 /* Make sure the vector is big enough even if key is all 0's */
10575 vec_validate_aligned
10576 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10579 /* Set size, include skipped vectors */
10580 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10591 api_classify_add_del_session (vat_main_t * vam)
10593 unformat_input_t *i = vam->input;
10594 vl_api_classify_add_del_session_t *mp;
10596 u32 table_index = ~0;
10597 u32 hit_next_index = ~0;
10598 u32 opaque_index = ~0;
10601 u32 skip_n_vectors = 0;
10602 u32 match_n_vectors = 0;
10608 * Warning: you have to supply skip_n and match_n
10609 * because the API client cant simply look at the classify
10613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10615 if (unformat (i, "del"))
10617 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10620 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10623 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10626 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10628 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10630 else if (unformat (i, "opaque-index %d", &opaque_index))
10632 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10634 else if (unformat (i, "match_n %d", &match_n_vectors))
10636 else if (unformat (i, "match %U", api_unformat_classify_match,
10637 &match, skip_n_vectors, match_n_vectors))
10639 else if (unformat (i, "advance %d", &advance))
10641 else if (unformat (i, "table-index %d", &table_index))
10643 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10645 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10647 else if (unformat (i, "action %d", &action))
10649 else if (unformat (i, "metadata %d", &metadata))
10655 if (table_index == ~0)
10657 errmsg ("Table index required");
10661 if (is_add && match == 0)
10663 errmsg ("Match value required");
10667 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10669 mp->is_add = is_add;
10670 mp->table_index = ntohl (table_index);
10671 mp->hit_next_index = ntohl (hit_next_index);
10672 mp->opaque_index = ntohl (opaque_index);
10673 mp->advance = ntohl (advance);
10674 mp->action = action;
10675 mp->metadata = ntohl (metadata);
10676 mp->match_len = ntohl (vec_len (match));
10677 clib_memcpy (mp->match, match, vec_len (match));
10686 api_classify_set_interface_ip_table (vat_main_t * vam)
10688 unformat_input_t *i = vam->input;
10689 vl_api_classify_set_interface_ip_table_t *mp;
10691 int sw_if_index_set;
10692 u32 table_index = ~0;
10696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10698 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10699 sw_if_index_set = 1;
10700 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10701 sw_if_index_set = 1;
10702 else if (unformat (i, "table %d", &table_index))
10706 clib_warning ("parse error '%U'", format_unformat_error, i);
10711 if (sw_if_index_set == 0)
10713 errmsg ("missing interface name or sw_if_index");
10718 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10720 mp->sw_if_index = ntohl (sw_if_index);
10721 mp->table_index = ntohl (table_index);
10722 mp->is_ipv6 = is_ipv6;
10730 api_classify_set_interface_l2_tables (vat_main_t * vam)
10732 unformat_input_t *i = vam->input;
10733 vl_api_classify_set_interface_l2_tables_t *mp;
10735 int sw_if_index_set;
10736 u32 ip4_table_index = ~0;
10737 u32 ip6_table_index = ~0;
10738 u32 other_table_index = ~0;
10742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10745 sw_if_index_set = 1;
10746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10747 sw_if_index_set = 1;
10748 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10750 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10752 else if (unformat (i, "other-table %d", &other_table_index))
10754 else if (unformat (i, "is-input %d", &is_input))
10758 clib_warning ("parse error '%U'", format_unformat_error, i);
10763 if (sw_if_index_set == 0)
10765 errmsg ("missing interface name or sw_if_index");
10770 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10772 mp->sw_if_index = ntohl (sw_if_index);
10773 mp->ip4_table_index = ntohl (ip4_table_index);
10774 mp->ip6_table_index = ntohl (ip6_table_index);
10775 mp->other_table_index = ntohl (other_table_index);
10776 mp->is_input = (u8) is_input;
10784 api_set_ipfix_exporter (vat_main_t * vam)
10786 unformat_input_t *i = vam->input;
10787 vl_api_set_ipfix_exporter_t *mp;
10788 ip4_address_t collector_address;
10789 u8 collector_address_set = 0;
10790 u32 collector_port = ~0;
10791 ip4_address_t src_address;
10792 u8 src_address_set = 0;
10795 u32 template_interval = ~0;
10796 u8 udp_checksum = 0;
10799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10801 if (unformat (i, "collector_address %U", unformat_ip4_address,
10802 &collector_address))
10803 collector_address_set = 1;
10804 else if (unformat (i, "collector_port %d", &collector_port))
10806 else if (unformat (i, "src_address %U", unformat_ip4_address,
10808 src_address_set = 1;
10809 else if (unformat (i, "vrf_id %d", &vrf_id))
10811 else if (unformat (i, "path_mtu %d", &path_mtu))
10813 else if (unformat (i, "template_interval %d", &template_interval))
10815 else if (unformat (i, "udp_checksum"))
10821 if (collector_address_set == 0)
10823 errmsg ("collector_address required");
10827 if (src_address_set == 0)
10829 errmsg ("src_address required");
10833 M (SET_IPFIX_EXPORTER, mp);
10835 memcpy (mp->collector_address.un.ip4, collector_address.data,
10836 sizeof (collector_address.data));
10837 mp->collector_port = htons ((u16) collector_port);
10838 memcpy (mp->src_address.un.ip4, src_address.data,
10839 sizeof (src_address.data));
10840 mp->vrf_id = htonl (vrf_id);
10841 mp->path_mtu = htonl (path_mtu);
10842 mp->template_interval = htonl (template_interval);
10843 mp->udp_checksum = udp_checksum;
10851 api_set_ipfix_classify_stream (vat_main_t * vam)
10853 unformat_input_t *i = vam->input;
10854 vl_api_set_ipfix_classify_stream_t *mp;
10856 u32 src_port = UDP_DST_PORT_ipfix;
10859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10861 if (unformat (i, "domain %d", &domain_id))
10863 else if (unformat (i, "src_port %d", &src_port))
10867 errmsg ("unknown input `%U'", format_unformat_error, i);
10872 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10874 mp->domain_id = htonl (domain_id);
10875 mp->src_port = htons ((u16) src_port);
10883 api_ipfix_classify_table_add_del (vat_main_t * vam)
10885 unformat_input_t *i = vam->input;
10886 vl_api_ipfix_classify_table_add_del_t *mp;
10888 u32 classify_table_index = ~0;
10890 u8 transport_protocol = 255;
10893 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10895 if (unformat (i, "add"))
10897 else if (unformat (i, "del"))
10899 else if (unformat (i, "table %d", &classify_table_index))
10901 else if (unformat (i, "ip4"))
10903 else if (unformat (i, "ip6"))
10905 else if (unformat (i, "tcp"))
10906 transport_protocol = 6;
10907 else if (unformat (i, "udp"))
10908 transport_protocol = 17;
10911 errmsg ("unknown input `%U'", format_unformat_error, i);
10918 errmsg ("expecting: add|del");
10921 if (classify_table_index == ~0)
10923 errmsg ("classifier table not specified");
10926 if (ip_version == 0)
10928 errmsg ("IP version not specified");
10932 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10934 mp->is_add = is_add;
10935 mp->table_id = htonl (classify_table_index);
10936 mp->ip_version = ip_version;
10937 mp->transport_protocol = transport_protocol;
10945 api_get_node_index (vat_main_t * vam)
10947 unformat_input_t *i = vam->input;
10948 vl_api_get_node_index_t *mp;
10952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10954 if (unformat (i, "node %s", &name))
10961 errmsg ("node name required");
10964 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10966 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
10970 M (GET_NODE_INDEX, mp);
10971 clib_memcpy (mp->node_name, name, vec_len (name));
10980 api_get_next_index (vat_main_t * vam)
10982 unformat_input_t *i = vam->input;
10983 vl_api_get_next_index_t *mp;
10984 u8 *node_name = 0, *next_node_name = 0;
10987 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10989 if (unformat (i, "node-name %s", &node_name))
10991 else if (unformat (i, "next-node-name %s", &next_node_name))
10995 if (node_name == 0)
10997 errmsg ("node name required");
11000 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11002 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11006 if (next_node_name == 0)
11008 errmsg ("next node name required");
11011 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11013 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11017 M (GET_NEXT_INDEX, mp);
11018 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11019 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11020 vec_free (node_name);
11021 vec_free (next_node_name);
11029 api_add_node_next (vat_main_t * vam)
11031 unformat_input_t *i = vam->input;
11032 vl_api_add_node_next_t *mp;
11037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11039 if (unformat (i, "node %s", &name))
11041 else if (unformat (i, "next %s", &next))
11048 errmsg ("node name required");
11051 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11053 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11058 errmsg ("next node required");
11061 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11063 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11067 M (ADD_NODE_NEXT, mp);
11068 clib_memcpy (mp->node_name, name, vec_len (name));
11069 clib_memcpy (mp->next_name, next, vec_len (next));
11079 api_l2tpv3_create_tunnel (vat_main_t * vam)
11081 unformat_input_t *i = vam->input;
11082 ip6_address_t client_address, our_address;
11083 int client_address_set = 0;
11084 int our_address_set = 0;
11085 u32 local_session_id = 0;
11086 u32 remote_session_id = 0;
11087 u64 local_cookie = 0;
11088 u64 remote_cookie = 0;
11089 u8 l2_sublayer_present = 0;
11090 vl_api_l2tpv3_create_tunnel_t *mp;
11093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11095 if (unformat (i, "client_address %U", unformat_ip6_address,
11097 client_address_set = 1;
11098 else if (unformat (i, "our_address %U", unformat_ip6_address,
11100 our_address_set = 1;
11101 else if (unformat (i, "local_session_id %d", &local_session_id))
11103 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11105 else if (unformat (i, "local_cookie %lld", &local_cookie))
11107 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11109 else if (unformat (i, "l2-sublayer-present"))
11110 l2_sublayer_present = 1;
11115 if (client_address_set == 0)
11117 errmsg ("client_address required");
11121 if (our_address_set == 0)
11123 errmsg ("our_address required");
11127 M (L2TPV3_CREATE_TUNNEL, mp);
11129 clib_memcpy (mp->client_address.un.ip6, client_address.as_u8,
11130 sizeof (ip6_address_t));
11132 clib_memcpy (mp->our_address.un.ip6, our_address.as_u8,
11133 sizeof (ip6_address_t));
11135 mp->local_session_id = ntohl (local_session_id);
11136 mp->remote_session_id = ntohl (remote_session_id);
11137 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11138 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11139 mp->l2_sublayer_present = l2_sublayer_present;
11147 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11149 unformat_input_t *i = vam->input;
11151 u8 sw_if_index_set = 0;
11152 u64 new_local_cookie = 0;
11153 u64 new_remote_cookie = 0;
11154 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11159 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11160 sw_if_index_set = 1;
11161 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11162 sw_if_index_set = 1;
11163 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11165 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11171 if (sw_if_index_set == 0)
11173 errmsg ("missing interface name or sw_if_index");
11177 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11179 mp->sw_if_index = ntohl (sw_if_index);
11180 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11181 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11189 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11191 unformat_input_t *i = vam->input;
11192 vl_api_l2tpv3_interface_enable_disable_t *mp;
11194 u8 sw_if_index_set = 0;
11195 u8 enable_disable = 1;
11198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11200 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11201 sw_if_index_set = 1;
11202 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11203 sw_if_index_set = 1;
11204 else if (unformat (i, "enable"))
11205 enable_disable = 1;
11206 else if (unformat (i, "disable"))
11207 enable_disable = 0;
11212 if (sw_if_index_set == 0)
11214 errmsg ("missing interface name or sw_if_index");
11218 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11220 mp->sw_if_index = ntohl (sw_if_index);
11221 mp->enable_disable = enable_disable;
11229 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11231 unformat_input_t *i = vam->input;
11232 vl_api_l2tpv3_set_lookup_key_t *mp;
11236 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11238 if (unformat (i, "lookup_v6_src"))
11239 key = L2T_LOOKUP_SRC_ADDRESS;
11240 else if (unformat (i, "lookup_v6_dst"))
11241 key = L2T_LOOKUP_DST_ADDRESS;
11242 else if (unformat (i, "lookup_session_id"))
11243 key = L2T_LOOKUP_SESSION_ID;
11248 if (key == (u8) ~ 0)
11250 errmsg ("l2tp session lookup key unset");
11254 M (L2TPV3_SET_LOOKUP_KEY, mp);
11263 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11264 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11266 vat_main_t *vam = &vat_main;
11268 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11269 format_ip6_address, mp->our_address,
11270 format_ip6_address, mp->client_address,
11271 clib_net_to_host_u32 (mp->sw_if_index));
11274 " local cookies %016llx %016llx remote cookie %016llx",
11275 clib_net_to_host_u64 (mp->local_cookie[0]),
11276 clib_net_to_host_u64 (mp->local_cookie[1]),
11277 clib_net_to_host_u64 (mp->remote_cookie));
11279 print (vam->ofp, " local session-id %d remote session-id %d",
11280 clib_net_to_host_u32 (mp->local_session_id),
11281 clib_net_to_host_u32 (mp->remote_session_id));
11283 print (vam->ofp, " l2 specific sublayer %s\n",
11284 mp->l2_sublayer_present ? "preset" : "absent");
11288 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11289 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11291 vat_main_t *vam = &vat_main;
11292 vat_json_node_t *node = NULL;
11293 struct in6_addr addr;
11295 if (VAT_JSON_ARRAY != vam->json_tree.type)
11297 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11298 vat_json_init_array (&vam->json_tree);
11300 node = vat_json_array_add (&vam->json_tree);
11302 vat_json_init_object (node);
11304 clib_memcpy (&addr, mp->our_address.un.ip6, sizeof (addr));
11305 vat_json_object_add_ip6 (node, "our_address", addr);
11306 clib_memcpy (&addr, mp->client_address.un.ip6, sizeof (addr));
11307 vat_json_object_add_ip6 (node, "client_address", addr);
11309 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11310 vat_json_init_array (lc);
11311 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11312 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11313 vat_json_object_add_uint (node, "remote_cookie",
11314 clib_net_to_host_u64 (mp->remote_cookie));
11316 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11317 vat_json_object_add_uint (node, "local_session_id",
11318 clib_net_to_host_u32 (mp->local_session_id));
11319 vat_json_object_add_uint (node, "remote_session_id",
11320 clib_net_to_host_u32 (mp->remote_session_id));
11321 vat_json_object_add_string_copy (node, "l2_sublayer",
11322 mp->l2_sublayer_present ? (u8 *) "present"
11323 : (u8 *) "absent");
11327 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11329 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11330 vl_api_control_ping_t *mp_ping;
11333 /* Get list of l2tpv3-tunnel interfaces */
11334 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11337 /* Use a control ping for synchronization */
11338 MPING (CONTROL_PING, mp_ping);
11346 static void vl_api_sw_interface_tap_v2_details_t_handler
11347 (vl_api_sw_interface_tap_v2_details_t * mp)
11349 vat_main_t *vam = &vat_main;
11352 format (0, "%U/%d", format_ip4_address, mp->host_ip4_prefix.address,
11353 mp->host_ip4_prefix.len);
11355 format (0, "%U/%d", format_ip6_address, mp->host_ip6_prefix.address,
11356 mp->host_ip6_prefix.len);
11359 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
11360 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
11361 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11362 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
11363 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
11369 static void vl_api_sw_interface_tap_v2_details_t_handler_json
11370 (vl_api_sw_interface_tap_v2_details_t * mp)
11372 vat_main_t *vam = &vat_main;
11373 vat_json_node_t *node = NULL;
11375 if (VAT_JSON_ARRAY != vam->json_tree.type)
11377 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11378 vat_json_init_array (&vam->json_tree);
11380 node = vat_json_array_add (&vam->json_tree);
11382 vat_json_init_object (node);
11383 vat_json_object_add_uint (node, "id", ntohl (mp->id));
11384 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11385 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
11386 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11387 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11388 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11389 vat_json_object_add_string_copy (node, "host_mac_addr",
11390 format (0, "%U", format_ethernet_address,
11391 &mp->host_mac_addr));
11392 vat_json_object_add_string_copy (node, "host_namespace",
11393 mp->host_namespace);
11394 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
11395 vat_json_object_add_string_copy (node, "host_ip4_addr",
11396 format (0, "%U/%d", format_ip4_address,
11397 mp->host_ip4_prefix.address,
11398 mp->host_ip4_prefix.len));
11399 vat_json_object_add_string_copy (node, "host_ip6_prefix",
11400 format (0, "%U/%d", format_ip6_address,
11401 mp->host_ip6_prefix.address,
11402 mp->host_ip6_prefix.len));
11407 api_sw_interface_tap_v2_dump (vat_main_t * vam)
11409 vl_api_sw_interface_tap_v2_dump_t *mp;
11410 vl_api_control_ping_t *mp_ping;
11414 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
11415 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
11416 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
11419 /* Get list of tap interfaces */
11420 M (SW_INTERFACE_TAP_V2_DUMP, mp);
11423 /* Use a control ping for synchronization */
11424 MPING (CONTROL_PING, mp_ping);
11431 static void vl_api_sw_interface_virtio_pci_details_t_handler
11432 (vl_api_sw_interface_virtio_pci_details_t * mp)
11434 vat_main_t *vam = &vat_main;
11449 addr.domain = ntohs (mp->pci_addr.domain);
11450 addr.bus = mp->pci_addr.bus;
11451 addr.slot = mp->pci_addr.slot;
11452 addr.function = mp->pci_addr.function;
11454 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
11455 addr.slot, addr.function);
11458 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
11459 pci_addr, ntohl (mp->sw_if_index),
11460 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
11461 format_ethernet_address, mp->mac_addr,
11462 clib_net_to_host_u64 (mp->features));
11463 vec_free (pci_addr);
11466 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
11467 (vl_api_sw_interface_virtio_pci_details_t * mp)
11469 vat_main_t *vam = &vat_main;
11470 vat_json_node_t *node = NULL;
11471 vlib_pci_addr_t pci_addr;
11473 if (VAT_JSON_ARRAY != vam->json_tree.type)
11475 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11476 vat_json_init_array (&vam->json_tree);
11478 node = vat_json_array_add (&vam->json_tree);
11480 pci_addr.domain = ntohs (mp->pci_addr.domain);
11481 pci_addr.bus = mp->pci_addr.bus;
11482 pci_addr.slot = mp->pci_addr.slot;
11483 pci_addr.function = mp->pci_addr.function;
11485 vat_json_init_object (node);
11486 vat_json_object_add_uint (node, "pci-addr", pci_addr.as_u32);
11487 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11488 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
11489 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
11490 vat_json_object_add_uint (node, "features",
11491 clib_net_to_host_u64 (mp->features));
11492 vat_json_object_add_string_copy (node, "mac_addr",
11493 format (0, "%U", format_ethernet_address,
11498 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
11500 vl_api_sw_interface_virtio_pci_dump_t *mp;
11501 vl_api_control_ping_t *mp_ping;
11505 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
11506 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
11507 "mac_addr", "features");
11509 /* Get list of tap interfaces */
11510 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
11513 /* Use a control ping for synchronization */
11514 MPING (CONTROL_PING, mp_ping);
11522 api_vxlan_offload_rx (vat_main_t * vam)
11524 unformat_input_t *line_input = vam->input;
11525 vl_api_vxlan_offload_rx_t *mp;
11526 u32 hw_if_index = ~0, rx_if_index = ~0;
11530 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11532 if (unformat (line_input, "del"))
11534 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
11537 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
11539 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
11542 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
11546 errmsg ("parse error '%U'", format_unformat_error, line_input);
11551 if (hw_if_index == ~0)
11553 errmsg ("no hw interface");
11557 if (rx_if_index == ~0)
11559 errmsg ("no rx tunnel");
11563 M (VXLAN_OFFLOAD_RX, mp);
11565 mp->hw_if_index = ntohl (hw_if_index);
11566 mp->sw_if_index = ntohl (rx_if_index);
11567 mp->enable = is_add;
11574 static uword unformat_vxlan_decap_next
11575 (unformat_input_t * input, va_list * args)
11577 u32 *result = va_arg (*args, u32 *);
11580 if (unformat (input, "l2"))
11581 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11582 else if (unformat (input, "%d", &tmp))
11590 api_vxlan_add_del_tunnel (vat_main_t * vam)
11592 unformat_input_t *line_input = vam->input;
11593 vl_api_vxlan_add_del_tunnel_t *mp;
11594 ip46_address_t src, dst;
11596 u8 ipv4_set = 0, ipv6_set = 0;
11601 u32 mcast_sw_if_index = ~0;
11602 u32 encap_vrf_id = 0;
11603 u32 decap_next_index = ~0;
11607 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11608 clib_memset (&src, 0, sizeof src);
11609 clib_memset (&dst, 0, sizeof dst);
11611 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11613 if (unformat (line_input, "del"))
11615 else if (unformat (line_input, "instance %d", &instance))
11618 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11624 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11630 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11636 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11641 else if (unformat (line_input, "group %U %U",
11642 unformat_ip4_address, &dst.ip4,
11643 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11645 grp_set = dst_set = 1;
11648 else if (unformat (line_input, "group %U",
11649 unformat_ip4_address, &dst.ip4))
11651 grp_set = dst_set = 1;
11654 else if (unformat (line_input, "group %U %U",
11655 unformat_ip6_address, &dst.ip6,
11656 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11658 grp_set = dst_set = 1;
11661 else if (unformat (line_input, "group %U",
11662 unformat_ip6_address, &dst.ip6))
11664 grp_set = dst_set = 1;
11668 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11670 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11672 else if (unformat (line_input, "decap-next %U",
11673 unformat_vxlan_decap_next, &decap_next_index))
11675 else if (unformat (line_input, "vni %d", &vni))
11679 errmsg ("parse error '%U'", format_unformat_error, line_input);
11686 errmsg ("tunnel src address not specified");
11691 errmsg ("tunnel dst address not specified");
11695 if (grp_set && !ip46_address_is_multicast (&dst))
11697 errmsg ("tunnel group address not multicast");
11700 if (grp_set && mcast_sw_if_index == ~0)
11702 errmsg ("tunnel nonexistent multicast device");
11705 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11707 errmsg ("tunnel dst address must be unicast");
11712 if (ipv4_set && ipv6_set)
11714 errmsg ("both IPv4 and IPv6 addresses specified");
11718 if ((vni == 0) || (vni >> 24))
11720 errmsg ("vni not specified or out of range");
11724 M (VXLAN_ADD_DEL_TUNNEL, mp);
11728 clib_memcpy (mp->src_address.un.ip6, &src.ip6, sizeof (src.ip6));
11729 clib_memcpy (mp->dst_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
11733 clib_memcpy (mp->src_address.un.ip4, &src.ip4, sizeof (src.ip4));
11734 clib_memcpy (mp->dst_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
11736 mp->src_address.af = ipv6_set;
11737 mp->dst_address.af = ipv6_set;
11739 mp->instance = htonl (instance);
11740 mp->encap_vrf_id = ntohl (encap_vrf_id);
11741 mp->decap_next_index = ntohl (decap_next_index);
11742 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11743 mp->vni = ntohl (vni);
11744 mp->is_add = is_add;
11751 static void vl_api_vxlan_tunnel_details_t_handler
11752 (vl_api_vxlan_tunnel_details_t * mp)
11754 vat_main_t *vam = &vat_main;
11755 ip46_address_t src =
11756 to_ip46 (mp->dst_address.af, (u8 *) & mp->dst_address.un);
11757 ip46_address_t dst =
11758 to_ip46 (mp->dst_address.af, (u8 *) & mp->src_address.un);
11760 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
11761 ntohl (mp->sw_if_index),
11762 ntohl (mp->instance),
11763 format_ip46_address, &src, IP46_TYPE_ANY,
11764 format_ip46_address, &dst, IP46_TYPE_ANY,
11765 ntohl (mp->encap_vrf_id),
11766 ntohl (mp->decap_next_index), ntohl (mp->vni),
11767 ntohl (mp->mcast_sw_if_index));
11770 static void vl_api_vxlan_tunnel_details_t_handler_json
11771 (vl_api_vxlan_tunnel_details_t * mp)
11773 vat_main_t *vam = &vat_main;
11774 vat_json_node_t *node = NULL;
11776 if (VAT_JSON_ARRAY != vam->json_tree.type)
11778 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11779 vat_json_init_array (&vam->json_tree);
11781 node = vat_json_array_add (&vam->json_tree);
11783 vat_json_init_object (node);
11784 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11786 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
11788 if (mp->src_address.af)
11790 struct in6_addr ip6;
11792 clib_memcpy (&ip6, mp->src_address.un.ip6, sizeof (ip6));
11793 vat_json_object_add_ip6 (node, "src_address", ip6);
11794 clib_memcpy (&ip6, mp->dst_address.un.ip6, sizeof (ip6));
11795 vat_json_object_add_ip6 (node, "dst_address", ip6);
11799 struct in_addr ip4;
11801 clib_memcpy (&ip4, mp->src_address.un.ip4, sizeof (ip4));
11802 vat_json_object_add_ip4 (node, "src_address", ip4);
11803 clib_memcpy (&ip4, mp->dst_address.un.ip4, sizeof (ip4));
11804 vat_json_object_add_ip4 (node, "dst_address", ip4);
11806 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11807 vat_json_object_add_uint (node, "decap_next_index",
11808 ntohl (mp->decap_next_index));
11809 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11810 vat_json_object_add_uint (node, "mcast_sw_if_index",
11811 ntohl (mp->mcast_sw_if_index));
11815 api_vxlan_tunnel_dump (vat_main_t * vam)
11817 unformat_input_t *i = vam->input;
11818 vl_api_vxlan_tunnel_dump_t *mp;
11819 vl_api_control_ping_t *mp_ping;
11821 u8 sw_if_index_set = 0;
11824 /* Parse args required to build the message */
11825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11827 if (unformat (i, "sw_if_index %d", &sw_if_index))
11828 sw_if_index_set = 1;
11833 if (sw_if_index_set == 0)
11838 if (!vam->json_output)
11840 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
11841 "sw_if_index", "instance", "src_address", "dst_address",
11842 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11845 /* Get list of vxlan-tunnel interfaces */
11846 M (VXLAN_TUNNEL_DUMP, mp);
11848 mp->sw_if_index = htonl (sw_if_index);
11852 /* Use a control ping for synchronization */
11853 MPING (CONTROL_PING, mp_ping);
11860 static uword unformat_geneve_decap_next
11861 (unformat_input_t * input, va_list * args)
11863 u32 *result = va_arg (*args, u32 *);
11866 if (unformat (input, "l2"))
11867 *result = GENEVE_INPUT_NEXT_L2_INPUT;
11868 else if (unformat (input, "%d", &tmp))
11876 api_geneve_add_del_tunnel (vat_main_t * vam)
11878 unformat_input_t *line_input = vam->input;
11879 vl_api_geneve_add_del_tunnel_t *mp;
11880 ip46_address_t src, dst;
11882 u8 ipv4_set = 0, ipv6_set = 0;
11886 u32 mcast_sw_if_index = ~0;
11887 u32 encap_vrf_id = 0;
11888 u32 decap_next_index = ~0;
11892 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11893 clib_memset (&src, 0, sizeof src);
11894 clib_memset (&dst, 0, sizeof dst);
11896 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11898 if (unformat (line_input, "del"))
11901 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11907 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11913 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11919 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11924 else if (unformat (line_input, "group %U %U",
11925 unformat_ip4_address, &dst.ip4,
11926 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11928 grp_set = dst_set = 1;
11931 else if (unformat (line_input, "group %U",
11932 unformat_ip4_address, &dst.ip4))
11934 grp_set = dst_set = 1;
11937 else if (unformat (line_input, "group %U %U",
11938 unformat_ip6_address, &dst.ip6,
11939 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11941 grp_set = dst_set = 1;
11944 else if (unformat (line_input, "group %U",
11945 unformat_ip6_address, &dst.ip6))
11947 grp_set = dst_set = 1;
11951 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11953 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11955 else if (unformat (line_input, "decap-next %U",
11956 unformat_geneve_decap_next, &decap_next_index))
11958 else if (unformat (line_input, "vni %d", &vni))
11962 errmsg ("parse error '%U'", format_unformat_error, line_input);
11969 errmsg ("tunnel src address not specified");
11974 errmsg ("tunnel dst address not specified");
11978 if (grp_set && !ip46_address_is_multicast (&dst))
11980 errmsg ("tunnel group address not multicast");
11983 if (grp_set && mcast_sw_if_index == ~0)
11985 errmsg ("tunnel nonexistent multicast device");
11988 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11990 errmsg ("tunnel dst address must be unicast");
11995 if (ipv4_set && ipv6_set)
11997 errmsg ("both IPv4 and IPv6 addresses specified");
12001 if ((vni == 0) || (vni >> 24))
12003 errmsg ("vni not specified or out of range");
12007 M (GENEVE_ADD_DEL_TUNNEL, mp);
12011 clib_memcpy (&mp->local_address.un.ip6, &src.ip6, sizeof (src.ip6));
12012 clib_memcpy (&mp->remote_address.un.ip6, &dst.ip6, sizeof (dst.ip6));
12016 clib_memcpy (&mp->local_address.un.ip4, &src.ip4, sizeof (src.ip4));
12017 clib_memcpy (&mp->remote_address.un.ip4, &dst.ip4, sizeof (dst.ip4));
12019 mp->encap_vrf_id = ntohl (encap_vrf_id);
12020 mp->decap_next_index = ntohl (decap_next_index);
12021 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12022 mp->vni = ntohl (vni);
12023 mp->is_add = is_add;
12030 static void vl_api_geneve_tunnel_details_t_handler
12031 (vl_api_geneve_tunnel_details_t * mp)
12033 vat_main_t *vam = &vat_main;
12034 ip46_address_t src = {.as_u64[0] = 0,.as_u64[1] = 0 };
12035 ip46_address_t dst = {.as_u64[0] = 0,.as_u64[1] = 0 };
12037 if (mp->src_address.af == ADDRESS_IP6)
12039 clib_memcpy (&src.ip6, &mp->src_address.un.ip6, sizeof (ip6_address_t));
12040 clib_memcpy (&dst.ip6, &mp->dst_address.un.ip6, sizeof (ip6_address_t));
12044 clib_memcpy (&src.ip4, &mp->src_address.un.ip4, sizeof (ip4_address_t));
12045 clib_memcpy (&dst.ip4, &mp->dst_address.un.ip4, sizeof (ip4_address_t));
12048 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
12049 ntohl (mp->sw_if_index),
12050 format_ip46_address, &src, IP46_TYPE_ANY,
12051 format_ip46_address, &dst, IP46_TYPE_ANY,
12052 ntohl (mp->encap_vrf_id),
12053 ntohl (mp->decap_next_index), ntohl (mp->vni),
12054 ntohl (mp->mcast_sw_if_index));
12057 static void vl_api_geneve_tunnel_details_t_handler_json
12058 (vl_api_geneve_tunnel_details_t * mp)
12060 vat_main_t *vam = &vat_main;
12061 vat_json_node_t *node = NULL;
12064 if (VAT_JSON_ARRAY != vam->json_tree.type)
12066 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12067 vat_json_init_array (&vam->json_tree);
12069 node = vat_json_array_add (&vam->json_tree);
12071 vat_json_init_object (node);
12072 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12073 is_ipv6 = mp->src_address.af == ADDRESS_IP6;
12076 struct in6_addr ip6;
12078 clib_memcpy (&ip6, &mp->src_address.un.ip6, sizeof (ip6));
12079 vat_json_object_add_ip6 (node, "src_address", ip6);
12080 clib_memcpy (&ip6, &mp->dst_address.un.ip6, sizeof (ip6));
12081 vat_json_object_add_ip6 (node, "dst_address", ip6);
12085 struct in_addr ip4;
12087 clib_memcpy (&ip4, &mp->src_address.un.ip4, sizeof (ip4));
12088 vat_json_object_add_ip4 (node, "src_address", ip4);
12089 clib_memcpy (&ip4, &mp->dst_address.un.ip4, sizeof (ip4));
12090 vat_json_object_add_ip4 (node, "dst_address", ip4);
12092 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12093 vat_json_object_add_uint (node, "decap_next_index",
12094 ntohl (mp->decap_next_index));
12095 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12096 vat_json_object_add_uint (node, "mcast_sw_if_index",
12097 ntohl (mp->mcast_sw_if_index));
12101 api_geneve_tunnel_dump (vat_main_t * vam)
12103 unformat_input_t *i = vam->input;
12104 vl_api_geneve_tunnel_dump_t *mp;
12105 vl_api_control_ping_t *mp_ping;
12107 u8 sw_if_index_set = 0;
12110 /* Parse args required to build the message */
12111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12113 if (unformat (i, "sw_if_index %d", &sw_if_index))
12114 sw_if_index_set = 1;
12119 if (sw_if_index_set == 0)
12124 if (!vam->json_output)
12126 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
12127 "sw_if_index", "local_address", "remote_address",
12128 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12131 /* Get list of geneve-tunnel interfaces */
12132 M (GENEVE_TUNNEL_DUMP, mp);
12134 mp->sw_if_index = htonl (sw_if_index);
12138 /* Use a control ping for synchronization */
12139 M (CONTROL_PING, mp_ping);
12147 api_gre_tunnel_add_del (vat_main_t * vam)
12149 unformat_input_t *line_input = vam->input;
12150 vl_api_address_t src = { }, dst =
12153 vl_api_gre_tunnel_add_del_t *mp;
12154 vl_api_gre_tunnel_type_t t_type;
12158 u32 outer_table_id = 0;
12159 u32 session_id = 0;
12163 t_type = GRE_API_TUNNEL_TYPE_L3;
12165 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12167 if (unformat (line_input, "del"))
12169 else if (unformat (line_input, "instance %d", &instance))
12171 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
12175 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
12179 else if (unformat (line_input, "outer-table-id %d", &outer_table_id))
12181 else if (unformat (line_input, "teb"))
12182 t_type = GRE_API_TUNNEL_TYPE_TEB;
12183 else if (unformat (line_input, "erspan %d", &session_id))
12184 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
12187 errmsg ("parse error '%U'", format_unformat_error, line_input);
12194 errmsg ("tunnel src address not specified");
12199 errmsg ("tunnel dst address not specified");
12203 M (GRE_TUNNEL_ADD_DEL, mp);
12205 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
12206 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
12208 mp->tunnel.instance = htonl (instance);
12209 mp->tunnel.outer_table_id = htonl (outer_table_id);
12210 mp->is_add = is_add;
12211 mp->tunnel.session_id = htons ((u16) session_id);
12212 mp->tunnel.type = htonl (t_type);
12219 static void vl_api_gre_tunnel_details_t_handler
12220 (vl_api_gre_tunnel_details_t * mp)
12222 vat_main_t *vam = &vat_main;
12224 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
12225 ntohl (mp->tunnel.sw_if_index),
12226 ntohl (mp->tunnel.instance),
12227 format_vl_api_address, &mp->tunnel.src,
12228 format_vl_api_address, &mp->tunnel.dst,
12229 mp->tunnel.type, ntohl (mp->tunnel.outer_table_id),
12230 ntohl (mp->tunnel.session_id));
12233 static void vl_api_gre_tunnel_details_t_handler_json
12234 (vl_api_gre_tunnel_details_t * mp)
12236 vat_main_t *vam = &vat_main;
12237 vat_json_node_t *node = NULL;
12239 if (VAT_JSON_ARRAY != vam->json_tree.type)
12241 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12242 vat_json_init_array (&vam->json_tree);
12244 node = vat_json_array_add (&vam->json_tree);
12246 vat_json_init_object (node);
12247 vat_json_object_add_uint (node, "sw_if_index",
12248 ntohl (mp->tunnel.sw_if_index));
12249 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
12251 vat_json_object_add_address (node, "src", &mp->tunnel.src);
12252 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
12253 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
12254 vat_json_object_add_uint (node, "outer_table_id",
12255 ntohl (mp->tunnel.outer_table_id));
12256 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
12260 api_gre_tunnel_dump (vat_main_t * vam)
12262 unformat_input_t *i = vam->input;
12263 vl_api_gre_tunnel_dump_t *mp;
12264 vl_api_control_ping_t *mp_ping;
12266 u8 sw_if_index_set = 0;
12269 /* Parse args required to build the message */
12270 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12272 if (unformat (i, "sw_if_index %d", &sw_if_index))
12273 sw_if_index_set = 1;
12278 if (sw_if_index_set == 0)
12283 if (!vam->json_output)
12285 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
12286 "sw_if_index", "instance", "src_address", "dst_address",
12287 "tunnel_type", "outer_fib_id", "session_id");
12290 /* Get list of gre-tunnel interfaces */
12291 M (GRE_TUNNEL_DUMP, mp);
12293 mp->sw_if_index = htonl (sw_if_index);
12297 /* Use a control ping for synchronization */
12298 MPING (CONTROL_PING, mp_ping);
12306 api_l2_fib_clear_table (vat_main_t * vam)
12308 // unformat_input_t * i = vam->input;
12309 vl_api_l2_fib_clear_table_t *mp;
12312 M (L2_FIB_CLEAR_TABLE, mp);
12320 api_l2_interface_efp_filter (vat_main_t * vam)
12322 unformat_input_t *i = vam->input;
12323 vl_api_l2_interface_efp_filter_t *mp;
12326 u8 sw_if_index_set = 0;
12329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12331 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12332 sw_if_index_set = 1;
12333 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12334 sw_if_index_set = 1;
12335 else if (unformat (i, "enable"))
12337 else if (unformat (i, "disable"))
12341 clib_warning ("parse error '%U'", format_unformat_error, i);
12346 if (sw_if_index_set == 0)
12348 errmsg ("missing sw_if_index");
12352 M (L2_INTERFACE_EFP_FILTER, mp);
12354 mp->sw_if_index = ntohl (sw_if_index);
12355 mp->enable_disable = enable;
12362 #define foreach_vtr_op \
12363 _("disable", L2_VTR_DISABLED) \
12364 _("push-1", L2_VTR_PUSH_1) \
12365 _("push-2", L2_VTR_PUSH_2) \
12366 _("pop-1", L2_VTR_POP_1) \
12367 _("pop-2", L2_VTR_POP_2) \
12368 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12369 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12370 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12371 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12374 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12376 unformat_input_t *i = vam->input;
12377 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12379 u8 sw_if_index_set = 0;
12382 u32 push_dot1q = 1;
12387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12389 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12390 sw_if_index_set = 1;
12391 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12392 sw_if_index_set = 1;
12393 else if (unformat (i, "vtr_op %d", &vtr_op))
12395 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12398 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12400 else if (unformat (i, "tag1 %d", &tag1))
12402 else if (unformat (i, "tag2 %d", &tag2))
12406 clib_warning ("parse error '%U'", format_unformat_error, i);
12411 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12413 errmsg ("missing vtr operation or sw_if_index");
12417 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12418 mp->sw_if_index = ntohl (sw_if_index);
12419 mp->vtr_op = ntohl (vtr_op);
12420 mp->push_dot1q = ntohl (push_dot1q);
12421 mp->tag1 = ntohl (tag1);
12422 mp->tag2 = ntohl (tag2);
12430 api_create_vhost_user_if (vat_main_t * vam)
12432 unformat_input_t *i = vam->input;
12433 vl_api_create_vhost_user_if_t *mp;
12436 u8 file_name_set = 0;
12437 u32 custom_dev_instance = ~0;
12439 u8 use_custom_mac = 0;
12440 u8 disable_mrg_rxbuf = 0;
12441 u8 disable_indirect_desc = 0;
12444 u8 enable_packed = 0;
12447 /* Shut up coverity */
12448 clib_memset (hwaddr, 0, sizeof (hwaddr));
12450 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12452 if (unformat (i, "socket %s", &file_name))
12456 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12458 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12459 use_custom_mac = 1;
12460 else if (unformat (i, "server"))
12462 else if (unformat (i, "disable_mrg_rxbuf"))
12463 disable_mrg_rxbuf = 1;
12464 else if (unformat (i, "disable_indirect_desc"))
12465 disable_indirect_desc = 1;
12466 else if (unformat (i, "gso"))
12468 else if (unformat (i, "packed"))
12470 else if (unformat (i, "tag %s", &tag))
12476 if (file_name_set == 0)
12478 errmsg ("missing socket file name");
12482 if (vec_len (file_name) > 255)
12484 errmsg ("socket file name too long");
12487 vec_add1 (file_name, 0);
12489 M (CREATE_VHOST_USER_IF, mp);
12491 mp->is_server = is_server;
12492 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
12493 mp->disable_indirect_desc = disable_indirect_desc;
12494 mp->enable_gso = enable_gso;
12495 mp->enable_packed = enable_packed;
12496 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12497 vec_free (file_name);
12498 if (custom_dev_instance != ~0)
12501 mp->custom_dev_instance = ntohl (custom_dev_instance);
12504 mp->use_custom_mac = use_custom_mac;
12505 clib_memcpy (mp->mac_address, hwaddr, 6);
12507 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12516 api_modify_vhost_user_if (vat_main_t * vam)
12518 unformat_input_t *i = vam->input;
12519 vl_api_modify_vhost_user_if_t *mp;
12522 u8 file_name_set = 0;
12523 u32 custom_dev_instance = ~0;
12524 u8 sw_if_index_set = 0;
12525 u32 sw_if_index = (u32) ~ 0;
12527 u8 enable_packed = 0;
12530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12533 sw_if_index_set = 1;
12534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12535 sw_if_index_set = 1;
12536 else if (unformat (i, "socket %s", &file_name))
12540 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12542 else if (unformat (i, "server"))
12544 else if (unformat (i, "gso"))
12546 else if (unformat (i, "packed"))
12552 if (sw_if_index_set == 0)
12554 errmsg ("missing sw_if_index or interface name");
12558 if (file_name_set == 0)
12560 errmsg ("missing socket file name");
12564 if (vec_len (file_name) > 255)
12566 errmsg ("socket file name too long");
12569 vec_add1 (file_name, 0);
12571 M (MODIFY_VHOST_USER_IF, mp);
12573 mp->sw_if_index = ntohl (sw_if_index);
12574 mp->is_server = is_server;
12575 mp->enable_gso = enable_gso;
12576 mp->enable_packed = enable_packed;
12577 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12578 vec_free (file_name);
12579 if (custom_dev_instance != ~0)
12582 mp->custom_dev_instance = ntohl (custom_dev_instance);
12591 api_delete_vhost_user_if (vat_main_t * vam)
12593 unformat_input_t *i = vam->input;
12594 vl_api_delete_vhost_user_if_t *mp;
12595 u32 sw_if_index = ~0;
12596 u8 sw_if_index_set = 0;
12599 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12601 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12602 sw_if_index_set = 1;
12603 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12604 sw_if_index_set = 1;
12609 if (sw_if_index_set == 0)
12611 errmsg ("missing sw_if_index or interface name");
12616 M (DELETE_VHOST_USER_IF, mp);
12618 mp->sw_if_index = ntohl (sw_if_index);
12625 static void vl_api_sw_interface_vhost_user_details_t_handler
12626 (vl_api_sw_interface_vhost_user_details_t * mp)
12628 vat_main_t *vam = &vat_main;
12632 clib_net_to_host_u32 (mp->features_first_32) | ((u64)
12633 clib_net_to_host_u32
12634 (mp->features_last_32) <<
12637 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12638 (char *) mp->interface_name,
12639 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12640 features, mp->is_server,
12641 ntohl (mp->num_regions), (char *) mp->sock_filename);
12642 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12645 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12646 (vl_api_sw_interface_vhost_user_details_t * mp)
12648 vat_main_t *vam = &vat_main;
12649 vat_json_node_t *node = NULL;
12651 if (VAT_JSON_ARRAY != vam->json_tree.type)
12653 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12654 vat_json_init_array (&vam->json_tree);
12656 node = vat_json_array_add (&vam->json_tree);
12658 vat_json_init_object (node);
12659 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12660 vat_json_object_add_string_copy (node, "interface_name",
12661 mp->interface_name);
12662 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12663 ntohl (mp->virtio_net_hdr_sz));
12664 vat_json_object_add_uint (node, "features_first_32",
12665 clib_net_to_host_u32 (mp->features_first_32));
12666 vat_json_object_add_uint (node, "features_last_32",
12667 clib_net_to_host_u32 (mp->features_last_32));
12668 vat_json_object_add_uint (node, "is_server", mp->is_server);
12669 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12670 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12671 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12675 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12677 unformat_input_t *i = vam->input;
12678 vl_api_sw_interface_vhost_user_dump_t *mp;
12679 vl_api_control_ping_t *mp_ping;
12681 u32 sw_if_index = ~0;
12683 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12685 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12687 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12694 "Interface name idx hdr_sz features server regions filename");
12696 /* Get list of vhost-user interfaces */
12697 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12698 mp->sw_if_index = ntohl (sw_if_index);
12701 /* Use a control ping for synchronization */
12702 MPING (CONTROL_PING, mp_ping);
12710 api_show_version (vat_main_t * vam)
12712 vl_api_show_version_t *mp;
12715 M (SHOW_VERSION, mp);
12724 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12726 unformat_input_t *line_input = vam->input;
12727 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12728 ip46_address_t local, remote;
12733 u32 mcast_sw_if_index = ~0;
12734 u32 encap_vrf_id = 0;
12735 u32 decap_vrf_id = 0;
12741 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12743 if (unformat (line_input, "del"))
12745 else if (unformat (line_input, "local %U",
12746 unformat_ip46_address, &local))
12750 else if (unformat (line_input, "remote %U",
12751 unformat_ip46_address, &remote))
12755 else if (unformat (line_input, "group %U %U",
12756 unformat_ip46_address, &remote,
12757 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12759 grp_set = remote_set = 1;
12761 else if (unformat (line_input, "group %U",
12762 unformat_ip46_address, &remote))
12764 grp_set = remote_set = 1;
12767 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12769 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12771 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12773 else if (unformat (line_input, "vni %d", &vni))
12775 else if (unformat (line_input, "next-ip4"))
12777 else if (unformat (line_input, "next-ip6"))
12779 else if (unformat (line_input, "next-ethernet"))
12781 else if (unformat (line_input, "next-nsh"))
12785 errmsg ("parse error '%U'", format_unformat_error, line_input);
12790 if (local_set == 0)
12792 errmsg ("tunnel local address not specified");
12795 if (remote_set == 0)
12797 errmsg ("tunnel remote address not specified");
12800 if (grp_set && mcast_sw_if_index == ~0)
12802 errmsg ("tunnel nonexistent multicast device");
12805 if (ip46_address_is_ip4 (&local) != ip46_address_is_ip4 (&remote))
12807 errmsg ("both IPv4 and IPv6 addresses specified");
12813 errmsg ("vni not specified");
12817 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12819 ip_address_encode (&local,
12820 ip46_address_is_ip4 (&local) ? IP46_TYPE_IP4 :
12821 IP46_TYPE_IP6, &mp->local);
12822 ip_address_encode (&remote,
12823 ip46_address_is_ip4 (&remote) ? IP46_TYPE_IP4 :
12824 IP46_TYPE_IP6, &mp->remote);
12826 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12827 mp->encap_vrf_id = ntohl (encap_vrf_id);
12828 mp->decap_vrf_id = ntohl (decap_vrf_id);
12829 mp->protocol = protocol;
12830 mp->vni = ntohl (vni);
12831 mp->is_add = is_add;
12838 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12839 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12841 vat_main_t *vam = &vat_main;
12842 ip46_address_t local, remote;
12844 ip_address_decode (&mp->local, &local);
12845 ip_address_decode (&mp->remote, &remote);
12847 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12848 ntohl (mp->sw_if_index),
12849 format_ip46_address, &local, IP46_TYPE_ANY,
12850 format_ip46_address, &remote, IP46_TYPE_ANY,
12851 ntohl (mp->vni), mp->protocol,
12852 ntohl (mp->mcast_sw_if_index),
12853 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12857 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12858 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12860 vat_main_t *vam = &vat_main;
12861 vat_json_node_t *node = NULL;
12862 struct in_addr ip4;
12863 struct in6_addr ip6;
12864 ip46_address_t local, remote;
12866 ip_address_decode (&mp->local, &local);
12867 ip_address_decode (&mp->remote, &remote);
12869 if (VAT_JSON_ARRAY != vam->json_tree.type)
12871 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12872 vat_json_init_array (&vam->json_tree);
12874 node = vat_json_array_add (&vam->json_tree);
12876 vat_json_init_object (node);
12877 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12878 if (ip46_address_is_ip4 (&local))
12880 clib_memcpy (&ip4, &local.ip4, sizeof (ip4));
12881 vat_json_object_add_ip4 (node, "local", ip4);
12882 clib_memcpy (&ip4, &remote.ip4, sizeof (ip4));
12883 vat_json_object_add_ip4 (node, "remote", ip4);
12887 clib_memcpy (&ip6, &local.ip6, sizeof (ip6));
12888 vat_json_object_add_ip6 (node, "local", ip6);
12889 clib_memcpy (&ip6, &remote.ip6, sizeof (ip6));
12890 vat_json_object_add_ip6 (node, "remote", ip6);
12892 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12893 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12894 vat_json_object_add_uint (node, "mcast_sw_if_index",
12895 ntohl (mp->mcast_sw_if_index));
12896 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12897 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12898 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12902 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12904 unformat_input_t *i = vam->input;
12905 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12906 vl_api_control_ping_t *mp_ping;
12908 u8 sw_if_index_set = 0;
12911 /* Parse args required to build the message */
12912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12914 if (unformat (i, "sw_if_index %d", &sw_if_index))
12915 sw_if_index_set = 1;
12920 if (sw_if_index_set == 0)
12925 if (!vam->json_output)
12927 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12928 "sw_if_index", "local", "remote", "vni",
12929 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12932 /* Get list of vxlan-tunnel interfaces */
12933 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12935 mp->sw_if_index = htonl (sw_if_index);
12939 /* Use a control ping for synchronization */
12940 MPING (CONTROL_PING, mp_ping);
12947 static void vl_api_l2_fib_table_details_t_handler
12948 (vl_api_l2_fib_table_details_t * mp)
12950 vat_main_t *vam = &vat_main;
12952 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12954 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
12955 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12959 static void vl_api_l2_fib_table_details_t_handler_json
12960 (vl_api_l2_fib_table_details_t * mp)
12962 vat_main_t *vam = &vat_main;
12963 vat_json_node_t *node = NULL;
12965 if (VAT_JSON_ARRAY != vam->json_tree.type)
12967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12968 vat_json_init_array (&vam->json_tree);
12970 node = vat_json_array_add (&vam->json_tree);
12972 vat_json_init_object (node);
12973 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12974 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
12975 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12976 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12977 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12978 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12982 api_l2_fib_table_dump (vat_main_t * vam)
12984 unformat_input_t *i = vam->input;
12985 vl_api_l2_fib_table_dump_t *mp;
12986 vl_api_control_ping_t *mp_ping;
12991 /* Parse args required to build the message */
12992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12994 if (unformat (i, "bd_id %d", &bd_id))
13000 if (bd_id_set == 0)
13002 errmsg ("missing bridge domain");
13006 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
13008 /* Get list of l2 fib entries */
13009 M (L2_FIB_TABLE_DUMP, mp);
13011 mp->bd_id = ntohl (bd_id);
13014 /* Use a control ping for synchronization */
13015 MPING (CONTROL_PING, mp_ping);
13024 api_interface_name_renumber (vat_main_t * vam)
13026 unformat_input_t *line_input = vam->input;
13027 vl_api_interface_name_renumber_t *mp;
13028 u32 sw_if_index = ~0;
13029 u32 new_show_dev_instance = ~0;
13032 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13034 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
13037 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13039 else if (unformat (line_input, "new_show_dev_instance %d",
13040 &new_show_dev_instance))
13046 if (sw_if_index == ~0)
13048 errmsg ("missing interface name or sw_if_index");
13052 if (new_show_dev_instance == ~0)
13054 errmsg ("missing new_show_dev_instance");
13058 M (INTERFACE_NAME_RENUMBER, mp);
13060 mp->sw_if_index = ntohl (sw_if_index);
13061 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
13069 api_want_l2_macs_events (vat_main_t * vam)
13071 unformat_input_t *line_input = vam->input;
13072 vl_api_want_l2_macs_events_t *mp;
13073 u8 enable_disable = 1;
13074 u32 scan_delay = 0;
13075 u32 max_macs_in_event = 0;
13076 u32 learn_limit = 0;
13079 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13081 if (unformat (line_input, "learn-limit %d", &learn_limit))
13083 else if (unformat (line_input, "scan-delay %d", &scan_delay))
13085 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
13087 else if (unformat (line_input, "disable"))
13088 enable_disable = 0;
13093 M (WANT_L2_MACS_EVENTS, mp);
13094 mp->enable_disable = enable_disable;
13095 mp->pid = htonl (getpid ());
13096 mp->learn_limit = htonl (learn_limit);
13097 mp->scan_delay = (u8) scan_delay;
13098 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
13105 api_input_acl_set_interface (vat_main_t * vam)
13107 unformat_input_t *i = vam->input;
13108 vl_api_input_acl_set_interface_t *mp;
13110 int sw_if_index_set;
13111 u32 ip4_table_index = ~0;
13112 u32 ip6_table_index = ~0;
13113 u32 l2_table_index = ~0;
13117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13120 sw_if_index_set = 1;
13121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13122 sw_if_index_set = 1;
13123 else if (unformat (i, "del"))
13125 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13127 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13129 else if (unformat (i, "l2-table %d", &l2_table_index))
13133 clib_warning ("parse error '%U'", format_unformat_error, i);
13138 if (sw_if_index_set == 0)
13140 errmsg ("missing interface name or sw_if_index");
13144 M (INPUT_ACL_SET_INTERFACE, mp);
13146 mp->sw_if_index = ntohl (sw_if_index);
13147 mp->ip4_table_index = ntohl (ip4_table_index);
13148 mp->ip6_table_index = ntohl (ip6_table_index);
13149 mp->l2_table_index = ntohl (l2_table_index);
13150 mp->is_add = is_add;
13158 api_output_acl_set_interface (vat_main_t * vam)
13160 unformat_input_t *i = vam->input;
13161 vl_api_output_acl_set_interface_t *mp;
13163 int sw_if_index_set;
13164 u32 ip4_table_index = ~0;
13165 u32 ip6_table_index = ~0;
13166 u32 l2_table_index = ~0;
13170 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13172 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13173 sw_if_index_set = 1;
13174 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13175 sw_if_index_set = 1;
13176 else if (unformat (i, "del"))
13178 else if (unformat (i, "ip4-table %d", &ip4_table_index))
13180 else if (unformat (i, "ip6-table %d", &ip6_table_index))
13182 else if (unformat (i, "l2-table %d", &l2_table_index))
13186 clib_warning ("parse error '%U'", format_unformat_error, i);
13191 if (sw_if_index_set == 0)
13193 errmsg ("missing interface name or sw_if_index");
13197 M (OUTPUT_ACL_SET_INTERFACE, mp);
13199 mp->sw_if_index = ntohl (sw_if_index);
13200 mp->ip4_table_index = ntohl (ip4_table_index);
13201 mp->ip6_table_index = ntohl (ip6_table_index);
13202 mp->l2_table_index = ntohl (l2_table_index);
13203 mp->is_add = is_add;
13211 api_ip_address_dump (vat_main_t * vam)
13213 unformat_input_t *i = vam->input;
13214 vl_api_ip_address_dump_t *mp;
13215 vl_api_control_ping_t *mp_ping;
13216 u32 sw_if_index = ~0;
13217 u8 sw_if_index_set = 0;
13222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13224 if (unformat (i, "sw_if_index %d", &sw_if_index))
13225 sw_if_index_set = 1;
13227 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13228 sw_if_index_set = 1;
13229 else if (unformat (i, "ipv4"))
13231 else if (unformat (i, "ipv6"))
13237 if (ipv4_set && ipv6_set)
13239 errmsg ("ipv4 and ipv6 flags cannot be both set");
13243 if ((!ipv4_set) && (!ipv6_set))
13245 errmsg ("no ipv4 nor ipv6 flag set");
13249 if (sw_if_index_set == 0)
13251 errmsg ("missing interface name or sw_if_index");
13255 vam->current_sw_if_index = sw_if_index;
13256 vam->is_ipv6 = ipv6_set;
13258 M (IP_ADDRESS_DUMP, mp);
13259 mp->sw_if_index = ntohl (sw_if_index);
13260 mp->is_ipv6 = ipv6_set;
13263 /* Use a control ping for synchronization */
13264 MPING (CONTROL_PING, mp_ping);
13272 api_ip_dump (vat_main_t * vam)
13274 vl_api_ip_dump_t *mp;
13275 vl_api_control_ping_t *mp_ping;
13276 unformat_input_t *in = vam->input;
13283 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13285 if (unformat (in, "ipv4"))
13287 else if (unformat (in, "ipv6"))
13293 if (ipv4_set && ipv6_set)
13295 errmsg ("ipv4 and ipv6 flags cannot be both set");
13299 if ((!ipv4_set) && (!ipv6_set))
13301 errmsg ("no ipv4 nor ipv6 flag set");
13305 is_ipv6 = ipv6_set;
13306 vam->is_ipv6 = is_ipv6;
13308 /* free old data */
13309 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13311 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13313 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13316 mp->is_ipv6 = ipv6_set;
13319 /* Use a control ping for synchronization */
13320 MPING (CONTROL_PING, mp_ping);
13328 api_ipsec_spd_add_del (vat_main_t * vam)
13330 unformat_input_t *i = vam->input;
13331 vl_api_ipsec_spd_add_del_t *mp;
13336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13338 if (unformat (i, "spd_id %d", &spd_id))
13340 else if (unformat (i, "del"))
13344 clib_warning ("parse error '%U'", format_unformat_error, i);
13350 errmsg ("spd_id must be set");
13354 M (IPSEC_SPD_ADD_DEL, mp);
13356 mp->spd_id = ntohl (spd_id);
13357 mp->is_add = is_add;
13365 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13367 unformat_input_t *i = vam->input;
13368 vl_api_ipsec_interface_add_del_spd_t *mp;
13370 u8 sw_if_index_set = 0;
13371 u32 spd_id = (u32) ~ 0;
13375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13377 if (unformat (i, "del"))
13379 else if (unformat (i, "spd_id %d", &spd_id))
13382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13383 sw_if_index_set = 1;
13384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13385 sw_if_index_set = 1;
13388 clib_warning ("parse error '%U'", format_unformat_error, i);
13394 if (spd_id == (u32) ~ 0)
13396 errmsg ("spd_id must be set");
13400 if (sw_if_index_set == 0)
13402 errmsg ("missing interface name or sw_if_index");
13406 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13408 mp->spd_id = ntohl (spd_id);
13409 mp->sw_if_index = ntohl (sw_if_index);
13410 mp->is_add = is_add;
13418 api_ipsec_spd_entry_add_del (vat_main_t * vam)
13420 unformat_input_t *i = vam->input;
13421 vl_api_ipsec_spd_entry_add_del_t *mp;
13422 u8 is_add = 1, is_outbound = 0;
13423 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13425 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13426 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13427 vl_api_address_t laddr_start = { }, laddr_stop =
13436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13438 if (unformat (i, "del"))
13440 if (unformat (i, "outbound"))
13442 if (unformat (i, "inbound"))
13444 else if (unformat (i, "spd_id %d", &spd_id))
13446 else if (unformat (i, "sa_id %d", &sa_id))
13448 else if (unformat (i, "priority %d", &priority))
13450 else if (unformat (i, "protocol %d", &protocol))
13452 else if (unformat (i, "lport_start %d", &lport_start))
13454 else if (unformat (i, "lport_stop %d", &lport_stop))
13456 else if (unformat (i, "rport_start %d", &rport_start))
13458 else if (unformat (i, "rport_stop %d", &rport_stop))
13460 else if (unformat (i, "laddr_start %U",
13461 unformat_vl_api_address, &laddr_start))
13463 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
13466 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
13469 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
13473 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13475 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13477 clib_warning ("unsupported action: 'resolve'");
13483 clib_warning ("parse error '%U'", format_unformat_error, i);
13489 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
13491 mp->is_add = is_add;
13493 mp->entry.spd_id = ntohl (spd_id);
13494 mp->entry.priority = ntohl (priority);
13495 mp->entry.is_outbound = is_outbound;
13497 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
13498 sizeof (vl_api_address_t));
13499 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
13500 sizeof (vl_api_address_t));
13501 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
13502 sizeof (vl_api_address_t));
13503 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
13504 sizeof (vl_api_address_t));
13506 mp->entry.protocol = (u8) protocol;
13507 mp->entry.local_port_start = ntohs ((u16) lport_start);
13508 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
13509 mp->entry.remote_port_start = ntohs ((u16) rport_start);
13510 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
13511 mp->entry.policy = (u8) policy;
13512 mp->entry.sa_id = ntohl (sa_id);
13520 api_ipsec_sad_entry_add_del (vat_main_t * vam)
13522 unformat_input_t *i = vam->input;
13523 vl_api_ipsec_sad_entry_add_del_t *mp;
13524 u32 sad_id = 0, spi = 0;
13525 u8 *ck = 0, *ik = 0;
13528 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
13529 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
13530 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
13531 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
13532 vl_api_address_t tun_src, tun_dst;
13535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13537 if (unformat (i, "del"))
13539 else if (unformat (i, "sad_id %d", &sad_id))
13541 else if (unformat (i, "spi %d", &spi))
13543 else if (unformat (i, "esp"))
13544 protocol = IPSEC_API_PROTO_ESP;
13546 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
13548 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13549 if (ADDRESS_IP6 == tun_src.af)
13550 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13553 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
13555 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
13556 if (ADDRESS_IP6 == tun_src.af)
13557 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
13560 if (unformat (i, "crypto_alg %U",
13561 unformat_ipsec_api_crypto_alg, &crypto_alg))
13563 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13565 else if (unformat (i, "integ_alg %U",
13566 unformat_ipsec_api_integ_alg, &integ_alg))
13568 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13572 clib_warning ("parse error '%U'", format_unformat_error, i);
13578 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
13580 mp->is_add = is_add;
13581 mp->entry.sad_id = ntohl (sad_id);
13582 mp->entry.protocol = protocol;
13583 mp->entry.spi = ntohl (spi);
13584 mp->entry.flags = flags;
13586 mp->entry.crypto_algorithm = crypto_alg;
13587 mp->entry.integrity_algorithm = integ_alg;
13588 mp->entry.crypto_key.length = vec_len (ck);
13589 mp->entry.integrity_key.length = vec_len (ik);
13591 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
13592 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
13594 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
13595 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
13598 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
13600 clib_memcpy (mp->entry.integrity_key.data, ik,
13601 mp->entry.integrity_key.length);
13603 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
13605 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
13606 sizeof (mp->entry.tunnel_src));
13607 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
13608 sizeof (mp->entry.tunnel_dst));
13617 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13619 unformat_input_t *i = vam->input;
13620 vl_api_ipsec_tunnel_if_add_del_t *mp;
13621 u32 local_spi = 0, remote_spi = 0;
13622 u32 crypto_alg = 0, integ_alg = 0;
13623 u8 *lck = NULL, *rck = NULL;
13624 u8 *lik = NULL, *rik = NULL;
13625 vl_api_address_t local_ip = { 0 };
13626 vl_api_address_t remote_ip = { 0 };
13630 u8 anti_replay = 0;
13636 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13638 if (unformat (i, "del"))
13640 else if (unformat (i, "esn"))
13642 else if (unformat (i, "anti-replay"))
13644 else if (unformat (i, "count %d", &count))
13646 else if (unformat (i, "local_spi %d", &local_spi))
13648 else if (unformat (i, "remote_spi %d", &remote_spi))
13651 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
13654 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
13656 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13659 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13661 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13663 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13667 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
13669 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
13671 errmsg ("unsupported crypto-alg: '%U'\n",
13672 format_ipsec_crypto_alg, crypto_alg);
13678 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
13680 if (integ_alg >= IPSEC_INTEG_N_ALG)
13682 errmsg ("unsupported integ-alg: '%U'\n",
13683 format_ipsec_integ_alg, integ_alg);
13687 else if (unformat (i, "instance %u", &instance))
13691 errmsg ("parse error '%U'\n", format_unformat_error, i);
13698 /* Turn on async mode */
13699 vam->async_mode = 1;
13700 vam->async_errors = 0;
13701 before = vat_time_now (vam);
13704 for (jj = 0; jj < count; jj++)
13706 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13708 mp->is_add = is_add;
13710 mp->anti_replay = anti_replay;
13713 increment_address (&remote_ip);
13715 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
13716 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
13718 mp->local_spi = htonl (local_spi + jj);
13719 mp->remote_spi = htonl (remote_spi + jj);
13720 mp->crypto_alg = (u8) crypto_alg;
13722 mp->local_crypto_key_len = 0;
13725 mp->local_crypto_key_len = vec_len (lck);
13726 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13727 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13728 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13731 mp->remote_crypto_key_len = 0;
13734 mp->remote_crypto_key_len = vec_len (rck);
13735 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13736 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13737 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13740 mp->integ_alg = (u8) integ_alg;
13742 mp->local_integ_key_len = 0;
13745 mp->local_integ_key_len = vec_len (lik);
13746 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13747 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13748 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13751 mp->remote_integ_key_len = 0;
13754 mp->remote_integ_key_len = vec_len (rik);
13755 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13756 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13757 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13762 mp->renumber = renumber;
13763 mp->show_instance = ntohl (instance);
13768 /* When testing multiple add/del ops, use a control-ping to sync */
13771 vl_api_control_ping_t *mp_ping;
13775 /* Shut off async mode */
13776 vam->async_mode = 0;
13778 MPING (CONTROL_PING, mp_ping);
13781 timeout = vat_time_now (vam) + 1.0;
13782 while (vat_time_now (vam) < timeout)
13783 if (vam->result_ready == 1)
13788 if (vam->retval == -99)
13789 errmsg ("timeout");
13791 if (vam->async_errors > 0)
13793 errmsg ("%d asynchronous errors", vam->async_errors);
13796 vam->async_errors = 0;
13797 after = vat_time_now (vam);
13799 /* slim chance, but we might have eaten SIGTERM on the first iteration */
13803 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
13804 count, after - before, count / (after - before));
13808 /* Wait for a reply... */
13817 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
13819 vat_main_t *vam = &vat_main;
13821 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
13822 "crypto_key %U integ_alg %u integ_key %U flags %x "
13823 "tunnel_src_addr %U tunnel_dst_addr %U "
13824 "salt %u seq_outbound %lu last_seq_inbound %lu "
13825 "replay_window %lu stat_index %u\n",
13826 ntohl (mp->entry.sad_id),
13827 ntohl (mp->sw_if_index),
13828 ntohl (mp->entry.spi),
13829 ntohl (mp->entry.protocol),
13830 ntohl (mp->entry.crypto_algorithm),
13831 format_hex_bytes, mp->entry.crypto_key.data,
13832 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
13833 format_hex_bytes, mp->entry.integrity_key.data,
13834 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
13835 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
13836 &mp->entry.tunnel_dst, ntohl (mp->salt),
13837 clib_net_to_host_u64 (mp->seq_outbound),
13838 clib_net_to_host_u64 (mp->last_seq_inbound),
13839 clib_net_to_host_u64 (mp->replay_window), ntohl (mp->stat_index));
13842 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
13843 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
13845 static void vl_api_ipsec_sa_details_t_handler_json
13846 (vl_api_ipsec_sa_details_t * mp)
13848 vat_main_t *vam = &vat_main;
13849 vat_json_node_t *node = NULL;
13850 vl_api_ipsec_sad_flags_t flags;
13852 if (VAT_JSON_ARRAY != vam->json_tree.type)
13854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13855 vat_json_init_array (&vam->json_tree);
13857 node = vat_json_array_add (&vam->json_tree);
13859 vat_json_init_object (node);
13860 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
13861 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13862 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
13863 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
13864 vat_json_object_add_uint (node, "crypto_alg",
13865 ntohl (mp->entry.crypto_algorithm));
13866 vat_json_object_add_uint (node, "integ_alg",
13867 ntohl (mp->entry.integrity_algorithm));
13868 flags = ntohl (mp->entry.flags);
13869 vat_json_object_add_uint (node, "use_esn",
13870 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
13871 vat_json_object_add_uint (node, "use_anti_replay",
13872 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
13873 vat_json_object_add_uint (node, "is_tunnel",
13874 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
13875 vat_json_object_add_uint (node, "is_tunnel_ip6",
13876 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
13877 vat_json_object_add_uint (node, "udp_encap",
13878 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
13879 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
13880 mp->entry.crypto_key.length);
13881 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
13882 mp->entry.integrity_key.length);
13883 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
13884 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
13885 vat_json_object_add_uint (node, "replay_window",
13886 clib_net_to_host_u64 (mp->replay_window));
13887 vat_json_object_add_uint (node, "stat_index", ntohl (mp->stat_index));
13891 api_ipsec_sa_dump (vat_main_t * vam)
13893 unformat_input_t *i = vam->input;
13894 vl_api_ipsec_sa_dump_t *mp;
13895 vl_api_control_ping_t *mp_ping;
13899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13901 if (unformat (i, "sa_id %d", &sa_id))
13905 clib_warning ("parse error '%U'", format_unformat_error, i);
13910 M (IPSEC_SA_DUMP, mp);
13912 mp->sa_id = ntohl (sa_id);
13916 /* Use a control ping for synchronization */
13917 M (CONTROL_PING, mp_ping);
13925 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
13927 unformat_input_t *i = vam->input;
13928 vl_api_ipsec_tunnel_if_set_sa_t *mp;
13929 u32 sw_if_index = ~0;
13931 u8 is_outbound = (u8) ~ 0;
13934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13936 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13938 else if (unformat (i, "sa_id %d", &sa_id))
13940 else if (unformat (i, "outbound"))
13942 else if (unformat (i, "inbound"))
13946 clib_warning ("parse error '%U'", format_unformat_error, i);
13951 if (sw_if_index == ~0)
13953 errmsg ("interface must be specified");
13959 errmsg ("SA ID must be specified");
13963 M (IPSEC_TUNNEL_IF_SET_SA, mp);
13965 mp->sw_if_index = htonl (sw_if_index);
13966 mp->sa_id = htonl (sa_id);
13967 mp->is_outbound = is_outbound;
13976 api_get_first_msg_id (vat_main_t * vam)
13978 vl_api_get_first_msg_id_t *mp;
13979 unformat_input_t *i = vam->input;
13984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13986 if (unformat (i, "client %s", &name))
13994 errmsg ("missing client name");
13997 vec_add1 (name, 0);
13999 if (vec_len (name) > 63)
14001 errmsg ("client name too long");
14005 M (GET_FIRST_MSG_ID, mp);
14006 clib_memcpy (mp->name, name, vec_len (name));
14013 api_cop_interface_enable_disable (vat_main_t * vam)
14015 unformat_input_t *line_input = vam->input;
14016 vl_api_cop_interface_enable_disable_t *mp;
14017 u32 sw_if_index = ~0;
14018 u8 enable_disable = 1;
14021 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14023 if (unformat (line_input, "disable"))
14024 enable_disable = 0;
14025 if (unformat (line_input, "enable"))
14026 enable_disable = 1;
14027 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14028 vam, &sw_if_index))
14030 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14036 if (sw_if_index == ~0)
14038 errmsg ("missing interface name or sw_if_index");
14042 /* Construct the API message */
14043 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14044 mp->sw_if_index = ntohl (sw_if_index);
14045 mp->enable_disable = enable_disable;
14049 /* Wait for the reply */
14055 api_cop_whitelist_enable_disable (vat_main_t * vam)
14057 unformat_input_t *line_input = vam->input;
14058 vl_api_cop_whitelist_enable_disable_t *mp;
14059 u32 sw_if_index = ~0;
14060 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14064 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14066 if (unformat (line_input, "ip4"))
14068 else if (unformat (line_input, "ip6"))
14070 else if (unformat (line_input, "default"))
14072 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14073 vam, &sw_if_index))
14075 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14077 else if (unformat (line_input, "fib-id %d", &fib_id))
14083 if (sw_if_index == ~0)
14085 errmsg ("missing interface name or sw_if_index");
14089 /* Construct the API message */
14090 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14091 mp->sw_if_index = ntohl (sw_if_index);
14092 mp->fib_id = ntohl (fib_id);
14095 mp->default_cop = default_cop;
14099 /* Wait for the reply */
14105 api_get_node_graph (vat_main_t * vam)
14107 vl_api_get_node_graph_t *mp;
14110 M (GET_NODE_GRAPH, mp);
14114 /* Wait for the reply */
14120 /** Used for parsing LISP eids */
14121 typedef CLIB_PACKED(struct{
14125 lisp_nsh_api_t nsh;
14127 u32 len; /**< prefix length if IP */
14128 u8 type; /**< type of eid */
14133 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14135 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14137 clib_memset (a, 0, sizeof (a[0]));
14139 if (unformat (input, "%U/%d", unformat_ip46_address, a->addr.ip, &a->len))
14141 a->type = 0; /* ip prefix type */
14143 else if (unformat (input, "%U", unformat_ethernet_address, a->addr.mac))
14145 a->type = 1; /* mac type */
14147 else if (unformat (input, "%U", unformat_nsh_address, a->addr.nsh))
14149 a->type = 2; /* NSH type */
14150 a->addr.nsh.spi = clib_host_to_net_u32 (a->addr.nsh.spi);
14159 if (ip46_address_is_ip4 (&a->addr.ip))
14160 return a->len > 32 ? 1 : 0;
14162 return a->len > 128 ? 1 : 0;
14169 lisp_eid_put_vat (vl_api_eid_t * eid, const lisp_eid_vat_t * vat_eid)
14171 eid->type = vat_eid->type;
14174 case EID_TYPE_API_PREFIX:
14175 if (ip46_address_is_ip4 (&vat_eid->addr.ip))
14177 clib_memcpy (&eid->address.prefix.address.un.ip4,
14178 &vat_eid->addr.ip.ip4, 4);
14179 eid->address.prefix.address.af = ADDRESS_IP4;
14180 eid->address.prefix.len = vat_eid->len;
14184 clib_memcpy (&eid->address.prefix.address.un.ip6,
14185 &vat_eid->addr.ip.ip6, 16);
14186 eid->address.prefix.address.af = ADDRESS_IP6;
14187 eid->address.prefix.len = vat_eid->len;
14190 case EID_TYPE_API_MAC:
14191 clib_memcpy (&eid->address.mac, &vat_eid->addr.mac,
14192 sizeof (eid->address.mac));
14194 case EID_TYPE_API_NSH:
14195 clib_memcpy (&eid->address.nsh, &vat_eid->addr.nsh,
14196 sizeof (eid->address.nsh));
14205 api_one_add_del_locator_set (vat_main_t * vam)
14207 unformat_input_t *input = vam->input;
14208 vl_api_one_add_del_locator_set_t *mp;
14210 u8 *locator_set_name = NULL;
14211 u8 locator_set_name_set = 0;
14212 vl_api_local_locator_t locator, *locators = 0;
14213 u32 sw_if_index, priority, weight;
14217 /* Parse args required to build the message */
14218 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14220 if (unformat (input, "del"))
14224 else if (unformat (input, "locator-set %s", &locator_set_name))
14226 locator_set_name_set = 1;
14228 else if (unformat (input, "sw_if_index %u p %u w %u",
14229 &sw_if_index, &priority, &weight))
14231 locator.sw_if_index = htonl (sw_if_index);
14232 locator.priority = priority;
14233 locator.weight = weight;
14234 vec_add1 (locators, locator);
14238 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14239 &sw_if_index, &priority, &weight))
14241 locator.sw_if_index = htonl (sw_if_index);
14242 locator.priority = priority;
14243 locator.weight = weight;
14244 vec_add1 (locators, locator);
14250 if (locator_set_name_set == 0)
14252 errmsg ("missing locator-set name");
14253 vec_free (locators);
14257 if (vec_len (locator_set_name) > 64)
14259 errmsg ("locator-set name too long");
14260 vec_free (locator_set_name);
14261 vec_free (locators);
14264 vec_add1 (locator_set_name, 0);
14266 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14268 /* Construct the API message */
14269 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14271 mp->is_add = is_add;
14272 clib_memcpy (mp->locator_set_name, locator_set_name,
14273 vec_len (locator_set_name));
14274 vec_free (locator_set_name);
14276 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14278 clib_memcpy (mp->locators, locators, data_len);
14279 vec_free (locators);
14284 /* Wait for a reply... */
14289 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14292 api_one_add_del_locator (vat_main_t * vam)
14294 unformat_input_t *input = vam->input;
14295 vl_api_one_add_del_locator_t *mp;
14296 u32 tmp_if_index = ~0;
14297 u32 sw_if_index = ~0;
14298 u8 sw_if_index_set = 0;
14299 u8 sw_if_index_if_name_set = 0;
14301 u8 priority_set = 0;
14305 u8 *locator_set_name = NULL;
14306 u8 locator_set_name_set = 0;
14309 /* Parse args required to build the message */
14310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14312 if (unformat (input, "del"))
14316 else if (unformat (input, "locator-set %s", &locator_set_name))
14318 locator_set_name_set = 1;
14320 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14323 sw_if_index_if_name_set = 1;
14324 sw_if_index = tmp_if_index;
14326 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14328 sw_if_index_set = 1;
14329 sw_if_index = tmp_if_index;
14331 else if (unformat (input, "p %d", &priority))
14335 else if (unformat (input, "w %d", &weight))
14343 if (locator_set_name_set == 0)
14345 errmsg ("missing locator-set name");
14349 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14351 errmsg ("missing sw_if_index");
14352 vec_free (locator_set_name);
14356 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14358 errmsg ("cannot use both params interface name and sw_if_index");
14359 vec_free (locator_set_name);
14363 if (priority_set == 0)
14365 errmsg ("missing locator-set priority");
14366 vec_free (locator_set_name);
14370 if (weight_set == 0)
14372 errmsg ("missing locator-set weight");
14373 vec_free (locator_set_name);
14377 if (vec_len (locator_set_name) > 64)
14379 errmsg ("locator-set name too long");
14380 vec_free (locator_set_name);
14383 vec_add1 (locator_set_name, 0);
14385 /* Construct the API message */
14386 M (ONE_ADD_DEL_LOCATOR, mp);
14388 mp->is_add = is_add;
14389 mp->sw_if_index = ntohl (sw_if_index);
14390 mp->priority = priority;
14391 mp->weight = weight;
14392 clib_memcpy (mp->locator_set_name, locator_set_name,
14393 vec_len (locator_set_name));
14394 vec_free (locator_set_name);
14399 /* Wait for a reply... */
14404 #define api_lisp_add_del_locator api_one_add_del_locator
14407 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14409 u32 *key_id = va_arg (*args, u32 *);
14412 if (unformat (input, "%s", &s))
14414 if (!strcmp ((char *) s, "sha1"))
14415 key_id[0] = HMAC_SHA_1_96;
14416 else if (!strcmp ((char *) s, "sha256"))
14417 key_id[0] = HMAC_SHA_256_128;
14420 clib_warning ("invalid key_id: '%s'", s);
14421 key_id[0] = HMAC_NO_KEY;
14432 api_one_add_del_local_eid (vat_main_t * vam)
14434 unformat_input_t *input = vam->input;
14435 vl_api_one_add_del_local_eid_t *mp;
14438 lisp_eid_vat_t _eid, *eid = &_eid;
14439 u8 *locator_set_name = 0;
14440 u8 locator_set_name_set = 0;
14446 /* Parse args required to build the message */
14447 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14449 if (unformat (input, "del"))
14453 else if (unformat (input, "vni %d", &vni))
14457 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14461 else if (unformat (input, "locator-set %s", &locator_set_name))
14463 locator_set_name_set = 1;
14465 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14467 else if (unformat (input, "secret-key %_%v%_", &key))
14473 if (locator_set_name_set == 0)
14475 errmsg ("missing locator-set name");
14481 errmsg ("EID address not set!");
14482 vec_free (locator_set_name);
14486 if (key && (0 == key_id))
14488 errmsg ("invalid key_id!");
14492 if (vec_len (key) > 64)
14494 errmsg ("key too long");
14499 if (vec_len (locator_set_name) > 64)
14501 errmsg ("locator-set name too long");
14502 vec_free (locator_set_name);
14505 vec_add1 (locator_set_name, 0);
14507 /* Construct the API message */
14508 M (ONE_ADD_DEL_LOCAL_EID, mp);
14510 mp->is_add = is_add;
14511 lisp_eid_put_vat (&mp->eid, eid);
14512 mp->vni = clib_host_to_net_u32 (vni);
14513 mp->key.id = key_id;
14514 clib_memcpy (mp->locator_set_name, locator_set_name,
14515 vec_len (locator_set_name));
14516 clib_memcpy (mp->key.key, key, vec_len (key));
14518 vec_free (locator_set_name);
14524 /* Wait for a reply... */
14529 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14532 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14534 u32 dp_table = 0, vni = 0;;
14535 unformat_input_t *input = vam->input;
14536 vl_api_gpe_add_del_fwd_entry_t *mp;
14538 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14539 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14540 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14541 u32 action = ~0, w;
14542 ip4_address_t rmt_rloc4, lcl_rloc4;
14543 ip6_address_t rmt_rloc6, lcl_rloc6;
14544 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14547 clib_memset (&rloc, 0, sizeof (rloc));
14549 /* Parse args required to build the message */
14550 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14552 if (unformat (input, "del"))
14554 else if (unformat (input, "add"))
14556 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14560 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14564 else if (unformat (input, "vrf %d", &dp_table))
14566 else if (unformat (input, "bd %d", &dp_table))
14568 else if (unformat (input, "vni %d", &vni))
14570 else if (unformat (input, "w %d", &w))
14574 errmsg ("No RLOC configured for setting priority/weight!");
14577 curr_rloc->weight = w;
14579 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14580 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14583 clib_memcpy (&rloc.addr.un.ip4, &lcl_rloc4, sizeof (lcl_rloc4));
14585 vec_add1 (lcl_locs, rloc);
14587 clib_memcpy (&rloc.addr.un.ip4, &rmt_rloc4, sizeof (rmt_rloc4));
14588 vec_add1 (rmt_locs, rloc);
14589 /* weight saved in rmt loc */
14590 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14592 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14593 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14596 clib_memcpy (&rloc.addr.un.ip6, &lcl_rloc6, sizeof (lcl_rloc6));
14598 vec_add1 (lcl_locs, rloc);
14600 clib_memcpy (&rloc.addr.un.ip6, &rmt_rloc6, sizeof (rmt_rloc6));
14601 vec_add1 (rmt_locs, rloc);
14602 /* weight saved in rmt loc */
14603 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14605 else if (unformat (input, "action %d", &action))
14611 clib_warning ("parse error '%U'", format_unformat_error, input);
14618 errmsg ("remote eid addresses not set");
14622 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
14624 errmsg ("eid types don't match");
14628 if (0 == rmt_locs && (u32) ~ 0 == action)
14630 errmsg ("action not set for negative mapping");
14634 /* Construct the API message */
14635 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
14636 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
14638 mp->is_add = is_add;
14639 lisp_eid_put_vat (&mp->rmt_eid, rmt_eid);
14640 lisp_eid_put_vat (&mp->lcl_eid, lcl_eid);
14641 mp->dp_table = clib_host_to_net_u32 (dp_table);
14642 mp->vni = clib_host_to_net_u32 (vni);
14643 mp->action = action;
14645 if (0 != rmt_locs && 0 != lcl_locs)
14647 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
14648 clib_memcpy (mp->locs, lcl_locs,
14649 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
14651 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
14652 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
14653 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
14655 vec_free (lcl_locs);
14656 vec_free (rmt_locs);
14661 /* Wait for a reply... */
14667 api_one_add_del_map_server (vat_main_t * vam)
14669 unformat_input_t *input = vam->input;
14670 vl_api_one_add_del_map_server_t *mp;
14674 ip4_address_t ipv4;
14675 ip6_address_t ipv6;
14678 /* Parse args required to build the message */
14679 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14681 if (unformat (input, "del"))
14685 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14689 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14697 if (ipv4_set && ipv6_set)
14699 errmsg ("both eid v4 and v6 addresses set");
14703 if (!ipv4_set && !ipv6_set)
14705 errmsg ("eid addresses not set");
14709 /* Construct the API message */
14710 M (ONE_ADD_DEL_MAP_SERVER, mp);
14712 mp->is_add = is_add;
14715 mp->ip_address.af = 1;
14716 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14720 mp->ip_address.af = 0;
14721 clib_memcpy (mp->ip_address.un.ip4, &ipv4, sizeof (ipv4));
14727 /* Wait for a reply... */
14732 #define api_lisp_add_del_map_server api_one_add_del_map_server
14735 api_one_add_del_map_resolver (vat_main_t * vam)
14737 unformat_input_t *input = vam->input;
14738 vl_api_one_add_del_map_resolver_t *mp;
14742 ip4_address_t ipv4;
14743 ip6_address_t ipv6;
14746 /* Parse args required to build the message */
14747 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14749 if (unformat (input, "del"))
14753 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
14757 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
14765 if (ipv4_set && ipv6_set)
14767 errmsg ("both eid v4 and v6 addresses set");
14771 if (!ipv4_set && !ipv6_set)
14773 errmsg ("eid addresses not set");
14777 /* Construct the API message */
14778 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
14780 mp->is_add = is_add;
14783 mp->ip_address.af = 1;
14784 clib_memcpy (mp->ip_address.un.ip6, &ipv6, sizeof (ipv6));
14788 mp->ip_address.af = 0;
14789 clib_memcpy (mp->ip_address.un.ip6, &ipv4, sizeof (ipv4));
14795 /* Wait for a reply... */
14800 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
14803 api_lisp_gpe_enable_disable (vat_main_t * vam)
14805 unformat_input_t *input = vam->input;
14806 vl_api_gpe_enable_disable_t *mp;
14811 /* Parse args required to build the message */
14812 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14814 if (unformat (input, "enable"))
14819 else if (unformat (input, "disable"))
14830 errmsg ("Value not set");
14834 /* Construct the API message */
14835 M (GPE_ENABLE_DISABLE, mp);
14837 mp->is_enable = is_enable;
14842 /* Wait for a reply... */
14848 api_one_rloc_probe_enable_disable (vat_main_t * vam)
14850 unformat_input_t *input = vam->input;
14851 vl_api_one_rloc_probe_enable_disable_t *mp;
14856 /* Parse args required to build the message */
14857 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14859 if (unformat (input, "enable"))
14864 else if (unformat (input, "disable"))
14872 errmsg ("Value not set");
14876 /* Construct the API message */
14877 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
14879 mp->is_enable = is_enable;
14884 /* Wait for a reply... */
14889 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
14892 api_one_map_register_enable_disable (vat_main_t * vam)
14894 unformat_input_t *input = vam->input;
14895 vl_api_one_map_register_enable_disable_t *mp;
14900 /* Parse args required to build the message */
14901 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14903 if (unformat (input, "enable"))
14908 else if (unformat (input, "disable"))
14916 errmsg ("Value not set");
14920 /* Construct the API message */
14921 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
14923 mp->is_enable = is_enable;
14928 /* Wait for a reply... */
14933 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
14936 api_one_enable_disable (vat_main_t * vam)
14938 unformat_input_t *input = vam->input;
14939 vl_api_one_enable_disable_t *mp;
14944 /* Parse args required to build the message */
14945 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14947 if (unformat (input, "enable"))
14952 else if (unformat (input, "disable"))
14962 errmsg ("Value not set");
14966 /* Construct the API message */
14967 M (ONE_ENABLE_DISABLE, mp);
14969 mp->is_enable = is_enable;
14974 /* Wait for a reply... */
14979 #define api_lisp_enable_disable api_one_enable_disable
14982 api_one_enable_disable_xtr_mode (vat_main_t * vam)
14984 unformat_input_t *input = vam->input;
14985 vl_api_one_enable_disable_xtr_mode_t *mp;
14990 /* Parse args required to build the message */
14991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14993 if (unformat (input, "enable"))
14998 else if (unformat (input, "disable"))
15008 errmsg ("Value not set");
15012 /* Construct the API message */
15013 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
15015 mp->is_enable = is_enable;
15020 /* Wait for a reply... */
15026 api_one_show_xtr_mode (vat_main_t * vam)
15028 vl_api_one_show_xtr_mode_t *mp;
15031 /* Construct the API message */
15032 M (ONE_SHOW_XTR_MODE, mp);
15037 /* Wait for a reply... */
15043 api_one_enable_disable_pitr_mode (vat_main_t * vam)
15045 unformat_input_t *input = vam->input;
15046 vl_api_one_enable_disable_pitr_mode_t *mp;
15051 /* Parse args required to build the message */
15052 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15054 if (unformat (input, "enable"))
15059 else if (unformat (input, "disable"))
15069 errmsg ("Value not set");
15073 /* Construct the API message */
15074 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
15076 mp->is_enable = is_enable;
15081 /* Wait for a reply... */
15087 api_one_show_pitr_mode (vat_main_t * vam)
15089 vl_api_one_show_pitr_mode_t *mp;
15092 /* Construct the API message */
15093 M (ONE_SHOW_PITR_MODE, mp);
15098 /* Wait for a reply... */
15104 api_one_enable_disable_petr_mode (vat_main_t * vam)
15106 unformat_input_t *input = vam->input;
15107 vl_api_one_enable_disable_petr_mode_t *mp;
15112 /* Parse args required to build the message */
15113 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15115 if (unformat (input, "enable"))
15120 else if (unformat (input, "disable"))
15130 errmsg ("Value not set");
15134 /* Construct the API message */
15135 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
15137 mp->is_enable = is_enable;
15142 /* Wait for a reply... */
15148 api_one_show_petr_mode (vat_main_t * vam)
15150 vl_api_one_show_petr_mode_t *mp;
15153 /* Construct the API message */
15154 M (ONE_SHOW_PETR_MODE, mp);
15159 /* Wait for a reply... */
15165 api_show_one_map_register_state (vat_main_t * vam)
15167 vl_api_show_one_map_register_state_t *mp;
15170 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15175 /* wait for reply */
15180 #define api_show_lisp_map_register_state api_show_one_map_register_state
15183 api_show_one_rloc_probe_state (vat_main_t * vam)
15185 vl_api_show_one_rloc_probe_state_t *mp;
15188 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15193 /* wait for reply */
15198 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15201 api_one_add_del_ndp_entry (vat_main_t * vam)
15203 vl_api_one_add_del_ndp_entry_t *mp;
15204 unformat_input_t *input = vam->input;
15209 u8 mac[6] = { 0, };
15210 u8 ip6[16] = { 0, };
15214 /* Parse args required to build the message */
15215 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15217 if (unformat (input, "del"))
15219 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15221 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15223 else if (unformat (input, "bd %d", &bd))
15227 errmsg ("parse error '%U'", format_unformat_error, input);
15232 if (!bd_set || !ip_set || (!mac_set && is_add))
15234 errmsg ("Missing BD, IP or MAC!");
15238 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15239 mp->is_add = is_add;
15240 clib_memcpy (&mp->entry.mac, mac, 6);
15241 mp->bd = clib_host_to_net_u32 (bd);
15242 clib_memcpy (&mp->entry.ip6, ip6, sizeof (mp->entry.ip6));
15247 /* wait for reply */
15253 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15255 vl_api_one_add_del_l2_arp_entry_t *mp;
15256 unformat_input_t *input = vam->input;
15261 u8 mac[6] = { 0, };
15262 u32 ip4 = 0, bd = ~0;
15265 /* Parse args required to build the message */
15266 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15268 if (unformat (input, "del"))
15270 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15272 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15274 else if (unformat (input, "bd %d", &bd))
15278 errmsg ("parse error '%U'", format_unformat_error, input);
15283 if (!bd_set || !ip_set || (!mac_set && is_add))
15285 errmsg ("Missing BD, IP or MAC!");
15289 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15290 mp->is_add = is_add;
15291 clib_memcpy (&mp->entry.mac, mac, 6);
15292 mp->bd = clib_host_to_net_u32 (bd);
15293 clib_memcpy (mp->entry.ip4, &ip4, sizeof (mp->entry.ip4));
15298 /* wait for reply */
15304 api_one_ndp_bd_get (vat_main_t * vam)
15306 vl_api_one_ndp_bd_get_t *mp;
15309 M (ONE_NDP_BD_GET, mp);
15314 /* wait for reply */
15320 api_one_ndp_entries_get (vat_main_t * vam)
15322 vl_api_one_ndp_entries_get_t *mp;
15323 unformat_input_t *input = vam->input;
15328 /* Parse args required to build the message */
15329 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15331 if (unformat (input, "bd %d", &bd))
15335 errmsg ("parse error '%U'", format_unformat_error, input);
15342 errmsg ("Expected bridge domain!");
15346 M (ONE_NDP_ENTRIES_GET, mp);
15347 mp->bd = clib_host_to_net_u32 (bd);
15352 /* wait for reply */
15358 api_one_l2_arp_bd_get (vat_main_t * vam)
15360 vl_api_one_l2_arp_bd_get_t *mp;
15363 M (ONE_L2_ARP_BD_GET, mp);
15368 /* wait for reply */
15374 api_one_l2_arp_entries_get (vat_main_t * vam)
15376 vl_api_one_l2_arp_entries_get_t *mp;
15377 unformat_input_t *input = vam->input;
15382 /* Parse args required to build the message */
15383 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15385 if (unformat (input, "bd %d", &bd))
15389 errmsg ("parse error '%U'", format_unformat_error, input);
15396 errmsg ("Expected bridge domain!");
15400 M (ONE_L2_ARP_ENTRIES_GET, mp);
15401 mp->bd = clib_host_to_net_u32 (bd);
15406 /* wait for reply */
15412 api_one_stats_enable_disable (vat_main_t * vam)
15414 vl_api_one_stats_enable_disable_t *mp;
15415 unformat_input_t *input = vam->input;
15420 /* Parse args required to build the message */
15421 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15423 if (unformat (input, "enable"))
15428 else if (unformat (input, "disable"))
15438 errmsg ("Value not set");
15442 M (ONE_STATS_ENABLE_DISABLE, mp);
15443 mp->is_enable = is_enable;
15448 /* wait for reply */
15454 api_show_one_stats_enable_disable (vat_main_t * vam)
15456 vl_api_show_one_stats_enable_disable_t *mp;
15459 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15464 /* wait for reply */
15470 api_show_one_map_request_mode (vat_main_t * vam)
15472 vl_api_show_one_map_request_mode_t *mp;
15475 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15480 /* wait for reply */
15485 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15488 api_one_map_request_mode (vat_main_t * vam)
15490 unformat_input_t *input = vam->input;
15491 vl_api_one_map_request_mode_t *mp;
15495 /* Parse args required to build the message */
15496 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15498 if (unformat (input, "dst-only"))
15500 else if (unformat (input, "src-dst"))
15504 errmsg ("parse error '%U'", format_unformat_error, input);
15509 M (ONE_MAP_REQUEST_MODE, mp);
15516 /* wait for reply */
15521 #define api_lisp_map_request_mode api_one_map_request_mode
15524 * Enable/disable ONE proxy ITR.
15526 * @param vam vpp API test context
15527 * @return return code
15530 api_one_pitr_set_locator_set (vat_main_t * vam)
15532 u8 ls_name_set = 0;
15533 unformat_input_t *input = vam->input;
15534 vl_api_one_pitr_set_locator_set_t *mp;
15539 /* Parse args required to build the message */
15540 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15542 if (unformat (input, "del"))
15544 else if (unformat (input, "locator-set %s", &ls_name))
15548 errmsg ("parse error '%U'", format_unformat_error, input);
15555 errmsg ("locator-set name not set!");
15559 M (ONE_PITR_SET_LOCATOR_SET, mp);
15561 mp->is_add = is_add;
15562 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15563 vec_free (ls_name);
15568 /* wait for reply */
15573 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15576 api_one_nsh_set_locator_set (vat_main_t * vam)
15578 u8 ls_name_set = 0;
15579 unformat_input_t *input = vam->input;
15580 vl_api_one_nsh_set_locator_set_t *mp;
15585 /* Parse args required to build the message */
15586 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15588 if (unformat (input, "del"))
15590 else if (unformat (input, "ls %s", &ls_name))
15594 errmsg ("parse error '%U'", format_unformat_error, input);
15599 if (!ls_name_set && is_add)
15601 errmsg ("locator-set name not set!");
15605 M (ONE_NSH_SET_LOCATOR_SET, mp);
15607 mp->is_add = is_add;
15608 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15609 vec_free (ls_name);
15614 /* wait for reply */
15620 api_show_one_pitr (vat_main_t * vam)
15622 vl_api_show_one_pitr_t *mp;
15625 if (!vam->json_output)
15627 print (vam->ofp, "%=20s", "lisp status:");
15630 M (SHOW_ONE_PITR, mp);
15634 /* Wait for a reply... */
15639 #define api_show_lisp_pitr api_show_one_pitr
15642 api_one_use_petr (vat_main_t * vam)
15644 unformat_input_t *input = vam->input;
15645 vl_api_one_use_petr_t *mp;
15650 clib_memset (&ip, 0, sizeof (ip));
15652 /* Parse args required to build the message */
15653 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15655 if (unformat (input, "disable"))
15658 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15661 ip_addr_version (&ip) = AF_IP4;
15664 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15667 ip_addr_version (&ip) = AF_IP6;
15671 errmsg ("parse error '%U'", format_unformat_error, input);
15676 M (ONE_USE_PETR, mp);
15678 mp->is_add = is_add;
15681 mp->ip_address.af = ip_addr_version (&ip) == AF_IP4 ? 0 : 1;
15682 if (mp->ip_address.af)
15683 clib_memcpy (mp->ip_address.un.ip6, &ip, 16);
15685 clib_memcpy (mp->ip_address.un.ip4, &ip, 4);
15691 /* wait for reply */
15696 #define api_lisp_use_petr api_one_use_petr
15699 api_show_one_nsh_mapping (vat_main_t * vam)
15701 vl_api_show_one_use_petr_t *mp;
15704 if (!vam->json_output)
15706 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15709 M (SHOW_ONE_NSH_MAPPING, mp);
15713 /* Wait for a reply... */
15719 api_show_one_use_petr (vat_main_t * vam)
15721 vl_api_show_one_use_petr_t *mp;
15724 if (!vam->json_output)
15726 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15729 M (SHOW_ONE_USE_PETR, mp);
15733 /* Wait for a reply... */
15738 #define api_show_lisp_use_petr api_show_one_use_petr
15741 * Add/delete mapping between vni and vrf
15744 api_one_eid_table_add_del_map (vat_main_t * vam)
15746 unformat_input_t *input = vam->input;
15747 vl_api_one_eid_table_add_del_map_t *mp;
15748 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15749 u32 vni, vrf, bd_index;
15752 /* Parse args required to build the message */
15753 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15755 if (unformat (input, "del"))
15757 else if (unformat (input, "vrf %d", &vrf))
15759 else if (unformat (input, "bd_index %d", &bd_index))
15761 else if (unformat (input, "vni %d", &vni))
15767 if (!vni_set || (!vrf_set && !bd_index_set))
15769 errmsg ("missing arguments!");
15773 if (vrf_set && bd_index_set)
15775 errmsg ("error: both vrf and bd entered!");
15779 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15781 mp->is_add = is_add;
15782 mp->vni = htonl (vni);
15783 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15784 mp->is_l2 = bd_index_set;
15789 /* wait for reply */
15794 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15797 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15799 u32 *action = va_arg (*args, u32 *);
15802 if (unformat (input, "%s", &s))
15804 if (!strcmp ((char *) s, "no-action"))
15806 else if (!strcmp ((char *) s, "natively-forward"))
15808 else if (!strcmp ((char *) s, "send-map-request"))
15810 else if (!strcmp ((char *) s, "drop"))
15814 clib_warning ("invalid action: '%s'", s);
15826 * Add/del remote mapping to/from ONE control plane
15828 * @param vam vpp API test context
15829 * @return return code
15832 api_one_add_del_remote_mapping (vat_main_t * vam)
15834 unformat_input_t *input = vam->input;
15835 vl_api_one_add_del_remote_mapping_t *mp;
15837 lisp_eid_vat_t _eid, *eid = &_eid;
15838 lisp_eid_vat_t _seid, *seid = &_seid;
15839 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15840 u32 action = ~0, p, w, data_len;
15841 ip4_address_t rloc4;
15842 ip6_address_t rloc6;
15843 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15846 clib_memset (&rloc, 0, sizeof (rloc));
15848 /* Parse args required to build the message */
15849 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15851 if (unformat (input, "del-all"))
15855 else if (unformat (input, "del"))
15859 else if (unformat (input, "add"))
15863 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15867 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15871 else if (unformat (input, "vni %d", &vni))
15875 else if (unformat (input, "p %d w %d", &p, &w))
15879 errmsg ("No RLOC configured for setting priority/weight!");
15882 curr_rloc->priority = p;
15883 curr_rloc->weight = w;
15885 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15887 rloc.ip_address.af = 0;
15888 clib_memcpy (&rloc.ip_address.un.ip6, &rloc6, sizeof (rloc6));
15889 vec_add1 (rlocs, rloc);
15890 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15892 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
15894 rloc.ip_address.af = 1;
15895 clib_memcpy (&rloc.ip_address.un.ip4, &rloc4, sizeof (rloc4));
15896 vec_add1 (rlocs, rloc);
15897 curr_rloc = &rlocs[vec_len (rlocs) - 1];
15899 else if (unformat (input, "action %U",
15900 unformat_negative_mapping_action, &action))
15906 clib_warning ("parse error '%U'", format_unformat_error, input);
15913 errmsg ("missing params!");
15917 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
15919 errmsg ("no action set for negative map-reply!");
15923 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
15925 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
15926 mp->is_add = is_add;
15927 mp->vni = htonl (vni);
15928 mp->action = (u8) action;
15929 mp->is_src_dst = seid_set;
15930 mp->del_all = del_all;
15931 lisp_eid_put_vat (&mp->deid, eid);
15932 lisp_eid_put_vat (&mp->seid, seid);
15934 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
15935 clib_memcpy (mp->rlocs, rlocs, data_len);
15941 /* Wait for a reply... */
15946 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
15949 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
15950 * forwarding entries in data-plane accordingly.
15952 * @param vam vpp API test context
15953 * @return return code
15956 api_one_add_del_adjacency (vat_main_t * vam)
15958 unformat_input_t *input = vam->input;
15959 vl_api_one_add_del_adjacency_t *mp;
15963 lisp_eid_vat_t leid, reid;
15965 leid.type = reid.type = (u8) ~ 0;
15967 /* Parse args required to build the message */
15968 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15970 if (unformat (input, "del"))
15974 else if (unformat (input, "add"))
15978 else if (unformat (input, "reid %U/%d", unformat_ip46_address,
15979 &reid.addr.ip, &reid.len))
15981 reid.type = 0; /* ipv4 */
15983 else if (unformat (input, "reid %U", unformat_ethernet_address,
15986 reid.type = 1; /* mac */
15988 else if (unformat (input, "leid %U/%d", unformat_ip46_address,
15989 &leid.addr.ip, &leid.len))
15991 leid.type = 0; /* ipv4 */
15993 else if (unformat (input, "leid %U", unformat_ethernet_address,
15996 leid.type = 1; /* mac */
15998 else if (unformat (input, "vni %d", &vni))
16004 errmsg ("parse error '%U'", format_unformat_error, input);
16009 if ((u8) ~ 0 == reid.type)
16011 errmsg ("missing params!");
16015 if (leid.type != reid.type)
16017 errmsg ("remote and local EIDs are of different types!");
16021 M (ONE_ADD_DEL_ADJACENCY, mp);
16022 mp->is_add = is_add;
16023 mp->vni = htonl (vni);
16024 lisp_eid_put_vat (&mp->leid, &leid);
16025 lisp_eid_put_vat (&mp->reid, &reid);
16030 /* Wait for a reply... */
16035 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16038 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16040 u32 *mode = va_arg (*args, u32 *);
16042 if (unformat (input, "lisp"))
16044 else if (unformat (input, "vxlan"))
16053 api_gpe_get_encap_mode (vat_main_t * vam)
16055 vl_api_gpe_get_encap_mode_t *mp;
16058 /* Construct the API message */
16059 M (GPE_GET_ENCAP_MODE, mp);
16064 /* Wait for a reply... */
16070 api_gpe_set_encap_mode (vat_main_t * vam)
16072 unformat_input_t *input = vam->input;
16073 vl_api_gpe_set_encap_mode_t *mp;
16077 /* Parse args required to build the message */
16078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16080 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16086 /* Construct the API message */
16087 M (GPE_SET_ENCAP_MODE, mp);
16089 mp->is_vxlan = mode;
16094 /* Wait for a reply... */
16100 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16102 unformat_input_t *input = vam->input;
16103 vl_api_gpe_add_del_iface_t *mp;
16104 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16105 u32 dp_table = 0, vni = 0;
16108 /* Parse args required to build the message */
16109 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16111 if (unformat (input, "up"))
16116 else if (unformat (input, "down"))
16121 else if (unformat (input, "table_id %d", &dp_table))
16125 else if (unformat (input, "bd_id %d", &dp_table))
16130 else if (unformat (input, "vni %d", &vni))
16138 if (action_set == 0)
16140 errmsg ("Action not set");
16143 if (dp_table_set == 0 || vni_set == 0)
16145 errmsg ("vni and dp_table must be set");
16149 /* Construct the API message */
16150 M (GPE_ADD_DEL_IFACE, mp);
16152 mp->is_add = is_add;
16153 mp->dp_table = clib_host_to_net_u32 (dp_table);
16155 mp->vni = clib_host_to_net_u32 (vni);
16160 /* Wait for a reply... */
16166 api_one_map_register_fallback_threshold (vat_main_t * vam)
16168 unformat_input_t *input = vam->input;
16169 vl_api_one_map_register_fallback_threshold_t *mp;
16174 /* Parse args required to build the message */
16175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16177 if (unformat (input, "%u", &value))
16181 clib_warning ("parse error '%U'", format_unformat_error, input);
16188 errmsg ("fallback threshold value is missing!");
16192 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16193 mp->value = clib_host_to_net_u32 (value);
16198 /* Wait for a reply... */
16204 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16206 vl_api_show_one_map_register_fallback_threshold_t *mp;
16209 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16214 /* Wait for a reply... */
16220 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
16222 u32 *proto = va_arg (*args, u32 *);
16224 if (unformat (input, "udp"))
16226 else if (unformat (input, "api"))
16235 api_one_set_transport_protocol (vat_main_t * vam)
16237 unformat_input_t *input = vam->input;
16238 vl_api_one_set_transport_protocol_t *mp;
16243 /* Parse args required to build the message */
16244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16246 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
16250 clib_warning ("parse error '%U'", format_unformat_error, input);
16257 errmsg ("Transport protocol missing!");
16261 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
16262 mp->protocol = (u8) protocol;
16267 /* Wait for a reply... */
16273 api_one_get_transport_protocol (vat_main_t * vam)
16275 vl_api_one_get_transport_protocol_t *mp;
16278 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
16283 /* Wait for a reply... */
16289 api_one_map_register_set_ttl (vat_main_t * vam)
16291 unformat_input_t *input = vam->input;
16292 vl_api_one_map_register_set_ttl_t *mp;
16297 /* Parse args required to build the message */
16298 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16300 if (unformat (input, "%u", &ttl))
16304 clib_warning ("parse error '%U'", format_unformat_error, input);
16311 errmsg ("TTL value missing!");
16315 M (ONE_MAP_REGISTER_SET_TTL, mp);
16316 mp->ttl = clib_host_to_net_u32 (ttl);
16321 /* Wait for a reply... */
16327 api_show_one_map_register_ttl (vat_main_t * vam)
16329 vl_api_show_one_map_register_ttl_t *mp;
16332 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16337 /* Wait for a reply... */
16343 * Add/del map request itr rlocs from ONE control plane and updates
16345 * @param vam vpp API test context
16346 * @return return code
16349 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16351 unformat_input_t *input = vam->input;
16352 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16353 u8 *locator_set_name = 0;
16354 u8 locator_set_name_set = 0;
16358 /* Parse args required to build the message */
16359 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16361 if (unformat (input, "del"))
16365 else if (unformat (input, "%_%v%_", &locator_set_name))
16367 locator_set_name_set = 1;
16371 clib_warning ("parse error '%U'", format_unformat_error, input);
16376 if (is_add && !locator_set_name_set)
16378 errmsg ("itr-rloc is not set!");
16382 if (is_add && vec_len (locator_set_name) > 64)
16384 errmsg ("itr-rloc locator-set name too long");
16385 vec_free (locator_set_name);
16389 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16390 mp->is_add = is_add;
16393 clib_memcpy (mp->locator_set_name, locator_set_name,
16394 vec_len (locator_set_name));
16398 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16400 vec_free (locator_set_name);
16405 /* Wait for a reply... */
16410 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16413 api_one_locator_dump (vat_main_t * vam)
16415 unformat_input_t *input = vam->input;
16416 vl_api_one_locator_dump_t *mp;
16417 vl_api_control_ping_t *mp_ping;
16418 u8 is_index_set = 0, is_name_set = 0;
16423 /* Parse args required to build the message */
16424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16426 if (unformat (input, "ls_name %_%v%_", &ls_name))
16430 else if (unformat (input, "ls_index %d", &ls_index))
16436 errmsg ("parse error '%U'", format_unformat_error, input);
16441 if (!is_index_set && !is_name_set)
16443 errmsg ("error: expected one of index or name!");
16447 if (is_index_set && is_name_set)
16449 errmsg ("error: only one param expected!");
16453 if (vec_len (ls_name) > 62)
16455 errmsg ("error: locator set name too long!");
16459 if (!vam->json_output)
16461 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16464 M (ONE_LOCATOR_DUMP, mp);
16465 mp->is_index_set = is_index_set;
16468 mp->ls_index = clib_host_to_net_u32 (ls_index);
16471 vec_add1 (ls_name, 0);
16472 strncpy ((char *) mp->ls_name, (char *) ls_name,
16473 sizeof (mp->ls_name) - 1);
16479 /* Use a control ping for synchronization */
16480 MPING (CONTROL_PING, mp_ping);
16483 /* Wait for a reply... */
16488 #define api_lisp_locator_dump api_one_locator_dump
16491 api_one_locator_set_dump (vat_main_t * vam)
16493 vl_api_one_locator_set_dump_t *mp;
16494 vl_api_control_ping_t *mp_ping;
16495 unformat_input_t *input = vam->input;
16499 /* Parse args required to build the message */
16500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16502 if (unformat (input, "local"))
16506 else if (unformat (input, "remote"))
16512 errmsg ("parse error '%U'", format_unformat_error, input);
16517 if (!vam->json_output)
16519 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16522 M (ONE_LOCATOR_SET_DUMP, mp);
16524 mp->filter = filter;
16529 /* Use a control ping for synchronization */
16530 MPING (CONTROL_PING, mp_ping);
16533 /* Wait for a reply... */
16538 #define api_lisp_locator_set_dump api_one_locator_set_dump
16541 api_one_eid_table_map_dump (vat_main_t * vam)
16545 unformat_input_t *input = vam->input;
16546 vl_api_one_eid_table_map_dump_t *mp;
16547 vl_api_control_ping_t *mp_ping;
16550 /* Parse args required to build the message */
16551 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16553 if (unformat (input, "l2"))
16558 else if (unformat (input, "l3"))
16565 errmsg ("parse error '%U'", format_unformat_error, input);
16572 errmsg ("expected one of 'l2' or 'l3' parameter!");
16576 if (!vam->json_output)
16578 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16581 M (ONE_EID_TABLE_MAP_DUMP, mp);
16587 /* Use a control ping for synchronization */
16588 MPING (CONTROL_PING, mp_ping);
16591 /* Wait for a reply... */
16596 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16599 api_one_eid_table_vni_dump (vat_main_t * vam)
16601 vl_api_one_eid_table_vni_dump_t *mp;
16602 vl_api_control_ping_t *mp_ping;
16605 if (!vam->json_output)
16607 print (vam->ofp, "VNI");
16610 M (ONE_EID_TABLE_VNI_DUMP, mp);
16615 /* Use a control ping for synchronization */
16616 MPING (CONTROL_PING, mp_ping);
16619 /* Wait for a reply... */
16624 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16627 api_one_eid_table_dump (vat_main_t * vam)
16629 unformat_input_t *i = vam->input;
16630 vl_api_one_eid_table_dump_t *mp;
16631 vl_api_control_ping_t *mp_ping;
16635 lisp_eid_vat_t eid;
16638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16641 (i, "eid %U/%d", unformat_ip46_address, &eid.addr.ip, &eid.len))
16647 if (unformat (i, "eid %U", unformat_ethernet_address, &eid.addr.mac))
16652 else if (unformat (i, "eid %U", unformat_nsh_address, &eid.addr.nsh))
16657 else if (unformat (i, "vni %d", &t))
16661 else if (unformat (i, "local"))
16665 else if (unformat (i, "remote"))
16671 errmsg ("parse error '%U'", format_unformat_error, i);
16676 if (!vam->json_output)
16678 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16679 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16682 M (ONE_EID_TABLE_DUMP, mp);
16684 mp->filter = filter;
16688 mp->vni = htonl (vni);
16689 lisp_eid_put_vat (&mp->eid, &eid);
16695 /* Use a control ping for synchronization */
16696 MPING (CONTROL_PING, mp_ping);
16699 /* Wait for a reply... */
16704 #define api_lisp_eid_table_dump api_one_eid_table_dump
16707 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16709 unformat_input_t *i = vam->input;
16710 vl_api_gpe_fwd_entries_get_t *mp;
16715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16717 if (unformat (i, "vni %d", &vni))
16723 errmsg ("parse error '%U'", format_unformat_error, i);
16730 errmsg ("vni not set!");
16734 if (!vam->json_output)
16736 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16740 M (GPE_FWD_ENTRIES_GET, mp);
16741 mp->vni = clib_host_to_net_u32 (vni);
16746 /* Wait for a reply... */
16751 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16752 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16753 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16754 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16755 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16756 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16757 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16758 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16761 api_one_adjacencies_get (vat_main_t * vam)
16763 unformat_input_t *i = vam->input;
16764 vl_api_one_adjacencies_get_t *mp;
16769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16771 if (unformat (i, "vni %d", &vni))
16777 errmsg ("parse error '%U'", format_unformat_error, i);
16784 errmsg ("vni not set!");
16788 if (!vam->json_output)
16790 print (vam->ofp, "%s %40s", "leid", "reid");
16793 M (ONE_ADJACENCIES_GET, mp);
16794 mp->vni = clib_host_to_net_u32 (vni);
16799 /* Wait for a reply... */
16804 #define api_lisp_adjacencies_get api_one_adjacencies_get
16807 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16809 unformat_input_t *i = vam->input;
16810 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16812 u8 ip_family_set = 0, is_ip4 = 1;
16814 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16816 if (unformat (i, "ip4"))
16821 else if (unformat (i, "ip6"))
16828 errmsg ("parse error '%U'", format_unformat_error, i);
16833 if (!ip_family_set)
16835 errmsg ("ip family not set!");
16839 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16840 mp->is_ip4 = is_ip4;
16845 /* Wait for a reply... */
16851 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16853 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16856 if (!vam->json_output)
16858 print (vam->ofp, "VNIs");
16861 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16866 /* Wait for a reply... */
16872 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16874 unformat_input_t *i = vam->input;
16875 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16877 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16878 struct in_addr ip4;
16879 struct in6_addr ip6;
16880 u32 table_id = 0, nh_sw_if_index = ~0;
16882 clib_memset (&ip4, 0, sizeof (ip4));
16883 clib_memset (&ip6, 0, sizeof (ip6));
16885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16887 if (unformat (i, "del"))
16889 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
16890 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16895 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
16896 api_unformat_sw_if_index, vam, &nh_sw_if_index))
16901 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
16905 nh_sw_if_index = ~0;
16907 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
16911 nh_sw_if_index = ~0;
16913 else if (unformat (i, "table %d", &table_id))
16917 errmsg ("parse error '%U'", format_unformat_error, i);
16924 errmsg ("nh addr not set!");
16928 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
16929 mp->is_add = is_add;
16930 mp->table_id = clib_host_to_net_u32 (table_id);
16931 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
16932 mp->nh_addr.af = is_ip4 ? 0 : 1;
16934 clib_memcpy (mp->nh_addr.un.ip4, &ip4, sizeof (ip4));
16936 clib_memcpy (mp->nh_addr.un.ip6, &ip6, sizeof (ip6));
16941 /* Wait for a reply... */
16947 api_one_map_server_dump (vat_main_t * vam)
16949 vl_api_one_map_server_dump_t *mp;
16950 vl_api_control_ping_t *mp_ping;
16953 if (!vam->json_output)
16955 print (vam->ofp, "%=20s", "Map server");
16958 M (ONE_MAP_SERVER_DUMP, mp);
16962 /* Use a control ping for synchronization */
16963 MPING (CONTROL_PING, mp_ping);
16966 /* Wait for a reply... */
16971 #define api_lisp_map_server_dump api_one_map_server_dump
16974 api_one_map_resolver_dump (vat_main_t * vam)
16976 vl_api_one_map_resolver_dump_t *mp;
16977 vl_api_control_ping_t *mp_ping;
16980 if (!vam->json_output)
16982 print (vam->ofp, "%=20s", "Map resolver");
16985 M (ONE_MAP_RESOLVER_DUMP, mp);
16989 /* Use a control ping for synchronization */
16990 MPING (CONTROL_PING, mp_ping);
16993 /* Wait for a reply... */
16998 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17001 api_one_stats_flush (vat_main_t * vam)
17003 vl_api_one_stats_flush_t *mp;
17006 M (ONE_STATS_FLUSH, mp);
17013 api_one_stats_dump (vat_main_t * vam)
17015 vl_api_one_stats_dump_t *mp;
17016 vl_api_control_ping_t *mp_ping;
17019 M (ONE_STATS_DUMP, mp);
17023 /* Use a control ping for synchronization */
17024 MPING (CONTROL_PING, mp_ping);
17027 /* Wait for a reply... */
17033 api_show_one_status (vat_main_t * vam)
17035 vl_api_show_one_status_t *mp;
17038 if (!vam->json_output)
17040 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17043 M (SHOW_ONE_STATUS, mp);
17046 /* Wait for a reply... */
17051 #define api_show_lisp_status api_show_one_status
17054 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17056 vl_api_gpe_fwd_entry_path_dump_t *mp;
17057 vl_api_control_ping_t *mp_ping;
17058 unformat_input_t *i = vam->input;
17059 u32 fwd_entry_index = ~0;
17062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17064 if (unformat (i, "index %d", &fwd_entry_index))
17070 if (~0 == fwd_entry_index)
17072 errmsg ("no index specified!");
17076 if (!vam->json_output)
17078 print (vam->ofp, "first line");
17081 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17085 /* Use a control ping for synchronization */
17086 MPING (CONTROL_PING, mp_ping);
17089 /* Wait for a reply... */
17095 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17097 vl_api_one_get_map_request_itr_rlocs_t *mp;
17100 if (!vam->json_output)
17102 print (vam->ofp, "%=20s", "itr-rlocs:");
17105 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17108 /* Wait for a reply... */
17113 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17116 api_af_packet_create (vat_main_t * vam)
17118 unformat_input_t *i = vam->input;
17119 vl_api_af_packet_create_t *mp;
17120 u8 *host_if_name = 0;
17122 u8 random_hw_addr = 1;
17125 clib_memset (hw_addr, 0, sizeof (hw_addr));
17127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17129 if (unformat (i, "name %s", &host_if_name))
17130 vec_add1 (host_if_name, 0);
17131 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17132 random_hw_addr = 0;
17137 if (!vec_len (host_if_name))
17139 errmsg ("host-interface name must be specified");
17143 if (vec_len (host_if_name) > 64)
17145 errmsg ("host-interface name too long");
17149 M (AF_PACKET_CREATE, mp);
17151 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17152 clib_memcpy (mp->hw_addr, hw_addr, 6);
17153 mp->use_random_hw_addr = random_hw_addr;
17154 vec_free (host_if_name);
17162 fprintf (vam->ofp ? vam->ofp : stderr,
17163 " new sw_if_index = %d\n", vam->sw_if_index);
17170 api_af_packet_delete (vat_main_t * vam)
17172 unformat_input_t *i = vam->input;
17173 vl_api_af_packet_delete_t *mp;
17174 u8 *host_if_name = 0;
17177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17179 if (unformat (i, "name %s", &host_if_name))
17180 vec_add1 (host_if_name, 0);
17185 if (!vec_len (host_if_name))
17187 errmsg ("host-interface name must be specified");
17191 if (vec_len (host_if_name) > 64)
17193 errmsg ("host-interface name too long");
17197 M (AF_PACKET_DELETE, mp);
17199 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17200 vec_free (host_if_name);
17207 static void vl_api_af_packet_details_t_handler
17208 (vl_api_af_packet_details_t * mp)
17210 vat_main_t *vam = &vat_main;
17212 print (vam->ofp, "%-16s %d",
17213 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
17216 static void vl_api_af_packet_details_t_handler_json
17217 (vl_api_af_packet_details_t * mp)
17219 vat_main_t *vam = &vat_main;
17220 vat_json_node_t *node = NULL;
17222 if (VAT_JSON_ARRAY != vam->json_tree.type)
17224 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17225 vat_json_init_array (&vam->json_tree);
17227 node = vat_json_array_add (&vam->json_tree);
17229 vat_json_init_object (node);
17230 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17231 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
17235 api_af_packet_dump (vat_main_t * vam)
17237 vl_api_af_packet_dump_t *mp;
17238 vl_api_control_ping_t *mp_ping;
17241 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
17242 /* Get list of tap interfaces */
17243 M (AF_PACKET_DUMP, mp);
17246 /* Use a control ping for synchronization */
17247 MPING (CONTROL_PING, mp_ping);
17255 api_policer_add_del (vat_main_t * vam)
17257 unformat_input_t *i = vam->input;
17258 vl_api_policer_add_del_t *mp;
17268 u8 color_aware = 0;
17269 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17272 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17273 conform_action.dscp = 0;
17274 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17275 exceed_action.dscp = 0;
17276 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17277 violate_action.dscp = 0;
17279 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17281 if (unformat (i, "del"))
17283 else if (unformat (i, "name %s", &name))
17284 vec_add1 (name, 0);
17285 else if (unformat (i, "cir %u", &cir))
17287 else if (unformat (i, "eir %u", &eir))
17289 else if (unformat (i, "cb %u", &cb))
17291 else if (unformat (i, "eb %u", &eb))
17293 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17296 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17299 else if (unformat (i, "type %U", unformat_policer_type, &type))
17301 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17304 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17307 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17310 else if (unformat (i, "color-aware"))
17316 if (!vec_len (name))
17318 errmsg ("policer name must be specified");
17322 if (vec_len (name) > 64)
17324 errmsg ("policer name too long");
17328 M (POLICER_ADD_DEL, mp);
17330 clib_memcpy (mp->name, name, vec_len (name));
17332 mp->is_add = is_add;
17333 mp->cir = ntohl (cir);
17334 mp->eir = ntohl (eir);
17335 mp->cb = clib_net_to_host_u64 (cb);
17336 mp->eb = clib_net_to_host_u64 (eb);
17337 mp->rate_type = rate_type;
17338 mp->round_type = round_type;
17340 mp->conform_action.type = conform_action.action_type;
17341 mp->conform_action.dscp = conform_action.dscp;
17342 mp->exceed_action.type = exceed_action.action_type;
17343 mp->exceed_action.dscp = exceed_action.dscp;
17344 mp->violate_action.type = violate_action.action_type;
17345 mp->violate_action.dscp = violate_action.dscp;
17346 mp->color_aware = color_aware;
17354 api_policer_dump (vat_main_t * vam)
17356 unformat_input_t *i = vam->input;
17357 vl_api_policer_dump_t *mp;
17358 vl_api_control_ping_t *mp_ping;
17359 u8 *match_name = 0;
17360 u8 match_name_valid = 0;
17363 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17365 if (unformat (i, "name %s", &match_name))
17367 vec_add1 (match_name, 0);
17368 match_name_valid = 1;
17374 M (POLICER_DUMP, mp);
17375 mp->match_name_valid = match_name_valid;
17376 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17377 vec_free (match_name);
17381 /* Use a control ping for synchronization */
17382 MPING (CONTROL_PING, mp_ping);
17385 /* Wait for a reply... */
17391 api_policer_classify_set_interface (vat_main_t * vam)
17393 unformat_input_t *i = vam->input;
17394 vl_api_policer_classify_set_interface_t *mp;
17396 int sw_if_index_set;
17397 u32 ip4_table_index = ~0;
17398 u32 ip6_table_index = ~0;
17399 u32 l2_table_index = ~0;
17403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17405 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17406 sw_if_index_set = 1;
17407 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17408 sw_if_index_set = 1;
17409 else if (unformat (i, "del"))
17411 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17413 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17415 else if (unformat (i, "l2-table %d", &l2_table_index))
17419 clib_warning ("parse error '%U'", format_unformat_error, i);
17424 if (sw_if_index_set == 0)
17426 errmsg ("missing interface name or sw_if_index");
17430 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17432 mp->sw_if_index = ntohl (sw_if_index);
17433 mp->ip4_table_index = ntohl (ip4_table_index);
17434 mp->ip6_table_index = ntohl (ip6_table_index);
17435 mp->l2_table_index = ntohl (l2_table_index);
17436 mp->is_add = is_add;
17444 api_policer_classify_dump (vat_main_t * vam)
17446 unformat_input_t *i = vam->input;
17447 vl_api_policer_classify_dump_t *mp;
17448 vl_api_control_ping_t *mp_ping;
17449 u8 type = POLICER_CLASSIFY_N_TABLES;
17452 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17456 errmsg ("classify table type must be specified");
17460 if (!vam->json_output)
17462 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17465 M (POLICER_CLASSIFY_DUMP, mp);
17470 /* Use a control ping for synchronization */
17471 MPING (CONTROL_PING, mp_ping);
17474 /* Wait for a reply... */
17480 format_fib_api_path_nh_proto (u8 * s, va_list * args)
17482 vl_api_fib_path_nh_proto_t proto =
17483 va_arg (*args, vl_api_fib_path_nh_proto_t);
17487 case FIB_API_PATH_NH_PROTO_IP4:
17488 s = format (s, "ip4");
17490 case FIB_API_PATH_NH_PROTO_IP6:
17491 s = format (s, "ip6");
17493 case FIB_API_PATH_NH_PROTO_MPLS:
17494 s = format (s, "mpls");
17496 case FIB_API_PATH_NH_PROTO_BIER:
17497 s = format (s, "bier");
17499 case FIB_API_PATH_NH_PROTO_ETHERNET:
17500 s = format (s, "ethernet");
17508 format_vl_api_ip_address_union (u8 * s, va_list * args)
17510 vl_api_address_family_t af = va_arg (*args, int);
17511 const vl_api_address_union_t *u = va_arg (*args, vl_api_address_union_t *);
17516 s = format (s, "%U", format_ip4_address, u->ip4);
17519 s = format (s, "%U", format_ip6_address, u->ip6);
17526 format_vl_api_fib_path_type (u8 * s, va_list * args)
17528 vl_api_fib_path_type_t t = va_arg (*args, vl_api_fib_path_type_t);
17532 case FIB_API_PATH_TYPE_NORMAL:
17533 s = format (s, "normal");
17535 case FIB_API_PATH_TYPE_LOCAL:
17536 s = format (s, "local");
17538 case FIB_API_PATH_TYPE_DROP:
17539 s = format (s, "drop");
17541 case FIB_API_PATH_TYPE_UDP_ENCAP:
17542 s = format (s, "udp-encap");
17544 case FIB_API_PATH_TYPE_BIER_IMP:
17545 s = format (s, "bier-imp");
17547 case FIB_API_PATH_TYPE_ICMP_UNREACH:
17548 s = format (s, "unreach");
17550 case FIB_API_PATH_TYPE_ICMP_PROHIBIT:
17551 s = format (s, "prohibit");
17553 case FIB_API_PATH_TYPE_SOURCE_LOOKUP:
17554 s = format (s, "src-lookup");
17556 case FIB_API_PATH_TYPE_DVR:
17557 s = format (s, "dvr");
17559 case FIB_API_PATH_TYPE_INTERFACE_RX:
17560 s = format (s, "interface-rx");
17562 case FIB_API_PATH_TYPE_CLASSIFY:
17563 s = format (s, "classify");
17571 vl_api_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
17574 " weight %d, sw_if_index %d, type %U, afi %U, next_hop %U",
17575 ntohl (fp->weight), ntohl (fp->sw_if_index),
17576 format_vl_api_fib_path_type, fp->type,
17577 format_fib_api_path_nh_proto, fp->proto,
17578 format_vl_api_ip_address_union, &fp->nh.address);
17582 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17583 vl_api_fib_path_t * fp)
17585 struct in_addr ip4;
17586 struct in6_addr ip6;
17588 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17589 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17590 vat_json_object_add_uint (node, "type", fp->type);
17591 vat_json_object_add_uint (node, "next_hop_proto", fp->proto);
17592 if (fp->proto == FIB_API_PATH_NH_PROTO_IP4)
17594 clib_memcpy (&ip4, &fp->nh.address.ip4, sizeof (ip4));
17595 vat_json_object_add_ip4 (node, "next_hop", ip4);
17597 else if (fp->proto == FIB_API_PATH_NH_PROTO_IP6)
17599 clib_memcpy (&ip6, &fp->nh.address.ip6, sizeof (ip6));
17600 vat_json_object_add_ip6 (node, "next_hop", ip6);
17605 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17607 vat_main_t *vam = &vat_main;
17608 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17609 vl_api_fib_path_t *fp;
17612 print (vam->ofp, "sw_if_index %d via:",
17613 ntohl (mp->mt_tunnel.mt_sw_if_index));
17614 fp = mp->mt_tunnel.mt_paths;
17615 for (i = 0; i < count; i++)
17617 vl_api_fib_path_print (vam, fp);
17621 print (vam->ofp, "");
17624 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17625 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17628 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17630 vat_main_t *vam = &vat_main;
17631 vat_json_node_t *node = NULL;
17632 int count = ntohl (mp->mt_tunnel.mt_n_paths);
17633 vl_api_fib_path_t *fp;
17636 if (VAT_JSON_ARRAY != vam->json_tree.type)
17638 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17639 vat_json_init_array (&vam->json_tree);
17641 node = vat_json_array_add (&vam->json_tree);
17643 vat_json_init_object (node);
17644 vat_json_object_add_uint (node, "sw_if_index",
17645 ntohl (mp->mt_tunnel.mt_sw_if_index));
17647 vat_json_object_add_uint (node, "l2_only", mp->mt_tunnel.mt_l2_only);
17649 fp = mp->mt_tunnel.mt_paths;
17650 for (i = 0; i < count; i++)
17652 vl_api_mpls_fib_path_json_print (node, fp);
17658 api_mpls_tunnel_dump (vat_main_t * vam)
17660 vl_api_mpls_tunnel_dump_t *mp;
17661 vl_api_control_ping_t *mp_ping;
17664 M (MPLS_TUNNEL_DUMP, mp);
17668 /* Use a control ping for synchronization */
17669 MPING (CONTROL_PING, mp_ping);
17676 #define vl_api_mpls_table_details_t_endian vl_noop_handler
17677 #define vl_api_mpls_table_details_t_print vl_noop_handler
17681 vl_api_mpls_table_details_t_handler (vl_api_mpls_table_details_t * mp)
17683 vat_main_t *vam = &vat_main;
17685 print (vam->ofp, "table-id %d,", ntohl (mp->mt_table.mt_table_id));
17688 static void vl_api_mpls_table_details_t_handler_json
17689 (vl_api_mpls_table_details_t * mp)
17691 vat_main_t *vam = &vat_main;
17692 vat_json_node_t *node = NULL;
17694 if (VAT_JSON_ARRAY != vam->json_tree.type)
17696 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17697 vat_json_init_array (&vam->json_tree);
17699 node = vat_json_array_add (&vam->json_tree);
17701 vat_json_init_object (node);
17702 vat_json_object_add_uint (node, "table", ntohl (mp->mt_table.mt_table_id));
17706 api_mpls_table_dump (vat_main_t * vam)
17708 vl_api_mpls_table_dump_t *mp;
17709 vl_api_control_ping_t *mp_ping;
17712 M (MPLS_TABLE_DUMP, mp);
17715 /* Use a control ping for synchronization */
17716 MPING (CONTROL_PING, mp_ping);
17723 #define vl_api_mpls_route_details_t_endian vl_noop_handler
17724 #define vl_api_mpls_route_details_t_print vl_noop_handler
17727 vl_api_mpls_route_details_t_handler (vl_api_mpls_route_details_t * mp)
17729 vat_main_t *vam = &vat_main;
17730 int count = (int) clib_net_to_host_u32 (mp->mr_route.mr_n_paths);
17731 vl_api_fib_path_t *fp;
17735 "table-id %d, label %u, ess_bit %u",
17736 ntohl (mp->mr_route.mr_table_id),
17737 ntohl (mp->mr_route.mr_label), mp->mr_route.mr_eos);
17738 fp = mp->mr_route.mr_paths;
17739 for (i = 0; i < count; i++)
17741 vl_api_fib_path_print (vam, fp);
17746 static void vl_api_mpls_route_details_t_handler_json
17747 (vl_api_mpls_route_details_t * mp)
17749 vat_main_t *vam = &vat_main;
17750 int count = (int) clib_host_to_net_u32 (mp->mr_route.mr_n_paths);
17751 vat_json_node_t *node = NULL;
17752 vl_api_fib_path_t *fp;
17755 if (VAT_JSON_ARRAY != vam->json_tree.type)
17757 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17758 vat_json_init_array (&vam->json_tree);
17760 node = vat_json_array_add (&vam->json_tree);
17762 vat_json_init_object (node);
17763 vat_json_object_add_uint (node, "table", ntohl (mp->mr_route.mr_table_id));
17764 vat_json_object_add_uint (node, "s_bit", mp->mr_route.mr_eos);
17765 vat_json_object_add_uint (node, "label", ntohl (mp->mr_route.mr_label));
17766 vat_json_object_add_uint (node, "path_count", count);
17767 fp = mp->mr_route.mr_paths;
17768 for (i = 0; i < count; i++)
17770 vl_api_mpls_fib_path_json_print (node, fp);
17776 api_mpls_route_dump (vat_main_t * vam)
17778 unformat_input_t *input = vam->input;
17779 vl_api_mpls_route_dump_t *mp;
17780 vl_api_control_ping_t *mp_ping;
17784 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17786 if (unformat (input, "table_id %d", &table_id))
17791 if (table_id == ~0)
17793 errmsg ("missing table id");
17797 M (MPLS_ROUTE_DUMP, mp);
17799 mp->table.mt_table_id = ntohl (table_id);
17802 /* Use a control ping for synchronization */
17803 MPING (CONTROL_PING, mp_ping);
17810 #define vl_api_ip_table_details_t_endian vl_noop_handler
17811 #define vl_api_ip_table_details_t_print vl_noop_handler
17814 vl_api_ip_table_details_t_handler (vl_api_ip_table_details_t * mp)
17816 vat_main_t *vam = &vat_main;
17819 "%s; table-id %d, prefix %U/%d",
17820 mp->table.name, ntohl (mp->table.table_id));
17824 static void vl_api_ip_table_details_t_handler_json
17825 (vl_api_ip_table_details_t * mp)
17827 vat_main_t *vam = &vat_main;
17828 vat_json_node_t *node = NULL;
17830 if (VAT_JSON_ARRAY != vam->json_tree.type)
17832 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17833 vat_json_init_array (&vam->json_tree);
17835 node = vat_json_array_add (&vam->json_tree);
17837 vat_json_init_object (node);
17838 vat_json_object_add_uint (node, "table", ntohl (mp->table.table_id));
17842 api_ip_table_dump (vat_main_t * vam)
17844 vl_api_ip_table_dump_t *mp;
17845 vl_api_control_ping_t *mp_ping;
17848 M (IP_TABLE_DUMP, mp);
17851 /* Use a control ping for synchronization */
17852 MPING (CONTROL_PING, mp_ping);
17860 api_ip_mtable_dump (vat_main_t * vam)
17862 vl_api_ip_mtable_dump_t *mp;
17863 vl_api_control_ping_t *mp_ping;
17866 M (IP_MTABLE_DUMP, mp);
17869 /* Use a control ping for synchronization */
17870 MPING (CONTROL_PING, mp_ping);
17878 api_ip_mroute_dump (vat_main_t * vam)
17880 unformat_input_t *input = vam->input;
17881 vl_api_control_ping_t *mp_ping;
17882 vl_api_ip_mroute_dump_t *mp;
17887 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17889 if (unformat (input, "table_id %d", &table_id))
17891 else if (unformat (input, "ip6"))
17893 else if (unformat (input, "ip4"))
17898 if (table_id == ~0)
17900 errmsg ("missing table id");
17904 M (IP_MROUTE_DUMP, mp);
17905 mp->table.table_id = table_id;
17906 mp->table.is_ip6 = is_ip6;
17909 /* Use a control ping for synchronization */
17910 MPING (CONTROL_PING, mp_ping);
17917 #define vl_api_ip_route_details_t_endian vl_noop_handler
17918 #define vl_api_ip_route_details_t_print vl_noop_handler
17921 vl_api_ip_route_details_t_handler (vl_api_ip_route_details_t * mp)
17923 vat_main_t *vam = &vat_main;
17924 u8 count = mp->route.n_paths;
17925 vl_api_fib_path_t *fp;
17929 "table-id %d, prefix %U/%d",
17930 ntohl (mp->route.table_id),
17931 format_ip46_address, mp->route.prefix.address, mp->route.prefix.len);
17932 for (i = 0; i < count; i++)
17934 fp = &mp->route.paths[i];
17936 vl_api_fib_path_print (vam, fp);
17941 static void vl_api_ip_route_details_t_handler_json
17942 (vl_api_ip_route_details_t * mp)
17944 vat_main_t *vam = &vat_main;
17945 u8 count = mp->route.n_paths;
17946 vat_json_node_t *node = NULL;
17947 struct in_addr ip4;
17948 struct in6_addr ip6;
17949 vl_api_fib_path_t *fp;
17952 if (VAT_JSON_ARRAY != vam->json_tree.type)
17954 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17955 vat_json_init_array (&vam->json_tree);
17957 node = vat_json_array_add (&vam->json_tree);
17959 vat_json_init_object (node);
17960 vat_json_object_add_uint (node, "table", ntohl (mp->route.table_id));
17961 if (ADDRESS_IP6 == mp->route.prefix.address.af)
17963 clib_memcpy (&ip6, &mp->route.prefix.address.un.ip6, sizeof (ip6));
17964 vat_json_object_add_ip6 (node, "prefix", ip6);
17968 clib_memcpy (&ip4, &mp->route.prefix.address.un.ip4, sizeof (ip4));
17969 vat_json_object_add_ip4 (node, "prefix", ip4);
17971 vat_json_object_add_uint (node, "mask_length", mp->route.prefix.len);
17972 vat_json_object_add_uint (node, "path_count", count);
17973 for (i = 0; i < count; i++)
17975 fp = &mp->route.paths[i];
17976 vl_api_mpls_fib_path_json_print (node, fp);
17981 api_ip_route_dump (vat_main_t * vam)
17983 unformat_input_t *input = vam->input;
17984 vl_api_ip_route_dump_t *mp;
17985 vl_api_control_ping_t *mp_ping;
17991 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17993 if (unformat (input, "table_id %d", &table_id))
17995 else if (unformat (input, "ip6"))
17997 else if (unformat (input, "ip4"))
18002 if (table_id == ~0)
18004 errmsg ("missing table id");
18008 M (IP_ROUTE_DUMP, mp);
18010 mp->table.table_id = table_id;
18011 mp->table.is_ip6 = is_ip6;
18015 /* Use a control ping for synchronization */
18016 MPING (CONTROL_PING, mp_ping);
18024 api_classify_table_ids (vat_main_t * vam)
18026 vl_api_classify_table_ids_t *mp;
18029 /* Construct the API message */
18030 M (CLASSIFY_TABLE_IDS, mp);
18039 api_classify_table_by_interface (vat_main_t * vam)
18041 unformat_input_t *input = vam->input;
18042 vl_api_classify_table_by_interface_t *mp;
18044 u32 sw_if_index = ~0;
18046 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18048 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18050 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18055 if (sw_if_index == ~0)
18057 errmsg ("missing interface name or sw_if_index");
18061 /* Construct the API message */
18062 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18064 mp->sw_if_index = ntohl (sw_if_index);
18072 api_classify_table_info (vat_main_t * vam)
18074 unformat_input_t *input = vam->input;
18075 vl_api_classify_table_info_t *mp;
18079 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18081 if (unformat (input, "table_id %d", &table_id))
18086 if (table_id == ~0)
18088 errmsg ("missing table id");
18092 /* Construct the API message */
18093 M (CLASSIFY_TABLE_INFO, mp);
18095 mp->table_id = ntohl (table_id);
18103 api_classify_session_dump (vat_main_t * vam)
18105 unformat_input_t *input = vam->input;
18106 vl_api_classify_session_dump_t *mp;
18107 vl_api_control_ping_t *mp_ping;
18111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18113 if (unformat (input, "table_id %d", &table_id))
18118 if (table_id == ~0)
18120 errmsg ("missing table id");
18124 /* Construct the API message */
18125 M (CLASSIFY_SESSION_DUMP, mp);
18127 mp->table_id = ntohl (table_id);
18130 /* Use a control ping for synchronization */
18131 MPING (CONTROL_PING, mp_ping);
18139 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18141 vat_main_t *vam = &vat_main;
18143 print (vam->ofp, "collector_address %U, collector_port %d, "
18144 "src_address %U, vrf_id %d, path_mtu %u, "
18145 "template_interval %u, udp_checksum %d",
18146 format_ip4_address, mp->collector_address,
18147 ntohs (mp->collector_port),
18148 format_ip4_address, mp->src_address,
18149 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18150 ntohl (mp->template_interval), mp->udp_checksum);
18153 vam->result_ready = 1;
18157 vl_api_ipfix_exporter_details_t_handler_json
18158 (vl_api_ipfix_exporter_details_t * mp)
18160 vat_main_t *vam = &vat_main;
18161 vat_json_node_t node;
18162 struct in_addr collector_address;
18163 struct in_addr src_address;
18165 vat_json_init_object (&node);
18166 clib_memcpy (&collector_address, &mp->collector_address,
18167 sizeof (collector_address));
18168 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18169 vat_json_object_add_uint (&node, "collector_port",
18170 ntohs (mp->collector_port));
18171 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18172 vat_json_object_add_ip4 (&node, "src_address", src_address);
18173 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18174 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18175 vat_json_object_add_uint (&node, "template_interval",
18176 ntohl (mp->template_interval));
18177 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18179 vat_json_print (vam->ofp, &node);
18180 vat_json_free (&node);
18182 vam->result_ready = 1;
18186 api_ipfix_exporter_dump (vat_main_t * vam)
18188 vl_api_ipfix_exporter_dump_t *mp;
18191 /* Construct the API message */
18192 M (IPFIX_EXPORTER_DUMP, mp);
18201 api_ipfix_classify_stream_dump (vat_main_t * vam)
18203 vl_api_ipfix_classify_stream_dump_t *mp;
18206 /* Construct the API message */
18207 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18218 vl_api_ipfix_classify_stream_details_t_handler
18219 (vl_api_ipfix_classify_stream_details_t * mp)
18221 vat_main_t *vam = &vat_main;
18222 print (vam->ofp, "domain_id %d, src_port %d",
18223 ntohl (mp->domain_id), ntohs (mp->src_port));
18225 vam->result_ready = 1;
18229 vl_api_ipfix_classify_stream_details_t_handler_json
18230 (vl_api_ipfix_classify_stream_details_t * mp)
18232 vat_main_t *vam = &vat_main;
18233 vat_json_node_t node;
18235 vat_json_init_object (&node);
18236 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18237 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18239 vat_json_print (vam->ofp, &node);
18240 vat_json_free (&node);
18242 vam->result_ready = 1;
18246 api_ipfix_classify_table_dump (vat_main_t * vam)
18248 vl_api_ipfix_classify_table_dump_t *mp;
18249 vl_api_control_ping_t *mp_ping;
18252 if (!vam->json_output)
18254 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18255 "transport_protocol");
18258 /* Construct the API message */
18259 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18264 /* Use a control ping for synchronization */
18265 MPING (CONTROL_PING, mp_ping);
18273 vl_api_ipfix_classify_table_details_t_handler
18274 (vl_api_ipfix_classify_table_details_t * mp)
18276 vat_main_t *vam = &vat_main;
18277 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18278 mp->transport_protocol);
18282 vl_api_ipfix_classify_table_details_t_handler_json
18283 (vl_api_ipfix_classify_table_details_t * mp)
18285 vat_json_node_t *node = NULL;
18286 vat_main_t *vam = &vat_main;
18288 if (VAT_JSON_ARRAY != vam->json_tree.type)
18290 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18291 vat_json_init_array (&vam->json_tree);
18294 node = vat_json_array_add (&vam->json_tree);
18295 vat_json_init_object (node);
18297 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18298 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18299 vat_json_object_add_uint (node, "transport_protocol",
18300 mp->transport_protocol);
18304 api_sw_interface_span_enable_disable (vat_main_t * vam)
18306 unformat_input_t *i = vam->input;
18307 vl_api_sw_interface_span_enable_disable_t *mp;
18308 u32 src_sw_if_index = ~0;
18309 u32 dst_sw_if_index = ~0;
18314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18317 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18319 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18323 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18325 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18327 else if (unformat (i, "disable"))
18329 else if (unformat (i, "rx"))
18331 else if (unformat (i, "tx"))
18333 else if (unformat (i, "both"))
18335 else if (unformat (i, "l2"))
18341 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18343 mp->sw_if_index_from = htonl (src_sw_if_index);
18344 mp->sw_if_index_to = htonl (dst_sw_if_index);
18354 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18357 vat_main_t *vam = &vat_main;
18358 u8 *sw_if_from_name = 0;
18359 u8 *sw_if_to_name = 0;
18360 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18361 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18362 char *states[] = { "none", "rx", "tx", "both" };
18366 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18368 if ((u32) p->value[0] == sw_if_index_from)
18370 sw_if_from_name = (u8 *)(p->key);
18374 if ((u32) p->value[0] == sw_if_index_to)
18376 sw_if_to_name = (u8 *)(p->key);
18377 if (sw_if_from_name)
18382 print (vam->ofp, "%20s => %20s (%s) %s",
18383 sw_if_from_name, sw_if_to_name, states[mp->state],
18384 mp->is_l2 ? "l2" : "device");
18388 vl_api_sw_interface_span_details_t_handler_json
18389 (vl_api_sw_interface_span_details_t * mp)
18391 vat_main_t *vam = &vat_main;
18392 vat_json_node_t *node = NULL;
18393 u8 *sw_if_from_name = 0;
18394 u8 *sw_if_to_name = 0;
18395 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18396 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18400 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18402 if ((u32) p->value[0] == sw_if_index_from)
18404 sw_if_from_name = (u8 *)(p->key);
18408 if ((u32) p->value[0] == sw_if_index_to)
18410 sw_if_to_name = (u8 *)(p->key);
18411 if (sw_if_from_name)
18417 if (VAT_JSON_ARRAY != vam->json_tree.type)
18419 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18420 vat_json_init_array (&vam->json_tree);
18422 node = vat_json_array_add (&vam->json_tree);
18424 vat_json_init_object (node);
18425 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18426 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18427 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18428 if (0 != sw_if_to_name)
18430 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18432 vat_json_object_add_uint (node, "state", mp->state);
18433 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
18437 api_sw_interface_span_dump (vat_main_t * vam)
18439 unformat_input_t *input = vam->input;
18440 vl_api_sw_interface_span_dump_t *mp;
18441 vl_api_control_ping_t *mp_ping;
18445 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18447 if (unformat (input, "l2"))
18453 M (SW_INTERFACE_SPAN_DUMP, mp);
18457 /* Use a control ping for synchronization */
18458 MPING (CONTROL_PING, mp_ping);
18466 api_pg_create_interface (vat_main_t * vam)
18468 unformat_input_t *input = vam->input;
18469 vl_api_pg_create_interface_t *mp;
18471 u32 if_id = ~0, gso_size = 0;
18472 u8 gso_enabled = 0;
18474 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18476 if (unformat (input, "if_id %d", &if_id))
18478 else if (unformat (input, "gso-enabled"))
18481 if (unformat (input, "gso-size %u", &gso_size))
18485 errmsg ("missing gso-size");
18494 errmsg ("missing pg interface index");
18498 /* Construct the API message */
18499 M (PG_CREATE_INTERFACE, mp);
18501 mp->interface_id = ntohl (if_id);
18502 mp->gso_enabled = gso_enabled;
18510 api_pg_capture (vat_main_t * vam)
18512 unformat_input_t *input = vam->input;
18513 vl_api_pg_capture_t *mp;
18518 u8 pcap_file_set = 0;
18521 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18523 if (unformat (input, "if_id %d", &if_id))
18525 else if (unformat (input, "pcap %s", &pcap_file))
18527 else if (unformat (input, "count %d", &count))
18529 else if (unformat (input, "disable"))
18536 errmsg ("missing pg interface index");
18539 if (pcap_file_set > 0)
18541 if (vec_len (pcap_file) > 255)
18543 errmsg ("pcap file name is too long");
18548 /* Construct the API message */
18549 M (PG_CAPTURE, mp);
18551 mp->interface_id = ntohl (if_id);
18552 mp->is_enabled = enable;
18553 mp->count = ntohl (count);
18554 if (pcap_file_set != 0)
18556 vl_api_vec_to_api_string (pcap_file, &mp->pcap_file_name);
18558 vec_free (pcap_file);
18566 api_pg_enable_disable (vat_main_t * vam)
18568 unformat_input_t *input = vam->input;
18569 vl_api_pg_enable_disable_t *mp;
18572 u8 stream_name_set = 0;
18573 u8 *stream_name = 0;
18575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18577 if (unformat (input, "stream %s", &stream_name))
18578 stream_name_set = 1;
18579 else if (unformat (input, "disable"))
18585 if (stream_name_set > 0)
18587 if (vec_len (stream_name) > 255)
18589 errmsg ("stream name too long");
18594 /* Construct the API message */
18595 M (PG_ENABLE_DISABLE, mp);
18597 mp->is_enabled = enable;
18598 if (stream_name_set != 0)
18600 vl_api_vec_to_api_string (stream_name, &mp->stream_name);
18602 vec_free (stream_name);
18610 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18612 unformat_input_t *input = vam->input;
18613 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18615 u16 *low_ports = 0;
18616 u16 *high_ports = 0;
18619 vl_api_prefix_t prefix;
18626 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18628 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
18630 else if (unformat (input, "vrf %d", &vrf_id))
18632 else if (unformat (input, "del"))
18634 else if (unformat (input, "port %d", &tmp))
18636 if (tmp == 0 || tmp > 65535)
18638 errmsg ("port %d out of range", tmp);
18642 this_hi = this_low + 1;
18643 vec_add1 (low_ports, this_low);
18644 vec_add1 (high_ports, this_hi);
18646 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18648 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18650 errmsg ("incorrect range parameters");
18654 /* Note: in debug CLI +1 is added to high before
18655 passing to real fn that does "the work"
18656 (ip_source_and_port_range_check_add_del).
18657 This fn is a wrapper around the binary API fn a
18658 control plane will call, which expects this increment
18659 to have occurred. Hence letting the binary API control
18660 plane fn do the increment for consistency between VAT
18661 and other control planes.
18664 vec_add1 (low_ports, this_low);
18665 vec_add1 (high_ports, this_hi);
18671 if (prefix_set == 0)
18673 errmsg ("<address>/<mask> not specified");
18679 errmsg ("VRF ID required, not specified");
18686 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18690 if (vec_len (low_ports) == 0)
18692 errmsg ("At least one port or port range required");
18696 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18698 mp->is_add = is_add;
18700 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
18702 mp->number_of_ranges = vec_len (low_ports);
18704 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18705 vec_free (low_ports);
18707 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18708 vec_free (high_ports);
18710 mp->vrf_id = ntohl (vrf_id);
18718 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18720 unformat_input_t *input = vam->input;
18721 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18722 u32 sw_if_index = ~0;
18724 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18725 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18731 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18733 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18735 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18737 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18739 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18741 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18743 else if (unformat (input, "del"))
18749 if (sw_if_index == ~0)
18751 errmsg ("Interface required but not specified");
18757 errmsg ("VRF ID required but not specified");
18761 if (tcp_out_vrf_id == 0
18762 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18765 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18769 /* Construct the API message */
18770 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18772 mp->sw_if_index = ntohl (sw_if_index);
18773 mp->is_add = is_add;
18774 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18775 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18776 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18777 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18782 /* Wait for a reply... */
18788 api_set_punt (vat_main_t * vam)
18790 unformat_input_t *i = vam->input;
18791 vl_api_address_family_t af;
18792 vl_api_set_punt_t *mp;
18798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18800 if (unformat (i, "%U", unformat_vl_api_address_family, &af))
18802 else if (unformat (i, "protocol %d", &protocol))
18804 else if (unformat (i, "port %d", &port))
18806 else if (unformat (i, "del"))
18810 clib_warning ("parse error '%U'", format_unformat_error, i);
18817 mp->is_add = (u8) is_add;
18818 mp->punt.type = PUNT_API_TYPE_L4;
18819 mp->punt.punt.l4.af = af;
18820 mp->punt.punt.l4.protocol = (u8) protocol;
18821 mp->punt.punt.l4.port = htons ((u16) port);
18829 api_delete_subif (vat_main_t * vam)
18831 unformat_input_t *i = vam->input;
18832 vl_api_delete_subif_t *mp;
18833 u32 sw_if_index = ~0;
18836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18838 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18840 if (unformat (i, "sw_if_index %d", &sw_if_index))
18846 if (sw_if_index == ~0)
18848 errmsg ("missing sw_if_index");
18852 /* Construct the API message */
18853 M (DELETE_SUBIF, mp);
18854 mp->sw_if_index = ntohl (sw_if_index);
18861 #define foreach_pbb_vtr_op \
18862 _("disable", L2_VTR_DISABLED) \
18863 _("pop", L2_VTR_POP_2) \
18864 _("push", L2_VTR_PUSH_2)
18867 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
18869 unformat_input_t *i = vam->input;
18870 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
18871 u32 sw_if_index = ~0, vtr_op = ~0;
18872 u16 outer_tag = ~0;
18873 u8 dmac[6], smac[6];
18874 u8 dmac_set = 0, smac_set = 0;
18880 /* Shut up coverity */
18881 clib_memset (dmac, 0, sizeof (dmac));
18882 clib_memset (smac, 0, sizeof (smac));
18884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18886 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18888 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18890 else if (unformat (i, "vtr_op %d", &vtr_op))
18892 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
18895 else if (unformat (i, "translate_pbb_stag"))
18897 if (unformat (i, "%d", &tmp))
18899 vtr_op = L2_VTR_TRANSLATE_2_1;
18905 ("translate_pbb_stag operation requires outer tag definition");
18909 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
18911 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
18913 else if (unformat (i, "sid %d", &sid))
18915 else if (unformat (i, "vlanid %d", &tmp))
18919 clib_warning ("parse error '%U'", format_unformat_error, i);
18924 if ((sw_if_index == ~0) || (vtr_op == ~0))
18926 errmsg ("missing sw_if_index or vtr operation");
18929 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
18930 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
18933 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
18937 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
18938 mp->sw_if_index = ntohl (sw_if_index);
18939 mp->vtr_op = ntohl (vtr_op);
18940 mp->outer_tag = ntohs (outer_tag);
18941 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
18942 clib_memcpy (mp->b_smac, smac, sizeof (smac));
18943 mp->b_vlanid = ntohs (vlanid);
18944 mp->i_sid = ntohl (sid);
18952 api_flow_classify_set_interface (vat_main_t * vam)
18954 unformat_input_t *i = vam->input;
18955 vl_api_flow_classify_set_interface_t *mp;
18957 int sw_if_index_set;
18958 u32 ip4_table_index = ~0;
18959 u32 ip6_table_index = ~0;
18963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18966 sw_if_index_set = 1;
18967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18968 sw_if_index_set = 1;
18969 else if (unformat (i, "del"))
18971 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18973 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18977 clib_warning ("parse error '%U'", format_unformat_error, i);
18982 if (sw_if_index_set == 0)
18984 errmsg ("missing interface name or sw_if_index");
18988 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
18990 mp->sw_if_index = ntohl (sw_if_index);
18991 mp->ip4_table_index = ntohl (ip4_table_index);
18992 mp->ip6_table_index = ntohl (ip6_table_index);
18993 mp->is_add = is_add;
19001 api_flow_classify_dump (vat_main_t * vam)
19003 unformat_input_t *i = vam->input;
19004 vl_api_flow_classify_dump_t *mp;
19005 vl_api_control_ping_t *mp_ping;
19006 u8 type = FLOW_CLASSIFY_N_TABLES;
19009 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19013 errmsg ("classify table type must be specified");
19017 if (!vam->json_output)
19019 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19022 M (FLOW_CLASSIFY_DUMP, mp);
19027 /* Use a control ping for synchronization */
19028 MPING (CONTROL_PING, mp_ping);
19031 /* Wait for a reply... */
19037 api_feature_enable_disable (vat_main_t * vam)
19039 unformat_input_t *i = vam->input;
19040 vl_api_feature_enable_disable_t *mp;
19042 u8 *feature_name = 0;
19043 u32 sw_if_index = ~0;
19047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19049 if (unformat (i, "arc_name %s", &arc_name))
19051 else if (unformat (i, "feature_name %s", &feature_name))
19054 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19056 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19058 else if (unformat (i, "disable"))
19066 errmsg ("missing arc name");
19069 if (vec_len (arc_name) > 63)
19071 errmsg ("arc name too long");
19074 if (feature_name == 0)
19076 errmsg ("missing feature name");
19079 if (vec_len (feature_name) > 63)
19081 errmsg ("feature name too long");
19084 if (sw_if_index == ~0)
19086 errmsg ("missing interface name or sw_if_index");
19090 /* Construct the API message */
19091 M (FEATURE_ENABLE_DISABLE, mp);
19092 mp->sw_if_index = ntohl (sw_if_index);
19093 mp->enable = enable;
19094 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19095 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19096 vec_free (arc_name);
19097 vec_free (feature_name);
19105 api_feature_gso_enable_disable (vat_main_t * vam)
19107 unformat_input_t *i = vam->input;
19108 vl_api_feature_gso_enable_disable_t *mp;
19109 u32 sw_if_index = ~0;
19113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19117 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19119 else if (unformat (i, "enable"))
19121 else if (unformat (i, "disable"))
19127 if (sw_if_index == ~0)
19129 errmsg ("missing interface name or sw_if_index");
19133 /* Construct the API message */
19134 M (FEATURE_GSO_ENABLE_DISABLE, mp);
19135 mp->sw_if_index = ntohl (sw_if_index);
19136 mp->enable_disable = enable;
19144 api_sw_interface_tag_add_del (vat_main_t * vam)
19146 unformat_input_t *i = vam->input;
19147 vl_api_sw_interface_tag_add_del_t *mp;
19148 u32 sw_if_index = ~0;
19153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19155 if (unformat (i, "tag %s", &tag))
19157 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19159 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19161 else if (unformat (i, "del"))
19167 if (sw_if_index == ~0)
19169 errmsg ("missing interface name or sw_if_index");
19173 if (enable && (tag == 0))
19175 errmsg ("no tag specified");
19179 /* Construct the API message */
19180 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19181 mp->sw_if_index = ntohl (sw_if_index);
19182 mp->is_add = enable;
19184 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19193 api_sw_interface_add_del_mac_address (vat_main_t * vam)
19195 unformat_input_t *i = vam->input;
19196 vl_api_mac_address_t mac = { 0 };
19197 vl_api_sw_interface_add_del_mac_address_t *mp;
19198 u32 sw_if_index = ~0;
19203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19205 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19207 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19209 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
19211 else if (unformat (i, "del"))
19217 if (sw_if_index == ~0)
19219 errmsg ("missing interface name or sw_if_index");
19225 errmsg ("missing MAC address");
19229 /* Construct the API message */
19230 M (SW_INTERFACE_ADD_DEL_MAC_ADDRESS, mp);
19231 mp->sw_if_index = ntohl (sw_if_index);
19232 mp->is_add = is_add;
19233 clib_memcpy (&mp->addr, &mac, sizeof (mac));
19240 static void vl_api_l2_xconnect_details_t_handler
19241 (vl_api_l2_xconnect_details_t * mp)
19243 vat_main_t *vam = &vat_main;
19245 print (vam->ofp, "%15d%15d",
19246 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19249 static void vl_api_l2_xconnect_details_t_handler_json
19250 (vl_api_l2_xconnect_details_t * mp)
19252 vat_main_t *vam = &vat_main;
19253 vat_json_node_t *node = NULL;
19255 if (VAT_JSON_ARRAY != vam->json_tree.type)
19257 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19258 vat_json_init_array (&vam->json_tree);
19260 node = vat_json_array_add (&vam->json_tree);
19262 vat_json_init_object (node);
19263 vat_json_object_add_uint (node, "rx_sw_if_index",
19264 ntohl (mp->rx_sw_if_index));
19265 vat_json_object_add_uint (node, "tx_sw_if_index",
19266 ntohl (mp->tx_sw_if_index));
19270 api_l2_xconnect_dump (vat_main_t * vam)
19272 vl_api_l2_xconnect_dump_t *mp;
19273 vl_api_control_ping_t *mp_ping;
19276 if (!vam->json_output)
19278 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19281 M (L2_XCONNECT_DUMP, mp);
19285 /* Use a control ping for synchronization */
19286 MPING (CONTROL_PING, mp_ping);
19294 api_hw_interface_set_mtu (vat_main_t * vam)
19296 unformat_input_t *i = vam->input;
19297 vl_api_hw_interface_set_mtu_t *mp;
19298 u32 sw_if_index = ~0;
19302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19304 if (unformat (i, "mtu %d", &mtu))
19306 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19308 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19314 if (sw_if_index == ~0)
19316 errmsg ("missing interface name or sw_if_index");
19322 errmsg ("no mtu specified");
19326 /* Construct the API message */
19327 M (HW_INTERFACE_SET_MTU, mp);
19328 mp->sw_if_index = ntohl (sw_if_index);
19329 mp->mtu = ntohs ((u16) mtu);
19337 api_p2p_ethernet_add (vat_main_t * vam)
19339 unformat_input_t *i = vam->input;
19340 vl_api_p2p_ethernet_add_t *mp;
19341 u32 parent_if_index = ~0;
19347 clib_memset (remote_mac, 0, sizeof (remote_mac));
19348 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19350 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19352 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19356 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19358 else if (unformat (i, "sub_id %d", &sub_id))
19362 clib_warning ("parse error '%U'", format_unformat_error, i);
19367 if (parent_if_index == ~0)
19369 errmsg ("missing interface name or sw_if_index");
19374 errmsg ("missing remote mac address");
19379 errmsg ("missing sub-interface id");
19383 M (P2P_ETHERNET_ADD, mp);
19384 mp->parent_if_index = ntohl (parent_if_index);
19385 mp->subif_id = ntohl (sub_id);
19386 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19394 api_p2p_ethernet_del (vat_main_t * vam)
19396 unformat_input_t *i = vam->input;
19397 vl_api_p2p_ethernet_del_t *mp;
19398 u32 parent_if_index = ~0;
19403 clib_memset (remote_mac, 0, sizeof (remote_mac));
19404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19406 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19408 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19412 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19416 clib_warning ("parse error '%U'", format_unformat_error, i);
19421 if (parent_if_index == ~0)
19423 errmsg ("missing interface name or sw_if_index");
19428 errmsg ("missing remote mac address");
19432 M (P2P_ETHERNET_DEL, mp);
19433 mp->parent_if_index = ntohl (parent_if_index);
19434 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19442 api_lldp_config (vat_main_t * vam)
19444 unformat_input_t *i = vam->input;
19445 vl_api_lldp_config_t *mp;
19447 int tx_interval = 0;
19448 u8 *sys_name = NULL;
19451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19453 if (unformat (i, "system-name %s", &sys_name))
19455 else if (unformat (i, "tx-hold %d", &tx_hold))
19457 else if (unformat (i, "tx-interval %d", &tx_interval))
19461 clib_warning ("parse error '%U'", format_unformat_error, i);
19466 vec_add1 (sys_name, 0);
19468 M (LLDP_CONFIG, mp);
19469 mp->tx_hold = htonl (tx_hold);
19470 mp->tx_interval = htonl (tx_interval);
19471 vl_api_vec_to_api_string (sys_name, &mp->system_name);
19472 vec_free (sys_name);
19480 api_sw_interface_set_lldp (vat_main_t * vam)
19482 unformat_input_t *i = vam->input;
19483 vl_api_sw_interface_set_lldp_t *mp;
19484 u32 sw_if_index = ~0;
19486 u8 *port_desc = NULL, *mgmt_oid = NULL;
19487 ip4_address_t ip4_addr;
19488 ip6_address_t ip6_addr;
19491 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
19492 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
19494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19496 if (unformat (i, "disable"))
19499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19503 else if (unformat (i, "port-desc %s", &port_desc))
19505 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
19507 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
19509 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
19515 if (sw_if_index == ~0)
19517 errmsg ("missing interface name or sw_if_index");
19521 /* Construct the API message */
19522 vec_add1 (port_desc, 0);
19523 vec_add1 (mgmt_oid, 0);
19524 M (SW_INTERFACE_SET_LLDP, mp);
19525 mp->sw_if_index = ntohl (sw_if_index);
19526 mp->enable = enable;
19527 vl_api_vec_to_api_string (port_desc, &mp->port_desc);
19528 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
19529 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
19530 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
19531 vec_free (port_desc);
19532 vec_free (mgmt_oid);
19540 api_tcp_configure_src_addresses (vat_main_t * vam)
19542 vl_api_tcp_configure_src_addresses_t *mp;
19543 unformat_input_t *i = vam->input;
19544 vl_api_address_t first, last;
19549 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19551 if (unformat (i, "%U - %U",
19552 unformat_vl_api_address, &first,
19553 unformat_vl_api_address, &last))
19557 errmsg ("one range per message (range already set)");
19562 else if (unformat (i, "vrf %d", &vrf_id))
19568 if (range_set == 0)
19570 errmsg ("address range not set");
19574 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19576 mp->vrf_id = ntohl (vrf_id);
19577 clib_memcpy (&mp->first_address, &first, sizeof (first));
19578 clib_memcpy (&mp->last_address, &last, sizeof (last));
19585 static void vl_api_app_namespace_add_del_reply_t_handler
19586 (vl_api_app_namespace_add_del_reply_t * mp)
19588 vat_main_t *vam = &vat_main;
19589 i32 retval = ntohl (mp->retval);
19590 if (vam->async_mode)
19592 vam->async_errors += (retval < 0);
19596 vam->retval = retval;
19598 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
19599 vam->result_ready = 1;
19603 static void vl_api_app_namespace_add_del_reply_t_handler_json
19604 (vl_api_app_namespace_add_del_reply_t * mp)
19606 vat_main_t *vam = &vat_main;
19607 vat_json_node_t node;
19609 vat_json_init_object (&node);
19610 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
19611 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
19613 vat_json_print (vam->ofp, &node);
19614 vat_json_free (&node);
19616 vam->retval = ntohl (mp->retval);
19617 vam->result_ready = 1;
19621 api_app_namespace_add_del (vat_main_t * vam)
19623 vl_api_app_namespace_add_del_t *mp;
19624 unformat_input_t *i = vam->input;
19625 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
19626 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
19630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19632 if (unformat (i, "id %_%v%_", &ns_id))
19634 else if (unformat (i, "secret %lu", &secret))
19636 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19637 sw_if_index_set = 1;
19638 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
19640 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
19645 if (!ns_id || !secret_set || !sw_if_index_set)
19647 errmsg ("namespace id, secret and sw_if_index must be set");
19650 if (vec_len (ns_id) > 64)
19652 errmsg ("namespace id too long");
19655 M (APP_NAMESPACE_ADD_DEL, mp);
19657 vl_api_vec_to_api_string (ns_id, &mp->namespace_id);
19658 mp->secret = clib_host_to_net_u64 (secret);
19659 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19660 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
19661 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
19669 api_sock_init_shm (vat_main_t * vam)
19671 #if VPP_API_TEST_BUILTIN == 0
19672 unformat_input_t *i = vam->input;
19673 vl_api_shm_elem_config_t *config = 0;
19674 u64 size = 64 << 20;
19677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19679 if (unformat (i, "size %U", unformat_memory_size, &size))
19686 * Canned custom ring allocator config.
19687 * Should probably parse all of this
19689 vec_validate (config, 6);
19690 config[0].type = VL_API_VLIB_RING;
19691 config[0].size = 256;
19692 config[0].count = 32;
19694 config[1].type = VL_API_VLIB_RING;
19695 config[1].size = 1024;
19696 config[1].count = 16;
19698 config[2].type = VL_API_VLIB_RING;
19699 config[2].size = 4096;
19700 config[2].count = 2;
19702 config[3].type = VL_API_CLIENT_RING;
19703 config[3].size = 256;
19704 config[3].count = 32;
19706 config[4].type = VL_API_CLIENT_RING;
19707 config[4].size = 1024;
19708 config[4].count = 16;
19710 config[5].type = VL_API_CLIENT_RING;
19711 config[5].size = 4096;
19712 config[5].count = 2;
19714 config[6].type = VL_API_QUEUE;
19715 config[6].count = 128;
19716 config[6].size = sizeof (uword);
19718 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
19720 vam->client_index_invalid = 1;
19728 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
19730 vat_main_t *vam = &vat_main;
19731 fib_prefix_t lcl, rmt;
19733 ip_prefix_decode (&mp->lcl, &lcl);
19734 ip_prefix_decode (&mp->rmt, &rmt);
19736 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19739 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19740 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19741 mp->scope, format_ip4_address, &lcl.fp_addr.ip4, lcl.fp_len,
19742 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
19743 &rmt.fp_addr.ip4, rmt.fp_len,
19744 clib_net_to_host_u16 (mp->rmt_port),
19745 clib_net_to_host_u32 (mp->action_index), mp->tag);
19750 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
19751 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
19752 mp->scope, format_ip6_address, &lcl.fp_addr.ip6, lcl.fp_len,
19753 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
19754 &rmt.fp_addr.ip6, rmt.fp_len,
19755 clib_net_to_host_u16 (mp->rmt_port),
19756 clib_net_to_host_u32 (mp->action_index), mp->tag);
19761 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
19764 vat_main_t *vam = &vat_main;
19765 vat_json_node_t *node = NULL;
19766 struct in6_addr ip6;
19767 struct in_addr ip4;
19769 fib_prefix_t lcl, rmt;
19771 ip_prefix_decode (&mp->lcl, &lcl);
19772 ip_prefix_decode (&mp->rmt, &rmt);
19774 if (VAT_JSON_ARRAY != vam->json_tree.type)
19776 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19777 vat_json_init_array (&vam->json_tree);
19779 node = vat_json_array_add (&vam->json_tree);
19780 vat_json_init_object (node);
19782 vat_json_object_add_uint (node, "appns_index",
19783 clib_net_to_host_u32 (mp->appns_index));
19784 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
19785 vat_json_object_add_uint (node, "scope", mp->scope);
19786 vat_json_object_add_uint (node, "action_index",
19787 clib_net_to_host_u32 (mp->action_index));
19788 vat_json_object_add_uint (node, "lcl_port",
19789 clib_net_to_host_u16 (mp->lcl_port));
19790 vat_json_object_add_uint (node, "rmt_port",
19791 clib_net_to_host_u16 (mp->rmt_port));
19792 vat_json_object_add_uint (node, "lcl_plen", lcl.fp_len);
19793 vat_json_object_add_uint (node, "rmt_plen", rmt.fp_len);
19794 vat_json_object_add_string_copy (node, "tag", mp->tag);
19795 if (lcl.fp_proto == FIB_PROTOCOL_IP4)
19797 clib_memcpy (&ip4, &lcl.fp_addr.ip4, sizeof (ip4));
19798 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
19799 clib_memcpy (&ip4, &rmt.fp_addr.ip4, sizeof (ip4));
19800 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
19804 clib_memcpy (&ip6, &lcl.fp_addr.ip6, sizeof (ip6));
19805 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
19806 clib_memcpy (&ip6, &rmt.fp_addr.ip6, sizeof (ip6));
19807 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
19812 api_session_rule_add_del (vat_main_t * vam)
19814 vl_api_session_rule_add_del_t *mp;
19815 unformat_input_t *i = vam->input;
19816 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
19817 u32 appns_index = 0, scope = 0;
19818 ip4_address_t lcl_ip4, rmt_ip4;
19819 ip6_address_t lcl_ip6, rmt_ip6;
19820 u8 is_ip4 = 1, conn_set = 0;
19821 u8 is_add = 1, *tag = 0;
19823 fib_prefix_t lcl, rmt;
19825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19827 if (unformat (i, "del"))
19829 else if (unformat (i, "add"))
19831 else if (unformat (i, "proto tcp"))
19833 else if (unformat (i, "proto udp"))
19835 else if (unformat (i, "appns %d", &appns_index))
19837 else if (unformat (i, "scope %d", &scope))
19839 else if (unformat (i, "tag %_%v%_", &tag))
19843 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
19844 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
19852 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
19853 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
19859 else if (unformat (i, "action %d", &action))
19864 if (proto == ~0 || !conn_set || action == ~0)
19866 errmsg ("transport proto, connection and action must be set");
19872 errmsg ("scope should be 0-3");
19876 M (SESSION_RULE_ADD_DEL, mp);
19878 clib_memset (&lcl, 0, sizeof (lcl));
19879 clib_memset (&rmt, 0, sizeof (rmt));
19882 ip_set (&lcl.fp_addr, &lcl_ip4, 1);
19883 ip_set (&rmt.fp_addr, &rmt_ip4, 1);
19884 lcl.fp_len = lcl_plen;
19885 rmt.fp_len = rmt_plen;
19889 ip_set (&lcl.fp_addr, &lcl_ip6, 0);
19890 ip_set (&rmt.fp_addr, &rmt_ip6, 0);
19891 lcl.fp_len = lcl_plen;
19892 rmt.fp_len = rmt_plen;
19896 ip_prefix_encode (&lcl, &mp->lcl);
19897 ip_prefix_encode (&rmt, &mp->rmt);
19898 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
19899 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
19900 mp->transport_proto =
19901 proto ? TRANSPORT_PROTO_API_UDP : TRANSPORT_PROTO_API_TCP;
19902 mp->action_index = clib_host_to_net_u32 (action);
19903 mp->appns_index = clib_host_to_net_u32 (appns_index);
19905 mp->is_add = is_add;
19908 clib_memcpy (mp->tag, tag, vec_len (tag));
19918 api_session_rules_dump (vat_main_t * vam)
19920 vl_api_session_rules_dump_t *mp;
19921 vl_api_control_ping_t *mp_ping;
19924 if (!vam->json_output)
19926 print (vam->ofp, "%=20s", "Session Rules");
19929 M (SESSION_RULES_DUMP, mp);
19933 /* Use a control ping for synchronization */
19934 MPING (CONTROL_PING, mp_ping);
19937 /* Wait for a reply... */
19943 api_ip_container_proxy_add_del (vat_main_t * vam)
19945 vl_api_ip_container_proxy_add_del_t *mp;
19946 unformat_input_t *i = vam->input;
19947 u32 sw_if_index = ~0;
19948 vl_api_prefix_t pfx = { };
19952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19954 if (unformat (i, "del"))
19956 else if (unformat (i, "add"))
19958 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
19960 else if (unformat (i, "sw_if_index %u", &sw_if_index))
19965 if (sw_if_index == ~0 || pfx.len == 0)
19967 errmsg ("address and sw_if_index must be set");
19971 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
19973 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
19974 mp->is_add = is_add;
19975 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
19983 api_qos_record_enable_disable (vat_main_t * vam)
19985 unformat_input_t *i = vam->input;
19986 vl_api_qos_record_enable_disable_t *mp;
19987 u32 sw_if_index, qs = 0xff;
19988 u8 sw_if_index_set = 0;
19992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19994 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19995 sw_if_index_set = 1;
19996 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19997 sw_if_index_set = 1;
19998 else if (unformat (i, "%U", unformat_qos_source, &qs))
20000 else if (unformat (i, "disable"))
20004 clib_warning ("parse error '%U'", format_unformat_error, i);
20009 if (sw_if_index_set == 0)
20011 errmsg ("missing interface name or sw_if_index");
20016 errmsg ("input location must be specified");
20020 M (QOS_RECORD_ENABLE_DISABLE, mp);
20022 mp->record.sw_if_index = ntohl (sw_if_index);
20023 mp->record.input_source = qs;
20024 mp->enable = enable;
20033 q_or_quit (vat_main_t * vam)
20035 #if VPP_API_TEST_BUILTIN == 0
20036 longjmp (vam->jump_buf, 1);
20038 return 0; /* not so much */
20042 q (vat_main_t * vam)
20044 return q_or_quit (vam);
20048 quit (vat_main_t * vam)
20050 return q_or_quit (vam);
20054 comment (vat_main_t * vam)
20060 elog_save (vat_main_t * vam)
20062 #if VPP_API_TEST_BUILTIN == 0
20063 elog_main_t *em = &vam->elog_main;
20064 unformat_input_t *i = vam->input;
20065 char *file, *chroot_file;
20066 clib_error_t *error;
20068 if (!unformat (i, "%s", &file))
20070 errmsg ("expected file name, got `%U'", format_unformat_error, i);
20074 /* It's fairly hard to get "../oopsie" through unformat; just in case */
20075 if (strstr (file, "..") || index (file, '/'))
20077 errmsg ("illegal characters in filename '%s'", file);
20081 chroot_file = (char *) format (0, "/tmp/%s%c", file, 0);
20085 errmsg ("Saving %wd of %wd events to %s",
20086 elog_n_events_in_buffer (em),
20087 elog_buffer_capacity (em), chroot_file);
20089 error = elog_write_file (em, chroot_file, 1 /* flush ring */ );
20090 vec_free (chroot_file);
20093 clib_error_report (error);
20095 errmsg ("Use the vpp event loger...");
20102 elog_setup (vat_main_t * vam)
20104 #if VPP_API_TEST_BUILTIN == 0
20105 elog_main_t *em = &vam->elog_main;
20106 unformat_input_t *i = vam->input;
20107 u32 nevents = 128 << 10;
20109 (void) unformat (i, "nevents %d", &nevents);
20111 elog_init (em, nevents);
20112 vl_api_set_elog_main (em);
20113 vl_api_set_elog_trace_api_messages (1);
20114 errmsg ("Event logger initialized with %u events", nevents);
20116 errmsg ("Use the vpp event loger...");
20122 elog_enable (vat_main_t * vam)
20124 #if VPP_API_TEST_BUILTIN == 0
20125 elog_main_t *em = &vam->elog_main;
20127 elog_enable_disable (em, 1 /* enable */ );
20128 vl_api_set_elog_trace_api_messages (1);
20129 errmsg ("Event logger enabled...");
20131 errmsg ("Use the vpp event loger...");
20137 elog_disable (vat_main_t * vam)
20139 #if VPP_API_TEST_BUILTIN == 0
20140 elog_main_t *em = &vam->elog_main;
20142 elog_enable_disable (em, 0 /* enable */ );
20143 vl_api_set_elog_trace_api_messages (1);
20144 errmsg ("Event logger disabled...");
20146 errmsg ("Use the vpp event loger...");
20152 statseg (vat_main_t * vam)
20154 ssvm_private_t *ssvmp = &vam->stat_segment;
20155 ssvm_shared_header_t *shared_header = ssvmp->sh;
20156 vlib_counter_t **counters;
20157 u64 thread0_index1_packets;
20158 u64 thread0_index1_bytes;
20159 f64 vector_rate, input_rate;
20162 uword *counter_vector_by_name;
20163 if (vam->stat_segment_lockp == 0)
20165 errmsg ("Stat segment not mapped...");
20169 /* look up "/if/rx for sw_if_index 1 as a test */
20171 clib_spinlock_lock (vam->stat_segment_lockp);
20173 counter_vector_by_name = (uword *) shared_header->opaque[1];
20175 p = hash_get_mem (counter_vector_by_name, "/if/rx");
20178 clib_spinlock_unlock (vam->stat_segment_lockp);
20179 errmsg ("/if/tx not found?");
20183 /* Fish per-thread vector of combined counters from shared memory */
20184 counters = (vlib_counter_t **) p[0];
20186 if (vec_len (counters[0]) < 2)
20188 clib_spinlock_unlock (vam->stat_segment_lockp);
20189 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
20193 /* Read thread 0 sw_if_index 1 counter */
20194 thread0_index1_packets = counters[0][1].packets;
20195 thread0_index1_bytes = counters[0][1].bytes;
20197 p = hash_get_mem (counter_vector_by_name, "vector_rate");
20200 clib_spinlock_unlock (vam->stat_segment_lockp);
20201 errmsg ("vector_rate not found?");
20205 vector_rate = *(f64 *) (p[0]);
20206 p = hash_get_mem (counter_vector_by_name, "input_rate");
20209 clib_spinlock_unlock (vam->stat_segment_lockp);
20210 errmsg ("input_rate not found?");
20213 input_rate = *(f64 *) (p[0]);
20215 clib_spinlock_unlock (vam->stat_segment_lockp);
20217 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
20218 vector_rate, input_rate);
20219 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
20220 thread0_index1_packets, thread0_index1_bytes);
20226 cmd_cmp (void *a1, void *a2)
20231 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20235 help (vat_main_t * vam)
20240 unformat_input_t *i = vam->input;
20243 if (unformat (i, "%s", &name))
20247 vec_add1 (name, 0);
20249 hs = hash_get_mem (vam->help_by_name, name);
20251 print (vam->ofp, "usage: %s %s", name, hs[0]);
20253 print (vam->ofp, "No such msg / command '%s'", name);
20258 print (vam->ofp, "Help is available for the following:");
20261 hash_foreach_pair (p, vam->function_by_name,
20263 vec_add1 (cmds, (u8 *)(p->key));
20267 vec_sort_with_function (cmds, cmd_cmp);
20269 for (j = 0; j < vec_len (cmds); j++)
20270 print (vam->ofp, "%s", cmds[j]);
20277 set (vat_main_t * vam)
20279 u8 *name = 0, *value = 0;
20280 unformat_input_t *i = vam->input;
20282 if (unformat (i, "%s", &name))
20284 /* The input buffer is a vector, not a string. */
20285 value = vec_dup (i->buffer);
20286 vec_delete (value, i->index, 0);
20287 /* Almost certainly has a trailing newline */
20288 if (value[vec_len (value) - 1] == '\n')
20289 value[vec_len (value) - 1] = 0;
20290 /* Make sure it's a proper string, one way or the other */
20291 vec_add1 (value, 0);
20292 (void) clib_macro_set_value (&vam->macro_main,
20293 (char *) name, (char *) value);
20296 errmsg ("usage: set <name> <value>");
20304 unset (vat_main_t * vam)
20308 if (unformat (vam->input, "%s", &name))
20309 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20310 errmsg ("unset: %s wasn't set", name);
20323 macro_sort_cmp (void *a1, void *a2)
20325 macro_sort_t *s1 = a1;
20326 macro_sort_t *s2 = a2;
20328 return strcmp ((char *) (s1->name), (char *) (s2->name));
20332 dump_macro_table (vat_main_t * vam)
20334 macro_sort_t *sort_me = 0, *sm;
20339 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20341 vec_add2 (sort_me, sm, 1);
20342 sm->name = (u8 *)(p->key);
20343 sm->value = (u8 *) (p->value[0]);
20347 vec_sort_with_function (sort_me, macro_sort_cmp);
20349 if (vec_len (sort_me))
20350 print (vam->ofp, "%-15s%s", "Name", "Value");
20352 print (vam->ofp, "The macro table is empty...");
20354 for (i = 0; i < vec_len (sort_me); i++)
20355 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20360 dump_node_table (vat_main_t * vam)
20363 vlib_node_t *node, *next_node;
20365 if (vec_len (vam->graph_nodes) == 0)
20367 print (vam->ofp, "Node table empty, issue get_node_graph...");
20371 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
20373 node = vam->graph_nodes[0][i];
20374 print (vam->ofp, "[%d] %s", i, node->name);
20375 for (j = 0; j < vec_len (node->next_nodes); j++)
20377 if (node->next_nodes[j] != ~0)
20379 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20380 print (vam->ofp, " [%d] %s", j, next_node->name);
20388 value_sort_cmp (void *a1, void *a2)
20390 name_sort_t *n1 = a1;
20391 name_sort_t *n2 = a2;
20393 if (n1->value < n2->value)
20395 if (n1->value > n2->value)
20402 dump_msg_api_table (vat_main_t * vam)
20404 api_main_t *am = vlibapi_get_main ();
20405 name_sort_t *nses = 0, *ns;
20410 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20412 vec_add2 (nses, ns, 1);
20413 ns->name = (u8 *)(hp->key);
20414 ns->value = (u32) hp->value[0];
20418 vec_sort_with_function (nses, value_sort_cmp);
20420 for (i = 0; i < vec_len (nses); i++)
20421 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20427 get_msg_id (vat_main_t * vam)
20432 if (unformat (vam->input, "%s", &name_and_crc))
20434 message_index = vl_msg_api_get_msg_index (name_and_crc);
20435 if (message_index == ~0)
20437 print (vam->ofp, " '%s' not found", name_and_crc);
20440 print (vam->ofp, " '%s' has message index %d",
20441 name_and_crc, message_index);
20444 errmsg ("name_and_crc required...");
20449 search_node_table (vat_main_t * vam)
20451 unformat_input_t *line_input = vam->input;
20454 vlib_node_t *node, *next_node;
20457 if (vam->graph_node_index_by_name == 0)
20459 print (vam->ofp, "Node table empty, issue get_node_graph...");
20463 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20465 if (unformat (line_input, "%s", &node_to_find))
20467 vec_add1 (node_to_find, 0);
20468 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20471 print (vam->ofp, "%s not found...", node_to_find);
20474 node = vam->graph_nodes[0][p[0]];
20475 print (vam->ofp, "[%d] %s", p[0], node->name);
20476 for (j = 0; j < vec_len (node->next_nodes); j++)
20478 if (node->next_nodes[j] != ~0)
20480 next_node = vam->graph_nodes[0][node->next_nodes[j]];
20481 print (vam->ofp, " [%d] %s", j, next_node->name);
20488 clib_warning ("parse error '%U'", format_unformat_error,
20494 vec_free (node_to_find);
20503 script (vat_main_t * vam)
20505 #if (VPP_API_TEST_BUILTIN==0)
20507 char *save_current_file;
20508 unformat_input_t save_input;
20509 jmp_buf save_jump_buf;
20510 u32 save_line_number;
20512 FILE *new_fp, *save_ifp;
20514 if (unformat (vam->input, "%s", &s))
20516 new_fp = fopen ((char *) s, "r");
20519 errmsg ("Couldn't open script file %s", s);
20526 errmsg ("Missing script name");
20530 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20531 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20532 save_ifp = vam->ifp;
20533 save_line_number = vam->input_line_number;
20534 save_current_file = (char *) vam->current_file;
20536 vam->input_line_number = 0;
20538 vam->current_file = s;
20541 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
20542 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20543 vam->ifp = save_ifp;
20544 vam->input_line_number = save_line_number;
20545 vam->current_file = (u8 *) save_current_file;
20550 clib_warning ("use the exec command...");
20556 echo (vat_main_t * vam)
20558 print (vam->ofp, "%v", vam->input->buffer);
20562 /* List of API message constructors, CLI names map to api_xxx */
20563 #define foreach_vpe_api_msg \
20564 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20565 _(sw_interface_dump,"") \
20566 _(sw_interface_set_flags, \
20567 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20568 _(sw_interface_add_del_address, \
20569 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20570 _(sw_interface_set_rx_mode, \
20571 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
20572 _(sw_interface_set_rx_placement, \
20573 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
20574 _(sw_interface_rx_placement_dump, \
20575 "[<intfc> | sw_if_index <id>]") \
20576 _(sw_interface_set_table, \
20577 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20578 _(sw_interface_set_mpls_enable, \
20579 "<intfc> | sw_if_index [disable | dis]") \
20580 _(sw_interface_set_vpath, \
20581 "<intfc> | sw_if_index <id> enable | disable") \
20582 _(sw_interface_set_vxlan_bypass, \
20583 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20584 _(sw_interface_set_geneve_bypass, \
20585 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20586 _(sw_interface_set_l2_xconnect, \
20587 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20588 "enable | disable") \
20589 _(sw_interface_set_l2_bridge, \
20590 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20591 "[shg <split-horizon-group>] [bvi]\n" \
20592 "enable | disable") \
20593 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20594 _(bridge_domain_add_del, \
20595 "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") \
20596 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20598 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20599 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20600 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20602 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20604 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20606 "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]") \
20608 "<vpp-if-name> | sw_if_index <id>") \
20609 _(sw_interface_tap_v2_dump, "") \
20610 _(virtio_pci_create, \
20611 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [features <hex-value>] [gso-enabled | csum-offload-enabled]") \
20612 _(virtio_pci_delete, \
20613 "<vpp-if-name> | sw_if_index <id>") \
20614 _(sw_interface_virtio_pci_dump, "") \
20616 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
20617 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
20620 "<vpp-if-name> | sw_if_index <id>") \
20622 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
20623 _(bond_detach_slave, \
20624 "sw_if_index <n>") \
20625 _(sw_interface_set_bond_weight, "<intfc> | sw_if_index <nn> weight <value>") \
20626 _(sw_interface_bond_dump, "") \
20627 _(sw_interface_slave_dump, \
20628 "<vpp-if-name> | sw_if_index <id>") \
20629 _(ip_table_add_del, \
20630 "table <n> [ipv6] [add | del]\n") \
20631 _(ip_route_add_del, \
20632 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
20633 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
20634 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
20635 "[multipath] [count <n>] [del]") \
20636 _(ip_mroute_add_del, \
20637 "<src> <grp>/<mask> [table-id <n>]\n" \
20638 "[<intfc> | sw_if_index <id>] [local] [del]") \
20639 _(mpls_table_add_del, \
20640 "table <n> [add | del]\n") \
20641 _(mpls_route_add_del, \
20642 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
20643 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
20644 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
20645 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
20646 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
20647 "[count <n>] [del]") \
20648 _(mpls_ip_bind_unbind, \
20649 "<label> <addr/len>") \
20650 _(mpls_tunnel_add_del, \
20651 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
20652 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
20653 "[l2-only] [out-label <n>]") \
20654 _(sr_mpls_policy_add, \
20655 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
20656 _(sr_mpls_policy_del, \
20658 _(bier_table_add_del, \
20659 "<label> <sub-domain> <set> <bsl> [del]") \
20660 _(bier_route_add_del, \
20661 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
20662 "[<intfc> | sw_if_index <id>]" \
20663 "[weight <n>] [del] [multipath]") \
20664 _(sw_interface_set_unnumbered, \
20665 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20666 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20667 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20668 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20669 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20670 "[outer_vlan_id_any][inner_vlan_id_any]") \
20671 _(ip_table_replace_begin, "table <n> [ipv6]") \
20672 _(ip_table_flush, "table <n> [ipv6]") \
20673 _(ip_table_replace_end, "table <n> [ipv6]") \
20674 _(set_ip_flow_hash, \
20675 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20676 _(sw_interface_ip6_enable_disable, \
20677 "<intfc> | sw_if_index <id> enable | disable") \
20678 _(l2_patch_add_del, \
20679 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20680 "enable | disable") \
20681 _(sr_localsid_add_del, \
20682 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20683 "fib-table <num> (end.psp) sw_if_index <num>") \
20684 _(classify_add_del_table, \
20685 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20686 " [del] [del-chain] mask <mask-value>\n" \
20687 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20688 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20689 _(classify_add_del_session, \
20690 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20691 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20692 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20693 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20694 _(classify_set_interface_ip_table, \
20695 "<intfc> | sw_if_index <nn> table <nn>") \
20696 _(classify_set_interface_l2_tables, \
20697 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20698 " [other-table <nn>]") \
20699 _(get_node_index, "node <node-name") \
20700 _(add_node_next, "node <node-name> next <next-node-name>") \
20701 _(l2tpv3_create_tunnel, \
20702 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20703 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20704 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20705 _(l2tpv3_set_tunnel_cookies, \
20706 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20707 "[new_remote_cookie <nn>]\n") \
20708 _(l2tpv3_interface_enable_disable, \
20709 "<intfc> | sw_if_index <nn> enable | disable") \
20710 _(l2tpv3_set_lookup_key, \
20711 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20712 _(sw_if_l2tpv3_tunnel_dump, "") \
20713 _(vxlan_offload_rx, \
20714 "hw { <interface name> | hw_if_index <nn>} " \
20715 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
20716 _(vxlan_add_del_tunnel, \
20717 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20718 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
20719 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20720 _(geneve_add_del_tunnel, \
20721 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20722 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20723 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20724 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20725 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20726 _(gre_tunnel_add_del, \
20727 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
20728 "[teb | erspan <session-id>] [del]") \
20729 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20730 _(l2_fib_clear_table, "") \
20731 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20732 _(l2_interface_vlan_tag_rewrite, \
20733 "<intfc> | sw_if_index <nn> \n" \
20734 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20735 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20736 _(create_vhost_user_if, \
20737 "socket <filename> [server] [renumber <dev_instance>] " \
20738 "[disable_mrg_rxbuf] [disable_indirect_desc] [gso] " \
20739 "[mac <mac_address>] [packed]") \
20740 _(modify_vhost_user_if, \
20741 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20742 "[server] [renumber <dev_instance>] [gso] [packed]") \
20743 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20744 _(sw_interface_vhost_user_dump, "<intfc> | sw_if_index <nn>") \
20745 _(show_version, "") \
20746 _(show_threads, "") \
20747 _(vxlan_gpe_add_del_tunnel, \
20748 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20749 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20750 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20751 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20752 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20753 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20754 _(interface_name_renumber, \
20755 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20756 _(input_acl_set_interface, \
20757 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20758 " [l2-table <nn>] [del]") \
20759 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20760 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20761 _(ip_dump, "ipv4 | ipv6") \
20762 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20763 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20765 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20766 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20767 " integ_alg <alg> integ_key <hex>") \
20768 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
20769 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20770 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20771 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20772 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20773 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20774 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20775 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
20776 " [instance <n>]") \
20777 _(ipsec_sa_dump, "[sa_id <n>]") \
20778 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
20779 _(delete_loopback,"sw_if_index <nn>") \
20780 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20781 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
20782 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
20783 _(want_interface_events, "enable|disable") \
20784 _(get_first_msg_id, "client <name>") \
20785 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20786 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20787 "fib-id <nn> [ip4][ip6][default]") \
20788 _(get_node_graph, " ") \
20789 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20790 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20791 _(ioam_disable, "") \
20792 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20793 " sw_if_index <sw_if_index> p <priority> " \
20794 "w <weight>] [del]") \
20795 _(one_add_del_locator, "locator-set <locator_name> " \
20796 "iface <intf> | sw_if_index <sw_if_index> " \
20797 "p <priority> w <weight> [del]") \
20798 _(one_add_del_local_eid,"vni <vni> eid " \
20799 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20800 "locator-set <locator_name> [del]" \
20801 "[key-id sha1|sha256 secret-key <secret-key>]")\
20802 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20803 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20804 _(one_enable_disable, "enable|disable") \
20805 _(one_map_register_enable_disable, "enable|disable") \
20806 _(one_map_register_fallback_threshold, "<value>") \
20807 _(one_rloc_probe_enable_disable, "enable|disable") \
20808 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20810 "rloc <locator> p <prio> " \
20811 "w <weight> [rloc <loc> ... ] " \
20812 "action <action> [del-all]") \
20813 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20815 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20816 _(one_use_petr, "ip-address> | disable") \
20817 _(one_map_request_mode, "src-dst|dst-only") \
20818 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20819 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20820 _(one_locator_set_dump, "[local | remote]") \
20821 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20822 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20823 "[local] | [remote]") \
20824 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20825 _(one_ndp_bd_get, "") \
20826 _(one_ndp_entries_get, "bd <bridge-domain>") \
20827 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20828 _(one_l2_arp_bd_get, "") \
20829 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20830 _(one_stats_enable_disable, "enable|disable") \
20831 _(show_one_stats_enable_disable, "") \
20832 _(one_eid_table_vni_dump, "") \
20833 _(one_eid_table_map_dump, "l2|l3") \
20834 _(one_map_resolver_dump, "") \
20835 _(one_map_server_dump, "") \
20836 _(one_adjacencies_get, "vni <vni>") \
20837 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20838 _(show_one_rloc_probe_state, "") \
20839 _(show_one_map_register_state, "") \
20840 _(show_one_status, "") \
20841 _(one_stats_dump, "") \
20842 _(one_stats_flush, "") \
20843 _(one_get_map_request_itr_rlocs, "") \
20844 _(one_map_register_set_ttl, "<ttl>") \
20845 _(one_set_transport_protocol, "udp|api") \
20846 _(one_get_transport_protocol, "") \
20847 _(one_enable_disable_xtr_mode, "enable|disable") \
20848 _(one_show_xtr_mode, "") \
20849 _(one_enable_disable_pitr_mode, "enable|disable") \
20850 _(one_show_pitr_mode, "") \
20851 _(one_enable_disable_petr_mode, "enable|disable") \
20852 _(one_show_petr_mode, "") \
20853 _(show_one_nsh_mapping, "") \
20854 _(show_one_pitr, "") \
20855 _(show_one_use_petr, "") \
20856 _(show_one_map_request_mode, "") \
20857 _(show_one_map_register_ttl, "") \
20858 _(show_one_map_register_fallback_threshold, "") \
20859 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20860 " sw_if_index <sw_if_index> p <priority> " \
20861 "w <weight>] [del]") \
20862 _(lisp_add_del_locator, "locator-set <locator_name> " \
20863 "iface <intf> | sw_if_index <sw_if_index> " \
20864 "p <priority> w <weight> [del]") \
20865 _(lisp_add_del_local_eid,"vni <vni> eid " \
20866 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20867 "locator-set <locator_name> [del]" \
20868 "[key-id sha1|sha256 secret-key <secret-key>]") \
20869 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20870 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20871 _(lisp_enable_disable, "enable|disable") \
20872 _(lisp_map_register_enable_disable, "enable|disable") \
20873 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20874 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20876 "rloc <locator> p <prio> " \
20877 "w <weight> [rloc <loc> ... ] " \
20878 "action <action> [del-all]") \
20879 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20881 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20882 _(lisp_use_petr, "<ip-address> | disable") \
20883 _(lisp_map_request_mode, "src-dst|dst-only") \
20884 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20885 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20886 _(lisp_locator_set_dump, "[local | remote]") \
20887 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20888 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20889 "[local] | [remote]") \
20890 _(lisp_eid_table_vni_dump, "") \
20891 _(lisp_eid_table_map_dump, "l2|l3") \
20892 _(lisp_map_resolver_dump, "") \
20893 _(lisp_map_server_dump, "") \
20894 _(lisp_adjacencies_get, "vni <vni>") \
20895 _(gpe_fwd_entry_vnis_get, "") \
20896 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20897 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20898 "[table <table-id>]") \
20899 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20900 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20901 _(gpe_set_encap_mode, "lisp|vxlan") \
20902 _(gpe_get_encap_mode, "") \
20903 _(lisp_gpe_add_del_iface, "up|down") \
20904 _(lisp_gpe_enable_disable, "enable|disable") \
20905 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20906 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20907 _(show_lisp_rloc_probe_state, "") \
20908 _(show_lisp_map_register_state, "") \
20909 _(show_lisp_status, "") \
20910 _(lisp_get_map_request_itr_rlocs, "") \
20911 _(show_lisp_pitr, "") \
20912 _(show_lisp_use_petr, "") \
20913 _(show_lisp_map_request_mode, "") \
20914 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20915 _(af_packet_delete, "name <host interface name>") \
20916 _(af_packet_dump, "") \
20917 _(policer_add_del, "name <policer name> <params> [del]") \
20918 _(policer_dump, "[name <policer name>]") \
20919 _(policer_classify_set_interface, \
20920 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20921 " [l2-table <nn>] [del]") \
20922 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20923 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20924 _(mpls_table_dump, "") \
20925 _(mpls_route_dump, "table-id <ID>") \
20926 _(classify_table_ids, "") \
20927 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20928 _(classify_table_info, "table_id <nn>") \
20929 _(classify_session_dump, "table_id <nn>") \
20930 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20931 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20932 "[template_interval <nn>] [udp_checksum]") \
20933 _(ipfix_exporter_dump, "") \
20934 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20935 _(ipfix_classify_stream_dump, "") \
20936 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20937 _(ipfix_classify_table_dump, "") \
20938 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20939 _(sw_interface_span_dump, "[l2]") \
20940 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20941 _(pg_create_interface, "if_id <nn> [gso-enabled gso-size <size>]") \
20942 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20943 _(pg_enable_disable, "[stream <id>] disable") \
20944 _(ip_source_and_port_range_check_add_del, \
20945 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20946 _(ip_source_and_port_range_check_interface_add_del, \
20947 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20948 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20949 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20950 _(l2_interface_pbb_tag_rewrite, \
20951 "<intfc> | sw_if_index <nn> \n" \
20952 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20953 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20954 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20955 _(flow_classify_set_interface, \
20956 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20957 _(flow_classify_dump, "type [ip4|ip6]") \
20958 _(ip_table_dump, "") \
20959 _(ip_route_dump, "table-id [ip4|ip6]") \
20960 _(ip_mtable_dump, "") \
20961 _(ip_mroute_dump, "table-id [ip4|ip6]") \
20962 _(feature_enable_disable, "arc_name <arc_name> " \
20963 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20964 _(feature_gso_enable_disable, "<intfc> | sw_if_index <nn> " \
20965 "[enable | disable] ") \
20966 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20968 _(sw_interface_add_del_mac_address, "<intfc> | sw_if_index <nn> " \
20969 "mac <mac-address> [del]") \
20970 _(l2_xconnect_dump, "") \
20971 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
20972 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20973 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20974 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20975 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20976 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
20977 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
20978 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
20979 _(sock_init_shm, "size <nnn>") \
20980 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
20981 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
20982 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
20983 _(session_rules_dump, "") \
20984 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
20985 _(output_acl_set_interface, \
20986 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20987 " [l2-table <nn>] [del]") \
20988 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
20990 /* List of command functions, CLI names map directly to functions */
20991 #define foreach_cli_function \
20992 _(comment, "usage: comment <ignore-rest-of-line>") \
20993 _(dump_interface_table, "usage: dump_interface_table") \
20994 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20995 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20996 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20997 _(dump_macro_table, "usage: dump_macro_table ") \
20998 _(dump_node_table, "usage: dump_node_table") \
20999 _(dump_msg_api_table, "usage: dump_msg_api_table") \
21000 _(elog_setup, "usage: elog_setup [nevents, default 128K]") \
21001 _(elog_disable, "usage: elog_disable") \
21002 _(elog_enable, "usage: elog_enable") \
21003 _(elog_save, "usage: elog_save <filename>") \
21004 _(get_msg_id, "usage: get_msg_id name_and_crc") \
21005 _(echo, "usage: echo <message>") \
21006 _(exec, "usage: exec <vpe-debug-CLI-command>") \
21007 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
21008 _(help, "usage: help") \
21009 _(q, "usage: quit") \
21010 _(quit, "usage: quit") \
21011 _(search_node_table, "usage: search_node_table <name>...") \
21012 _(set, "usage: set <variable-name> <value>") \
21013 _(script, "usage: script <file-name>") \
21014 _(statseg, "usage: statseg") \
21015 _(unset, "usage: unset <variable-name>")
21018 static void vl_api_##n##_t_handler_uni \
21019 (vl_api_##n##_t * mp) \
21021 vat_main_t * vam = &vat_main; \
21022 if (vam->json_output) { \
21023 vl_api_##n##_t_handler_json(mp); \
21025 vl_api_##n##_t_handler(mp); \
21028 foreach_vpe_api_reply_msg;
21029 #if VPP_API_TEST_BUILTIN == 0
21030 foreach_standalone_reply_msg;
21035 vat_api_hookup (vat_main_t * vam)
21038 vl_msg_api_set_handlers(VL_API_##N, #n, \
21039 vl_api_##n##_t_handler_uni, \
21041 vl_api_##n##_t_endian, \
21042 vl_api_##n##_t_print, \
21043 sizeof(vl_api_##n##_t), 1);
21044 foreach_vpe_api_reply_msg;
21045 #if VPP_API_TEST_BUILTIN == 0
21046 foreach_standalone_reply_msg;
21050 #if (VPP_API_TEST_BUILTIN==0)
21051 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
21053 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
21055 vam->function_by_name = hash_create_string (0, sizeof (uword));
21057 vam->help_by_name = hash_create_string (0, sizeof (uword));
21060 /* API messages we can send */
21061 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
21062 foreach_vpe_api_msg;
21066 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21067 foreach_vpe_api_msg;
21070 /* CLI functions */
21071 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
21072 foreach_cli_function;
21076 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
21077 foreach_cli_function;
21081 #if VPP_API_TEST_BUILTIN
21082 static clib_error_t *
21083 vat_api_hookup_shim (vlib_main_t * vm)
21085 vat_api_hookup (&vat_main);
21089 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
21093 * fd.io coding-style-patch-verification: ON
21096 * eval: (c-set-style "gnu")