2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vpp/api/types.h>
22 #include <vppinfra/socket.h>
23 #include <vlibapi/api.h>
24 #include <vlibmemory/api.h>
25 #include <vnet/ip/ip.h>
26 #include <vnet/ip/ip_neighbor.h>
27 #include <vnet/ip/ip_types_api.h>
28 #include <vnet/l2/l2_input.h>
29 #include <vnet/l2tp/l2tp.h>
30 #include <vnet/vxlan/vxlan.h>
31 #include <vnet/geneve/geneve.h>
32 #include <vnet/gre/gre.h>
33 #include <vnet/vxlan-gpe/vxlan_gpe.h>
34 #include <vnet/lisp-gpe/lisp_gpe.h>
36 #include <vpp/api/vpe_msg_enum.h>
37 #include <vnet/l2/l2_classify.h>
38 #include <vnet/l2/l2_vtr.h>
39 #include <vnet/classify/in_out_acl.h>
40 #include <vnet/classify/policer_classify.h>
41 #include <vnet/classify/flow_classify.h>
42 #include <vnet/mpls/mpls.h>
43 #include <vnet/ipsec/ipsec.h>
45 #include <vnet/cop/cop.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/dhcp/dhcp_proxy.h>
54 #include <vnet/bonding/node.h>
55 #include <vnet/qos/qos_types.h>
56 #include <vnet/ethernet/ethernet_types_api.h>
57 #include <vnet/ip/ip_types_api.h>
58 #include "vat/json_format.h"
59 #include <vnet/ip/ip_types_api.h>
60 #include <vnet/ethernet/ethernet_types_api.h>
65 #define vl_typedefs /* define message structures */
66 #include <vpp/api/vpe_all_api_h.h>
69 /* declare message handlers for each api */
71 #define vl_endianfun /* define message structures */
72 #include <vpp/api/vpe_all_api_h.h>
75 /* instantiate all the print functions we know about */
76 #define vl_print(handle, ...)
78 #include <vpp/api/vpe_all_api_h.h>
81 #define __plugin_msg_base 0
82 #include <vlibapi/vat_helper_macros.h>
84 #if VPP_API_TEST_BUILTIN == 0
94 vat_socket_connect (vat_main_t * vam)
97 vam->socket_client_main = &socket_client_main;
98 if ((rv = vl_socket_client_connect ((char *) vam->socket_name,
100 0 /* default socket rx, tx buffer */ )))
102 /* vpp expects the client index in network order */
103 vam->my_client_index = htonl (socket_client_main.client_index);
106 #else /* vpp built-in case, we don't do sockets... */
108 vat_socket_connect (vat_main_t * vam)
114 vl_socket_client_read (int wait)
120 vl_socket_client_write ()
126 vl_socket_client_msg_alloc (int nbytes)
134 vat_time_now (vat_main_t * vam)
136 #if VPP_API_TEST_BUILTIN
137 return vlib_time_now (vam->vlib_main);
139 return clib_time_now (&vam->clib_time);
144 errmsg (char *fmt, ...)
146 vat_main_t *vam = &vat_main;
151 s = va_format (0, fmt, &va);
156 #if VPP_API_TEST_BUILTIN
157 vlib_cli_output (vam->vlib_main, (char *) s);
160 if (vam->ifp != stdin)
161 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
162 vam->input_line_number);
163 fformat (vam->ofp, (char *) s);
171 #if VPP_API_TEST_BUILTIN == 0
173 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
175 vat_main_t *vam = va_arg (*args, vat_main_t *);
176 u32 *result = va_arg (*args, u32 *);
180 if (!unformat (input, "%s", &if_name))
183 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
191 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
196 /* Parse an IP4 address %d.%d.%d.%d. */
198 unformat_ip4_address (unformat_input_t * input, va_list * args)
200 u8 *result = va_arg (*args, u8 *);
203 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
206 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
218 unformat_ethernet_address (unformat_input_t * input, va_list * args)
220 u8 *result = va_arg (*args, u8 *);
223 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
224 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
228 for (i = 0; i < 6; i++)
229 if (a[i] >= (1 << 8))
232 for (i = 0; i < 6; i++)
238 /* Returns ethernet type as an int in host byte order. */
240 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
243 u16 *result = va_arg (*args, u16 *);
247 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
249 if (type >= (1 << 16))
257 /* Parse an IP6 address. */
259 unformat_ip6_address (unformat_input_t * input, va_list * args)
261 ip6_address_t *result = va_arg (*args, ip6_address_t *);
263 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
264 uword c, n_colon, double_colon_index;
266 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
267 double_colon_index = ARRAY_LEN (hex_quads);
268 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
271 if (c >= '0' && c <= '9')
273 else if (c >= 'a' && c <= 'f')
274 hex_digit = c + 10 - 'a';
275 else if (c >= 'A' && c <= 'F')
276 hex_digit = c + 10 - 'A';
277 else if (c == ':' && n_colon < 2)
281 unformat_put_input (input);
285 /* Too many hex quads. */
286 if (n_hex_quads >= ARRAY_LEN (hex_quads))
291 hex_quad = (hex_quad << 4) | hex_digit;
293 /* Hex quad must fit in 16 bits. */
294 if (n_hex_digits >= 4)
301 /* Save position of :: */
304 /* More than one :: ? */
305 if (double_colon_index < ARRAY_LEN (hex_quads))
307 double_colon_index = n_hex_quads;
310 if (n_colon > 0 && n_hex_digits > 0)
312 hex_quads[n_hex_quads++] = hex_quad;
318 if (n_hex_digits > 0)
319 hex_quads[n_hex_quads++] = hex_quad;
324 /* Expand :: to appropriate number of zero hex quads. */
325 if (double_colon_index < ARRAY_LEN (hex_quads))
327 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
329 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
330 hex_quads[n_zero + i] = hex_quads[i];
332 for (i = 0; i < n_zero; i++)
333 hex_quads[double_colon_index + i] = 0;
335 n_hex_quads = ARRAY_LEN (hex_quads);
338 /* Too few hex quads given. */
339 if (n_hex_quads < ARRAY_LEN (hex_quads))
342 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
343 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
350 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
352 u32 *r = va_arg (*args, u32 *);
355 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
356 foreach_ipsec_policy_action
364 format_ipsec_crypto_alg (u8 * s, va_list * args)
366 u32 i = va_arg (*args, u32);
371 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
372 foreach_ipsec_crypto_alg
375 return format (s, "unknown");
377 return format (s, "%s", t);
381 format_ipsec_integ_alg (u8 * s, va_list * args)
383 u32 i = va_arg (*args, u32);
388 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
389 foreach_ipsec_integ_alg
392 return format (s, "unknown");
394 return format (s, "%s", t);
397 #else /* VPP_API_TEST_BUILTIN == 1 */
399 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
401 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
402 vnet_main_t *vnm = vnet_get_main ();
403 u32 *result = va_arg (*args, u32 *);
405 return unformat (input, "%U", unformat_vnet_sw_interface, vnm, result);
409 api_unformat_hw_if_index (unformat_input_t * input, va_list * args)
411 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
412 vnet_main_t *vnm = vnet_get_main ();
413 u32 *result = va_arg (*args, u32 *);
415 return unformat (input, "%U", unformat_vnet_hw_interface, vnm, result);
418 #endif /* VPP_API_TEST_BUILTIN */
421 unformat_ipsec_api_crypto_alg (unformat_input_t * input, va_list * args)
423 u32 *r = va_arg (*args, u32 *);
426 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_CRYPTO_ALG_##f;
427 foreach_ipsec_crypto_alg
435 unformat_ipsec_api_integ_alg (unformat_input_t * input, va_list * args)
437 u32 *r = va_arg (*args, u32 *);
440 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_API_INTEG_ALG_##f;
441 foreach_ipsec_integ_alg
449 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
451 u8 *r = va_arg (*args, u8 *);
453 if (unformat (input, "kbps"))
454 *r = SSE2_QOS_RATE_KBPS;
455 else if (unformat (input, "pps"))
456 *r = SSE2_QOS_RATE_PPS;
463 unformat_policer_round_type (unformat_input_t * input, va_list * args)
465 u8 *r = va_arg (*args, u8 *);
467 if (unformat (input, "closest"))
468 *r = SSE2_QOS_ROUND_TO_CLOSEST;
469 else if (unformat (input, "up"))
470 *r = SSE2_QOS_ROUND_TO_UP;
471 else if (unformat (input, "down"))
472 *r = SSE2_QOS_ROUND_TO_DOWN;
479 unformat_policer_type (unformat_input_t * input, va_list * args)
481 u8 *r = va_arg (*args, u8 *);
483 if (unformat (input, "1r2c"))
484 *r = SSE2_QOS_POLICER_TYPE_1R2C;
485 else if (unformat (input, "1r3c"))
486 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
487 else if (unformat (input, "2r3c-2698"))
488 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
489 else if (unformat (input, "2r3c-4115"))
490 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
491 else if (unformat (input, "2r3c-mef5cf1"))
492 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
499 unformat_dscp (unformat_input_t * input, va_list * va)
501 u8 *r = va_arg (*va, u8 *);
504 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
513 unformat_policer_action_type (unformat_input_t * input, va_list * va)
515 sse2_qos_pol_action_params_st *a
516 = va_arg (*va, sse2_qos_pol_action_params_st *);
518 if (unformat (input, "drop"))
519 a->action_type = SSE2_QOS_ACTION_DROP;
520 else if (unformat (input, "transmit"))
521 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
522 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
523 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
530 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
532 u32 *r = va_arg (*va, u32 *);
535 if (unformat (input, "ip4"))
536 tid = POLICER_CLASSIFY_TABLE_IP4;
537 else if (unformat (input, "ip6"))
538 tid = POLICER_CLASSIFY_TABLE_IP6;
539 else if (unformat (input, "l2"))
540 tid = POLICER_CLASSIFY_TABLE_L2;
549 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
551 u32 *r = va_arg (*va, u32 *);
554 if (unformat (input, "ip4"))
555 tid = FLOW_CLASSIFY_TABLE_IP4;
556 else if (unformat (input, "ip6"))
557 tid = FLOW_CLASSIFY_TABLE_IP6;
565 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
566 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
567 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
568 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
570 #if (VPP_API_TEST_BUILTIN==0)
572 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
574 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
575 mfib_itf_attribute_t attr;
578 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
580 if (unformat (input, mfib_itf_flag_long_names[attr]))
581 *iflags |= (1 << attr);
583 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
585 if (unformat (input, mfib_itf_flag_names[attr]))
586 *iflags |= (1 << attr);
589 return (old == *iflags ? 0 : 1);
593 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
595 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
596 mfib_entry_attribute_t attr;
599 FOR_EACH_MFIB_ATTRIBUTE (attr)
601 if (unformat (input, mfib_flag_long_names[attr]))
602 *eflags |= (1 << attr);
604 FOR_EACH_MFIB_ATTRIBUTE (attr)
606 if (unformat (input, mfib_flag_names[attr]))
607 *eflags |= (1 << attr);
610 return (old == *eflags ? 0 : 1);
614 format_ip4_address (u8 * s, va_list * args)
616 u8 *a = va_arg (*args, u8 *);
617 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
621 format_ip6_address (u8 * s, va_list * args)
623 ip6_address_t *a = va_arg (*args, ip6_address_t *);
624 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
626 i_max_n_zero = ARRAY_LEN (a->as_u16);
628 i_first_zero = i_max_n_zero;
630 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
632 u32 is_zero = a->as_u16[i] == 0;
633 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
639 if ((!is_zero && n_zeros > max_n_zeros)
640 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
642 i_max_n_zero = i_first_zero;
643 max_n_zeros = n_zeros;
644 i_first_zero = ARRAY_LEN (a->as_u16);
649 last_double_colon = 0;
650 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
652 if (i == i_max_n_zero && max_n_zeros > 1)
654 s = format (s, "::");
655 i += max_n_zeros - 1;
656 last_double_colon = 1;
660 s = format (s, "%s%x",
661 (last_double_colon || i == 0) ? "" : ":",
662 clib_net_to_host_u16 (a->as_u16[i]));
663 last_double_colon = 0;
670 /* Format an IP46 address. */
672 format_ip46_address (u8 * s, va_list * args)
674 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
675 ip46_type_t type = va_arg (*args, ip46_type_t);
681 is_ip4 = ip46_address_is_ip4 (ip46);
692 format (s, "%U", format_ip4_address, &ip46->ip4) :
693 format (s, "%U", format_ip6_address, &ip46->ip6);
697 format_ethernet_address (u8 * s, va_list * args)
699 u8 *a = va_arg (*args, u8 *);
701 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
702 a[0], a[1], a[2], a[3], a[4], a[5]);
707 increment_v4_address (ip4_address_t * a)
711 v = ntohl (a->as_u32) + 1;
712 a->as_u32 = ntohl (v);
716 increment_v6_address (ip6_address_t * a)
720 v0 = clib_net_to_host_u64 (a->as_u64[0]);
721 v1 = clib_net_to_host_u64 (a->as_u64[1]);
726 a->as_u64[0] = clib_net_to_host_u64 (v0);
727 a->as_u64[1] = clib_net_to_host_u64 (v1);
731 increment_mac_address (u8 * mac)
733 u64 tmp = *((u64 *) mac);
734 tmp = clib_net_to_host_u64 (tmp);
735 tmp += 1 << 16; /* skip unused (least significant) octets */
736 tmp = clib_host_to_net_u64 (tmp);
738 clib_memcpy (mac, &tmp, 6);
741 static void vl_api_create_loopback_reply_t_handler
742 (vl_api_create_loopback_reply_t * mp)
744 vat_main_t *vam = &vat_main;
745 i32 retval = ntohl (mp->retval);
747 vam->retval = retval;
748 vam->regenerate_interface_table = 1;
749 vam->sw_if_index = ntohl (mp->sw_if_index);
750 vam->result_ready = 1;
753 static void vl_api_create_loopback_reply_t_handler_json
754 (vl_api_create_loopback_reply_t * mp)
756 vat_main_t *vam = &vat_main;
757 vat_json_node_t node;
759 vat_json_init_object (&node);
760 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
761 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
763 vat_json_print (vam->ofp, &node);
764 vat_json_free (&node);
765 vam->retval = ntohl (mp->retval);
766 vam->result_ready = 1;
769 static void vl_api_create_loopback_instance_reply_t_handler
770 (vl_api_create_loopback_instance_reply_t * mp)
772 vat_main_t *vam = &vat_main;
773 i32 retval = ntohl (mp->retval);
775 vam->retval = retval;
776 vam->regenerate_interface_table = 1;
777 vam->sw_if_index = ntohl (mp->sw_if_index);
778 vam->result_ready = 1;
781 static void vl_api_create_loopback_instance_reply_t_handler_json
782 (vl_api_create_loopback_instance_reply_t * mp)
784 vat_main_t *vam = &vat_main;
785 vat_json_node_t node;
787 vat_json_init_object (&node);
788 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
789 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
791 vat_json_print (vam->ofp, &node);
792 vat_json_free (&node);
793 vam->retval = ntohl (mp->retval);
794 vam->result_ready = 1;
797 static void vl_api_af_packet_create_reply_t_handler
798 (vl_api_af_packet_create_reply_t * mp)
800 vat_main_t *vam = &vat_main;
801 i32 retval = ntohl (mp->retval);
803 vam->retval = retval;
804 vam->regenerate_interface_table = 1;
805 vam->sw_if_index = ntohl (mp->sw_if_index);
806 vam->result_ready = 1;
809 static void vl_api_af_packet_create_reply_t_handler_json
810 (vl_api_af_packet_create_reply_t * mp)
812 vat_main_t *vam = &vat_main;
813 vat_json_node_t node;
815 vat_json_init_object (&node);
816 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
817 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
819 vat_json_print (vam->ofp, &node);
820 vat_json_free (&node);
822 vam->retval = ntohl (mp->retval);
823 vam->result_ready = 1;
826 static void vl_api_create_vlan_subif_reply_t_handler
827 (vl_api_create_vlan_subif_reply_t * mp)
829 vat_main_t *vam = &vat_main;
830 i32 retval = ntohl (mp->retval);
832 vam->retval = retval;
833 vam->regenerate_interface_table = 1;
834 vam->sw_if_index = ntohl (mp->sw_if_index);
835 vam->result_ready = 1;
838 static void vl_api_create_vlan_subif_reply_t_handler_json
839 (vl_api_create_vlan_subif_reply_t * mp)
841 vat_main_t *vam = &vat_main;
842 vat_json_node_t node;
844 vat_json_init_object (&node);
845 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
846 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
848 vat_json_print (vam->ofp, &node);
849 vat_json_free (&node);
851 vam->retval = ntohl (mp->retval);
852 vam->result_ready = 1;
855 static void vl_api_create_subif_reply_t_handler
856 (vl_api_create_subif_reply_t * mp)
858 vat_main_t *vam = &vat_main;
859 i32 retval = ntohl (mp->retval);
861 vam->retval = retval;
862 vam->regenerate_interface_table = 1;
863 vam->sw_if_index = ntohl (mp->sw_if_index);
864 vam->result_ready = 1;
867 static void vl_api_create_subif_reply_t_handler_json
868 (vl_api_create_subif_reply_t * mp)
870 vat_main_t *vam = &vat_main;
871 vat_json_node_t node;
873 vat_json_init_object (&node);
874 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
875 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
877 vat_json_print (vam->ofp, &node);
878 vat_json_free (&node);
880 vam->retval = ntohl (mp->retval);
881 vam->result_ready = 1;
884 static void vl_api_interface_name_renumber_reply_t_handler
885 (vl_api_interface_name_renumber_reply_t * mp)
887 vat_main_t *vam = &vat_main;
888 i32 retval = ntohl (mp->retval);
890 vam->retval = retval;
891 vam->regenerate_interface_table = 1;
892 vam->result_ready = 1;
895 static void vl_api_interface_name_renumber_reply_t_handler_json
896 (vl_api_interface_name_renumber_reply_t * mp)
898 vat_main_t *vam = &vat_main;
899 vat_json_node_t node;
901 vat_json_init_object (&node);
902 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
904 vat_json_print (vam->ofp, &node);
905 vat_json_free (&node);
907 vam->retval = ntohl (mp->retval);
908 vam->result_ready = 1;
912 * Special-case: build the interface table, maintain
913 * the next loopback sw_if_index vbl.
915 static void vl_api_sw_interface_details_t_handler
916 (vl_api_sw_interface_details_t * mp)
918 vat_main_t *vam = &vat_main;
919 u8 *s = format (0, "%s%c", mp->interface_name, 0);
921 hash_set_mem (vam->sw_if_index_by_interface_name, s,
922 ntohl (mp->sw_if_index));
924 /* In sub interface case, fill the sub interface table entry */
925 if (mp->sw_if_index != mp->sup_sw_if_index)
927 sw_interface_subif_t *sub = NULL;
929 vec_add2 (vam->sw_if_subif_table, sub, 1);
931 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
932 strncpy ((char *) sub->interface_name, (char *) s,
933 vec_len (sub->interface_name));
934 sub->sw_if_index = ntohl (mp->sw_if_index);
935 sub->sub_id = ntohl (mp->sub_id);
937 sub->sub_dot1ad = mp->sub_dot1ad;
938 sub->sub_number_of_tags = mp->sub_number_of_tags;
939 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
940 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
941 sub->sub_exact_match = mp->sub_exact_match;
942 sub->sub_default = mp->sub_default;
943 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
944 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
946 /* vlan tag rewrite */
947 sub->vtr_op = ntohl (mp->vtr_op);
948 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
949 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
950 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
954 static void vl_api_sw_interface_details_t_handler_json
955 (vl_api_sw_interface_details_t * mp)
957 vat_main_t *vam = &vat_main;
958 vat_json_node_t *node = NULL;
960 if (VAT_JSON_ARRAY != vam->json_tree.type)
962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
963 vat_json_init_array (&vam->json_tree);
965 node = vat_json_array_add (&vam->json_tree);
967 vat_json_init_object (node);
968 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
969 vat_json_object_add_uint (node, "sup_sw_if_index",
970 ntohl (mp->sup_sw_if_index));
971 vat_json_object_add_uint (node, "l2_address_length",
972 ntohl (mp->l2_address_length));
973 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
974 sizeof (mp->l2_address));
975 vat_json_object_add_string_copy (node, "interface_name",
977 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
978 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
979 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
980 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
981 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
982 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
983 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
984 vat_json_object_add_uint (node, "sub_number_of_tags",
985 mp->sub_number_of_tags);
986 vat_json_object_add_uint (node, "sub_outer_vlan_id",
987 ntohs (mp->sub_outer_vlan_id));
988 vat_json_object_add_uint (node, "sub_inner_vlan_id",
989 ntohs (mp->sub_inner_vlan_id));
990 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
991 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
992 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
993 mp->sub_outer_vlan_id_any);
994 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
995 mp->sub_inner_vlan_id_any);
996 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
997 vat_json_object_add_uint (node, "vtr_push_dot1q",
998 ntohl (mp->vtr_push_dot1q));
999 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1000 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1003 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1005 format_ethernet_address,
1007 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1009 format_ethernet_address,
1011 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1012 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1016 #if VPP_API_TEST_BUILTIN == 0
1017 static void vl_api_sw_interface_event_t_handler
1018 (vl_api_sw_interface_event_t * mp)
1020 vat_main_t *vam = &vat_main;
1021 if (vam->interface_event_display)
1022 errmsg ("interface flags: sw_if_index %d %s %s",
1023 ntohl (mp->sw_if_index),
1024 mp->admin_up_down ? "admin-up" : "admin-down",
1025 mp->link_up_down ? "link-up" : "link-down");
1029 static void vl_api_sw_interface_event_t_handler_json
1030 (vl_api_sw_interface_event_t * mp)
1032 /* JSON output not supported */
1036 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1038 vat_main_t *vam = &vat_main;
1039 i32 retval = ntohl (mp->retval);
1041 vam->retval = retval;
1042 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1043 vam->result_ready = 1;
1047 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1049 vat_main_t *vam = &vat_main;
1050 vat_json_node_t node;
1051 api_main_t *am = &api_main;
1055 vat_json_init_object (&node);
1056 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1057 vat_json_object_add_uint (&node, "reply_in_shmem",
1058 ntohl (mp->reply_in_shmem));
1059 /* Toss the shared-memory original... */
1060 pthread_mutex_lock (&am->vlib_rp->mutex);
1061 oldheap = svm_push_data_heap (am->vlib_rp);
1063 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1066 svm_pop_heap (oldheap);
1067 pthread_mutex_unlock (&am->vlib_rp->mutex);
1069 vat_json_print (vam->ofp, &node);
1070 vat_json_free (&node);
1072 vam->retval = ntohl (mp->retval);
1073 vam->result_ready = 1;
1077 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1079 vat_main_t *vam = &vat_main;
1080 i32 retval = ntohl (mp->retval);
1081 u32 length = vl_api_string_len (&mp->reply);
1083 vec_reset_length (vam->cmd_reply);
1085 vam->retval = retval;
1088 vec_validate (vam->cmd_reply, length);
1089 clib_memcpy ((char *) (vam->cmd_reply),
1090 vl_api_from_api_string (&mp->reply), length);
1091 vam->cmd_reply[length] = 0;
1093 vam->result_ready = 1;
1097 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1099 vat_main_t *vam = &vat_main;
1100 vat_json_node_t node;
1102 vec_reset_length (vam->cmd_reply);
1104 vat_json_init_object (&node);
1105 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1106 vat_json_object_add_string_copy (&node, "reply",
1107 vl_api_from_api_string (&mp->reply));
1109 vat_json_print (vam->ofp, &node);
1110 vat_json_free (&node);
1112 vam->retval = ntohl (mp->retval);
1113 vam->result_ready = 1;
1116 static void vl_api_classify_add_del_table_reply_t_handler
1117 (vl_api_classify_add_del_table_reply_t * mp)
1119 vat_main_t *vam = &vat_main;
1120 i32 retval = ntohl (mp->retval);
1121 if (vam->async_mode)
1123 vam->async_errors += (retval < 0);
1127 vam->retval = retval;
1129 ((mp->new_table_index != 0xFFFFFFFF) ||
1130 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1131 (mp->match_n_vectors != 0xFFFFFFFF)))
1133 * Note: this is just barely thread-safe, depends on
1134 * the main thread spinning waiting for an answer...
1136 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1137 ntohl (mp->new_table_index),
1138 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1139 vam->result_ready = 1;
1143 static void vl_api_classify_add_del_table_reply_t_handler_json
1144 (vl_api_classify_add_del_table_reply_t * mp)
1146 vat_main_t *vam = &vat_main;
1147 vat_json_node_t node;
1149 vat_json_init_object (&node);
1150 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1151 vat_json_object_add_uint (&node, "new_table_index",
1152 ntohl (mp->new_table_index));
1153 vat_json_object_add_uint (&node, "skip_n_vectors",
1154 ntohl (mp->skip_n_vectors));
1155 vat_json_object_add_uint (&node, "match_n_vectors",
1156 ntohl (mp->match_n_vectors));
1158 vat_json_print (vam->ofp, &node);
1159 vat_json_free (&node);
1161 vam->retval = ntohl (mp->retval);
1162 vam->result_ready = 1;
1165 static void vl_api_get_node_index_reply_t_handler
1166 (vl_api_get_node_index_reply_t * mp)
1168 vat_main_t *vam = &vat_main;
1169 i32 retval = ntohl (mp->retval);
1170 if (vam->async_mode)
1172 vam->async_errors += (retval < 0);
1176 vam->retval = retval;
1178 errmsg ("node index %d", ntohl (mp->node_index));
1179 vam->result_ready = 1;
1183 static void vl_api_get_node_index_reply_t_handler_json
1184 (vl_api_get_node_index_reply_t * mp)
1186 vat_main_t *vam = &vat_main;
1187 vat_json_node_t node;
1189 vat_json_init_object (&node);
1190 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1191 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1193 vat_json_print (vam->ofp, &node);
1194 vat_json_free (&node);
1196 vam->retval = ntohl (mp->retval);
1197 vam->result_ready = 1;
1200 static void vl_api_get_next_index_reply_t_handler
1201 (vl_api_get_next_index_reply_t * mp)
1203 vat_main_t *vam = &vat_main;
1204 i32 retval = ntohl (mp->retval);
1205 if (vam->async_mode)
1207 vam->async_errors += (retval < 0);
1211 vam->retval = retval;
1213 errmsg ("next node index %d", ntohl (mp->next_index));
1214 vam->result_ready = 1;
1218 static void vl_api_get_next_index_reply_t_handler_json
1219 (vl_api_get_next_index_reply_t * mp)
1221 vat_main_t *vam = &vat_main;
1222 vat_json_node_t node;
1224 vat_json_init_object (&node);
1225 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1226 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1228 vat_json_print (vam->ofp, &node);
1229 vat_json_free (&node);
1231 vam->retval = ntohl (mp->retval);
1232 vam->result_ready = 1;
1235 static void vl_api_add_node_next_reply_t_handler
1236 (vl_api_add_node_next_reply_t * mp)
1238 vat_main_t *vam = &vat_main;
1239 i32 retval = ntohl (mp->retval);
1240 if (vam->async_mode)
1242 vam->async_errors += (retval < 0);
1246 vam->retval = retval;
1248 errmsg ("next index %d", ntohl (mp->next_index));
1249 vam->result_ready = 1;
1253 static void vl_api_add_node_next_reply_t_handler_json
1254 (vl_api_add_node_next_reply_t * mp)
1256 vat_main_t *vam = &vat_main;
1257 vat_json_node_t node;
1259 vat_json_init_object (&node);
1260 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1261 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1263 vat_json_print (vam->ofp, &node);
1264 vat_json_free (&node);
1266 vam->retval = ntohl (mp->retval);
1267 vam->result_ready = 1;
1270 static void vl_api_show_version_reply_t_handler
1271 (vl_api_show_version_reply_t * mp)
1273 vat_main_t *vam = &vat_main;
1274 i32 retval = ntohl (mp->retval);
1279 char *p = (char *) &mp->program;
1281 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1282 errmsg (" program: %s\n", s);
1286 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1287 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1288 errmsg (" version: %s\n", s);
1292 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1293 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1294 errmsg (" build date: %s\n", s);
1298 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1299 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1300 errmsg ("build directory: %s\n", s);
1303 vam->retval = retval;
1304 vam->result_ready = 1;
1307 static void vl_api_show_version_reply_t_handler_json
1308 (vl_api_show_version_reply_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 vat_json_node_t node;
1313 vat_json_init_object (&node);
1314 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1315 char *p = (char *) &mp->program;
1316 vat_json_object_add_string_copy (&node, "program",
1317 vl_api_from_api_string ((vl_api_string_t *)
1319 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1320 vat_json_object_add_string_copy (&node, "version",
1321 vl_api_from_api_string ((vl_api_string_t *)
1323 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1324 vat_json_object_add_string_copy (&node, "build_date",
1325 vl_api_from_api_string ((vl_api_string_t *)
1327 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1328 vat_json_object_add_string_copy (&node, "build_directory",
1329 vl_api_from_api_string ((vl_api_string_t *)
1332 vat_json_print (vam->ofp, &node);
1333 vat_json_free (&node);
1335 vam->retval = ntohl (mp->retval);
1336 vam->result_ready = 1;
1339 static void vl_api_show_threads_reply_t_handler
1340 (vl_api_show_threads_reply_t * mp)
1342 vat_main_t *vam = &vat_main;
1343 i32 retval = ntohl (mp->retval);
1347 count = ntohl (mp->count);
1349 for (i = 0; i < count; i++)
1351 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1352 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1353 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1354 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1355 ntohl (mp->thread_data[i].cpu_socket));
1357 vam->retval = retval;
1358 vam->result_ready = 1;
1361 static void vl_api_show_threads_reply_t_handler_json
1362 (vl_api_show_threads_reply_t * mp)
1364 vat_main_t *vam = &vat_main;
1365 vat_json_node_t node;
1366 vl_api_thread_data_t *td;
1367 i32 retval = ntohl (mp->retval);
1371 count = ntohl (mp->count);
1373 vat_json_init_object (&node);
1374 vat_json_object_add_int (&node, "retval", retval);
1375 vat_json_object_add_uint (&node, "count", count);
1377 for (i = 0; i < count; i++)
1379 td = &mp->thread_data[i];
1380 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1381 vat_json_object_add_string_copy (&node, "name", td->name);
1382 vat_json_object_add_string_copy (&node, "type", td->type);
1383 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1384 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1385 vat_json_object_add_int (&node, "core", ntohl (td->id));
1386 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1389 vat_json_print (vam->ofp, &node);
1390 vat_json_free (&node);
1392 vam->retval = retval;
1393 vam->result_ready = 1;
1397 api_show_threads (vat_main_t * vam)
1399 vl_api_show_threads_t *mp;
1403 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1404 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1406 M (SHOW_THREADS, mp);
1414 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1416 u32 sw_if_index = ntohl (mp->sw_if_index);
1417 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1418 mp->mac_ip ? "mac/ip binding" : "address resolution",
1419 ntohl (mp->pid), format_ip4_address, mp->ip,
1420 format_vl_api_mac_address, &mp->mac, sw_if_index);
1424 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1426 /* JSON output not supported */
1430 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1432 u32 sw_if_index = ntohl (mp->sw_if_index);
1433 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1434 mp->mac_ip ? "mac/ip binding" : "address resolution",
1435 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1436 format_vl_api_mac_address, mp->mac, sw_if_index);
1440 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1442 /* JSON output not supported */
1446 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1448 u32 n_macs = ntohl (mp->n_macs);
1449 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1450 ntohl (mp->pid), mp->client_index, n_macs);
1452 for (i = 0; i < n_macs; i++)
1454 vl_api_mac_entry_t *mac = &mp->mac[i];
1455 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1456 i + 1, ntohl (mac->sw_if_index),
1457 format_ethernet_address, mac->mac_addr, mac->action);
1464 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1466 /* JSON output not supported */
1469 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1470 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1473 * Special-case: build the bridge domain table, maintain
1474 * the next bd id vbl.
1476 static void vl_api_bridge_domain_details_t_handler
1477 (vl_api_bridge_domain_details_t * mp)
1479 vat_main_t *vam = &vat_main;
1480 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1483 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1484 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1486 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1487 ntohl (mp->bd_id), mp->learn, mp->forward,
1488 mp->flood, ntohl (mp->bvi_sw_if_index),
1489 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1493 vl_api_bridge_domain_sw_if_t *sw_ifs;
1494 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1497 sw_ifs = mp->sw_if_details;
1498 for (i = 0; i < n_sw_ifs; i++)
1504 sw_if_index = ntohl (sw_ifs->sw_if_index);
1507 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1509 if ((u32) p->value[0] == sw_if_index)
1511 sw_if_name = (u8 *)(p->key);
1516 print (vam->ofp, "%7d %3d %s", sw_if_index,
1517 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1518 "sw_if_index not found!");
1525 static void vl_api_bridge_domain_details_t_handler_json
1526 (vl_api_bridge_domain_details_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 vat_json_node_t *node, *array = NULL;
1530 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1532 if (VAT_JSON_ARRAY != vam->json_tree.type)
1534 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1535 vat_json_init_array (&vam->json_tree);
1537 node = vat_json_array_add (&vam->json_tree);
1539 vat_json_init_object (node);
1540 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1541 vat_json_object_add_uint (node, "flood", mp->flood);
1542 vat_json_object_add_uint (node, "forward", mp->forward);
1543 vat_json_object_add_uint (node, "learn", mp->learn);
1544 vat_json_object_add_uint (node, "bvi_sw_if_index",
1545 ntohl (mp->bvi_sw_if_index));
1546 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1547 array = vat_json_object_add (node, "sw_if");
1548 vat_json_init_array (array);
1554 vl_api_bridge_domain_sw_if_t *sw_ifs;
1557 sw_ifs = mp->sw_if_details;
1558 for (i = 0; i < n_sw_ifs; i++)
1560 node = vat_json_array_add (array);
1561 vat_json_init_object (node);
1562 vat_json_object_add_uint (node, "sw_if_index",
1563 ntohl (sw_ifs->sw_if_index));
1564 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1570 static void vl_api_control_ping_reply_t_handler
1571 (vl_api_control_ping_reply_t * mp)
1573 vat_main_t *vam = &vat_main;
1574 i32 retval = ntohl (mp->retval);
1575 if (vam->async_mode)
1577 vam->async_errors += (retval < 0);
1581 vam->retval = retval;
1582 vam->result_ready = 1;
1584 if (vam->socket_client_main)
1585 vam->socket_client_main->control_pings_outstanding--;
1588 static void vl_api_control_ping_reply_t_handler_json
1589 (vl_api_control_ping_reply_t * mp)
1591 vat_main_t *vam = &vat_main;
1592 i32 retval = ntohl (mp->retval);
1594 if (VAT_JSON_NONE != vam->json_tree.type)
1596 vat_json_print (vam->ofp, &vam->json_tree);
1597 vat_json_free (&vam->json_tree);
1598 vam->json_tree.type = VAT_JSON_NONE;
1603 vat_json_init_array (&vam->json_tree);
1604 vat_json_print (vam->ofp, &vam->json_tree);
1605 vam->json_tree.type = VAT_JSON_NONE;
1608 vam->retval = retval;
1609 vam->result_ready = 1;
1613 vl_api_bridge_domain_set_mac_age_reply_t_handler
1614 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1616 vat_main_t *vam = &vat_main;
1617 i32 retval = ntohl (mp->retval);
1618 if (vam->async_mode)
1620 vam->async_errors += (retval < 0);
1624 vam->retval = retval;
1625 vam->result_ready = 1;
1629 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1630 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1632 vat_main_t *vam = &vat_main;
1633 vat_json_node_t node;
1635 vat_json_init_object (&node);
1636 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1638 vat_json_print (vam->ofp, &node);
1639 vat_json_free (&node);
1641 vam->retval = ntohl (mp->retval);
1642 vam->result_ready = 1;
1646 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1648 vat_main_t *vam = &vat_main;
1649 i32 retval = ntohl (mp->retval);
1650 if (vam->async_mode)
1652 vam->async_errors += (retval < 0);
1656 vam->retval = retval;
1657 vam->result_ready = 1;
1661 static void vl_api_l2_flags_reply_t_handler_json
1662 (vl_api_l2_flags_reply_t * mp)
1664 vat_main_t *vam = &vat_main;
1665 vat_json_node_t node;
1667 vat_json_init_object (&node);
1668 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1669 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1670 ntohl (mp->resulting_feature_bitmap));
1672 vat_json_print (vam->ofp, &node);
1673 vat_json_free (&node);
1675 vam->retval = ntohl (mp->retval);
1676 vam->result_ready = 1;
1679 static void vl_api_bridge_flags_reply_t_handler
1680 (vl_api_bridge_flags_reply_t * mp)
1682 vat_main_t *vam = &vat_main;
1683 i32 retval = ntohl (mp->retval);
1684 if (vam->async_mode)
1686 vam->async_errors += (retval < 0);
1690 vam->retval = retval;
1691 vam->result_ready = 1;
1695 static void vl_api_bridge_flags_reply_t_handler_json
1696 (vl_api_bridge_flags_reply_t * mp)
1698 vat_main_t *vam = &vat_main;
1699 vat_json_node_t node;
1701 vat_json_init_object (&node);
1702 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1703 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1704 ntohl (mp->resulting_feature_bitmap));
1706 vat_json_print (vam->ofp, &node);
1707 vat_json_free (&node);
1709 vam->retval = ntohl (mp->retval);
1710 vam->result_ready = 1;
1714 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1716 vat_main_t *vam = &vat_main;
1717 i32 retval = ntohl (mp->retval);
1718 if (vam->async_mode)
1720 vam->async_errors += (retval < 0);
1724 vam->retval = retval;
1725 vam->sw_if_index = ntohl (mp->sw_if_index);
1726 vam->result_ready = 1;
1731 static void vl_api_tap_create_v2_reply_t_handler_json
1732 (vl_api_tap_create_v2_reply_t * mp)
1734 vat_main_t *vam = &vat_main;
1735 vat_json_node_t node;
1737 vat_json_init_object (&node);
1738 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1739 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1741 vat_json_print (vam->ofp, &node);
1742 vat_json_free (&node);
1744 vam->retval = ntohl (mp->retval);
1745 vam->result_ready = 1;
1750 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1752 vat_main_t *vam = &vat_main;
1753 i32 retval = ntohl (mp->retval);
1754 if (vam->async_mode)
1756 vam->async_errors += (retval < 0);
1760 vam->retval = retval;
1761 vam->result_ready = 1;
1765 static void vl_api_tap_delete_v2_reply_t_handler_json
1766 (vl_api_tap_delete_v2_reply_t * mp)
1768 vat_main_t *vam = &vat_main;
1769 vat_json_node_t node;
1771 vat_json_init_object (&node);
1772 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1774 vat_json_print (vam->ofp, &node);
1775 vat_json_free (&node);
1777 vam->retval = ntohl (mp->retval);
1778 vam->result_ready = 1;
1782 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1785 vat_main_t *vam = &vat_main;
1786 i32 retval = ntohl (mp->retval);
1787 if (vam->async_mode)
1789 vam->async_errors += (retval < 0);
1793 vam->retval = retval;
1794 vam->sw_if_index = ntohl (mp->sw_if_index);
1795 vam->result_ready = 1;
1799 static void vl_api_virtio_pci_create_reply_t_handler_json
1800 (vl_api_virtio_pci_create_reply_t * mp)
1802 vat_main_t *vam = &vat_main;
1803 vat_json_node_t node;
1805 vat_json_init_object (&node);
1806 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1807 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1809 vat_json_print (vam->ofp, &node);
1810 vat_json_free (&node);
1812 vam->retval = ntohl (mp->retval);
1813 vam->result_ready = 1;
1818 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1821 vat_main_t *vam = &vat_main;
1822 i32 retval = ntohl (mp->retval);
1823 if (vam->async_mode)
1825 vam->async_errors += (retval < 0);
1829 vam->retval = retval;
1830 vam->result_ready = 1;
1834 static void vl_api_virtio_pci_delete_reply_t_handler_json
1835 (vl_api_virtio_pci_delete_reply_t * mp)
1837 vat_main_t *vam = &vat_main;
1838 vat_json_node_t node;
1840 vat_json_init_object (&node);
1841 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1843 vat_json_print (vam->ofp, &node);
1844 vat_json_free (&node);
1846 vam->retval = ntohl (mp->retval);
1847 vam->result_ready = 1;
1851 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1853 vat_main_t *vam = &vat_main;
1854 i32 retval = ntohl (mp->retval);
1856 if (vam->async_mode)
1858 vam->async_errors += (retval < 0);
1862 vam->retval = retval;
1863 vam->sw_if_index = ntohl (mp->sw_if_index);
1864 vam->result_ready = 1;
1868 static void vl_api_bond_create_reply_t_handler_json
1869 (vl_api_bond_create_reply_t * mp)
1871 vat_main_t *vam = &vat_main;
1872 vat_json_node_t node;
1874 vat_json_init_object (&node);
1875 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1876 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1878 vat_json_print (vam->ofp, &node);
1879 vat_json_free (&node);
1881 vam->retval = ntohl (mp->retval);
1882 vam->result_ready = 1;
1886 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1888 vat_main_t *vam = &vat_main;
1889 i32 retval = ntohl (mp->retval);
1891 if (vam->async_mode)
1893 vam->async_errors += (retval < 0);
1897 vam->retval = retval;
1898 vam->result_ready = 1;
1902 static void vl_api_bond_delete_reply_t_handler_json
1903 (vl_api_bond_delete_reply_t * mp)
1905 vat_main_t *vam = &vat_main;
1906 vat_json_node_t node;
1908 vat_json_init_object (&node);
1909 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1911 vat_json_print (vam->ofp, &node);
1912 vat_json_free (&node);
1914 vam->retval = ntohl (mp->retval);
1915 vam->result_ready = 1;
1919 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1921 vat_main_t *vam = &vat_main;
1922 i32 retval = ntohl (mp->retval);
1924 if (vam->async_mode)
1926 vam->async_errors += (retval < 0);
1930 vam->retval = retval;
1931 vam->result_ready = 1;
1935 static void vl_api_bond_enslave_reply_t_handler_json
1936 (vl_api_bond_enslave_reply_t * mp)
1938 vat_main_t *vam = &vat_main;
1939 vat_json_node_t node;
1941 vat_json_init_object (&node);
1942 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1944 vat_json_print (vam->ofp, &node);
1945 vat_json_free (&node);
1947 vam->retval = ntohl (mp->retval);
1948 vam->result_ready = 1;
1952 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1955 vat_main_t *vam = &vat_main;
1956 i32 retval = ntohl (mp->retval);
1958 if (vam->async_mode)
1960 vam->async_errors += (retval < 0);
1964 vam->retval = retval;
1965 vam->result_ready = 1;
1969 static void vl_api_bond_detach_slave_reply_t_handler_json
1970 (vl_api_bond_detach_slave_reply_t * mp)
1972 vat_main_t *vam = &vat_main;
1973 vat_json_node_t node;
1975 vat_json_init_object (&node);
1976 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1978 vat_json_print (vam->ofp, &node);
1979 vat_json_free (&node);
1981 vam->retval = ntohl (mp->retval);
1982 vam->result_ready = 1;
1985 static void vl_api_sw_interface_bond_details_t_handler
1986 (vl_api_sw_interface_bond_details_t * mp)
1988 vat_main_t *vam = &vat_main;
1991 "%-16s %-12d %-12U %-13U %-14u %-14u",
1992 mp->interface_name, ntohl (mp->sw_if_index),
1993 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1994 ntohl (mp->active_slaves), ntohl (mp->slaves));
1997 static void vl_api_sw_interface_bond_details_t_handler_json
1998 (vl_api_sw_interface_bond_details_t * mp)
2000 vat_main_t *vam = &vat_main;
2001 vat_json_node_t *node = NULL;
2003 if (VAT_JSON_ARRAY != vam->json_tree.type)
2005 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2006 vat_json_init_array (&vam->json_tree);
2008 node = vat_json_array_add (&vam->json_tree);
2010 vat_json_init_object (node);
2011 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2012 vat_json_object_add_string_copy (node, "interface_name",
2013 mp->interface_name);
2014 vat_json_object_add_uint (node, "mode", mp->mode);
2015 vat_json_object_add_uint (node, "load_balance", mp->lb);
2016 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2017 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2021 api_sw_interface_bond_dump (vat_main_t * vam)
2023 vl_api_sw_interface_bond_dump_t *mp;
2024 vl_api_control_ping_t *mp_ping;
2028 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2029 "interface name", "sw_if_index", "mode", "load balance",
2030 "active slaves", "slaves");
2032 /* Get list of bond interfaces */
2033 M (SW_INTERFACE_BOND_DUMP, mp);
2036 /* Use a control ping for synchronization */
2037 MPING (CONTROL_PING, mp_ping);
2044 static void vl_api_sw_interface_slave_details_t_handler
2045 (vl_api_sw_interface_slave_details_t * mp)
2047 vat_main_t *vam = &vat_main;
2050 "%-25s %-12d %-12d %d", mp->interface_name,
2051 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2054 static void vl_api_sw_interface_slave_details_t_handler_json
2055 (vl_api_sw_interface_slave_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, "passive", mp->is_passive);
2072 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2076 api_sw_interface_slave_dump (vat_main_t * vam)
2078 unformat_input_t *i = vam->input;
2079 vl_api_sw_interface_slave_dump_t *mp;
2080 vl_api_control_ping_t *mp_ping;
2081 u32 sw_if_index = ~0;
2082 u8 sw_if_index_set = 0;
2085 /* Parse args required to build the message */
2086 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2088 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2089 sw_if_index_set = 1;
2090 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2091 sw_if_index_set = 1;
2096 if (sw_if_index_set == 0)
2098 errmsg ("missing vpp interface name. ");
2103 "\n%-25s %-12s %-12s %s",
2104 "slave interface name", "sw_if_index", "passive", "long_timeout");
2106 /* Get list of bond interfaces */
2107 M (SW_INTERFACE_SLAVE_DUMP, mp);
2108 mp->sw_if_index = ntohl (sw_if_index);
2111 /* Use a control ping for synchronization */
2112 MPING (CONTROL_PING, mp_ping);
2119 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2120 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2122 vat_main_t *vam = &vat_main;
2123 i32 retval = ntohl (mp->retval);
2124 if (vam->async_mode)
2126 vam->async_errors += (retval < 0);
2130 vam->retval = retval;
2131 vam->sw_if_index = ntohl (mp->sw_if_index);
2132 vam->result_ready = 1;
2134 vam->regenerate_interface_table = 1;
2137 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2138 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2140 vat_main_t *vam = &vat_main;
2141 vat_json_node_t node;
2143 vat_json_init_object (&node);
2144 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2145 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2146 ntohl (mp->sw_if_index));
2148 vat_json_print (vam->ofp, &node);
2149 vat_json_free (&node);
2151 vam->retval = ntohl (mp->retval);
2152 vam->result_ready = 1;
2155 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2156 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2158 vat_main_t *vam = &vat_main;
2159 i32 retval = ntohl (mp->retval);
2160 if (vam->async_mode)
2162 vam->async_errors += (retval < 0);
2166 vam->retval = retval;
2167 vam->sw_if_index = ntohl (mp->sw_if_index);
2168 vam->result_ready = 1;
2172 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2173 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2175 vat_main_t *vam = &vat_main;
2176 vat_json_node_t node;
2178 vat_json_init_object (&node);
2179 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2180 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2182 vat_json_print (vam->ofp, &node);
2183 vat_json_free (&node);
2185 vam->retval = ntohl (mp->retval);
2186 vam->result_ready = 1;
2189 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2190 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2192 vat_main_t *vam = &vat_main;
2193 i32 retval = ntohl (mp->retval);
2194 if (vam->async_mode)
2196 vam->async_errors += (retval < 0);
2200 vam->retval = retval;
2201 vam->result_ready = 1;
2205 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2206 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2208 vat_main_t *vam = &vat_main;
2209 vat_json_node_t node;
2211 vat_json_init_object (&node);
2212 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2213 vat_json_object_add_uint (&node, "fwd_entry_index",
2214 clib_net_to_host_u32 (mp->fwd_entry_index));
2216 vat_json_print (vam->ofp, &node);
2217 vat_json_free (&node);
2219 vam->retval = ntohl (mp->retval);
2220 vam->result_ready = 1;
2224 format_lisp_transport_protocol (u8 * s, va_list * args)
2226 u32 proto = va_arg (*args, u32);
2231 return format (s, "udp");
2233 return format (s, "api");
2240 static void vl_api_one_get_transport_protocol_reply_t_handler
2241 (vl_api_one_get_transport_protocol_reply_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 i32 retval = ntohl (mp->retval);
2245 if (vam->async_mode)
2247 vam->async_errors += (retval < 0);
2251 u32 proto = mp->protocol;
2252 print (vam->ofp, "Transport protocol: %U",
2253 format_lisp_transport_protocol, proto);
2254 vam->retval = retval;
2255 vam->result_ready = 1;
2259 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2260 (vl_api_one_get_transport_protocol_reply_t * mp)
2262 vat_main_t *vam = &vat_main;
2263 vat_json_node_t node;
2266 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2269 vat_json_init_object (&node);
2270 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2271 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2274 vat_json_print (vam->ofp, &node);
2275 vat_json_free (&node);
2277 vam->retval = ntohl (mp->retval);
2278 vam->result_ready = 1;
2281 static void vl_api_one_add_del_locator_set_reply_t_handler
2282 (vl_api_one_add_del_locator_set_reply_t * mp)
2284 vat_main_t *vam = &vat_main;
2285 i32 retval = ntohl (mp->retval);
2286 if (vam->async_mode)
2288 vam->async_errors += (retval < 0);
2292 vam->retval = retval;
2293 vam->result_ready = 1;
2297 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2298 (vl_api_one_add_del_locator_set_reply_t * mp)
2300 vat_main_t *vam = &vat_main;
2301 vat_json_node_t node;
2303 vat_json_init_object (&node);
2304 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2305 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2307 vat_json_print (vam->ofp, &node);
2308 vat_json_free (&node);
2310 vam->retval = ntohl (mp->retval);
2311 vam->result_ready = 1;
2314 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2315 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2317 vat_main_t *vam = &vat_main;
2318 i32 retval = ntohl (mp->retval);
2319 if (vam->async_mode)
2321 vam->async_errors += (retval < 0);
2325 vam->retval = retval;
2326 vam->sw_if_index = ntohl (mp->sw_if_index);
2327 vam->result_ready = 1;
2329 vam->regenerate_interface_table = 1;
2332 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2333 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2335 vat_main_t *vam = &vat_main;
2336 vat_json_node_t node;
2338 vat_json_init_object (&node);
2339 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2340 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2342 vat_json_print (vam->ofp, &node);
2343 vat_json_free (&node);
2345 vam->retval = ntohl (mp->retval);
2346 vam->result_ready = 1;
2349 static void vl_api_vxlan_offload_rx_reply_t_handler
2350 (vl_api_vxlan_offload_rx_reply_t * mp)
2352 vat_main_t *vam = &vat_main;
2353 i32 retval = ntohl (mp->retval);
2354 if (vam->async_mode)
2356 vam->async_errors += (retval < 0);
2360 vam->retval = retval;
2361 vam->result_ready = 1;
2365 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2366 (vl_api_vxlan_offload_rx_reply_t * mp)
2368 vat_main_t *vam = &vat_main;
2369 vat_json_node_t node;
2371 vat_json_init_object (&node);
2372 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2374 vat_json_print (vam->ofp, &node);
2375 vat_json_free (&node);
2377 vam->retval = ntohl (mp->retval);
2378 vam->result_ready = 1;
2381 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2382 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2384 vat_main_t *vam = &vat_main;
2385 i32 retval = ntohl (mp->retval);
2386 if (vam->async_mode)
2388 vam->async_errors += (retval < 0);
2392 vam->retval = retval;
2393 vam->sw_if_index = ntohl (mp->sw_if_index);
2394 vam->result_ready = 1;
2398 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2399 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2401 vat_main_t *vam = &vat_main;
2402 vat_json_node_t node;
2404 vat_json_init_object (&node);
2405 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2406 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2408 vat_json_print (vam->ofp, &node);
2409 vat_json_free (&node);
2411 vam->retval = ntohl (mp->retval);
2412 vam->result_ready = 1;
2415 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2416 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2418 vat_main_t *vam = &vat_main;
2419 i32 retval = ntohl (mp->retval);
2420 if (vam->async_mode)
2422 vam->async_errors += (retval < 0);
2426 vam->retval = retval;
2427 vam->sw_if_index = ntohl (mp->sw_if_index);
2428 vam->result_ready = 1;
2430 vam->regenerate_interface_table = 1;
2433 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2434 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2436 vat_main_t *vam = &vat_main;
2437 vat_json_node_t node;
2439 vat_json_init_object (&node);
2440 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2441 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2443 vat_json_print (vam->ofp, &node);
2444 vat_json_free (&node);
2446 vam->retval = ntohl (mp->retval);
2447 vam->result_ready = 1;
2450 static void vl_api_gre_add_del_tunnel_reply_t_handler
2451 (vl_api_gre_add_del_tunnel_reply_t * mp)
2453 vat_main_t *vam = &vat_main;
2454 i32 retval = ntohl (mp->retval);
2455 if (vam->async_mode)
2457 vam->async_errors += (retval < 0);
2461 vam->retval = retval;
2462 vam->sw_if_index = ntohl (mp->sw_if_index);
2463 vam->result_ready = 1;
2467 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2468 (vl_api_gre_add_del_tunnel_reply_t * mp)
2470 vat_main_t *vam = &vat_main;
2471 vat_json_node_t node;
2473 vat_json_init_object (&node);
2474 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2475 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2477 vat_json_print (vam->ofp, &node);
2478 vat_json_free (&node);
2480 vam->retval = ntohl (mp->retval);
2481 vam->result_ready = 1;
2484 static void vl_api_create_vhost_user_if_reply_t_handler
2485 (vl_api_create_vhost_user_if_reply_t * mp)
2487 vat_main_t *vam = &vat_main;
2488 i32 retval = ntohl (mp->retval);
2489 if (vam->async_mode)
2491 vam->async_errors += (retval < 0);
2495 vam->retval = retval;
2496 vam->sw_if_index = ntohl (mp->sw_if_index);
2497 vam->result_ready = 1;
2499 vam->regenerate_interface_table = 1;
2502 static void vl_api_create_vhost_user_if_reply_t_handler_json
2503 (vl_api_create_vhost_user_if_reply_t * mp)
2505 vat_main_t *vam = &vat_main;
2506 vat_json_node_t node;
2508 vat_json_init_object (&node);
2509 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2510 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2512 vat_json_print (vam->ofp, &node);
2513 vat_json_free (&node);
2515 vam->retval = ntohl (mp->retval);
2516 vam->result_ready = 1;
2519 static void vl_api_dns_resolve_name_reply_t_handler
2520 (vl_api_dns_resolve_name_reply_t * mp)
2522 vat_main_t *vam = &vat_main;
2523 i32 retval = ntohl (mp->retval);
2524 if (vam->async_mode)
2526 vam->async_errors += (retval < 0);
2530 vam->retval = retval;
2531 vam->result_ready = 1;
2536 clib_warning ("ip4 address %U", format_ip4_address,
2537 (ip4_address_t *) mp->ip4_address);
2539 clib_warning ("ip6 address %U", format_ip6_address,
2540 (ip6_address_t *) mp->ip6_address);
2543 clib_warning ("retval %d", retval);
2547 static void vl_api_dns_resolve_name_reply_t_handler_json
2548 (vl_api_dns_resolve_name_reply_t * mp)
2550 clib_warning ("not implemented");
2553 static void vl_api_dns_resolve_ip_reply_t_handler
2554 (vl_api_dns_resolve_ip_reply_t * mp)
2556 vat_main_t *vam = &vat_main;
2557 i32 retval = ntohl (mp->retval);
2558 if (vam->async_mode)
2560 vam->async_errors += (retval < 0);
2564 vam->retval = retval;
2565 vam->result_ready = 1;
2569 clib_warning ("canonical name %s", mp->name);
2572 clib_warning ("retval %d", retval);
2576 static void vl_api_dns_resolve_ip_reply_t_handler_json
2577 (vl_api_dns_resolve_ip_reply_t * mp)
2579 clib_warning ("not implemented");
2583 static void vl_api_ip_address_details_t_handler
2584 (vl_api_ip_address_details_t * mp)
2586 vat_main_t *vam = &vat_main;
2587 static ip_address_details_t empty_ip_address_details = { {0} };
2588 ip_address_details_t *address = NULL;
2589 ip_details_t *current_ip_details = NULL;
2590 ip_details_t *details = NULL;
2592 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2594 if (!details || vam->current_sw_if_index >= vec_len (details)
2595 || !details[vam->current_sw_if_index].present)
2597 errmsg ("ip address details arrived but not stored");
2598 errmsg ("ip_dump should be called first");
2602 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2604 #define addresses (current_ip_details->addr)
2606 vec_validate_init_empty (addresses, vec_len (addresses),
2607 empty_ip_address_details);
2609 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2611 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2612 address->prefix_length = mp->prefix_length;
2616 static void vl_api_ip_address_details_t_handler_json
2617 (vl_api_ip_address_details_t * mp)
2619 vat_main_t *vam = &vat_main;
2620 vat_json_node_t *node = NULL;
2621 struct in6_addr ip6;
2624 if (VAT_JSON_ARRAY != vam->json_tree.type)
2626 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2627 vat_json_init_array (&vam->json_tree);
2629 node = vat_json_array_add (&vam->json_tree);
2631 vat_json_init_object (node);
2634 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2635 vat_json_object_add_ip6 (node, "ip", ip6);
2639 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2640 vat_json_object_add_ip4 (node, "ip", ip4);
2642 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2646 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2648 vat_main_t *vam = &vat_main;
2649 static ip_details_t empty_ip_details = { 0 };
2650 ip_details_t *ip = NULL;
2651 u32 sw_if_index = ~0;
2653 sw_if_index = ntohl (mp->sw_if_index);
2655 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2656 sw_if_index, empty_ip_details);
2658 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2665 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2667 vat_main_t *vam = &vat_main;
2669 if (VAT_JSON_ARRAY != vam->json_tree.type)
2671 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2672 vat_json_init_array (&vam->json_tree);
2674 vat_json_array_add_uint (&vam->json_tree,
2675 clib_net_to_host_u32 (mp->sw_if_index));
2679 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2681 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2682 "router_addr %U host_mac %U",
2683 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2685 format_ip4_address, &mp->lease.host_address,
2686 format_ip4_address, &mp->lease.router_address,
2687 format_ethernet_address, mp->lease.host_mac);
2690 static void vl_api_dhcp_compl_event_t_handler_json
2691 (vl_api_dhcp_compl_event_t * mp)
2693 /* JSON output not supported */
2696 static void vl_api_get_first_msg_id_reply_t_handler
2697 (vl_api_get_first_msg_id_reply_t * mp)
2699 vat_main_t *vam = &vat_main;
2700 i32 retval = ntohl (mp->retval);
2702 if (vam->async_mode)
2704 vam->async_errors += (retval < 0);
2708 vam->retval = retval;
2709 vam->result_ready = 1;
2713 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2717 static void vl_api_get_first_msg_id_reply_t_handler_json
2718 (vl_api_get_first_msg_id_reply_t * mp)
2720 vat_main_t *vam = &vat_main;
2721 vat_json_node_t node;
2723 vat_json_init_object (&node);
2724 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2725 vat_json_object_add_uint (&node, "first_msg_id",
2726 (uint) ntohs (mp->first_msg_id));
2728 vat_json_print (vam->ofp, &node);
2729 vat_json_free (&node);
2731 vam->retval = ntohl (mp->retval);
2732 vam->result_ready = 1;
2735 static void vl_api_get_node_graph_reply_t_handler
2736 (vl_api_get_node_graph_reply_t * mp)
2738 vat_main_t *vam = &vat_main;
2739 api_main_t *am = &api_main;
2740 i32 retval = ntohl (mp->retval);
2741 u8 *pvt_copy, *reply;
2746 if (vam->async_mode)
2748 vam->async_errors += (retval < 0);
2752 vam->retval = retval;
2753 vam->result_ready = 1;
2756 /* "Should never happen..." */
2760 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2761 pvt_copy = vec_dup (reply);
2763 /* Toss the shared-memory original... */
2764 pthread_mutex_lock (&am->vlib_rp->mutex);
2765 oldheap = svm_push_data_heap (am->vlib_rp);
2769 svm_pop_heap (oldheap);
2770 pthread_mutex_unlock (&am->vlib_rp->mutex);
2772 if (vam->graph_nodes)
2774 hash_free (vam->graph_node_index_by_name);
2776 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2778 node = vam->graph_nodes[0][i];
2779 vec_free (node->name);
2780 vec_free (node->next_nodes);
2783 vec_free (vam->graph_nodes[0]);
2784 vec_free (vam->graph_nodes);
2787 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2788 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2789 vec_free (pvt_copy);
2791 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2793 node = vam->graph_nodes[0][i];
2794 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2798 static void vl_api_get_node_graph_reply_t_handler_json
2799 (vl_api_get_node_graph_reply_t * mp)
2801 vat_main_t *vam = &vat_main;
2802 api_main_t *am = &api_main;
2804 vat_json_node_t node;
2807 /* $$$$ make this real? */
2808 vat_json_init_object (&node);
2809 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2810 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2812 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2814 /* Toss the shared-memory original... */
2815 pthread_mutex_lock (&am->vlib_rp->mutex);
2816 oldheap = svm_push_data_heap (am->vlib_rp);
2820 svm_pop_heap (oldheap);
2821 pthread_mutex_unlock (&am->vlib_rp->mutex);
2823 vat_json_print (vam->ofp, &node);
2824 vat_json_free (&node);
2826 vam->retval = ntohl (mp->retval);
2827 vam->result_ready = 1;
2831 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2833 vat_main_t *vam = &vat_main;
2838 s = format (s, "%=16d%=16d%=16d",
2839 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2843 s = format (s, "%=16U%=16d%=16d",
2844 mp->is_ipv6 ? format_ip6_address :
2846 mp->ip_address, mp->priority, mp->weight);
2849 print (vam->ofp, "%v", s);
2854 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2856 vat_main_t *vam = &vat_main;
2857 vat_json_node_t *node = NULL;
2858 struct in6_addr ip6;
2861 if (VAT_JSON_ARRAY != vam->json_tree.type)
2863 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2864 vat_json_init_array (&vam->json_tree);
2866 node = vat_json_array_add (&vam->json_tree);
2867 vat_json_init_object (node);
2869 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2870 vat_json_object_add_uint (node, "priority", mp->priority);
2871 vat_json_object_add_uint (node, "weight", mp->weight);
2874 vat_json_object_add_uint (node, "sw_if_index",
2875 clib_net_to_host_u32 (mp->sw_if_index));
2880 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2881 vat_json_object_add_ip6 (node, "address", ip6);
2885 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2886 vat_json_object_add_ip4 (node, "address", ip4);
2892 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2895 vat_main_t *vam = &vat_main;
2898 ls_name = format (0, "%s", mp->ls_name);
2900 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2906 vl_api_one_locator_set_details_t_handler_json
2907 (vl_api_one_locator_set_details_t * mp)
2909 vat_main_t *vam = &vat_main;
2910 vat_json_node_t *node = 0;
2913 ls_name = format (0, "%s", mp->ls_name);
2914 vec_add1 (ls_name, 0);
2916 if (VAT_JSON_ARRAY != vam->json_tree.type)
2918 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2919 vat_json_init_array (&vam->json_tree);
2921 node = vat_json_array_add (&vam->json_tree);
2923 vat_json_init_object (node);
2924 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2925 vat_json_object_add_uint (node, "ls_index",
2926 clib_net_to_host_u32 (mp->ls_index));
2934 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2937 unformat_nsh_address (unformat_input_t * input, va_list * args)
2939 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2940 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2944 format_nsh_address_vat (u8 * s, va_list * args)
2946 nsh_t *a = va_arg (*args, nsh_t *);
2947 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2951 format_lisp_flat_eid (u8 * s, va_list * args)
2953 u32 type = va_arg (*args, u32);
2954 u8 *eid = va_arg (*args, u8 *);
2955 u32 eid_len = va_arg (*args, u32);
2960 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2962 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2964 return format (s, "%U", format_ethernet_address, eid);
2966 return format (s, "%U", format_nsh_address_vat, eid);
2972 format_lisp_eid_vat (u8 * s, va_list * args)
2974 u32 type = va_arg (*args, u32);
2975 u8 *eid = va_arg (*args, u8 *);
2976 u32 eid_len = va_arg (*args, u32);
2977 u8 *seid = va_arg (*args, u8 *);
2978 u32 seid_len = va_arg (*args, u32);
2979 u32 is_src_dst = va_arg (*args, u32);
2982 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2984 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2990 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2992 vat_main_t *vam = &vat_main;
2993 u8 *s = 0, *eid = 0;
2995 if (~0 == mp->locator_set_index)
2996 s = format (0, "action: %d", mp->action);
2998 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3000 eid = format (0, "%U", format_lisp_eid_vat,
3004 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3007 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3008 clib_net_to_host_u32 (mp->vni),
3010 mp->is_local ? "local" : "remote",
3011 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3012 clib_net_to_host_u16 (mp->key_id), mp->key);
3019 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3022 vat_main_t *vam = &vat_main;
3023 vat_json_node_t *node = 0;
3026 if (VAT_JSON_ARRAY != vam->json_tree.type)
3028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3029 vat_json_init_array (&vam->json_tree);
3031 node = vat_json_array_add (&vam->json_tree);
3033 vat_json_init_object (node);
3034 if (~0 == mp->locator_set_index)
3035 vat_json_object_add_uint (node, "action", mp->action);
3037 vat_json_object_add_uint (node, "locator_set_index",
3038 clib_net_to_host_u32 (mp->locator_set_index));
3040 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3041 if (mp->eid_type == 3)
3043 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3044 vat_json_init_object (nsh_json);
3045 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3046 vat_json_object_add_uint (nsh_json, "spi",
3047 clib_net_to_host_u32 (nsh->spi));
3048 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3052 eid = format (0, "%U", format_lisp_eid_vat,
3056 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3058 vat_json_object_add_string_copy (node, "eid", eid);
3061 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3062 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3063 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3067 vat_json_object_add_uint (node, "key_id",
3068 clib_net_to_host_u16 (mp->key_id));
3069 vat_json_object_add_string_copy (node, "key", mp->key);
3074 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3076 vat_main_t *vam = &vat_main;
3077 u8 *seid = 0, *deid = 0;
3078 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3080 deid = format (0, "%U", format_lisp_eid_vat,
3081 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3083 seid = format (0, "%U", format_lisp_eid_vat,
3084 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3090 format_ip_address_fcn = format_ip4_address;
3092 format_ip_address_fcn = format_ip6_address;
3095 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3096 clib_net_to_host_u32 (mp->vni),
3098 format_ip_address_fcn, mp->lloc,
3099 format_ip_address_fcn, mp->rloc,
3100 clib_net_to_host_u32 (mp->pkt_count),
3101 clib_net_to_host_u32 (mp->bytes));
3108 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3110 struct in6_addr ip6;
3112 vat_main_t *vam = &vat_main;
3113 vat_json_node_t *node = 0;
3114 u8 *deid = 0, *seid = 0;
3116 if (VAT_JSON_ARRAY != vam->json_tree.type)
3118 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3119 vat_json_init_array (&vam->json_tree);
3121 node = vat_json_array_add (&vam->json_tree);
3123 vat_json_init_object (node);
3124 deid = format (0, "%U", format_lisp_eid_vat,
3125 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3127 seid = format (0, "%U", format_lisp_eid_vat,
3128 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3133 vat_json_object_add_string_copy (node, "seid", seid);
3134 vat_json_object_add_string_copy (node, "deid", deid);
3135 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3139 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3140 vat_json_object_add_ip4 (node, "lloc", ip4);
3141 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3142 vat_json_object_add_ip4 (node, "rloc", ip4);
3146 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3147 vat_json_object_add_ip6 (node, "lloc", ip6);
3148 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3149 vat_json_object_add_ip6 (node, "rloc", ip6);
3151 vat_json_object_add_uint (node, "pkt_count",
3152 clib_net_to_host_u32 (mp->pkt_count));
3153 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3160 vl_api_one_eid_table_map_details_t_handler
3161 (vl_api_one_eid_table_map_details_t * mp)
3163 vat_main_t *vam = &vat_main;
3165 u8 *line = format (0, "%=10d%=10d",
3166 clib_net_to_host_u32 (mp->vni),
3167 clib_net_to_host_u32 (mp->dp_table));
3168 print (vam->ofp, "%v", line);
3173 vl_api_one_eid_table_map_details_t_handler_json
3174 (vl_api_one_eid_table_map_details_t * mp)
3176 vat_main_t *vam = &vat_main;
3177 vat_json_node_t *node = NULL;
3179 if (VAT_JSON_ARRAY != vam->json_tree.type)
3181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3182 vat_json_init_array (&vam->json_tree);
3184 node = vat_json_array_add (&vam->json_tree);
3185 vat_json_init_object (node);
3186 vat_json_object_add_uint (node, "dp_table",
3187 clib_net_to_host_u32 (mp->dp_table));
3188 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3192 vl_api_one_eid_table_vni_details_t_handler
3193 (vl_api_one_eid_table_vni_details_t * mp)
3195 vat_main_t *vam = &vat_main;
3197 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3198 print (vam->ofp, "%v", line);
3203 vl_api_one_eid_table_vni_details_t_handler_json
3204 (vl_api_one_eid_table_vni_details_t * mp)
3206 vat_main_t *vam = &vat_main;
3207 vat_json_node_t *node = NULL;
3209 if (VAT_JSON_ARRAY != vam->json_tree.type)
3211 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3212 vat_json_init_array (&vam->json_tree);
3214 node = vat_json_array_add (&vam->json_tree);
3215 vat_json_init_object (node);
3216 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3220 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3221 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3223 vat_main_t *vam = &vat_main;
3224 int retval = clib_net_to_host_u32 (mp->retval);
3226 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3227 print (vam->ofp, "fallback threshold value: %d", mp->value);
3229 vam->retval = retval;
3230 vam->result_ready = 1;
3234 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3235 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3237 vat_main_t *vam = &vat_main;
3238 vat_json_node_t _node, *node = &_node;
3239 int retval = clib_net_to_host_u32 (mp->retval);
3241 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3242 vat_json_init_object (node);
3243 vat_json_object_add_uint (node, "value", mp->value);
3245 vat_json_print (vam->ofp, node);
3246 vat_json_free (node);
3248 vam->retval = retval;
3249 vam->result_ready = 1;
3253 vl_api_show_one_map_register_state_reply_t_handler
3254 (vl_api_show_one_map_register_state_reply_t * mp)
3256 vat_main_t *vam = &vat_main;
3257 int retval = clib_net_to_host_u32 (mp->retval);
3259 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3261 vam->retval = retval;
3262 vam->result_ready = 1;
3266 vl_api_show_one_map_register_state_reply_t_handler_json
3267 (vl_api_show_one_map_register_state_reply_t * mp)
3269 vat_main_t *vam = &vat_main;
3270 vat_json_node_t _node, *node = &_node;
3271 int retval = clib_net_to_host_u32 (mp->retval);
3273 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3275 vat_json_init_object (node);
3276 vat_json_object_add_string_copy (node, "state", s);
3278 vat_json_print (vam->ofp, node);
3279 vat_json_free (node);
3281 vam->retval = retval;
3282 vam->result_ready = 1;
3287 vl_api_show_one_rloc_probe_state_reply_t_handler
3288 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3290 vat_main_t *vam = &vat_main;
3291 int retval = clib_net_to_host_u32 (mp->retval);
3296 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3298 vam->retval = retval;
3299 vam->result_ready = 1;
3303 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3304 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3306 vat_main_t *vam = &vat_main;
3307 vat_json_node_t _node, *node = &_node;
3308 int retval = clib_net_to_host_u32 (mp->retval);
3310 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3311 vat_json_init_object (node);
3312 vat_json_object_add_string_copy (node, "state", s);
3314 vat_json_print (vam->ofp, node);
3315 vat_json_free (node);
3317 vam->retval = retval;
3318 vam->result_ready = 1;
3323 vl_api_show_one_stats_enable_disable_reply_t_handler
3324 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3326 vat_main_t *vam = &vat_main;
3327 int retval = clib_net_to_host_u32 (mp->retval);
3332 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3334 vam->retval = retval;
3335 vam->result_ready = 1;
3339 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3340 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3342 vat_main_t *vam = &vat_main;
3343 vat_json_node_t _node, *node = &_node;
3344 int retval = clib_net_to_host_u32 (mp->retval);
3346 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3347 vat_json_init_object (node);
3348 vat_json_object_add_string_copy (node, "state", s);
3350 vat_json_print (vam->ofp, node);
3351 vat_json_free (node);
3353 vam->retval = retval;
3354 vam->result_ready = 1;
3359 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3361 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3362 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3363 e->vni = clib_net_to_host_u32 (e->vni);
3367 gpe_fwd_entries_get_reply_t_net_to_host
3368 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3372 mp->count = clib_net_to_host_u32 (mp->count);
3373 for (i = 0; i < mp->count; i++)
3375 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3380 format_gpe_encap_mode (u8 * s, va_list * args)
3382 u32 mode = va_arg (*args, u32);
3387 return format (s, "lisp");
3389 return format (s, "vxlan");
3395 vl_api_gpe_get_encap_mode_reply_t_handler
3396 (vl_api_gpe_get_encap_mode_reply_t * mp)
3398 vat_main_t *vam = &vat_main;
3400 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3401 vam->retval = ntohl (mp->retval);
3402 vam->result_ready = 1;
3406 vl_api_gpe_get_encap_mode_reply_t_handler_json
3407 (vl_api_gpe_get_encap_mode_reply_t * mp)
3409 vat_main_t *vam = &vat_main;
3410 vat_json_node_t node;
3412 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3413 vec_add1 (encap_mode, 0);
3415 vat_json_init_object (&node);
3416 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3418 vec_free (encap_mode);
3419 vat_json_print (vam->ofp, &node);
3420 vat_json_free (&node);
3422 vam->retval = ntohl (mp->retval);
3423 vam->result_ready = 1;
3427 vl_api_gpe_fwd_entry_path_details_t_handler
3428 (vl_api_gpe_fwd_entry_path_details_t * mp)
3430 vat_main_t *vam = &vat_main;
3431 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3433 if (mp->lcl_loc.is_ip4)
3434 format_ip_address_fcn = format_ip4_address;
3436 format_ip_address_fcn = format_ip6_address;
3438 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3439 format_ip_address_fcn, &mp->lcl_loc,
3440 format_ip_address_fcn, &mp->rmt_loc);
3444 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3446 struct in6_addr ip6;
3451 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3452 vat_json_object_add_ip4 (n, "address", ip4);
3456 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3457 vat_json_object_add_ip6 (n, "address", ip6);
3459 vat_json_object_add_uint (n, "weight", loc->weight);
3463 vl_api_gpe_fwd_entry_path_details_t_handler_json
3464 (vl_api_gpe_fwd_entry_path_details_t * mp)
3466 vat_main_t *vam = &vat_main;
3467 vat_json_node_t *node = NULL;
3468 vat_json_node_t *loc_node;
3470 if (VAT_JSON_ARRAY != vam->json_tree.type)
3472 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3473 vat_json_init_array (&vam->json_tree);
3475 node = vat_json_array_add (&vam->json_tree);
3476 vat_json_init_object (node);
3478 loc_node = vat_json_object_add (node, "local_locator");
3479 vat_json_init_object (loc_node);
3480 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3482 loc_node = vat_json_object_add (node, "remote_locator");
3483 vat_json_init_object (loc_node);
3484 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3488 vl_api_gpe_fwd_entries_get_reply_t_handler
3489 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3491 vat_main_t *vam = &vat_main;
3493 int retval = clib_net_to_host_u32 (mp->retval);
3494 vl_api_gpe_fwd_entry_t *e;
3499 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3501 for (i = 0; i < mp->count; i++)
3503 e = &mp->entries[i];
3504 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3505 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3506 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3510 vam->retval = retval;
3511 vam->result_ready = 1;
3515 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3516 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3519 vat_main_t *vam = &vat_main;
3520 vat_json_node_t *e = 0, root;
3522 int retval = clib_net_to_host_u32 (mp->retval);
3523 vl_api_gpe_fwd_entry_t *fwd;
3528 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3529 vat_json_init_array (&root);
3531 for (i = 0; i < mp->count; i++)
3533 e = vat_json_array_add (&root);
3534 fwd = &mp->entries[i];
3536 vat_json_init_object (e);
3537 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3538 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3539 vat_json_object_add_int (e, "vni", fwd->vni);
3540 vat_json_object_add_int (e, "action", fwd->action);
3542 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3543 fwd->leid_prefix_len);
3545 vat_json_object_add_string_copy (e, "leid", s);
3548 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3549 fwd->reid_prefix_len);
3551 vat_json_object_add_string_copy (e, "reid", s);
3555 vat_json_print (vam->ofp, &root);
3556 vat_json_free (&root);
3559 vam->retval = retval;
3560 vam->result_ready = 1;
3564 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3565 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3567 vat_main_t *vam = &vat_main;
3569 int retval = clib_net_to_host_u32 (mp->retval);
3570 vl_api_gpe_native_fwd_rpath_t *r;
3575 n = clib_net_to_host_u32 (mp->count);
3577 for (i = 0; i < n; i++)
3579 r = &mp->entries[i];
3580 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3581 clib_net_to_host_u32 (r->fib_index),
3582 clib_net_to_host_u32 (r->nh_sw_if_index),
3583 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3592 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3593 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3596 vat_json_node_t root, *e;
3598 int retval = clib_net_to_host_u32 (mp->retval);
3599 vl_api_gpe_native_fwd_rpath_t *r;
3605 n = clib_net_to_host_u32 (mp->count);
3606 vat_json_init_array (&root);
3608 for (i = 0; i < n; i++)
3610 e = vat_json_array_add (&root);
3611 vat_json_init_object (e);
3612 r = &mp->entries[i];
3614 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3617 vat_json_object_add_string_copy (e, "ip4", s);
3620 vat_json_object_add_uint (e, "fib_index",
3621 clib_net_to_host_u32 (r->fib_index));
3622 vat_json_object_add_uint (e, "nh_sw_if_index",
3623 clib_net_to_host_u32 (r->nh_sw_if_index));
3626 vat_json_print (vam->ofp, &root);
3627 vat_json_free (&root);
3630 vam->retval = retval;
3631 vam->result_ready = 1;
3635 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3636 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3638 vat_main_t *vam = &vat_main;
3640 int retval = clib_net_to_host_u32 (mp->retval);
3645 n = clib_net_to_host_u32 (mp->count);
3647 for (i = 0; i < n; i++)
3648 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3651 vam->retval = retval;
3652 vam->result_ready = 1;
3656 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3657 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3659 vat_main_t *vam = &vat_main;
3660 vat_json_node_t root;
3662 int retval = clib_net_to_host_u32 (mp->retval);
3667 n = clib_net_to_host_u32 (mp->count);
3668 vat_json_init_array (&root);
3670 for (i = 0; i < n; i++)
3671 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3673 vat_json_print (vam->ofp, &root);
3674 vat_json_free (&root);
3677 vam->retval = retval;
3678 vam->result_ready = 1;
3682 vl_api_one_ndp_entries_get_reply_t_handler
3683 (vl_api_one_ndp_entries_get_reply_t * mp)
3685 vat_main_t *vam = &vat_main;
3687 int retval = clib_net_to_host_u32 (mp->retval);
3692 n = clib_net_to_host_u32 (mp->count);
3694 for (i = 0; i < n; i++)
3695 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3696 format_ethernet_address, mp->entries[i].mac);
3699 vam->retval = retval;
3700 vam->result_ready = 1;
3704 vl_api_one_ndp_entries_get_reply_t_handler_json
3705 (vl_api_one_ndp_entries_get_reply_t * mp)
3708 vat_main_t *vam = &vat_main;
3709 vat_json_node_t *e = 0, root;
3711 int retval = clib_net_to_host_u32 (mp->retval);
3712 vl_api_one_ndp_entry_t *arp_entry;
3717 n = clib_net_to_host_u32 (mp->count);
3718 vat_json_init_array (&root);
3720 for (i = 0; i < n; i++)
3722 e = vat_json_array_add (&root);
3723 arp_entry = &mp->entries[i];
3725 vat_json_init_object (e);
3726 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3729 vat_json_object_add_string_copy (e, "mac", s);
3732 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3734 vat_json_object_add_string_copy (e, "ip6", s);
3738 vat_json_print (vam->ofp, &root);
3739 vat_json_free (&root);
3742 vam->retval = retval;
3743 vam->result_ready = 1;
3747 vl_api_one_l2_arp_entries_get_reply_t_handler
3748 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3750 vat_main_t *vam = &vat_main;
3752 int retval = clib_net_to_host_u32 (mp->retval);
3757 n = clib_net_to_host_u32 (mp->count);
3759 for (i = 0; i < n; i++)
3760 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3761 format_ethernet_address, mp->entries[i].mac);
3764 vam->retval = retval;
3765 vam->result_ready = 1;
3769 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3770 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3773 vat_main_t *vam = &vat_main;
3774 vat_json_node_t *e = 0, root;
3776 int retval = clib_net_to_host_u32 (mp->retval);
3777 vl_api_one_l2_arp_entry_t *arp_entry;
3782 n = clib_net_to_host_u32 (mp->count);
3783 vat_json_init_array (&root);
3785 for (i = 0; i < n; i++)
3787 e = vat_json_array_add (&root);
3788 arp_entry = &mp->entries[i];
3790 vat_json_init_object (e);
3791 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3794 vat_json_object_add_string_copy (e, "mac", s);
3797 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3799 vat_json_object_add_string_copy (e, "ip4", s);
3803 vat_json_print (vam->ofp, &root);
3804 vat_json_free (&root);
3807 vam->retval = retval;
3808 vam->result_ready = 1;
3812 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3814 vat_main_t *vam = &vat_main;
3816 int retval = clib_net_to_host_u32 (mp->retval);
3821 n = clib_net_to_host_u32 (mp->count);
3823 for (i = 0; i < n; i++)
3825 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3829 vam->retval = retval;
3830 vam->result_ready = 1;
3834 vl_api_one_ndp_bd_get_reply_t_handler_json
3835 (vl_api_one_ndp_bd_get_reply_t * mp)
3837 vat_main_t *vam = &vat_main;
3838 vat_json_node_t root;
3840 int retval = clib_net_to_host_u32 (mp->retval);
3845 n = clib_net_to_host_u32 (mp->count);
3846 vat_json_init_array (&root);
3848 for (i = 0; i < n; i++)
3850 vat_json_array_add_uint (&root,
3851 clib_net_to_host_u32 (mp->bridge_domains[i]));
3854 vat_json_print (vam->ofp, &root);
3855 vat_json_free (&root);
3858 vam->retval = retval;
3859 vam->result_ready = 1;
3863 vl_api_one_l2_arp_bd_get_reply_t_handler
3864 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3866 vat_main_t *vam = &vat_main;
3868 int retval = clib_net_to_host_u32 (mp->retval);
3873 n = clib_net_to_host_u32 (mp->count);
3875 for (i = 0; i < n; i++)
3877 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3881 vam->retval = retval;
3882 vam->result_ready = 1;
3886 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3887 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3889 vat_main_t *vam = &vat_main;
3890 vat_json_node_t root;
3892 int retval = clib_net_to_host_u32 (mp->retval);
3897 n = clib_net_to_host_u32 (mp->count);
3898 vat_json_init_array (&root);
3900 for (i = 0; i < n; i++)
3902 vat_json_array_add_uint (&root,
3903 clib_net_to_host_u32 (mp->bridge_domains[i]));
3906 vat_json_print (vam->ofp, &root);
3907 vat_json_free (&root);
3910 vam->retval = retval;
3911 vam->result_ready = 1;
3915 vl_api_one_adjacencies_get_reply_t_handler
3916 (vl_api_one_adjacencies_get_reply_t * mp)
3918 vat_main_t *vam = &vat_main;
3920 int retval = clib_net_to_host_u32 (mp->retval);
3921 vl_api_one_adjacency_t *a;
3926 n = clib_net_to_host_u32 (mp->count);
3928 for (i = 0; i < n; i++)
3930 a = &mp->adjacencies[i];
3931 print (vam->ofp, "%U %40U",
3932 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3933 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3937 vam->retval = retval;
3938 vam->result_ready = 1;
3942 vl_api_one_adjacencies_get_reply_t_handler_json
3943 (vl_api_one_adjacencies_get_reply_t * mp)
3946 vat_main_t *vam = &vat_main;
3947 vat_json_node_t *e = 0, root;
3949 int retval = clib_net_to_host_u32 (mp->retval);
3950 vl_api_one_adjacency_t *a;
3955 n = clib_net_to_host_u32 (mp->count);
3956 vat_json_init_array (&root);
3958 for (i = 0; i < n; i++)
3960 e = vat_json_array_add (&root);
3961 a = &mp->adjacencies[i];
3963 vat_json_init_object (e);
3964 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3965 a->leid_prefix_len);
3967 vat_json_object_add_string_copy (e, "leid", s);
3970 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3971 a->reid_prefix_len);
3973 vat_json_object_add_string_copy (e, "reid", s);
3977 vat_json_print (vam->ofp, &root);
3978 vat_json_free (&root);
3981 vam->retval = retval;
3982 vam->result_ready = 1;
3986 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3988 vat_main_t *vam = &vat_main;
3990 print (vam->ofp, "%=20U",
3991 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3996 vl_api_one_map_server_details_t_handler_json
3997 (vl_api_one_map_server_details_t * mp)
3999 vat_main_t *vam = &vat_main;
4000 vat_json_node_t *node = NULL;
4001 struct in6_addr ip6;
4004 if (VAT_JSON_ARRAY != vam->json_tree.type)
4006 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4007 vat_json_init_array (&vam->json_tree);
4009 node = vat_json_array_add (&vam->json_tree);
4011 vat_json_init_object (node);
4014 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4015 vat_json_object_add_ip6 (node, "map-server", ip6);
4019 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4020 vat_json_object_add_ip4 (node, "map-server", ip4);
4025 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4028 vat_main_t *vam = &vat_main;
4030 print (vam->ofp, "%=20U",
4031 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4036 vl_api_one_map_resolver_details_t_handler_json
4037 (vl_api_one_map_resolver_details_t * mp)
4039 vat_main_t *vam = &vat_main;
4040 vat_json_node_t *node = NULL;
4041 struct in6_addr ip6;
4044 if (VAT_JSON_ARRAY != vam->json_tree.type)
4046 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4047 vat_json_init_array (&vam->json_tree);
4049 node = vat_json_array_add (&vam->json_tree);
4051 vat_json_init_object (node);
4054 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4055 vat_json_object_add_ip6 (node, "map resolver", ip6);
4059 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4060 vat_json_object_add_ip4 (node, "map resolver", ip4);
4065 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4067 vat_main_t *vam = &vat_main;
4068 i32 retval = ntohl (mp->retval);
4072 print (vam->ofp, "feature: %s\ngpe: %s",
4073 mp->feature_status ? "enabled" : "disabled",
4074 mp->gpe_status ? "enabled" : "disabled");
4077 vam->retval = retval;
4078 vam->result_ready = 1;
4082 vl_api_show_one_status_reply_t_handler_json
4083 (vl_api_show_one_status_reply_t * mp)
4085 vat_main_t *vam = &vat_main;
4086 vat_json_node_t node;
4087 u8 *gpe_status = NULL;
4088 u8 *feature_status = NULL;
4090 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4091 feature_status = format (0, "%s",
4092 mp->feature_status ? "enabled" : "disabled");
4093 vec_add1 (gpe_status, 0);
4094 vec_add1 (feature_status, 0);
4096 vat_json_init_object (&node);
4097 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4098 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4100 vec_free (gpe_status);
4101 vec_free (feature_status);
4103 vat_json_print (vam->ofp, &node);
4104 vat_json_free (&node);
4106 vam->retval = ntohl (mp->retval);
4107 vam->result_ready = 1;
4111 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4112 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4114 vat_main_t *vam = &vat_main;
4115 i32 retval = ntohl (mp->retval);
4119 print (vam->ofp, "%=20s", mp->locator_set_name);
4122 vam->retval = retval;
4123 vam->result_ready = 1;
4127 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4128 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4130 vat_main_t *vam = &vat_main;
4131 vat_json_node_t *node = NULL;
4133 if (VAT_JSON_ARRAY != vam->json_tree.type)
4135 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4136 vat_json_init_array (&vam->json_tree);
4138 node = vat_json_array_add (&vam->json_tree);
4140 vat_json_init_object (node);
4141 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4143 vat_json_print (vam->ofp, node);
4144 vat_json_free (node);
4146 vam->retval = ntohl (mp->retval);
4147 vam->result_ready = 1;
4151 format_lisp_map_request_mode (u8 * s, va_list * args)
4153 u32 mode = va_arg (*args, u32);
4158 return format (0, "dst-only");
4160 return format (0, "src-dst");
4166 vl_api_show_one_map_request_mode_reply_t_handler
4167 (vl_api_show_one_map_request_mode_reply_t * mp)
4169 vat_main_t *vam = &vat_main;
4170 i32 retval = ntohl (mp->retval);
4174 u32 mode = mp->mode;
4175 print (vam->ofp, "map_request_mode: %U",
4176 format_lisp_map_request_mode, mode);
4179 vam->retval = retval;
4180 vam->result_ready = 1;
4184 vl_api_show_one_map_request_mode_reply_t_handler_json
4185 (vl_api_show_one_map_request_mode_reply_t * mp)
4187 vat_main_t *vam = &vat_main;
4188 vat_json_node_t node;
4193 s = format (0, "%U", format_lisp_map_request_mode, mode);
4196 vat_json_init_object (&node);
4197 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4198 vat_json_print (vam->ofp, &node);
4199 vat_json_free (&node);
4202 vam->retval = ntohl (mp->retval);
4203 vam->result_ready = 1;
4207 vl_api_one_show_xtr_mode_reply_t_handler
4208 (vl_api_one_show_xtr_mode_reply_t * mp)
4210 vat_main_t *vam = &vat_main;
4211 i32 retval = ntohl (mp->retval);
4215 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4218 vam->retval = retval;
4219 vam->result_ready = 1;
4223 vl_api_one_show_xtr_mode_reply_t_handler_json
4224 (vl_api_one_show_xtr_mode_reply_t * mp)
4226 vat_main_t *vam = &vat_main;
4227 vat_json_node_t node;
4230 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4231 vec_add1 (status, 0);
4233 vat_json_init_object (&node);
4234 vat_json_object_add_string_copy (&node, "status", status);
4238 vat_json_print (vam->ofp, &node);
4239 vat_json_free (&node);
4241 vam->retval = ntohl (mp->retval);
4242 vam->result_ready = 1;
4246 vl_api_one_show_pitr_mode_reply_t_handler
4247 (vl_api_one_show_pitr_mode_reply_t * mp)
4249 vat_main_t *vam = &vat_main;
4250 i32 retval = ntohl (mp->retval);
4254 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4257 vam->retval = retval;
4258 vam->result_ready = 1;
4262 vl_api_one_show_pitr_mode_reply_t_handler_json
4263 (vl_api_one_show_pitr_mode_reply_t * mp)
4265 vat_main_t *vam = &vat_main;
4266 vat_json_node_t node;
4269 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4270 vec_add1 (status, 0);
4272 vat_json_init_object (&node);
4273 vat_json_object_add_string_copy (&node, "status", status);
4277 vat_json_print (vam->ofp, &node);
4278 vat_json_free (&node);
4280 vam->retval = ntohl (mp->retval);
4281 vam->result_ready = 1;
4285 vl_api_one_show_petr_mode_reply_t_handler
4286 (vl_api_one_show_petr_mode_reply_t * mp)
4288 vat_main_t *vam = &vat_main;
4289 i32 retval = ntohl (mp->retval);
4293 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4296 vam->retval = retval;
4297 vam->result_ready = 1;
4301 vl_api_one_show_petr_mode_reply_t_handler_json
4302 (vl_api_one_show_petr_mode_reply_t * mp)
4304 vat_main_t *vam = &vat_main;
4305 vat_json_node_t node;
4308 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4309 vec_add1 (status, 0);
4311 vat_json_init_object (&node);
4312 vat_json_object_add_string_copy (&node, "status", status);
4316 vat_json_print (vam->ofp, &node);
4317 vat_json_free (&node);
4319 vam->retval = ntohl (mp->retval);
4320 vam->result_ready = 1;
4324 vl_api_show_one_use_petr_reply_t_handler
4325 (vl_api_show_one_use_petr_reply_t * mp)
4327 vat_main_t *vam = &vat_main;
4328 i32 retval = ntohl (mp->retval);
4332 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4335 print (vam->ofp, "Proxy-ETR address; %U",
4336 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4341 vam->retval = retval;
4342 vam->result_ready = 1;
4346 vl_api_show_one_use_petr_reply_t_handler_json
4347 (vl_api_show_one_use_petr_reply_t * mp)
4349 vat_main_t *vam = &vat_main;
4350 vat_json_node_t node;
4353 struct in6_addr ip6;
4355 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4356 vec_add1 (status, 0);
4358 vat_json_init_object (&node);
4359 vat_json_object_add_string_copy (&node, "status", status);
4364 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4365 vat_json_object_add_ip6 (&node, "address", ip6);
4369 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4370 vat_json_object_add_ip4 (&node, "address", ip4);
4376 vat_json_print (vam->ofp, &node);
4377 vat_json_free (&node);
4379 vam->retval = ntohl (mp->retval);
4380 vam->result_ready = 1;
4384 vl_api_show_one_nsh_mapping_reply_t_handler
4385 (vl_api_show_one_nsh_mapping_reply_t * mp)
4387 vat_main_t *vam = &vat_main;
4388 i32 retval = ntohl (mp->retval);
4392 print (vam->ofp, "%-20s%-16s",
4393 mp->is_set ? "set" : "not-set",
4394 mp->is_set ? (char *) mp->locator_set_name : "");
4397 vam->retval = retval;
4398 vam->result_ready = 1;
4402 vl_api_show_one_nsh_mapping_reply_t_handler_json
4403 (vl_api_show_one_nsh_mapping_reply_t * mp)
4405 vat_main_t *vam = &vat_main;
4406 vat_json_node_t node;
4409 status = format (0, "%s", mp->is_set ? "yes" : "no");
4410 vec_add1 (status, 0);
4412 vat_json_init_object (&node);
4413 vat_json_object_add_string_copy (&node, "is_set", status);
4416 vat_json_object_add_string_copy (&node, "locator_set",
4417 mp->locator_set_name);
4422 vat_json_print (vam->ofp, &node);
4423 vat_json_free (&node);
4425 vam->retval = ntohl (mp->retval);
4426 vam->result_ready = 1;
4430 vl_api_show_one_map_register_ttl_reply_t_handler
4431 (vl_api_show_one_map_register_ttl_reply_t * mp)
4433 vat_main_t *vam = &vat_main;
4434 i32 retval = ntohl (mp->retval);
4436 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4440 print (vam->ofp, "ttl: %u", mp->ttl);
4443 vam->retval = retval;
4444 vam->result_ready = 1;
4448 vl_api_show_one_map_register_ttl_reply_t_handler_json
4449 (vl_api_show_one_map_register_ttl_reply_t * mp)
4451 vat_main_t *vam = &vat_main;
4452 vat_json_node_t node;
4454 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4455 vat_json_init_object (&node);
4456 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4458 vat_json_print (vam->ofp, &node);
4459 vat_json_free (&node);
4461 vam->retval = ntohl (mp->retval);
4462 vam->result_ready = 1;
4466 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4468 vat_main_t *vam = &vat_main;
4469 i32 retval = ntohl (mp->retval);
4473 print (vam->ofp, "%-20s%-16s",
4474 mp->status ? "enabled" : "disabled",
4475 mp->status ? (char *) mp->locator_set_name : "");
4478 vam->retval = retval;
4479 vam->result_ready = 1;
4483 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4485 vat_main_t *vam = &vat_main;
4486 vat_json_node_t node;
4489 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4490 vec_add1 (status, 0);
4492 vat_json_init_object (&node);
4493 vat_json_object_add_string_copy (&node, "status", status);
4496 vat_json_object_add_string_copy (&node, "locator_set",
4497 mp->locator_set_name);
4502 vat_json_print (vam->ofp, &node);
4503 vat_json_free (&node);
4505 vam->retval = ntohl (mp->retval);
4506 vam->result_ready = 1;
4510 format_policer_type (u8 * s, va_list * va)
4512 u32 i = va_arg (*va, u32);
4514 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4515 s = format (s, "1r2c");
4516 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4517 s = format (s, "1r3c");
4518 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4519 s = format (s, "2r3c-2698");
4520 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4521 s = format (s, "2r3c-4115");
4522 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4523 s = format (s, "2r3c-mef5cf1");
4525 s = format (s, "ILLEGAL");
4530 format_policer_rate_type (u8 * s, va_list * va)
4532 u32 i = va_arg (*va, u32);
4534 if (i == SSE2_QOS_RATE_KBPS)
4535 s = format (s, "kbps");
4536 else if (i == SSE2_QOS_RATE_PPS)
4537 s = format (s, "pps");
4539 s = format (s, "ILLEGAL");
4544 format_policer_round_type (u8 * s, va_list * va)
4546 u32 i = va_arg (*va, u32);
4548 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4549 s = format (s, "closest");
4550 else if (i == SSE2_QOS_ROUND_TO_UP)
4551 s = format (s, "up");
4552 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4553 s = format (s, "down");
4555 s = format (s, "ILLEGAL");
4560 format_policer_action_type (u8 * s, va_list * va)
4562 u32 i = va_arg (*va, u32);
4564 if (i == SSE2_QOS_ACTION_DROP)
4565 s = format (s, "drop");
4566 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4567 s = format (s, "transmit");
4568 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4569 s = format (s, "mark-and-transmit");
4571 s = format (s, "ILLEGAL");
4576 format_dscp (u8 * s, va_list * va)
4578 u32 i = va_arg (*va, u32);
4583 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4587 return format (s, "ILLEGAL");
4589 s = format (s, "%s", t);
4594 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4596 vat_main_t *vam = &vat_main;
4597 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4599 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4600 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4602 conform_dscp_str = format (0, "");
4604 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4605 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4607 exceed_dscp_str = format (0, "");
4609 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4610 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4612 violate_dscp_str = format (0, "");
4614 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4615 "rate type %U, round type %U, %s rate, %s color-aware, "
4616 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4617 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4618 "conform action %U%s, exceed action %U%s, violate action %U%s",
4620 format_policer_type, mp->type,
4623 clib_net_to_host_u64 (mp->cb),
4624 clib_net_to_host_u64 (mp->eb),
4625 format_policer_rate_type, mp->rate_type,
4626 format_policer_round_type, mp->round_type,
4627 mp->single_rate ? "single" : "dual",
4628 mp->color_aware ? "is" : "not",
4629 ntohl (mp->cir_tokens_per_period),
4630 ntohl (mp->pir_tokens_per_period),
4632 ntohl (mp->current_limit),
4633 ntohl (mp->current_bucket),
4634 ntohl (mp->extended_limit),
4635 ntohl (mp->extended_bucket),
4636 clib_net_to_host_u64 (mp->last_update_time),
4637 format_policer_action_type, mp->conform_action_type,
4639 format_policer_action_type, mp->exceed_action_type,
4641 format_policer_action_type, mp->violate_action_type,
4644 vec_free (conform_dscp_str);
4645 vec_free (exceed_dscp_str);
4646 vec_free (violate_dscp_str);
4649 static void vl_api_policer_details_t_handler_json
4650 (vl_api_policer_details_t * mp)
4652 vat_main_t *vam = &vat_main;
4653 vat_json_node_t *node;
4654 u8 *rate_type_str, *round_type_str, *type_str;
4655 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4657 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4659 format (0, "%U", format_policer_round_type, mp->round_type);
4660 type_str = format (0, "%U", format_policer_type, mp->type);
4661 conform_action_str = format (0, "%U", format_policer_action_type,
4662 mp->conform_action_type);
4663 exceed_action_str = format (0, "%U", format_policer_action_type,
4664 mp->exceed_action_type);
4665 violate_action_str = format (0, "%U", format_policer_action_type,
4666 mp->violate_action_type);
4668 if (VAT_JSON_ARRAY != vam->json_tree.type)
4670 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4671 vat_json_init_array (&vam->json_tree);
4673 node = vat_json_array_add (&vam->json_tree);
4675 vat_json_init_object (node);
4676 vat_json_object_add_string_copy (node, "name", mp->name);
4677 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4678 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4679 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4680 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4681 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4682 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4683 vat_json_object_add_string_copy (node, "type", type_str);
4684 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4685 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4686 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4687 vat_json_object_add_uint (node, "cir_tokens_per_period",
4688 ntohl (mp->cir_tokens_per_period));
4689 vat_json_object_add_uint (node, "eir_tokens_per_period",
4690 ntohl (mp->pir_tokens_per_period));
4691 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4692 vat_json_object_add_uint (node, "current_bucket",
4693 ntohl (mp->current_bucket));
4694 vat_json_object_add_uint (node, "extended_limit",
4695 ntohl (mp->extended_limit));
4696 vat_json_object_add_uint (node, "extended_bucket",
4697 ntohl (mp->extended_bucket));
4698 vat_json_object_add_uint (node, "last_update_time",
4699 ntohl (mp->last_update_time));
4700 vat_json_object_add_string_copy (node, "conform_action",
4701 conform_action_str);
4702 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4704 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4705 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4706 vec_free (dscp_str);
4708 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4709 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4711 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4712 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4713 vec_free (dscp_str);
4715 vat_json_object_add_string_copy (node, "violate_action",
4716 violate_action_str);
4717 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4719 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4720 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4721 vec_free (dscp_str);
4724 vec_free (rate_type_str);
4725 vec_free (round_type_str);
4726 vec_free (type_str);
4727 vec_free (conform_action_str);
4728 vec_free (exceed_action_str);
4729 vec_free (violate_action_str);
4733 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4736 vat_main_t *vam = &vat_main;
4737 int i, count = ntohl (mp->count);
4740 print (vam->ofp, "classify table ids (%d) : ", count);
4741 for (i = 0; i < count; i++)
4743 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4744 print (vam->ofp, (i < count - 1) ? "," : "");
4746 vam->retval = ntohl (mp->retval);
4747 vam->result_ready = 1;
4751 vl_api_classify_table_ids_reply_t_handler_json
4752 (vl_api_classify_table_ids_reply_t * mp)
4754 vat_main_t *vam = &vat_main;
4755 int i, count = ntohl (mp->count);
4759 vat_json_node_t node;
4761 vat_json_init_object (&node);
4762 for (i = 0; i < count; i++)
4764 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4766 vat_json_print (vam->ofp, &node);
4767 vat_json_free (&node);
4769 vam->retval = ntohl (mp->retval);
4770 vam->result_ready = 1;
4774 vl_api_classify_table_by_interface_reply_t_handler
4775 (vl_api_classify_table_by_interface_reply_t * mp)
4777 vat_main_t *vam = &vat_main;
4780 table_id = ntohl (mp->l2_table_id);
4782 print (vam->ofp, "l2 table id : %d", table_id);
4784 print (vam->ofp, "l2 table id : No input ACL tables configured");
4785 table_id = ntohl (mp->ip4_table_id);
4787 print (vam->ofp, "ip4 table id : %d", table_id);
4789 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4790 table_id = ntohl (mp->ip6_table_id);
4792 print (vam->ofp, "ip6 table id : %d", table_id);
4794 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4795 vam->retval = ntohl (mp->retval);
4796 vam->result_ready = 1;
4800 vl_api_classify_table_by_interface_reply_t_handler_json
4801 (vl_api_classify_table_by_interface_reply_t * mp)
4803 vat_main_t *vam = &vat_main;
4804 vat_json_node_t node;
4806 vat_json_init_object (&node);
4808 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4809 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4810 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4812 vat_json_print (vam->ofp, &node);
4813 vat_json_free (&node);
4815 vam->retval = ntohl (mp->retval);
4816 vam->result_ready = 1;
4819 static void vl_api_policer_add_del_reply_t_handler
4820 (vl_api_policer_add_del_reply_t * mp)
4822 vat_main_t *vam = &vat_main;
4823 i32 retval = ntohl (mp->retval);
4824 if (vam->async_mode)
4826 vam->async_errors += (retval < 0);
4830 vam->retval = retval;
4831 vam->result_ready = 1;
4832 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4834 * Note: this is just barely thread-safe, depends on
4835 * the main thread spinning waiting for an answer...
4837 errmsg ("policer index %d", ntohl (mp->policer_index));
4841 static void vl_api_policer_add_del_reply_t_handler_json
4842 (vl_api_policer_add_del_reply_t * mp)
4844 vat_main_t *vam = &vat_main;
4845 vat_json_node_t node;
4847 vat_json_init_object (&node);
4848 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4849 vat_json_object_add_uint (&node, "policer_index",
4850 ntohl (mp->policer_index));
4852 vat_json_print (vam->ofp, &node);
4853 vat_json_free (&node);
4855 vam->retval = ntohl (mp->retval);
4856 vam->result_ready = 1;
4859 /* Format hex dump. */
4861 format_hex_bytes (u8 * s, va_list * va)
4863 u8 *bytes = va_arg (*va, u8 *);
4864 int n_bytes = va_arg (*va, int);
4867 /* Print short or long form depending on byte count. */
4868 uword short_form = n_bytes <= 32;
4869 u32 indent = format_get_indent (s);
4874 for (i = 0; i < n_bytes; i++)
4876 if (!short_form && (i % 32) == 0)
4877 s = format (s, "%08x: ", i);
4878 s = format (s, "%02x", bytes[i]);
4879 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4880 s = format (s, "\n%U", format_white_space, indent);
4887 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4890 vat_main_t *vam = &vat_main;
4891 i32 retval = ntohl (mp->retval);
4894 print (vam->ofp, "classify table info :");
4895 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4896 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4897 ntohl (mp->miss_next_index));
4898 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4899 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4900 ntohl (mp->match_n_vectors));
4901 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4902 ntohl (mp->mask_length));
4904 vam->retval = retval;
4905 vam->result_ready = 1;
4909 vl_api_classify_table_info_reply_t_handler_json
4910 (vl_api_classify_table_info_reply_t * mp)
4912 vat_main_t *vam = &vat_main;
4913 vat_json_node_t node;
4915 i32 retval = ntohl (mp->retval);
4918 vat_json_init_object (&node);
4920 vat_json_object_add_int (&node, "sessions",
4921 ntohl (mp->active_sessions));
4922 vat_json_object_add_int (&node, "nexttbl",
4923 ntohl (mp->next_table_index));
4924 vat_json_object_add_int (&node, "nextnode",
4925 ntohl (mp->miss_next_index));
4926 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4927 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4928 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4929 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4930 ntohl (mp->mask_length), 0);
4931 vat_json_object_add_string_copy (&node, "mask", s);
4933 vat_json_print (vam->ofp, &node);
4934 vat_json_free (&node);
4936 vam->retval = ntohl (mp->retval);
4937 vam->result_ready = 1;
4941 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4944 vat_main_t *vam = &vat_main;
4946 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4947 ntohl (mp->hit_next_index), ntohl (mp->advance),
4948 ntohl (mp->opaque_index));
4949 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4950 ntohl (mp->match_length));
4954 vl_api_classify_session_details_t_handler_json
4955 (vl_api_classify_session_details_t * mp)
4957 vat_main_t *vam = &vat_main;
4958 vat_json_node_t *node = NULL;
4960 if (VAT_JSON_ARRAY != vam->json_tree.type)
4962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4963 vat_json_init_array (&vam->json_tree);
4965 node = vat_json_array_add (&vam->json_tree);
4967 vat_json_init_object (node);
4968 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4969 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4970 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4972 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4974 vat_json_object_add_string_copy (node, "match", s);
4977 static void vl_api_pg_create_interface_reply_t_handler
4978 (vl_api_pg_create_interface_reply_t * mp)
4980 vat_main_t *vam = &vat_main;
4982 vam->retval = ntohl (mp->retval);
4983 vam->result_ready = 1;
4986 static void vl_api_pg_create_interface_reply_t_handler_json
4987 (vl_api_pg_create_interface_reply_t * mp)
4989 vat_main_t *vam = &vat_main;
4990 vat_json_node_t node;
4992 i32 retval = ntohl (mp->retval);
4995 vat_json_init_object (&node);
4997 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4999 vat_json_print (vam->ofp, &node);
5000 vat_json_free (&node);
5002 vam->retval = ntohl (mp->retval);
5003 vam->result_ready = 1;
5006 static void vl_api_policer_classify_details_t_handler
5007 (vl_api_policer_classify_details_t * mp)
5009 vat_main_t *vam = &vat_main;
5011 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5012 ntohl (mp->table_index));
5015 static void vl_api_policer_classify_details_t_handler_json
5016 (vl_api_policer_classify_details_t * mp)
5018 vat_main_t *vam = &vat_main;
5019 vat_json_node_t *node;
5021 if (VAT_JSON_ARRAY != vam->json_tree.type)
5023 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5024 vat_json_init_array (&vam->json_tree);
5026 node = vat_json_array_add (&vam->json_tree);
5028 vat_json_init_object (node);
5029 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5030 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5033 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5034 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5036 vat_main_t *vam = &vat_main;
5037 i32 retval = ntohl (mp->retval);
5038 if (vam->async_mode)
5040 vam->async_errors += (retval < 0);
5044 vam->retval = retval;
5045 vam->sw_if_index = ntohl (mp->sw_if_index);
5046 vam->result_ready = 1;
5048 vam->regenerate_interface_table = 1;
5051 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5052 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5054 vat_main_t *vam = &vat_main;
5055 vat_json_node_t node;
5057 vat_json_init_object (&node);
5058 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5059 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5061 vat_json_print (vam->ofp, &node);
5062 vat_json_free (&node);
5064 vam->retval = ntohl (mp->retval);
5065 vam->result_ready = 1;
5068 static void vl_api_flow_classify_details_t_handler
5069 (vl_api_flow_classify_details_t * mp)
5071 vat_main_t *vam = &vat_main;
5073 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5074 ntohl (mp->table_index));
5077 static void vl_api_flow_classify_details_t_handler_json
5078 (vl_api_flow_classify_details_t * mp)
5080 vat_main_t *vam = &vat_main;
5081 vat_json_node_t *node;
5083 if (VAT_JSON_ARRAY != vam->json_tree.type)
5085 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5086 vat_json_init_array (&vam->json_tree);
5088 node = vat_json_array_add (&vam->json_tree);
5090 vat_json_init_object (node);
5091 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5092 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5095 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5096 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5097 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5098 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5099 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5100 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5101 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5102 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5103 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5104 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5107 * Generate boilerplate reply handlers, which
5108 * dig the return value out of the xxx_reply_t API message,
5109 * stick it into vam->retval, and set vam->result_ready
5111 * Could also do this by pointing N message decode slots at
5112 * a single function, but that could break in subtle ways.
5115 #define foreach_standard_reply_retval_handler \
5116 _(sw_interface_set_flags_reply) \
5117 _(sw_interface_add_del_address_reply) \
5118 _(sw_interface_set_rx_mode_reply) \
5119 _(sw_interface_set_rx_placement_reply) \
5120 _(sw_interface_set_table_reply) \
5121 _(sw_interface_set_mpls_enable_reply) \
5122 _(sw_interface_set_vpath_reply) \
5123 _(sw_interface_set_vxlan_bypass_reply) \
5124 _(sw_interface_set_geneve_bypass_reply) \
5125 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5126 _(sw_interface_set_l2_bridge_reply) \
5127 _(bridge_domain_add_del_reply) \
5128 _(sw_interface_set_l2_xconnect_reply) \
5129 _(l2fib_add_del_reply) \
5130 _(l2fib_flush_int_reply) \
5131 _(l2fib_flush_bd_reply) \
5132 _(ip_add_del_route_reply) \
5133 _(ip_table_add_del_reply) \
5134 _(ip_mroute_add_del_reply) \
5135 _(mpls_route_add_del_reply) \
5136 _(mpls_table_add_del_reply) \
5137 _(mpls_ip_bind_unbind_reply) \
5138 _(bier_route_add_del_reply) \
5139 _(bier_table_add_del_reply) \
5140 _(proxy_arp_add_del_reply) \
5141 _(proxy_arp_intfc_enable_disable_reply) \
5142 _(sw_interface_set_unnumbered_reply) \
5143 _(ip_neighbor_add_del_reply) \
5144 _(oam_add_del_reply) \
5145 _(reset_fib_reply) \
5146 _(dhcp_proxy_config_reply) \
5147 _(dhcp_proxy_set_vss_reply) \
5148 _(dhcp_client_config_reply) \
5149 _(set_ip_flow_hash_reply) \
5150 _(sw_interface_ip6_enable_disable_reply) \
5151 _(ip6nd_proxy_add_del_reply) \
5152 _(sw_interface_ip6nd_ra_prefix_reply) \
5153 _(sw_interface_ip6nd_ra_config_reply) \
5154 _(set_arp_neighbor_limit_reply) \
5155 _(l2_patch_add_del_reply) \
5156 _(sr_mpls_policy_add_reply) \
5157 _(sr_mpls_policy_mod_reply) \
5158 _(sr_mpls_policy_del_reply) \
5159 _(sr_policy_add_reply) \
5160 _(sr_policy_mod_reply) \
5161 _(sr_policy_del_reply) \
5162 _(sr_localsid_add_del_reply) \
5163 _(sr_steering_add_del_reply) \
5164 _(classify_add_del_session_reply) \
5165 _(classify_set_interface_ip_table_reply) \
5166 _(classify_set_interface_l2_tables_reply) \
5167 _(l2tpv3_set_tunnel_cookies_reply) \
5168 _(l2tpv3_interface_enable_disable_reply) \
5169 _(l2tpv3_set_lookup_key_reply) \
5170 _(l2_fib_clear_table_reply) \
5171 _(l2_interface_efp_filter_reply) \
5172 _(l2_interface_vlan_tag_rewrite_reply) \
5173 _(modify_vhost_user_if_reply) \
5174 _(delete_vhost_user_if_reply) \
5175 _(ip_probe_neighbor_reply) \
5176 _(ip_scan_neighbor_enable_disable_reply) \
5177 _(want_ip4_arp_events_reply) \
5178 _(want_ip6_nd_events_reply) \
5179 _(want_l2_macs_events_reply) \
5180 _(input_acl_set_interface_reply) \
5181 _(ipsec_spd_add_del_reply) \
5182 _(ipsec_interface_add_del_spd_reply) \
5183 _(ipsec_spd_entry_add_del_reply) \
5184 _(ipsec_sad_entry_add_del_reply) \
5185 _(ipsec_sa_set_key_reply) \
5186 _(ipsec_tunnel_if_add_del_reply) \
5187 _(ipsec_tunnel_if_set_key_reply) \
5188 _(ipsec_tunnel_if_set_sa_reply) \
5189 _(delete_loopback_reply) \
5190 _(bd_ip_mac_add_del_reply) \
5191 _(bd_ip_mac_flush_reply) \
5192 _(want_interface_events_reply) \
5193 _(cop_interface_enable_disable_reply) \
5194 _(cop_whitelist_enable_disable_reply) \
5195 _(sw_interface_clear_stats_reply) \
5196 _(ioam_enable_reply) \
5197 _(ioam_disable_reply) \
5198 _(one_add_del_locator_reply) \
5199 _(one_add_del_local_eid_reply) \
5200 _(one_add_del_remote_mapping_reply) \
5201 _(one_add_del_adjacency_reply) \
5202 _(one_add_del_map_resolver_reply) \
5203 _(one_add_del_map_server_reply) \
5204 _(one_enable_disable_reply) \
5205 _(one_rloc_probe_enable_disable_reply) \
5206 _(one_map_register_enable_disable_reply) \
5207 _(one_map_register_set_ttl_reply) \
5208 _(one_set_transport_protocol_reply) \
5209 _(one_map_register_fallback_threshold_reply) \
5210 _(one_pitr_set_locator_set_reply) \
5211 _(one_map_request_mode_reply) \
5212 _(one_add_del_map_request_itr_rlocs_reply) \
5213 _(one_eid_table_add_del_map_reply) \
5214 _(one_use_petr_reply) \
5215 _(one_stats_enable_disable_reply) \
5216 _(one_add_del_l2_arp_entry_reply) \
5217 _(one_add_del_ndp_entry_reply) \
5218 _(one_stats_flush_reply) \
5219 _(one_enable_disable_xtr_mode_reply) \
5220 _(one_enable_disable_pitr_mode_reply) \
5221 _(one_enable_disable_petr_mode_reply) \
5222 _(gpe_enable_disable_reply) \
5223 _(gpe_set_encap_mode_reply) \
5224 _(gpe_add_del_iface_reply) \
5225 _(gpe_add_del_native_fwd_rpath_reply) \
5226 _(af_packet_delete_reply) \
5227 _(policer_classify_set_interface_reply) \
5228 _(netmap_create_reply) \
5229 _(netmap_delete_reply) \
5230 _(set_ipfix_exporter_reply) \
5231 _(set_ipfix_classify_stream_reply) \
5232 _(ipfix_classify_table_add_del_reply) \
5233 _(flow_classify_set_interface_reply) \
5234 _(sw_interface_span_enable_disable_reply) \
5235 _(pg_capture_reply) \
5236 _(pg_enable_disable_reply) \
5237 _(ip_source_and_port_range_check_add_del_reply) \
5238 _(ip_source_and_port_range_check_interface_add_del_reply)\
5239 _(delete_subif_reply) \
5240 _(l2_interface_pbb_tag_rewrite_reply) \
5242 _(feature_enable_disable_reply) \
5243 _(sw_interface_tag_add_del_reply) \
5244 _(hw_interface_set_mtu_reply) \
5245 _(p2p_ethernet_add_reply) \
5246 _(p2p_ethernet_del_reply) \
5247 _(lldp_config_reply) \
5248 _(sw_interface_set_lldp_reply) \
5249 _(tcp_configure_src_addresses_reply) \
5250 _(dns_enable_disable_reply) \
5251 _(dns_name_server_add_del_reply) \
5252 _(session_rule_add_del_reply) \
5253 _(ip_container_proxy_add_del_reply) \
5254 _(output_acl_set_interface_reply) \
5255 _(qos_record_enable_disable_reply)
5258 static void vl_api_##n##_t_handler \
5259 (vl_api_##n##_t * mp) \
5261 vat_main_t * vam = &vat_main; \
5262 i32 retval = ntohl(mp->retval); \
5263 if (vam->async_mode) { \
5264 vam->async_errors += (retval < 0); \
5266 vam->retval = retval; \
5267 vam->result_ready = 1; \
5270 foreach_standard_reply_retval_handler;
5274 static void vl_api_##n##_t_handler_json \
5275 (vl_api_##n##_t * mp) \
5277 vat_main_t * vam = &vat_main; \
5278 vat_json_node_t node; \
5279 vat_json_init_object(&node); \
5280 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5281 vat_json_print(vam->ofp, &node); \
5282 vam->retval = ntohl(mp->retval); \
5283 vam->result_ready = 1; \
5285 foreach_standard_reply_retval_handler;
5289 * Table of message reply handlers, must include boilerplate handlers
5293 #define foreach_vpe_api_reply_msg \
5294 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5295 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5296 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5297 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5298 _(CONTROL_PING_REPLY, control_ping_reply) \
5299 _(CLI_REPLY, cli_reply) \
5300 _(CLI_INBAND_REPLY, cli_inband_reply) \
5301 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5302 sw_interface_add_del_address_reply) \
5303 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5304 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5305 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5306 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5307 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5308 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5309 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5310 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5311 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5312 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5313 sw_interface_set_l2_xconnect_reply) \
5314 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5315 sw_interface_set_l2_bridge_reply) \
5316 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5317 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5318 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5319 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5320 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5321 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5322 _(L2_FLAGS_REPLY, l2_flags_reply) \
5323 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5324 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5325 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5326 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5327 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5328 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5329 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5330 _(BOND_CREATE_REPLY, bond_create_reply) \
5331 _(BOND_DELETE_REPLY, bond_delete_reply) \
5332 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5333 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5334 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5335 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5336 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5337 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5338 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5339 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5340 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5341 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5342 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5343 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5344 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5345 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5346 proxy_arp_intfc_enable_disable_reply) \
5347 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5348 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5349 sw_interface_set_unnumbered_reply) \
5350 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5351 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5352 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5353 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5354 _(RESET_FIB_REPLY, reset_fib_reply) \
5355 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5356 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5357 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5358 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5359 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5360 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5361 sw_interface_ip6_enable_disable_reply) \
5362 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5363 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5364 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5365 sw_interface_ip6nd_ra_prefix_reply) \
5366 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5367 sw_interface_ip6nd_ra_config_reply) \
5368 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5369 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5370 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5371 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5372 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5373 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5374 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5375 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5376 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5377 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5378 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5379 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5380 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5381 classify_set_interface_ip_table_reply) \
5382 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5383 classify_set_interface_l2_tables_reply) \
5384 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5385 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5386 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5387 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5388 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5389 l2tpv3_interface_enable_disable_reply) \
5390 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5391 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5392 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5393 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5394 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5395 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5396 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5397 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5398 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5399 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5400 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5401 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5402 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5403 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5404 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5405 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5406 _(SHOW_VERSION_REPLY, show_version_reply) \
5407 _(SHOW_THREADS_REPLY, show_threads_reply) \
5408 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5409 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5410 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5411 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5412 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5413 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5414 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5415 _(IP4_ARP_EVENT, ip4_arp_event) \
5416 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5417 _(IP6_ND_EVENT, ip6_nd_event) \
5418 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5419 _(L2_MACS_EVENT, l2_macs_event) \
5420 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5421 _(IP_ADDRESS_DETAILS, ip_address_details) \
5422 _(IP_DETAILS, ip_details) \
5423 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5424 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5425 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5426 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5427 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5428 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5429 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5430 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5431 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5432 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5433 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5434 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5435 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5436 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5437 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5438 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5439 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5440 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5441 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5442 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5443 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5444 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5445 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5446 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5447 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5448 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5449 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5450 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5451 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5452 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5453 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5454 one_map_register_enable_disable_reply) \
5455 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5456 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5457 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5458 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5459 one_map_register_fallback_threshold_reply) \
5460 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5461 one_rloc_probe_enable_disable_reply) \
5462 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5463 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5464 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5465 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5466 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5467 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5468 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5469 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5470 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5471 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5472 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5473 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5474 _(ONE_STATS_DETAILS, one_stats_details) \
5475 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5476 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5477 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5478 show_one_stats_enable_disable_reply) \
5479 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5480 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5481 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5482 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5483 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5484 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5485 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5486 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5487 one_enable_disable_pitr_mode_reply) \
5488 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5489 one_enable_disable_petr_mode_reply) \
5490 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5491 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5492 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5493 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5494 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5495 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5496 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5497 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5498 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5499 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5500 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5501 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5502 gpe_add_del_native_fwd_rpath_reply) \
5503 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5504 gpe_fwd_entry_path_details) \
5505 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5506 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5507 one_add_del_map_request_itr_rlocs_reply) \
5508 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5509 one_get_map_request_itr_rlocs_reply) \
5510 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5511 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5512 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5513 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5514 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5515 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5516 show_one_map_register_state_reply) \
5517 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5518 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5519 show_one_map_register_fallback_threshold_reply) \
5520 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5521 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5522 _(AF_PACKET_DETAILS, af_packet_details) \
5523 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5524 _(POLICER_DETAILS, policer_details) \
5525 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5526 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5527 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5528 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5529 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5530 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5531 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5532 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5533 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5534 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5535 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5536 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5537 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5538 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5539 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5540 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5541 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5542 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5543 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5544 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5545 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5546 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5547 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5548 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5549 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5550 ip_source_and_port_range_check_add_del_reply) \
5551 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5552 ip_source_and_port_range_check_interface_add_del_reply) \
5553 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5554 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5555 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5556 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5557 _(SET_PUNT_REPLY, set_punt_reply) \
5558 _(IP_FIB_DETAILS, ip_fib_details) \
5559 _(IP6_FIB_DETAILS, ip6_fib_details) \
5560 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5561 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5562 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5563 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5564 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5565 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5566 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5567 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5568 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5569 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5570 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5571 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5572 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5573 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5574 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5575 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5576 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5577 _(SESSION_RULES_DETAILS, session_rules_details) \
5578 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5579 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5580 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5582 #define foreach_standalone_reply_msg \
5583 _(SW_INTERFACE_EVENT, sw_interface_event)
5591 #define STR_VTR_OP_CASE(op) \
5592 case L2_VTR_ ## op: \
5596 str_vtr_op (u32 vtr_op)
5600 STR_VTR_OP_CASE (DISABLED);
5601 STR_VTR_OP_CASE (PUSH_1);
5602 STR_VTR_OP_CASE (PUSH_2);
5603 STR_VTR_OP_CASE (POP_1);
5604 STR_VTR_OP_CASE (POP_2);
5605 STR_VTR_OP_CASE (TRANSLATE_1_1);
5606 STR_VTR_OP_CASE (TRANSLATE_1_2);
5607 STR_VTR_OP_CASE (TRANSLATE_2_1);
5608 STR_VTR_OP_CASE (TRANSLATE_2_2);
5615 dump_sub_interface_table (vat_main_t * vam)
5617 const sw_interface_subif_t *sub = NULL;
5619 if (vam->json_output)
5622 ("JSON output supported only for VPE API calls and dump_stats_table");
5627 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5628 "Interface", "sw_if_index",
5629 "sub id", "dot1ad", "tags", "outer id",
5630 "inner id", "exact", "default", "outer any", "inner any");
5632 vec_foreach (sub, vam->sw_if_subif_table)
5635 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5636 sub->interface_name,
5638 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5639 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5640 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5641 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5642 if (sub->vtr_op != L2_VTR_DISABLED)
5645 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5646 "tag1: %d tag2: %d ]",
5647 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5648 sub->vtr_tag1, sub->vtr_tag2);
5656 name_sort_cmp (void *a1, void *a2)
5658 name_sort_t *n1 = a1;
5659 name_sort_t *n2 = a2;
5661 return strcmp ((char *) n1->name, (char *) n2->name);
5665 dump_interface_table (vat_main_t * vam)
5668 name_sort_t *nses = 0, *ns;
5670 if (vam->json_output)
5673 ("JSON output supported only for VPE API calls and dump_stats_table");
5678 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5680 vec_add2 (nses, ns, 1);
5681 ns->name = (u8 *)(p->key);
5682 ns->value = (u32) p->value[0];
5686 vec_sort_with_function (nses, name_sort_cmp);
5688 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5689 vec_foreach (ns, nses)
5691 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5698 dump_ip_table (vat_main_t * vam, int is_ipv6)
5700 const ip_details_t *det = NULL;
5701 const ip_address_details_t *address = NULL;
5704 print (vam->ofp, "%-12s", "sw_if_index");
5706 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5713 print (vam->ofp, "%-12d", i);
5714 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5719 vec_foreach (address, det->addr)
5723 is_ipv6 ? format_ip6_address : format_ip4_address,
5724 address->ip, address->prefix_length);
5732 dump_ipv4_table (vat_main_t * vam)
5734 if (vam->json_output)
5737 ("JSON output supported only for VPE API calls and dump_stats_table");
5741 return dump_ip_table (vam, 0);
5745 dump_ipv6_table (vat_main_t * vam)
5747 if (vam->json_output)
5750 ("JSON output supported only for VPE API calls and dump_stats_table");
5754 return dump_ip_table (vam, 1);
5758 * Pass CLI buffers directly in the CLI_INBAND API message,
5759 * instead of an additional shared memory area.
5762 exec_inband (vat_main_t * vam)
5764 vl_api_cli_inband_t *mp;
5765 unformat_input_t *i = vam->input;
5768 if (vec_len (i->buffer) == 0)
5771 if (vam->exec_mode == 0 && unformat (i, "mode"))
5776 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5783 * In order for the CLI command to work, it
5784 * must be a vector ending in \n, not a C-string ending
5787 u32 len = vec_len (vam->input->buffer);
5788 M2 (CLI_INBAND, mp, len);
5789 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5793 /* json responses may or may not include a useful reply... */
5794 if (vec_len (vam->cmd_reply))
5795 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5800 exec (vat_main_t * vam)
5802 return exec_inband (vam);
5806 api_create_loopback (vat_main_t * vam)
5808 unformat_input_t *i = vam->input;
5809 vl_api_create_loopback_t *mp;
5810 vl_api_create_loopback_instance_t *mp_lbi;
5813 u8 is_specified = 0;
5814 u32 user_instance = 0;
5817 clib_memset (mac_address, 0, sizeof (mac_address));
5819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5821 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5823 if (unformat (i, "instance %d", &user_instance))
5831 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5832 mp_lbi->is_specified = is_specified;
5834 mp_lbi->user_instance = htonl (user_instance);
5836 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5841 /* Construct the API message */
5842 M (CREATE_LOOPBACK, mp);
5844 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5853 api_delete_loopback (vat_main_t * vam)
5855 unformat_input_t *i = vam->input;
5856 vl_api_delete_loopback_t *mp;
5857 u32 sw_if_index = ~0;
5860 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5862 if (unformat (i, "sw_if_index %d", &sw_if_index))
5868 if (sw_if_index == ~0)
5870 errmsg ("missing sw_if_index");
5874 /* Construct the API message */
5875 M (DELETE_LOOPBACK, mp);
5876 mp->sw_if_index = ntohl (sw_if_index);
5884 api_want_interface_events (vat_main_t * vam)
5886 unformat_input_t *i = vam->input;
5887 vl_api_want_interface_events_t *mp;
5891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5893 if (unformat (i, "enable"))
5895 else if (unformat (i, "disable"))
5903 errmsg ("missing enable|disable");
5907 M (WANT_INTERFACE_EVENTS, mp);
5908 mp->enable_disable = enable;
5910 vam->interface_event_display = enable;
5918 /* Note: non-static, called once to set up the initial intfc table */
5920 api_sw_interface_dump (vat_main_t * vam)
5922 vl_api_sw_interface_dump_t *mp;
5923 vl_api_control_ping_t *mp_ping;
5925 name_sort_t *nses = 0, *ns;
5926 sw_interface_subif_t *sub = NULL;
5929 /* Toss the old name table */
5931 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5933 vec_add2 (nses, ns, 1);
5934 ns->name = (u8 *)(p->key);
5935 ns->value = (u32) p->value[0];
5939 hash_free (vam->sw_if_index_by_interface_name);
5941 vec_foreach (ns, nses) vec_free (ns->name);
5945 vec_foreach (sub, vam->sw_if_subif_table)
5947 vec_free (sub->interface_name);
5949 vec_free (vam->sw_if_subif_table);
5951 /* recreate the interface name hash table */
5952 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5955 * Ask for all interface names. Otherwise, the epic catalog of
5956 * name filters becomes ridiculously long, and vat ends up needing
5957 * to be taught about new interface types.
5959 M (SW_INTERFACE_DUMP, mp);
5962 /* Use a control ping for synchronization */
5963 MPING (CONTROL_PING, mp_ping);
5971 api_sw_interface_set_flags (vat_main_t * vam)
5973 unformat_input_t *i = vam->input;
5974 vl_api_sw_interface_set_flags_t *mp;
5976 u8 sw_if_index_set = 0;
5980 /* Parse args required to build the message */
5981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5983 if (unformat (i, "admin-up"))
5985 else if (unformat (i, "admin-down"))
5988 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5989 sw_if_index_set = 1;
5990 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5991 sw_if_index_set = 1;
5996 if (sw_if_index_set == 0)
5998 errmsg ("missing interface name or sw_if_index");
6002 /* Construct the API message */
6003 M (SW_INTERFACE_SET_FLAGS, mp);
6004 mp->sw_if_index = ntohl (sw_if_index);
6005 mp->admin_up_down = admin_up;
6010 /* Wait for a reply, return the good/bad news... */
6016 api_sw_interface_set_rx_mode (vat_main_t * vam)
6018 unformat_input_t *i = vam->input;
6019 vl_api_sw_interface_set_rx_mode_t *mp;
6021 u8 sw_if_index_set = 0;
6023 u8 queue_id_valid = 0;
6025 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6027 /* Parse args required to build the message */
6028 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6030 if (unformat (i, "queue %d", &queue_id))
6032 else if (unformat (i, "polling"))
6033 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6034 else if (unformat (i, "interrupt"))
6035 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6036 else if (unformat (i, "adaptive"))
6037 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6039 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6040 sw_if_index_set = 1;
6041 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6042 sw_if_index_set = 1;
6047 if (sw_if_index_set == 0)
6049 errmsg ("missing interface name or sw_if_index");
6052 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6054 errmsg ("missing rx-mode");
6058 /* Construct the API message */
6059 M (SW_INTERFACE_SET_RX_MODE, mp);
6060 mp->sw_if_index = ntohl (sw_if_index);
6062 mp->queue_id_valid = queue_id_valid;
6063 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6068 /* Wait for a reply, return the good/bad news... */
6074 api_sw_interface_set_rx_placement (vat_main_t * vam)
6076 unformat_input_t *i = vam->input;
6077 vl_api_sw_interface_set_rx_placement_t *mp;
6079 u8 sw_if_index_set = 0;
6082 u32 queue_id, thread_index;
6084 /* Parse args required to build the message */
6085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6087 if (unformat (i, "queue %d", &queue_id))
6089 else if (unformat (i, "main"))
6091 else if (unformat (i, "worker %d", &thread_index))
6094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6095 sw_if_index_set = 1;
6096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6097 sw_if_index_set = 1;
6102 if (sw_if_index_set == 0)
6104 errmsg ("missing interface name or sw_if_index");
6110 /* Construct the API message */
6111 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6112 mp->sw_if_index = ntohl (sw_if_index);
6113 mp->worker_id = ntohl (thread_index);
6114 mp->queue_id = ntohl (queue_id);
6115 mp->is_main = is_main;
6119 /* Wait for a reply, return the good/bad news... */
6124 static void vl_api_sw_interface_rx_placement_details_t_handler
6125 (vl_api_sw_interface_rx_placement_details_t * mp)
6127 vat_main_t *vam = &vat_main;
6128 u32 worker_id = ntohl (mp->worker_id);
6131 "\n%-11d %-11s %-6d %-5d %-9s",
6132 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6133 worker_id, ntohl (mp->queue_id),
6135 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6138 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6139 (vl_api_sw_interface_rx_placement_details_t * mp)
6141 vat_main_t *vam = &vat_main;
6142 vat_json_node_t *node = NULL;
6144 if (VAT_JSON_ARRAY != vam->json_tree.type)
6146 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6147 vat_json_init_array (&vam->json_tree);
6149 node = vat_json_array_add (&vam->json_tree);
6151 vat_json_init_object (node);
6152 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6153 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6154 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6155 vat_json_object_add_uint (node, "mode", mp->mode);
6159 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6161 unformat_input_t *i = vam->input;
6162 vl_api_sw_interface_rx_placement_dump_t *mp;
6163 vl_api_control_ping_t *mp_ping;
6166 u8 sw_if_index_set = 0;
6168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6170 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6172 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6179 "\n%-11s %-11s %-6s %-5s %-4s",
6180 "sw_if_index", "main/worker", "thread", "queue", "mode");
6182 /* Dump Interface rx placement */
6183 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6185 if (sw_if_index_set)
6186 mp->sw_if_index = htonl (sw_if_index);
6188 mp->sw_if_index = ~0;
6192 /* Use a control ping for synchronization */
6193 MPING (CONTROL_PING, mp_ping);
6201 api_sw_interface_clear_stats (vat_main_t * vam)
6203 unformat_input_t *i = vam->input;
6204 vl_api_sw_interface_clear_stats_t *mp;
6206 u8 sw_if_index_set = 0;
6209 /* Parse args required to build the message */
6210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6212 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6213 sw_if_index_set = 1;
6214 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6215 sw_if_index_set = 1;
6220 /* Construct the API message */
6221 M (SW_INTERFACE_CLEAR_STATS, mp);
6223 if (sw_if_index_set == 1)
6224 mp->sw_if_index = ntohl (sw_if_index);
6226 mp->sw_if_index = ~0;
6231 /* Wait for a reply, return the good/bad news... */
6237 api_sw_interface_add_del_address (vat_main_t * vam)
6239 unformat_input_t *i = vam->input;
6240 vl_api_sw_interface_add_del_address_t *mp;
6242 u8 sw_if_index_set = 0;
6243 u8 is_add = 1, del_all = 0;
6244 u32 address_length = 0;
6245 u8 v4_address_set = 0;
6246 u8 v6_address_set = 0;
6247 ip4_address_t v4address;
6248 ip6_address_t v6address;
6251 /* Parse args required to build the message */
6252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6254 if (unformat (i, "del-all"))
6256 else if (unformat (i, "del"))
6259 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6260 sw_if_index_set = 1;
6261 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6262 sw_if_index_set = 1;
6263 else if (unformat (i, "%U/%d",
6264 unformat_ip4_address, &v4address, &address_length))
6266 else if (unformat (i, "%U/%d",
6267 unformat_ip6_address, &v6address, &address_length))
6273 if (sw_if_index_set == 0)
6275 errmsg ("missing interface name or sw_if_index");
6278 if (v4_address_set && v6_address_set)
6280 errmsg ("both v4 and v6 addresses set");
6283 if (!v4_address_set && !v6_address_set && !del_all)
6285 errmsg ("no addresses set");
6289 /* Construct the API message */
6290 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6292 mp->sw_if_index = ntohl (sw_if_index);
6293 mp->is_add = is_add;
6294 mp->del_all = del_all;
6298 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6302 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6304 mp->address_length = address_length;
6309 /* Wait for a reply, return good/bad news */
6315 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6317 unformat_input_t *i = vam->input;
6318 vl_api_sw_interface_set_mpls_enable_t *mp;
6320 u8 sw_if_index_set = 0;
6324 /* Parse args required to build the message */
6325 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6327 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6328 sw_if_index_set = 1;
6329 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6330 sw_if_index_set = 1;
6331 else if (unformat (i, "disable"))
6333 else if (unformat (i, "dis"))
6339 if (sw_if_index_set == 0)
6341 errmsg ("missing interface name or sw_if_index");
6345 /* Construct the API message */
6346 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6348 mp->sw_if_index = ntohl (sw_if_index);
6349 mp->enable = enable;
6354 /* Wait for a reply... */
6360 api_sw_interface_set_table (vat_main_t * vam)
6362 unformat_input_t *i = vam->input;
6363 vl_api_sw_interface_set_table_t *mp;
6364 u32 sw_if_index, vrf_id = 0;
6365 u8 sw_if_index_set = 0;
6369 /* Parse args required to build the message */
6370 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6372 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6373 sw_if_index_set = 1;
6374 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6375 sw_if_index_set = 1;
6376 else if (unformat (i, "vrf %d", &vrf_id))
6378 else if (unformat (i, "ipv6"))
6384 if (sw_if_index_set == 0)
6386 errmsg ("missing interface name or sw_if_index");
6390 /* Construct the API message */
6391 M (SW_INTERFACE_SET_TABLE, mp);
6393 mp->sw_if_index = ntohl (sw_if_index);
6394 mp->is_ipv6 = is_ipv6;
6395 mp->vrf_id = ntohl (vrf_id);
6400 /* Wait for a reply... */
6405 static void vl_api_sw_interface_get_table_reply_t_handler
6406 (vl_api_sw_interface_get_table_reply_t * mp)
6408 vat_main_t *vam = &vat_main;
6410 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6412 vam->retval = ntohl (mp->retval);
6413 vam->result_ready = 1;
6417 static void vl_api_sw_interface_get_table_reply_t_handler_json
6418 (vl_api_sw_interface_get_table_reply_t * mp)
6420 vat_main_t *vam = &vat_main;
6421 vat_json_node_t node;
6423 vat_json_init_object (&node);
6424 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6425 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6427 vat_json_print (vam->ofp, &node);
6428 vat_json_free (&node);
6430 vam->retval = ntohl (mp->retval);
6431 vam->result_ready = 1;
6435 api_sw_interface_get_table (vat_main_t * vam)
6437 unformat_input_t *i = vam->input;
6438 vl_api_sw_interface_get_table_t *mp;
6440 u8 sw_if_index_set = 0;
6444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6446 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6447 sw_if_index_set = 1;
6448 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6449 sw_if_index_set = 1;
6450 else if (unformat (i, "ipv6"))
6456 if (sw_if_index_set == 0)
6458 errmsg ("missing interface name or sw_if_index");
6462 M (SW_INTERFACE_GET_TABLE, mp);
6463 mp->sw_if_index = htonl (sw_if_index);
6464 mp->is_ipv6 = is_ipv6;
6472 api_sw_interface_set_vpath (vat_main_t * vam)
6474 unformat_input_t *i = vam->input;
6475 vl_api_sw_interface_set_vpath_t *mp;
6476 u32 sw_if_index = 0;
6477 u8 sw_if_index_set = 0;
6481 /* Parse args required to build the message */
6482 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6484 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6485 sw_if_index_set = 1;
6486 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6487 sw_if_index_set = 1;
6488 else if (unformat (i, "enable"))
6490 else if (unformat (i, "disable"))
6496 if (sw_if_index_set == 0)
6498 errmsg ("missing interface name or sw_if_index");
6502 /* Construct the API message */
6503 M (SW_INTERFACE_SET_VPATH, mp);
6505 mp->sw_if_index = ntohl (sw_if_index);
6506 mp->enable = is_enable;
6511 /* Wait for a reply... */
6517 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6519 unformat_input_t *i = vam->input;
6520 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6521 u32 sw_if_index = 0;
6522 u8 sw_if_index_set = 0;
6527 /* Parse args required to build the message */
6528 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6530 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6531 sw_if_index_set = 1;
6532 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6533 sw_if_index_set = 1;
6534 else if (unformat (i, "enable"))
6536 else if (unformat (i, "disable"))
6538 else if (unformat (i, "ip4"))
6540 else if (unformat (i, "ip6"))
6546 if (sw_if_index_set == 0)
6548 errmsg ("missing interface name or sw_if_index");
6552 /* Construct the API message */
6553 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6555 mp->sw_if_index = ntohl (sw_if_index);
6556 mp->enable = is_enable;
6557 mp->is_ipv6 = is_ipv6;
6562 /* Wait for a reply... */
6568 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6570 unformat_input_t *i = vam->input;
6571 vl_api_sw_interface_set_geneve_bypass_t *mp;
6572 u32 sw_if_index = 0;
6573 u8 sw_if_index_set = 0;
6578 /* Parse args required to build the message */
6579 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6581 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6582 sw_if_index_set = 1;
6583 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6584 sw_if_index_set = 1;
6585 else if (unformat (i, "enable"))
6587 else if (unformat (i, "disable"))
6589 else if (unformat (i, "ip4"))
6591 else if (unformat (i, "ip6"))
6597 if (sw_if_index_set == 0)
6599 errmsg ("missing interface name or sw_if_index");
6603 /* Construct the API message */
6604 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6606 mp->sw_if_index = ntohl (sw_if_index);
6607 mp->enable = is_enable;
6608 mp->is_ipv6 = is_ipv6;
6613 /* Wait for a reply... */
6619 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6621 unformat_input_t *i = vam->input;
6622 vl_api_sw_interface_set_l2_xconnect_t *mp;
6624 u8 rx_sw_if_index_set = 0;
6626 u8 tx_sw_if_index_set = 0;
6630 /* Parse args required to build the message */
6631 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6633 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6634 rx_sw_if_index_set = 1;
6635 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6636 tx_sw_if_index_set = 1;
6637 else if (unformat (i, "rx"))
6639 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6641 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6643 rx_sw_if_index_set = 1;
6648 else if (unformat (i, "tx"))
6650 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6652 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6654 tx_sw_if_index_set = 1;
6659 else if (unformat (i, "enable"))
6661 else if (unformat (i, "disable"))
6667 if (rx_sw_if_index_set == 0)
6669 errmsg ("missing rx interface name or rx_sw_if_index");
6673 if (enable && (tx_sw_if_index_set == 0))
6675 errmsg ("missing tx interface name or tx_sw_if_index");
6679 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6681 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6682 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6683 mp->enable = enable;
6691 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6693 unformat_input_t *i = vam->input;
6694 vl_api_sw_interface_set_l2_bridge_t *mp;
6695 vl_api_l2_port_type_t port_type;
6697 u8 rx_sw_if_index_set = 0;
6704 port_type = L2_API_PORT_TYPE_NORMAL;
6706 /* Parse args required to build the message */
6707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6709 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6710 rx_sw_if_index_set = 1;
6711 else if (unformat (i, "bd_id %d", &bd_id))
6715 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6716 rx_sw_if_index_set = 1;
6717 else if (unformat (i, "shg %d", &shg))
6719 else if (unformat (i, "bvi"))
6720 port_type = L2_API_PORT_TYPE_BVI;
6721 else if (unformat (i, "uu-fwd"))
6722 port_type = L2_API_PORT_TYPE_UU_FWD;
6723 else if (unformat (i, "enable"))
6725 else if (unformat (i, "disable"))
6731 if (rx_sw_if_index_set == 0)
6733 errmsg ("missing rx interface name or sw_if_index");
6737 if (enable && (bd_id_set == 0))
6739 errmsg ("missing bridge domain");
6743 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6745 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6746 mp->bd_id = ntohl (bd_id);
6748 mp->port_type = ntohl (port_type);
6749 mp->enable = enable;
6757 api_bridge_domain_dump (vat_main_t * vam)
6759 unformat_input_t *i = vam->input;
6760 vl_api_bridge_domain_dump_t *mp;
6761 vl_api_control_ping_t *mp_ping;
6765 /* Parse args required to build the message */
6766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6768 if (unformat (i, "bd_id %d", &bd_id))
6774 M (BRIDGE_DOMAIN_DUMP, mp);
6775 mp->bd_id = ntohl (bd_id);
6778 /* Use a control ping for synchronization */
6779 MPING (CONTROL_PING, mp_ping);
6787 api_bridge_domain_add_del (vat_main_t * vam)
6789 unformat_input_t *i = vam->input;
6790 vl_api_bridge_domain_add_del_t *mp;
6793 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6798 /* Parse args required to build the message */
6799 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6801 if (unformat (i, "bd_id %d", &bd_id))
6803 else if (unformat (i, "flood %d", &flood))
6805 else if (unformat (i, "uu-flood %d", &uu_flood))
6807 else if (unformat (i, "forward %d", &forward))
6809 else if (unformat (i, "learn %d", &learn))
6811 else if (unformat (i, "arp-term %d", &arp_term))
6813 else if (unformat (i, "mac-age %d", &mac_age))
6815 else if (unformat (i, "bd-tag %s", &bd_tag))
6817 else if (unformat (i, "del"))
6820 flood = uu_flood = forward = learn = 0;
6828 errmsg ("missing bridge domain");
6835 errmsg ("mac age must be less than 256 ");
6840 if ((bd_tag) && (vec_len (bd_tag) > 63))
6842 errmsg ("bd-tag cannot be longer than 63");
6847 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6849 mp->bd_id = ntohl (bd_id);
6851 mp->uu_flood = uu_flood;
6852 mp->forward = forward;
6854 mp->arp_term = arp_term;
6855 mp->is_add = is_add;
6856 mp->mac_age = (u8) mac_age;
6859 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6860 mp->bd_tag[vec_len (bd_tag)] = 0;
6871 api_l2fib_flush_bd (vat_main_t * vam)
6873 unformat_input_t *i = vam->input;
6874 vl_api_l2fib_flush_bd_t *mp;
6878 /* Parse args required to build the message */
6879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6881 if (unformat (i, "bd_id %d", &bd_id));
6888 errmsg ("missing bridge domain");
6892 M (L2FIB_FLUSH_BD, mp);
6894 mp->bd_id = htonl (bd_id);
6902 api_l2fib_flush_int (vat_main_t * vam)
6904 unformat_input_t *i = vam->input;
6905 vl_api_l2fib_flush_int_t *mp;
6906 u32 sw_if_index = ~0;
6909 /* Parse args required to build the message */
6910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6912 if (unformat (i, "sw_if_index %d", &sw_if_index));
6914 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6919 if (sw_if_index == ~0)
6921 errmsg ("missing interface name or sw_if_index");
6925 M (L2FIB_FLUSH_INT, mp);
6927 mp->sw_if_index = ntohl (sw_if_index);
6935 api_l2fib_add_del (vat_main_t * vam)
6937 unformat_input_t *i = vam->input;
6938 vl_api_l2fib_add_del_t *mp;
6944 u32 sw_if_index = 0;
6945 u8 sw_if_index_set = 0;
6954 /* Parse args required to build the message */
6955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6957 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6959 else if (unformat (i, "bd_id %d", &bd_id))
6961 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6962 sw_if_index_set = 1;
6963 else if (unformat (i, "sw_if"))
6965 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6968 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6969 sw_if_index_set = 1;
6974 else if (unformat (i, "static"))
6976 else if (unformat (i, "filter"))
6981 else if (unformat (i, "bvi"))
6986 else if (unformat (i, "del"))
6988 else if (unformat (i, "count %d", &count))
6996 errmsg ("missing mac address");
7002 errmsg ("missing bridge domain");
7006 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7008 errmsg ("missing interface name or sw_if_index");
7014 /* Turn on async mode */
7015 vam->async_mode = 1;
7016 vam->async_errors = 0;
7017 before = vat_time_now (vam);
7020 for (j = 0; j < count; j++)
7022 M (L2FIB_ADD_DEL, mp);
7024 clib_memcpy (mp->mac, mac, 6);
7025 mp->bd_id = ntohl (bd_id);
7026 mp->is_add = is_add;
7027 mp->sw_if_index = ntohl (sw_if_index);
7031 mp->static_mac = static_mac;
7032 mp->filter_mac = filter_mac;
7033 mp->bvi_mac = bvi_mac;
7035 increment_mac_address (mac);
7042 vl_api_control_ping_t *mp_ping;
7045 /* Shut off async mode */
7046 vam->async_mode = 0;
7048 MPING (CONTROL_PING, mp_ping);
7051 timeout = vat_time_now (vam) + 1.0;
7052 while (vat_time_now (vam) < timeout)
7053 if (vam->result_ready == 1)
7058 if (vam->retval == -99)
7061 if (vam->async_errors > 0)
7063 errmsg ("%d asynchronous errors", vam->async_errors);
7066 vam->async_errors = 0;
7067 after = vat_time_now (vam);
7069 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7070 count, after - before, count / (after - before));
7076 /* Wait for a reply... */
7080 /* Return the good/bad news */
7081 return (vam->retval);
7085 api_bridge_domain_set_mac_age (vat_main_t * vam)
7087 unformat_input_t *i = vam->input;
7088 vl_api_bridge_domain_set_mac_age_t *mp;
7093 /* Parse args required to build the message */
7094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7096 if (unformat (i, "bd_id %d", &bd_id));
7097 else if (unformat (i, "mac-age %d", &mac_age));
7104 errmsg ("missing bridge domain");
7110 errmsg ("mac age must be less than 256 ");
7114 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7116 mp->bd_id = htonl (bd_id);
7117 mp->mac_age = (u8) mac_age;
7125 api_l2_flags (vat_main_t * vam)
7127 unformat_input_t *i = vam->input;
7128 vl_api_l2_flags_t *mp;
7131 u8 sw_if_index_set = 0;
7135 /* Parse args required to build the message */
7136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7138 if (unformat (i, "sw_if_index %d", &sw_if_index))
7139 sw_if_index_set = 1;
7140 else if (unformat (i, "sw_if"))
7142 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7145 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7146 sw_if_index_set = 1;
7151 else if (unformat (i, "learn"))
7153 else if (unformat (i, "forward"))
7155 else if (unformat (i, "flood"))
7157 else if (unformat (i, "uu-flood"))
7158 flags |= L2_UU_FLOOD;
7159 else if (unformat (i, "arp-term"))
7160 flags |= L2_ARP_TERM;
7161 else if (unformat (i, "off"))
7163 else if (unformat (i, "disable"))
7169 if (sw_if_index_set == 0)
7171 errmsg ("missing interface name or sw_if_index");
7177 mp->sw_if_index = ntohl (sw_if_index);
7178 mp->feature_bitmap = ntohl (flags);
7179 mp->is_set = is_set;
7187 api_bridge_flags (vat_main_t * vam)
7189 unformat_input_t *i = vam->input;
7190 vl_api_bridge_flags_t *mp;
7194 bd_flags_t flags = 0;
7197 /* Parse args required to build the message */
7198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7200 if (unformat (i, "bd_id %d", &bd_id))
7202 else if (unformat (i, "learn"))
7203 flags |= BRIDGE_API_FLAG_LEARN;
7204 else if (unformat (i, "forward"))
7205 flags |= BRIDGE_API_FLAG_FWD;
7206 else if (unformat (i, "flood"))
7207 flags |= BRIDGE_API_FLAG_FLOOD;
7208 else if (unformat (i, "uu-flood"))
7209 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7210 else if (unformat (i, "arp-term"))
7211 flags |= BRIDGE_API_FLAG_ARP_TERM;
7212 else if (unformat (i, "off"))
7214 else if (unformat (i, "disable"))
7222 errmsg ("missing bridge domain");
7226 M (BRIDGE_FLAGS, mp);
7228 mp->bd_id = ntohl (bd_id);
7229 mp->flags = ntohl (flags);
7230 mp->is_set = is_set;
7238 api_bd_ip_mac_add_del (vat_main_t * vam)
7240 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7241 vl_api_mac_address_t mac = { 0 };
7242 unformat_input_t *i = vam->input;
7243 vl_api_bd_ip_mac_add_del_t *mp;
7255 /* Parse args required to build the message */
7256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7258 if (unformat (i, "bd_id %d", &bd_id))
7262 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7266 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7270 else if (unformat (i, "del"))
7278 errmsg ("missing bridge domain");
7281 else if (ip_set == 0)
7283 errmsg ("missing IP address");
7286 else if (mac_set == 0)
7288 errmsg ("missing MAC address");
7292 M (BD_IP_MAC_ADD_DEL, mp);
7294 mp->bd_id = ntohl (bd_id);
7295 mp->is_add = is_add;
7297 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7298 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7306 api_bd_ip_mac_flush (vat_main_t * vam)
7308 unformat_input_t *i = vam->input;
7309 vl_api_bd_ip_mac_flush_t *mp;
7314 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7316 if (unformat (i, "bd_id %d", &bd_id))
7326 errmsg ("missing bridge domain");
7330 M (BD_IP_MAC_FLUSH, mp);
7332 mp->bd_id = ntohl (bd_id);
7339 static void vl_api_bd_ip_mac_details_t_handler
7340 (vl_api_bd_ip_mac_details_t * mp)
7342 vat_main_t *vam = &vat_main;
7347 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7350 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7353 "\n%-5d %-7s %-20U %-30s",
7354 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7355 format_ethernet_address, mp->mac_address, ip);
7360 static void vl_api_bd_ip_mac_details_t_handler_json
7361 (vl_api_bd_ip_mac_details_t * mp)
7363 vat_main_t *vam = &vat_main;
7364 vat_json_node_t *node = NULL;
7366 if (VAT_JSON_ARRAY != vam->json_tree.type)
7368 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7369 vat_json_init_array (&vam->json_tree);
7371 node = vat_json_array_add (&vam->json_tree);
7373 vat_json_init_object (node);
7374 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7375 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7376 vat_json_object_add_string_copy (node, "mac_address",
7377 format (0, "%U", format_ethernet_address,
7383 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7386 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7387 vat_json_object_add_string_copy (node, "ip_address", ip);
7392 api_bd_ip_mac_dump (vat_main_t * vam)
7394 unformat_input_t *i = vam->input;
7395 vl_api_bd_ip_mac_dump_t *mp;
7396 vl_api_control_ping_t *mp_ping;
7401 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7403 if (unformat (i, "bd_id %d", &bd_id))
7412 "\n%-5s %-7s %-20s %-30s",
7413 "bd_id", "is_ipv6", "mac_address", "ip_address");
7415 /* Dump Bridge Domain Ip to Mac entries */
7416 M (BD_IP_MAC_DUMP, mp);
7419 mp->bd_id = htonl (bd_id);
7425 /* Use a control ping for synchronization */
7426 MPING (CONTROL_PING, mp_ping);
7434 api_tap_create_v2 (vat_main_t * vam)
7436 unformat_input_t *i = vam->input;
7437 vl_api_tap_create_v2_t *mp;
7441 u8 *host_if_name = 0;
7443 u8 host_mac_addr[6];
7444 u8 host_mac_addr_set = 0;
7445 u8 *host_bridge = 0;
7446 ip4_address_t host_ip4_addr;
7447 ip4_address_t host_ip4_gw;
7448 u8 host_ip4_gw_set = 0;
7449 u32 host_ip4_prefix_len = 0;
7450 ip6_address_t host_ip6_addr;
7451 ip6_address_t host_ip6_gw;
7452 u8 host_ip6_gw_set = 0;
7453 u32 host_ip6_prefix_len = 0;
7455 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7457 clib_memset (mac_address, 0, sizeof (mac_address));
7459 /* Parse args required to build the message */
7460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7462 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7466 else if (unformat (i, "id %u", &id))
7468 else if (unformat (i, "host-if-name %s", &host_if_name))
7470 else if (unformat (i, "host-ns %s", &host_ns))
7472 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7474 host_mac_addr_set = 1;
7475 else if (unformat (i, "host-bridge %s", &host_bridge))
7477 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7478 &host_ip4_addr, &host_ip4_prefix_len))
7480 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7481 &host_ip6_addr, &host_ip6_prefix_len))
7483 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7485 host_ip4_gw_set = 1;
7486 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7488 host_ip6_gw_set = 1;
7489 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7491 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7497 if (vec_len (host_if_name) > 63)
7499 errmsg ("tap name too long. ");
7502 if (vec_len (host_ns) > 63)
7504 errmsg ("host name space too long. ");
7507 if (vec_len (host_bridge) > 63)
7509 errmsg ("host bridge name too long. ");
7512 if (host_ip4_prefix_len > 32)
7514 errmsg ("host ip4 prefix length not valid. ");
7517 if (host_ip6_prefix_len > 128)
7519 errmsg ("host ip6 prefix length not valid. ");
7522 if (!is_pow2 (rx_ring_sz))
7524 errmsg ("rx ring size must be power of 2. ");
7527 if (rx_ring_sz > 32768)
7529 errmsg ("rx ring size must be 32768 or lower. ");
7532 if (!is_pow2 (tx_ring_sz))
7534 errmsg ("tx ring size must be power of 2. ");
7537 if (tx_ring_sz > 32768)
7539 errmsg ("tx ring size must be 32768 or lower. ");
7543 /* Construct the API message */
7544 M (TAP_CREATE_V2, mp);
7546 mp->use_random_mac = random_mac;
7548 mp->id = ntohl (id);
7549 mp->host_namespace_set = host_ns != 0;
7550 mp->host_bridge_set = host_bridge != 0;
7551 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7552 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7553 mp->rx_ring_sz = ntohs (rx_ring_sz);
7554 mp->tx_ring_sz = ntohs (tx_ring_sz);
7556 if (random_mac == 0)
7557 clib_memcpy (mp->mac_address, mac_address, 6);
7558 if (host_mac_addr_set)
7559 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7561 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7563 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7565 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7566 if (host_ip4_prefix_len)
7567 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7568 if (host_ip6_prefix_len)
7569 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7570 if (host_ip4_gw_set)
7571 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7572 if (host_ip6_gw_set)
7573 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7576 vec_free (host_if_name);
7577 vec_free (host_bridge);
7582 /* Wait for a reply... */
7588 api_tap_delete_v2 (vat_main_t * vam)
7590 unformat_input_t *i = vam->input;
7591 vl_api_tap_delete_v2_t *mp;
7592 u32 sw_if_index = ~0;
7593 u8 sw_if_index_set = 0;
7596 /* Parse args required to build the message */
7597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7599 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7600 sw_if_index_set = 1;
7601 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7602 sw_if_index_set = 1;
7607 if (sw_if_index_set == 0)
7609 errmsg ("missing vpp interface name. ");
7613 /* Construct the API message */
7614 M (TAP_DELETE_V2, mp);
7616 mp->sw_if_index = ntohl (sw_if_index);
7621 /* Wait for a reply... */
7627 unformat_pci_addr (unformat_input_t * input, va_list * args)
7636 addr = va_arg (*args, struct pci_addr_t *);
7639 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7642 addr->domain = x[0];
7645 addr->function = x[3];
7651 api_virtio_pci_create (vat_main_t * vam)
7653 unformat_input_t *i = vam->input;
7654 vl_api_virtio_pci_create_t *mp;
7658 u64 features = (u64) ~ (0ULL);
7659 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7662 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, "hw-addr %U", unformat_ethernet_address, mac_address))
7671 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7673 else if (unformat (i, "features 0x%llx", &features))
7675 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7677 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7685 errmsg ("pci address must be non zero. ");
7688 if (!is_pow2 (rx_ring_sz))
7690 errmsg ("rx ring size must be power of 2. ");
7693 if (rx_ring_sz > 32768)
7695 errmsg ("rx ring size must be 32768 or lower. ");
7698 if (!is_pow2 (tx_ring_sz))
7700 errmsg ("tx ring size must be power of 2. ");
7703 if (tx_ring_sz > 32768)
7705 errmsg ("tx ring size must be 32768 or lower. ");
7709 /* Construct the API message */
7710 M (VIRTIO_PCI_CREATE, mp);
7712 mp->use_random_mac = random_mac;
7714 mp->pci_addr = htonl (pci_addr);
7715 mp->features = clib_host_to_net_u64 (features);
7716 mp->rx_ring_sz = htons (rx_ring_sz);
7717 mp->tx_ring_sz = htons (tx_ring_sz);
7719 if (random_mac == 0)
7720 clib_memcpy (mp->mac_address, mac_address, 6);
7725 /* Wait for a reply... */
7731 api_virtio_pci_delete (vat_main_t * vam)
7733 unformat_input_t *i = vam->input;
7734 vl_api_virtio_pci_delete_t *mp;
7735 u32 sw_if_index = ~0;
7736 u8 sw_if_index_set = 0;
7739 /* Parse args required to build the message */
7740 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7742 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7743 sw_if_index_set = 1;
7744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7745 sw_if_index_set = 1;
7750 if (sw_if_index_set == 0)
7752 errmsg ("missing vpp interface name. ");
7756 /* Construct the API message */
7757 M (VIRTIO_PCI_DELETE, mp);
7759 mp->sw_if_index = htonl (sw_if_index);
7764 /* Wait for a reply... */
7770 api_bond_create (vat_main_t * vam)
7772 unformat_input_t *i = vam->input;
7773 vl_api_bond_create_t *mp;
7782 clib_memset (mac_address, 0, sizeof (mac_address));
7785 /* Parse args required to build the message */
7786 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7788 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7790 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7791 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7793 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7796 else if (unformat (i, "id %u", &id))
7802 if (mode_is_set == 0)
7804 errmsg ("Missing bond mode. ");
7808 /* Construct the API message */
7809 M (BOND_CREATE, mp);
7811 mp->use_custom_mac = custom_mac;
7815 mp->id = htonl (id);
7818 clib_memcpy (mp->mac_address, mac_address, 6);
7823 /* Wait for a reply... */
7829 api_bond_delete (vat_main_t * vam)
7831 unformat_input_t *i = vam->input;
7832 vl_api_bond_delete_t *mp;
7833 u32 sw_if_index = ~0;
7834 u8 sw_if_index_set = 0;
7837 /* Parse args required to build the message */
7838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7840 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7841 sw_if_index_set = 1;
7842 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7843 sw_if_index_set = 1;
7848 if (sw_if_index_set == 0)
7850 errmsg ("missing vpp interface name. ");
7854 /* Construct the API message */
7855 M (BOND_DELETE, mp);
7857 mp->sw_if_index = ntohl (sw_if_index);
7862 /* Wait for a reply... */
7868 api_bond_enslave (vat_main_t * vam)
7870 unformat_input_t *i = vam->input;
7871 vl_api_bond_enslave_t *mp;
7872 u32 bond_sw_if_index;
7876 u32 bond_sw_if_index_is_set = 0;
7878 u8 sw_if_index_is_set = 0;
7880 /* Parse args required to build the message */
7881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7883 if (unformat (i, "sw_if_index %d", &sw_if_index))
7884 sw_if_index_is_set = 1;
7885 else if (unformat (i, "bond %u", &bond_sw_if_index))
7886 bond_sw_if_index_is_set = 1;
7887 else if (unformat (i, "passive %d", &is_passive))
7889 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7895 if (bond_sw_if_index_is_set == 0)
7897 errmsg ("Missing bond sw_if_index. ");
7900 if (sw_if_index_is_set == 0)
7902 errmsg ("Missing slave sw_if_index. ");
7906 /* Construct the API message */
7907 M (BOND_ENSLAVE, mp);
7909 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7910 mp->sw_if_index = ntohl (sw_if_index);
7911 mp->is_long_timeout = is_long_timeout;
7912 mp->is_passive = is_passive;
7917 /* Wait for a reply... */
7923 api_bond_detach_slave (vat_main_t * vam)
7925 unformat_input_t *i = vam->input;
7926 vl_api_bond_detach_slave_t *mp;
7927 u32 sw_if_index = ~0;
7928 u8 sw_if_index_set = 0;
7931 /* Parse args required to build the message */
7932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7934 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7935 sw_if_index_set = 1;
7936 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7937 sw_if_index_set = 1;
7942 if (sw_if_index_set == 0)
7944 errmsg ("missing vpp interface name. ");
7948 /* Construct the API message */
7949 M (BOND_DETACH_SLAVE, mp);
7951 mp->sw_if_index = ntohl (sw_if_index);
7956 /* Wait for a reply... */
7962 api_ip_table_add_del (vat_main_t * vam)
7964 unformat_input_t *i = vam->input;
7965 vl_api_ip_table_add_del_t *mp;
7971 /* Parse args required to build the message */
7972 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7974 if (unformat (i, "ipv6"))
7976 else if (unformat (i, "del"))
7978 else if (unformat (i, "add"))
7980 else if (unformat (i, "table %d", &table_id))
7984 clib_warning ("parse error '%U'", format_unformat_error, i);
7991 errmsg ("missing table-ID");
7995 /* Construct the API message */
7996 M (IP_TABLE_ADD_DEL, mp);
7998 mp->table_id = ntohl (table_id);
7999 mp->is_ipv6 = is_ipv6;
8000 mp->is_add = is_add;
8005 /* Wait for a reply... */
8012 api_ip_add_del_route (vat_main_t * vam)
8014 unformat_input_t *i = vam->input;
8015 vl_api_ip_add_del_route_t *mp;
8016 u32 sw_if_index = ~0, vrf_id = 0;
8018 u8 is_local = 0, is_drop = 0;
8019 u8 is_unreach = 0, is_prohibit = 0;
8021 u32 next_hop_weight = 1;
8022 u8 is_multipath = 0;
8024 u8 address_length_set = 0;
8025 u32 next_hop_table_id = 0;
8026 u32 resolve_attempts = 0;
8027 u32 dst_address_length = 0;
8028 u8 next_hop_set = 0;
8029 ip4_address_t v4_dst_address, v4_next_hop_address;
8030 ip6_address_t v6_dst_address, v6_next_hop_address;
8034 u32 random_add_del = 0;
8035 u32 *random_vector = 0;
8037 u32 random_seed = 0xdeaddabe;
8038 u32 classify_table_index = ~0;
8040 u8 resolve_host = 0, resolve_attached = 0;
8041 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8042 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8043 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8045 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8046 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8047 /* Parse args required to build the message */
8048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8050 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8052 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8054 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8059 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8064 else if (unformat (i, "/%d", &dst_address_length))
8066 address_length_set = 1;
8069 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8070 &v4_next_hop_address))
8074 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8075 &v6_next_hop_address))
8081 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8085 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8089 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8091 else if (unformat (i, "weight %d", &next_hop_weight))
8093 else if (unformat (i, "drop"))
8097 else if (unformat (i, "null-send-unreach"))
8101 else if (unformat (i, "null-send-prohibit"))
8105 else if (unformat (i, "local"))
8109 else if (unformat (i, "classify %d", &classify_table_index))
8113 else if (unformat (i, "del"))
8115 else if (unformat (i, "add"))
8117 else if (unformat (i, "resolve-via-host"))
8119 else if (unformat (i, "resolve-via-attached"))
8120 resolve_attached = 1;
8121 else if (unformat (i, "multipath"))
8123 else if (unformat (i, "vrf %d", &vrf_id))
8125 else if (unformat (i, "count %d", &count))
8127 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8129 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8131 else if (unformat (i, "out-label %d", &next_hop_out_label))
8133 vl_api_fib_mpls_label_t fib_label = {
8134 .label = ntohl (next_hop_out_label),
8138 vec_add1 (next_hop_out_label_stack, fib_label);
8140 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8142 else if (unformat (i, "random"))
8144 else if (unformat (i, "seed %d", &random_seed))
8148 clib_warning ("parse error '%U'", format_unformat_error, i);
8153 if (!next_hop_set && !is_drop && !is_local &&
8154 !is_classify && !is_unreach && !is_prohibit &&
8155 MPLS_LABEL_INVALID == next_hop_via_label)
8158 ("next hop / local / drop / unreach / prohibit / classify not set");
8162 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8164 errmsg ("next hop and next-hop via label set");
8167 if (address_set == 0)
8169 errmsg ("missing addresses");
8173 if (address_length_set == 0)
8175 errmsg ("missing address length");
8179 /* Generate a pile of unique, random routes */
8182 u32 this_random_address;
8183 random_hash = hash_create (count, sizeof (uword));
8185 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8186 for (j = 0; j <= count; j++)
8190 this_random_address = random_u32 (&random_seed);
8191 this_random_address =
8192 clib_host_to_net_u32 (this_random_address);
8194 while (hash_get (random_hash, this_random_address));
8195 vec_add1 (random_vector, this_random_address);
8196 hash_set (random_hash, this_random_address, 1);
8198 hash_free (random_hash);
8199 v4_dst_address.as_u32 = random_vector[0];
8204 /* Turn on async mode */
8205 vam->async_mode = 1;
8206 vam->async_errors = 0;
8207 before = vat_time_now (vam);
8210 for (j = 0; j < count; j++)
8212 /* Construct the API message */
8213 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8214 vec_len (next_hop_out_label_stack));
8216 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8217 mp->table_id = ntohl (vrf_id);
8219 mp->is_add = is_add;
8220 mp->is_drop = is_drop;
8221 mp->is_unreach = is_unreach;
8222 mp->is_prohibit = is_prohibit;
8223 mp->is_ipv6 = is_ipv6;
8224 mp->is_local = is_local;
8225 mp->is_classify = is_classify;
8226 mp->is_multipath = is_multipath;
8227 mp->is_resolve_host = resolve_host;
8228 mp->is_resolve_attached = resolve_attached;
8229 mp->next_hop_weight = next_hop_weight;
8230 mp->next_hop_preference = 0;
8231 mp->dst_address_length = dst_address_length;
8232 mp->next_hop_table_id = ntohl (next_hop_table_id);
8233 mp->classify_table_index = ntohl (classify_table_index);
8234 mp->next_hop_via_label = ntohl (next_hop_via_label);
8235 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8236 if (0 != mp->next_hop_n_out_labels)
8238 memcpy (mp->next_hop_out_label_stack,
8239 next_hop_out_label_stack,
8240 (vec_len (next_hop_out_label_stack) *
8241 sizeof (vl_api_fib_mpls_label_t)));
8242 vec_free (next_hop_out_label_stack);
8247 clib_memcpy (mp->dst_address, &v6_dst_address,
8248 sizeof (v6_dst_address));
8250 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8251 sizeof (v6_next_hop_address));
8252 increment_v6_address (&v6_dst_address);
8256 clib_memcpy (mp->dst_address, &v4_dst_address,
8257 sizeof (v4_dst_address));
8259 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8260 sizeof (v4_next_hop_address));
8262 v4_dst_address.as_u32 = random_vector[j + 1];
8264 increment_v4_address (&v4_dst_address);
8268 /* If we receive SIGTERM, stop now... */
8273 /* When testing multiple add/del ops, use a control-ping to sync */
8276 vl_api_control_ping_t *mp_ping;
8280 /* Shut off async mode */
8281 vam->async_mode = 0;
8283 MPING (CONTROL_PING, mp_ping);
8286 timeout = vat_time_now (vam) + 1.0;
8287 while (vat_time_now (vam) < timeout)
8288 if (vam->result_ready == 1)
8293 if (vam->retval == -99)
8296 if (vam->async_errors > 0)
8298 errmsg ("%d asynchronous errors", vam->async_errors);
8301 vam->async_errors = 0;
8302 after = vat_time_now (vam);
8304 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8308 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8309 count, after - before, count / (after - before));
8315 /* Wait for a reply... */
8320 /* Return the good/bad news */
8321 return (vam->retval);
8325 api_ip_mroute_add_del (vat_main_t * vam)
8327 unformat_input_t *i = vam->input;
8328 vl_api_ip_mroute_add_del_t *mp;
8329 u32 sw_if_index = ~0, vrf_id = 0;
8334 u32 grp_address_length = 0;
8335 ip4_address_t v4_grp_address, v4_src_address;
8336 ip6_address_t v6_grp_address, v6_src_address;
8337 mfib_itf_flags_t iflags = 0;
8338 mfib_entry_flags_t eflags = 0;
8341 /* Parse args required to build the message */
8342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8344 if (unformat (i, "sw_if_index %d", &sw_if_index))
8346 else if (unformat (i, "%U %U",
8347 unformat_ip4_address, &v4_src_address,
8348 unformat_ip4_address, &v4_grp_address))
8350 grp_address_length = 64;
8354 else if (unformat (i, "%U %U",
8355 unformat_ip6_address, &v6_src_address,
8356 unformat_ip6_address, &v6_grp_address))
8358 grp_address_length = 256;
8362 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8364 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8365 grp_address_length = 32;
8369 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8371 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8372 grp_address_length = 128;
8376 else if (unformat (i, "/%d", &grp_address_length))
8378 else if (unformat (i, "local"))
8382 else if (unformat (i, "del"))
8384 else if (unformat (i, "add"))
8386 else if (unformat (i, "vrf %d", &vrf_id))
8388 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8390 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8394 clib_warning ("parse error '%U'", format_unformat_error, i);
8399 if (address_set == 0)
8401 errmsg ("missing addresses\n");
8405 /* Construct the API message */
8406 M (IP_MROUTE_ADD_DEL, mp);
8408 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8409 mp->table_id = ntohl (vrf_id);
8411 mp->is_add = is_add;
8412 mp->is_ipv6 = is_ipv6;
8413 mp->is_local = is_local;
8414 mp->itf_flags = ntohl (iflags);
8415 mp->entry_flags = ntohl (eflags);
8416 mp->grp_address_length = grp_address_length;
8417 mp->grp_address_length = ntohs (mp->grp_address_length);
8421 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8422 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8426 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8427 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8433 /* Wait for a reply... */
8439 api_mpls_table_add_del (vat_main_t * vam)
8441 unformat_input_t *i = vam->input;
8442 vl_api_mpls_table_add_del_t *mp;
8447 /* Parse args required to build the message */
8448 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8450 if (unformat (i, "table %d", &table_id))
8452 else if (unformat (i, "del"))
8454 else if (unformat (i, "add"))
8458 clib_warning ("parse error '%U'", format_unformat_error, i);
8465 errmsg ("missing table-ID");
8469 /* Construct the API message */
8470 M (MPLS_TABLE_ADD_DEL, mp);
8472 mp->mt_table_id = ntohl (table_id);
8473 mp->mt_is_add = is_add;
8478 /* Wait for a reply... */
8485 api_mpls_route_add_del (vat_main_t * vam)
8487 unformat_input_t *i = vam->input;
8488 vl_api_mpls_route_add_del_t *mp;
8489 u32 sw_if_index = ~0, table_id = 0;
8491 u32 next_hop_weight = 1;
8492 u8 is_multipath = 0;
8493 u32 next_hop_table_id = 0;
8494 u8 next_hop_set = 0;
8495 ip4_address_t v4_next_hop_address = {
8498 ip6_address_t v6_next_hop_address = { {0} };
8502 u32 classify_table_index = ~0;
8504 u8 resolve_host = 0, resolve_attached = 0;
8505 u8 is_interface_rx = 0;
8506 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8507 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8508 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8509 mpls_label_t local_label = MPLS_LABEL_INVALID;
8511 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8513 /* Parse args required to build the message */
8514 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8516 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8518 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8520 else if (unformat (i, "%d", &local_label))
8522 else if (unformat (i, "eos"))
8524 else if (unformat (i, "non-eos"))
8526 else if (unformat (i, "via %U", unformat_ip4_address,
8527 &v4_next_hop_address))
8530 next_hop_proto = DPO_PROTO_IP4;
8532 else if (unformat (i, "via %U", unformat_ip6_address,
8533 &v6_next_hop_address))
8536 next_hop_proto = DPO_PROTO_IP6;
8538 else if (unformat (i, "weight %d", &next_hop_weight))
8540 else if (unformat (i, "classify %d", &classify_table_index))
8544 else if (unformat (i, "del"))
8546 else if (unformat (i, "add"))
8548 else if (unformat (i, "resolve-via-host"))
8550 else if (unformat (i, "resolve-via-attached"))
8551 resolve_attached = 1;
8552 else if (unformat (i, "multipath"))
8554 else if (unformat (i, "count %d", &count))
8556 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8559 next_hop_proto = DPO_PROTO_IP4;
8561 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8564 next_hop_proto = DPO_PROTO_IP6;
8568 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8572 next_hop_proto = DPO_PROTO_ETHERNET;
8573 is_interface_rx = 1;
8575 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8578 next_hop_proto = DPO_PROTO_ETHERNET;
8579 is_interface_rx = 1;
8581 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8583 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8585 else if (unformat (i, "out-label %d", &next_hop_out_label))
8587 vl_api_fib_mpls_label_t fib_label = {
8588 .label = ntohl (next_hop_out_label),
8592 vec_add1 (next_hop_out_label_stack, fib_label);
8596 clib_warning ("parse error '%U'", format_unformat_error, i);
8601 if (!next_hop_set && !is_classify)
8603 errmsg ("next hop / classify not set");
8607 if (MPLS_LABEL_INVALID == local_label)
8609 errmsg ("missing label");
8615 /* Turn on async mode */
8616 vam->async_mode = 1;
8617 vam->async_errors = 0;
8618 before = vat_time_now (vam);
8621 for (j = 0; j < count; j++)
8623 /* Construct the API message */
8624 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8625 vec_len (next_hop_out_label_stack));
8627 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8628 mp->mr_table_id = ntohl (table_id);
8630 mp->mr_is_add = is_add;
8631 mp->mr_next_hop_proto = next_hop_proto;
8632 mp->mr_is_classify = is_classify;
8633 mp->mr_is_multipath = is_multipath;
8634 mp->mr_is_resolve_host = resolve_host;
8635 mp->mr_is_resolve_attached = resolve_attached;
8636 mp->mr_is_interface_rx = is_interface_rx;
8637 mp->mr_next_hop_weight = next_hop_weight;
8638 mp->mr_next_hop_preference = 0;
8639 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8640 mp->mr_classify_table_index = ntohl (classify_table_index);
8641 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8642 mp->mr_label = ntohl (local_label);
8643 mp->mr_eos = is_eos;
8645 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8646 if (0 != mp->mr_next_hop_n_out_labels)
8648 memcpy (mp->mr_next_hop_out_label_stack,
8649 next_hop_out_label_stack,
8650 vec_len (next_hop_out_label_stack) *
8651 sizeof (vl_api_fib_mpls_label_t));
8652 vec_free (next_hop_out_label_stack);
8657 if (DPO_PROTO_IP4 == next_hop_proto)
8659 clib_memcpy (mp->mr_next_hop,
8660 &v4_next_hop_address,
8661 sizeof (v4_next_hop_address));
8663 else if (DPO_PROTO_IP6 == next_hop_proto)
8666 clib_memcpy (mp->mr_next_hop,
8667 &v6_next_hop_address,
8668 sizeof (v6_next_hop_address));
8675 /* If we receive SIGTERM, stop now... */
8680 /* When testing multiple add/del ops, use a control-ping to sync */
8683 vl_api_control_ping_t *mp_ping;
8687 /* Shut off async mode */
8688 vam->async_mode = 0;
8690 MPING (CONTROL_PING, mp_ping);
8693 timeout = vat_time_now (vam) + 1.0;
8694 while (vat_time_now (vam) < timeout)
8695 if (vam->result_ready == 1)
8700 if (vam->retval == -99)
8703 if (vam->async_errors > 0)
8705 errmsg ("%d asynchronous errors", vam->async_errors);
8708 vam->async_errors = 0;
8709 after = vat_time_now (vam);
8711 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8715 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8716 count, after - before, count / (after - before));
8722 /* Wait for a reply... */
8727 /* Return the good/bad news */
8728 return (vam->retval);
8732 api_mpls_ip_bind_unbind (vat_main_t * vam)
8734 unformat_input_t *i = vam->input;
8735 vl_api_mpls_ip_bind_unbind_t *mp;
8736 u32 ip_table_id = 0;
8739 ip4_address_t v4_address;
8740 ip6_address_t v6_address;
8743 mpls_label_t local_label = MPLS_LABEL_INVALID;
8746 /* Parse args required to build the message */
8747 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8749 if (unformat (i, "%U/%d", unformat_ip4_address,
8750 &v4_address, &address_length))
8755 else if (unformat (i, "%U/%d", unformat_ip6_address,
8756 &v6_address, &address_length))
8761 else if (unformat (i, "%d", &local_label))
8763 else if (unformat (i, "table-id %d", &ip_table_id))
8765 else if (unformat (i, "unbind"))
8767 else if (unformat (i, "bind"))
8771 clib_warning ("parse error '%U'", format_unformat_error, i);
8778 errmsg ("IP address not set");
8782 if (MPLS_LABEL_INVALID == local_label)
8784 errmsg ("missing label");
8788 /* Construct the API message */
8789 M (MPLS_IP_BIND_UNBIND, mp);
8791 mp->mb_is_bind = is_bind;
8792 mp->mb_is_ip4 = is_ip4;
8793 mp->mb_ip_table_id = ntohl (ip_table_id);
8794 mp->mb_mpls_table_id = 0;
8795 mp->mb_label = ntohl (local_label);
8796 mp->mb_address_length = address_length;
8799 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8801 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8806 /* Wait for a reply... */
8812 api_sr_mpls_policy_add (vat_main_t * vam)
8814 unformat_input_t *i = vam->input;
8815 vl_api_sr_mpls_policy_add_t *mp;
8821 u32 *segments = NULL;
8824 /* Parse args required to build the message */
8825 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8827 if (unformat (i, "bsid %d", &bsid))
8829 else if (unformat (i, "weight %d", &weight))
8831 else if (unformat (i, "spray"))
8833 else if (unformat (i, "next %d", &sid))
8836 vec_add1 (segments, htonl (sid));
8840 clib_warning ("parse error '%U'", format_unformat_error, i);
8847 errmsg ("bsid not set");
8851 if (n_segments == 0)
8853 errmsg ("no sid in segment stack");
8857 /* Construct the API message */
8858 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8860 mp->bsid = htonl (bsid);
8861 mp->weight = htonl (weight);
8863 mp->n_segments = n_segments;
8864 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8865 vec_free (segments);
8870 /* Wait for a reply... */
8876 api_sr_mpls_policy_del (vat_main_t * vam)
8878 unformat_input_t *i = vam->input;
8879 vl_api_sr_mpls_policy_del_t *mp;
8883 /* Parse args required to build the message */
8884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8886 if (unformat (i, "bsid %d", &bsid))
8890 clib_warning ("parse error '%U'", format_unformat_error, i);
8897 errmsg ("bsid not set");
8901 /* Construct the API message */
8902 M (SR_MPLS_POLICY_DEL, mp);
8904 mp->bsid = htonl (bsid);
8909 /* Wait for a reply... */
8915 api_bier_table_add_del (vat_main_t * vam)
8917 unformat_input_t *i = vam->input;
8918 vl_api_bier_table_add_del_t *mp;
8920 u32 set = 0, sub_domain = 0, hdr_len = 3;
8921 mpls_label_t local_label = MPLS_LABEL_INVALID;
8924 /* Parse args required to build the message */
8925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8927 if (unformat (i, "sub-domain %d", &sub_domain))
8929 else if (unformat (i, "set %d", &set))
8931 else if (unformat (i, "label %d", &local_label))
8933 else if (unformat (i, "hdr-len %d", &hdr_len))
8935 else if (unformat (i, "add"))
8937 else if (unformat (i, "del"))
8941 clib_warning ("parse error '%U'", format_unformat_error, i);
8946 if (MPLS_LABEL_INVALID == local_label)
8948 errmsg ("missing label\n");
8952 /* Construct the API message */
8953 M (BIER_TABLE_ADD_DEL, mp);
8955 mp->bt_is_add = is_add;
8956 mp->bt_label = ntohl (local_label);
8957 mp->bt_tbl_id.bt_set = set;
8958 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8959 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8964 /* Wait for a reply... */
8971 api_bier_route_add_del (vat_main_t * vam)
8973 unformat_input_t *i = vam->input;
8974 vl_api_bier_route_add_del_t *mp;
8976 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8977 ip4_address_t v4_next_hop_address;
8978 ip6_address_t v6_next_hop_address;
8979 u8 next_hop_set = 0;
8980 u8 next_hop_proto_is_ip4 = 1;
8981 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8984 /* Parse args required to build the message */
8985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8987 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8989 next_hop_proto_is_ip4 = 1;
8992 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8994 next_hop_proto_is_ip4 = 0;
8997 if (unformat (i, "sub-domain %d", &sub_domain))
8999 else if (unformat (i, "set %d", &set))
9001 else if (unformat (i, "hdr-len %d", &hdr_len))
9003 else if (unformat (i, "bp %d", &bp))
9005 else if (unformat (i, "add"))
9007 else if (unformat (i, "del"))
9009 else if (unformat (i, "out-label %d", &next_hop_out_label))
9013 clib_warning ("parse error '%U'", format_unformat_error, i);
9018 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9020 errmsg ("next hop / label set\n");
9025 errmsg ("bit=position not set\n");
9029 /* Construct the API message */
9030 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9032 mp->br_is_add = is_add;
9033 mp->br_tbl_id.bt_set = set;
9034 mp->br_tbl_id.bt_sub_domain = sub_domain;
9035 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9036 mp->br_bp = ntohs (bp);
9038 mp->br_paths[0].n_labels = 1;
9039 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9040 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9042 if (next_hop_proto_is_ip4)
9044 clib_memcpy (mp->br_paths[0].next_hop,
9045 &v4_next_hop_address, sizeof (v4_next_hop_address));
9049 clib_memcpy (mp->br_paths[0].next_hop,
9050 &v6_next_hop_address, sizeof (v6_next_hop_address));
9056 /* Wait for a reply... */
9063 api_proxy_arp_add_del (vat_main_t * vam)
9065 unformat_input_t *i = vam->input;
9066 vl_api_proxy_arp_add_del_t *mp;
9069 vl_api_ip4_address_t lo, hi;
9073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9075 if (unformat (i, "vrf %d", &vrf_id))
9077 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
9078 unformat_vl_api_ip4_address, &hi))
9080 else if (unformat (i, "del"))
9084 clib_warning ("parse error '%U'", format_unformat_error, i);
9091 errmsg ("address range not set");
9095 M (PROXY_ARP_ADD_DEL, mp);
9097 mp->proxy.table_id = ntohl (vrf_id);
9098 mp->is_add = is_add;
9099 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
9100 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
9108 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9110 unformat_input_t *i = vam->input;
9111 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9114 u8 sw_if_index_set = 0;
9117 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9119 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9120 sw_if_index_set = 1;
9121 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9122 sw_if_index_set = 1;
9123 else if (unformat (i, "enable"))
9125 else if (unformat (i, "disable"))
9129 clib_warning ("parse error '%U'", format_unformat_error, i);
9134 if (sw_if_index_set == 0)
9136 errmsg ("missing interface name or sw_if_index");
9140 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9142 mp->sw_if_index = ntohl (sw_if_index);
9143 mp->enable_disable = enable;
9151 api_mpls_tunnel_add_del (vat_main_t * vam)
9153 unformat_input_t *i = vam->input;
9154 vl_api_mpls_tunnel_add_del_t *mp;
9158 u32 sw_if_index = ~0;
9159 u32 next_hop_sw_if_index = ~0;
9160 u32 next_hop_proto_is_ip4 = 1;
9162 u32 next_hop_table_id = 0;
9163 ip4_address_t v4_next_hop_address = {
9166 ip6_address_t v6_next_hop_address = { {0} };
9167 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9168 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9169 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9172 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9174 if (unformat (i, "add"))
9178 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9180 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9182 else if (unformat (i, "via %U",
9183 unformat_ip4_address, &v4_next_hop_address))
9185 next_hop_proto_is_ip4 = 1;
9187 else if (unformat (i, "via %U",
9188 unformat_ip6_address, &v6_next_hop_address))
9190 next_hop_proto_is_ip4 = 0;
9192 else if (unformat (i, "via-label %d", &next_hop_via_label))
9196 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9198 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9200 else if (unformat (i, "l2-only"))
9202 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9204 else if (unformat (i, "out-label %d", &next_hop_out_label))
9206 vl_api_fib_mpls_label_t fib_label = {
9207 .label = ntohl (next_hop_out_label),
9211 vec_add1 (next_hop_out_label_stack, fib_label);
9215 clib_warning ("parse error '%U'", format_unformat_error, i);
9220 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9221 vec_len (next_hop_out_label_stack));
9223 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9224 mp->mt_sw_if_index = ntohl (sw_if_index);
9225 mp->mt_is_add = is_add;
9226 mp->mt_l2_only = l2_only;
9227 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9228 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9229 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9230 mp->mt_next_hop_weight = 1;
9231 mp->mt_next_hop_preference = 0;
9233 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9235 if (0 != mp->mt_next_hop_n_out_labels)
9237 clib_memcpy (mp->mt_next_hop_out_label_stack,
9238 next_hop_out_label_stack,
9239 (vec_len (next_hop_out_label_stack) *
9240 sizeof (vl_api_fib_mpls_label_t)));
9241 vec_free (next_hop_out_label_stack);
9244 if (next_hop_proto_is_ip4)
9246 clib_memcpy (mp->mt_next_hop,
9247 &v4_next_hop_address, sizeof (v4_next_hop_address));
9251 clib_memcpy (mp->mt_next_hop,
9252 &v6_next_hop_address, sizeof (v6_next_hop_address));
9261 api_sw_interface_set_unnumbered (vat_main_t * vam)
9263 unformat_input_t *i = vam->input;
9264 vl_api_sw_interface_set_unnumbered_t *mp;
9266 u32 unnum_sw_index = ~0;
9268 u8 sw_if_index_set = 0;
9271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9274 sw_if_index_set = 1;
9275 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9276 sw_if_index_set = 1;
9277 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9279 else if (unformat (i, "del"))
9283 clib_warning ("parse error '%U'", format_unformat_error, i);
9288 if (sw_if_index_set == 0)
9290 errmsg ("missing interface name or sw_if_index");
9294 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9296 mp->sw_if_index = ntohl (sw_if_index);
9297 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9298 mp->is_add = is_add;
9306 api_ip_neighbor_add_del (vat_main_t * vam)
9308 vl_api_mac_address_t mac_address;
9309 unformat_input_t *i = vam->input;
9310 vl_api_ip_neighbor_add_del_t *mp;
9311 vl_api_address_t ip_address;
9313 u8 sw_if_index_set = 0;
9318 ip_neighbor_flags_t flags;
9320 flags = IP_NEIGHBOR_FLAG_NONE;
9321 clib_memset (&ip_address, 0, sizeof (ip_address));
9322 clib_memset (&mac_address, 0, sizeof (mac_address));
9323 /* Parse args required to build the message */
9324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9326 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9330 else if (unformat (i, "del"))
9333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9334 sw_if_index_set = 1;
9335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9336 sw_if_index_set = 1;
9337 else if (unformat (i, "static"))
9338 flags |= IP_NEIGHBOR_FLAG_STATIC;
9339 else if (unformat (i, "no-fib-entry"))
9340 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9341 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9345 clib_warning ("parse error '%U'", format_unformat_error, i);
9350 if (sw_if_index_set == 0)
9352 errmsg ("missing interface name or sw_if_index");
9357 errmsg ("no address set");
9361 /* Construct the API message */
9362 M (IP_NEIGHBOR_ADD_DEL, mp);
9364 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9365 mp->is_add = is_add;
9366 mp->neighbor.flags = htonl (flags);
9368 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9369 sizeof (mac_address));
9371 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9376 /* Wait for a reply, return good/bad news */
9382 api_create_vlan_subif (vat_main_t * vam)
9384 unformat_input_t *i = vam->input;
9385 vl_api_create_vlan_subif_t *mp;
9387 u8 sw_if_index_set = 0;
9392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9394 if (unformat (i, "sw_if_index %d", &sw_if_index))
9395 sw_if_index_set = 1;
9397 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9398 sw_if_index_set = 1;
9399 else if (unformat (i, "vlan %d", &vlan_id))
9403 clib_warning ("parse error '%U'", format_unformat_error, i);
9408 if (sw_if_index_set == 0)
9410 errmsg ("missing interface name or sw_if_index");
9414 if (vlan_id_set == 0)
9416 errmsg ("missing vlan_id");
9419 M (CREATE_VLAN_SUBIF, mp);
9421 mp->sw_if_index = ntohl (sw_if_index);
9422 mp->vlan_id = ntohl (vlan_id);
9429 #define foreach_create_subif_bit \
9436 _(outer_vlan_id_any) \
9437 _(inner_vlan_id_any)
9440 api_create_subif (vat_main_t * vam)
9442 unformat_input_t *i = vam->input;
9443 vl_api_create_subif_t *mp;
9445 u8 sw_if_index_set = 0;
9452 u32 exact_match = 0;
9453 u32 default_sub = 0;
9454 u32 outer_vlan_id_any = 0;
9455 u32 inner_vlan_id_any = 0;
9457 u16 outer_vlan_id = 0;
9458 u16 inner_vlan_id = 0;
9461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9463 if (unformat (i, "sw_if_index %d", &sw_if_index))
9464 sw_if_index_set = 1;
9466 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9467 sw_if_index_set = 1;
9468 else if (unformat (i, "sub_id %d", &sub_id))
9470 else if (unformat (i, "outer_vlan_id %d", &tmp))
9471 outer_vlan_id = tmp;
9472 else if (unformat (i, "inner_vlan_id %d", &tmp))
9473 inner_vlan_id = tmp;
9475 #define _(a) else if (unformat (i, #a)) a = 1 ;
9476 foreach_create_subif_bit
9480 clib_warning ("parse error '%U'", format_unformat_error, i);
9485 if (sw_if_index_set == 0)
9487 errmsg ("missing interface name or sw_if_index");
9491 if (sub_id_set == 0)
9493 errmsg ("missing sub_id");
9496 M (CREATE_SUBIF, mp);
9498 mp->sw_if_index = ntohl (sw_if_index);
9499 mp->sub_id = ntohl (sub_id);
9501 #define _(a) mp->a = a;
9502 foreach_create_subif_bit;
9505 mp->outer_vlan_id = ntohs (outer_vlan_id);
9506 mp->inner_vlan_id = ntohs (inner_vlan_id);
9514 api_oam_add_del (vat_main_t * vam)
9516 unformat_input_t *i = vam->input;
9517 vl_api_oam_add_del_t *mp;
9520 ip4_address_t src, dst;
9525 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9527 if (unformat (i, "vrf %d", &vrf_id))
9529 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9531 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9533 else if (unformat (i, "del"))
9537 clib_warning ("parse error '%U'", format_unformat_error, i);
9544 errmsg ("missing src addr");
9550 errmsg ("missing dst addr");
9554 M (OAM_ADD_DEL, mp);
9556 mp->vrf_id = ntohl (vrf_id);
9557 mp->is_add = is_add;
9558 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9559 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9567 api_reset_fib (vat_main_t * vam)
9569 unformat_input_t *i = vam->input;
9570 vl_api_reset_fib_t *mp;
9576 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9578 if (unformat (i, "vrf %d", &vrf_id))
9580 else if (unformat (i, "ipv6"))
9584 clib_warning ("parse error '%U'", format_unformat_error, i);
9589 if (vrf_id_set == 0)
9591 errmsg ("missing vrf id");
9597 mp->vrf_id = ntohl (vrf_id);
9598 mp->is_ipv6 = is_ipv6;
9606 api_dhcp_proxy_config (vat_main_t * vam)
9608 unformat_input_t *i = vam->input;
9609 vl_api_dhcp_proxy_config_t *mp;
9611 u32 server_vrf_id = 0;
9613 u8 v4_address_set = 0;
9614 u8 v6_address_set = 0;
9615 ip4_address_t v4address;
9616 ip6_address_t v6address;
9617 u8 v4_src_address_set = 0;
9618 u8 v6_src_address_set = 0;
9619 ip4_address_t v4srcaddress;
9620 ip6_address_t v6srcaddress;
9623 /* Parse args required to build the message */
9624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9626 if (unformat (i, "del"))
9628 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9630 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9632 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9634 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9636 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9637 v4_src_address_set = 1;
9638 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9639 v6_src_address_set = 1;
9644 if (v4_address_set && v6_address_set)
9646 errmsg ("both v4 and v6 server addresses set");
9649 if (!v4_address_set && !v6_address_set)
9651 errmsg ("no server addresses set");
9655 if (v4_src_address_set && v6_src_address_set)
9657 errmsg ("both v4 and v6 src addresses set");
9660 if (!v4_src_address_set && !v6_src_address_set)
9662 errmsg ("no src addresses set");
9666 if (!(v4_src_address_set && v4_address_set) &&
9667 !(v6_src_address_set && v6_address_set))
9669 errmsg ("no matching server and src addresses set");
9673 /* Construct the API message */
9674 M (DHCP_PROXY_CONFIG, mp);
9676 mp->is_add = is_add;
9677 mp->rx_vrf_id = ntohl (rx_vrf_id);
9678 mp->server_vrf_id = ntohl (server_vrf_id);
9682 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9683 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9687 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9688 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9694 /* Wait for a reply, return good/bad news */
9699 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9700 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9703 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9705 vat_main_t *vam = &vat_main;
9706 u32 i, count = mp->count;
9707 vl_api_dhcp_server_t *s;
9711 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9712 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9713 ntohl (mp->rx_vrf_id),
9714 format_ip6_address, mp->dhcp_src_address,
9715 mp->vss_type, mp->vss_vpn_ascii_id,
9716 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9719 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9720 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9721 ntohl (mp->rx_vrf_id),
9722 format_ip4_address, mp->dhcp_src_address,
9723 mp->vss_type, mp->vss_vpn_ascii_id,
9724 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9726 for (i = 0; i < count; i++)
9728 s = &mp->servers[i];
9732 " Server Table-ID %d, Server Address %U",
9733 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9736 " Server Table-ID %d, Server Address %U",
9737 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9741 static void vl_api_dhcp_proxy_details_t_handler_json
9742 (vl_api_dhcp_proxy_details_t * mp)
9744 vat_main_t *vam = &vat_main;
9745 vat_json_node_t *node = NULL;
9746 u32 i, count = mp->count;
9748 struct in6_addr ip6;
9749 vl_api_dhcp_server_t *s;
9751 if (VAT_JSON_ARRAY != vam->json_tree.type)
9753 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9754 vat_json_init_array (&vam->json_tree);
9756 node = vat_json_array_add (&vam->json_tree);
9758 vat_json_init_object (node);
9759 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9760 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9761 sizeof (mp->vss_type));
9762 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9763 mp->vss_vpn_ascii_id);
9764 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9765 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9769 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9770 vat_json_object_add_ip6 (node, "src_address", ip6);
9774 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9775 vat_json_object_add_ip4 (node, "src_address", ip4);
9778 for (i = 0; i < count; i++)
9780 s = &mp->servers[i];
9782 vat_json_object_add_uint (node, "server-table-id",
9783 ntohl (s->server_vrf_id));
9787 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9788 vat_json_object_add_ip4 (node, "src_address", ip4);
9792 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9793 vat_json_object_add_ip6 (node, "server_address", ip6);
9799 api_dhcp_proxy_dump (vat_main_t * vam)
9801 unformat_input_t *i = vam->input;
9802 vl_api_control_ping_t *mp_ping;
9803 vl_api_dhcp_proxy_dump_t *mp;
9807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9809 if (unformat (i, "ipv6"))
9813 clib_warning ("parse error '%U'", format_unformat_error, i);
9818 M (DHCP_PROXY_DUMP, mp);
9820 mp->is_ip6 = is_ipv6;
9823 /* Use a control ping for synchronization */
9824 MPING (CONTROL_PING, mp_ping);
9832 api_dhcp_proxy_set_vss (vat_main_t * vam)
9834 unformat_input_t *i = vam->input;
9835 vl_api_dhcp_proxy_set_vss_t *mp;
9839 u8 vss_type = VSS_TYPE_DEFAULT;
9840 u8 *vpn_ascii_id = 0;
9845 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9847 if (unformat (i, "tbl_id %d", &tbl_id))
9849 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9850 vss_type = VSS_TYPE_ASCII;
9851 else if (unformat (i, "fib_id %d", &fib_id))
9852 vss_type = VSS_TYPE_VPN_ID;
9853 else if (unformat (i, "oui %d", &oui))
9854 vss_type = VSS_TYPE_VPN_ID;
9855 else if (unformat (i, "ipv6"))
9857 else if (unformat (i, "del"))
9865 errmsg ("missing tbl_id ");
9866 vec_free (vpn_ascii_id);
9870 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9872 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9873 vec_free (vpn_ascii_id);
9877 M (DHCP_PROXY_SET_VSS, mp);
9878 mp->tbl_id = ntohl (tbl_id);
9879 mp->vss_type = vss_type;
9882 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9883 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9885 mp->vpn_index = ntohl (fib_id);
9886 mp->oui = ntohl (oui);
9887 mp->is_ipv6 = is_ipv6;
9888 mp->is_add = is_add;
9893 vec_free (vpn_ascii_id);
9898 api_dhcp_client_config (vat_main_t * vam)
9900 unformat_input_t *i = vam->input;
9901 vl_api_dhcp_client_config_t *mp;
9903 u8 sw_if_index_set = 0;
9906 u8 disable_event = 0;
9909 /* Parse args required to build the message */
9910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9912 if (unformat (i, "del"))
9915 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9916 sw_if_index_set = 1;
9917 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9918 sw_if_index_set = 1;
9919 else if (unformat (i, "hostname %s", &hostname))
9921 else if (unformat (i, "disable_event"))
9927 if (sw_if_index_set == 0)
9929 errmsg ("missing interface name or sw_if_index");
9933 if (vec_len (hostname) > 63)
9935 errmsg ("hostname too long");
9937 vec_add1 (hostname, 0);
9939 /* Construct the API message */
9940 M (DHCP_CLIENT_CONFIG, mp);
9942 mp->is_add = is_add;
9943 mp->client.sw_if_index = htonl (sw_if_index);
9944 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9945 vec_free (hostname);
9946 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9947 mp->client.pid = htonl (getpid ());
9952 /* Wait for a reply, return good/bad news */
9958 api_set_ip_flow_hash (vat_main_t * vam)
9960 unformat_input_t *i = vam->input;
9961 vl_api_set_ip_flow_hash_t *mp;
9973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9975 if (unformat (i, "vrf %d", &vrf_id))
9977 else if (unformat (i, "ipv6"))
9979 else if (unformat (i, "src"))
9981 else if (unformat (i, "dst"))
9983 else if (unformat (i, "sport"))
9985 else if (unformat (i, "dport"))
9987 else if (unformat (i, "proto"))
9989 else if (unformat (i, "reverse"))
9994 clib_warning ("parse error '%U'", format_unformat_error, i);
9999 if (vrf_id_set == 0)
10001 errmsg ("missing vrf id");
10005 M (SET_IP_FLOW_HASH, mp);
10011 mp->reverse = reverse;
10012 mp->vrf_id = ntohl (vrf_id);
10013 mp->is_ipv6 = is_ipv6;
10021 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10023 unformat_input_t *i = vam->input;
10024 vl_api_sw_interface_ip6_enable_disable_t *mp;
10026 u8 sw_if_index_set = 0;
10030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10032 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10033 sw_if_index_set = 1;
10034 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10035 sw_if_index_set = 1;
10036 else if (unformat (i, "enable"))
10038 else if (unformat (i, "disable"))
10042 clib_warning ("parse error '%U'", format_unformat_error, i);
10047 if (sw_if_index_set == 0)
10049 errmsg ("missing interface name or sw_if_index");
10053 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10055 mp->sw_if_index = ntohl (sw_if_index);
10056 mp->enable = enable;
10064 api_ip6nd_proxy_add_del (vat_main_t * vam)
10066 unformat_input_t *i = vam->input;
10067 vl_api_ip6nd_proxy_add_del_t *mp;
10068 u32 sw_if_index = ~0;
10069 u8 v6_address_set = 0;
10070 vl_api_ip6_address_t v6address;
10074 /* Parse args required to build the message */
10075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10077 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10079 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10081 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
10082 v6_address_set = 1;
10083 if (unformat (i, "del"))
10087 clib_warning ("parse error '%U'", format_unformat_error, i);
10092 if (sw_if_index == ~0)
10094 errmsg ("missing interface name or sw_if_index");
10097 if (!v6_address_set)
10099 errmsg ("no address set");
10103 /* Construct the API message */
10104 M (IP6ND_PROXY_ADD_DEL, mp);
10106 mp->is_del = is_del;
10107 mp->sw_if_index = ntohl (sw_if_index);
10108 clib_memcpy (mp->ip, v6address, sizeof (v6address));
10113 /* Wait for a reply, return good/bad news */
10119 api_ip6nd_proxy_dump (vat_main_t * vam)
10121 vl_api_ip6nd_proxy_dump_t *mp;
10122 vl_api_control_ping_t *mp_ping;
10125 M (IP6ND_PROXY_DUMP, mp);
10129 /* Use a control ping for synchronization */
10130 MPING (CONTROL_PING, mp_ping);
10137 static void vl_api_ip6nd_proxy_details_t_handler
10138 (vl_api_ip6nd_proxy_details_t * mp)
10140 vat_main_t *vam = &vat_main;
10142 print (vam->ofp, "host %U sw_if_index %d",
10143 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
10146 static void vl_api_ip6nd_proxy_details_t_handler_json
10147 (vl_api_ip6nd_proxy_details_t * mp)
10149 vat_main_t *vam = &vat_main;
10150 struct in6_addr ip6;
10151 vat_json_node_t *node = NULL;
10153 if (VAT_JSON_ARRAY != vam->json_tree.type)
10155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10156 vat_json_init_array (&vam->json_tree);
10158 node = vat_json_array_add (&vam->json_tree);
10160 vat_json_init_object (node);
10161 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10163 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
10164 vat_json_object_add_ip6 (node, "host", ip6);
10168 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10170 unformat_input_t *i = vam->input;
10171 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10173 u8 sw_if_index_set = 0;
10174 u32 address_length = 0;
10175 u8 v6_address_set = 0;
10176 vl_api_prefix_t pfx;
10177 u8 use_default = 0;
10178 u8 no_advertise = 0;
10180 u8 no_autoconfig = 0;
10183 u32 val_lifetime = 0;
10184 u32 pref_lifetime = 0;
10187 /* Parse args required to build the message */
10188 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10190 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10191 sw_if_index_set = 1;
10192 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10193 sw_if_index_set = 1;
10194 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
10195 v6_address_set = 1;
10196 else if (unformat (i, "val_life %d", &val_lifetime))
10198 else if (unformat (i, "pref_life %d", &pref_lifetime))
10200 else if (unformat (i, "def"))
10202 else if (unformat (i, "noadv"))
10204 else if (unformat (i, "offl"))
10206 else if (unformat (i, "noauto"))
10208 else if (unformat (i, "nolink"))
10210 else if (unformat (i, "isno"))
10214 clib_warning ("parse error '%U'", format_unformat_error, i);
10219 if (sw_if_index_set == 0)
10221 errmsg ("missing interface name or sw_if_index");
10224 if (!v6_address_set)
10226 errmsg ("no address set");
10230 /* Construct the API message */
10231 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10233 mp->sw_if_index = ntohl (sw_if_index);
10234 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
10235 mp->use_default = use_default;
10236 mp->no_advertise = no_advertise;
10237 mp->off_link = off_link;
10238 mp->no_autoconfig = no_autoconfig;
10239 mp->no_onlink = no_onlink;
10241 mp->val_lifetime = ntohl (val_lifetime);
10242 mp->pref_lifetime = ntohl (pref_lifetime);
10247 /* Wait for a reply, return good/bad news */
10253 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10255 unformat_input_t *i = vam->input;
10256 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10258 u8 sw_if_index_set = 0;
10263 u8 send_unicast = 0;
10266 u8 default_router = 0;
10267 u32 max_interval = 0;
10268 u32 min_interval = 0;
10270 u32 initial_count = 0;
10271 u32 initial_interval = 0;
10275 /* Parse args required to build the message */
10276 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10278 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10279 sw_if_index_set = 1;
10280 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10281 sw_if_index_set = 1;
10282 else if (unformat (i, "maxint %d", &max_interval))
10284 else if (unformat (i, "minint %d", &min_interval))
10286 else if (unformat (i, "life %d", &lifetime))
10288 else if (unformat (i, "count %d", &initial_count))
10290 else if (unformat (i, "interval %d", &initial_interval))
10292 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10294 else if (unformat (i, "managed"))
10296 else if (unformat (i, "other"))
10298 else if (unformat (i, "ll"))
10300 else if (unformat (i, "send"))
10302 else if (unformat (i, "cease"))
10304 else if (unformat (i, "isno"))
10306 else if (unformat (i, "def"))
10307 default_router = 1;
10310 clib_warning ("parse error '%U'", format_unformat_error, i);
10315 if (sw_if_index_set == 0)
10317 errmsg ("missing interface name or sw_if_index");
10321 /* Construct the API message */
10322 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10324 mp->sw_if_index = ntohl (sw_if_index);
10325 mp->max_interval = ntohl (max_interval);
10326 mp->min_interval = ntohl (min_interval);
10327 mp->lifetime = ntohl (lifetime);
10328 mp->initial_count = ntohl (initial_count);
10329 mp->initial_interval = ntohl (initial_interval);
10330 mp->suppress = suppress;
10331 mp->managed = managed;
10333 mp->ll_option = ll_option;
10334 mp->send_unicast = send_unicast;
10337 mp->default_router = default_router;
10342 /* Wait for a reply, return good/bad news */
10348 api_set_arp_neighbor_limit (vat_main_t * vam)
10350 unformat_input_t *i = vam->input;
10351 vl_api_set_arp_neighbor_limit_t *mp;
10357 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10359 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10361 else if (unformat (i, "ipv6"))
10365 clib_warning ("parse error '%U'", format_unformat_error, i);
10370 if (limit_set == 0)
10372 errmsg ("missing limit value");
10376 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10378 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10379 mp->is_ipv6 = is_ipv6;
10387 api_l2_patch_add_del (vat_main_t * vam)
10389 unformat_input_t *i = vam->input;
10390 vl_api_l2_patch_add_del_t *mp;
10391 u32 rx_sw_if_index;
10392 u8 rx_sw_if_index_set = 0;
10393 u32 tx_sw_if_index;
10394 u8 tx_sw_if_index_set = 0;
10398 /* Parse args required to build the message */
10399 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10401 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10402 rx_sw_if_index_set = 1;
10403 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10404 tx_sw_if_index_set = 1;
10405 else if (unformat (i, "rx"))
10407 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10409 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10411 rx_sw_if_index_set = 1;
10416 else if (unformat (i, "tx"))
10418 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10420 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10422 tx_sw_if_index_set = 1;
10427 else if (unformat (i, "del"))
10433 if (rx_sw_if_index_set == 0)
10435 errmsg ("missing rx interface name or rx_sw_if_index");
10439 if (tx_sw_if_index_set == 0)
10441 errmsg ("missing tx interface name or tx_sw_if_index");
10445 M (L2_PATCH_ADD_DEL, mp);
10447 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10448 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10449 mp->is_add = is_add;
10457 u8 localsid_addr[16];
10466 api_sr_localsid_add_del (vat_main_t * vam)
10468 unformat_input_t *i = vam->input;
10469 vl_api_sr_localsid_add_del_t *mp;
10472 ip6_address_t localsid;
10476 u32 fib_table = ~(u32) 0;
10477 ip6_address_t nh_addr6;
10478 ip4_address_t nh_addr4;
10479 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10480 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10482 bool nexthop_set = 0;
10486 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10488 if (unformat (i, "del"))
10490 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10491 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10493 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10495 else if (unformat (i, "behavior %u", &behavior));
10496 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10497 else if (unformat (i, "fib-table %u", &fib_table));
10498 else if (unformat (i, "end.psp %u", &behavior));
10503 M (SR_LOCALSID_ADD_DEL, mp);
10505 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10508 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10509 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10511 mp->behavior = behavior;
10512 mp->sw_if_index = ntohl (sw_if_index);
10513 mp->fib_table = ntohl (fib_table);
10514 mp->end_psp = end_psp;
10515 mp->is_del = is_del;
10523 api_ioam_enable (vat_main_t * vam)
10525 unformat_input_t *input = vam->input;
10526 vl_api_ioam_enable_t *mp;
10528 int has_trace_option = 0;
10529 int has_pot_option = 0;
10530 int has_seqno_option = 0;
10531 int has_analyse_option = 0;
10534 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10536 if (unformat (input, "trace"))
10537 has_trace_option = 1;
10538 else if (unformat (input, "pot"))
10539 has_pot_option = 1;
10540 else if (unformat (input, "seqno"))
10541 has_seqno_option = 1;
10542 else if (unformat (input, "analyse"))
10543 has_analyse_option = 1;
10547 M (IOAM_ENABLE, mp);
10548 mp->id = htons (id);
10549 mp->seqno = has_seqno_option;
10550 mp->analyse = has_analyse_option;
10551 mp->pot_enable = has_pot_option;
10552 mp->trace_enable = has_trace_option;
10561 api_ioam_disable (vat_main_t * vam)
10563 vl_api_ioam_disable_t *mp;
10566 M (IOAM_DISABLE, mp);
10572 #define foreach_tcp_proto_field \
10576 #define foreach_udp_proto_field \
10580 #define foreach_ip4_proto_field \
10592 u16 src_port, dst_port;
10595 #if VPP_API_TEST_BUILTIN == 0
10597 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10599 u8 **maskp = va_arg (*args, u8 **);
10601 u8 found_something = 0;
10604 #define _(a) u8 a=0;
10605 foreach_tcp_proto_field;
10608 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10611 #define _(a) else if (unformat (input, #a)) a=1;
10612 foreach_tcp_proto_field
10618 #define _(a) found_something += a;
10619 foreach_tcp_proto_field;
10622 if (found_something == 0)
10625 vec_validate (mask, sizeof (*tcp) - 1);
10627 tcp = (tcp_header_t *) mask;
10629 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10630 foreach_tcp_proto_field;
10638 unformat_udp_mask (unformat_input_t * input, va_list * args)
10640 u8 **maskp = va_arg (*args, u8 **);
10642 u8 found_something = 0;
10645 #define _(a) u8 a=0;
10646 foreach_udp_proto_field;
10649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10652 #define _(a) else if (unformat (input, #a)) a=1;
10653 foreach_udp_proto_field
10659 #define _(a) found_something += a;
10660 foreach_udp_proto_field;
10663 if (found_something == 0)
10666 vec_validate (mask, sizeof (*udp) - 1);
10668 udp = (udp_header_t *) mask;
10670 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10671 foreach_udp_proto_field;
10679 unformat_l4_mask (unformat_input_t * input, va_list * args)
10681 u8 **maskp = va_arg (*args, u8 **);
10682 u16 src_port = 0, dst_port = 0;
10683 tcpudp_header_t *tcpudp;
10685 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10687 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10689 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10691 else if (unformat (input, "src_port"))
10693 else if (unformat (input, "dst_port"))
10699 if (!src_port && !dst_port)
10703 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10705 tcpudp = (tcpudp_header_t *) mask;
10706 tcpudp->src_port = src_port;
10707 tcpudp->dst_port = dst_port;
10715 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10717 u8 **maskp = va_arg (*args, u8 **);
10719 u8 found_something = 0;
10722 #define _(a) u8 a=0;
10723 foreach_ip4_proto_field;
10729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10731 if (unformat (input, "version"))
10733 else if (unformat (input, "hdr_length"))
10735 else if (unformat (input, "src"))
10737 else if (unformat (input, "dst"))
10739 else if (unformat (input, "proto"))
10742 #define _(a) else if (unformat (input, #a)) a=1;
10743 foreach_ip4_proto_field
10749 #define _(a) found_something += a;
10750 foreach_ip4_proto_field;
10753 if (found_something == 0)
10756 vec_validate (mask, sizeof (*ip) - 1);
10758 ip = (ip4_header_t *) mask;
10760 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10761 foreach_ip4_proto_field;
10764 ip->ip_version_and_header_length = 0;
10767 ip->ip_version_and_header_length |= 0xF0;
10770 ip->ip_version_and_header_length |= 0x0F;
10776 #define foreach_ip6_proto_field \
10779 _(payload_length) \
10784 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10786 u8 **maskp = va_arg (*args, u8 **);
10788 u8 found_something = 0;
10790 u32 ip_version_traffic_class_and_flow_label;
10792 #define _(a) u8 a=0;
10793 foreach_ip6_proto_field;
10796 u8 traffic_class = 0;
10799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10801 if (unformat (input, "version"))
10803 else if (unformat (input, "traffic-class"))
10805 else if (unformat (input, "flow-label"))
10807 else if (unformat (input, "src"))
10809 else if (unformat (input, "dst"))
10811 else if (unformat (input, "proto"))
10814 #define _(a) else if (unformat (input, #a)) a=1;
10815 foreach_ip6_proto_field
10821 #define _(a) found_something += a;
10822 foreach_ip6_proto_field;
10825 if (found_something == 0)
10828 vec_validate (mask, sizeof (*ip) - 1);
10830 ip = (ip6_header_t *) mask;
10832 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10833 foreach_ip6_proto_field;
10836 ip_version_traffic_class_and_flow_label = 0;
10839 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10842 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10845 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10847 ip->ip_version_traffic_class_and_flow_label =
10848 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10855 unformat_l3_mask (unformat_input_t * input, va_list * args)
10857 u8 **maskp = va_arg (*args, u8 **);
10859 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10861 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10863 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10872 unformat_l2_mask (unformat_input_t * input, va_list * args)
10874 u8 **maskp = va_arg (*args, u8 **);
10881 u8 ignore_tag1 = 0;
10882 u8 ignore_tag2 = 0;
10889 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10891 if (unformat (input, "src"))
10893 else if (unformat (input, "dst"))
10895 else if (unformat (input, "proto"))
10897 else if (unformat (input, "tag1"))
10899 else if (unformat (input, "tag2"))
10901 else if (unformat (input, "ignore-tag1"))
10903 else if (unformat (input, "ignore-tag2"))
10905 else if (unformat (input, "cos1"))
10907 else if (unformat (input, "cos2"))
10909 else if (unformat (input, "dot1q"))
10911 else if (unformat (input, "dot1ad"))
10916 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10917 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10920 if (tag1 || ignore_tag1 || cos1 || dot1q)
10922 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10925 vec_validate (mask, len - 1);
10928 clib_memset (mask, 0xff, 6);
10931 clib_memset (mask + 6, 0xff, 6);
10933 if (tag2 || dot1ad)
10935 /* inner vlan tag */
10944 mask[21] = mask[20] = 0xff;
10965 mask[16] = mask[17] = 0xff;
10975 mask[12] = mask[13] = 0xff;
10982 unformat_classify_mask (unformat_input_t * input, va_list * args)
10984 u8 **maskp = va_arg (*args, u8 **);
10985 u32 *skipp = va_arg (*args, u32 *);
10986 u32 *matchp = va_arg (*args, u32 *);
10994 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10996 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10998 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11000 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11002 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11016 if (mask || l2 || l3 || l4)
11018 if (l2 || l3 || l4)
11020 /* "With a free Ethernet header in every package" */
11022 vec_validate (l2, 13);
11026 vec_append (mask, l3);
11031 vec_append (mask, l4);
11036 /* Scan forward looking for the first significant mask octet */
11037 for (i = 0; i < vec_len (mask); i++)
11041 /* compute (skip, match) params */
11042 *skipp = i / sizeof (u32x4);
11043 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11045 /* Pad mask to an even multiple of the vector size */
11046 while (vec_len (mask) % sizeof (u32x4))
11047 vec_add1 (mask, 0);
11049 match = vec_len (mask) / sizeof (u32x4);
11051 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11053 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11054 if (*tmp || *(tmp + 1))
11059 clib_warning ("BUG: match 0");
11061 _vec_len (mask) = match * sizeof (u32x4);
11071 #endif /* VPP_API_TEST_BUILTIN */
11073 #define foreach_l2_next \
11075 _(ethernet, ETHERNET_INPUT) \
11076 _(ip4, IP4_INPUT) \
11080 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11082 u32 *miss_next_indexp = va_arg (*args, u32 *);
11083 u32 next_index = 0;
11087 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11091 if (unformat (input, "%d", &tmp))
11100 *miss_next_indexp = next_index;
11104 #define foreach_ip_next \
11107 _(rewrite, REWRITE)
11110 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11112 u32 *miss_next_indexp = va_arg (*args, u32 *);
11113 u32 next_index = 0;
11117 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11121 if (unformat (input, "%d", &tmp))
11130 *miss_next_indexp = next_index;
11134 #define foreach_acl_next \
11138 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11140 u32 *miss_next_indexp = va_arg (*args, u32 *);
11141 u32 next_index = 0;
11145 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11149 if (unformat (input, "permit"))
11154 else if (unformat (input, "%d", &tmp))
11163 *miss_next_indexp = next_index;
11168 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11170 u32 *r = va_arg (*args, u32 *);
11172 if (unformat (input, "conform-color"))
11173 *r = POLICE_CONFORM;
11174 else if (unformat (input, "exceed-color"))
11175 *r = POLICE_EXCEED;
11183 api_classify_add_del_table (vat_main_t * vam)
11185 unformat_input_t *i = vam->input;
11186 vl_api_classify_add_del_table_t *mp;
11193 u32 table_index = ~0;
11194 u32 next_table_index = ~0;
11195 u32 miss_next_index = ~0;
11196 u32 memory_size = 32 << 20;
11198 u32 current_data_flag = 0;
11199 int current_data_offset = 0;
11202 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11204 if (unformat (i, "del"))
11206 else if (unformat (i, "del-chain"))
11211 else if (unformat (i, "buckets %d", &nbuckets))
11213 else if (unformat (i, "memory_size %d", &memory_size))
11215 else if (unformat (i, "skip %d", &skip))
11217 else if (unformat (i, "match %d", &match))
11219 else if (unformat (i, "table %d", &table_index))
11221 else if (unformat (i, "mask %U", unformat_classify_mask,
11222 &mask, &skip, &match))
11224 else if (unformat (i, "next-table %d", &next_table_index))
11226 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11229 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11232 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11235 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11237 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11243 if (is_add && mask == 0)
11245 errmsg ("Mask required");
11249 if (is_add && skip == ~0)
11251 errmsg ("skip count required");
11255 if (is_add && match == ~0)
11257 errmsg ("match count required");
11261 if (!is_add && table_index == ~0)
11263 errmsg ("table index required for delete");
11267 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11269 mp->is_add = is_add;
11270 mp->del_chain = del_chain;
11271 mp->table_index = ntohl (table_index);
11272 mp->nbuckets = ntohl (nbuckets);
11273 mp->memory_size = ntohl (memory_size);
11274 mp->skip_n_vectors = ntohl (skip);
11275 mp->match_n_vectors = ntohl (match);
11276 mp->next_table_index = ntohl (next_table_index);
11277 mp->miss_next_index = ntohl (miss_next_index);
11278 mp->current_data_flag = ntohl (current_data_flag);
11279 mp->current_data_offset = ntohl (current_data_offset);
11280 mp->mask_len = ntohl (vec_len (mask));
11281 clib_memcpy (mp->mask, mask, vec_len (mask));
11290 #if VPP_API_TEST_BUILTIN == 0
11292 unformat_l4_match (unformat_input_t * input, va_list * args)
11294 u8 **matchp = va_arg (*args, u8 **);
11296 u8 *proto_header = 0;
11302 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11304 if (unformat (input, "src_port %d", &src_port))
11306 else if (unformat (input, "dst_port %d", &dst_port))
11312 h.src_port = clib_host_to_net_u16 (src_port);
11313 h.dst_port = clib_host_to_net_u16 (dst_port);
11314 vec_validate (proto_header, sizeof (h) - 1);
11315 memcpy (proto_header, &h, sizeof (h));
11317 *matchp = proto_header;
11323 unformat_ip4_match (unformat_input_t * input, va_list * args)
11325 u8 **matchp = va_arg (*args, u8 **);
11330 int hdr_length = 0;
11331 u32 hdr_length_val;
11332 int src = 0, dst = 0;
11333 ip4_address_t src_val, dst_val;
11340 int fragment_id = 0;
11341 u32 fragment_id_val;
11347 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11349 if (unformat (input, "version %d", &version_val))
11351 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11353 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11355 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11357 else if (unformat (input, "proto %d", &proto_val))
11359 else if (unformat (input, "tos %d", &tos_val))
11361 else if (unformat (input, "length %d", &length_val))
11363 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11365 else if (unformat (input, "ttl %d", &ttl_val))
11367 else if (unformat (input, "checksum %d", &checksum_val))
11373 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11374 + ttl + checksum == 0)
11378 * Aligned because we use the real comparison functions
11380 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11382 ip = (ip4_header_t *) match;
11384 /* These are realistically matched in practice */
11386 ip->src_address.as_u32 = src_val.as_u32;
11389 ip->dst_address.as_u32 = dst_val.as_u32;
11392 ip->protocol = proto_val;
11395 /* These are not, but they're included for completeness */
11397 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11400 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11406 ip->length = clib_host_to_net_u16 (length_val);
11412 ip->checksum = clib_host_to_net_u16 (checksum_val);
11419 unformat_ip6_match (unformat_input_t * input, va_list * args)
11421 u8 **matchp = va_arg (*args, u8 **);
11426 u8 traffic_class = 0;
11427 u32 traffic_class_val = 0;
11430 int src = 0, dst = 0;
11431 ip6_address_t src_val, dst_val;
11434 int payload_length = 0;
11435 u32 payload_length_val;
11438 u32 ip_version_traffic_class_and_flow_label;
11440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11442 if (unformat (input, "version %d", &version_val))
11444 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11446 else if (unformat (input, "flow_label %d", &flow_label_val))
11448 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11450 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11452 else if (unformat (input, "proto %d", &proto_val))
11454 else if (unformat (input, "payload_length %d", &payload_length_val))
11455 payload_length = 1;
11456 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11462 if (version + traffic_class + flow_label + src + dst + proto +
11463 payload_length + hop_limit == 0)
11467 * Aligned because we use the real comparison functions
11469 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11471 ip = (ip6_header_t *) match;
11474 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11477 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11480 ip->protocol = proto_val;
11482 ip_version_traffic_class_and_flow_label = 0;
11485 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11488 ip_version_traffic_class_and_flow_label |=
11489 (traffic_class_val & 0xFF) << 20;
11492 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11494 ip->ip_version_traffic_class_and_flow_label =
11495 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11497 if (payload_length)
11498 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11501 ip->hop_limit = hop_limit_val;
11508 unformat_l3_match (unformat_input_t * input, va_list * args)
11510 u8 **matchp = va_arg (*args, u8 **);
11512 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11514 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11516 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11525 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11527 u8 *tagp = va_arg (*args, u8 *);
11530 if (unformat (input, "%d", &tag))
11532 tagp[0] = (tag >> 8) & 0x0F;
11533 tagp[1] = tag & 0xFF;
11541 unformat_l2_match (unformat_input_t * input, va_list * args)
11543 u8 **matchp = va_arg (*args, u8 **);
11556 u8 ignore_tag1 = 0;
11557 u8 ignore_tag2 = 0;
11563 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11565 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11568 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11570 else if (unformat (input, "proto %U",
11571 unformat_ethernet_type_host_byte_order, &proto_val))
11573 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11575 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11577 else if (unformat (input, "ignore-tag1"))
11579 else if (unformat (input, "ignore-tag2"))
11581 else if (unformat (input, "cos1 %d", &cos1_val))
11583 else if (unformat (input, "cos2 %d", &cos2_val))
11588 if ((src + dst + proto + tag1 + tag2 +
11589 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11592 if (tag1 || ignore_tag1 || cos1)
11594 if (tag2 || ignore_tag2 || cos2)
11597 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11600 clib_memcpy (match, dst_val, 6);
11603 clib_memcpy (match + 6, src_val, 6);
11607 /* inner vlan tag */
11608 match[19] = tag2_val[1];
11609 match[18] = tag2_val[0];
11611 match[18] |= (cos2_val & 0x7) << 5;
11614 match[21] = proto_val & 0xff;
11615 match[20] = proto_val >> 8;
11619 match[15] = tag1_val[1];
11620 match[14] = tag1_val[0];
11623 match[14] |= (cos1_val & 0x7) << 5;
11629 match[15] = tag1_val[1];
11630 match[14] = tag1_val[0];
11633 match[17] = proto_val & 0xff;
11634 match[16] = proto_val >> 8;
11637 match[14] |= (cos1_val & 0x7) << 5;
11643 match[18] |= (cos2_val & 0x7) << 5;
11645 match[14] |= (cos1_val & 0x7) << 5;
11648 match[13] = proto_val & 0xff;
11649 match[12] = proto_val >> 8;
11657 unformat_qos_source (unformat_input_t * input, va_list * args)
11659 int *qs = va_arg (*args, int *);
11661 if (unformat (input, "ip"))
11662 *qs = QOS_SOURCE_IP;
11663 else if (unformat (input, "mpls"))
11664 *qs = QOS_SOURCE_MPLS;
11665 else if (unformat (input, "ext"))
11666 *qs = QOS_SOURCE_EXT;
11667 else if (unformat (input, "vlan"))
11668 *qs = QOS_SOURCE_VLAN;
11677 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11679 u8 **matchp = va_arg (*args, u8 **);
11680 u32 skip_n_vectors = va_arg (*args, u32);
11681 u32 match_n_vectors = va_arg (*args, u32);
11688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11690 if (unformat (input, "hex %U", unformat_hex_string, &match))
11692 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11694 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11696 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11710 if (match || l2 || l3 || l4)
11712 if (l2 || l3 || l4)
11714 /* "Win a free Ethernet header in every packet" */
11716 vec_validate_aligned (l2, 13, sizeof (u32x4));
11720 vec_append_aligned (match, l3, sizeof (u32x4));
11725 vec_append_aligned (match, l4, sizeof (u32x4));
11730 /* Make sure the vector is big enough even if key is all 0's */
11731 vec_validate_aligned
11732 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11735 /* Set size, include skipped vectors */
11736 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11747 api_classify_add_del_session (vat_main_t * vam)
11749 unformat_input_t *i = vam->input;
11750 vl_api_classify_add_del_session_t *mp;
11752 u32 table_index = ~0;
11753 u32 hit_next_index = ~0;
11754 u32 opaque_index = ~0;
11757 u32 skip_n_vectors = 0;
11758 u32 match_n_vectors = 0;
11764 * Warning: you have to supply skip_n and match_n
11765 * because the API client cant simply look at the classify
11769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11771 if (unformat (i, "del"))
11773 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11776 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11779 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11782 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11784 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11786 else if (unformat (i, "opaque-index %d", &opaque_index))
11788 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11790 else if (unformat (i, "match_n %d", &match_n_vectors))
11792 else if (unformat (i, "match %U", api_unformat_classify_match,
11793 &match, skip_n_vectors, match_n_vectors))
11795 else if (unformat (i, "advance %d", &advance))
11797 else if (unformat (i, "table-index %d", &table_index))
11799 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11801 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11803 else if (unformat (i, "action %d", &action))
11805 else if (unformat (i, "metadata %d", &metadata))
11811 if (table_index == ~0)
11813 errmsg ("Table index required");
11817 if (is_add && match == 0)
11819 errmsg ("Match value required");
11823 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11825 mp->is_add = is_add;
11826 mp->table_index = ntohl (table_index);
11827 mp->hit_next_index = ntohl (hit_next_index);
11828 mp->opaque_index = ntohl (opaque_index);
11829 mp->advance = ntohl (advance);
11830 mp->action = action;
11831 mp->metadata = ntohl (metadata);
11832 mp->match_len = ntohl (vec_len (match));
11833 clib_memcpy (mp->match, match, vec_len (match));
11842 api_classify_set_interface_ip_table (vat_main_t * vam)
11844 unformat_input_t *i = vam->input;
11845 vl_api_classify_set_interface_ip_table_t *mp;
11847 int sw_if_index_set;
11848 u32 table_index = ~0;
11852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11854 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11855 sw_if_index_set = 1;
11856 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11857 sw_if_index_set = 1;
11858 else if (unformat (i, "table %d", &table_index))
11862 clib_warning ("parse error '%U'", format_unformat_error, i);
11867 if (sw_if_index_set == 0)
11869 errmsg ("missing interface name or sw_if_index");
11874 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11876 mp->sw_if_index = ntohl (sw_if_index);
11877 mp->table_index = ntohl (table_index);
11878 mp->is_ipv6 = is_ipv6;
11886 api_classify_set_interface_l2_tables (vat_main_t * vam)
11888 unformat_input_t *i = vam->input;
11889 vl_api_classify_set_interface_l2_tables_t *mp;
11891 int sw_if_index_set;
11892 u32 ip4_table_index = ~0;
11893 u32 ip6_table_index = ~0;
11894 u32 other_table_index = ~0;
11898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11900 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11901 sw_if_index_set = 1;
11902 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11903 sw_if_index_set = 1;
11904 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11906 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11908 else if (unformat (i, "other-table %d", &other_table_index))
11910 else if (unformat (i, "is-input %d", &is_input))
11914 clib_warning ("parse error '%U'", format_unformat_error, i);
11919 if (sw_if_index_set == 0)
11921 errmsg ("missing interface name or sw_if_index");
11926 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11928 mp->sw_if_index = ntohl (sw_if_index);
11929 mp->ip4_table_index = ntohl (ip4_table_index);
11930 mp->ip6_table_index = ntohl (ip6_table_index);
11931 mp->other_table_index = ntohl (other_table_index);
11932 mp->is_input = (u8) is_input;
11940 api_set_ipfix_exporter (vat_main_t * vam)
11942 unformat_input_t *i = vam->input;
11943 vl_api_set_ipfix_exporter_t *mp;
11944 ip4_address_t collector_address;
11945 u8 collector_address_set = 0;
11946 u32 collector_port = ~0;
11947 ip4_address_t src_address;
11948 u8 src_address_set = 0;
11951 u32 template_interval = ~0;
11952 u8 udp_checksum = 0;
11955 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11957 if (unformat (i, "collector_address %U", unformat_ip4_address,
11958 &collector_address))
11959 collector_address_set = 1;
11960 else if (unformat (i, "collector_port %d", &collector_port))
11962 else if (unformat (i, "src_address %U", unformat_ip4_address,
11964 src_address_set = 1;
11965 else if (unformat (i, "vrf_id %d", &vrf_id))
11967 else if (unformat (i, "path_mtu %d", &path_mtu))
11969 else if (unformat (i, "template_interval %d", &template_interval))
11971 else if (unformat (i, "udp_checksum"))
11977 if (collector_address_set == 0)
11979 errmsg ("collector_address required");
11983 if (src_address_set == 0)
11985 errmsg ("src_address required");
11989 M (SET_IPFIX_EXPORTER, mp);
11991 memcpy (mp->collector_address, collector_address.data,
11992 sizeof (collector_address.data));
11993 mp->collector_port = htons ((u16) collector_port);
11994 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11995 mp->vrf_id = htonl (vrf_id);
11996 mp->path_mtu = htonl (path_mtu);
11997 mp->template_interval = htonl (template_interval);
11998 mp->udp_checksum = udp_checksum;
12006 api_set_ipfix_classify_stream (vat_main_t * vam)
12008 unformat_input_t *i = vam->input;
12009 vl_api_set_ipfix_classify_stream_t *mp;
12011 u32 src_port = UDP_DST_PORT_ipfix;
12014 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12016 if (unformat (i, "domain %d", &domain_id))
12018 else if (unformat (i, "src_port %d", &src_port))
12022 errmsg ("unknown input `%U'", format_unformat_error, i);
12027 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12029 mp->domain_id = htonl (domain_id);
12030 mp->src_port = htons ((u16) src_port);
12038 api_ipfix_classify_table_add_del (vat_main_t * vam)
12040 unformat_input_t *i = vam->input;
12041 vl_api_ipfix_classify_table_add_del_t *mp;
12043 u32 classify_table_index = ~0;
12045 u8 transport_protocol = 255;
12048 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12050 if (unformat (i, "add"))
12052 else if (unformat (i, "del"))
12054 else if (unformat (i, "table %d", &classify_table_index))
12056 else if (unformat (i, "ip4"))
12058 else if (unformat (i, "ip6"))
12060 else if (unformat (i, "tcp"))
12061 transport_protocol = 6;
12062 else if (unformat (i, "udp"))
12063 transport_protocol = 17;
12066 errmsg ("unknown input `%U'", format_unformat_error, i);
12073 errmsg ("expecting: add|del");
12076 if (classify_table_index == ~0)
12078 errmsg ("classifier table not specified");
12081 if (ip_version == 0)
12083 errmsg ("IP version not specified");
12087 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12089 mp->is_add = is_add;
12090 mp->table_id = htonl (classify_table_index);
12091 mp->ip_version = ip_version;
12092 mp->transport_protocol = transport_protocol;
12100 api_get_node_index (vat_main_t * vam)
12102 unformat_input_t *i = vam->input;
12103 vl_api_get_node_index_t *mp;
12107 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12109 if (unformat (i, "node %s", &name))
12116 errmsg ("node name required");
12119 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12121 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12125 M (GET_NODE_INDEX, mp);
12126 clib_memcpy (mp->node_name, name, vec_len (name));
12135 api_get_next_index (vat_main_t * vam)
12137 unformat_input_t *i = vam->input;
12138 vl_api_get_next_index_t *mp;
12139 u8 *node_name = 0, *next_node_name = 0;
12142 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12144 if (unformat (i, "node-name %s", &node_name))
12146 else if (unformat (i, "next-node-name %s", &next_node_name))
12150 if (node_name == 0)
12152 errmsg ("node name required");
12155 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12157 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12161 if (next_node_name == 0)
12163 errmsg ("next node name required");
12166 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12168 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12172 M (GET_NEXT_INDEX, mp);
12173 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12174 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12175 vec_free (node_name);
12176 vec_free (next_node_name);
12184 api_add_node_next (vat_main_t * vam)
12186 unformat_input_t *i = vam->input;
12187 vl_api_add_node_next_t *mp;
12192 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12194 if (unformat (i, "node %s", &name))
12196 else if (unformat (i, "next %s", &next))
12203 errmsg ("node name required");
12206 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12208 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12213 errmsg ("next node required");
12216 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12218 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12222 M (ADD_NODE_NEXT, mp);
12223 clib_memcpy (mp->node_name, name, vec_len (name));
12224 clib_memcpy (mp->next_name, next, vec_len (next));
12234 api_l2tpv3_create_tunnel (vat_main_t * vam)
12236 unformat_input_t *i = vam->input;
12237 ip6_address_t client_address, our_address;
12238 int client_address_set = 0;
12239 int our_address_set = 0;
12240 u32 local_session_id = 0;
12241 u32 remote_session_id = 0;
12242 u64 local_cookie = 0;
12243 u64 remote_cookie = 0;
12244 u8 l2_sublayer_present = 0;
12245 vl_api_l2tpv3_create_tunnel_t *mp;
12248 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12250 if (unformat (i, "client_address %U", unformat_ip6_address,
12252 client_address_set = 1;
12253 else if (unformat (i, "our_address %U", unformat_ip6_address,
12255 our_address_set = 1;
12256 else if (unformat (i, "local_session_id %d", &local_session_id))
12258 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12260 else if (unformat (i, "local_cookie %lld", &local_cookie))
12262 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12264 else if (unformat (i, "l2-sublayer-present"))
12265 l2_sublayer_present = 1;
12270 if (client_address_set == 0)
12272 errmsg ("client_address required");
12276 if (our_address_set == 0)
12278 errmsg ("our_address required");
12282 M (L2TPV3_CREATE_TUNNEL, mp);
12284 clib_memcpy (mp->client_address, client_address.as_u8,
12285 sizeof (mp->client_address));
12287 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12289 mp->local_session_id = ntohl (local_session_id);
12290 mp->remote_session_id = ntohl (remote_session_id);
12291 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12292 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12293 mp->l2_sublayer_present = l2_sublayer_present;
12302 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12304 unformat_input_t *i = vam->input;
12306 u8 sw_if_index_set = 0;
12307 u64 new_local_cookie = 0;
12308 u64 new_remote_cookie = 0;
12309 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12312 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12314 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12315 sw_if_index_set = 1;
12316 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12317 sw_if_index_set = 1;
12318 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12320 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12326 if (sw_if_index_set == 0)
12328 errmsg ("missing interface name or sw_if_index");
12332 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12334 mp->sw_if_index = ntohl (sw_if_index);
12335 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12336 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12344 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12346 unformat_input_t *i = vam->input;
12347 vl_api_l2tpv3_interface_enable_disable_t *mp;
12349 u8 sw_if_index_set = 0;
12350 u8 enable_disable = 1;
12353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12356 sw_if_index_set = 1;
12357 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12358 sw_if_index_set = 1;
12359 else if (unformat (i, "enable"))
12360 enable_disable = 1;
12361 else if (unformat (i, "disable"))
12362 enable_disable = 0;
12367 if (sw_if_index_set == 0)
12369 errmsg ("missing interface name or sw_if_index");
12373 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12375 mp->sw_if_index = ntohl (sw_if_index);
12376 mp->enable_disable = enable_disable;
12384 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12386 unformat_input_t *i = vam->input;
12387 vl_api_l2tpv3_set_lookup_key_t *mp;
12391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12393 if (unformat (i, "lookup_v6_src"))
12394 key = L2T_LOOKUP_SRC_ADDRESS;
12395 else if (unformat (i, "lookup_v6_dst"))
12396 key = L2T_LOOKUP_DST_ADDRESS;
12397 else if (unformat (i, "lookup_session_id"))
12398 key = L2T_LOOKUP_SESSION_ID;
12403 if (key == (u8) ~ 0)
12405 errmsg ("l2tp session lookup key unset");
12409 M (L2TPV3_SET_LOOKUP_KEY, mp);
12418 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12419 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12421 vat_main_t *vam = &vat_main;
12423 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12424 format_ip6_address, mp->our_address,
12425 format_ip6_address, mp->client_address,
12426 clib_net_to_host_u32 (mp->sw_if_index));
12429 " local cookies %016llx %016llx remote cookie %016llx",
12430 clib_net_to_host_u64 (mp->local_cookie[0]),
12431 clib_net_to_host_u64 (mp->local_cookie[1]),
12432 clib_net_to_host_u64 (mp->remote_cookie));
12434 print (vam->ofp, " local session-id %d remote session-id %d",
12435 clib_net_to_host_u32 (mp->local_session_id),
12436 clib_net_to_host_u32 (mp->remote_session_id));
12438 print (vam->ofp, " l2 specific sublayer %s\n",
12439 mp->l2_sublayer_present ? "preset" : "absent");
12443 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12444 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12446 vat_main_t *vam = &vat_main;
12447 vat_json_node_t *node = NULL;
12448 struct in6_addr addr;
12450 if (VAT_JSON_ARRAY != vam->json_tree.type)
12452 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12453 vat_json_init_array (&vam->json_tree);
12455 node = vat_json_array_add (&vam->json_tree);
12457 vat_json_init_object (node);
12459 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12460 vat_json_object_add_ip6 (node, "our_address", addr);
12461 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12462 vat_json_object_add_ip6 (node, "client_address", addr);
12464 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12465 vat_json_init_array (lc);
12466 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12467 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12468 vat_json_object_add_uint (node, "remote_cookie",
12469 clib_net_to_host_u64 (mp->remote_cookie));
12471 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12472 vat_json_object_add_uint (node, "local_session_id",
12473 clib_net_to_host_u32 (mp->local_session_id));
12474 vat_json_object_add_uint (node, "remote_session_id",
12475 clib_net_to_host_u32 (mp->remote_session_id));
12476 vat_json_object_add_string_copy (node, "l2_sublayer",
12477 mp->l2_sublayer_present ? (u8 *) "present"
12478 : (u8 *) "absent");
12482 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12484 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12485 vl_api_control_ping_t *mp_ping;
12488 /* Get list of l2tpv3-tunnel interfaces */
12489 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12492 /* Use a control ping for synchronization */
12493 MPING (CONTROL_PING, mp_ping);
12501 static void vl_api_sw_interface_tap_v2_details_t_handler
12502 (vl_api_sw_interface_tap_v2_details_t * mp)
12504 vat_main_t *vam = &vat_main;
12506 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12507 mp->host_ip4_prefix_len);
12508 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12509 mp->host_ip6_prefix_len);
12512 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12513 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12514 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12515 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12516 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12522 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12523 (vl_api_sw_interface_tap_v2_details_t * mp)
12525 vat_main_t *vam = &vat_main;
12526 vat_json_node_t *node = NULL;
12528 if (VAT_JSON_ARRAY != vam->json_tree.type)
12530 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12531 vat_json_init_array (&vam->json_tree);
12533 node = vat_json_array_add (&vam->json_tree);
12535 vat_json_init_object (node);
12536 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12537 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12538 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12539 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12540 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12541 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12542 vat_json_object_add_string_copy (node, "host_mac_addr",
12543 format (0, "%U", format_ethernet_address,
12544 &mp->host_mac_addr));
12545 vat_json_object_add_string_copy (node, "host_namespace",
12546 mp->host_namespace);
12547 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12548 vat_json_object_add_string_copy (node, "host_ip4_addr",
12549 format (0, "%U/%d", format_ip4_address,
12551 mp->host_ip4_prefix_len));
12552 vat_json_object_add_string_copy (node, "host_ip6_addr",
12553 format (0, "%U/%d", format_ip6_address,
12555 mp->host_ip6_prefix_len));
12560 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12562 vl_api_sw_interface_tap_v2_dump_t *mp;
12563 vl_api_control_ping_t *mp_ping;
12567 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12568 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12569 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12572 /* Get list of tap interfaces */
12573 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12576 /* Use a control ping for synchronization */
12577 MPING (CONTROL_PING, mp_ping);
12584 static void vl_api_sw_interface_virtio_pci_details_t_handler
12585 (vl_api_sw_interface_virtio_pci_details_t * mp)
12587 vat_main_t *vam = &vat_main;
12601 addr.as_u32 = ntohl (mp->pci_addr);
12602 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12603 addr.slot, addr.function);
12606 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12607 pci_addr, ntohl (mp->sw_if_index),
12608 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12609 format_ethernet_address, mp->mac_addr,
12610 clib_net_to_host_u64 (mp->features));
12611 vec_free (pci_addr);
12614 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12615 (vl_api_sw_interface_virtio_pci_details_t * mp)
12617 vat_main_t *vam = &vat_main;
12618 vat_json_node_t *node = NULL;
12620 if (VAT_JSON_ARRAY != vam->json_tree.type)
12622 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12623 vat_json_init_array (&vam->json_tree);
12625 node = vat_json_array_add (&vam->json_tree);
12627 vat_json_init_object (node);
12628 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12629 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12630 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12631 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12632 vat_json_object_add_uint (node, "features",
12633 clib_net_to_host_u64 (mp->features));
12634 vat_json_object_add_string_copy (node, "mac_addr",
12635 format (0, "%U", format_ethernet_address,
12640 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12642 vl_api_sw_interface_virtio_pci_dump_t *mp;
12643 vl_api_control_ping_t *mp_ping;
12647 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12648 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12649 "mac_addr", "features");
12651 /* Get list of tap interfaces */
12652 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12655 /* Use a control ping for synchronization */
12656 MPING (CONTROL_PING, mp_ping);
12664 api_vxlan_offload_rx (vat_main_t * vam)
12666 unformat_input_t *line_input = vam->input;
12667 vl_api_vxlan_offload_rx_t *mp;
12668 u32 hw_if_index = ~0, rx_if_index = ~0;
12672 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12674 if (unformat (line_input, "del"))
12676 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12679 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12681 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12684 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12688 errmsg ("parse error '%U'", format_unformat_error, line_input);
12693 if (hw_if_index == ~0)
12695 errmsg ("no hw interface");
12699 if (rx_if_index == ~0)
12701 errmsg ("no rx tunnel");
12705 M (VXLAN_OFFLOAD_RX, mp);
12707 mp->hw_if_index = ntohl (hw_if_index);
12708 mp->sw_if_index = ntohl (rx_if_index);
12709 mp->enable = is_add;
12716 static uword unformat_vxlan_decap_next
12717 (unformat_input_t * input, va_list * args)
12719 u32 *result = va_arg (*args, u32 *);
12722 if (unformat (input, "l2"))
12723 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12724 else if (unformat (input, "%d", &tmp))
12732 api_vxlan_add_del_tunnel (vat_main_t * vam)
12734 unformat_input_t *line_input = vam->input;
12735 vl_api_vxlan_add_del_tunnel_t *mp;
12736 ip46_address_t src, dst;
12738 u8 ipv4_set = 0, ipv6_set = 0;
12743 u32 mcast_sw_if_index = ~0;
12744 u32 encap_vrf_id = 0;
12745 u32 decap_next_index = ~0;
12749 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12750 clib_memset (&src, 0, sizeof src);
12751 clib_memset (&dst, 0, sizeof dst);
12753 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12755 if (unformat (line_input, "del"))
12757 else if (unformat (line_input, "instance %d", &instance))
12760 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12766 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12772 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12778 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12783 else if (unformat (line_input, "group %U %U",
12784 unformat_ip4_address, &dst.ip4,
12785 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12787 grp_set = dst_set = 1;
12790 else if (unformat (line_input, "group %U",
12791 unformat_ip4_address, &dst.ip4))
12793 grp_set = dst_set = 1;
12796 else if (unformat (line_input, "group %U %U",
12797 unformat_ip6_address, &dst.ip6,
12798 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12800 grp_set = dst_set = 1;
12803 else if (unformat (line_input, "group %U",
12804 unformat_ip6_address, &dst.ip6))
12806 grp_set = dst_set = 1;
12810 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12812 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12814 else if (unformat (line_input, "decap-next %U",
12815 unformat_vxlan_decap_next, &decap_next_index))
12817 else if (unformat (line_input, "vni %d", &vni))
12821 errmsg ("parse error '%U'", format_unformat_error, line_input);
12828 errmsg ("tunnel src address not specified");
12833 errmsg ("tunnel dst address not specified");
12837 if (grp_set && !ip46_address_is_multicast (&dst))
12839 errmsg ("tunnel group address not multicast");
12842 if (grp_set && mcast_sw_if_index == ~0)
12844 errmsg ("tunnel nonexistent multicast device");
12847 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12849 errmsg ("tunnel dst address must be unicast");
12854 if (ipv4_set && ipv6_set)
12856 errmsg ("both IPv4 and IPv6 addresses specified");
12860 if ((vni == 0) || (vni >> 24))
12862 errmsg ("vni not specified or out of range");
12866 M (VXLAN_ADD_DEL_TUNNEL, mp);
12870 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12871 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12875 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12876 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12879 mp->instance = htonl (instance);
12880 mp->encap_vrf_id = ntohl (encap_vrf_id);
12881 mp->decap_next_index = ntohl (decap_next_index);
12882 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12883 mp->vni = ntohl (vni);
12884 mp->is_add = is_add;
12885 mp->is_ipv6 = ipv6_set;
12892 static void vl_api_vxlan_tunnel_details_t_handler
12893 (vl_api_vxlan_tunnel_details_t * mp)
12895 vat_main_t *vam = &vat_main;
12896 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12897 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12899 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12900 ntohl (mp->sw_if_index),
12901 ntohl (mp->instance),
12902 format_ip46_address, &src, IP46_TYPE_ANY,
12903 format_ip46_address, &dst, IP46_TYPE_ANY,
12904 ntohl (mp->encap_vrf_id),
12905 ntohl (mp->decap_next_index), ntohl (mp->vni),
12906 ntohl (mp->mcast_sw_if_index));
12909 static void vl_api_vxlan_tunnel_details_t_handler_json
12910 (vl_api_vxlan_tunnel_details_t * mp)
12912 vat_main_t *vam = &vat_main;
12913 vat_json_node_t *node = NULL;
12915 if (VAT_JSON_ARRAY != vam->json_tree.type)
12917 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12918 vat_json_init_array (&vam->json_tree);
12920 node = vat_json_array_add (&vam->json_tree);
12922 vat_json_init_object (node);
12923 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12925 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12929 struct in6_addr ip6;
12931 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12932 vat_json_object_add_ip6 (node, "src_address", ip6);
12933 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12934 vat_json_object_add_ip6 (node, "dst_address", ip6);
12938 struct in_addr ip4;
12940 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12941 vat_json_object_add_ip4 (node, "src_address", ip4);
12942 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12943 vat_json_object_add_ip4 (node, "dst_address", ip4);
12945 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12946 vat_json_object_add_uint (node, "decap_next_index",
12947 ntohl (mp->decap_next_index));
12948 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12949 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12950 vat_json_object_add_uint (node, "mcast_sw_if_index",
12951 ntohl (mp->mcast_sw_if_index));
12955 api_vxlan_tunnel_dump (vat_main_t * vam)
12957 unformat_input_t *i = vam->input;
12958 vl_api_vxlan_tunnel_dump_t *mp;
12959 vl_api_control_ping_t *mp_ping;
12961 u8 sw_if_index_set = 0;
12964 /* Parse args required to build the message */
12965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12967 if (unformat (i, "sw_if_index %d", &sw_if_index))
12968 sw_if_index_set = 1;
12973 if (sw_if_index_set == 0)
12978 if (!vam->json_output)
12980 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12981 "sw_if_index", "instance", "src_address", "dst_address",
12982 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12985 /* Get list of vxlan-tunnel interfaces */
12986 M (VXLAN_TUNNEL_DUMP, mp);
12988 mp->sw_if_index = htonl (sw_if_index);
12992 /* Use a control ping for synchronization */
12993 MPING (CONTROL_PING, mp_ping);
13000 static uword unformat_geneve_decap_next
13001 (unformat_input_t * input, va_list * args)
13003 u32 *result = va_arg (*args, u32 *);
13006 if (unformat (input, "l2"))
13007 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13008 else if (unformat (input, "%d", &tmp))
13016 api_geneve_add_del_tunnel (vat_main_t * vam)
13018 unformat_input_t *line_input = vam->input;
13019 vl_api_geneve_add_del_tunnel_t *mp;
13020 ip46_address_t src, dst;
13022 u8 ipv4_set = 0, ipv6_set = 0;
13026 u32 mcast_sw_if_index = ~0;
13027 u32 encap_vrf_id = 0;
13028 u32 decap_next_index = ~0;
13032 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13033 clib_memset (&src, 0, sizeof src);
13034 clib_memset (&dst, 0, sizeof dst);
13036 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13038 if (unformat (line_input, "del"))
13041 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13047 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13053 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13059 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13064 else if (unformat (line_input, "group %U %U",
13065 unformat_ip4_address, &dst.ip4,
13066 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13068 grp_set = dst_set = 1;
13071 else if (unformat (line_input, "group %U",
13072 unformat_ip4_address, &dst.ip4))
13074 grp_set = dst_set = 1;
13077 else if (unformat (line_input, "group %U %U",
13078 unformat_ip6_address, &dst.ip6,
13079 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13081 grp_set = dst_set = 1;
13084 else if (unformat (line_input, "group %U",
13085 unformat_ip6_address, &dst.ip6))
13087 grp_set = dst_set = 1;
13091 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13093 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13095 else if (unformat (line_input, "decap-next %U",
13096 unformat_geneve_decap_next, &decap_next_index))
13098 else if (unformat (line_input, "vni %d", &vni))
13102 errmsg ("parse error '%U'", format_unformat_error, line_input);
13109 errmsg ("tunnel src address not specified");
13114 errmsg ("tunnel dst address not specified");
13118 if (grp_set && !ip46_address_is_multicast (&dst))
13120 errmsg ("tunnel group address not multicast");
13123 if (grp_set && mcast_sw_if_index == ~0)
13125 errmsg ("tunnel nonexistent multicast device");
13128 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13130 errmsg ("tunnel dst address must be unicast");
13135 if (ipv4_set && ipv6_set)
13137 errmsg ("both IPv4 and IPv6 addresses specified");
13141 if ((vni == 0) || (vni >> 24))
13143 errmsg ("vni not specified or out of range");
13147 M (GENEVE_ADD_DEL_TUNNEL, mp);
13151 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13152 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13156 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13157 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13159 mp->encap_vrf_id = ntohl (encap_vrf_id);
13160 mp->decap_next_index = ntohl (decap_next_index);
13161 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13162 mp->vni = ntohl (vni);
13163 mp->is_add = is_add;
13164 mp->is_ipv6 = ipv6_set;
13171 static void vl_api_geneve_tunnel_details_t_handler
13172 (vl_api_geneve_tunnel_details_t * mp)
13174 vat_main_t *vam = &vat_main;
13175 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13176 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13178 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13179 ntohl (mp->sw_if_index),
13180 format_ip46_address, &src, IP46_TYPE_ANY,
13181 format_ip46_address, &dst, IP46_TYPE_ANY,
13182 ntohl (mp->encap_vrf_id),
13183 ntohl (mp->decap_next_index), ntohl (mp->vni),
13184 ntohl (mp->mcast_sw_if_index));
13187 static void vl_api_geneve_tunnel_details_t_handler_json
13188 (vl_api_geneve_tunnel_details_t * mp)
13190 vat_main_t *vam = &vat_main;
13191 vat_json_node_t *node = NULL;
13193 if (VAT_JSON_ARRAY != vam->json_tree.type)
13195 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13196 vat_json_init_array (&vam->json_tree);
13198 node = vat_json_array_add (&vam->json_tree);
13200 vat_json_init_object (node);
13201 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13204 struct in6_addr ip6;
13206 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13207 vat_json_object_add_ip6 (node, "src_address", ip6);
13208 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13209 vat_json_object_add_ip6 (node, "dst_address", ip6);
13213 struct in_addr ip4;
13215 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13216 vat_json_object_add_ip4 (node, "src_address", ip4);
13217 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13218 vat_json_object_add_ip4 (node, "dst_address", ip4);
13220 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13221 vat_json_object_add_uint (node, "decap_next_index",
13222 ntohl (mp->decap_next_index));
13223 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13224 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13225 vat_json_object_add_uint (node, "mcast_sw_if_index",
13226 ntohl (mp->mcast_sw_if_index));
13230 api_geneve_tunnel_dump (vat_main_t * vam)
13232 unformat_input_t *i = vam->input;
13233 vl_api_geneve_tunnel_dump_t *mp;
13234 vl_api_control_ping_t *mp_ping;
13236 u8 sw_if_index_set = 0;
13239 /* Parse args required to build the message */
13240 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13242 if (unformat (i, "sw_if_index %d", &sw_if_index))
13243 sw_if_index_set = 1;
13248 if (sw_if_index_set == 0)
13253 if (!vam->json_output)
13255 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13256 "sw_if_index", "local_address", "remote_address",
13257 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13260 /* Get list of geneve-tunnel interfaces */
13261 M (GENEVE_TUNNEL_DUMP, mp);
13263 mp->sw_if_index = htonl (sw_if_index);
13267 /* Use a control ping for synchronization */
13268 M (CONTROL_PING, mp_ping);
13276 api_gre_add_del_tunnel (vat_main_t * vam)
13278 unformat_input_t *line_input = vam->input;
13279 vl_api_gre_add_del_tunnel_t *mp;
13280 ip4_address_t src4, dst4;
13281 ip6_address_t src6, dst6;
13285 u8 t_type = GRE_TUNNEL_TYPE_L3;
13288 u32 outer_fib_id = 0;
13289 u32 session_id = 0;
13293 clib_memset (&src4, 0, sizeof src4);
13294 clib_memset (&dst4, 0, sizeof dst4);
13295 clib_memset (&src6, 0, sizeof src6);
13296 clib_memset (&dst6, 0, sizeof dst6);
13298 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13300 if (unformat (line_input, "del"))
13302 else if (unformat (line_input, "instance %d", &instance))
13304 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13309 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13314 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13319 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13324 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13326 else if (unformat (line_input, "teb"))
13327 t_type = GRE_TUNNEL_TYPE_TEB;
13328 else if (unformat (line_input, "erspan %d", &session_id))
13329 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13332 errmsg ("parse error '%U'", format_unformat_error, line_input);
13339 errmsg ("tunnel src address not specified");
13344 errmsg ("tunnel dst address not specified");
13347 if (ipv4_set && ipv6_set)
13349 errmsg ("both IPv4 and IPv6 addresses specified");
13354 M (GRE_ADD_DEL_TUNNEL, mp);
13358 clib_memcpy (&mp->src_address, &src4, 4);
13359 clib_memcpy (&mp->dst_address, &dst4, 4);
13363 clib_memcpy (&mp->src_address, &src6, 16);
13364 clib_memcpy (&mp->dst_address, &dst6, 16);
13366 mp->instance = htonl (instance);
13367 mp->outer_fib_id = htonl (outer_fib_id);
13368 mp->is_add = is_add;
13369 mp->session_id = htons ((u16) session_id);
13370 mp->tunnel_type = t_type;
13371 mp->is_ipv6 = ipv6_set;
13378 static void vl_api_gre_tunnel_details_t_handler
13379 (vl_api_gre_tunnel_details_t * mp)
13381 vat_main_t *vam = &vat_main;
13382 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13383 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13385 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13386 ntohl (mp->sw_if_index),
13387 ntohl (mp->instance),
13388 format_ip46_address, &src, IP46_TYPE_ANY,
13389 format_ip46_address, &dst, IP46_TYPE_ANY,
13390 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13393 static void vl_api_gre_tunnel_details_t_handler_json
13394 (vl_api_gre_tunnel_details_t * mp)
13396 vat_main_t *vam = &vat_main;
13397 vat_json_node_t *node = NULL;
13398 struct in_addr ip4;
13399 struct in6_addr ip6;
13401 if (VAT_JSON_ARRAY != vam->json_tree.type)
13403 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13404 vat_json_init_array (&vam->json_tree);
13406 node = vat_json_array_add (&vam->json_tree);
13408 vat_json_init_object (node);
13409 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13410 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13413 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13414 vat_json_object_add_ip4 (node, "src_address", ip4);
13415 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13416 vat_json_object_add_ip4 (node, "dst_address", ip4);
13420 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13421 vat_json_object_add_ip6 (node, "src_address", ip6);
13422 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13423 vat_json_object_add_ip6 (node, "dst_address", ip6);
13425 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13426 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13427 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13428 vat_json_object_add_uint (node, "session_id", mp->session_id);
13432 api_gre_tunnel_dump (vat_main_t * vam)
13434 unformat_input_t *i = vam->input;
13435 vl_api_gre_tunnel_dump_t *mp;
13436 vl_api_control_ping_t *mp_ping;
13438 u8 sw_if_index_set = 0;
13441 /* Parse args required to build the message */
13442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13444 if (unformat (i, "sw_if_index %d", &sw_if_index))
13445 sw_if_index_set = 1;
13450 if (sw_if_index_set == 0)
13455 if (!vam->json_output)
13457 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13458 "sw_if_index", "instance", "src_address", "dst_address",
13459 "tunnel_type", "outer_fib_id", "session_id");
13462 /* Get list of gre-tunnel interfaces */
13463 M (GRE_TUNNEL_DUMP, mp);
13465 mp->sw_if_index = htonl (sw_if_index);
13469 /* Use a control ping for synchronization */
13470 MPING (CONTROL_PING, mp_ping);
13478 api_l2_fib_clear_table (vat_main_t * vam)
13480 // unformat_input_t * i = vam->input;
13481 vl_api_l2_fib_clear_table_t *mp;
13484 M (L2_FIB_CLEAR_TABLE, mp);
13492 api_l2_interface_efp_filter (vat_main_t * vam)
13494 unformat_input_t *i = vam->input;
13495 vl_api_l2_interface_efp_filter_t *mp;
13498 u8 sw_if_index_set = 0;
13501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13504 sw_if_index_set = 1;
13505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13506 sw_if_index_set = 1;
13507 else if (unformat (i, "enable"))
13509 else if (unformat (i, "disable"))
13513 clib_warning ("parse error '%U'", format_unformat_error, i);
13518 if (sw_if_index_set == 0)
13520 errmsg ("missing sw_if_index");
13524 M (L2_INTERFACE_EFP_FILTER, mp);
13526 mp->sw_if_index = ntohl (sw_if_index);
13527 mp->enable_disable = enable;
13534 #define foreach_vtr_op \
13535 _("disable", L2_VTR_DISABLED) \
13536 _("push-1", L2_VTR_PUSH_1) \
13537 _("push-2", L2_VTR_PUSH_2) \
13538 _("pop-1", L2_VTR_POP_1) \
13539 _("pop-2", L2_VTR_POP_2) \
13540 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13541 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13542 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13543 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13546 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13548 unformat_input_t *i = vam->input;
13549 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13551 u8 sw_if_index_set = 0;
13554 u32 push_dot1q = 1;
13559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13562 sw_if_index_set = 1;
13563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13564 sw_if_index_set = 1;
13565 else if (unformat (i, "vtr_op %d", &vtr_op))
13567 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13570 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13572 else if (unformat (i, "tag1 %d", &tag1))
13574 else if (unformat (i, "tag2 %d", &tag2))
13578 clib_warning ("parse error '%U'", format_unformat_error, i);
13583 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13585 errmsg ("missing vtr operation or sw_if_index");
13589 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13590 mp->sw_if_index = ntohl (sw_if_index);
13591 mp->vtr_op = ntohl (vtr_op);
13592 mp->push_dot1q = ntohl (push_dot1q);
13593 mp->tag1 = ntohl (tag1);
13594 mp->tag2 = ntohl (tag2);
13602 api_create_vhost_user_if (vat_main_t * vam)
13604 unformat_input_t *i = vam->input;
13605 vl_api_create_vhost_user_if_t *mp;
13608 u8 file_name_set = 0;
13609 u32 custom_dev_instance = ~0;
13611 u8 use_custom_mac = 0;
13612 u8 disable_mrg_rxbuf = 0;
13613 u8 disable_indirect_desc = 0;
13617 /* Shut up coverity */
13618 clib_memset (hwaddr, 0, sizeof (hwaddr));
13620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13622 if (unformat (i, "socket %s", &file_name))
13626 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13628 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13629 use_custom_mac = 1;
13630 else if (unformat (i, "server"))
13632 else if (unformat (i, "disable_mrg_rxbuf"))
13633 disable_mrg_rxbuf = 1;
13634 else if (unformat (i, "disable_indirect_desc"))
13635 disable_indirect_desc = 1;
13636 else if (unformat (i, "tag %s", &tag))
13642 if (file_name_set == 0)
13644 errmsg ("missing socket file name");
13648 if (vec_len (file_name) > 255)
13650 errmsg ("socket file name too long");
13653 vec_add1 (file_name, 0);
13655 M (CREATE_VHOST_USER_IF, mp);
13657 mp->is_server = is_server;
13658 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13659 mp->disable_indirect_desc = disable_indirect_desc;
13660 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13661 vec_free (file_name);
13662 if (custom_dev_instance != ~0)
13665 mp->custom_dev_instance = ntohl (custom_dev_instance);
13668 mp->use_custom_mac = use_custom_mac;
13669 clib_memcpy (mp->mac_address, hwaddr, 6);
13671 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13680 api_modify_vhost_user_if (vat_main_t * vam)
13682 unformat_input_t *i = vam->input;
13683 vl_api_modify_vhost_user_if_t *mp;
13686 u8 file_name_set = 0;
13687 u32 custom_dev_instance = ~0;
13688 u8 sw_if_index_set = 0;
13689 u32 sw_if_index = (u32) ~ 0;
13692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13694 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13695 sw_if_index_set = 1;
13696 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13697 sw_if_index_set = 1;
13698 else if (unformat (i, "socket %s", &file_name))
13702 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13704 else if (unformat (i, "server"))
13710 if (sw_if_index_set == 0)
13712 errmsg ("missing sw_if_index or interface name");
13716 if (file_name_set == 0)
13718 errmsg ("missing socket file name");
13722 if (vec_len (file_name) > 255)
13724 errmsg ("socket file name too long");
13727 vec_add1 (file_name, 0);
13729 M (MODIFY_VHOST_USER_IF, mp);
13731 mp->sw_if_index = ntohl (sw_if_index);
13732 mp->is_server = is_server;
13733 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13734 vec_free (file_name);
13735 if (custom_dev_instance != ~0)
13738 mp->custom_dev_instance = ntohl (custom_dev_instance);
13747 api_delete_vhost_user_if (vat_main_t * vam)
13749 unformat_input_t *i = vam->input;
13750 vl_api_delete_vhost_user_if_t *mp;
13751 u32 sw_if_index = ~0;
13752 u8 sw_if_index_set = 0;
13755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13758 sw_if_index_set = 1;
13759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13760 sw_if_index_set = 1;
13765 if (sw_if_index_set == 0)
13767 errmsg ("missing sw_if_index or interface name");
13772 M (DELETE_VHOST_USER_IF, mp);
13774 mp->sw_if_index = ntohl (sw_if_index);
13781 static void vl_api_sw_interface_vhost_user_details_t_handler
13782 (vl_api_sw_interface_vhost_user_details_t * mp)
13784 vat_main_t *vam = &vat_main;
13786 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13787 (char *) mp->interface_name,
13788 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13789 clib_net_to_host_u64 (mp->features), mp->is_server,
13790 ntohl (mp->num_regions), (char *) mp->sock_filename);
13791 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13794 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13795 (vl_api_sw_interface_vhost_user_details_t * mp)
13797 vat_main_t *vam = &vat_main;
13798 vat_json_node_t *node = NULL;
13800 if (VAT_JSON_ARRAY != vam->json_tree.type)
13802 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13803 vat_json_init_array (&vam->json_tree);
13805 node = vat_json_array_add (&vam->json_tree);
13807 vat_json_init_object (node);
13808 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13809 vat_json_object_add_string_copy (node, "interface_name",
13810 mp->interface_name);
13811 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13812 ntohl (mp->virtio_net_hdr_sz));
13813 vat_json_object_add_uint (node, "features",
13814 clib_net_to_host_u64 (mp->features));
13815 vat_json_object_add_uint (node, "is_server", mp->is_server);
13816 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13817 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13818 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13822 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13824 vl_api_sw_interface_vhost_user_dump_t *mp;
13825 vl_api_control_ping_t *mp_ping;
13828 "Interface name idx hdr_sz features server regions filename");
13830 /* Get list of vhost-user interfaces */
13831 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13834 /* Use a control ping for synchronization */
13835 MPING (CONTROL_PING, mp_ping);
13843 api_show_version (vat_main_t * vam)
13845 vl_api_show_version_t *mp;
13848 M (SHOW_VERSION, mp);
13857 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13859 unformat_input_t *line_input = vam->input;
13860 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13861 ip4_address_t local4, remote4;
13862 ip6_address_t local6, remote6;
13864 u8 ipv4_set = 0, ipv6_set = 0;
13868 u32 mcast_sw_if_index = ~0;
13869 u32 encap_vrf_id = 0;
13870 u32 decap_vrf_id = 0;
13876 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13877 clib_memset (&local4, 0, sizeof local4);
13878 clib_memset (&remote4, 0, sizeof remote4);
13879 clib_memset (&local6, 0, sizeof local6);
13880 clib_memset (&remote6, 0, sizeof remote6);
13882 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13884 if (unformat (line_input, "del"))
13886 else if (unformat (line_input, "local %U",
13887 unformat_ip4_address, &local4))
13892 else if (unformat (line_input, "remote %U",
13893 unformat_ip4_address, &remote4))
13898 else if (unformat (line_input, "local %U",
13899 unformat_ip6_address, &local6))
13904 else if (unformat (line_input, "remote %U",
13905 unformat_ip6_address, &remote6))
13910 else if (unformat (line_input, "group %U %U",
13911 unformat_ip4_address, &remote4,
13912 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13914 grp_set = remote_set = 1;
13917 else if (unformat (line_input, "group %U",
13918 unformat_ip4_address, &remote4))
13920 grp_set = remote_set = 1;
13923 else if (unformat (line_input, "group %U %U",
13924 unformat_ip6_address, &remote6,
13925 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13927 grp_set = remote_set = 1;
13930 else if (unformat (line_input, "group %U",
13931 unformat_ip6_address, &remote6))
13933 grp_set = remote_set = 1;
13937 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13939 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13941 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13943 else if (unformat (line_input, "vni %d", &vni))
13945 else if (unformat (line_input, "next-ip4"))
13947 else if (unformat (line_input, "next-ip6"))
13949 else if (unformat (line_input, "next-ethernet"))
13951 else if (unformat (line_input, "next-nsh"))
13955 errmsg ("parse error '%U'", format_unformat_error, line_input);
13960 if (local_set == 0)
13962 errmsg ("tunnel local address not specified");
13965 if (remote_set == 0)
13967 errmsg ("tunnel remote address not specified");
13970 if (grp_set && mcast_sw_if_index == ~0)
13972 errmsg ("tunnel nonexistent multicast device");
13975 if (ipv4_set && ipv6_set)
13977 errmsg ("both IPv4 and IPv6 addresses specified");
13983 errmsg ("vni not specified");
13987 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13992 clib_memcpy (&mp->local, &local6, sizeof (local6));
13993 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13997 clib_memcpy (&mp->local, &local4, sizeof (local4));
13998 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14001 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14002 mp->encap_vrf_id = ntohl (encap_vrf_id);
14003 mp->decap_vrf_id = ntohl (decap_vrf_id);
14004 mp->protocol = protocol;
14005 mp->vni = ntohl (vni);
14006 mp->is_add = is_add;
14007 mp->is_ipv6 = ipv6_set;
14014 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14015 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14017 vat_main_t *vam = &vat_main;
14018 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14019 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14021 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14022 ntohl (mp->sw_if_index),
14023 format_ip46_address, &local, IP46_TYPE_ANY,
14024 format_ip46_address, &remote, IP46_TYPE_ANY,
14025 ntohl (mp->vni), mp->protocol,
14026 ntohl (mp->mcast_sw_if_index),
14027 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14031 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14032 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14034 vat_main_t *vam = &vat_main;
14035 vat_json_node_t *node = NULL;
14036 struct in_addr ip4;
14037 struct in6_addr ip6;
14039 if (VAT_JSON_ARRAY != vam->json_tree.type)
14041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14042 vat_json_init_array (&vam->json_tree);
14044 node = vat_json_array_add (&vam->json_tree);
14046 vat_json_init_object (node);
14047 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14050 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14051 vat_json_object_add_ip6 (node, "local", ip6);
14052 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14053 vat_json_object_add_ip6 (node, "remote", ip6);
14057 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14058 vat_json_object_add_ip4 (node, "local", ip4);
14059 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14060 vat_json_object_add_ip4 (node, "remote", ip4);
14062 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14063 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14064 vat_json_object_add_uint (node, "mcast_sw_if_index",
14065 ntohl (mp->mcast_sw_if_index));
14066 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14067 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14068 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14072 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14074 unformat_input_t *i = vam->input;
14075 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14076 vl_api_control_ping_t *mp_ping;
14078 u8 sw_if_index_set = 0;
14081 /* Parse args required to build the message */
14082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14084 if (unformat (i, "sw_if_index %d", &sw_if_index))
14085 sw_if_index_set = 1;
14090 if (sw_if_index_set == 0)
14095 if (!vam->json_output)
14097 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14098 "sw_if_index", "local", "remote", "vni",
14099 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14102 /* Get list of vxlan-tunnel interfaces */
14103 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14105 mp->sw_if_index = htonl (sw_if_index);
14109 /* Use a control ping for synchronization */
14110 MPING (CONTROL_PING, mp_ping);
14117 static void vl_api_l2_fib_table_details_t_handler
14118 (vl_api_l2_fib_table_details_t * mp)
14120 vat_main_t *vam = &vat_main;
14122 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14124 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14125 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14129 static void vl_api_l2_fib_table_details_t_handler_json
14130 (vl_api_l2_fib_table_details_t * mp)
14132 vat_main_t *vam = &vat_main;
14133 vat_json_node_t *node = NULL;
14135 if (VAT_JSON_ARRAY != vam->json_tree.type)
14137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14138 vat_json_init_array (&vam->json_tree);
14140 node = vat_json_array_add (&vam->json_tree);
14142 vat_json_init_object (node);
14143 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14144 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14145 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14146 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14147 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14148 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14152 api_l2_fib_table_dump (vat_main_t * vam)
14154 unformat_input_t *i = vam->input;
14155 vl_api_l2_fib_table_dump_t *mp;
14156 vl_api_control_ping_t *mp_ping;
14161 /* Parse args required to build the message */
14162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14164 if (unformat (i, "bd_id %d", &bd_id))
14170 if (bd_id_set == 0)
14172 errmsg ("missing bridge domain");
14176 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14178 /* Get list of l2 fib entries */
14179 M (L2_FIB_TABLE_DUMP, mp);
14181 mp->bd_id = ntohl (bd_id);
14184 /* Use a control ping for synchronization */
14185 MPING (CONTROL_PING, mp_ping);
14194 api_interface_name_renumber (vat_main_t * vam)
14196 unformat_input_t *line_input = vam->input;
14197 vl_api_interface_name_renumber_t *mp;
14198 u32 sw_if_index = ~0;
14199 u32 new_show_dev_instance = ~0;
14202 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14204 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14207 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14209 else if (unformat (line_input, "new_show_dev_instance %d",
14210 &new_show_dev_instance))
14216 if (sw_if_index == ~0)
14218 errmsg ("missing interface name or sw_if_index");
14222 if (new_show_dev_instance == ~0)
14224 errmsg ("missing new_show_dev_instance");
14228 M (INTERFACE_NAME_RENUMBER, mp);
14230 mp->sw_if_index = ntohl (sw_if_index);
14231 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14239 api_ip_probe_neighbor (vat_main_t * vam)
14241 unformat_input_t *i = vam->input;
14242 vl_api_ip_probe_neighbor_t *mp;
14243 vl_api_address_t dst_adr;
14249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14251 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14253 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14255 else if (unformat (i, "address %U", unformat_vl_api_address, dst_adr))
14263 errmsg ("missing interface");
14269 errmsg ("missing addresses");
14273 M (IP_PROBE_NEIGHBOR, mp);
14275 mp->sw_if_index = ntohl (sw_if_index);
14276 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
14284 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14286 unformat_input_t *i = vam->input;
14287 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14288 u8 mode = IP_SCAN_V46_NEIGHBORS;
14289 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14294 if (unformat (i, "ip4"))
14295 mode = IP_SCAN_V4_NEIGHBORS;
14296 else if (unformat (i, "ip6"))
14297 mode = IP_SCAN_V6_NEIGHBORS;
14298 if (unformat (i, "both"))
14299 mode = IP_SCAN_V46_NEIGHBORS;
14300 else if (unformat (i, "disable"))
14301 mode = IP_SCAN_DISABLED;
14302 else if (unformat (i, "interval %d", &interval))
14304 else if (unformat (i, "max-time %d", &time))
14306 else if (unformat (i, "max-update %d", &update))
14308 else if (unformat (i, "delay %d", &delay))
14310 else if (unformat (i, "stale %d", &stale))
14316 if (interval > 255)
14318 errmsg ("interval cannot exceed 255 minutes.");
14323 errmsg ("max-time cannot exceed 255 usec.");
14328 errmsg ("max-update cannot exceed 255.");
14333 errmsg ("delay cannot exceed 255 msec.");
14338 errmsg ("stale cannot exceed 255 minutes.");
14342 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14344 mp->scan_interval = interval;
14345 mp->max_proc_time = time;
14346 mp->max_update = update;
14347 mp->scan_int_delay = delay;
14348 mp->stale_threshold = stale;
14356 api_want_ip4_arp_events (vat_main_t * vam)
14358 unformat_input_t *line_input = vam->input;
14359 vl_api_want_ip4_arp_events_t *mp;
14360 ip4_address_t address;
14361 int address_set = 0;
14362 u32 enable_disable = 1;
14365 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14367 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14369 else if (unformat (line_input, "del"))
14370 enable_disable = 0;
14375 if (address_set == 0)
14377 errmsg ("missing addresses");
14381 M (WANT_IP4_ARP_EVENTS, mp);
14382 mp->enable_disable = enable_disable;
14383 mp->pid = htonl (getpid ());
14384 clib_memcpy (mp->ip, &address, sizeof (address));
14392 api_want_ip6_nd_events (vat_main_t * vam)
14394 unformat_input_t *line_input = vam->input;
14395 vl_api_want_ip6_nd_events_t *mp;
14396 vl_api_ip6_address_t address;
14397 int address_set = 0;
14398 u32 enable_disable = 1;
14401 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14404 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14406 else if (unformat (line_input, "del"))
14407 enable_disable = 0;
14412 if (address_set == 0)
14414 errmsg ("missing addresses");
14418 M (WANT_IP6_ND_EVENTS, mp);
14419 mp->enable_disable = enable_disable;
14420 mp->pid = htonl (getpid ());
14421 clib_memcpy (&mp->ip, &address, sizeof (address));
14429 api_want_l2_macs_events (vat_main_t * vam)
14431 unformat_input_t *line_input = vam->input;
14432 vl_api_want_l2_macs_events_t *mp;
14433 u8 enable_disable = 1;
14434 u32 scan_delay = 0;
14435 u32 max_macs_in_event = 0;
14436 u32 learn_limit = 0;
14439 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14441 if (unformat (line_input, "learn-limit %d", &learn_limit))
14443 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14445 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14447 else if (unformat (line_input, "disable"))
14448 enable_disable = 0;
14453 M (WANT_L2_MACS_EVENTS, mp);
14454 mp->enable_disable = enable_disable;
14455 mp->pid = htonl (getpid ());
14456 mp->learn_limit = htonl (learn_limit);
14457 mp->scan_delay = (u8) scan_delay;
14458 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14465 api_input_acl_set_interface (vat_main_t * vam)
14467 unformat_input_t *i = vam->input;
14468 vl_api_input_acl_set_interface_t *mp;
14470 int sw_if_index_set;
14471 u32 ip4_table_index = ~0;
14472 u32 ip6_table_index = ~0;
14473 u32 l2_table_index = ~0;
14477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14480 sw_if_index_set = 1;
14481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14482 sw_if_index_set = 1;
14483 else if (unformat (i, "del"))
14485 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14487 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14489 else if (unformat (i, "l2-table %d", &l2_table_index))
14493 clib_warning ("parse error '%U'", format_unformat_error, i);
14498 if (sw_if_index_set == 0)
14500 errmsg ("missing interface name or sw_if_index");
14504 M (INPUT_ACL_SET_INTERFACE, mp);
14506 mp->sw_if_index = ntohl (sw_if_index);
14507 mp->ip4_table_index = ntohl (ip4_table_index);
14508 mp->ip6_table_index = ntohl (ip6_table_index);
14509 mp->l2_table_index = ntohl (l2_table_index);
14510 mp->is_add = is_add;
14518 api_output_acl_set_interface (vat_main_t * vam)
14520 unformat_input_t *i = vam->input;
14521 vl_api_output_acl_set_interface_t *mp;
14523 int sw_if_index_set;
14524 u32 ip4_table_index = ~0;
14525 u32 ip6_table_index = ~0;
14526 u32 l2_table_index = ~0;
14530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14533 sw_if_index_set = 1;
14534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14535 sw_if_index_set = 1;
14536 else if (unformat (i, "del"))
14538 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14540 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14542 else if (unformat (i, "l2-table %d", &l2_table_index))
14546 clib_warning ("parse error '%U'", format_unformat_error, i);
14551 if (sw_if_index_set == 0)
14553 errmsg ("missing interface name or sw_if_index");
14557 M (OUTPUT_ACL_SET_INTERFACE, mp);
14559 mp->sw_if_index = ntohl (sw_if_index);
14560 mp->ip4_table_index = ntohl (ip4_table_index);
14561 mp->ip6_table_index = ntohl (ip6_table_index);
14562 mp->l2_table_index = ntohl (l2_table_index);
14563 mp->is_add = is_add;
14571 api_ip_address_dump (vat_main_t * vam)
14573 unformat_input_t *i = vam->input;
14574 vl_api_ip_address_dump_t *mp;
14575 vl_api_control_ping_t *mp_ping;
14576 u32 sw_if_index = ~0;
14577 u8 sw_if_index_set = 0;
14582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14584 if (unformat (i, "sw_if_index %d", &sw_if_index))
14585 sw_if_index_set = 1;
14587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14588 sw_if_index_set = 1;
14589 else if (unformat (i, "ipv4"))
14591 else if (unformat (i, "ipv6"))
14597 if (ipv4_set && ipv6_set)
14599 errmsg ("ipv4 and ipv6 flags cannot be both set");
14603 if ((!ipv4_set) && (!ipv6_set))
14605 errmsg ("no ipv4 nor ipv6 flag set");
14609 if (sw_if_index_set == 0)
14611 errmsg ("missing interface name or sw_if_index");
14615 vam->current_sw_if_index = sw_if_index;
14616 vam->is_ipv6 = ipv6_set;
14618 M (IP_ADDRESS_DUMP, mp);
14619 mp->sw_if_index = ntohl (sw_if_index);
14620 mp->is_ipv6 = ipv6_set;
14623 /* Use a control ping for synchronization */
14624 MPING (CONTROL_PING, mp_ping);
14632 api_ip_dump (vat_main_t * vam)
14634 vl_api_ip_dump_t *mp;
14635 vl_api_control_ping_t *mp_ping;
14636 unformat_input_t *in = vam->input;
14643 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14645 if (unformat (in, "ipv4"))
14647 else if (unformat (in, "ipv6"))
14653 if (ipv4_set && ipv6_set)
14655 errmsg ("ipv4 and ipv6 flags cannot be both set");
14659 if ((!ipv4_set) && (!ipv6_set))
14661 errmsg ("no ipv4 nor ipv6 flag set");
14665 is_ipv6 = ipv6_set;
14666 vam->is_ipv6 = is_ipv6;
14668 /* free old data */
14669 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14671 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14673 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14676 mp->is_ipv6 = ipv6_set;
14679 /* Use a control ping for synchronization */
14680 MPING (CONTROL_PING, mp_ping);
14688 api_ipsec_spd_add_del (vat_main_t * vam)
14690 unformat_input_t *i = vam->input;
14691 vl_api_ipsec_spd_add_del_t *mp;
14696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14698 if (unformat (i, "spd_id %d", &spd_id))
14700 else if (unformat (i, "del"))
14704 clib_warning ("parse error '%U'", format_unformat_error, i);
14710 errmsg ("spd_id must be set");
14714 M (IPSEC_SPD_ADD_DEL, mp);
14716 mp->spd_id = ntohl (spd_id);
14717 mp->is_add = is_add;
14725 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14727 unformat_input_t *i = vam->input;
14728 vl_api_ipsec_interface_add_del_spd_t *mp;
14730 u8 sw_if_index_set = 0;
14731 u32 spd_id = (u32) ~ 0;
14735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14737 if (unformat (i, "del"))
14739 else if (unformat (i, "spd_id %d", &spd_id))
14742 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14743 sw_if_index_set = 1;
14744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14745 sw_if_index_set = 1;
14748 clib_warning ("parse error '%U'", format_unformat_error, i);
14754 if (spd_id == (u32) ~ 0)
14756 errmsg ("spd_id must be set");
14760 if (sw_if_index_set == 0)
14762 errmsg ("missing interface name or sw_if_index");
14766 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14768 mp->spd_id = ntohl (spd_id);
14769 mp->sw_if_index = ntohl (sw_if_index);
14770 mp->is_add = is_add;
14778 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14780 unformat_input_t *i = vam->input;
14781 vl_api_ipsec_spd_entry_add_del_t *mp;
14782 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14783 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14785 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14786 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14787 vl_api_address_t laddr_start = { }, laddr_stop =
14796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14798 if (unformat (i, "del"))
14800 if (unformat (i, "outbound"))
14802 if (unformat (i, "inbound"))
14804 else if (unformat (i, "spd_id %d", &spd_id))
14806 else if (unformat (i, "sa_id %d", &sa_id))
14808 else if (unformat (i, "priority %d", &priority))
14810 else if (unformat (i, "protocol %d", &protocol))
14812 else if (unformat (i, "lport_start %d", &lport_start))
14814 else if (unformat (i, "lport_stop %d", &lport_stop))
14816 else if (unformat (i, "rport_start %d", &rport_start))
14818 else if (unformat (i, "rport_stop %d", &rport_stop))
14820 else if (unformat (i, "laddr_start %U",
14821 unformat_vl_api_address, &laddr_start))
14823 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14826 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14829 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14833 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14835 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14837 clib_warning ("unsupported action: 'resolve'");
14843 clib_warning ("parse error '%U'", format_unformat_error, i);
14849 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14851 mp->is_add = is_add;
14853 mp->entry.spd_id = ntohl (spd_id);
14854 mp->entry.priority = ntohl (priority);
14855 mp->entry.is_outbound = is_outbound;
14857 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14858 sizeof (vl_api_address_t));
14859 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14860 sizeof (vl_api_address_t));
14861 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14862 sizeof (vl_api_address_t));
14863 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14864 sizeof (vl_api_address_t));
14866 mp->entry.protocol = (u8) protocol;
14867 mp->entry.local_port_start = ntohs ((u16) lport_start);
14868 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14869 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14870 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14871 mp->entry.policy = (u8) policy;
14872 mp->entry.sa_id = ntohl (sa_id);
14880 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14882 unformat_input_t *i = vam->input;
14883 vl_api_ipsec_sad_entry_add_del_t *mp;
14884 u32 sad_id = 0, spi = 0;
14885 u8 *ck = 0, *ik = 0;
14888 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14889 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14890 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14891 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14892 vl_api_address_t tun_src, tun_dst;
14895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14897 if (unformat (i, "del"))
14899 else if (unformat (i, "sad_id %d", &sad_id))
14901 else if (unformat (i, "spi %d", &spi))
14903 else if (unformat (i, "esp"))
14904 protocol = IPSEC_API_PROTO_ESP;
14906 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14908 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14909 if (ADDRESS_IP6 == tun_src.af)
14910 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14913 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14915 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14916 if (ADDRESS_IP6 == tun_src.af)
14917 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14920 if (unformat (i, "crypto_alg %U",
14921 unformat_ipsec_api_crypto_alg, &crypto_alg))
14923 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14925 else if (unformat (i, "integ_alg %U",
14926 unformat_ipsec_api_integ_alg, &integ_alg))
14928 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14932 clib_warning ("parse error '%U'", format_unformat_error, i);
14938 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14940 mp->is_add = is_add;
14941 mp->entry.sad_id = ntohl (sad_id);
14942 mp->entry.protocol = protocol;
14943 mp->entry.spi = ntohl (spi);
14944 mp->entry.flags = flags;
14946 mp->entry.crypto_algorithm = crypto_alg;
14947 mp->entry.integrity_algorithm = integ_alg;
14948 mp->entry.crypto_key.length = vec_len (ck);
14949 mp->entry.integrity_key.length = vec_len (ik);
14951 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14952 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14954 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14955 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14958 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14960 clib_memcpy (mp->entry.integrity_key.data, ik,
14961 mp->entry.integrity_key.length);
14963 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14965 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14966 sizeof (mp->entry.tunnel_src));
14967 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14968 sizeof (mp->entry.tunnel_dst));
14977 api_ipsec_sa_set_key (vat_main_t * vam)
14979 unformat_input_t *i = vam->input;
14980 vl_api_ipsec_sa_set_key_t *mp;
14982 u8 *ck = 0, *ik = 0;
14985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14987 if (unformat (i, "sa_id %d", &sa_id))
14989 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14991 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14995 clib_warning ("parse error '%U'", format_unformat_error, i);
15000 M (IPSEC_SA_SET_KEY, mp);
15002 mp->sa_id = ntohl (sa_id);
15003 mp->crypto_key.length = vec_len (ck);
15004 mp->integrity_key.length = vec_len (ik);
15006 if (mp->crypto_key.length > sizeof (mp->crypto_key.data))
15007 mp->crypto_key.length = sizeof (mp->crypto_key.data);
15009 if (mp->integrity_key.length > sizeof (mp->integrity_key.data))
15010 mp->integrity_key.length = sizeof (mp->integrity_key.data);
15013 clib_memcpy (mp->crypto_key.data, ck, mp->crypto_key.length);
15015 clib_memcpy (mp->integrity_key.data, ik, mp->integrity_key.length);
15023 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15025 unformat_input_t *i = vam->input;
15026 vl_api_ipsec_tunnel_if_add_del_t *mp;
15027 u32 local_spi = 0, remote_spi = 0;
15028 u32 crypto_alg = 0, integ_alg = 0;
15029 u8 *lck = NULL, *rck = NULL;
15030 u8 *lik = NULL, *rik = NULL;
15031 vl_api_address_t local_ip = { 0 };
15032 vl_api_address_t remote_ip = { 0 };
15035 u8 anti_replay = 0;
15040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15042 if (unformat (i, "del"))
15044 else if (unformat (i, "esn"))
15046 else if (unformat (i, "anti_replay"))
15048 else if (unformat (i, "local_spi %d", &local_spi))
15050 else if (unformat (i, "remote_spi %d", &remote_spi))
15053 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
15056 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
15058 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15061 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15063 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15065 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15069 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
15071 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15073 errmsg ("unsupported crypto-alg: '%U'\n",
15074 format_ipsec_crypto_alg, crypto_alg);
15080 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
15082 if (integ_alg >= IPSEC_INTEG_N_ALG)
15084 errmsg ("unsupported integ-alg: '%U'\n",
15085 format_ipsec_integ_alg, integ_alg);
15089 else if (unformat (i, "instance %u", &instance))
15093 errmsg ("parse error '%U'\n", format_unformat_error, i);
15098 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15100 mp->is_add = is_add;
15102 mp->anti_replay = anti_replay;
15104 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
15105 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
15107 mp->local_spi = htonl (local_spi);
15108 mp->remote_spi = htonl (remote_spi);
15109 mp->crypto_alg = (u8) crypto_alg;
15111 mp->local_crypto_key_len = 0;
15114 mp->local_crypto_key_len = vec_len (lck);
15115 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15116 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15117 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15120 mp->remote_crypto_key_len = 0;
15123 mp->remote_crypto_key_len = vec_len (rck);
15124 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15125 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15126 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15129 mp->integ_alg = (u8) integ_alg;
15131 mp->local_integ_key_len = 0;
15134 mp->local_integ_key_len = vec_len (lik);
15135 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15136 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15137 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15140 mp->remote_integ_key_len = 0;
15143 mp->remote_integ_key_len = vec_len (rik);
15144 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15145 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15146 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15151 mp->renumber = renumber;
15152 mp->show_instance = ntohl (instance);
15161 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15163 vat_main_t *vam = &vat_main;
15165 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15166 "crypto_key %U integ_alg %u integ_key %U flags %x "
15167 "tunnel_src_addr %U tunnel_dst_addr %U "
15168 "salt %u seq_outbound %lu last_seq_inbound %lu "
15169 "replay_window %lu\n",
15170 ntohl (mp->entry.sad_id),
15171 ntohl (mp->sw_if_index),
15172 ntohl (mp->entry.spi),
15173 ntohl (mp->entry.protocol),
15174 ntohl (mp->entry.crypto_algorithm),
15175 format_hex_bytes, mp->entry.crypto_key.data,
15176 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
15177 format_hex_bytes, mp->entry.integrity_key.data,
15178 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
15179 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
15180 &mp->entry.tunnel_dst, ntohl (mp->salt),
15181 clib_net_to_host_u64 (mp->seq_outbound),
15182 clib_net_to_host_u64 (mp->last_seq_inbound),
15183 clib_net_to_host_u64 (mp->replay_window));
15186 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15187 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15190 vat_json_object_add_address (vat_json_node_t * node,
15191 const vl_api_address_t * addr)
15193 if (ADDRESS_IP6 == addr->af)
15195 struct in6_addr ip6;
15197 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
15198 vat_json_object_add_ip6 (node, "ip_address", ip6);
15202 struct in_addr ip4;
15204 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
15205 vat_json_object_add_ip4 (node, "ip_address", ip4);
15209 static void vl_api_ipsec_sa_details_t_handler_json
15210 (vl_api_ipsec_sa_details_t * mp)
15212 vat_main_t *vam = &vat_main;
15213 vat_json_node_t *node = NULL;
15214 vl_api_ipsec_sad_flags_t flags;
15216 if (VAT_JSON_ARRAY != vam->json_tree.type)
15218 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15219 vat_json_init_array (&vam->json_tree);
15221 node = vat_json_array_add (&vam->json_tree);
15223 vat_json_init_object (node);
15224 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
15225 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15226 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
15227 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
15228 vat_json_object_add_uint (node, "crypto_alg",
15229 ntohl (mp->entry.crypto_algorithm));
15230 vat_json_object_add_uint (node, "integ_alg",
15231 ntohl (mp->entry.integrity_algorithm));
15232 flags = ntohl (mp->entry.flags);
15233 vat_json_object_add_uint (node, "use_esn",
15235 IPSEC_API_SAD_FLAG_USE_EXTENDED_SEQ_NUM));
15236 vat_json_object_add_uint (node, "use_anti_replay",
15237 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
15238 vat_json_object_add_uint (node, "is_tunnel",
15239 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
15240 vat_json_object_add_uint (node, "is_tunnel_ip6",
15241 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
15242 vat_json_object_add_uint (node, "udp_encap",
15243 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
15244 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
15245 mp->entry.crypto_key.length);
15246 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
15247 mp->entry.integrity_key.length);
15248 vat_json_object_add_address (node, &mp->entry.tunnel_src);
15249 vat_json_object_add_address (node, &mp->entry.tunnel_dst);
15250 vat_json_object_add_uint (node, "replay_window",
15251 clib_net_to_host_u64 (mp->replay_window));
15255 api_ipsec_sa_dump (vat_main_t * vam)
15257 unformat_input_t *i = vam->input;
15258 vl_api_ipsec_sa_dump_t *mp;
15259 vl_api_control_ping_t *mp_ping;
15263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15265 if (unformat (i, "sa_id %d", &sa_id))
15269 clib_warning ("parse error '%U'", format_unformat_error, i);
15274 M (IPSEC_SA_DUMP, mp);
15276 mp->sa_id = ntohl (sa_id);
15280 /* Use a control ping for synchronization */
15281 M (CONTROL_PING, mp_ping);
15289 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15291 unformat_input_t *i = vam->input;
15292 vl_api_ipsec_tunnel_if_set_key_t *mp;
15293 u32 sw_if_index = ~0;
15294 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15305 (i, "local crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15306 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15309 (i, "remote crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15310 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15313 (i, "local integ %U", unformat_ipsec_api_integ_alg, &alg))
15314 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15317 (i, "remote integ %U", unformat_ipsec_api_integ_alg, &alg))
15318 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15319 else if (unformat (i, "%U", unformat_hex_string, &key))
15323 clib_warning ("parse error '%U'", format_unformat_error, i);
15328 if (sw_if_index == ~0)
15330 errmsg ("interface must be specified");
15334 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15336 errmsg ("key type must be specified");
15342 errmsg ("algorithm must be specified");
15346 if (vec_len (key) == 0)
15348 errmsg ("key must be specified");
15352 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15354 mp->sw_if_index = htonl (sw_if_index);
15356 mp->key_type = key_type;
15357 mp->key_len = vec_len (key);
15358 clib_memcpy (mp->key, key, vec_len (key));
15367 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15369 unformat_input_t *i = vam->input;
15370 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15371 u32 sw_if_index = ~0;
15373 u8 is_outbound = (u8) ~ 0;
15376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15378 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15380 else if (unformat (i, "sa_id %d", &sa_id))
15382 else if (unformat (i, "outbound"))
15384 else if (unformat (i, "inbound"))
15388 clib_warning ("parse error '%U'", format_unformat_error, i);
15393 if (sw_if_index == ~0)
15395 errmsg ("interface must be specified");
15401 errmsg ("SA ID must be specified");
15405 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15407 mp->sw_if_index = htonl (sw_if_index);
15408 mp->sa_id = htonl (sa_id);
15409 mp->is_outbound = is_outbound;
15418 api_get_first_msg_id (vat_main_t * vam)
15420 vl_api_get_first_msg_id_t *mp;
15421 unformat_input_t *i = vam->input;
15426 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15428 if (unformat (i, "client %s", &name))
15436 errmsg ("missing client name");
15439 vec_add1 (name, 0);
15441 if (vec_len (name) > 63)
15443 errmsg ("client name too long");
15447 M (GET_FIRST_MSG_ID, mp);
15448 clib_memcpy (mp->name, name, vec_len (name));
15455 api_cop_interface_enable_disable (vat_main_t * vam)
15457 unformat_input_t *line_input = vam->input;
15458 vl_api_cop_interface_enable_disable_t *mp;
15459 u32 sw_if_index = ~0;
15460 u8 enable_disable = 1;
15463 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15465 if (unformat (line_input, "disable"))
15466 enable_disable = 0;
15467 if (unformat (line_input, "enable"))
15468 enable_disable = 1;
15469 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15470 vam, &sw_if_index))
15472 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15478 if (sw_if_index == ~0)
15480 errmsg ("missing interface name or sw_if_index");
15484 /* Construct the API message */
15485 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15486 mp->sw_if_index = ntohl (sw_if_index);
15487 mp->enable_disable = enable_disable;
15491 /* Wait for the reply */
15497 api_cop_whitelist_enable_disable (vat_main_t * vam)
15499 unformat_input_t *line_input = vam->input;
15500 vl_api_cop_whitelist_enable_disable_t *mp;
15501 u32 sw_if_index = ~0;
15502 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15506 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15508 if (unformat (line_input, "ip4"))
15510 else if (unformat (line_input, "ip6"))
15512 else if (unformat (line_input, "default"))
15514 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15515 vam, &sw_if_index))
15517 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15519 else if (unformat (line_input, "fib-id %d", &fib_id))
15525 if (sw_if_index == ~0)
15527 errmsg ("missing interface name or sw_if_index");
15531 /* Construct the API message */
15532 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15533 mp->sw_if_index = ntohl (sw_if_index);
15534 mp->fib_id = ntohl (fib_id);
15537 mp->default_cop = default_cop;
15541 /* Wait for the reply */
15547 api_get_node_graph (vat_main_t * vam)
15549 vl_api_get_node_graph_t *mp;
15552 M (GET_NODE_GRAPH, mp);
15556 /* Wait for the reply */
15562 /** Used for parsing LISP eids */
15563 typedef CLIB_PACKED(struct{
15564 u8 addr[16]; /**< eid address */
15565 u32 len; /**< prefix length if IP */
15566 u8 type; /**< type of eid */
15571 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15573 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15575 clib_memset (a, 0, sizeof (a[0]));
15577 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15579 a->type = 0; /* ipv4 type */
15581 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15583 a->type = 1; /* ipv6 type */
15585 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15587 a->type = 2; /* mac type */
15589 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15591 a->type = 3; /* NSH type */
15592 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15593 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15600 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15609 lisp_eid_size_vat (u8 type)
15626 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15628 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15632 api_one_add_del_locator_set (vat_main_t * vam)
15634 unformat_input_t *input = vam->input;
15635 vl_api_one_add_del_locator_set_t *mp;
15637 u8 *locator_set_name = NULL;
15638 u8 locator_set_name_set = 0;
15639 vl_api_local_locator_t locator, *locators = 0;
15640 u32 sw_if_index, priority, weight;
15644 /* Parse args required to build the message */
15645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15647 if (unformat (input, "del"))
15651 else if (unformat (input, "locator-set %s", &locator_set_name))
15653 locator_set_name_set = 1;
15655 else if (unformat (input, "sw_if_index %u p %u w %u",
15656 &sw_if_index, &priority, &weight))
15658 locator.sw_if_index = htonl (sw_if_index);
15659 locator.priority = priority;
15660 locator.weight = weight;
15661 vec_add1 (locators, locator);
15665 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15666 &sw_if_index, &priority, &weight))
15668 locator.sw_if_index = htonl (sw_if_index);
15669 locator.priority = priority;
15670 locator.weight = weight;
15671 vec_add1 (locators, locator);
15677 if (locator_set_name_set == 0)
15679 errmsg ("missing locator-set name");
15680 vec_free (locators);
15684 if (vec_len (locator_set_name) > 64)
15686 errmsg ("locator-set name too long");
15687 vec_free (locator_set_name);
15688 vec_free (locators);
15691 vec_add1 (locator_set_name, 0);
15693 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15695 /* Construct the API message */
15696 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15698 mp->is_add = is_add;
15699 clib_memcpy (mp->locator_set_name, locator_set_name,
15700 vec_len (locator_set_name));
15701 vec_free (locator_set_name);
15703 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15705 clib_memcpy (mp->locators, locators, data_len);
15706 vec_free (locators);
15711 /* Wait for a reply... */
15716 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15719 api_one_add_del_locator (vat_main_t * vam)
15721 unformat_input_t *input = vam->input;
15722 vl_api_one_add_del_locator_t *mp;
15723 u32 tmp_if_index = ~0;
15724 u32 sw_if_index = ~0;
15725 u8 sw_if_index_set = 0;
15726 u8 sw_if_index_if_name_set = 0;
15728 u8 priority_set = 0;
15732 u8 *locator_set_name = NULL;
15733 u8 locator_set_name_set = 0;
15736 /* Parse args required to build the message */
15737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15739 if (unformat (input, "del"))
15743 else if (unformat (input, "locator-set %s", &locator_set_name))
15745 locator_set_name_set = 1;
15747 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15750 sw_if_index_if_name_set = 1;
15751 sw_if_index = tmp_if_index;
15753 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15755 sw_if_index_set = 1;
15756 sw_if_index = tmp_if_index;
15758 else if (unformat (input, "p %d", &priority))
15762 else if (unformat (input, "w %d", &weight))
15770 if (locator_set_name_set == 0)
15772 errmsg ("missing locator-set name");
15776 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15778 errmsg ("missing sw_if_index");
15779 vec_free (locator_set_name);
15783 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15785 errmsg ("cannot use both params interface name and sw_if_index");
15786 vec_free (locator_set_name);
15790 if (priority_set == 0)
15792 errmsg ("missing locator-set priority");
15793 vec_free (locator_set_name);
15797 if (weight_set == 0)
15799 errmsg ("missing locator-set weight");
15800 vec_free (locator_set_name);
15804 if (vec_len (locator_set_name) > 64)
15806 errmsg ("locator-set name too long");
15807 vec_free (locator_set_name);
15810 vec_add1 (locator_set_name, 0);
15812 /* Construct the API message */
15813 M (ONE_ADD_DEL_LOCATOR, mp);
15815 mp->is_add = is_add;
15816 mp->sw_if_index = ntohl (sw_if_index);
15817 mp->priority = priority;
15818 mp->weight = weight;
15819 clib_memcpy (mp->locator_set_name, locator_set_name,
15820 vec_len (locator_set_name));
15821 vec_free (locator_set_name);
15826 /* Wait for a reply... */
15831 #define api_lisp_add_del_locator api_one_add_del_locator
15834 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15836 u32 *key_id = va_arg (*args, u32 *);
15839 if (unformat (input, "%s", &s))
15841 if (!strcmp ((char *) s, "sha1"))
15842 key_id[0] = HMAC_SHA_1_96;
15843 else if (!strcmp ((char *) s, "sha256"))
15844 key_id[0] = HMAC_SHA_256_128;
15847 clib_warning ("invalid key_id: '%s'", s);
15848 key_id[0] = HMAC_NO_KEY;
15859 api_one_add_del_local_eid (vat_main_t * vam)
15861 unformat_input_t *input = vam->input;
15862 vl_api_one_add_del_local_eid_t *mp;
15865 lisp_eid_vat_t _eid, *eid = &_eid;
15866 u8 *locator_set_name = 0;
15867 u8 locator_set_name_set = 0;
15873 /* Parse args required to build the message */
15874 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15876 if (unformat (input, "del"))
15880 else if (unformat (input, "vni %d", &vni))
15884 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15888 else if (unformat (input, "locator-set %s", &locator_set_name))
15890 locator_set_name_set = 1;
15892 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15894 else if (unformat (input, "secret-key %_%v%_", &key))
15900 if (locator_set_name_set == 0)
15902 errmsg ("missing locator-set name");
15908 errmsg ("EID address not set!");
15909 vec_free (locator_set_name);
15913 if (key && (0 == key_id))
15915 errmsg ("invalid key_id!");
15919 if (vec_len (key) > 64)
15921 errmsg ("key too long");
15926 if (vec_len (locator_set_name) > 64)
15928 errmsg ("locator-set name too long");
15929 vec_free (locator_set_name);
15932 vec_add1 (locator_set_name, 0);
15934 /* Construct the API message */
15935 M (ONE_ADD_DEL_LOCAL_EID, mp);
15937 mp->is_add = is_add;
15938 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15939 mp->eid_type = eid->type;
15940 mp->prefix_len = eid->len;
15941 mp->vni = clib_host_to_net_u32 (vni);
15942 mp->key_id = clib_host_to_net_u16 (key_id);
15943 clib_memcpy (mp->locator_set_name, locator_set_name,
15944 vec_len (locator_set_name));
15945 clib_memcpy (mp->key, key, vec_len (key));
15947 vec_free (locator_set_name);
15953 /* Wait for a reply... */
15958 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15961 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15963 u32 dp_table = 0, vni = 0;;
15964 unformat_input_t *input = vam->input;
15965 vl_api_gpe_add_del_fwd_entry_t *mp;
15967 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15968 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15969 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15970 u32 action = ~0, w;
15971 ip4_address_t rmt_rloc4, lcl_rloc4;
15972 ip6_address_t rmt_rloc6, lcl_rloc6;
15973 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15976 clib_memset (&rloc, 0, sizeof (rloc));
15978 /* Parse args required to build the message */
15979 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15981 if (unformat (input, "del"))
15983 else if (unformat (input, "add"))
15985 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15989 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15993 else if (unformat (input, "vrf %d", &dp_table))
15995 else if (unformat (input, "bd %d", &dp_table))
15997 else if (unformat (input, "vni %d", &vni))
15999 else if (unformat (input, "w %d", &w))
16003 errmsg ("No RLOC configured for setting priority/weight!");
16006 curr_rloc->weight = w;
16008 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16009 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16013 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16015 vec_add1 (lcl_locs, rloc);
16017 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16018 vec_add1 (rmt_locs, rloc);
16019 /* weight saved in rmt loc */
16020 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16022 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16023 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16026 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16028 vec_add1 (lcl_locs, rloc);
16030 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16031 vec_add1 (rmt_locs, rloc);
16032 /* weight saved in rmt loc */
16033 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16035 else if (unformat (input, "action %d", &action))
16041 clib_warning ("parse error '%U'", format_unformat_error, input);
16048 errmsg ("remote eid addresses not set");
16052 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16054 errmsg ("eid types don't match");
16058 if (0 == rmt_locs && (u32) ~ 0 == action)
16060 errmsg ("action not set for negative mapping");
16064 /* Construct the API message */
16065 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16066 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16068 mp->is_add = is_add;
16069 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16070 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16071 mp->eid_type = rmt_eid->type;
16072 mp->dp_table = clib_host_to_net_u32 (dp_table);
16073 mp->vni = clib_host_to_net_u32 (vni);
16074 mp->rmt_len = rmt_eid->len;
16075 mp->lcl_len = lcl_eid->len;
16076 mp->action = action;
16078 if (0 != rmt_locs && 0 != lcl_locs)
16080 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16081 clib_memcpy (mp->locs, lcl_locs,
16082 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16084 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16085 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16086 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16088 vec_free (lcl_locs);
16089 vec_free (rmt_locs);
16094 /* Wait for a reply... */
16100 api_one_add_del_map_server (vat_main_t * vam)
16102 unformat_input_t *input = vam->input;
16103 vl_api_one_add_del_map_server_t *mp;
16107 ip4_address_t ipv4;
16108 ip6_address_t ipv6;
16111 /* Parse args required to build the message */
16112 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16114 if (unformat (input, "del"))
16118 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16122 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16130 if (ipv4_set && ipv6_set)
16132 errmsg ("both eid v4 and v6 addresses set");
16136 if (!ipv4_set && !ipv6_set)
16138 errmsg ("eid addresses not set");
16142 /* Construct the API message */
16143 M (ONE_ADD_DEL_MAP_SERVER, mp);
16145 mp->is_add = is_add;
16149 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16154 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16160 /* Wait for a reply... */
16165 #define api_lisp_add_del_map_server api_one_add_del_map_server
16168 api_one_add_del_map_resolver (vat_main_t * vam)
16170 unformat_input_t *input = vam->input;
16171 vl_api_one_add_del_map_resolver_t *mp;
16175 ip4_address_t ipv4;
16176 ip6_address_t ipv6;
16179 /* Parse args required to build the message */
16180 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16182 if (unformat (input, "del"))
16186 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16190 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16198 if (ipv4_set && ipv6_set)
16200 errmsg ("both eid v4 and v6 addresses set");
16204 if (!ipv4_set && !ipv6_set)
16206 errmsg ("eid addresses not set");
16210 /* Construct the API message */
16211 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16213 mp->is_add = is_add;
16217 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16222 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16228 /* Wait for a reply... */
16233 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16236 api_lisp_gpe_enable_disable (vat_main_t * vam)
16238 unformat_input_t *input = vam->input;
16239 vl_api_gpe_enable_disable_t *mp;
16244 /* Parse args required to build the message */
16245 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16247 if (unformat (input, "enable"))
16252 else if (unformat (input, "disable"))
16263 errmsg ("Value not set");
16267 /* Construct the API message */
16268 M (GPE_ENABLE_DISABLE, mp);
16275 /* Wait for a reply... */
16281 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16283 unformat_input_t *input = vam->input;
16284 vl_api_one_rloc_probe_enable_disable_t *mp;
16289 /* Parse args required to build the message */
16290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16292 if (unformat (input, "enable"))
16297 else if (unformat (input, "disable"))
16305 errmsg ("Value not set");
16309 /* Construct the API message */
16310 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16312 mp->is_enabled = is_en;
16317 /* Wait for a reply... */
16322 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16325 api_one_map_register_enable_disable (vat_main_t * vam)
16327 unformat_input_t *input = vam->input;
16328 vl_api_one_map_register_enable_disable_t *mp;
16333 /* Parse args required to build the message */
16334 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16336 if (unformat (input, "enable"))
16341 else if (unformat (input, "disable"))
16349 errmsg ("Value not set");
16353 /* Construct the API message */
16354 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16356 mp->is_enabled = is_en;
16361 /* Wait for a reply... */
16366 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16369 api_one_enable_disable (vat_main_t * vam)
16371 unformat_input_t *input = vam->input;
16372 vl_api_one_enable_disable_t *mp;
16377 /* Parse args required to build the message */
16378 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16380 if (unformat (input, "enable"))
16385 else if (unformat (input, "disable"))
16395 errmsg ("Value not set");
16399 /* Construct the API message */
16400 M (ONE_ENABLE_DISABLE, mp);
16407 /* Wait for a reply... */
16412 #define api_lisp_enable_disable api_one_enable_disable
16415 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16417 unformat_input_t *input = vam->input;
16418 vl_api_one_enable_disable_xtr_mode_t *mp;
16423 /* Parse args required to build the message */
16424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16426 if (unformat (input, "enable"))
16431 else if (unformat (input, "disable"))
16441 errmsg ("Value not set");
16445 /* Construct the API message */
16446 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16453 /* Wait for a reply... */
16459 api_one_show_xtr_mode (vat_main_t * vam)
16461 vl_api_one_show_xtr_mode_t *mp;
16464 /* Construct the API message */
16465 M (ONE_SHOW_XTR_MODE, mp);
16470 /* Wait for a reply... */
16476 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16478 unformat_input_t *input = vam->input;
16479 vl_api_one_enable_disable_pitr_mode_t *mp;
16484 /* Parse args required to build the message */
16485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16487 if (unformat (input, "enable"))
16492 else if (unformat (input, "disable"))
16502 errmsg ("Value not set");
16506 /* Construct the API message */
16507 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16514 /* Wait for a reply... */
16520 api_one_show_pitr_mode (vat_main_t * vam)
16522 vl_api_one_show_pitr_mode_t *mp;
16525 /* Construct the API message */
16526 M (ONE_SHOW_PITR_MODE, mp);
16531 /* Wait for a reply... */
16537 api_one_enable_disable_petr_mode (vat_main_t * vam)
16539 unformat_input_t *input = vam->input;
16540 vl_api_one_enable_disable_petr_mode_t *mp;
16545 /* Parse args required to build the message */
16546 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16548 if (unformat (input, "enable"))
16553 else if (unformat (input, "disable"))
16563 errmsg ("Value not set");
16567 /* Construct the API message */
16568 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16575 /* Wait for a reply... */
16581 api_one_show_petr_mode (vat_main_t * vam)
16583 vl_api_one_show_petr_mode_t *mp;
16586 /* Construct the API message */
16587 M (ONE_SHOW_PETR_MODE, mp);
16592 /* Wait for a reply... */
16598 api_show_one_map_register_state (vat_main_t * vam)
16600 vl_api_show_one_map_register_state_t *mp;
16603 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16608 /* wait for reply */
16613 #define api_show_lisp_map_register_state api_show_one_map_register_state
16616 api_show_one_rloc_probe_state (vat_main_t * vam)
16618 vl_api_show_one_rloc_probe_state_t *mp;
16621 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16626 /* wait for reply */
16631 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16634 api_one_add_del_ndp_entry (vat_main_t * vam)
16636 vl_api_one_add_del_ndp_entry_t *mp;
16637 unformat_input_t *input = vam->input;
16642 u8 mac[6] = { 0, };
16643 u8 ip6[16] = { 0, };
16647 /* Parse args required to build the message */
16648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16650 if (unformat (input, "del"))
16652 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16654 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16656 else if (unformat (input, "bd %d", &bd))
16660 errmsg ("parse error '%U'", format_unformat_error, input);
16665 if (!bd_set || !ip_set || (!mac_set && is_add))
16667 errmsg ("Missing BD, IP or MAC!");
16671 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16672 mp->is_add = is_add;
16673 clib_memcpy (mp->mac, mac, 6);
16674 mp->bd = clib_host_to_net_u32 (bd);
16675 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16680 /* wait for reply */
16686 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16688 vl_api_one_add_del_l2_arp_entry_t *mp;
16689 unformat_input_t *input = vam->input;
16694 u8 mac[6] = { 0, };
16695 u32 ip4 = 0, bd = ~0;
16698 /* Parse args required to build the message */
16699 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16701 if (unformat (input, "del"))
16703 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16705 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16707 else if (unformat (input, "bd %d", &bd))
16711 errmsg ("parse error '%U'", format_unformat_error, input);
16716 if (!bd_set || !ip_set || (!mac_set && is_add))
16718 errmsg ("Missing BD, IP or MAC!");
16722 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16723 mp->is_add = is_add;
16724 clib_memcpy (mp->mac, mac, 6);
16725 mp->bd = clib_host_to_net_u32 (bd);
16731 /* wait for reply */
16737 api_one_ndp_bd_get (vat_main_t * vam)
16739 vl_api_one_ndp_bd_get_t *mp;
16742 M (ONE_NDP_BD_GET, mp);
16747 /* wait for reply */
16753 api_one_ndp_entries_get (vat_main_t * vam)
16755 vl_api_one_ndp_entries_get_t *mp;
16756 unformat_input_t *input = vam->input;
16761 /* Parse args required to build the message */
16762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16764 if (unformat (input, "bd %d", &bd))
16768 errmsg ("parse error '%U'", format_unformat_error, input);
16775 errmsg ("Expected bridge domain!");
16779 M (ONE_NDP_ENTRIES_GET, mp);
16780 mp->bd = clib_host_to_net_u32 (bd);
16785 /* wait for reply */
16791 api_one_l2_arp_bd_get (vat_main_t * vam)
16793 vl_api_one_l2_arp_bd_get_t *mp;
16796 M (ONE_L2_ARP_BD_GET, mp);
16801 /* wait for reply */
16807 api_one_l2_arp_entries_get (vat_main_t * vam)
16809 vl_api_one_l2_arp_entries_get_t *mp;
16810 unformat_input_t *input = vam->input;
16815 /* Parse args required to build the message */
16816 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16818 if (unformat (input, "bd %d", &bd))
16822 errmsg ("parse error '%U'", format_unformat_error, input);
16829 errmsg ("Expected bridge domain!");
16833 M (ONE_L2_ARP_ENTRIES_GET, mp);
16834 mp->bd = clib_host_to_net_u32 (bd);
16839 /* wait for reply */
16845 api_one_stats_enable_disable (vat_main_t * vam)
16847 vl_api_one_stats_enable_disable_t *mp;
16848 unformat_input_t *input = vam->input;
16853 /* Parse args required to build the message */
16854 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16856 if (unformat (input, "enable"))
16861 else if (unformat (input, "disable"))
16871 errmsg ("Value not set");
16875 M (ONE_STATS_ENABLE_DISABLE, mp);
16881 /* wait for reply */
16887 api_show_one_stats_enable_disable (vat_main_t * vam)
16889 vl_api_show_one_stats_enable_disable_t *mp;
16892 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16897 /* wait for reply */
16903 api_show_one_map_request_mode (vat_main_t * vam)
16905 vl_api_show_one_map_request_mode_t *mp;
16908 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16913 /* wait for reply */
16918 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16921 api_one_map_request_mode (vat_main_t * vam)
16923 unformat_input_t *input = vam->input;
16924 vl_api_one_map_request_mode_t *mp;
16928 /* Parse args required to build the message */
16929 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16931 if (unformat (input, "dst-only"))
16933 else if (unformat (input, "src-dst"))
16937 errmsg ("parse error '%U'", format_unformat_error, input);
16942 M (ONE_MAP_REQUEST_MODE, mp);
16949 /* wait for reply */
16954 #define api_lisp_map_request_mode api_one_map_request_mode
16957 * Enable/disable ONE proxy ITR.
16959 * @param vam vpp API test context
16960 * @return return code
16963 api_one_pitr_set_locator_set (vat_main_t * vam)
16965 u8 ls_name_set = 0;
16966 unformat_input_t *input = vam->input;
16967 vl_api_one_pitr_set_locator_set_t *mp;
16972 /* Parse args required to build the message */
16973 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16975 if (unformat (input, "del"))
16977 else if (unformat (input, "locator-set %s", &ls_name))
16981 errmsg ("parse error '%U'", format_unformat_error, input);
16988 errmsg ("locator-set name not set!");
16992 M (ONE_PITR_SET_LOCATOR_SET, mp);
16994 mp->is_add = is_add;
16995 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16996 vec_free (ls_name);
17001 /* wait for reply */
17006 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17009 api_one_nsh_set_locator_set (vat_main_t * vam)
17011 u8 ls_name_set = 0;
17012 unformat_input_t *input = vam->input;
17013 vl_api_one_nsh_set_locator_set_t *mp;
17018 /* Parse args required to build the message */
17019 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17021 if (unformat (input, "del"))
17023 else if (unformat (input, "ls %s", &ls_name))
17027 errmsg ("parse error '%U'", format_unformat_error, input);
17032 if (!ls_name_set && is_add)
17034 errmsg ("locator-set name not set!");
17038 M (ONE_NSH_SET_LOCATOR_SET, mp);
17040 mp->is_add = is_add;
17041 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17042 vec_free (ls_name);
17047 /* wait for reply */
17053 api_show_one_pitr (vat_main_t * vam)
17055 vl_api_show_one_pitr_t *mp;
17058 if (!vam->json_output)
17060 print (vam->ofp, "%=20s", "lisp status:");
17063 M (SHOW_ONE_PITR, mp);
17067 /* Wait for a reply... */
17072 #define api_show_lisp_pitr api_show_one_pitr
17075 api_one_use_petr (vat_main_t * vam)
17077 unformat_input_t *input = vam->input;
17078 vl_api_one_use_petr_t *mp;
17083 clib_memset (&ip, 0, sizeof (ip));
17085 /* Parse args required to build the message */
17086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17088 if (unformat (input, "disable"))
17091 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17094 ip_addr_version (&ip) = IP4;
17097 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17100 ip_addr_version (&ip) = IP6;
17104 errmsg ("parse error '%U'", format_unformat_error, input);
17109 M (ONE_USE_PETR, mp);
17111 mp->is_add = is_add;
17114 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17116 clib_memcpy (mp->address, &ip, 4);
17118 clib_memcpy (mp->address, &ip, 16);
17124 /* wait for reply */
17129 #define api_lisp_use_petr api_one_use_petr
17132 api_show_one_nsh_mapping (vat_main_t * vam)
17134 vl_api_show_one_use_petr_t *mp;
17137 if (!vam->json_output)
17139 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17142 M (SHOW_ONE_NSH_MAPPING, mp);
17146 /* Wait for a reply... */
17152 api_show_one_use_petr (vat_main_t * vam)
17154 vl_api_show_one_use_petr_t *mp;
17157 if (!vam->json_output)
17159 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17162 M (SHOW_ONE_USE_PETR, mp);
17166 /* Wait for a reply... */
17171 #define api_show_lisp_use_petr api_show_one_use_petr
17174 * Add/delete mapping between vni and vrf
17177 api_one_eid_table_add_del_map (vat_main_t * vam)
17179 unformat_input_t *input = vam->input;
17180 vl_api_one_eid_table_add_del_map_t *mp;
17181 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17182 u32 vni, vrf, bd_index;
17185 /* Parse args required to build the message */
17186 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17188 if (unformat (input, "del"))
17190 else if (unformat (input, "vrf %d", &vrf))
17192 else if (unformat (input, "bd_index %d", &bd_index))
17194 else if (unformat (input, "vni %d", &vni))
17200 if (!vni_set || (!vrf_set && !bd_index_set))
17202 errmsg ("missing arguments!");
17206 if (vrf_set && bd_index_set)
17208 errmsg ("error: both vrf and bd entered!");
17212 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17214 mp->is_add = is_add;
17215 mp->vni = htonl (vni);
17216 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17217 mp->is_l2 = bd_index_set;
17222 /* wait for reply */
17227 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17230 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17232 u32 *action = va_arg (*args, u32 *);
17235 if (unformat (input, "%s", &s))
17237 if (!strcmp ((char *) s, "no-action"))
17239 else if (!strcmp ((char *) s, "natively-forward"))
17241 else if (!strcmp ((char *) s, "send-map-request"))
17243 else if (!strcmp ((char *) s, "drop"))
17247 clib_warning ("invalid action: '%s'", s);
17259 * Add/del remote mapping to/from ONE control plane
17261 * @param vam vpp API test context
17262 * @return return code
17265 api_one_add_del_remote_mapping (vat_main_t * vam)
17267 unformat_input_t *input = vam->input;
17268 vl_api_one_add_del_remote_mapping_t *mp;
17270 lisp_eid_vat_t _eid, *eid = &_eid;
17271 lisp_eid_vat_t _seid, *seid = &_seid;
17272 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17273 u32 action = ~0, p, w, data_len;
17274 ip4_address_t rloc4;
17275 ip6_address_t rloc6;
17276 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17279 clib_memset (&rloc, 0, sizeof (rloc));
17281 /* Parse args required to build the message */
17282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17284 if (unformat (input, "del-all"))
17288 else if (unformat (input, "del"))
17292 else if (unformat (input, "add"))
17296 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17300 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17304 else if (unformat (input, "vni %d", &vni))
17308 else if (unformat (input, "p %d w %d", &p, &w))
17312 errmsg ("No RLOC configured for setting priority/weight!");
17315 curr_rloc->priority = p;
17316 curr_rloc->weight = w;
17318 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17321 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17322 vec_add1 (rlocs, rloc);
17323 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17325 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17328 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17329 vec_add1 (rlocs, rloc);
17330 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17332 else if (unformat (input, "action %U",
17333 unformat_negative_mapping_action, &action))
17339 clib_warning ("parse error '%U'", format_unformat_error, input);
17346 errmsg ("missing params!");
17350 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17352 errmsg ("no action set for negative map-reply!");
17356 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17358 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17359 mp->is_add = is_add;
17360 mp->vni = htonl (vni);
17361 mp->action = (u8) action;
17362 mp->is_src_dst = seid_set;
17363 mp->eid_len = eid->len;
17364 mp->seid_len = seid->len;
17365 mp->del_all = del_all;
17366 mp->eid_type = eid->type;
17367 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17368 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17370 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17371 clib_memcpy (mp->rlocs, rlocs, data_len);
17377 /* Wait for a reply... */
17382 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17385 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17386 * forwarding entries in data-plane accordingly.
17388 * @param vam vpp API test context
17389 * @return return code
17392 api_one_add_del_adjacency (vat_main_t * vam)
17394 unformat_input_t *input = vam->input;
17395 vl_api_one_add_del_adjacency_t *mp;
17397 ip4_address_t leid4, reid4;
17398 ip6_address_t leid6, reid6;
17399 u8 reid_mac[6] = { 0 };
17400 u8 leid_mac[6] = { 0 };
17401 u8 reid_type, leid_type;
17402 u32 leid_len = 0, reid_len = 0, len;
17406 leid_type = reid_type = (u8) ~ 0;
17408 /* Parse args required to build the message */
17409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17411 if (unformat (input, "del"))
17415 else if (unformat (input, "add"))
17419 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17422 reid_type = 0; /* ipv4 */
17425 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17428 reid_type = 1; /* ipv6 */
17431 else if (unformat (input, "reid %U", unformat_ethernet_address,
17434 reid_type = 2; /* mac */
17436 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17439 leid_type = 0; /* ipv4 */
17442 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17445 leid_type = 1; /* ipv6 */
17448 else if (unformat (input, "leid %U", unformat_ethernet_address,
17451 leid_type = 2; /* mac */
17453 else if (unformat (input, "vni %d", &vni))
17459 errmsg ("parse error '%U'", format_unformat_error, input);
17464 if ((u8) ~ 0 == reid_type)
17466 errmsg ("missing params!");
17470 if (leid_type != reid_type)
17472 errmsg ("remote and local EIDs are of different types!");
17476 M (ONE_ADD_DEL_ADJACENCY, mp);
17477 mp->is_add = is_add;
17478 mp->vni = htonl (vni);
17479 mp->leid_len = leid_len;
17480 mp->reid_len = reid_len;
17481 mp->eid_type = reid_type;
17483 switch (mp->eid_type)
17486 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17487 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17490 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17491 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17494 clib_memcpy (mp->leid, leid_mac, 6);
17495 clib_memcpy (mp->reid, reid_mac, 6);
17498 errmsg ("unknown EID type %d!", mp->eid_type);
17505 /* Wait for a reply... */
17510 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17513 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17515 u32 *mode = va_arg (*args, u32 *);
17517 if (unformat (input, "lisp"))
17519 else if (unformat (input, "vxlan"))
17528 api_gpe_get_encap_mode (vat_main_t * vam)
17530 vl_api_gpe_get_encap_mode_t *mp;
17533 /* Construct the API message */
17534 M (GPE_GET_ENCAP_MODE, mp);
17539 /* Wait for a reply... */
17545 api_gpe_set_encap_mode (vat_main_t * vam)
17547 unformat_input_t *input = vam->input;
17548 vl_api_gpe_set_encap_mode_t *mp;
17552 /* Parse args required to build the message */
17553 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17555 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17561 /* Construct the API message */
17562 M (GPE_SET_ENCAP_MODE, mp);
17569 /* Wait for a reply... */
17575 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17577 unformat_input_t *input = vam->input;
17578 vl_api_gpe_add_del_iface_t *mp;
17579 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17580 u32 dp_table = 0, vni = 0;
17583 /* Parse args required to build the message */
17584 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17586 if (unformat (input, "up"))
17591 else if (unformat (input, "down"))
17596 else if (unformat (input, "table_id %d", &dp_table))
17600 else if (unformat (input, "bd_id %d", &dp_table))
17605 else if (unformat (input, "vni %d", &vni))
17613 if (action_set == 0)
17615 errmsg ("Action not set");
17618 if (dp_table_set == 0 || vni_set == 0)
17620 errmsg ("vni and dp_table must be set");
17624 /* Construct the API message */
17625 M (GPE_ADD_DEL_IFACE, mp);
17627 mp->is_add = is_add;
17628 mp->dp_table = clib_host_to_net_u32 (dp_table);
17630 mp->vni = clib_host_to_net_u32 (vni);
17635 /* Wait for a reply... */
17641 api_one_map_register_fallback_threshold (vat_main_t * vam)
17643 unformat_input_t *input = vam->input;
17644 vl_api_one_map_register_fallback_threshold_t *mp;
17649 /* Parse args required to build the message */
17650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17652 if (unformat (input, "%u", &value))
17656 clib_warning ("parse error '%U'", format_unformat_error, input);
17663 errmsg ("fallback threshold value is missing!");
17667 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17668 mp->value = clib_host_to_net_u32 (value);
17673 /* Wait for a reply... */
17679 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17681 vl_api_show_one_map_register_fallback_threshold_t *mp;
17684 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17689 /* Wait for a reply... */
17695 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17697 u32 *proto = va_arg (*args, u32 *);
17699 if (unformat (input, "udp"))
17701 else if (unformat (input, "api"))
17710 api_one_set_transport_protocol (vat_main_t * vam)
17712 unformat_input_t *input = vam->input;
17713 vl_api_one_set_transport_protocol_t *mp;
17718 /* Parse args required to build the message */
17719 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17721 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17725 clib_warning ("parse error '%U'", format_unformat_error, input);
17732 errmsg ("Transport protocol missing!");
17736 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17737 mp->protocol = (u8) protocol;
17742 /* Wait for a reply... */
17748 api_one_get_transport_protocol (vat_main_t * vam)
17750 vl_api_one_get_transport_protocol_t *mp;
17753 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17758 /* Wait for a reply... */
17764 api_one_map_register_set_ttl (vat_main_t * vam)
17766 unformat_input_t *input = vam->input;
17767 vl_api_one_map_register_set_ttl_t *mp;
17772 /* Parse args required to build the message */
17773 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17775 if (unformat (input, "%u", &ttl))
17779 clib_warning ("parse error '%U'", format_unformat_error, input);
17786 errmsg ("TTL value missing!");
17790 M (ONE_MAP_REGISTER_SET_TTL, mp);
17791 mp->ttl = clib_host_to_net_u32 (ttl);
17796 /* Wait for a reply... */
17802 api_show_one_map_register_ttl (vat_main_t * vam)
17804 vl_api_show_one_map_register_ttl_t *mp;
17807 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17812 /* Wait for a reply... */
17818 * Add/del map request itr rlocs from ONE control plane and updates
17820 * @param vam vpp API test context
17821 * @return return code
17824 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17826 unformat_input_t *input = vam->input;
17827 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17828 u8 *locator_set_name = 0;
17829 u8 locator_set_name_set = 0;
17833 /* Parse args required to build the message */
17834 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17836 if (unformat (input, "del"))
17840 else if (unformat (input, "%_%v%_", &locator_set_name))
17842 locator_set_name_set = 1;
17846 clib_warning ("parse error '%U'", format_unformat_error, input);
17851 if (is_add && !locator_set_name_set)
17853 errmsg ("itr-rloc is not set!");
17857 if (is_add && vec_len (locator_set_name) > 64)
17859 errmsg ("itr-rloc locator-set name too long");
17860 vec_free (locator_set_name);
17864 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17865 mp->is_add = is_add;
17868 clib_memcpy (mp->locator_set_name, locator_set_name,
17869 vec_len (locator_set_name));
17873 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17875 vec_free (locator_set_name);
17880 /* Wait for a reply... */
17885 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17888 api_one_locator_dump (vat_main_t * vam)
17890 unformat_input_t *input = vam->input;
17891 vl_api_one_locator_dump_t *mp;
17892 vl_api_control_ping_t *mp_ping;
17893 u8 is_index_set = 0, is_name_set = 0;
17898 /* Parse args required to build the message */
17899 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17901 if (unformat (input, "ls_name %_%v%_", &ls_name))
17905 else if (unformat (input, "ls_index %d", &ls_index))
17911 errmsg ("parse error '%U'", format_unformat_error, input);
17916 if (!is_index_set && !is_name_set)
17918 errmsg ("error: expected one of index or name!");
17922 if (is_index_set && is_name_set)
17924 errmsg ("error: only one param expected!");
17928 if (vec_len (ls_name) > 62)
17930 errmsg ("error: locator set name too long!");
17934 if (!vam->json_output)
17936 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17939 M (ONE_LOCATOR_DUMP, mp);
17940 mp->is_index_set = is_index_set;
17943 mp->ls_index = clib_host_to_net_u32 (ls_index);
17946 vec_add1 (ls_name, 0);
17947 strncpy ((char *) mp->ls_name, (char *) ls_name,
17948 sizeof (mp->ls_name) - 1);
17954 /* Use a control ping for synchronization */
17955 MPING (CONTROL_PING, mp_ping);
17958 /* Wait for a reply... */
17963 #define api_lisp_locator_dump api_one_locator_dump
17966 api_one_locator_set_dump (vat_main_t * vam)
17968 vl_api_one_locator_set_dump_t *mp;
17969 vl_api_control_ping_t *mp_ping;
17970 unformat_input_t *input = vam->input;
17974 /* Parse args required to build the message */
17975 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17977 if (unformat (input, "local"))
17981 else if (unformat (input, "remote"))
17987 errmsg ("parse error '%U'", format_unformat_error, input);
17992 if (!vam->json_output)
17994 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17997 M (ONE_LOCATOR_SET_DUMP, mp);
17999 mp->filter = filter;
18004 /* Use a control ping for synchronization */
18005 MPING (CONTROL_PING, mp_ping);
18008 /* Wait for a reply... */
18013 #define api_lisp_locator_set_dump api_one_locator_set_dump
18016 api_one_eid_table_map_dump (vat_main_t * vam)
18020 unformat_input_t *input = vam->input;
18021 vl_api_one_eid_table_map_dump_t *mp;
18022 vl_api_control_ping_t *mp_ping;
18025 /* Parse args required to build the message */
18026 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18028 if (unformat (input, "l2"))
18033 else if (unformat (input, "l3"))
18040 errmsg ("parse error '%U'", format_unformat_error, input);
18047 errmsg ("expected one of 'l2' or 'l3' parameter!");
18051 if (!vam->json_output)
18053 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18056 M (ONE_EID_TABLE_MAP_DUMP, mp);
18062 /* Use a control ping for synchronization */
18063 MPING (CONTROL_PING, mp_ping);
18066 /* Wait for a reply... */
18071 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18074 api_one_eid_table_vni_dump (vat_main_t * vam)
18076 vl_api_one_eid_table_vni_dump_t *mp;
18077 vl_api_control_ping_t *mp_ping;
18080 if (!vam->json_output)
18082 print (vam->ofp, "VNI");
18085 M (ONE_EID_TABLE_VNI_DUMP, mp);
18090 /* Use a control ping for synchronization */
18091 MPING (CONTROL_PING, mp_ping);
18094 /* Wait for a reply... */
18099 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18102 api_one_eid_table_dump (vat_main_t * vam)
18104 unformat_input_t *i = vam->input;
18105 vl_api_one_eid_table_dump_t *mp;
18106 vl_api_control_ping_t *mp_ping;
18107 struct in_addr ip4;
18108 struct in6_addr ip6;
18110 u8 eid_type = ~0, eid_set = 0;
18111 u32 prefix_length = ~0, t, vni = 0;
18114 lisp_nsh_api_t nsh;
18116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18118 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18124 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18130 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18135 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18140 else if (unformat (i, "vni %d", &t))
18144 else if (unformat (i, "local"))
18148 else if (unformat (i, "remote"))
18154 errmsg ("parse error '%U'", format_unformat_error, i);
18159 if (!vam->json_output)
18161 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18162 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18165 M (ONE_EID_TABLE_DUMP, mp);
18167 mp->filter = filter;
18171 mp->vni = htonl (vni);
18172 mp->eid_type = eid_type;
18176 mp->prefix_length = prefix_length;
18177 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18180 mp->prefix_length = prefix_length;
18181 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18184 clib_memcpy (mp->eid, mac, sizeof (mac));
18187 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18190 errmsg ("unknown EID type %d!", eid_type);
18198 /* Use a control ping for synchronization */
18199 MPING (CONTROL_PING, mp_ping);
18202 /* Wait for a reply... */
18207 #define api_lisp_eid_table_dump api_one_eid_table_dump
18210 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18212 unformat_input_t *i = vam->input;
18213 vl_api_gpe_fwd_entries_get_t *mp;
18218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18220 if (unformat (i, "vni %d", &vni))
18226 errmsg ("parse error '%U'", format_unformat_error, i);
18233 errmsg ("vni not set!");
18237 if (!vam->json_output)
18239 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18243 M (GPE_FWD_ENTRIES_GET, mp);
18244 mp->vni = clib_host_to_net_u32 (vni);
18249 /* Wait for a reply... */
18254 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18255 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18256 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18257 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18258 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18259 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18260 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18261 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18264 api_one_adjacencies_get (vat_main_t * vam)
18266 unformat_input_t *i = vam->input;
18267 vl_api_one_adjacencies_get_t *mp;
18272 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18274 if (unformat (i, "vni %d", &vni))
18280 errmsg ("parse error '%U'", format_unformat_error, i);
18287 errmsg ("vni not set!");
18291 if (!vam->json_output)
18293 print (vam->ofp, "%s %40s", "leid", "reid");
18296 M (ONE_ADJACENCIES_GET, mp);
18297 mp->vni = clib_host_to_net_u32 (vni);
18302 /* Wait for a reply... */
18307 #define api_lisp_adjacencies_get api_one_adjacencies_get
18310 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18312 unformat_input_t *i = vam->input;
18313 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18315 u8 ip_family_set = 0, is_ip4 = 1;
18317 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18319 if (unformat (i, "ip4"))
18324 else if (unformat (i, "ip6"))
18331 errmsg ("parse error '%U'", format_unformat_error, i);
18336 if (!ip_family_set)
18338 errmsg ("ip family not set!");
18342 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18343 mp->is_ip4 = is_ip4;
18348 /* Wait for a reply... */
18354 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18356 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18359 if (!vam->json_output)
18361 print (vam->ofp, "VNIs");
18364 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18369 /* Wait for a reply... */
18375 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18377 unformat_input_t *i = vam->input;
18378 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18380 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18381 struct in_addr ip4;
18382 struct in6_addr ip6;
18383 u32 table_id = 0, nh_sw_if_index = ~0;
18385 clib_memset (&ip4, 0, sizeof (ip4));
18386 clib_memset (&ip6, 0, sizeof (ip6));
18388 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18390 if (unformat (i, "del"))
18392 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18393 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18398 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18399 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18404 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18408 nh_sw_if_index = ~0;
18410 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18414 nh_sw_if_index = ~0;
18416 else if (unformat (i, "table %d", &table_id))
18420 errmsg ("parse error '%U'", format_unformat_error, i);
18427 errmsg ("nh addr not set!");
18431 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18432 mp->is_add = is_add;
18433 mp->table_id = clib_host_to_net_u32 (table_id);
18434 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18435 mp->is_ip4 = is_ip4;
18437 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18439 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18444 /* Wait for a reply... */
18450 api_one_map_server_dump (vat_main_t * vam)
18452 vl_api_one_map_server_dump_t *mp;
18453 vl_api_control_ping_t *mp_ping;
18456 if (!vam->json_output)
18458 print (vam->ofp, "%=20s", "Map server");
18461 M (ONE_MAP_SERVER_DUMP, mp);
18465 /* Use a control ping for synchronization */
18466 MPING (CONTROL_PING, mp_ping);
18469 /* Wait for a reply... */
18474 #define api_lisp_map_server_dump api_one_map_server_dump
18477 api_one_map_resolver_dump (vat_main_t * vam)
18479 vl_api_one_map_resolver_dump_t *mp;
18480 vl_api_control_ping_t *mp_ping;
18483 if (!vam->json_output)
18485 print (vam->ofp, "%=20s", "Map resolver");
18488 M (ONE_MAP_RESOLVER_DUMP, mp);
18492 /* Use a control ping for synchronization */
18493 MPING (CONTROL_PING, mp_ping);
18496 /* Wait for a reply... */
18501 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18504 api_one_stats_flush (vat_main_t * vam)
18506 vl_api_one_stats_flush_t *mp;
18509 M (ONE_STATS_FLUSH, mp);
18516 api_one_stats_dump (vat_main_t * vam)
18518 vl_api_one_stats_dump_t *mp;
18519 vl_api_control_ping_t *mp_ping;
18522 M (ONE_STATS_DUMP, mp);
18526 /* Use a control ping for synchronization */
18527 MPING (CONTROL_PING, mp_ping);
18530 /* Wait for a reply... */
18536 api_show_one_status (vat_main_t * vam)
18538 vl_api_show_one_status_t *mp;
18541 if (!vam->json_output)
18543 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18546 M (SHOW_ONE_STATUS, mp);
18549 /* Wait for a reply... */
18554 #define api_show_lisp_status api_show_one_status
18557 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18559 vl_api_gpe_fwd_entry_path_dump_t *mp;
18560 vl_api_control_ping_t *mp_ping;
18561 unformat_input_t *i = vam->input;
18562 u32 fwd_entry_index = ~0;
18565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18567 if (unformat (i, "index %d", &fwd_entry_index))
18573 if (~0 == fwd_entry_index)
18575 errmsg ("no index specified!");
18579 if (!vam->json_output)
18581 print (vam->ofp, "first line");
18584 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18588 /* Use a control ping for synchronization */
18589 MPING (CONTROL_PING, mp_ping);
18592 /* Wait for a reply... */
18598 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18600 vl_api_one_get_map_request_itr_rlocs_t *mp;
18603 if (!vam->json_output)
18605 print (vam->ofp, "%=20s", "itr-rlocs:");
18608 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18611 /* Wait for a reply... */
18616 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18619 api_af_packet_create (vat_main_t * vam)
18621 unformat_input_t *i = vam->input;
18622 vl_api_af_packet_create_t *mp;
18623 u8 *host_if_name = 0;
18625 u8 random_hw_addr = 1;
18628 clib_memset (hw_addr, 0, sizeof (hw_addr));
18630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18632 if (unformat (i, "name %s", &host_if_name))
18633 vec_add1 (host_if_name, 0);
18634 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18635 random_hw_addr = 0;
18640 if (!vec_len (host_if_name))
18642 errmsg ("host-interface name must be specified");
18646 if (vec_len (host_if_name) > 64)
18648 errmsg ("host-interface name too long");
18652 M (AF_PACKET_CREATE, mp);
18654 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18655 clib_memcpy (mp->hw_addr, hw_addr, 6);
18656 mp->use_random_hw_addr = random_hw_addr;
18657 vec_free (host_if_name);
18665 fprintf (vam->ofp ? vam->ofp : stderr,
18666 " new sw_if_index = %d\n", vam->sw_if_index);
18673 api_af_packet_delete (vat_main_t * vam)
18675 unformat_input_t *i = vam->input;
18676 vl_api_af_packet_delete_t *mp;
18677 u8 *host_if_name = 0;
18680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18682 if (unformat (i, "name %s", &host_if_name))
18683 vec_add1 (host_if_name, 0);
18688 if (!vec_len (host_if_name))
18690 errmsg ("host-interface name must be specified");
18694 if (vec_len (host_if_name) > 64)
18696 errmsg ("host-interface name too long");
18700 M (AF_PACKET_DELETE, mp);
18702 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18703 vec_free (host_if_name);
18710 static void vl_api_af_packet_details_t_handler
18711 (vl_api_af_packet_details_t * mp)
18713 vat_main_t *vam = &vat_main;
18715 print (vam->ofp, "%-16s %d",
18716 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18719 static void vl_api_af_packet_details_t_handler_json
18720 (vl_api_af_packet_details_t * mp)
18722 vat_main_t *vam = &vat_main;
18723 vat_json_node_t *node = NULL;
18725 if (VAT_JSON_ARRAY != vam->json_tree.type)
18727 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18728 vat_json_init_array (&vam->json_tree);
18730 node = vat_json_array_add (&vam->json_tree);
18732 vat_json_init_object (node);
18733 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18734 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18738 api_af_packet_dump (vat_main_t * vam)
18740 vl_api_af_packet_dump_t *mp;
18741 vl_api_control_ping_t *mp_ping;
18744 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18745 /* Get list of tap interfaces */
18746 M (AF_PACKET_DUMP, mp);
18749 /* Use a control ping for synchronization */
18750 MPING (CONTROL_PING, mp_ping);
18758 api_policer_add_del (vat_main_t * vam)
18760 unformat_input_t *i = vam->input;
18761 vl_api_policer_add_del_t *mp;
18771 u8 color_aware = 0;
18772 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18775 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18776 conform_action.dscp = 0;
18777 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18778 exceed_action.dscp = 0;
18779 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18780 violate_action.dscp = 0;
18782 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18784 if (unformat (i, "del"))
18786 else if (unformat (i, "name %s", &name))
18787 vec_add1 (name, 0);
18788 else if (unformat (i, "cir %u", &cir))
18790 else if (unformat (i, "eir %u", &eir))
18792 else if (unformat (i, "cb %u", &cb))
18794 else if (unformat (i, "eb %u", &eb))
18796 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18799 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18802 else if (unformat (i, "type %U", unformat_policer_type, &type))
18804 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18807 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18810 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18813 else if (unformat (i, "color-aware"))
18819 if (!vec_len (name))
18821 errmsg ("policer name must be specified");
18825 if (vec_len (name) > 64)
18827 errmsg ("policer name too long");
18831 M (POLICER_ADD_DEL, mp);
18833 clib_memcpy (mp->name, name, vec_len (name));
18835 mp->is_add = is_add;
18836 mp->cir = ntohl (cir);
18837 mp->eir = ntohl (eir);
18838 mp->cb = clib_net_to_host_u64 (cb);
18839 mp->eb = clib_net_to_host_u64 (eb);
18840 mp->rate_type = rate_type;
18841 mp->round_type = round_type;
18843 mp->conform_action_type = conform_action.action_type;
18844 mp->conform_dscp = conform_action.dscp;
18845 mp->exceed_action_type = exceed_action.action_type;
18846 mp->exceed_dscp = exceed_action.dscp;
18847 mp->violate_action_type = violate_action.action_type;
18848 mp->violate_dscp = violate_action.dscp;
18849 mp->color_aware = color_aware;
18857 api_policer_dump (vat_main_t * vam)
18859 unformat_input_t *i = vam->input;
18860 vl_api_policer_dump_t *mp;
18861 vl_api_control_ping_t *mp_ping;
18862 u8 *match_name = 0;
18863 u8 match_name_valid = 0;
18866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18868 if (unformat (i, "name %s", &match_name))
18870 vec_add1 (match_name, 0);
18871 match_name_valid = 1;
18877 M (POLICER_DUMP, mp);
18878 mp->match_name_valid = match_name_valid;
18879 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18880 vec_free (match_name);
18884 /* Use a control ping for synchronization */
18885 MPING (CONTROL_PING, mp_ping);
18888 /* Wait for a reply... */
18894 api_policer_classify_set_interface (vat_main_t * vam)
18896 unformat_input_t *i = vam->input;
18897 vl_api_policer_classify_set_interface_t *mp;
18899 int sw_if_index_set;
18900 u32 ip4_table_index = ~0;
18901 u32 ip6_table_index = ~0;
18902 u32 l2_table_index = ~0;
18906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18909 sw_if_index_set = 1;
18910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18911 sw_if_index_set = 1;
18912 else if (unformat (i, "del"))
18914 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18916 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18918 else if (unformat (i, "l2-table %d", &l2_table_index))
18922 clib_warning ("parse error '%U'", format_unformat_error, i);
18927 if (sw_if_index_set == 0)
18929 errmsg ("missing interface name or sw_if_index");
18933 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18935 mp->sw_if_index = ntohl (sw_if_index);
18936 mp->ip4_table_index = ntohl (ip4_table_index);
18937 mp->ip6_table_index = ntohl (ip6_table_index);
18938 mp->l2_table_index = ntohl (l2_table_index);
18939 mp->is_add = is_add;
18947 api_policer_classify_dump (vat_main_t * vam)
18949 unformat_input_t *i = vam->input;
18950 vl_api_policer_classify_dump_t *mp;
18951 vl_api_control_ping_t *mp_ping;
18952 u8 type = POLICER_CLASSIFY_N_TABLES;
18955 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18959 errmsg ("classify table type must be specified");
18963 if (!vam->json_output)
18965 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18968 M (POLICER_CLASSIFY_DUMP, mp);
18973 /* Use a control ping for synchronization */
18974 MPING (CONTROL_PING, mp_ping);
18977 /* Wait for a reply... */
18983 api_netmap_create (vat_main_t * vam)
18985 unformat_input_t *i = vam->input;
18986 vl_api_netmap_create_t *mp;
18989 u8 random_hw_addr = 1;
18994 clib_memset (hw_addr, 0, sizeof (hw_addr));
18996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18998 if (unformat (i, "name %s", &if_name))
18999 vec_add1 (if_name, 0);
19000 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19001 random_hw_addr = 0;
19002 else if (unformat (i, "pipe"))
19004 else if (unformat (i, "master"))
19006 else if (unformat (i, "slave"))
19012 if (!vec_len (if_name))
19014 errmsg ("interface name must be specified");
19018 if (vec_len (if_name) > 64)
19020 errmsg ("interface name too long");
19024 M (NETMAP_CREATE, mp);
19026 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19027 clib_memcpy (mp->hw_addr, hw_addr, 6);
19028 mp->use_random_hw_addr = random_hw_addr;
19029 mp->is_pipe = is_pipe;
19030 mp->is_master = is_master;
19031 vec_free (if_name);
19039 api_netmap_delete (vat_main_t * vam)
19041 unformat_input_t *i = vam->input;
19042 vl_api_netmap_delete_t *mp;
19046 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19048 if (unformat (i, "name %s", &if_name))
19049 vec_add1 (if_name, 0);
19054 if (!vec_len (if_name))
19056 errmsg ("interface name must be specified");
19060 if (vec_len (if_name) > 64)
19062 errmsg ("interface name too long");
19066 M (NETMAP_DELETE, mp);
19068 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19069 vec_free (if_name);
19077 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19079 if (fp->afi == IP46_TYPE_IP6)
19081 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19082 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19083 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19084 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19085 format_ip6_address, fp->next_hop);
19086 else if (fp->afi == IP46_TYPE_IP4)
19088 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19089 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19090 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19091 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19092 format_ip4_address, fp->next_hop);
19096 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19097 vl_api_fib_path_t * fp)
19099 struct in_addr ip4;
19100 struct in6_addr ip6;
19102 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19103 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19104 vat_json_object_add_uint (node, "is_local", fp->is_local);
19105 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19106 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19107 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19108 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19109 if (fp->afi == IP46_TYPE_IP4)
19111 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19112 vat_json_object_add_ip4 (node, "next_hop", ip4);
19114 else if (fp->afi == IP46_TYPE_IP6)
19116 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19117 vat_json_object_add_ip6 (node, "next_hop", ip6);
19122 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19124 vat_main_t *vam = &vat_main;
19125 int count = ntohl (mp->mt_count);
19126 vl_api_fib_path_t *fp;
19129 print (vam->ofp, "[%d]: sw_if_index %d via:",
19130 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19132 for (i = 0; i < count; i++)
19134 vl_api_mpls_fib_path_print (vam, fp);
19138 print (vam->ofp, "");
19141 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19142 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19145 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19147 vat_main_t *vam = &vat_main;
19148 vat_json_node_t *node = NULL;
19149 int count = ntohl (mp->mt_count);
19150 vl_api_fib_path_t *fp;
19153 if (VAT_JSON_ARRAY != vam->json_tree.type)
19155 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19156 vat_json_init_array (&vam->json_tree);
19158 node = vat_json_array_add (&vam->json_tree);
19160 vat_json_init_object (node);
19161 vat_json_object_add_uint (node, "tunnel_index",
19162 ntohl (mp->mt_tunnel_index));
19163 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19165 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19168 for (i = 0; i < count; i++)
19170 vl_api_mpls_fib_path_json_print (node, fp);
19176 api_mpls_tunnel_dump (vat_main_t * vam)
19178 vl_api_mpls_tunnel_dump_t *mp;
19179 vl_api_control_ping_t *mp_ping;
19180 u32 sw_if_index = ~0;
19183 /* Parse args required to build the message */
19184 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19186 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19190 print (vam->ofp, " sw_if_index %d", sw_if_index);
19192 M (MPLS_TUNNEL_DUMP, mp);
19193 mp->sw_if_index = htonl (sw_if_index);
19196 /* Use a control ping for synchronization */
19197 MPING (CONTROL_PING, mp_ping);
19204 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19205 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19209 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19211 vat_main_t *vam = &vat_main;
19212 int count = ntohl (mp->count);
19213 vl_api_fib_path_t *fp;
19217 "table-id %d, label %u, ess_bit %u",
19218 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19220 for (i = 0; i < count; i++)
19222 vl_api_mpls_fib_path_print (vam, fp);
19227 static void vl_api_mpls_fib_details_t_handler_json
19228 (vl_api_mpls_fib_details_t * mp)
19230 vat_main_t *vam = &vat_main;
19231 int count = ntohl (mp->count);
19232 vat_json_node_t *node = NULL;
19233 vl_api_fib_path_t *fp;
19236 if (VAT_JSON_ARRAY != vam->json_tree.type)
19238 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19239 vat_json_init_array (&vam->json_tree);
19241 node = vat_json_array_add (&vam->json_tree);
19243 vat_json_init_object (node);
19244 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19245 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19246 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19247 vat_json_object_add_uint (node, "path_count", count);
19249 for (i = 0; i < count; i++)
19251 vl_api_mpls_fib_path_json_print (node, fp);
19257 api_mpls_fib_dump (vat_main_t * vam)
19259 vl_api_mpls_fib_dump_t *mp;
19260 vl_api_control_ping_t *mp_ping;
19263 M (MPLS_FIB_DUMP, mp);
19266 /* Use a control ping for synchronization */
19267 MPING (CONTROL_PING, mp_ping);
19274 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19275 #define vl_api_ip_fib_details_t_print vl_noop_handler
19278 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19280 vat_main_t *vam = &vat_main;
19281 int count = ntohl (mp->count);
19282 vl_api_fib_path_t *fp;
19286 "table-id %d, prefix %U/%d stats-index %d",
19287 ntohl (mp->table_id), format_ip4_address, mp->address,
19288 mp->address_length, ntohl (mp->stats_index));
19290 for (i = 0; i < count; i++)
19292 if (fp->afi == IP46_TYPE_IP6)
19294 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19295 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19296 "next_hop_table %d",
19297 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19298 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19299 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
19300 else if (fp->afi == IP46_TYPE_IP4)
19302 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19303 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19304 "next_hop_table %d",
19305 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19306 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19307 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
19312 static void vl_api_ip_fib_details_t_handler_json
19313 (vl_api_ip_fib_details_t * mp)
19315 vat_main_t *vam = &vat_main;
19316 int count = ntohl (mp->count);
19317 vat_json_node_t *node = NULL;
19318 struct in_addr ip4;
19319 struct in6_addr ip6;
19320 vl_api_fib_path_t *fp;
19323 if (VAT_JSON_ARRAY != vam->json_tree.type)
19325 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19326 vat_json_init_array (&vam->json_tree);
19328 node = vat_json_array_add (&vam->json_tree);
19330 vat_json_init_object (node);
19331 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19332 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19333 vat_json_object_add_ip4 (node, "prefix", ip4);
19334 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19335 vat_json_object_add_uint (node, "path_count", count);
19337 for (i = 0; i < count; i++)
19339 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19340 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19341 vat_json_object_add_uint (node, "is_local", fp->is_local);
19342 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19343 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19344 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19345 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19346 if (fp->afi == IP46_TYPE_IP4)
19348 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19349 vat_json_object_add_ip4 (node, "next_hop", ip4);
19351 else if (fp->afi == IP46_TYPE_IP6)
19353 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19354 vat_json_object_add_ip6 (node, "next_hop", ip6);
19360 api_ip_fib_dump (vat_main_t * vam)
19362 vl_api_ip_fib_dump_t *mp;
19363 vl_api_control_ping_t *mp_ping;
19366 M (IP_FIB_DUMP, mp);
19369 /* Use a control ping for synchronization */
19370 MPING (CONTROL_PING, mp_ping);
19378 api_ip_mfib_dump (vat_main_t * vam)
19380 vl_api_ip_mfib_dump_t *mp;
19381 vl_api_control_ping_t *mp_ping;
19384 M (IP_MFIB_DUMP, mp);
19387 /* Use a control ping for synchronization */
19388 MPING (CONTROL_PING, mp_ping);
19395 static void vl_api_ip_neighbor_details_t_handler
19396 (vl_api_ip_neighbor_details_t * mp)
19398 vat_main_t *vam = &vat_main;
19400 print (vam->ofp, "%c %U %U",
19401 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19402 format_vl_api_mac_address, &mp->neighbor.mac_address,
19403 format_vl_api_address, &mp->neighbor.ip_address);
19406 static void vl_api_ip_neighbor_details_t_handler_json
19407 (vl_api_ip_neighbor_details_t * mp)
19410 vat_main_t *vam = &vat_main;
19411 vat_json_node_t *node;
19413 if (VAT_JSON_ARRAY != vam->json_tree.type)
19415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19416 vat_json_init_array (&vam->json_tree);
19418 node = vat_json_array_add (&vam->json_tree);
19420 vat_json_init_object (node);
19421 vat_json_object_add_string_copy
19423 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19424 (u8 *) "static" : (u8 *) "dynamic"));
19426 vat_json_object_add_string_copy (node, "link_layer",
19427 format (0, "%U", format_vl_api_mac_address,
19428 &mp->neighbor.mac_address));
19429 vat_json_object_add_address (node, &mp->neighbor.ip_address);
19433 api_ip_neighbor_dump (vat_main_t * vam)
19435 unformat_input_t *i = vam->input;
19436 vl_api_ip_neighbor_dump_t *mp;
19437 vl_api_control_ping_t *mp_ping;
19439 u32 sw_if_index = ~0;
19442 /* Parse args required to build the message */
19443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19445 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19447 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19449 else if (unformat (i, "ip6"))
19455 if (sw_if_index == ~0)
19457 errmsg ("missing interface name or sw_if_index");
19461 M (IP_NEIGHBOR_DUMP, mp);
19462 mp->is_ipv6 = (u8) is_ipv6;
19463 mp->sw_if_index = ntohl (sw_if_index);
19466 /* Use a control ping for synchronization */
19467 MPING (CONTROL_PING, mp_ping);
19474 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19475 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19478 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19480 vat_main_t *vam = &vat_main;
19481 int count = ntohl (mp->count);
19482 vl_api_fib_path_t *fp;
19486 "table-id %d, prefix %U/%d stats-index %d",
19487 ntohl (mp->table_id), format_ip6_address, mp->address,
19488 mp->address_length, ntohl (mp->stats_index));
19490 for (i = 0; i < count; i++)
19492 if (fp->afi == IP46_TYPE_IP6)
19494 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19495 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19496 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19497 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19498 format_ip6_address, fp->next_hop);
19499 else if (fp->afi == IP46_TYPE_IP4)
19501 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19502 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19503 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19504 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19505 format_ip4_address, fp->next_hop);
19510 static void vl_api_ip6_fib_details_t_handler_json
19511 (vl_api_ip6_fib_details_t * mp)
19513 vat_main_t *vam = &vat_main;
19514 int count = ntohl (mp->count);
19515 vat_json_node_t *node = NULL;
19516 struct in_addr ip4;
19517 struct in6_addr ip6;
19518 vl_api_fib_path_t *fp;
19521 if (VAT_JSON_ARRAY != vam->json_tree.type)
19523 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19524 vat_json_init_array (&vam->json_tree);
19526 node = vat_json_array_add (&vam->json_tree);
19528 vat_json_init_object (node);
19529 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19530 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19531 vat_json_object_add_ip6 (node, "prefix", ip6);
19532 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19533 vat_json_object_add_uint (node, "path_count", count);
19535 for (i = 0; i < count; i++)
19537 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19538 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19539 vat_json_object_add_uint (node, "is_local", fp->is_local);
19540 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19541 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19542 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19543 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19544 if (fp->afi == IP46_TYPE_IP4)
19546 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19547 vat_json_object_add_ip4 (node, "next_hop", ip4);
19549 else if (fp->afi == IP46_TYPE_IP6)
19551 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19552 vat_json_object_add_ip6 (node, "next_hop", ip6);
19558 api_ip6_fib_dump (vat_main_t * vam)
19560 vl_api_ip6_fib_dump_t *mp;
19561 vl_api_control_ping_t *mp_ping;
19564 M (IP6_FIB_DUMP, mp);
19567 /* Use a control ping for synchronization */
19568 MPING (CONTROL_PING, mp_ping);
19576 api_ip6_mfib_dump (vat_main_t * vam)
19578 vl_api_ip6_mfib_dump_t *mp;
19579 vl_api_control_ping_t *mp_ping;
19582 M (IP6_MFIB_DUMP, mp);
19585 /* Use a control ping for synchronization */
19586 MPING (CONTROL_PING, mp_ping);
19594 api_classify_table_ids (vat_main_t * vam)
19596 vl_api_classify_table_ids_t *mp;
19599 /* Construct the API message */
19600 M (CLASSIFY_TABLE_IDS, mp);
19609 api_classify_table_by_interface (vat_main_t * vam)
19611 unformat_input_t *input = vam->input;
19612 vl_api_classify_table_by_interface_t *mp;
19614 u32 sw_if_index = ~0;
19616 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19618 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19620 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19625 if (sw_if_index == ~0)
19627 errmsg ("missing interface name or sw_if_index");
19631 /* Construct the API message */
19632 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19634 mp->sw_if_index = ntohl (sw_if_index);
19642 api_classify_table_info (vat_main_t * vam)
19644 unformat_input_t *input = vam->input;
19645 vl_api_classify_table_info_t *mp;
19649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19651 if (unformat (input, "table_id %d", &table_id))
19656 if (table_id == ~0)
19658 errmsg ("missing table id");
19662 /* Construct the API message */
19663 M (CLASSIFY_TABLE_INFO, mp);
19665 mp->table_id = ntohl (table_id);
19673 api_classify_session_dump (vat_main_t * vam)
19675 unformat_input_t *input = vam->input;
19676 vl_api_classify_session_dump_t *mp;
19677 vl_api_control_ping_t *mp_ping;
19681 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19683 if (unformat (input, "table_id %d", &table_id))
19688 if (table_id == ~0)
19690 errmsg ("missing table id");
19694 /* Construct the API message */
19695 M (CLASSIFY_SESSION_DUMP, mp);
19697 mp->table_id = ntohl (table_id);
19700 /* Use a control ping for synchronization */
19701 MPING (CONTROL_PING, mp_ping);
19709 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19711 vat_main_t *vam = &vat_main;
19713 print (vam->ofp, "collector_address %U, collector_port %d, "
19714 "src_address %U, vrf_id %d, path_mtu %u, "
19715 "template_interval %u, udp_checksum %d",
19716 format_ip4_address, mp->collector_address,
19717 ntohs (mp->collector_port),
19718 format_ip4_address, mp->src_address,
19719 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19720 ntohl (mp->template_interval), mp->udp_checksum);
19723 vam->result_ready = 1;
19727 vl_api_ipfix_exporter_details_t_handler_json
19728 (vl_api_ipfix_exporter_details_t * mp)
19730 vat_main_t *vam = &vat_main;
19731 vat_json_node_t node;
19732 struct in_addr collector_address;
19733 struct in_addr src_address;
19735 vat_json_init_object (&node);
19736 clib_memcpy (&collector_address, &mp->collector_address,
19737 sizeof (collector_address));
19738 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19739 vat_json_object_add_uint (&node, "collector_port",
19740 ntohs (mp->collector_port));
19741 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19742 vat_json_object_add_ip4 (&node, "src_address", src_address);
19743 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19744 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19745 vat_json_object_add_uint (&node, "template_interval",
19746 ntohl (mp->template_interval));
19747 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19749 vat_json_print (vam->ofp, &node);
19750 vat_json_free (&node);
19752 vam->result_ready = 1;
19756 api_ipfix_exporter_dump (vat_main_t * vam)
19758 vl_api_ipfix_exporter_dump_t *mp;
19761 /* Construct the API message */
19762 M (IPFIX_EXPORTER_DUMP, mp);
19771 api_ipfix_classify_stream_dump (vat_main_t * vam)
19773 vl_api_ipfix_classify_stream_dump_t *mp;
19776 /* Construct the API message */
19777 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19788 vl_api_ipfix_classify_stream_details_t_handler
19789 (vl_api_ipfix_classify_stream_details_t * mp)
19791 vat_main_t *vam = &vat_main;
19792 print (vam->ofp, "domain_id %d, src_port %d",
19793 ntohl (mp->domain_id), ntohs (mp->src_port));
19795 vam->result_ready = 1;
19799 vl_api_ipfix_classify_stream_details_t_handler_json
19800 (vl_api_ipfix_classify_stream_details_t * mp)
19802 vat_main_t *vam = &vat_main;
19803 vat_json_node_t node;
19805 vat_json_init_object (&node);
19806 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19807 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19809 vat_json_print (vam->ofp, &node);
19810 vat_json_free (&node);
19812 vam->result_ready = 1;
19816 api_ipfix_classify_table_dump (vat_main_t * vam)
19818 vl_api_ipfix_classify_table_dump_t *mp;
19819 vl_api_control_ping_t *mp_ping;
19822 if (!vam->json_output)
19824 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19825 "transport_protocol");
19828 /* Construct the API message */
19829 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19834 /* Use a control ping for synchronization */
19835 MPING (CONTROL_PING, mp_ping);
19843 vl_api_ipfix_classify_table_details_t_handler
19844 (vl_api_ipfix_classify_table_details_t * mp)
19846 vat_main_t *vam = &vat_main;
19847 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19848 mp->transport_protocol);
19852 vl_api_ipfix_classify_table_details_t_handler_json
19853 (vl_api_ipfix_classify_table_details_t * mp)
19855 vat_json_node_t *node = NULL;
19856 vat_main_t *vam = &vat_main;
19858 if (VAT_JSON_ARRAY != vam->json_tree.type)
19860 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19861 vat_json_init_array (&vam->json_tree);
19864 node = vat_json_array_add (&vam->json_tree);
19865 vat_json_init_object (node);
19867 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19868 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19869 vat_json_object_add_uint (node, "transport_protocol",
19870 mp->transport_protocol);
19874 api_sw_interface_span_enable_disable (vat_main_t * vam)
19876 unformat_input_t *i = vam->input;
19877 vl_api_sw_interface_span_enable_disable_t *mp;
19878 u32 src_sw_if_index = ~0;
19879 u32 dst_sw_if_index = ~0;
19884 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19887 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19889 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19893 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19895 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19897 else if (unformat (i, "disable"))
19899 else if (unformat (i, "rx"))
19901 else if (unformat (i, "tx"))
19903 else if (unformat (i, "both"))
19905 else if (unformat (i, "l2"))
19911 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19913 mp->sw_if_index_from = htonl (src_sw_if_index);
19914 mp->sw_if_index_to = htonl (dst_sw_if_index);
19924 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19927 vat_main_t *vam = &vat_main;
19928 u8 *sw_if_from_name = 0;
19929 u8 *sw_if_to_name = 0;
19930 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19931 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19932 char *states[] = { "none", "rx", "tx", "both" };
19936 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19938 if ((u32) p->value[0] == sw_if_index_from)
19940 sw_if_from_name = (u8 *)(p->key);
19944 if ((u32) p->value[0] == sw_if_index_to)
19946 sw_if_to_name = (u8 *)(p->key);
19947 if (sw_if_from_name)
19952 print (vam->ofp, "%20s => %20s (%s) %s",
19953 sw_if_from_name, sw_if_to_name, states[mp->state],
19954 mp->is_l2 ? "l2" : "device");
19958 vl_api_sw_interface_span_details_t_handler_json
19959 (vl_api_sw_interface_span_details_t * mp)
19961 vat_main_t *vam = &vat_main;
19962 vat_json_node_t *node = NULL;
19963 u8 *sw_if_from_name = 0;
19964 u8 *sw_if_to_name = 0;
19965 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19966 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19970 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19972 if ((u32) p->value[0] == sw_if_index_from)
19974 sw_if_from_name = (u8 *)(p->key);
19978 if ((u32) p->value[0] == sw_if_index_to)
19980 sw_if_to_name = (u8 *)(p->key);
19981 if (sw_if_from_name)
19987 if (VAT_JSON_ARRAY != vam->json_tree.type)
19989 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19990 vat_json_init_array (&vam->json_tree);
19992 node = vat_json_array_add (&vam->json_tree);
19994 vat_json_init_object (node);
19995 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19996 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19997 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19998 if (0 != sw_if_to_name)
20000 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20002 vat_json_object_add_uint (node, "state", mp->state);
20003 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20007 api_sw_interface_span_dump (vat_main_t * vam)
20009 unformat_input_t *input = vam->input;
20010 vl_api_sw_interface_span_dump_t *mp;
20011 vl_api_control_ping_t *mp_ping;
20015 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20017 if (unformat (input, "l2"))
20023 M (SW_INTERFACE_SPAN_DUMP, mp);
20027 /* Use a control ping for synchronization */
20028 MPING (CONTROL_PING, mp_ping);
20036 api_pg_create_interface (vat_main_t * vam)
20038 unformat_input_t *input = vam->input;
20039 vl_api_pg_create_interface_t *mp;
20043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20045 if (unformat (input, "if_id %d", &if_id))
20052 errmsg ("missing pg interface index");
20056 /* Construct the API message */
20057 M (PG_CREATE_INTERFACE, mp);
20059 mp->interface_id = ntohl (if_id);
20067 api_pg_capture (vat_main_t * vam)
20069 unformat_input_t *input = vam->input;
20070 vl_api_pg_capture_t *mp;
20075 u8 pcap_file_set = 0;
20078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20080 if (unformat (input, "if_id %d", &if_id))
20082 else if (unformat (input, "pcap %s", &pcap_file))
20084 else if (unformat (input, "count %d", &count))
20086 else if (unformat (input, "disable"))
20093 errmsg ("missing pg interface index");
20096 if (pcap_file_set > 0)
20098 if (vec_len (pcap_file) > 255)
20100 errmsg ("pcap file name is too long");
20105 u32 name_len = vec_len (pcap_file);
20106 /* Construct the API message */
20107 M (PG_CAPTURE, mp);
20109 mp->interface_id = ntohl (if_id);
20110 mp->is_enabled = enable;
20111 mp->count = ntohl (count);
20112 mp->pcap_name_length = ntohl (name_len);
20113 if (pcap_file_set != 0)
20115 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20117 vec_free (pcap_file);
20125 api_pg_enable_disable (vat_main_t * vam)
20127 unformat_input_t *input = vam->input;
20128 vl_api_pg_enable_disable_t *mp;
20131 u8 stream_name_set = 0;
20132 u8 *stream_name = 0;
20134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20136 if (unformat (input, "stream %s", &stream_name))
20137 stream_name_set = 1;
20138 else if (unformat (input, "disable"))
20144 if (stream_name_set > 0)
20146 if (vec_len (stream_name) > 255)
20148 errmsg ("stream name too long");
20153 u32 name_len = vec_len (stream_name);
20154 /* Construct the API message */
20155 M (PG_ENABLE_DISABLE, mp);
20157 mp->is_enabled = enable;
20158 if (stream_name_set != 0)
20160 mp->stream_name_length = ntohl (name_len);
20161 clib_memcpy (mp->stream_name, stream_name, name_len);
20163 vec_free (stream_name);
20171 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20173 unformat_input_t *input = vam->input;
20174 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20176 u16 *low_ports = 0;
20177 u16 *high_ports = 0;
20180 vl_api_prefix_t prefix;
20188 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20190 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
20192 else if (unformat (input, "vrf %d", &vrf_id))
20194 else if (unformat (input, "del"))
20196 else if (unformat (input, "port %d", &tmp))
20198 if (tmp == 0 || tmp > 65535)
20200 errmsg ("port %d out of range", tmp);
20204 this_hi = this_low + 1;
20205 vec_add1 (low_ports, this_low);
20206 vec_add1 (high_ports, this_hi);
20208 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20210 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20212 errmsg ("incorrect range parameters");
20216 /* Note: in debug CLI +1 is added to high before
20217 passing to real fn that does "the work"
20218 (ip_source_and_port_range_check_add_del).
20219 This fn is a wrapper around the binary API fn a
20220 control plane will call, which expects this increment
20221 to have occurred. Hence letting the binary API control
20222 plane fn do the increment for consistency between VAT
20223 and other control planes.
20226 vec_add1 (low_ports, this_low);
20227 vec_add1 (high_ports, this_hi);
20233 if (prefix_set == 0)
20235 errmsg ("<address>/<mask> not specified");
20241 errmsg ("VRF ID required, not specified");
20248 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20252 if (vec_len (low_ports) == 0)
20254 errmsg ("At least one port or port range required");
20258 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20260 mp->is_add = is_add;
20262 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
20264 mp->number_of_ranges = vec_len (low_ports);
20266 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20267 vec_free (low_ports);
20269 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20270 vec_free (high_ports);
20272 mp->vrf_id = ntohl (vrf_id);
20280 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20282 unformat_input_t *input = vam->input;
20283 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20284 u32 sw_if_index = ~0;
20286 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20287 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20291 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20293 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20295 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20297 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20299 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20301 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20303 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20305 else if (unformat (input, "del"))
20311 if (sw_if_index == ~0)
20313 errmsg ("Interface required but not specified");
20319 errmsg ("VRF ID required but not specified");
20323 if (tcp_out_vrf_id == 0
20324 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20327 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20331 /* Construct the API message */
20332 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20334 mp->sw_if_index = ntohl (sw_if_index);
20335 mp->is_add = is_add;
20336 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20337 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20338 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20339 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20344 /* Wait for a reply... */
20350 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20352 unformat_input_t *i = vam->input;
20353 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20354 u32 local_sa_id = 0;
20355 u32 remote_sa_id = 0;
20356 ip4_address_t src_address;
20357 ip4_address_t dst_address;
20361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20363 if (unformat (i, "local_sa %d", &local_sa_id))
20365 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20367 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20369 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20371 else if (unformat (i, "del"))
20375 clib_warning ("parse error '%U'", format_unformat_error, i);
20380 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20382 mp->local_sa_id = ntohl (local_sa_id);
20383 mp->remote_sa_id = ntohl (remote_sa_id);
20384 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20385 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20386 mp->is_add = is_add;
20394 api_set_punt (vat_main_t * vam)
20396 unformat_input_t *i = vam->input;
20397 vl_api_set_punt_t *mp;
20404 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20406 if (unformat (i, "ip %d", &ipv))
20408 else if (unformat (i, "protocol %d", &protocol))
20410 else if (unformat (i, "port %d", &port))
20412 else if (unformat (i, "del"))
20416 clib_warning ("parse error '%U'", format_unformat_error, i);
20423 mp->is_add = (u8) is_add;
20424 mp->punt.ipv = (u8) ipv;
20425 mp->punt.l4_protocol = (u8) protocol;
20426 mp->punt.l4_port = htons ((u16) port);
20433 static void vl_api_ipsec_gre_tunnel_details_t_handler
20434 (vl_api_ipsec_gre_tunnel_details_t * mp)
20436 vat_main_t *vam = &vat_main;
20438 print (vam->ofp, "%11d%15U%15U%14d%14d",
20439 ntohl (mp->sw_if_index),
20440 format_ip4_address, &mp->src_address,
20441 format_ip4_address, &mp->dst_address,
20442 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20445 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20446 (vl_api_ipsec_gre_tunnel_details_t * mp)
20448 vat_main_t *vam = &vat_main;
20449 vat_json_node_t *node = NULL;
20450 struct in_addr ip4;
20452 if (VAT_JSON_ARRAY != vam->json_tree.type)
20454 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20455 vat_json_init_array (&vam->json_tree);
20457 node = vat_json_array_add (&vam->json_tree);
20459 vat_json_init_object (node);
20460 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20461 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20462 vat_json_object_add_ip4 (node, "src_address", ip4);
20463 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20464 vat_json_object_add_ip4 (node, "dst_address", ip4);
20465 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20466 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20470 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20472 unformat_input_t *i = vam->input;
20473 vl_api_ipsec_gre_tunnel_dump_t *mp;
20474 vl_api_control_ping_t *mp_ping;
20476 u8 sw_if_index_set = 0;
20479 /* Parse args required to build the message */
20480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20482 if (unformat (i, "sw_if_index %d", &sw_if_index))
20483 sw_if_index_set = 1;
20488 if (sw_if_index_set == 0)
20493 if (!vam->json_output)
20495 print (vam->ofp, "%11s%15s%15s%14s%14s",
20496 "sw_if_index", "src_address", "dst_address",
20497 "local_sa_id", "remote_sa_id");
20500 /* Get list of gre-tunnel interfaces */
20501 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20503 mp->sw_if_index = htonl (sw_if_index);
20507 /* Use a control ping for synchronization */
20508 MPING (CONTROL_PING, mp_ping);
20516 api_delete_subif (vat_main_t * vam)
20518 unformat_input_t *i = vam->input;
20519 vl_api_delete_subif_t *mp;
20520 u32 sw_if_index = ~0;
20523 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20525 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20527 if (unformat (i, "sw_if_index %d", &sw_if_index))
20533 if (sw_if_index == ~0)
20535 errmsg ("missing sw_if_index");
20539 /* Construct the API message */
20540 M (DELETE_SUBIF, mp);
20541 mp->sw_if_index = ntohl (sw_if_index);
20548 #define foreach_pbb_vtr_op \
20549 _("disable", L2_VTR_DISABLED) \
20550 _("pop", L2_VTR_POP_2) \
20551 _("push", L2_VTR_PUSH_2)
20554 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20556 unformat_input_t *i = vam->input;
20557 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20558 u32 sw_if_index = ~0, vtr_op = ~0;
20559 u16 outer_tag = ~0;
20560 u8 dmac[6], smac[6];
20561 u8 dmac_set = 0, smac_set = 0;
20567 /* Shut up coverity */
20568 clib_memset (dmac, 0, sizeof (dmac));
20569 clib_memset (smac, 0, sizeof (smac));
20571 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20573 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20575 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20577 else if (unformat (i, "vtr_op %d", &vtr_op))
20579 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20582 else if (unformat (i, "translate_pbb_stag"))
20584 if (unformat (i, "%d", &tmp))
20586 vtr_op = L2_VTR_TRANSLATE_2_1;
20592 ("translate_pbb_stag operation requires outer tag definition");
20596 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20598 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20600 else if (unformat (i, "sid %d", &sid))
20602 else if (unformat (i, "vlanid %d", &tmp))
20606 clib_warning ("parse error '%U'", format_unformat_error, i);
20611 if ((sw_if_index == ~0) || (vtr_op == ~0))
20613 errmsg ("missing sw_if_index or vtr operation");
20616 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20617 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20620 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20624 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20625 mp->sw_if_index = ntohl (sw_if_index);
20626 mp->vtr_op = ntohl (vtr_op);
20627 mp->outer_tag = ntohs (outer_tag);
20628 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20629 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20630 mp->b_vlanid = ntohs (vlanid);
20631 mp->i_sid = ntohl (sid);
20639 api_flow_classify_set_interface (vat_main_t * vam)
20641 unformat_input_t *i = vam->input;
20642 vl_api_flow_classify_set_interface_t *mp;
20644 int sw_if_index_set;
20645 u32 ip4_table_index = ~0;
20646 u32 ip6_table_index = ~0;
20650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20652 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20653 sw_if_index_set = 1;
20654 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20655 sw_if_index_set = 1;
20656 else if (unformat (i, "del"))
20658 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20660 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20664 clib_warning ("parse error '%U'", format_unformat_error, i);
20669 if (sw_if_index_set == 0)
20671 errmsg ("missing interface name or sw_if_index");
20675 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20677 mp->sw_if_index = ntohl (sw_if_index);
20678 mp->ip4_table_index = ntohl (ip4_table_index);
20679 mp->ip6_table_index = ntohl (ip6_table_index);
20680 mp->is_add = is_add;
20688 api_flow_classify_dump (vat_main_t * vam)
20690 unformat_input_t *i = vam->input;
20691 vl_api_flow_classify_dump_t *mp;
20692 vl_api_control_ping_t *mp_ping;
20693 u8 type = FLOW_CLASSIFY_N_TABLES;
20696 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20700 errmsg ("classify table type must be specified");
20704 if (!vam->json_output)
20706 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20709 M (FLOW_CLASSIFY_DUMP, mp);
20714 /* Use a control ping for synchronization */
20715 MPING (CONTROL_PING, mp_ping);
20718 /* Wait for a reply... */
20724 api_feature_enable_disable (vat_main_t * vam)
20726 unformat_input_t *i = vam->input;
20727 vl_api_feature_enable_disable_t *mp;
20729 u8 *feature_name = 0;
20730 u32 sw_if_index = ~0;
20734 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20736 if (unformat (i, "arc_name %s", &arc_name))
20738 else if (unformat (i, "feature_name %s", &feature_name))
20741 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20743 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20745 else if (unformat (i, "disable"))
20753 errmsg ("missing arc name");
20756 if (vec_len (arc_name) > 63)
20758 errmsg ("arc name too long");
20761 if (feature_name == 0)
20763 errmsg ("missing feature name");
20766 if (vec_len (feature_name) > 63)
20768 errmsg ("feature name too long");
20771 if (sw_if_index == ~0)
20773 errmsg ("missing interface name or sw_if_index");
20777 /* Construct the API message */
20778 M (FEATURE_ENABLE_DISABLE, mp);
20779 mp->sw_if_index = ntohl (sw_if_index);
20780 mp->enable = enable;
20781 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20782 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20783 vec_free (arc_name);
20784 vec_free (feature_name);
20792 api_sw_interface_tag_add_del (vat_main_t * vam)
20794 unformat_input_t *i = vam->input;
20795 vl_api_sw_interface_tag_add_del_t *mp;
20796 u32 sw_if_index = ~0;
20801 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20803 if (unformat (i, "tag %s", &tag))
20805 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20807 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20809 else if (unformat (i, "del"))
20815 if (sw_if_index == ~0)
20817 errmsg ("missing interface name or sw_if_index");
20821 if (enable && (tag == 0))
20823 errmsg ("no tag specified");
20827 /* Construct the API message */
20828 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20829 mp->sw_if_index = ntohl (sw_if_index);
20830 mp->is_add = enable;
20832 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20840 static void vl_api_l2_xconnect_details_t_handler
20841 (vl_api_l2_xconnect_details_t * mp)
20843 vat_main_t *vam = &vat_main;
20845 print (vam->ofp, "%15d%15d",
20846 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20849 static void vl_api_l2_xconnect_details_t_handler_json
20850 (vl_api_l2_xconnect_details_t * mp)
20852 vat_main_t *vam = &vat_main;
20853 vat_json_node_t *node = NULL;
20855 if (VAT_JSON_ARRAY != vam->json_tree.type)
20857 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20858 vat_json_init_array (&vam->json_tree);
20860 node = vat_json_array_add (&vam->json_tree);
20862 vat_json_init_object (node);
20863 vat_json_object_add_uint (node, "rx_sw_if_index",
20864 ntohl (mp->rx_sw_if_index));
20865 vat_json_object_add_uint (node, "tx_sw_if_index",
20866 ntohl (mp->tx_sw_if_index));
20870 api_l2_xconnect_dump (vat_main_t * vam)
20872 vl_api_l2_xconnect_dump_t *mp;
20873 vl_api_control_ping_t *mp_ping;
20876 if (!vam->json_output)
20878 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20881 M (L2_XCONNECT_DUMP, mp);
20885 /* Use a control ping for synchronization */
20886 MPING (CONTROL_PING, mp_ping);
20894 api_hw_interface_set_mtu (vat_main_t * vam)
20896 unformat_input_t *i = vam->input;
20897 vl_api_hw_interface_set_mtu_t *mp;
20898 u32 sw_if_index = ~0;
20902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20904 if (unformat (i, "mtu %d", &mtu))
20906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20914 if (sw_if_index == ~0)
20916 errmsg ("missing interface name or sw_if_index");
20922 errmsg ("no mtu specified");
20926 /* Construct the API message */
20927 M (HW_INTERFACE_SET_MTU, mp);
20928 mp->sw_if_index = ntohl (sw_if_index);
20929 mp->mtu = ntohs ((u16) mtu);
20937 api_p2p_ethernet_add (vat_main_t * vam)
20939 unformat_input_t *i = vam->input;
20940 vl_api_p2p_ethernet_add_t *mp;
20941 u32 parent_if_index = ~0;
20947 clib_memset (remote_mac, 0, sizeof (remote_mac));
20948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20952 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20956 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20958 else if (unformat (i, "sub_id %d", &sub_id))
20962 clib_warning ("parse error '%U'", format_unformat_error, i);
20967 if (parent_if_index == ~0)
20969 errmsg ("missing interface name or sw_if_index");
20974 errmsg ("missing remote mac address");
20979 errmsg ("missing sub-interface id");
20983 M (P2P_ETHERNET_ADD, mp);
20984 mp->parent_if_index = ntohl (parent_if_index);
20985 mp->subif_id = ntohl (sub_id);
20986 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20994 api_p2p_ethernet_del (vat_main_t * vam)
20996 unformat_input_t *i = vam->input;
20997 vl_api_p2p_ethernet_del_t *mp;
20998 u32 parent_if_index = ~0;
21003 clib_memset (remote_mac, 0, sizeof (remote_mac));
21004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21006 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21008 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21012 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21016 clib_warning ("parse error '%U'", format_unformat_error, i);
21021 if (parent_if_index == ~0)
21023 errmsg ("missing interface name or sw_if_index");
21028 errmsg ("missing remote mac address");
21032 M (P2P_ETHERNET_DEL, mp);
21033 mp->parent_if_index = ntohl (parent_if_index);
21034 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21042 api_lldp_config (vat_main_t * vam)
21044 unformat_input_t *i = vam->input;
21045 vl_api_lldp_config_t *mp;
21047 int tx_interval = 0;
21048 u8 *sys_name = NULL;
21051 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21053 if (unformat (i, "system-name %s", &sys_name))
21055 else if (unformat (i, "tx-hold %d", &tx_hold))
21057 else if (unformat (i, "tx-interval %d", &tx_interval))
21061 clib_warning ("parse error '%U'", format_unformat_error, i);
21066 vec_add1 (sys_name, 0);
21068 M (LLDP_CONFIG, mp);
21069 mp->tx_hold = htonl (tx_hold);
21070 mp->tx_interval = htonl (tx_interval);
21071 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21072 vec_free (sys_name);
21080 api_sw_interface_set_lldp (vat_main_t * vam)
21082 unformat_input_t *i = vam->input;
21083 vl_api_sw_interface_set_lldp_t *mp;
21084 u32 sw_if_index = ~0;
21086 u8 *port_desc = NULL, *mgmt_oid = NULL;
21087 ip4_address_t ip4_addr;
21088 ip6_address_t ip6_addr;
21091 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21092 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21096 if (unformat (i, "disable"))
21099 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21101 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21103 else if (unformat (i, "port-desc %s", &port_desc))
21105 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21107 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21109 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21115 if (sw_if_index == ~0)
21117 errmsg ("missing interface name or sw_if_index");
21121 /* Construct the API message */
21122 vec_add1 (port_desc, 0);
21123 vec_add1 (mgmt_oid, 0);
21124 M (SW_INTERFACE_SET_LLDP, mp);
21125 mp->sw_if_index = ntohl (sw_if_index);
21126 mp->enable = enable;
21127 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21128 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21129 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21130 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21131 vec_free (port_desc);
21132 vec_free (mgmt_oid);
21140 api_tcp_configure_src_addresses (vat_main_t * vam)
21142 vl_api_tcp_configure_src_addresses_t *mp;
21143 unformat_input_t *i = vam->input;
21144 ip4_address_t v4first, v4last;
21145 ip6_address_t v6first, v6last;
21150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21152 if (unformat (i, "%U - %U",
21153 unformat_ip4_address, &v4first,
21154 unformat_ip4_address, &v4last))
21158 errmsg ("one range per message (range already set)");
21163 else if (unformat (i, "%U - %U",
21164 unformat_ip6_address, &v6first,
21165 unformat_ip6_address, &v6last))
21169 errmsg ("one range per message (range already set)");
21174 else if (unformat (i, "vrf %d", &vrf_id))
21180 if (range_set == 0)
21182 errmsg ("address range not set");
21186 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21187 mp->vrf_id = ntohl (vrf_id);
21189 if (range_set == 2)
21192 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21193 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21198 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21199 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21206 static void vl_api_app_namespace_add_del_reply_t_handler
21207 (vl_api_app_namespace_add_del_reply_t * mp)
21209 vat_main_t *vam = &vat_main;
21210 i32 retval = ntohl (mp->retval);
21211 if (vam->async_mode)
21213 vam->async_errors += (retval < 0);
21217 vam->retval = retval;
21219 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21220 vam->result_ready = 1;
21224 static void vl_api_app_namespace_add_del_reply_t_handler_json
21225 (vl_api_app_namespace_add_del_reply_t * mp)
21227 vat_main_t *vam = &vat_main;
21228 vat_json_node_t node;
21230 vat_json_init_object (&node);
21231 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21232 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21234 vat_json_print (vam->ofp, &node);
21235 vat_json_free (&node);
21237 vam->retval = ntohl (mp->retval);
21238 vam->result_ready = 1;
21242 api_app_namespace_add_del (vat_main_t * vam)
21244 vl_api_app_namespace_add_del_t *mp;
21245 unformat_input_t *i = vam->input;
21246 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21247 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21251 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21253 if (unformat (i, "id %_%v%_", &ns_id))
21255 else if (unformat (i, "secret %lu", &secret))
21257 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21258 sw_if_index_set = 1;
21259 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21261 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21266 if (!ns_id || !secret_set || !sw_if_index_set)
21268 errmsg ("namespace id, secret and sw_if_index must be set");
21271 if (vec_len (ns_id) > 64)
21273 errmsg ("namespace id too long");
21276 M (APP_NAMESPACE_ADD_DEL, mp);
21278 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21279 mp->namespace_id_len = vec_len (ns_id);
21280 mp->secret = clib_host_to_net_u64 (secret);
21281 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21282 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21283 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21291 api_sock_init_shm (vat_main_t * vam)
21293 #if VPP_API_TEST_BUILTIN == 0
21294 unformat_input_t *i = vam->input;
21295 vl_api_shm_elem_config_t *config = 0;
21296 u64 size = 64 << 20;
21299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21301 if (unformat (i, "size %U", unformat_memory_size, &size))
21308 * Canned custom ring allocator config.
21309 * Should probably parse all of this
21311 vec_validate (config, 6);
21312 config[0].type = VL_API_VLIB_RING;
21313 config[0].size = 256;
21314 config[0].count = 32;
21316 config[1].type = VL_API_VLIB_RING;
21317 config[1].size = 1024;
21318 config[1].count = 16;
21320 config[2].type = VL_API_VLIB_RING;
21321 config[2].size = 4096;
21322 config[2].count = 2;
21324 config[3].type = VL_API_CLIENT_RING;
21325 config[3].size = 256;
21326 config[3].count = 32;
21328 config[4].type = VL_API_CLIENT_RING;
21329 config[4].size = 1024;
21330 config[4].count = 16;
21332 config[5].type = VL_API_CLIENT_RING;
21333 config[5].size = 4096;
21334 config[5].count = 2;
21336 config[6].type = VL_API_QUEUE;
21337 config[6].count = 128;
21338 config[6].size = sizeof (uword);
21340 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
21342 vam->client_index_invalid = 1;
21350 api_dns_enable_disable (vat_main_t * vam)
21352 unformat_input_t *line_input = vam->input;
21353 vl_api_dns_enable_disable_t *mp;
21354 u8 enable_disable = 1;
21357 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21359 if (unformat (line_input, "disable"))
21360 enable_disable = 0;
21361 if (unformat (line_input, "enable"))
21362 enable_disable = 1;
21367 /* Construct the API message */
21368 M (DNS_ENABLE_DISABLE, mp);
21369 mp->enable = enable_disable;
21373 /* Wait for the reply */
21379 api_dns_resolve_name (vat_main_t * vam)
21381 unformat_input_t *line_input = vam->input;
21382 vl_api_dns_resolve_name_t *mp;
21386 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21388 if (unformat (line_input, "%s", &name))
21394 if (vec_len (name) > 127)
21396 errmsg ("name too long");
21400 /* Construct the API message */
21401 M (DNS_RESOLVE_NAME, mp);
21402 memcpy (mp->name, name, vec_len (name));
21407 /* Wait for the reply */
21413 api_dns_resolve_ip (vat_main_t * vam)
21415 unformat_input_t *line_input = vam->input;
21416 vl_api_dns_resolve_ip_t *mp;
21418 ip4_address_t addr4;
21419 ip6_address_t addr6;
21422 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21424 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21426 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21434 errmsg ("missing address");
21438 /* Construct the API message */
21439 M (DNS_RESOLVE_IP, mp);
21440 mp->is_ip6 = is_ip6;
21442 memcpy (mp->address, &addr6, sizeof (addr6));
21444 memcpy (mp->address, &addr4, sizeof (addr4));
21448 /* Wait for the reply */
21454 api_dns_name_server_add_del (vat_main_t * vam)
21456 unformat_input_t *i = vam->input;
21457 vl_api_dns_name_server_add_del_t *mp;
21459 ip6_address_t ip6_server;
21460 ip4_address_t ip4_server;
21465 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21467 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21469 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21471 else if (unformat (i, "del"))
21475 clib_warning ("parse error '%U'", format_unformat_error, i);
21480 if (ip4_set && ip6_set)
21482 errmsg ("Only one server address allowed per message");
21485 if ((ip4_set + ip6_set) == 0)
21487 errmsg ("Server address required");
21491 /* Construct the API message */
21492 M (DNS_NAME_SERVER_ADD_DEL, mp);
21496 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21501 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21505 mp->is_add = is_add;
21510 /* Wait for a reply, return good/bad news */
21516 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21518 vat_main_t *vam = &vat_main;
21523 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21524 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21525 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21526 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21527 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21528 clib_net_to_host_u32 (mp->action_index), mp->tag);
21533 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21534 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21535 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21536 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21537 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21538 clib_net_to_host_u32 (mp->action_index), mp->tag);
21543 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21546 vat_main_t *vam = &vat_main;
21547 vat_json_node_t *node = NULL;
21548 struct in6_addr ip6;
21549 struct in_addr ip4;
21551 if (VAT_JSON_ARRAY != vam->json_tree.type)
21553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21554 vat_json_init_array (&vam->json_tree);
21556 node = vat_json_array_add (&vam->json_tree);
21557 vat_json_init_object (node);
21559 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21560 vat_json_object_add_uint (node, "appns_index",
21561 clib_net_to_host_u32 (mp->appns_index));
21562 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21563 vat_json_object_add_uint (node, "scope", mp->scope);
21564 vat_json_object_add_uint (node, "action_index",
21565 clib_net_to_host_u32 (mp->action_index));
21566 vat_json_object_add_uint (node, "lcl_port",
21567 clib_net_to_host_u16 (mp->lcl_port));
21568 vat_json_object_add_uint (node, "rmt_port",
21569 clib_net_to_host_u16 (mp->rmt_port));
21570 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21571 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21572 vat_json_object_add_string_copy (node, "tag", mp->tag);
21575 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21576 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21577 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21578 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21582 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21583 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21584 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21585 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21590 api_session_rule_add_del (vat_main_t * vam)
21592 vl_api_session_rule_add_del_t *mp;
21593 unformat_input_t *i = vam->input;
21594 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21595 u32 appns_index = 0, scope = 0;
21596 ip4_address_t lcl_ip4, rmt_ip4;
21597 ip6_address_t lcl_ip6, rmt_ip6;
21598 u8 is_ip4 = 1, conn_set = 0;
21599 u8 is_add = 1, *tag = 0;
21602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21604 if (unformat (i, "del"))
21606 else if (unformat (i, "add"))
21608 else if (unformat (i, "proto tcp"))
21610 else if (unformat (i, "proto udp"))
21612 else if (unformat (i, "appns %d", &appns_index))
21614 else if (unformat (i, "scope %d", &scope))
21616 else if (unformat (i, "tag %_%v%_", &tag))
21620 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21621 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21629 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21630 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21636 else if (unformat (i, "action %d", &action))
21641 if (proto == ~0 || !conn_set || action == ~0)
21643 errmsg ("transport proto, connection and action must be set");
21649 errmsg ("scope should be 0-3");
21653 M (SESSION_RULE_ADD_DEL, mp);
21655 mp->is_ip4 = is_ip4;
21656 mp->transport_proto = proto;
21657 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21658 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21659 mp->lcl_plen = lcl_plen;
21660 mp->rmt_plen = rmt_plen;
21661 mp->action_index = clib_host_to_net_u32 (action);
21662 mp->appns_index = clib_host_to_net_u32 (appns_index);
21664 mp->is_add = is_add;
21667 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21668 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21672 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21673 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21677 clib_memcpy (mp->tag, tag, vec_len (tag));
21687 api_session_rules_dump (vat_main_t * vam)
21689 vl_api_session_rules_dump_t *mp;
21690 vl_api_control_ping_t *mp_ping;
21693 if (!vam->json_output)
21695 print (vam->ofp, "%=20s", "Session Rules");
21698 M (SESSION_RULES_DUMP, mp);
21702 /* Use a control ping for synchronization */
21703 MPING (CONTROL_PING, mp_ping);
21706 /* Wait for a reply... */
21712 api_ip_container_proxy_add_del (vat_main_t * vam)
21714 vl_api_ip_container_proxy_add_del_t *mp;
21715 unformat_input_t *i = vam->input;
21716 u32 sw_if_index = ~0;
21717 vl_api_prefix_t pfx = { };
21721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21723 if (unformat (i, "del"))
21725 else if (unformat (i, "add"))
21727 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21729 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21734 if (sw_if_index == ~0 || pfx.address_length == 0)
21736 errmsg ("address and sw_if_index must be set");
21740 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21742 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21743 mp->is_add = is_add;
21744 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21752 api_qos_record_enable_disable (vat_main_t * vam)
21754 unformat_input_t *i = vam->input;
21755 vl_api_qos_record_enable_disable_t *mp;
21756 u32 sw_if_index, qs = 0xff;
21757 u8 sw_if_index_set = 0;
21761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21763 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21764 sw_if_index_set = 1;
21765 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21766 sw_if_index_set = 1;
21767 else if (unformat (i, "%U", unformat_qos_source, &qs))
21769 else if (unformat (i, "disable"))
21773 clib_warning ("parse error '%U'", format_unformat_error, i);
21778 if (sw_if_index_set == 0)
21780 errmsg ("missing interface name or sw_if_index");
21785 errmsg ("input location must be specified");
21789 M (QOS_RECORD_ENABLE_DISABLE, mp);
21791 mp->sw_if_index = ntohl (sw_if_index);
21792 mp->input_source = qs;
21793 mp->enable = enable;
21802 q_or_quit (vat_main_t * vam)
21804 #if VPP_API_TEST_BUILTIN == 0
21805 longjmp (vam->jump_buf, 1);
21807 return 0; /* not so much */
21811 q (vat_main_t * vam)
21813 return q_or_quit (vam);
21817 quit (vat_main_t * vam)
21819 return q_or_quit (vam);
21823 comment (vat_main_t * vam)
21829 statseg (vat_main_t * vam)
21831 ssvm_private_t *ssvmp = &vam->stat_segment;
21832 ssvm_shared_header_t *shared_header = ssvmp->sh;
21833 vlib_counter_t **counters;
21834 u64 thread0_index1_packets;
21835 u64 thread0_index1_bytes;
21836 f64 vector_rate, input_rate;
21839 uword *counter_vector_by_name;
21840 if (vam->stat_segment_lockp == 0)
21842 errmsg ("Stat segment not mapped...");
21846 /* look up "/if/rx for sw_if_index 1 as a test */
21848 clib_spinlock_lock (vam->stat_segment_lockp);
21850 counter_vector_by_name = (uword *) shared_header->opaque[1];
21852 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21855 clib_spinlock_unlock (vam->stat_segment_lockp);
21856 errmsg ("/if/tx not found?");
21860 /* Fish per-thread vector of combined counters from shared memory */
21861 counters = (vlib_counter_t **) p[0];
21863 if (vec_len (counters[0]) < 2)
21865 clib_spinlock_unlock (vam->stat_segment_lockp);
21866 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21870 /* Read thread 0 sw_if_index 1 counter */
21871 thread0_index1_packets = counters[0][1].packets;
21872 thread0_index1_bytes = counters[0][1].bytes;
21874 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21877 clib_spinlock_unlock (vam->stat_segment_lockp);
21878 errmsg ("vector_rate not found?");
21882 vector_rate = *(f64 *) (p[0]);
21883 p = hash_get_mem (counter_vector_by_name, "input_rate");
21886 clib_spinlock_unlock (vam->stat_segment_lockp);
21887 errmsg ("input_rate not found?");
21890 input_rate = *(f64 *) (p[0]);
21892 clib_spinlock_unlock (vam->stat_segment_lockp);
21894 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21895 vector_rate, input_rate);
21896 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21897 thread0_index1_packets, thread0_index1_bytes);
21903 cmd_cmp (void *a1, void *a2)
21908 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21912 help (vat_main_t * vam)
21917 unformat_input_t *i = vam->input;
21920 if (unformat (i, "%s", &name))
21924 vec_add1 (name, 0);
21926 hs = hash_get_mem (vam->help_by_name, name);
21928 print (vam->ofp, "usage: %s %s", name, hs[0]);
21930 print (vam->ofp, "No such msg / command '%s'", name);
21935 print (vam->ofp, "Help is available for the following:");
21938 hash_foreach_pair (p, vam->function_by_name,
21940 vec_add1 (cmds, (u8 *)(p->key));
21944 vec_sort_with_function (cmds, cmd_cmp);
21946 for (j = 0; j < vec_len (cmds); j++)
21947 print (vam->ofp, "%s", cmds[j]);
21954 set (vat_main_t * vam)
21956 u8 *name = 0, *value = 0;
21957 unformat_input_t *i = vam->input;
21959 if (unformat (i, "%s", &name))
21961 /* The input buffer is a vector, not a string. */
21962 value = vec_dup (i->buffer);
21963 vec_delete (value, i->index, 0);
21964 /* Almost certainly has a trailing newline */
21965 if (value[vec_len (value) - 1] == '\n')
21966 value[vec_len (value) - 1] = 0;
21967 /* Make sure it's a proper string, one way or the other */
21968 vec_add1 (value, 0);
21969 (void) clib_macro_set_value (&vam->macro_main,
21970 (char *) name, (char *) value);
21973 errmsg ("usage: set <name> <value>");
21981 unset (vat_main_t * vam)
21985 if (unformat (vam->input, "%s", &name))
21986 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21987 errmsg ("unset: %s wasn't set", name);
22000 macro_sort_cmp (void *a1, void *a2)
22002 macro_sort_t *s1 = a1;
22003 macro_sort_t *s2 = a2;
22005 return strcmp ((char *) (s1->name), (char *) (s2->name));
22009 dump_macro_table (vat_main_t * vam)
22011 macro_sort_t *sort_me = 0, *sm;
22016 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22018 vec_add2 (sort_me, sm, 1);
22019 sm->name = (u8 *)(p->key);
22020 sm->value = (u8 *) (p->value[0]);
22024 vec_sort_with_function (sort_me, macro_sort_cmp);
22026 if (vec_len (sort_me))
22027 print (vam->ofp, "%-15s%s", "Name", "Value");
22029 print (vam->ofp, "The macro table is empty...");
22031 for (i = 0; i < vec_len (sort_me); i++)
22032 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22037 dump_node_table (vat_main_t * vam)
22040 vlib_node_t *node, *next_node;
22042 if (vec_len (vam->graph_nodes) == 0)
22044 print (vam->ofp, "Node table empty, issue get_node_graph...");
22048 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22050 node = vam->graph_nodes[0][i];
22051 print (vam->ofp, "[%d] %s", i, node->name);
22052 for (j = 0; j < vec_len (node->next_nodes); j++)
22054 if (node->next_nodes[j] != ~0)
22056 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22057 print (vam->ofp, " [%d] %s", j, next_node->name);
22065 value_sort_cmp (void *a1, void *a2)
22067 name_sort_t *n1 = a1;
22068 name_sort_t *n2 = a2;
22070 if (n1->value < n2->value)
22072 if (n1->value > n2->value)
22079 dump_msg_api_table (vat_main_t * vam)
22081 api_main_t *am = &api_main;
22082 name_sort_t *nses = 0, *ns;
22087 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22089 vec_add2 (nses, ns, 1);
22090 ns->name = (u8 *)(hp->key);
22091 ns->value = (u32) hp->value[0];
22095 vec_sort_with_function (nses, value_sort_cmp);
22097 for (i = 0; i < vec_len (nses); i++)
22098 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22104 get_msg_id (vat_main_t * vam)
22109 if (unformat (vam->input, "%s", &name_and_crc))
22111 message_index = vl_msg_api_get_msg_index (name_and_crc);
22112 if (message_index == ~0)
22114 print (vam->ofp, " '%s' not found", name_and_crc);
22117 print (vam->ofp, " '%s' has message index %d",
22118 name_and_crc, message_index);
22121 errmsg ("name_and_crc required...");
22126 search_node_table (vat_main_t * vam)
22128 unformat_input_t *line_input = vam->input;
22131 vlib_node_t *node, *next_node;
22134 if (vam->graph_node_index_by_name == 0)
22136 print (vam->ofp, "Node table empty, issue get_node_graph...");
22140 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22142 if (unformat (line_input, "%s", &node_to_find))
22144 vec_add1 (node_to_find, 0);
22145 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22148 print (vam->ofp, "%s not found...", node_to_find);
22151 node = vam->graph_nodes[0][p[0]];
22152 print (vam->ofp, "[%d] %s", p[0], node->name);
22153 for (j = 0; j < vec_len (node->next_nodes); j++)
22155 if (node->next_nodes[j] != ~0)
22157 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22158 print (vam->ofp, " [%d] %s", j, next_node->name);
22165 clib_warning ("parse error '%U'", format_unformat_error,
22171 vec_free (node_to_find);
22180 script (vat_main_t * vam)
22182 #if (VPP_API_TEST_BUILTIN==0)
22184 char *save_current_file;
22185 unformat_input_t save_input;
22186 jmp_buf save_jump_buf;
22187 u32 save_line_number;
22189 FILE *new_fp, *save_ifp;
22191 if (unformat (vam->input, "%s", &s))
22193 new_fp = fopen ((char *) s, "r");
22196 errmsg ("Couldn't open script file %s", s);
22203 errmsg ("Missing script name");
22207 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22208 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22209 save_ifp = vam->ifp;
22210 save_line_number = vam->input_line_number;
22211 save_current_file = (char *) vam->current_file;
22213 vam->input_line_number = 0;
22215 vam->current_file = s;
22218 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
22219 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22220 vam->ifp = save_ifp;
22221 vam->input_line_number = save_line_number;
22222 vam->current_file = (u8 *) save_current_file;
22227 clib_warning ("use the exec command...");
22233 echo (vat_main_t * vam)
22235 print (vam->ofp, "%v", vam->input->buffer);
22239 /* List of API message constructors, CLI names map to api_xxx */
22240 #define foreach_vpe_api_msg \
22241 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22242 _(sw_interface_dump,"") \
22243 _(sw_interface_set_flags, \
22244 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22245 _(sw_interface_add_del_address, \
22246 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22247 _(sw_interface_set_rx_mode, \
22248 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22249 _(sw_interface_set_rx_placement, \
22250 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
22251 _(sw_interface_rx_placement_dump, \
22252 "[<intfc> | sw_if_index <id>]") \
22253 _(sw_interface_set_table, \
22254 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22255 _(sw_interface_set_mpls_enable, \
22256 "<intfc> | sw_if_index [disable | dis]") \
22257 _(sw_interface_set_vpath, \
22258 "<intfc> | sw_if_index <id> enable | disable") \
22259 _(sw_interface_set_vxlan_bypass, \
22260 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22261 _(sw_interface_set_geneve_bypass, \
22262 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22263 _(sw_interface_set_l2_xconnect, \
22264 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22265 "enable | disable") \
22266 _(sw_interface_set_l2_bridge, \
22267 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22268 "[shg <split-horizon-group>] [bvi]\n" \
22269 "enable | disable") \
22270 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22271 _(bridge_domain_add_del, \
22272 "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") \
22273 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22275 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22276 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22277 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22279 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22281 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22283 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22285 "<vpp-if-name> | sw_if_index <id>") \
22286 _(sw_interface_tap_v2_dump, "") \
22287 _(virtio_pci_create, \
22288 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
22289 _(virtio_pci_delete, \
22290 "<vpp-if-name> | sw_if_index <id>") \
22291 _(sw_interface_virtio_pci_dump, "") \
22293 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
22294 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
22297 "<vpp-if-name> | sw_if_index <id>") \
22299 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
22300 _(bond_detach_slave, \
22301 "sw_if_index <n>") \
22302 _(sw_interface_bond_dump, "") \
22303 _(sw_interface_slave_dump, \
22304 "<vpp-if-name> | sw_if_index <id>") \
22305 _(ip_table_add_del, \
22306 "table <n> [ipv6] [add | del]\n") \
22307 _(ip_add_del_route, \
22308 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
22309 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
22310 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
22311 "[multipath] [count <n>] [del]") \
22312 _(ip_mroute_add_del, \
22313 "<src> <grp>/<mask> [table-id <n>]\n" \
22314 "[<intfc> | sw_if_index <id>] [local] [del]") \
22315 _(mpls_table_add_del, \
22316 "table <n> [add | del]\n") \
22317 _(mpls_route_add_del, \
22318 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
22319 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
22320 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
22321 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
22322 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
22323 "[count <n>] [del]") \
22324 _(mpls_ip_bind_unbind, \
22325 "<label> <addr/len>") \
22326 _(mpls_tunnel_add_del, \
22327 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22328 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22329 "[l2-only] [out-label <n>]") \
22330 _(sr_mpls_policy_add, \
22331 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22332 _(sr_mpls_policy_del, \
22334 _(bier_table_add_del, \
22335 "<label> <sub-domain> <set> <bsl> [del]") \
22336 _(bier_route_add_del, \
22337 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22338 "[<intfc> | sw_if_index <id>]" \
22339 "[weight <n>] [del] [multipath]") \
22340 _(proxy_arp_add_del, \
22341 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22342 _(proxy_arp_intfc_enable_disable, \
22343 "<intfc> | sw_if_index <id> enable | disable") \
22344 _(sw_interface_set_unnumbered, \
22345 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22346 _(ip_neighbor_add_del, \
22347 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22348 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22349 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22350 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22351 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22352 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22353 "[outer_vlan_id_any][inner_vlan_id_any]") \
22354 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22355 _(reset_fib, "vrf <n> [ipv6]") \
22356 _(dhcp_proxy_config, \
22357 "svr <v46-address> src <v46-address>\n" \
22358 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22359 _(dhcp_proxy_set_vss, \
22360 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22361 _(dhcp_proxy_dump, "ip6") \
22362 _(dhcp_client_config, \
22363 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22364 _(set_ip_flow_hash, \
22365 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22366 _(sw_interface_ip6_enable_disable, \
22367 "<intfc> | sw_if_index <id> enable | disable") \
22368 _(ip6nd_proxy_add_del, \
22369 "<intfc> | sw_if_index <id> <ip6-address>") \
22370 _(ip6nd_proxy_dump, "") \
22371 _(sw_interface_ip6nd_ra_prefix, \
22372 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22373 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22374 "[nolink] [isno]") \
22375 _(sw_interface_ip6nd_ra_config, \
22376 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22377 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22378 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22379 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22380 _(l2_patch_add_del, \
22381 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22382 "enable | disable") \
22383 _(sr_localsid_add_del, \
22384 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22385 "fib-table <num> (end.psp) sw_if_index <num>") \
22386 _(classify_add_del_table, \
22387 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22388 " [del] [del-chain] mask <mask-value>\n" \
22389 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22390 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22391 _(classify_add_del_session, \
22392 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22393 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22394 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22395 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22396 _(classify_set_interface_ip_table, \
22397 "<intfc> | sw_if_index <nn> table <nn>") \
22398 _(classify_set_interface_l2_tables, \
22399 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22400 " [other-table <nn>]") \
22401 _(get_node_index, "node <node-name") \
22402 _(add_node_next, "node <node-name> next <next-node-name>") \
22403 _(l2tpv3_create_tunnel, \
22404 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22405 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22406 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22407 _(l2tpv3_set_tunnel_cookies, \
22408 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22409 "[new_remote_cookie <nn>]\n") \
22410 _(l2tpv3_interface_enable_disable, \
22411 "<intfc> | sw_if_index <nn> enable | disable") \
22412 _(l2tpv3_set_lookup_key, \
22413 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22414 _(sw_if_l2tpv3_tunnel_dump, "") \
22415 _(vxlan_offload_rx, \
22416 "hw { <interface name> | hw_if_index <nn>} " \
22417 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22418 _(vxlan_add_del_tunnel, \
22419 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22420 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22421 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22422 _(geneve_add_del_tunnel, \
22423 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22424 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22425 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22426 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22427 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22428 _(gre_add_del_tunnel, \
22429 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22430 "[teb | erspan <session-id>] [del]") \
22431 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22432 _(l2_fib_clear_table, "") \
22433 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22434 _(l2_interface_vlan_tag_rewrite, \
22435 "<intfc> | sw_if_index <nn> \n" \
22436 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22437 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22438 _(create_vhost_user_if, \
22439 "socket <filename> [server] [renumber <dev_instance>] " \
22440 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22441 "[mac <mac_address>]") \
22442 _(modify_vhost_user_if, \
22443 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22444 "[server] [renumber <dev_instance>]") \
22445 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22446 _(sw_interface_vhost_user_dump, "") \
22447 _(show_version, "") \
22448 _(show_threads, "") \
22449 _(vxlan_gpe_add_del_tunnel, \
22450 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22451 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22452 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22453 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22454 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22455 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22456 _(interface_name_renumber, \
22457 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22458 _(input_acl_set_interface, \
22459 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22460 " [l2-table <nn>] [del]") \
22461 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22462 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22463 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22464 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22465 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22466 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22467 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22468 _(ip_dump, "ipv4 | ipv6") \
22469 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22470 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22472 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22473 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22474 " integ_alg <alg> integ_key <hex>") \
22475 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22476 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22477 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22478 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22479 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22480 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22481 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22482 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22483 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22484 " [instance <n>]") \
22485 _(ipsec_sa_dump, "[sa_id <n>]") \
22486 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22487 " <alg> <hex>\n") \
22488 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22489 _(delete_loopback,"sw_if_index <nn>") \
22490 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22491 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22492 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22493 _(want_interface_events, "enable|disable") \
22494 _(get_first_msg_id, "client <name>") \
22495 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22496 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22497 "fib-id <nn> [ip4][ip6][default]") \
22498 _(get_node_graph, " ") \
22499 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22500 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22501 _(ioam_disable, "") \
22502 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22503 " sw_if_index <sw_if_index> p <priority> " \
22504 "w <weight>] [del]") \
22505 _(one_add_del_locator, "locator-set <locator_name> " \
22506 "iface <intf> | sw_if_index <sw_if_index> " \
22507 "p <priority> w <weight> [del]") \
22508 _(one_add_del_local_eid,"vni <vni> eid " \
22509 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22510 "locator-set <locator_name> [del]" \
22511 "[key-id sha1|sha256 secret-key <secret-key>]")\
22512 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22513 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22514 _(one_enable_disable, "enable|disable") \
22515 _(one_map_register_enable_disable, "enable|disable") \
22516 _(one_map_register_fallback_threshold, "<value>") \
22517 _(one_rloc_probe_enable_disable, "enable|disable") \
22518 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22520 "rloc <locator> p <prio> " \
22521 "w <weight> [rloc <loc> ... ] " \
22522 "action <action> [del-all]") \
22523 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22525 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22526 _(one_use_petr, "ip-address> | disable") \
22527 _(one_map_request_mode, "src-dst|dst-only") \
22528 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22529 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22530 _(one_locator_set_dump, "[local | remote]") \
22531 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22532 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22533 "[local] | [remote]") \
22534 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22535 _(one_ndp_bd_get, "") \
22536 _(one_ndp_entries_get, "bd <bridge-domain>") \
22537 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22538 _(one_l2_arp_bd_get, "") \
22539 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22540 _(one_stats_enable_disable, "enable|disable") \
22541 _(show_one_stats_enable_disable, "") \
22542 _(one_eid_table_vni_dump, "") \
22543 _(one_eid_table_map_dump, "l2|l3") \
22544 _(one_map_resolver_dump, "") \
22545 _(one_map_server_dump, "") \
22546 _(one_adjacencies_get, "vni <vni>") \
22547 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22548 _(show_one_rloc_probe_state, "") \
22549 _(show_one_map_register_state, "") \
22550 _(show_one_status, "") \
22551 _(one_stats_dump, "") \
22552 _(one_stats_flush, "") \
22553 _(one_get_map_request_itr_rlocs, "") \
22554 _(one_map_register_set_ttl, "<ttl>") \
22555 _(one_set_transport_protocol, "udp|api") \
22556 _(one_get_transport_protocol, "") \
22557 _(one_enable_disable_xtr_mode, "enable|disable") \
22558 _(one_show_xtr_mode, "") \
22559 _(one_enable_disable_pitr_mode, "enable|disable") \
22560 _(one_show_pitr_mode, "") \
22561 _(one_enable_disable_petr_mode, "enable|disable") \
22562 _(one_show_petr_mode, "") \
22563 _(show_one_nsh_mapping, "") \
22564 _(show_one_pitr, "") \
22565 _(show_one_use_petr, "") \
22566 _(show_one_map_request_mode, "") \
22567 _(show_one_map_register_ttl, "") \
22568 _(show_one_map_register_fallback_threshold, "") \
22569 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22570 " sw_if_index <sw_if_index> p <priority> " \
22571 "w <weight>] [del]") \
22572 _(lisp_add_del_locator, "locator-set <locator_name> " \
22573 "iface <intf> | sw_if_index <sw_if_index> " \
22574 "p <priority> w <weight> [del]") \
22575 _(lisp_add_del_local_eid,"vni <vni> eid " \
22576 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22577 "locator-set <locator_name> [del]" \
22578 "[key-id sha1|sha256 secret-key <secret-key>]") \
22579 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22580 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22581 _(lisp_enable_disable, "enable|disable") \
22582 _(lisp_map_register_enable_disable, "enable|disable") \
22583 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22584 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22586 "rloc <locator> p <prio> " \
22587 "w <weight> [rloc <loc> ... ] " \
22588 "action <action> [del-all]") \
22589 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22591 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22592 _(lisp_use_petr, "<ip-address> | disable") \
22593 _(lisp_map_request_mode, "src-dst|dst-only") \
22594 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22595 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22596 _(lisp_locator_set_dump, "[local | remote]") \
22597 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22598 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22599 "[local] | [remote]") \
22600 _(lisp_eid_table_vni_dump, "") \
22601 _(lisp_eid_table_map_dump, "l2|l3") \
22602 _(lisp_map_resolver_dump, "") \
22603 _(lisp_map_server_dump, "") \
22604 _(lisp_adjacencies_get, "vni <vni>") \
22605 _(gpe_fwd_entry_vnis_get, "") \
22606 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22607 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22608 "[table <table-id>]") \
22609 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22610 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22611 _(gpe_set_encap_mode, "lisp|vxlan") \
22612 _(gpe_get_encap_mode, "") \
22613 _(lisp_gpe_add_del_iface, "up|down") \
22614 _(lisp_gpe_enable_disable, "enable|disable") \
22615 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22616 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22617 _(show_lisp_rloc_probe_state, "") \
22618 _(show_lisp_map_register_state, "") \
22619 _(show_lisp_status, "") \
22620 _(lisp_get_map_request_itr_rlocs, "") \
22621 _(show_lisp_pitr, "") \
22622 _(show_lisp_use_petr, "") \
22623 _(show_lisp_map_request_mode, "") \
22624 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22625 _(af_packet_delete, "name <host interface name>") \
22626 _(af_packet_dump, "") \
22627 _(policer_add_del, "name <policer name> <params> [del]") \
22628 _(policer_dump, "[name <policer name>]") \
22629 _(policer_classify_set_interface, \
22630 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22631 " [l2-table <nn>] [del]") \
22632 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22633 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22634 "[master|slave]") \
22635 _(netmap_delete, "name <interface name>") \
22636 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22637 _(mpls_fib_dump, "") \
22638 _(classify_table_ids, "") \
22639 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22640 _(classify_table_info, "table_id <nn>") \
22641 _(classify_session_dump, "table_id <nn>") \
22642 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22643 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22644 "[template_interval <nn>] [udp_checksum]") \
22645 _(ipfix_exporter_dump, "") \
22646 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22647 _(ipfix_classify_stream_dump, "") \
22648 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22649 _(ipfix_classify_table_dump, "") \
22650 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22651 _(sw_interface_span_dump, "[l2]") \
22652 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22653 _(pg_create_interface, "if_id <nn>") \
22654 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22655 _(pg_enable_disable, "[stream <id>] disable") \
22656 _(ip_source_and_port_range_check_add_del, \
22657 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22658 _(ip_source_and_port_range_check_interface_add_del, \
22659 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22660 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22661 _(ipsec_gre_add_del_tunnel, \
22662 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22663 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22664 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22665 _(l2_interface_pbb_tag_rewrite, \
22666 "<intfc> | sw_if_index <nn> \n" \
22667 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22668 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22669 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22670 _(flow_classify_set_interface, \
22671 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22672 _(flow_classify_dump, "type [ip4|ip6]") \
22673 _(ip_fib_dump, "") \
22674 _(ip_mfib_dump, "") \
22675 _(ip6_fib_dump, "") \
22676 _(ip6_mfib_dump, "") \
22677 _(feature_enable_disable, "arc_name <arc_name> " \
22678 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22679 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22681 _(l2_xconnect_dump, "") \
22682 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22683 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22684 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22685 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22686 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22687 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22688 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22689 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22690 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22691 _(sock_init_shm, "size <nnn>") \
22692 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22693 _(dns_enable_disable, "[enable][disable]") \
22694 _(dns_name_server_add_del, "<ip-address> [del]") \
22695 _(dns_resolve_name, "<hostname>") \
22696 _(dns_resolve_ip, "<ip4|ip6>") \
22697 _(dns_name_server_add_del, "<ip-address> [del]") \
22698 _(dns_resolve_name, "<hostname>") \
22699 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22700 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22701 _(session_rules_dump, "") \
22702 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22703 _(output_acl_set_interface, \
22704 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22705 " [l2-table <nn>] [del]") \
22706 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22708 /* List of command functions, CLI names map directly to functions */
22709 #define foreach_cli_function \
22710 _(comment, "usage: comment <ignore-rest-of-line>") \
22711 _(dump_interface_table, "usage: dump_interface_table") \
22712 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22713 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22714 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22715 _(dump_macro_table, "usage: dump_macro_table ") \
22716 _(dump_node_table, "usage: dump_node_table") \
22717 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22718 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22719 _(echo, "usage: echo <message>") \
22720 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22721 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22722 _(help, "usage: help") \
22723 _(q, "usage: quit") \
22724 _(quit, "usage: quit") \
22725 _(search_node_table, "usage: search_node_table <name>...") \
22726 _(set, "usage: set <variable-name> <value>") \
22727 _(script, "usage: script <file-name>") \
22728 _(statseg, "usage: statseg"); \
22729 _(unset, "usage: unset <variable-name>")
22732 static void vl_api_##n##_t_handler_uni \
22733 (vl_api_##n##_t * mp) \
22735 vat_main_t * vam = &vat_main; \
22736 if (vam->json_output) { \
22737 vl_api_##n##_t_handler_json(mp); \
22739 vl_api_##n##_t_handler(mp); \
22742 foreach_vpe_api_reply_msg;
22743 #if VPP_API_TEST_BUILTIN == 0
22744 foreach_standalone_reply_msg;
22749 vat_api_hookup (vat_main_t * vam)
22752 vl_msg_api_set_handlers(VL_API_##N, #n, \
22753 vl_api_##n##_t_handler_uni, \
22755 vl_api_##n##_t_endian, \
22756 vl_api_##n##_t_print, \
22757 sizeof(vl_api_##n##_t), 1);
22758 foreach_vpe_api_reply_msg;
22759 #if VPP_API_TEST_BUILTIN == 0
22760 foreach_standalone_reply_msg;
22764 #if (VPP_API_TEST_BUILTIN==0)
22765 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22767 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22769 vam->function_by_name = hash_create_string (0, sizeof (uword));
22771 vam->help_by_name = hash_create_string (0, sizeof (uword));
22774 /* API messages we can send */
22775 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22776 foreach_vpe_api_msg;
22780 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22781 foreach_vpe_api_msg;
22784 /* CLI functions */
22785 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22786 foreach_cli_function;
22790 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22791 foreach_cli_function;
22795 #if VPP_API_TEST_BUILTIN
22796 static clib_error_t *
22797 vat_api_hookup_shim (vlib_main_t * vm)
22799 vat_api_hookup (&vat_main);
22803 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22807 * fd.io coding-style-patch-verification: ON
22810 * eval: (c-set-style "gnu")