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->raw_flags = ntohl (mp->sub_if_flags & SUB_IF_API_FLAG_MASK_VNET);
939 sub->sub_number_of_tags = mp->sub_number_of_tags;
940 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
941 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
943 /* vlan tag rewrite */
944 sub->vtr_op = ntohl (mp->vtr_op);
945 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
946 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
947 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
951 static void vl_api_sw_interface_details_t_handler_json
952 (vl_api_sw_interface_details_t * mp)
954 vat_main_t *vam = &vat_main;
955 vat_json_node_t *node = NULL;
957 if (VAT_JSON_ARRAY != vam->json_tree.type)
959 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
960 vat_json_init_array (&vam->json_tree);
962 node = vat_json_array_add (&vam->json_tree);
964 vat_json_init_object (node);
965 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
966 vat_json_object_add_uint (node, "sup_sw_if_index",
967 ntohl (mp->sup_sw_if_index));
968 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
969 sizeof (mp->l2_address));
970 vat_json_object_add_string_copy (node, "interface_name",
971 mp->interface_name.buf);
972 vat_json_object_add_uint (node, "flags", mp->flags);
973 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
974 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
975 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
976 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
977 vat_json_object_add_uint (node, "sub_number_of_tags",
978 mp->sub_number_of_tags);
979 vat_json_object_add_uint (node, "sub_outer_vlan_id",
980 ntohs (mp->sub_outer_vlan_id));
981 vat_json_object_add_uint (node, "sub_inner_vlan_id",
982 ntohs (mp->sub_inner_vlan_id));
983 vat_json_object_add_uint (node, "sub_if_flags", ntohl (mp->sub_if_flags));
984 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
985 vat_json_object_add_uint (node, "vtr_push_dot1q",
986 ntohl (mp->vtr_push_dot1q));
987 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
988 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
989 if (ntohl (mp->sub_if_flags) & SUB_IF_API_FLAG_DOT1AH)
991 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
993 format_ethernet_address,
995 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
997 format_ethernet_address,
999 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1000 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1004 #if VPP_API_TEST_BUILTIN == 0
1005 static void vl_api_sw_interface_event_t_handler
1006 (vl_api_sw_interface_event_t * mp)
1008 vat_main_t *vam = &vat_main;
1009 if (vam->interface_event_display)
1010 errmsg ("interface flags: sw_if_index %d %s %s",
1011 ntohl (mp->sw_if_index),
1012 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_ADMIN_UP) ?
1013 "admin-up" : "admin-down",
1014 ((ntohl (mp->flags)) & IF_STATUS_API_FLAG_LINK_UP) ?
1015 "link-up" : "link-down");
1019 static void vl_api_sw_interface_event_t_handler_json
1020 (vl_api_sw_interface_event_t * mp)
1022 /* JSON output not supported */
1026 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1028 vat_main_t *vam = &vat_main;
1029 i32 retval = ntohl (mp->retval);
1031 vam->retval = retval;
1032 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1033 vam->result_ready = 1;
1037 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 vat_json_node_t node;
1041 api_main_t *am = &api_main;
1045 vat_json_init_object (&node);
1046 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1047 vat_json_object_add_uint (&node, "reply_in_shmem",
1048 ntohl (mp->reply_in_shmem));
1049 /* Toss the shared-memory original... */
1050 pthread_mutex_lock (&am->vlib_rp->mutex);
1051 oldheap = svm_push_data_heap (am->vlib_rp);
1053 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1056 svm_pop_heap (oldheap);
1057 pthread_mutex_unlock (&am->vlib_rp->mutex);
1059 vat_json_print (vam->ofp, &node);
1060 vat_json_free (&node);
1062 vam->retval = ntohl (mp->retval);
1063 vam->result_ready = 1;
1067 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1069 vat_main_t *vam = &vat_main;
1070 i32 retval = ntohl (mp->retval);
1071 u32 length = vl_api_string_len (&mp->reply);
1073 vec_reset_length (vam->cmd_reply);
1075 vam->retval = retval;
1078 vec_validate (vam->cmd_reply, length);
1079 clib_memcpy ((char *) (vam->cmd_reply),
1080 vl_api_from_api_string (&mp->reply), length);
1081 vam->cmd_reply[length] = 0;
1083 vam->result_ready = 1;
1087 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1089 vat_main_t *vam = &vat_main;
1090 vat_json_node_t node;
1092 vec_reset_length (vam->cmd_reply);
1094 vat_json_init_object (&node);
1095 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1096 vat_json_object_add_string_copy (&node, "reply",
1097 vl_api_from_api_string (&mp->reply));
1099 vat_json_print (vam->ofp, &node);
1100 vat_json_free (&node);
1102 vam->retval = ntohl (mp->retval);
1103 vam->result_ready = 1;
1106 static void vl_api_classify_add_del_table_reply_t_handler
1107 (vl_api_classify_add_del_table_reply_t * mp)
1109 vat_main_t *vam = &vat_main;
1110 i32 retval = ntohl (mp->retval);
1111 if (vam->async_mode)
1113 vam->async_errors += (retval < 0);
1117 vam->retval = retval;
1119 ((mp->new_table_index != 0xFFFFFFFF) ||
1120 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1121 (mp->match_n_vectors != 0xFFFFFFFF)))
1123 * Note: this is just barely thread-safe, depends on
1124 * the main thread spinning waiting for an answer...
1126 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1127 ntohl (mp->new_table_index),
1128 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1129 vam->result_ready = 1;
1133 static void vl_api_classify_add_del_table_reply_t_handler_json
1134 (vl_api_classify_add_del_table_reply_t * mp)
1136 vat_main_t *vam = &vat_main;
1137 vat_json_node_t node;
1139 vat_json_init_object (&node);
1140 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1141 vat_json_object_add_uint (&node, "new_table_index",
1142 ntohl (mp->new_table_index));
1143 vat_json_object_add_uint (&node, "skip_n_vectors",
1144 ntohl (mp->skip_n_vectors));
1145 vat_json_object_add_uint (&node, "match_n_vectors",
1146 ntohl (mp->match_n_vectors));
1148 vat_json_print (vam->ofp, &node);
1149 vat_json_free (&node);
1151 vam->retval = ntohl (mp->retval);
1152 vam->result_ready = 1;
1155 static void vl_api_get_node_index_reply_t_handler
1156 (vl_api_get_node_index_reply_t * mp)
1158 vat_main_t *vam = &vat_main;
1159 i32 retval = ntohl (mp->retval);
1160 if (vam->async_mode)
1162 vam->async_errors += (retval < 0);
1166 vam->retval = retval;
1168 errmsg ("node index %d", ntohl (mp->node_index));
1169 vam->result_ready = 1;
1173 static void vl_api_get_node_index_reply_t_handler_json
1174 (vl_api_get_node_index_reply_t * mp)
1176 vat_main_t *vam = &vat_main;
1177 vat_json_node_t node;
1179 vat_json_init_object (&node);
1180 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1181 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1183 vat_json_print (vam->ofp, &node);
1184 vat_json_free (&node);
1186 vam->retval = ntohl (mp->retval);
1187 vam->result_ready = 1;
1190 static void vl_api_get_next_index_reply_t_handler
1191 (vl_api_get_next_index_reply_t * mp)
1193 vat_main_t *vam = &vat_main;
1194 i32 retval = ntohl (mp->retval);
1195 if (vam->async_mode)
1197 vam->async_errors += (retval < 0);
1201 vam->retval = retval;
1203 errmsg ("next node index %d", ntohl (mp->next_index));
1204 vam->result_ready = 1;
1208 static void vl_api_get_next_index_reply_t_handler_json
1209 (vl_api_get_next_index_reply_t * mp)
1211 vat_main_t *vam = &vat_main;
1212 vat_json_node_t node;
1214 vat_json_init_object (&node);
1215 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1216 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1218 vat_json_print (vam->ofp, &node);
1219 vat_json_free (&node);
1221 vam->retval = ntohl (mp->retval);
1222 vam->result_ready = 1;
1225 static void vl_api_add_node_next_reply_t_handler
1226 (vl_api_add_node_next_reply_t * mp)
1228 vat_main_t *vam = &vat_main;
1229 i32 retval = ntohl (mp->retval);
1230 if (vam->async_mode)
1232 vam->async_errors += (retval < 0);
1236 vam->retval = retval;
1238 errmsg ("next index %d", ntohl (mp->next_index));
1239 vam->result_ready = 1;
1243 static void vl_api_add_node_next_reply_t_handler_json
1244 (vl_api_add_node_next_reply_t * mp)
1246 vat_main_t *vam = &vat_main;
1247 vat_json_node_t node;
1249 vat_json_init_object (&node);
1250 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1251 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1253 vat_json_print (vam->ofp, &node);
1254 vat_json_free (&node);
1256 vam->retval = ntohl (mp->retval);
1257 vam->result_ready = 1;
1260 static void vl_api_show_version_reply_t_handler
1261 (vl_api_show_version_reply_t * mp)
1263 vat_main_t *vam = &vat_main;
1264 i32 retval = ntohl (mp->retval);
1269 char *p = (char *) &mp->program;
1271 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1272 errmsg (" program: %s\n", s);
1276 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1277 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1278 errmsg (" version: %s\n", s);
1282 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1283 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1284 errmsg (" build date: %s\n", s);
1288 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1289 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1290 errmsg ("build directory: %s\n", s);
1293 vam->retval = retval;
1294 vam->result_ready = 1;
1297 static void vl_api_show_version_reply_t_handler_json
1298 (vl_api_show_version_reply_t * mp)
1300 vat_main_t *vam = &vat_main;
1301 vat_json_node_t node;
1303 vat_json_init_object (&node);
1304 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1305 char *p = (char *) &mp->program;
1306 vat_json_object_add_string_copy (&node, "program",
1307 vl_api_from_api_string ((vl_api_string_t *)
1309 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1310 vat_json_object_add_string_copy (&node, "version",
1311 vl_api_from_api_string ((vl_api_string_t *)
1313 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1314 vat_json_object_add_string_copy (&node, "build_date",
1315 vl_api_from_api_string ((vl_api_string_t *)
1317 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1318 vat_json_object_add_string_copy (&node, "build_directory",
1319 vl_api_from_api_string ((vl_api_string_t *)
1322 vat_json_print (vam->ofp, &node);
1323 vat_json_free (&node);
1325 vam->retval = ntohl (mp->retval);
1326 vam->result_ready = 1;
1329 static void vl_api_show_threads_reply_t_handler
1330 (vl_api_show_threads_reply_t * mp)
1332 vat_main_t *vam = &vat_main;
1333 i32 retval = ntohl (mp->retval);
1337 count = ntohl (mp->count);
1339 for (i = 0; i < count; i++)
1341 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1342 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1343 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1344 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1345 ntohl (mp->thread_data[i].cpu_socket));
1347 vam->retval = retval;
1348 vam->result_ready = 1;
1351 static void vl_api_show_threads_reply_t_handler_json
1352 (vl_api_show_threads_reply_t * mp)
1354 vat_main_t *vam = &vat_main;
1355 vat_json_node_t node;
1356 vl_api_thread_data_t *td;
1357 i32 retval = ntohl (mp->retval);
1361 count = ntohl (mp->count);
1363 vat_json_init_object (&node);
1364 vat_json_object_add_int (&node, "retval", retval);
1365 vat_json_object_add_uint (&node, "count", count);
1367 for (i = 0; i < count; i++)
1369 td = &mp->thread_data[i];
1370 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1371 vat_json_object_add_string_copy (&node, "name", td->name);
1372 vat_json_object_add_string_copy (&node, "type", td->type);
1373 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1374 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1375 vat_json_object_add_int (&node, "core", ntohl (td->id));
1376 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1379 vat_json_print (vam->ofp, &node);
1380 vat_json_free (&node);
1382 vam->retval = retval;
1383 vam->result_ready = 1;
1387 api_show_threads (vat_main_t * vam)
1389 vl_api_show_threads_t *mp;
1393 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1394 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1396 M (SHOW_THREADS, mp);
1404 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1406 u32 sw_if_index = ntohl (mp->sw_if_index);
1407 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1408 mp->mac_ip ? "mac/ip binding" : "address resolution",
1409 ntohl (mp->pid), format_ip4_address, mp->ip,
1410 format_vl_api_mac_address, &mp->mac, sw_if_index);
1414 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1416 /* JSON output not supported */
1420 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1422 u32 sw_if_index = ntohl (mp->sw_if_index);
1423 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1424 mp->mac_ip ? "mac/ip binding" : "address resolution",
1425 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1426 format_vl_api_mac_address, mp->mac, sw_if_index);
1430 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1432 /* JSON output not supported */
1436 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1438 u32 n_macs = ntohl (mp->n_macs);
1439 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1440 ntohl (mp->pid), mp->client_index, n_macs);
1442 for (i = 0; i < n_macs; i++)
1444 vl_api_mac_entry_t *mac = &mp->mac[i];
1445 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1446 i + 1, ntohl (mac->sw_if_index),
1447 format_ethernet_address, mac->mac_addr, mac->action);
1454 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1456 /* JSON output not supported */
1459 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1460 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1463 * Special-case: build the bridge domain table, maintain
1464 * the next bd id vbl.
1466 static void vl_api_bridge_domain_details_t_handler
1467 (vl_api_bridge_domain_details_t * mp)
1469 vat_main_t *vam = &vat_main;
1470 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1473 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1474 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1476 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1477 ntohl (mp->bd_id), mp->learn, mp->forward,
1478 mp->flood, ntohl (mp->bvi_sw_if_index),
1479 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1483 vl_api_bridge_domain_sw_if_t *sw_ifs;
1484 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1487 sw_ifs = mp->sw_if_details;
1488 for (i = 0; i < n_sw_ifs; i++)
1494 sw_if_index = ntohl (sw_ifs->sw_if_index);
1497 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1499 if ((u32) p->value[0] == sw_if_index)
1501 sw_if_name = (u8 *)(p->key);
1506 print (vam->ofp, "%7d %3d %s", sw_if_index,
1507 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1508 "sw_if_index not found!");
1515 static void vl_api_bridge_domain_details_t_handler_json
1516 (vl_api_bridge_domain_details_t * mp)
1518 vat_main_t *vam = &vat_main;
1519 vat_json_node_t *node, *array = NULL;
1520 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1522 if (VAT_JSON_ARRAY != vam->json_tree.type)
1524 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1525 vat_json_init_array (&vam->json_tree);
1527 node = vat_json_array_add (&vam->json_tree);
1529 vat_json_init_object (node);
1530 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1531 vat_json_object_add_uint (node, "flood", mp->flood);
1532 vat_json_object_add_uint (node, "forward", mp->forward);
1533 vat_json_object_add_uint (node, "learn", mp->learn);
1534 vat_json_object_add_uint (node, "bvi_sw_if_index",
1535 ntohl (mp->bvi_sw_if_index));
1536 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1537 array = vat_json_object_add (node, "sw_if");
1538 vat_json_init_array (array);
1544 vl_api_bridge_domain_sw_if_t *sw_ifs;
1547 sw_ifs = mp->sw_if_details;
1548 for (i = 0; i < n_sw_ifs; i++)
1550 node = vat_json_array_add (array);
1551 vat_json_init_object (node);
1552 vat_json_object_add_uint (node, "sw_if_index",
1553 ntohl (sw_ifs->sw_if_index));
1554 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1560 static void vl_api_control_ping_reply_t_handler
1561 (vl_api_control_ping_reply_t * mp)
1563 vat_main_t *vam = &vat_main;
1564 i32 retval = ntohl (mp->retval);
1565 if (vam->async_mode)
1567 vam->async_errors += (retval < 0);
1571 vam->retval = retval;
1572 vam->result_ready = 1;
1574 if (vam->socket_client_main)
1575 vam->socket_client_main->control_pings_outstanding--;
1578 static void vl_api_control_ping_reply_t_handler_json
1579 (vl_api_control_ping_reply_t * mp)
1581 vat_main_t *vam = &vat_main;
1582 i32 retval = ntohl (mp->retval);
1584 if (VAT_JSON_NONE != vam->json_tree.type)
1586 vat_json_print (vam->ofp, &vam->json_tree);
1587 vat_json_free (&vam->json_tree);
1588 vam->json_tree.type = VAT_JSON_NONE;
1593 vat_json_init_array (&vam->json_tree);
1594 vat_json_print (vam->ofp, &vam->json_tree);
1595 vam->json_tree.type = VAT_JSON_NONE;
1598 vam->retval = retval;
1599 vam->result_ready = 1;
1603 vl_api_bridge_domain_set_mac_age_reply_t_handler
1604 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1606 vat_main_t *vam = &vat_main;
1607 i32 retval = ntohl (mp->retval);
1608 if (vam->async_mode)
1610 vam->async_errors += (retval < 0);
1614 vam->retval = retval;
1615 vam->result_ready = 1;
1619 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1620 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1622 vat_main_t *vam = &vat_main;
1623 vat_json_node_t node;
1625 vat_json_init_object (&node);
1626 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1628 vat_json_print (vam->ofp, &node);
1629 vat_json_free (&node);
1631 vam->retval = ntohl (mp->retval);
1632 vam->result_ready = 1;
1636 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1638 vat_main_t *vam = &vat_main;
1639 i32 retval = ntohl (mp->retval);
1640 if (vam->async_mode)
1642 vam->async_errors += (retval < 0);
1646 vam->retval = retval;
1647 vam->result_ready = 1;
1651 static void vl_api_l2_flags_reply_t_handler_json
1652 (vl_api_l2_flags_reply_t * mp)
1654 vat_main_t *vam = &vat_main;
1655 vat_json_node_t node;
1657 vat_json_init_object (&node);
1658 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1659 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1660 ntohl (mp->resulting_feature_bitmap));
1662 vat_json_print (vam->ofp, &node);
1663 vat_json_free (&node);
1665 vam->retval = ntohl (mp->retval);
1666 vam->result_ready = 1;
1669 static void vl_api_bridge_flags_reply_t_handler
1670 (vl_api_bridge_flags_reply_t * mp)
1672 vat_main_t *vam = &vat_main;
1673 i32 retval = ntohl (mp->retval);
1674 if (vam->async_mode)
1676 vam->async_errors += (retval < 0);
1680 vam->retval = retval;
1681 vam->result_ready = 1;
1685 static void vl_api_bridge_flags_reply_t_handler_json
1686 (vl_api_bridge_flags_reply_t * mp)
1688 vat_main_t *vam = &vat_main;
1689 vat_json_node_t node;
1691 vat_json_init_object (&node);
1692 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1693 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1694 ntohl (mp->resulting_feature_bitmap));
1696 vat_json_print (vam->ofp, &node);
1697 vat_json_free (&node);
1699 vam->retval = ntohl (mp->retval);
1700 vam->result_ready = 1;
1704 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1706 vat_main_t *vam = &vat_main;
1707 i32 retval = ntohl (mp->retval);
1708 if (vam->async_mode)
1710 vam->async_errors += (retval < 0);
1714 vam->retval = retval;
1715 vam->sw_if_index = ntohl (mp->sw_if_index);
1716 vam->result_ready = 1;
1721 static void vl_api_tap_create_v2_reply_t_handler_json
1722 (vl_api_tap_create_v2_reply_t * mp)
1724 vat_main_t *vam = &vat_main;
1725 vat_json_node_t node;
1727 vat_json_init_object (&node);
1728 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1729 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1731 vat_json_print (vam->ofp, &node);
1732 vat_json_free (&node);
1734 vam->retval = ntohl (mp->retval);
1735 vam->result_ready = 1;
1740 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1742 vat_main_t *vam = &vat_main;
1743 i32 retval = ntohl (mp->retval);
1744 if (vam->async_mode)
1746 vam->async_errors += (retval < 0);
1750 vam->retval = retval;
1751 vam->result_ready = 1;
1755 static void vl_api_tap_delete_v2_reply_t_handler_json
1756 (vl_api_tap_delete_v2_reply_t * mp)
1758 vat_main_t *vam = &vat_main;
1759 vat_json_node_t node;
1761 vat_json_init_object (&node);
1762 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1764 vat_json_print (vam->ofp, &node);
1765 vat_json_free (&node);
1767 vam->retval = ntohl (mp->retval);
1768 vam->result_ready = 1;
1772 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1775 vat_main_t *vam = &vat_main;
1776 i32 retval = ntohl (mp->retval);
1777 if (vam->async_mode)
1779 vam->async_errors += (retval < 0);
1783 vam->retval = retval;
1784 vam->sw_if_index = ntohl (mp->sw_if_index);
1785 vam->result_ready = 1;
1789 static void vl_api_virtio_pci_create_reply_t_handler_json
1790 (vl_api_virtio_pci_create_reply_t * mp)
1792 vat_main_t *vam = &vat_main;
1793 vat_json_node_t node;
1795 vat_json_init_object (&node);
1796 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1797 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1799 vat_json_print (vam->ofp, &node);
1800 vat_json_free (&node);
1802 vam->retval = ntohl (mp->retval);
1803 vam->result_ready = 1;
1808 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1811 vat_main_t *vam = &vat_main;
1812 i32 retval = ntohl (mp->retval);
1813 if (vam->async_mode)
1815 vam->async_errors += (retval < 0);
1819 vam->retval = retval;
1820 vam->result_ready = 1;
1824 static void vl_api_virtio_pci_delete_reply_t_handler_json
1825 (vl_api_virtio_pci_delete_reply_t * mp)
1827 vat_main_t *vam = &vat_main;
1828 vat_json_node_t node;
1830 vat_json_init_object (&node);
1831 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1833 vat_json_print (vam->ofp, &node);
1834 vat_json_free (&node);
1836 vam->retval = ntohl (mp->retval);
1837 vam->result_ready = 1;
1841 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1843 vat_main_t *vam = &vat_main;
1844 i32 retval = ntohl (mp->retval);
1846 if (vam->async_mode)
1848 vam->async_errors += (retval < 0);
1852 vam->retval = retval;
1853 vam->sw_if_index = ntohl (mp->sw_if_index);
1854 vam->result_ready = 1;
1858 static void vl_api_bond_create_reply_t_handler_json
1859 (vl_api_bond_create_reply_t * mp)
1861 vat_main_t *vam = &vat_main;
1862 vat_json_node_t node;
1864 vat_json_init_object (&node);
1865 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1866 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1868 vat_json_print (vam->ofp, &node);
1869 vat_json_free (&node);
1871 vam->retval = ntohl (mp->retval);
1872 vam->result_ready = 1;
1876 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1878 vat_main_t *vam = &vat_main;
1879 i32 retval = ntohl (mp->retval);
1881 if (vam->async_mode)
1883 vam->async_errors += (retval < 0);
1887 vam->retval = retval;
1888 vam->result_ready = 1;
1892 static void vl_api_bond_delete_reply_t_handler_json
1893 (vl_api_bond_delete_reply_t * mp)
1895 vat_main_t *vam = &vat_main;
1896 vat_json_node_t node;
1898 vat_json_init_object (&node);
1899 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1901 vat_json_print (vam->ofp, &node);
1902 vat_json_free (&node);
1904 vam->retval = ntohl (mp->retval);
1905 vam->result_ready = 1;
1909 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1911 vat_main_t *vam = &vat_main;
1912 i32 retval = ntohl (mp->retval);
1914 if (vam->async_mode)
1916 vam->async_errors += (retval < 0);
1920 vam->retval = retval;
1921 vam->result_ready = 1;
1925 static void vl_api_bond_enslave_reply_t_handler_json
1926 (vl_api_bond_enslave_reply_t * mp)
1928 vat_main_t *vam = &vat_main;
1929 vat_json_node_t node;
1931 vat_json_init_object (&node);
1932 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1934 vat_json_print (vam->ofp, &node);
1935 vat_json_free (&node);
1937 vam->retval = ntohl (mp->retval);
1938 vam->result_ready = 1;
1942 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1945 vat_main_t *vam = &vat_main;
1946 i32 retval = ntohl (mp->retval);
1948 if (vam->async_mode)
1950 vam->async_errors += (retval < 0);
1954 vam->retval = retval;
1955 vam->result_ready = 1;
1959 static void vl_api_bond_detach_slave_reply_t_handler_json
1960 (vl_api_bond_detach_slave_reply_t * mp)
1962 vat_main_t *vam = &vat_main;
1963 vat_json_node_t node;
1965 vat_json_init_object (&node);
1966 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1968 vat_json_print (vam->ofp, &node);
1969 vat_json_free (&node);
1971 vam->retval = ntohl (mp->retval);
1972 vam->result_ready = 1;
1975 static void vl_api_sw_interface_bond_details_t_handler
1976 (vl_api_sw_interface_bond_details_t * mp)
1978 vat_main_t *vam = &vat_main;
1981 "%-16s %-12d %-12U %-13U %-14u %-14u",
1982 mp->interface_name, ntohl (mp->sw_if_index),
1983 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
1984 ntohl (mp->active_slaves), ntohl (mp->slaves));
1987 static void vl_api_sw_interface_bond_details_t_handler_json
1988 (vl_api_sw_interface_bond_details_t * mp)
1990 vat_main_t *vam = &vat_main;
1991 vat_json_node_t *node = NULL;
1993 if (VAT_JSON_ARRAY != vam->json_tree.type)
1995 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1996 vat_json_init_array (&vam->json_tree);
1998 node = vat_json_array_add (&vam->json_tree);
2000 vat_json_init_object (node);
2001 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2002 vat_json_object_add_string_copy (node, "interface_name",
2003 mp->interface_name);
2004 vat_json_object_add_uint (node, "mode", mp->mode);
2005 vat_json_object_add_uint (node, "load_balance", mp->lb);
2006 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2007 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2011 api_sw_interface_bond_dump (vat_main_t * vam)
2013 vl_api_sw_interface_bond_dump_t *mp;
2014 vl_api_control_ping_t *mp_ping;
2018 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2019 "interface name", "sw_if_index", "mode", "load balance",
2020 "active slaves", "slaves");
2022 /* Get list of bond interfaces */
2023 M (SW_INTERFACE_BOND_DUMP, mp);
2026 /* Use a control ping for synchronization */
2027 MPING (CONTROL_PING, mp_ping);
2034 static void vl_api_sw_interface_slave_details_t_handler
2035 (vl_api_sw_interface_slave_details_t * mp)
2037 vat_main_t *vam = &vat_main;
2040 "%-25s %-12d %-12d %d", mp->interface_name,
2041 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2044 static void vl_api_sw_interface_slave_details_t_handler_json
2045 (vl_api_sw_interface_slave_details_t * mp)
2047 vat_main_t *vam = &vat_main;
2048 vat_json_node_t *node = NULL;
2050 if (VAT_JSON_ARRAY != vam->json_tree.type)
2052 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2053 vat_json_init_array (&vam->json_tree);
2055 node = vat_json_array_add (&vam->json_tree);
2057 vat_json_init_object (node);
2058 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2059 vat_json_object_add_string_copy (node, "interface_name",
2060 mp->interface_name);
2061 vat_json_object_add_uint (node, "passive", mp->is_passive);
2062 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2066 api_sw_interface_slave_dump (vat_main_t * vam)
2068 unformat_input_t *i = vam->input;
2069 vl_api_sw_interface_slave_dump_t *mp;
2070 vl_api_control_ping_t *mp_ping;
2071 u32 sw_if_index = ~0;
2072 u8 sw_if_index_set = 0;
2075 /* Parse args required to build the message */
2076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2078 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2079 sw_if_index_set = 1;
2080 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2081 sw_if_index_set = 1;
2086 if (sw_if_index_set == 0)
2088 errmsg ("missing vpp interface name. ");
2093 "\n%-25s %-12s %-12s %s",
2094 "slave interface name", "sw_if_index", "passive", "long_timeout");
2096 /* Get list of bond interfaces */
2097 M (SW_INTERFACE_SLAVE_DUMP, mp);
2098 mp->sw_if_index = ntohl (sw_if_index);
2101 /* Use a control ping for synchronization */
2102 MPING (CONTROL_PING, mp_ping);
2109 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2110 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2112 vat_main_t *vam = &vat_main;
2113 i32 retval = ntohl (mp->retval);
2114 if (vam->async_mode)
2116 vam->async_errors += (retval < 0);
2120 vam->retval = retval;
2121 vam->sw_if_index = ntohl (mp->sw_if_index);
2122 vam->result_ready = 1;
2124 vam->regenerate_interface_table = 1;
2127 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2128 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2130 vat_main_t *vam = &vat_main;
2131 vat_json_node_t node;
2133 vat_json_init_object (&node);
2134 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2135 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2136 ntohl (mp->sw_if_index));
2138 vat_json_print (vam->ofp, &node);
2139 vat_json_free (&node);
2141 vam->retval = ntohl (mp->retval);
2142 vam->result_ready = 1;
2145 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2146 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2148 vat_main_t *vam = &vat_main;
2149 i32 retval = ntohl (mp->retval);
2150 if (vam->async_mode)
2152 vam->async_errors += (retval < 0);
2156 vam->retval = retval;
2157 vam->sw_if_index = ntohl (mp->sw_if_index);
2158 vam->result_ready = 1;
2162 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2163 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2165 vat_main_t *vam = &vat_main;
2166 vat_json_node_t node;
2168 vat_json_init_object (&node);
2169 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2170 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2172 vat_json_print (vam->ofp, &node);
2173 vat_json_free (&node);
2175 vam->retval = ntohl (mp->retval);
2176 vam->result_ready = 1;
2179 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2180 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2182 vat_main_t *vam = &vat_main;
2183 i32 retval = ntohl (mp->retval);
2184 if (vam->async_mode)
2186 vam->async_errors += (retval < 0);
2190 vam->retval = retval;
2191 vam->result_ready = 1;
2195 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2196 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vat_json_node_t node;
2201 vat_json_init_object (&node);
2202 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2203 vat_json_object_add_uint (&node, "fwd_entry_index",
2204 clib_net_to_host_u32 (mp->fwd_entry_index));
2206 vat_json_print (vam->ofp, &node);
2207 vat_json_free (&node);
2209 vam->retval = ntohl (mp->retval);
2210 vam->result_ready = 1;
2214 format_lisp_transport_protocol (u8 * s, va_list * args)
2216 u32 proto = va_arg (*args, u32);
2221 return format (s, "udp");
2223 return format (s, "api");
2230 static void vl_api_one_get_transport_protocol_reply_t_handler
2231 (vl_api_one_get_transport_protocol_reply_t * mp)
2233 vat_main_t *vam = &vat_main;
2234 i32 retval = ntohl (mp->retval);
2235 if (vam->async_mode)
2237 vam->async_errors += (retval < 0);
2241 u32 proto = mp->protocol;
2242 print (vam->ofp, "Transport protocol: %U",
2243 format_lisp_transport_protocol, proto);
2244 vam->retval = retval;
2245 vam->result_ready = 1;
2249 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2250 (vl_api_one_get_transport_protocol_reply_t * mp)
2252 vat_main_t *vam = &vat_main;
2253 vat_json_node_t node;
2256 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2259 vat_json_init_object (&node);
2260 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2261 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2264 vat_json_print (vam->ofp, &node);
2265 vat_json_free (&node);
2267 vam->retval = ntohl (mp->retval);
2268 vam->result_ready = 1;
2271 static void vl_api_one_add_del_locator_set_reply_t_handler
2272 (vl_api_one_add_del_locator_set_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 i32 retval = ntohl (mp->retval);
2276 if (vam->async_mode)
2278 vam->async_errors += (retval < 0);
2282 vam->retval = retval;
2283 vam->result_ready = 1;
2287 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2288 (vl_api_one_add_del_locator_set_reply_t * mp)
2290 vat_main_t *vam = &vat_main;
2291 vat_json_node_t node;
2293 vat_json_init_object (&node);
2294 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2295 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2297 vat_json_print (vam->ofp, &node);
2298 vat_json_free (&node);
2300 vam->retval = ntohl (mp->retval);
2301 vam->result_ready = 1;
2304 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2305 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2307 vat_main_t *vam = &vat_main;
2308 i32 retval = ntohl (mp->retval);
2309 if (vam->async_mode)
2311 vam->async_errors += (retval < 0);
2315 vam->retval = retval;
2316 vam->sw_if_index = ntohl (mp->sw_if_index);
2317 vam->result_ready = 1;
2319 vam->regenerate_interface_table = 1;
2322 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2323 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2325 vat_main_t *vam = &vat_main;
2326 vat_json_node_t node;
2328 vat_json_init_object (&node);
2329 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2330 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2332 vat_json_print (vam->ofp, &node);
2333 vat_json_free (&node);
2335 vam->retval = ntohl (mp->retval);
2336 vam->result_ready = 1;
2339 static void vl_api_vxlan_offload_rx_reply_t_handler
2340 (vl_api_vxlan_offload_rx_reply_t * mp)
2342 vat_main_t *vam = &vat_main;
2343 i32 retval = ntohl (mp->retval);
2344 if (vam->async_mode)
2346 vam->async_errors += (retval < 0);
2350 vam->retval = retval;
2351 vam->result_ready = 1;
2355 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2356 (vl_api_vxlan_offload_rx_reply_t * mp)
2358 vat_main_t *vam = &vat_main;
2359 vat_json_node_t node;
2361 vat_json_init_object (&node);
2362 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2364 vat_json_print (vam->ofp, &node);
2365 vat_json_free (&node);
2367 vam->retval = ntohl (mp->retval);
2368 vam->result_ready = 1;
2371 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2372 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2374 vat_main_t *vam = &vat_main;
2375 i32 retval = ntohl (mp->retval);
2376 if (vam->async_mode)
2378 vam->async_errors += (retval < 0);
2382 vam->retval = retval;
2383 vam->sw_if_index = ntohl (mp->sw_if_index);
2384 vam->result_ready = 1;
2388 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2389 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2391 vat_main_t *vam = &vat_main;
2392 vat_json_node_t node;
2394 vat_json_init_object (&node);
2395 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2396 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2398 vat_json_print (vam->ofp, &node);
2399 vat_json_free (&node);
2401 vam->retval = ntohl (mp->retval);
2402 vam->result_ready = 1;
2405 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2406 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2408 vat_main_t *vam = &vat_main;
2409 i32 retval = ntohl (mp->retval);
2410 if (vam->async_mode)
2412 vam->async_errors += (retval < 0);
2416 vam->retval = retval;
2417 vam->sw_if_index = ntohl (mp->sw_if_index);
2418 vam->result_ready = 1;
2420 vam->regenerate_interface_table = 1;
2423 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2424 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2426 vat_main_t *vam = &vat_main;
2427 vat_json_node_t node;
2429 vat_json_init_object (&node);
2430 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2431 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2433 vat_json_print (vam->ofp, &node);
2434 vat_json_free (&node);
2436 vam->retval = ntohl (mp->retval);
2437 vam->result_ready = 1;
2440 static void vl_api_gre_add_del_tunnel_reply_t_handler
2441 (vl_api_gre_add_del_tunnel_reply_t * mp)
2443 vat_main_t *vam = &vat_main;
2444 i32 retval = ntohl (mp->retval);
2445 if (vam->async_mode)
2447 vam->async_errors += (retval < 0);
2451 vam->retval = retval;
2452 vam->sw_if_index = ntohl (mp->sw_if_index);
2453 vam->result_ready = 1;
2457 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
2458 (vl_api_gre_add_del_tunnel_reply_t * mp)
2460 vat_main_t *vam = &vat_main;
2461 vat_json_node_t node;
2463 vat_json_init_object (&node);
2464 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2465 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2467 vat_json_print (vam->ofp, &node);
2468 vat_json_free (&node);
2470 vam->retval = ntohl (mp->retval);
2471 vam->result_ready = 1;
2474 static void vl_api_create_vhost_user_if_reply_t_handler
2475 (vl_api_create_vhost_user_if_reply_t * mp)
2477 vat_main_t *vam = &vat_main;
2478 i32 retval = ntohl (mp->retval);
2479 if (vam->async_mode)
2481 vam->async_errors += (retval < 0);
2485 vam->retval = retval;
2486 vam->sw_if_index = ntohl (mp->sw_if_index);
2487 vam->result_ready = 1;
2489 vam->regenerate_interface_table = 1;
2492 static void vl_api_create_vhost_user_if_reply_t_handler_json
2493 (vl_api_create_vhost_user_if_reply_t * mp)
2495 vat_main_t *vam = &vat_main;
2496 vat_json_node_t node;
2498 vat_json_init_object (&node);
2499 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2500 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2502 vat_json_print (vam->ofp, &node);
2503 vat_json_free (&node);
2505 vam->retval = ntohl (mp->retval);
2506 vam->result_ready = 1;
2509 static void vl_api_dns_resolve_name_reply_t_handler
2510 (vl_api_dns_resolve_name_reply_t * mp)
2512 vat_main_t *vam = &vat_main;
2513 i32 retval = ntohl (mp->retval);
2514 if (vam->async_mode)
2516 vam->async_errors += (retval < 0);
2520 vam->retval = retval;
2521 vam->result_ready = 1;
2526 clib_warning ("ip4 address %U", format_ip4_address,
2527 (ip4_address_t *) mp->ip4_address);
2529 clib_warning ("ip6 address %U", format_ip6_address,
2530 (ip6_address_t *) mp->ip6_address);
2533 clib_warning ("retval %d", retval);
2537 static void vl_api_dns_resolve_name_reply_t_handler_json
2538 (vl_api_dns_resolve_name_reply_t * mp)
2540 clib_warning ("not implemented");
2543 static void vl_api_dns_resolve_ip_reply_t_handler
2544 (vl_api_dns_resolve_ip_reply_t * mp)
2546 vat_main_t *vam = &vat_main;
2547 i32 retval = ntohl (mp->retval);
2548 if (vam->async_mode)
2550 vam->async_errors += (retval < 0);
2554 vam->retval = retval;
2555 vam->result_ready = 1;
2559 clib_warning ("canonical name %s", mp->name);
2562 clib_warning ("retval %d", retval);
2566 static void vl_api_dns_resolve_ip_reply_t_handler_json
2567 (vl_api_dns_resolve_ip_reply_t * mp)
2569 clib_warning ("not implemented");
2573 static void vl_api_ip_address_details_t_handler
2574 (vl_api_ip_address_details_t * mp)
2576 vat_main_t *vam = &vat_main;
2577 static ip_address_details_t empty_ip_address_details = { {0} };
2578 ip_address_details_t *address = NULL;
2579 ip_details_t *current_ip_details = NULL;
2580 ip_details_t *details = NULL;
2582 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2584 if (!details || vam->current_sw_if_index >= vec_len (details)
2585 || !details[vam->current_sw_if_index].present)
2587 errmsg ("ip address details arrived but not stored");
2588 errmsg ("ip_dump should be called first");
2592 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2594 #define addresses (current_ip_details->addr)
2596 vec_validate_init_empty (addresses, vec_len (addresses),
2597 empty_ip_address_details);
2599 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2601 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2602 address->prefix_length = mp->prefix_length;
2606 static void vl_api_ip_address_details_t_handler_json
2607 (vl_api_ip_address_details_t * mp)
2609 vat_main_t *vam = &vat_main;
2610 vat_json_node_t *node = NULL;
2611 struct in6_addr ip6;
2614 if (VAT_JSON_ARRAY != vam->json_tree.type)
2616 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2617 vat_json_init_array (&vam->json_tree);
2619 node = vat_json_array_add (&vam->json_tree);
2621 vat_json_init_object (node);
2624 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2625 vat_json_object_add_ip6 (node, "ip", ip6);
2629 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2630 vat_json_object_add_ip4 (node, "ip", ip4);
2632 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2636 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2638 vat_main_t *vam = &vat_main;
2639 static ip_details_t empty_ip_details = { 0 };
2640 ip_details_t *ip = NULL;
2641 u32 sw_if_index = ~0;
2643 sw_if_index = ntohl (mp->sw_if_index);
2645 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2646 sw_if_index, empty_ip_details);
2648 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2655 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2657 vat_main_t *vam = &vat_main;
2659 if (VAT_JSON_ARRAY != vam->json_tree.type)
2661 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2662 vat_json_init_array (&vam->json_tree);
2664 vat_json_array_add_uint (&vam->json_tree,
2665 clib_net_to_host_u32 (mp->sw_if_index));
2669 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2671 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2672 "router_addr %U host_mac %U",
2673 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2675 format_ip4_address, &mp->lease.host_address,
2676 format_ip4_address, &mp->lease.router_address,
2677 format_ethernet_address, mp->lease.host_mac);
2680 static void vl_api_dhcp_compl_event_t_handler_json
2681 (vl_api_dhcp_compl_event_t * mp)
2683 /* JSON output not supported */
2686 static void vl_api_get_first_msg_id_reply_t_handler
2687 (vl_api_get_first_msg_id_reply_t * mp)
2689 vat_main_t *vam = &vat_main;
2690 i32 retval = ntohl (mp->retval);
2692 if (vam->async_mode)
2694 vam->async_errors += (retval < 0);
2698 vam->retval = retval;
2699 vam->result_ready = 1;
2703 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2707 static void vl_api_get_first_msg_id_reply_t_handler_json
2708 (vl_api_get_first_msg_id_reply_t * mp)
2710 vat_main_t *vam = &vat_main;
2711 vat_json_node_t node;
2713 vat_json_init_object (&node);
2714 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2715 vat_json_object_add_uint (&node, "first_msg_id",
2716 (uint) ntohs (mp->first_msg_id));
2718 vat_json_print (vam->ofp, &node);
2719 vat_json_free (&node);
2721 vam->retval = ntohl (mp->retval);
2722 vam->result_ready = 1;
2725 static void vl_api_get_node_graph_reply_t_handler
2726 (vl_api_get_node_graph_reply_t * mp)
2728 vat_main_t *vam = &vat_main;
2729 api_main_t *am = &api_main;
2730 i32 retval = ntohl (mp->retval);
2731 u8 *pvt_copy, *reply;
2736 if (vam->async_mode)
2738 vam->async_errors += (retval < 0);
2742 vam->retval = retval;
2743 vam->result_ready = 1;
2746 /* "Should never happen..." */
2750 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2751 pvt_copy = vec_dup (reply);
2753 /* Toss the shared-memory original... */
2754 pthread_mutex_lock (&am->vlib_rp->mutex);
2755 oldheap = svm_push_data_heap (am->vlib_rp);
2759 svm_pop_heap (oldheap);
2760 pthread_mutex_unlock (&am->vlib_rp->mutex);
2762 if (vam->graph_nodes)
2764 hash_free (vam->graph_node_index_by_name);
2766 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2768 node = vam->graph_nodes[0][i];
2769 vec_free (node->name);
2770 vec_free (node->next_nodes);
2773 vec_free (vam->graph_nodes[0]);
2774 vec_free (vam->graph_nodes);
2777 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2778 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2779 vec_free (pvt_copy);
2781 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2783 node = vam->graph_nodes[0][i];
2784 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2788 static void vl_api_get_node_graph_reply_t_handler_json
2789 (vl_api_get_node_graph_reply_t * mp)
2791 vat_main_t *vam = &vat_main;
2792 api_main_t *am = &api_main;
2794 vat_json_node_t node;
2797 /* $$$$ make this real? */
2798 vat_json_init_object (&node);
2799 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2800 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2802 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2804 /* Toss the shared-memory original... */
2805 pthread_mutex_lock (&am->vlib_rp->mutex);
2806 oldheap = svm_push_data_heap (am->vlib_rp);
2810 svm_pop_heap (oldheap);
2811 pthread_mutex_unlock (&am->vlib_rp->mutex);
2813 vat_json_print (vam->ofp, &node);
2814 vat_json_free (&node);
2816 vam->retval = ntohl (mp->retval);
2817 vam->result_ready = 1;
2821 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2823 vat_main_t *vam = &vat_main;
2828 s = format (s, "%=16d%=16d%=16d",
2829 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2833 s = format (s, "%=16U%=16d%=16d",
2834 mp->is_ipv6 ? format_ip6_address :
2836 mp->ip_address, mp->priority, mp->weight);
2839 print (vam->ofp, "%v", s);
2844 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2846 vat_main_t *vam = &vat_main;
2847 vat_json_node_t *node = NULL;
2848 struct in6_addr ip6;
2851 if (VAT_JSON_ARRAY != vam->json_tree.type)
2853 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2854 vat_json_init_array (&vam->json_tree);
2856 node = vat_json_array_add (&vam->json_tree);
2857 vat_json_init_object (node);
2859 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2860 vat_json_object_add_uint (node, "priority", mp->priority);
2861 vat_json_object_add_uint (node, "weight", mp->weight);
2864 vat_json_object_add_uint (node, "sw_if_index",
2865 clib_net_to_host_u32 (mp->sw_if_index));
2870 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2871 vat_json_object_add_ip6 (node, "address", ip6);
2875 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2876 vat_json_object_add_ip4 (node, "address", ip4);
2882 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2885 vat_main_t *vam = &vat_main;
2888 ls_name = format (0, "%s", mp->ls_name);
2890 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2896 vl_api_one_locator_set_details_t_handler_json
2897 (vl_api_one_locator_set_details_t * mp)
2899 vat_main_t *vam = &vat_main;
2900 vat_json_node_t *node = 0;
2903 ls_name = format (0, "%s", mp->ls_name);
2904 vec_add1 (ls_name, 0);
2906 if (VAT_JSON_ARRAY != vam->json_tree.type)
2908 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2909 vat_json_init_array (&vam->json_tree);
2911 node = vat_json_array_add (&vam->json_tree);
2913 vat_json_init_object (node);
2914 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2915 vat_json_object_add_uint (node, "ls_index",
2916 clib_net_to_host_u32 (mp->ls_index));
2924 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2927 unformat_nsh_address (unformat_input_t * input, va_list * args)
2929 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2930 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2934 format_nsh_address_vat (u8 * s, va_list * args)
2936 nsh_t *a = va_arg (*args, nsh_t *);
2937 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2941 format_lisp_flat_eid (u8 * s, va_list * args)
2943 u32 type = va_arg (*args, u32);
2944 u8 *eid = va_arg (*args, u8 *);
2945 u32 eid_len = va_arg (*args, u32);
2950 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2952 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2954 return format (s, "%U", format_ethernet_address, eid);
2956 return format (s, "%U", format_nsh_address_vat, eid);
2962 format_lisp_eid_vat (u8 * s, va_list * args)
2964 u32 type = va_arg (*args, u32);
2965 u8 *eid = va_arg (*args, u8 *);
2966 u32 eid_len = va_arg (*args, u32);
2967 u8 *seid = va_arg (*args, u8 *);
2968 u32 seid_len = va_arg (*args, u32);
2969 u32 is_src_dst = va_arg (*args, u32);
2972 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2974 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2980 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2982 vat_main_t *vam = &vat_main;
2983 u8 *s = 0, *eid = 0;
2985 if (~0 == mp->locator_set_index)
2986 s = format (0, "action: %d", mp->action);
2988 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2990 eid = format (0, "%U", format_lisp_eid_vat,
2994 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2997 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2998 clib_net_to_host_u32 (mp->vni),
3000 mp->is_local ? "local" : "remote",
3001 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3002 clib_net_to_host_u16 (mp->key_id), mp->key);
3009 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3012 vat_main_t *vam = &vat_main;
3013 vat_json_node_t *node = 0;
3016 if (VAT_JSON_ARRAY != vam->json_tree.type)
3018 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3019 vat_json_init_array (&vam->json_tree);
3021 node = vat_json_array_add (&vam->json_tree);
3023 vat_json_init_object (node);
3024 if (~0 == mp->locator_set_index)
3025 vat_json_object_add_uint (node, "action", mp->action);
3027 vat_json_object_add_uint (node, "locator_set_index",
3028 clib_net_to_host_u32 (mp->locator_set_index));
3030 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3031 if (mp->eid_type == 3)
3033 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3034 vat_json_init_object (nsh_json);
3035 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3036 vat_json_object_add_uint (nsh_json, "spi",
3037 clib_net_to_host_u32 (nsh->spi));
3038 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3042 eid = format (0, "%U", format_lisp_eid_vat,
3046 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3048 vat_json_object_add_string_copy (node, "eid", eid);
3051 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3052 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3053 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3057 vat_json_object_add_uint (node, "key_id",
3058 clib_net_to_host_u16 (mp->key_id));
3059 vat_json_object_add_string_copy (node, "key", mp->key);
3064 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3066 vat_main_t *vam = &vat_main;
3067 u8 *seid = 0, *deid = 0;
3068 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3070 deid = format (0, "%U", format_lisp_eid_vat,
3071 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3073 seid = format (0, "%U", format_lisp_eid_vat,
3074 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3080 format_ip_address_fcn = format_ip4_address;
3082 format_ip_address_fcn = format_ip6_address;
3085 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3086 clib_net_to_host_u32 (mp->vni),
3088 format_ip_address_fcn, mp->lloc,
3089 format_ip_address_fcn, mp->rloc,
3090 clib_net_to_host_u32 (mp->pkt_count),
3091 clib_net_to_host_u32 (mp->bytes));
3098 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3100 struct in6_addr ip6;
3102 vat_main_t *vam = &vat_main;
3103 vat_json_node_t *node = 0;
3104 u8 *deid = 0, *seid = 0;
3106 if (VAT_JSON_ARRAY != vam->json_tree.type)
3108 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3109 vat_json_init_array (&vam->json_tree);
3111 node = vat_json_array_add (&vam->json_tree);
3113 vat_json_init_object (node);
3114 deid = format (0, "%U", format_lisp_eid_vat,
3115 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3117 seid = format (0, "%U", format_lisp_eid_vat,
3118 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3123 vat_json_object_add_string_copy (node, "seid", seid);
3124 vat_json_object_add_string_copy (node, "deid", deid);
3125 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3129 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3130 vat_json_object_add_ip4 (node, "lloc", ip4);
3131 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3132 vat_json_object_add_ip4 (node, "rloc", ip4);
3136 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3137 vat_json_object_add_ip6 (node, "lloc", ip6);
3138 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3139 vat_json_object_add_ip6 (node, "rloc", ip6);
3141 vat_json_object_add_uint (node, "pkt_count",
3142 clib_net_to_host_u32 (mp->pkt_count));
3143 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3150 vl_api_one_eid_table_map_details_t_handler
3151 (vl_api_one_eid_table_map_details_t * mp)
3153 vat_main_t *vam = &vat_main;
3155 u8 *line = format (0, "%=10d%=10d",
3156 clib_net_to_host_u32 (mp->vni),
3157 clib_net_to_host_u32 (mp->dp_table));
3158 print (vam->ofp, "%v", line);
3163 vl_api_one_eid_table_map_details_t_handler_json
3164 (vl_api_one_eid_table_map_details_t * mp)
3166 vat_main_t *vam = &vat_main;
3167 vat_json_node_t *node = NULL;
3169 if (VAT_JSON_ARRAY != vam->json_tree.type)
3171 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3172 vat_json_init_array (&vam->json_tree);
3174 node = vat_json_array_add (&vam->json_tree);
3175 vat_json_init_object (node);
3176 vat_json_object_add_uint (node, "dp_table",
3177 clib_net_to_host_u32 (mp->dp_table));
3178 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3182 vl_api_one_eid_table_vni_details_t_handler
3183 (vl_api_one_eid_table_vni_details_t * mp)
3185 vat_main_t *vam = &vat_main;
3187 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3188 print (vam->ofp, "%v", line);
3193 vl_api_one_eid_table_vni_details_t_handler_json
3194 (vl_api_one_eid_table_vni_details_t * mp)
3196 vat_main_t *vam = &vat_main;
3197 vat_json_node_t *node = NULL;
3199 if (VAT_JSON_ARRAY != vam->json_tree.type)
3201 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3202 vat_json_init_array (&vam->json_tree);
3204 node = vat_json_array_add (&vam->json_tree);
3205 vat_json_init_object (node);
3206 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3210 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3211 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3213 vat_main_t *vam = &vat_main;
3214 int retval = clib_net_to_host_u32 (mp->retval);
3216 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3217 print (vam->ofp, "fallback threshold value: %d", mp->value);
3219 vam->retval = retval;
3220 vam->result_ready = 1;
3224 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3225 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3227 vat_main_t *vam = &vat_main;
3228 vat_json_node_t _node, *node = &_node;
3229 int retval = clib_net_to_host_u32 (mp->retval);
3231 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3232 vat_json_init_object (node);
3233 vat_json_object_add_uint (node, "value", mp->value);
3235 vat_json_print (vam->ofp, node);
3236 vat_json_free (node);
3238 vam->retval = retval;
3239 vam->result_ready = 1;
3243 vl_api_show_one_map_register_state_reply_t_handler
3244 (vl_api_show_one_map_register_state_reply_t * mp)
3246 vat_main_t *vam = &vat_main;
3247 int retval = clib_net_to_host_u32 (mp->retval);
3249 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3251 vam->retval = retval;
3252 vam->result_ready = 1;
3256 vl_api_show_one_map_register_state_reply_t_handler_json
3257 (vl_api_show_one_map_register_state_reply_t * mp)
3259 vat_main_t *vam = &vat_main;
3260 vat_json_node_t _node, *node = &_node;
3261 int retval = clib_net_to_host_u32 (mp->retval);
3263 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3265 vat_json_init_object (node);
3266 vat_json_object_add_string_copy (node, "state", s);
3268 vat_json_print (vam->ofp, node);
3269 vat_json_free (node);
3271 vam->retval = retval;
3272 vam->result_ready = 1;
3277 vl_api_show_one_rloc_probe_state_reply_t_handler
3278 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3280 vat_main_t *vam = &vat_main;
3281 int retval = clib_net_to_host_u32 (mp->retval);
3286 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3288 vam->retval = retval;
3289 vam->result_ready = 1;
3293 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3294 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3296 vat_main_t *vam = &vat_main;
3297 vat_json_node_t _node, *node = &_node;
3298 int retval = clib_net_to_host_u32 (mp->retval);
3300 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3301 vat_json_init_object (node);
3302 vat_json_object_add_string_copy (node, "state", s);
3304 vat_json_print (vam->ofp, node);
3305 vat_json_free (node);
3307 vam->retval = retval;
3308 vam->result_ready = 1;
3313 vl_api_show_one_stats_enable_disable_reply_t_handler
3314 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3316 vat_main_t *vam = &vat_main;
3317 int retval = clib_net_to_host_u32 (mp->retval);
3322 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3324 vam->retval = retval;
3325 vam->result_ready = 1;
3329 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3330 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3332 vat_main_t *vam = &vat_main;
3333 vat_json_node_t _node, *node = &_node;
3334 int retval = clib_net_to_host_u32 (mp->retval);
3336 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3337 vat_json_init_object (node);
3338 vat_json_object_add_string_copy (node, "state", s);
3340 vat_json_print (vam->ofp, node);
3341 vat_json_free (node);
3343 vam->retval = retval;
3344 vam->result_ready = 1;
3349 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3351 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3352 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3353 e->vni = clib_net_to_host_u32 (e->vni);
3357 gpe_fwd_entries_get_reply_t_net_to_host
3358 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3362 mp->count = clib_net_to_host_u32 (mp->count);
3363 for (i = 0; i < mp->count; i++)
3365 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3370 format_gpe_encap_mode (u8 * s, va_list * args)
3372 u32 mode = va_arg (*args, u32);
3377 return format (s, "lisp");
3379 return format (s, "vxlan");
3385 vl_api_gpe_get_encap_mode_reply_t_handler
3386 (vl_api_gpe_get_encap_mode_reply_t * mp)
3388 vat_main_t *vam = &vat_main;
3390 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3391 vam->retval = ntohl (mp->retval);
3392 vam->result_ready = 1;
3396 vl_api_gpe_get_encap_mode_reply_t_handler_json
3397 (vl_api_gpe_get_encap_mode_reply_t * mp)
3399 vat_main_t *vam = &vat_main;
3400 vat_json_node_t node;
3402 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3403 vec_add1 (encap_mode, 0);
3405 vat_json_init_object (&node);
3406 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3408 vec_free (encap_mode);
3409 vat_json_print (vam->ofp, &node);
3410 vat_json_free (&node);
3412 vam->retval = ntohl (mp->retval);
3413 vam->result_ready = 1;
3417 vl_api_gpe_fwd_entry_path_details_t_handler
3418 (vl_api_gpe_fwd_entry_path_details_t * mp)
3420 vat_main_t *vam = &vat_main;
3421 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3423 if (mp->lcl_loc.is_ip4)
3424 format_ip_address_fcn = format_ip4_address;
3426 format_ip_address_fcn = format_ip6_address;
3428 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3429 format_ip_address_fcn, &mp->lcl_loc,
3430 format_ip_address_fcn, &mp->rmt_loc);
3434 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3436 struct in6_addr ip6;
3441 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3442 vat_json_object_add_ip4 (n, "address", ip4);
3446 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3447 vat_json_object_add_ip6 (n, "address", ip6);
3449 vat_json_object_add_uint (n, "weight", loc->weight);
3453 vl_api_gpe_fwd_entry_path_details_t_handler_json
3454 (vl_api_gpe_fwd_entry_path_details_t * mp)
3456 vat_main_t *vam = &vat_main;
3457 vat_json_node_t *node = NULL;
3458 vat_json_node_t *loc_node;
3460 if (VAT_JSON_ARRAY != vam->json_tree.type)
3462 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3463 vat_json_init_array (&vam->json_tree);
3465 node = vat_json_array_add (&vam->json_tree);
3466 vat_json_init_object (node);
3468 loc_node = vat_json_object_add (node, "local_locator");
3469 vat_json_init_object (loc_node);
3470 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3472 loc_node = vat_json_object_add (node, "remote_locator");
3473 vat_json_init_object (loc_node);
3474 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3478 vl_api_gpe_fwd_entries_get_reply_t_handler
3479 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3481 vat_main_t *vam = &vat_main;
3483 int retval = clib_net_to_host_u32 (mp->retval);
3484 vl_api_gpe_fwd_entry_t *e;
3489 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3491 for (i = 0; i < mp->count; i++)
3493 e = &mp->entries[i];
3494 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3495 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3496 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3500 vam->retval = retval;
3501 vam->result_ready = 1;
3505 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3506 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3509 vat_main_t *vam = &vat_main;
3510 vat_json_node_t *e = 0, root;
3512 int retval = clib_net_to_host_u32 (mp->retval);
3513 vl_api_gpe_fwd_entry_t *fwd;
3518 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3519 vat_json_init_array (&root);
3521 for (i = 0; i < mp->count; i++)
3523 e = vat_json_array_add (&root);
3524 fwd = &mp->entries[i];
3526 vat_json_init_object (e);
3527 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3528 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3529 vat_json_object_add_int (e, "vni", fwd->vni);
3530 vat_json_object_add_int (e, "action", fwd->action);
3532 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3533 fwd->leid_prefix_len);
3535 vat_json_object_add_string_copy (e, "leid", s);
3538 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3539 fwd->reid_prefix_len);
3541 vat_json_object_add_string_copy (e, "reid", s);
3545 vat_json_print (vam->ofp, &root);
3546 vat_json_free (&root);
3549 vam->retval = retval;
3550 vam->result_ready = 1;
3554 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3555 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3557 vat_main_t *vam = &vat_main;
3559 int retval = clib_net_to_host_u32 (mp->retval);
3560 vl_api_gpe_native_fwd_rpath_t *r;
3565 n = clib_net_to_host_u32 (mp->count);
3567 for (i = 0; i < n; i++)
3569 r = &mp->entries[i];
3570 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3571 clib_net_to_host_u32 (r->fib_index),
3572 clib_net_to_host_u32 (r->nh_sw_if_index),
3573 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3577 vam->retval = retval;
3578 vam->result_ready = 1;
3582 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3583 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3585 vat_main_t *vam = &vat_main;
3586 vat_json_node_t root, *e;
3588 int retval = clib_net_to_host_u32 (mp->retval);
3589 vl_api_gpe_native_fwd_rpath_t *r;
3595 n = clib_net_to_host_u32 (mp->count);
3596 vat_json_init_array (&root);
3598 for (i = 0; i < n; i++)
3600 e = vat_json_array_add (&root);
3601 vat_json_init_object (e);
3602 r = &mp->entries[i];
3604 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3607 vat_json_object_add_string_copy (e, "ip4", s);
3610 vat_json_object_add_uint (e, "fib_index",
3611 clib_net_to_host_u32 (r->fib_index));
3612 vat_json_object_add_uint (e, "nh_sw_if_index",
3613 clib_net_to_host_u32 (r->nh_sw_if_index));
3616 vat_json_print (vam->ofp, &root);
3617 vat_json_free (&root);
3620 vam->retval = retval;
3621 vam->result_ready = 1;
3625 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3626 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3628 vat_main_t *vam = &vat_main;
3630 int retval = clib_net_to_host_u32 (mp->retval);
3635 n = clib_net_to_host_u32 (mp->count);
3637 for (i = 0; i < n; i++)
3638 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3641 vam->retval = retval;
3642 vam->result_ready = 1;
3646 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3647 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3649 vat_main_t *vam = &vat_main;
3650 vat_json_node_t root;
3652 int retval = clib_net_to_host_u32 (mp->retval);
3657 n = clib_net_to_host_u32 (mp->count);
3658 vat_json_init_array (&root);
3660 for (i = 0; i < n; i++)
3661 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3663 vat_json_print (vam->ofp, &root);
3664 vat_json_free (&root);
3667 vam->retval = retval;
3668 vam->result_ready = 1;
3672 vl_api_one_ndp_entries_get_reply_t_handler
3673 (vl_api_one_ndp_entries_get_reply_t * mp)
3675 vat_main_t *vam = &vat_main;
3677 int retval = clib_net_to_host_u32 (mp->retval);
3682 n = clib_net_to_host_u32 (mp->count);
3684 for (i = 0; i < n; i++)
3685 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3686 format_ethernet_address, mp->entries[i].mac);
3689 vam->retval = retval;
3690 vam->result_ready = 1;
3694 vl_api_one_ndp_entries_get_reply_t_handler_json
3695 (vl_api_one_ndp_entries_get_reply_t * mp)
3698 vat_main_t *vam = &vat_main;
3699 vat_json_node_t *e = 0, root;
3701 int retval = clib_net_to_host_u32 (mp->retval);
3702 vl_api_one_ndp_entry_t *arp_entry;
3707 n = clib_net_to_host_u32 (mp->count);
3708 vat_json_init_array (&root);
3710 for (i = 0; i < n; i++)
3712 e = vat_json_array_add (&root);
3713 arp_entry = &mp->entries[i];
3715 vat_json_init_object (e);
3716 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3719 vat_json_object_add_string_copy (e, "mac", s);
3722 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3724 vat_json_object_add_string_copy (e, "ip6", s);
3728 vat_json_print (vam->ofp, &root);
3729 vat_json_free (&root);
3732 vam->retval = retval;
3733 vam->result_ready = 1;
3737 vl_api_one_l2_arp_entries_get_reply_t_handler
3738 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3740 vat_main_t *vam = &vat_main;
3742 int retval = clib_net_to_host_u32 (mp->retval);
3747 n = clib_net_to_host_u32 (mp->count);
3749 for (i = 0; i < n; i++)
3750 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3751 format_ethernet_address, mp->entries[i].mac);
3754 vam->retval = retval;
3755 vam->result_ready = 1;
3759 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3760 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3763 vat_main_t *vam = &vat_main;
3764 vat_json_node_t *e = 0, root;
3766 int retval = clib_net_to_host_u32 (mp->retval);
3767 vl_api_one_l2_arp_entry_t *arp_entry;
3772 n = clib_net_to_host_u32 (mp->count);
3773 vat_json_init_array (&root);
3775 for (i = 0; i < n; i++)
3777 e = vat_json_array_add (&root);
3778 arp_entry = &mp->entries[i];
3780 vat_json_init_object (e);
3781 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3784 vat_json_object_add_string_copy (e, "mac", s);
3787 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3789 vat_json_object_add_string_copy (e, "ip4", s);
3793 vat_json_print (vam->ofp, &root);
3794 vat_json_free (&root);
3797 vam->retval = retval;
3798 vam->result_ready = 1;
3802 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3804 vat_main_t *vam = &vat_main;
3806 int retval = clib_net_to_host_u32 (mp->retval);
3811 n = clib_net_to_host_u32 (mp->count);
3813 for (i = 0; i < n; i++)
3815 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3819 vam->retval = retval;
3820 vam->result_ready = 1;
3824 vl_api_one_ndp_bd_get_reply_t_handler_json
3825 (vl_api_one_ndp_bd_get_reply_t * mp)
3827 vat_main_t *vam = &vat_main;
3828 vat_json_node_t root;
3830 int retval = clib_net_to_host_u32 (mp->retval);
3835 n = clib_net_to_host_u32 (mp->count);
3836 vat_json_init_array (&root);
3838 for (i = 0; i < n; i++)
3840 vat_json_array_add_uint (&root,
3841 clib_net_to_host_u32 (mp->bridge_domains[i]));
3844 vat_json_print (vam->ofp, &root);
3845 vat_json_free (&root);
3848 vam->retval = retval;
3849 vam->result_ready = 1;
3853 vl_api_one_l2_arp_bd_get_reply_t_handler
3854 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3856 vat_main_t *vam = &vat_main;
3858 int retval = clib_net_to_host_u32 (mp->retval);
3863 n = clib_net_to_host_u32 (mp->count);
3865 for (i = 0; i < n; i++)
3867 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3871 vam->retval = retval;
3872 vam->result_ready = 1;
3876 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3877 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3879 vat_main_t *vam = &vat_main;
3880 vat_json_node_t root;
3882 int retval = clib_net_to_host_u32 (mp->retval);
3887 n = clib_net_to_host_u32 (mp->count);
3888 vat_json_init_array (&root);
3890 for (i = 0; i < n; i++)
3892 vat_json_array_add_uint (&root,
3893 clib_net_to_host_u32 (mp->bridge_domains[i]));
3896 vat_json_print (vam->ofp, &root);
3897 vat_json_free (&root);
3900 vam->retval = retval;
3901 vam->result_ready = 1;
3905 vl_api_one_adjacencies_get_reply_t_handler
3906 (vl_api_one_adjacencies_get_reply_t * mp)
3908 vat_main_t *vam = &vat_main;
3910 int retval = clib_net_to_host_u32 (mp->retval);
3911 vl_api_one_adjacency_t *a;
3916 n = clib_net_to_host_u32 (mp->count);
3918 for (i = 0; i < n; i++)
3920 a = &mp->adjacencies[i];
3921 print (vam->ofp, "%U %40U",
3922 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3923 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3927 vam->retval = retval;
3928 vam->result_ready = 1;
3932 vl_api_one_adjacencies_get_reply_t_handler_json
3933 (vl_api_one_adjacencies_get_reply_t * mp)
3936 vat_main_t *vam = &vat_main;
3937 vat_json_node_t *e = 0, root;
3939 int retval = clib_net_to_host_u32 (mp->retval);
3940 vl_api_one_adjacency_t *a;
3945 n = clib_net_to_host_u32 (mp->count);
3946 vat_json_init_array (&root);
3948 for (i = 0; i < n; i++)
3950 e = vat_json_array_add (&root);
3951 a = &mp->adjacencies[i];
3953 vat_json_init_object (e);
3954 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3955 a->leid_prefix_len);
3957 vat_json_object_add_string_copy (e, "leid", s);
3960 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3961 a->reid_prefix_len);
3963 vat_json_object_add_string_copy (e, "reid", s);
3967 vat_json_print (vam->ofp, &root);
3968 vat_json_free (&root);
3971 vam->retval = retval;
3972 vam->result_ready = 1;
3976 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3978 vat_main_t *vam = &vat_main;
3980 print (vam->ofp, "%=20U",
3981 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3986 vl_api_one_map_server_details_t_handler_json
3987 (vl_api_one_map_server_details_t * mp)
3989 vat_main_t *vam = &vat_main;
3990 vat_json_node_t *node = NULL;
3991 struct in6_addr ip6;
3994 if (VAT_JSON_ARRAY != vam->json_tree.type)
3996 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3997 vat_json_init_array (&vam->json_tree);
3999 node = vat_json_array_add (&vam->json_tree);
4001 vat_json_init_object (node);
4004 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4005 vat_json_object_add_ip6 (node, "map-server", ip6);
4009 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4010 vat_json_object_add_ip4 (node, "map-server", ip4);
4015 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4018 vat_main_t *vam = &vat_main;
4020 print (vam->ofp, "%=20U",
4021 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4026 vl_api_one_map_resolver_details_t_handler_json
4027 (vl_api_one_map_resolver_details_t * mp)
4029 vat_main_t *vam = &vat_main;
4030 vat_json_node_t *node = NULL;
4031 struct in6_addr ip6;
4034 if (VAT_JSON_ARRAY != vam->json_tree.type)
4036 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4037 vat_json_init_array (&vam->json_tree);
4039 node = vat_json_array_add (&vam->json_tree);
4041 vat_json_init_object (node);
4044 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4045 vat_json_object_add_ip6 (node, "map resolver", ip6);
4049 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4050 vat_json_object_add_ip4 (node, "map resolver", ip4);
4055 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4057 vat_main_t *vam = &vat_main;
4058 i32 retval = ntohl (mp->retval);
4062 print (vam->ofp, "feature: %s\ngpe: %s",
4063 mp->feature_status ? "enabled" : "disabled",
4064 mp->gpe_status ? "enabled" : "disabled");
4067 vam->retval = retval;
4068 vam->result_ready = 1;
4072 vl_api_show_one_status_reply_t_handler_json
4073 (vl_api_show_one_status_reply_t * mp)
4075 vat_main_t *vam = &vat_main;
4076 vat_json_node_t node;
4077 u8 *gpe_status = NULL;
4078 u8 *feature_status = NULL;
4080 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4081 feature_status = format (0, "%s",
4082 mp->feature_status ? "enabled" : "disabled");
4083 vec_add1 (gpe_status, 0);
4084 vec_add1 (feature_status, 0);
4086 vat_json_init_object (&node);
4087 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4088 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4090 vec_free (gpe_status);
4091 vec_free (feature_status);
4093 vat_json_print (vam->ofp, &node);
4094 vat_json_free (&node);
4096 vam->retval = ntohl (mp->retval);
4097 vam->result_ready = 1;
4101 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4102 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4104 vat_main_t *vam = &vat_main;
4105 i32 retval = ntohl (mp->retval);
4109 print (vam->ofp, "%=20s", mp->locator_set_name);
4112 vam->retval = retval;
4113 vam->result_ready = 1;
4117 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4118 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4120 vat_main_t *vam = &vat_main;
4121 vat_json_node_t *node = NULL;
4123 if (VAT_JSON_ARRAY != vam->json_tree.type)
4125 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4126 vat_json_init_array (&vam->json_tree);
4128 node = vat_json_array_add (&vam->json_tree);
4130 vat_json_init_object (node);
4131 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4133 vat_json_print (vam->ofp, node);
4134 vat_json_free (node);
4136 vam->retval = ntohl (mp->retval);
4137 vam->result_ready = 1;
4141 format_lisp_map_request_mode (u8 * s, va_list * args)
4143 u32 mode = va_arg (*args, u32);
4148 return format (0, "dst-only");
4150 return format (0, "src-dst");
4156 vl_api_show_one_map_request_mode_reply_t_handler
4157 (vl_api_show_one_map_request_mode_reply_t * mp)
4159 vat_main_t *vam = &vat_main;
4160 i32 retval = ntohl (mp->retval);
4164 u32 mode = mp->mode;
4165 print (vam->ofp, "map_request_mode: %U",
4166 format_lisp_map_request_mode, mode);
4169 vam->retval = retval;
4170 vam->result_ready = 1;
4174 vl_api_show_one_map_request_mode_reply_t_handler_json
4175 (vl_api_show_one_map_request_mode_reply_t * mp)
4177 vat_main_t *vam = &vat_main;
4178 vat_json_node_t node;
4183 s = format (0, "%U", format_lisp_map_request_mode, mode);
4186 vat_json_init_object (&node);
4187 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4188 vat_json_print (vam->ofp, &node);
4189 vat_json_free (&node);
4192 vam->retval = ntohl (mp->retval);
4193 vam->result_ready = 1;
4197 vl_api_one_show_xtr_mode_reply_t_handler
4198 (vl_api_one_show_xtr_mode_reply_t * mp)
4200 vat_main_t *vam = &vat_main;
4201 i32 retval = ntohl (mp->retval);
4205 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4208 vam->retval = retval;
4209 vam->result_ready = 1;
4213 vl_api_one_show_xtr_mode_reply_t_handler_json
4214 (vl_api_one_show_xtr_mode_reply_t * mp)
4216 vat_main_t *vam = &vat_main;
4217 vat_json_node_t node;
4220 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4221 vec_add1 (status, 0);
4223 vat_json_init_object (&node);
4224 vat_json_object_add_string_copy (&node, "status", status);
4228 vat_json_print (vam->ofp, &node);
4229 vat_json_free (&node);
4231 vam->retval = ntohl (mp->retval);
4232 vam->result_ready = 1;
4236 vl_api_one_show_pitr_mode_reply_t_handler
4237 (vl_api_one_show_pitr_mode_reply_t * mp)
4239 vat_main_t *vam = &vat_main;
4240 i32 retval = ntohl (mp->retval);
4244 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4247 vam->retval = retval;
4248 vam->result_ready = 1;
4252 vl_api_one_show_pitr_mode_reply_t_handler_json
4253 (vl_api_one_show_pitr_mode_reply_t * mp)
4255 vat_main_t *vam = &vat_main;
4256 vat_json_node_t node;
4259 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4260 vec_add1 (status, 0);
4262 vat_json_init_object (&node);
4263 vat_json_object_add_string_copy (&node, "status", status);
4267 vat_json_print (vam->ofp, &node);
4268 vat_json_free (&node);
4270 vam->retval = ntohl (mp->retval);
4271 vam->result_ready = 1;
4275 vl_api_one_show_petr_mode_reply_t_handler
4276 (vl_api_one_show_petr_mode_reply_t * mp)
4278 vat_main_t *vam = &vat_main;
4279 i32 retval = ntohl (mp->retval);
4283 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4286 vam->retval = retval;
4287 vam->result_ready = 1;
4291 vl_api_one_show_petr_mode_reply_t_handler_json
4292 (vl_api_one_show_petr_mode_reply_t * mp)
4294 vat_main_t *vam = &vat_main;
4295 vat_json_node_t node;
4298 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4299 vec_add1 (status, 0);
4301 vat_json_init_object (&node);
4302 vat_json_object_add_string_copy (&node, "status", status);
4306 vat_json_print (vam->ofp, &node);
4307 vat_json_free (&node);
4309 vam->retval = ntohl (mp->retval);
4310 vam->result_ready = 1;
4314 vl_api_show_one_use_petr_reply_t_handler
4315 (vl_api_show_one_use_petr_reply_t * mp)
4317 vat_main_t *vam = &vat_main;
4318 i32 retval = ntohl (mp->retval);
4322 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4325 print (vam->ofp, "Proxy-ETR address; %U",
4326 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4331 vam->retval = retval;
4332 vam->result_ready = 1;
4336 vl_api_show_one_use_petr_reply_t_handler_json
4337 (vl_api_show_one_use_petr_reply_t * mp)
4339 vat_main_t *vam = &vat_main;
4340 vat_json_node_t node;
4343 struct in6_addr ip6;
4345 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4346 vec_add1 (status, 0);
4348 vat_json_init_object (&node);
4349 vat_json_object_add_string_copy (&node, "status", status);
4354 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4355 vat_json_object_add_ip6 (&node, "address", ip6);
4359 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4360 vat_json_object_add_ip4 (&node, "address", ip4);
4366 vat_json_print (vam->ofp, &node);
4367 vat_json_free (&node);
4369 vam->retval = ntohl (mp->retval);
4370 vam->result_ready = 1;
4374 vl_api_show_one_nsh_mapping_reply_t_handler
4375 (vl_api_show_one_nsh_mapping_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 i32 retval = ntohl (mp->retval);
4382 print (vam->ofp, "%-20s%-16s",
4383 mp->is_set ? "set" : "not-set",
4384 mp->is_set ? (char *) mp->locator_set_name : "");
4387 vam->retval = retval;
4388 vam->result_ready = 1;
4392 vl_api_show_one_nsh_mapping_reply_t_handler_json
4393 (vl_api_show_one_nsh_mapping_reply_t * mp)
4395 vat_main_t *vam = &vat_main;
4396 vat_json_node_t node;
4399 status = format (0, "%s", mp->is_set ? "yes" : "no");
4400 vec_add1 (status, 0);
4402 vat_json_init_object (&node);
4403 vat_json_object_add_string_copy (&node, "is_set", status);
4406 vat_json_object_add_string_copy (&node, "locator_set",
4407 mp->locator_set_name);
4412 vat_json_print (vam->ofp, &node);
4413 vat_json_free (&node);
4415 vam->retval = ntohl (mp->retval);
4416 vam->result_ready = 1;
4420 vl_api_show_one_map_register_ttl_reply_t_handler
4421 (vl_api_show_one_map_register_ttl_reply_t * mp)
4423 vat_main_t *vam = &vat_main;
4424 i32 retval = ntohl (mp->retval);
4426 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4430 print (vam->ofp, "ttl: %u", mp->ttl);
4433 vam->retval = retval;
4434 vam->result_ready = 1;
4438 vl_api_show_one_map_register_ttl_reply_t_handler_json
4439 (vl_api_show_one_map_register_ttl_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 vat_json_node_t node;
4444 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4445 vat_json_init_object (&node);
4446 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4448 vat_json_print (vam->ofp, &node);
4449 vat_json_free (&node);
4451 vam->retval = ntohl (mp->retval);
4452 vam->result_ready = 1;
4456 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4458 vat_main_t *vam = &vat_main;
4459 i32 retval = ntohl (mp->retval);
4463 print (vam->ofp, "%-20s%-16s",
4464 mp->status ? "enabled" : "disabled",
4465 mp->status ? (char *) mp->locator_set_name : "");
4468 vam->retval = retval;
4469 vam->result_ready = 1;
4473 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4475 vat_main_t *vam = &vat_main;
4476 vat_json_node_t node;
4479 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4480 vec_add1 (status, 0);
4482 vat_json_init_object (&node);
4483 vat_json_object_add_string_copy (&node, "status", status);
4486 vat_json_object_add_string_copy (&node, "locator_set",
4487 mp->locator_set_name);
4492 vat_json_print (vam->ofp, &node);
4493 vat_json_free (&node);
4495 vam->retval = ntohl (mp->retval);
4496 vam->result_ready = 1;
4500 format_policer_type (u8 * s, va_list * va)
4502 u32 i = va_arg (*va, u32);
4504 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4505 s = format (s, "1r2c");
4506 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4507 s = format (s, "1r3c");
4508 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4509 s = format (s, "2r3c-2698");
4510 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4511 s = format (s, "2r3c-4115");
4512 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4513 s = format (s, "2r3c-mef5cf1");
4515 s = format (s, "ILLEGAL");
4520 format_policer_rate_type (u8 * s, va_list * va)
4522 u32 i = va_arg (*va, u32);
4524 if (i == SSE2_QOS_RATE_KBPS)
4525 s = format (s, "kbps");
4526 else if (i == SSE2_QOS_RATE_PPS)
4527 s = format (s, "pps");
4529 s = format (s, "ILLEGAL");
4534 format_policer_round_type (u8 * s, va_list * va)
4536 u32 i = va_arg (*va, u32);
4538 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4539 s = format (s, "closest");
4540 else if (i == SSE2_QOS_ROUND_TO_UP)
4541 s = format (s, "up");
4542 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4543 s = format (s, "down");
4545 s = format (s, "ILLEGAL");
4550 format_policer_action_type (u8 * s, va_list * va)
4552 u32 i = va_arg (*va, u32);
4554 if (i == SSE2_QOS_ACTION_DROP)
4555 s = format (s, "drop");
4556 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4557 s = format (s, "transmit");
4558 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4559 s = format (s, "mark-and-transmit");
4561 s = format (s, "ILLEGAL");
4566 format_dscp (u8 * s, va_list * va)
4568 u32 i = va_arg (*va, u32);
4573 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4577 return format (s, "ILLEGAL");
4579 s = format (s, "%s", t);
4584 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4586 vat_main_t *vam = &vat_main;
4587 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4589 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4590 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4592 conform_dscp_str = format (0, "");
4594 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4595 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4597 exceed_dscp_str = format (0, "");
4599 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4600 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4602 violate_dscp_str = format (0, "");
4604 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4605 "rate type %U, round type %U, %s rate, %s color-aware, "
4606 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4607 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4608 "conform action %U%s, exceed action %U%s, violate action %U%s",
4610 format_policer_type, mp->type,
4613 clib_net_to_host_u64 (mp->cb),
4614 clib_net_to_host_u64 (mp->eb),
4615 format_policer_rate_type, mp->rate_type,
4616 format_policer_round_type, mp->round_type,
4617 mp->single_rate ? "single" : "dual",
4618 mp->color_aware ? "is" : "not",
4619 ntohl (mp->cir_tokens_per_period),
4620 ntohl (mp->pir_tokens_per_period),
4622 ntohl (mp->current_limit),
4623 ntohl (mp->current_bucket),
4624 ntohl (mp->extended_limit),
4625 ntohl (mp->extended_bucket),
4626 clib_net_to_host_u64 (mp->last_update_time),
4627 format_policer_action_type, mp->conform_action_type,
4629 format_policer_action_type, mp->exceed_action_type,
4631 format_policer_action_type, mp->violate_action_type,
4634 vec_free (conform_dscp_str);
4635 vec_free (exceed_dscp_str);
4636 vec_free (violate_dscp_str);
4639 static void vl_api_policer_details_t_handler_json
4640 (vl_api_policer_details_t * mp)
4642 vat_main_t *vam = &vat_main;
4643 vat_json_node_t *node;
4644 u8 *rate_type_str, *round_type_str, *type_str;
4645 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4647 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4649 format (0, "%U", format_policer_round_type, mp->round_type);
4650 type_str = format (0, "%U", format_policer_type, mp->type);
4651 conform_action_str = format (0, "%U", format_policer_action_type,
4652 mp->conform_action_type);
4653 exceed_action_str = format (0, "%U", format_policer_action_type,
4654 mp->exceed_action_type);
4655 violate_action_str = format (0, "%U", format_policer_action_type,
4656 mp->violate_action_type);
4658 if (VAT_JSON_ARRAY != vam->json_tree.type)
4660 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4661 vat_json_init_array (&vam->json_tree);
4663 node = vat_json_array_add (&vam->json_tree);
4665 vat_json_init_object (node);
4666 vat_json_object_add_string_copy (node, "name", mp->name);
4667 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4668 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4669 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4670 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4671 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4672 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4673 vat_json_object_add_string_copy (node, "type", type_str);
4674 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4675 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4676 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4677 vat_json_object_add_uint (node, "cir_tokens_per_period",
4678 ntohl (mp->cir_tokens_per_period));
4679 vat_json_object_add_uint (node, "eir_tokens_per_period",
4680 ntohl (mp->pir_tokens_per_period));
4681 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4682 vat_json_object_add_uint (node, "current_bucket",
4683 ntohl (mp->current_bucket));
4684 vat_json_object_add_uint (node, "extended_limit",
4685 ntohl (mp->extended_limit));
4686 vat_json_object_add_uint (node, "extended_bucket",
4687 ntohl (mp->extended_bucket));
4688 vat_json_object_add_uint (node, "last_update_time",
4689 ntohl (mp->last_update_time));
4690 vat_json_object_add_string_copy (node, "conform_action",
4691 conform_action_str);
4692 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4694 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4695 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4696 vec_free (dscp_str);
4698 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4699 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4701 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4702 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4703 vec_free (dscp_str);
4705 vat_json_object_add_string_copy (node, "violate_action",
4706 violate_action_str);
4707 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4709 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4710 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4711 vec_free (dscp_str);
4714 vec_free (rate_type_str);
4715 vec_free (round_type_str);
4716 vec_free (type_str);
4717 vec_free (conform_action_str);
4718 vec_free (exceed_action_str);
4719 vec_free (violate_action_str);
4723 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4726 vat_main_t *vam = &vat_main;
4727 int i, count = ntohl (mp->count);
4730 print (vam->ofp, "classify table ids (%d) : ", count);
4731 for (i = 0; i < count; i++)
4733 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4734 print (vam->ofp, (i < count - 1) ? "," : "");
4736 vam->retval = ntohl (mp->retval);
4737 vam->result_ready = 1;
4741 vl_api_classify_table_ids_reply_t_handler_json
4742 (vl_api_classify_table_ids_reply_t * mp)
4744 vat_main_t *vam = &vat_main;
4745 int i, count = ntohl (mp->count);
4749 vat_json_node_t node;
4751 vat_json_init_object (&node);
4752 for (i = 0; i < count; i++)
4754 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4756 vat_json_print (vam->ofp, &node);
4757 vat_json_free (&node);
4759 vam->retval = ntohl (mp->retval);
4760 vam->result_ready = 1;
4764 vl_api_classify_table_by_interface_reply_t_handler
4765 (vl_api_classify_table_by_interface_reply_t * mp)
4767 vat_main_t *vam = &vat_main;
4770 table_id = ntohl (mp->l2_table_id);
4772 print (vam->ofp, "l2 table id : %d", table_id);
4774 print (vam->ofp, "l2 table id : No input ACL tables configured");
4775 table_id = ntohl (mp->ip4_table_id);
4777 print (vam->ofp, "ip4 table id : %d", table_id);
4779 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4780 table_id = ntohl (mp->ip6_table_id);
4782 print (vam->ofp, "ip6 table id : %d", table_id);
4784 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4785 vam->retval = ntohl (mp->retval);
4786 vam->result_ready = 1;
4790 vl_api_classify_table_by_interface_reply_t_handler_json
4791 (vl_api_classify_table_by_interface_reply_t * mp)
4793 vat_main_t *vam = &vat_main;
4794 vat_json_node_t node;
4796 vat_json_init_object (&node);
4798 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4799 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4800 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4802 vat_json_print (vam->ofp, &node);
4803 vat_json_free (&node);
4805 vam->retval = ntohl (mp->retval);
4806 vam->result_ready = 1;
4809 static void vl_api_policer_add_del_reply_t_handler
4810 (vl_api_policer_add_del_reply_t * mp)
4812 vat_main_t *vam = &vat_main;
4813 i32 retval = ntohl (mp->retval);
4814 if (vam->async_mode)
4816 vam->async_errors += (retval < 0);
4820 vam->retval = retval;
4821 vam->result_ready = 1;
4822 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4824 * Note: this is just barely thread-safe, depends on
4825 * the main thread spinning waiting for an answer...
4827 errmsg ("policer index %d", ntohl (mp->policer_index));
4831 static void vl_api_policer_add_del_reply_t_handler_json
4832 (vl_api_policer_add_del_reply_t * mp)
4834 vat_main_t *vam = &vat_main;
4835 vat_json_node_t node;
4837 vat_json_init_object (&node);
4838 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4839 vat_json_object_add_uint (&node, "policer_index",
4840 ntohl (mp->policer_index));
4842 vat_json_print (vam->ofp, &node);
4843 vat_json_free (&node);
4845 vam->retval = ntohl (mp->retval);
4846 vam->result_ready = 1;
4849 /* Format hex dump. */
4851 format_hex_bytes (u8 * s, va_list * va)
4853 u8 *bytes = va_arg (*va, u8 *);
4854 int n_bytes = va_arg (*va, int);
4857 /* Print short or long form depending on byte count. */
4858 uword short_form = n_bytes <= 32;
4859 u32 indent = format_get_indent (s);
4864 for (i = 0; i < n_bytes; i++)
4866 if (!short_form && (i % 32) == 0)
4867 s = format (s, "%08x: ", i);
4868 s = format (s, "%02x", bytes[i]);
4869 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4870 s = format (s, "\n%U", format_white_space, indent);
4877 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4880 vat_main_t *vam = &vat_main;
4881 i32 retval = ntohl (mp->retval);
4884 print (vam->ofp, "classify table info :");
4885 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4886 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4887 ntohl (mp->miss_next_index));
4888 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4889 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4890 ntohl (mp->match_n_vectors));
4891 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4892 ntohl (mp->mask_length));
4894 vam->retval = retval;
4895 vam->result_ready = 1;
4899 vl_api_classify_table_info_reply_t_handler_json
4900 (vl_api_classify_table_info_reply_t * mp)
4902 vat_main_t *vam = &vat_main;
4903 vat_json_node_t node;
4905 i32 retval = ntohl (mp->retval);
4908 vat_json_init_object (&node);
4910 vat_json_object_add_int (&node, "sessions",
4911 ntohl (mp->active_sessions));
4912 vat_json_object_add_int (&node, "nexttbl",
4913 ntohl (mp->next_table_index));
4914 vat_json_object_add_int (&node, "nextnode",
4915 ntohl (mp->miss_next_index));
4916 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4917 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4918 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4919 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4920 ntohl (mp->mask_length), 0);
4921 vat_json_object_add_string_copy (&node, "mask", s);
4923 vat_json_print (vam->ofp, &node);
4924 vat_json_free (&node);
4926 vam->retval = ntohl (mp->retval);
4927 vam->result_ready = 1;
4931 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4934 vat_main_t *vam = &vat_main;
4936 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4937 ntohl (mp->hit_next_index), ntohl (mp->advance),
4938 ntohl (mp->opaque_index));
4939 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4940 ntohl (mp->match_length));
4944 vl_api_classify_session_details_t_handler_json
4945 (vl_api_classify_session_details_t * mp)
4947 vat_main_t *vam = &vat_main;
4948 vat_json_node_t *node = NULL;
4950 if (VAT_JSON_ARRAY != vam->json_tree.type)
4952 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4953 vat_json_init_array (&vam->json_tree);
4955 node = vat_json_array_add (&vam->json_tree);
4957 vat_json_init_object (node);
4958 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4959 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4960 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4962 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4964 vat_json_object_add_string_copy (node, "match", s);
4967 static void vl_api_pg_create_interface_reply_t_handler
4968 (vl_api_pg_create_interface_reply_t * mp)
4970 vat_main_t *vam = &vat_main;
4972 vam->retval = ntohl (mp->retval);
4973 vam->result_ready = 1;
4976 static void vl_api_pg_create_interface_reply_t_handler_json
4977 (vl_api_pg_create_interface_reply_t * mp)
4979 vat_main_t *vam = &vat_main;
4980 vat_json_node_t node;
4982 i32 retval = ntohl (mp->retval);
4985 vat_json_init_object (&node);
4987 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4989 vat_json_print (vam->ofp, &node);
4990 vat_json_free (&node);
4992 vam->retval = ntohl (mp->retval);
4993 vam->result_ready = 1;
4996 static void vl_api_policer_classify_details_t_handler
4997 (vl_api_policer_classify_details_t * mp)
4999 vat_main_t *vam = &vat_main;
5001 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5002 ntohl (mp->table_index));
5005 static void vl_api_policer_classify_details_t_handler_json
5006 (vl_api_policer_classify_details_t * mp)
5008 vat_main_t *vam = &vat_main;
5009 vat_json_node_t *node;
5011 if (VAT_JSON_ARRAY != vam->json_tree.type)
5013 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5014 vat_json_init_array (&vam->json_tree);
5016 node = vat_json_array_add (&vam->json_tree);
5018 vat_json_init_object (node);
5019 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5020 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5023 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
5024 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5026 vat_main_t *vam = &vat_main;
5027 i32 retval = ntohl (mp->retval);
5028 if (vam->async_mode)
5030 vam->async_errors += (retval < 0);
5034 vam->retval = retval;
5035 vam->sw_if_index = ntohl (mp->sw_if_index);
5036 vam->result_ready = 1;
5038 vam->regenerate_interface_table = 1;
5041 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
5042 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
5044 vat_main_t *vam = &vat_main;
5045 vat_json_node_t node;
5047 vat_json_init_object (&node);
5048 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5049 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5051 vat_json_print (vam->ofp, &node);
5052 vat_json_free (&node);
5054 vam->retval = ntohl (mp->retval);
5055 vam->result_ready = 1;
5058 static void vl_api_flow_classify_details_t_handler
5059 (vl_api_flow_classify_details_t * mp)
5061 vat_main_t *vam = &vat_main;
5063 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5064 ntohl (mp->table_index));
5067 static void vl_api_flow_classify_details_t_handler_json
5068 (vl_api_flow_classify_details_t * mp)
5070 vat_main_t *vam = &vat_main;
5071 vat_json_node_t *node;
5073 if (VAT_JSON_ARRAY != vam->json_tree.type)
5075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5076 vat_json_init_array (&vam->json_tree);
5078 node = vat_json_array_add (&vam->json_tree);
5080 vat_json_init_object (node);
5081 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5082 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5085 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5086 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5087 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5088 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5089 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5090 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5091 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5092 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5093 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5094 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5097 * Generate boilerplate reply handlers, which
5098 * dig the return value out of the xxx_reply_t API message,
5099 * stick it into vam->retval, and set vam->result_ready
5101 * Could also do this by pointing N message decode slots at
5102 * a single function, but that could break in subtle ways.
5105 #define foreach_standard_reply_retval_handler \
5106 _(sw_interface_set_flags_reply) \
5107 _(sw_interface_add_del_address_reply) \
5108 _(sw_interface_set_rx_mode_reply) \
5109 _(sw_interface_set_rx_placement_reply) \
5110 _(sw_interface_set_table_reply) \
5111 _(sw_interface_set_mpls_enable_reply) \
5112 _(sw_interface_set_vpath_reply) \
5113 _(sw_interface_set_vxlan_bypass_reply) \
5114 _(sw_interface_set_geneve_bypass_reply) \
5115 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5116 _(sw_interface_set_l2_bridge_reply) \
5117 _(bridge_domain_add_del_reply) \
5118 _(sw_interface_set_l2_xconnect_reply) \
5119 _(l2fib_add_del_reply) \
5120 _(l2fib_flush_int_reply) \
5121 _(l2fib_flush_bd_reply) \
5122 _(ip_add_del_route_reply) \
5123 _(ip_table_add_del_reply) \
5124 _(ip_mroute_add_del_reply) \
5125 _(mpls_route_add_del_reply) \
5126 _(mpls_table_add_del_reply) \
5127 _(mpls_ip_bind_unbind_reply) \
5128 _(bier_route_add_del_reply) \
5129 _(bier_table_add_del_reply) \
5130 _(proxy_arp_add_del_reply) \
5131 _(proxy_arp_intfc_enable_disable_reply) \
5132 _(sw_interface_set_unnumbered_reply) \
5133 _(ip_neighbor_add_del_reply) \
5134 _(oam_add_del_reply) \
5135 _(reset_fib_reply) \
5136 _(dhcp_proxy_config_reply) \
5137 _(dhcp_proxy_set_vss_reply) \
5138 _(dhcp_client_config_reply) \
5139 _(set_ip_flow_hash_reply) \
5140 _(sw_interface_ip6_enable_disable_reply) \
5141 _(ip6nd_proxy_add_del_reply) \
5142 _(sw_interface_ip6nd_ra_prefix_reply) \
5143 _(sw_interface_ip6nd_ra_config_reply) \
5144 _(set_arp_neighbor_limit_reply) \
5145 _(l2_patch_add_del_reply) \
5146 _(sr_mpls_policy_add_reply) \
5147 _(sr_mpls_policy_mod_reply) \
5148 _(sr_mpls_policy_del_reply) \
5149 _(sr_policy_add_reply) \
5150 _(sr_policy_mod_reply) \
5151 _(sr_policy_del_reply) \
5152 _(sr_localsid_add_del_reply) \
5153 _(sr_steering_add_del_reply) \
5154 _(classify_add_del_session_reply) \
5155 _(classify_set_interface_ip_table_reply) \
5156 _(classify_set_interface_l2_tables_reply) \
5157 _(l2tpv3_set_tunnel_cookies_reply) \
5158 _(l2tpv3_interface_enable_disable_reply) \
5159 _(l2tpv3_set_lookup_key_reply) \
5160 _(l2_fib_clear_table_reply) \
5161 _(l2_interface_efp_filter_reply) \
5162 _(l2_interface_vlan_tag_rewrite_reply) \
5163 _(modify_vhost_user_if_reply) \
5164 _(delete_vhost_user_if_reply) \
5165 _(ip_probe_neighbor_reply) \
5166 _(ip_scan_neighbor_enable_disable_reply) \
5167 _(want_ip4_arp_events_reply) \
5168 _(want_ip6_nd_events_reply) \
5169 _(want_l2_macs_events_reply) \
5170 _(input_acl_set_interface_reply) \
5171 _(ipsec_spd_add_del_reply) \
5172 _(ipsec_interface_add_del_spd_reply) \
5173 _(ipsec_spd_entry_add_del_reply) \
5174 _(ipsec_sad_entry_add_del_reply) \
5175 _(ipsec_sa_set_key_reply) \
5176 _(ipsec_tunnel_if_add_del_reply) \
5177 _(ipsec_tunnel_if_set_key_reply) \
5178 _(ipsec_tunnel_if_set_sa_reply) \
5179 _(delete_loopback_reply) \
5180 _(bd_ip_mac_add_del_reply) \
5181 _(bd_ip_mac_flush_reply) \
5182 _(want_interface_events_reply) \
5183 _(cop_interface_enable_disable_reply) \
5184 _(cop_whitelist_enable_disable_reply) \
5185 _(sw_interface_clear_stats_reply) \
5186 _(ioam_enable_reply) \
5187 _(ioam_disable_reply) \
5188 _(one_add_del_locator_reply) \
5189 _(one_add_del_local_eid_reply) \
5190 _(one_add_del_remote_mapping_reply) \
5191 _(one_add_del_adjacency_reply) \
5192 _(one_add_del_map_resolver_reply) \
5193 _(one_add_del_map_server_reply) \
5194 _(one_enable_disable_reply) \
5195 _(one_rloc_probe_enable_disable_reply) \
5196 _(one_map_register_enable_disable_reply) \
5197 _(one_map_register_set_ttl_reply) \
5198 _(one_set_transport_protocol_reply) \
5199 _(one_map_register_fallback_threshold_reply) \
5200 _(one_pitr_set_locator_set_reply) \
5201 _(one_map_request_mode_reply) \
5202 _(one_add_del_map_request_itr_rlocs_reply) \
5203 _(one_eid_table_add_del_map_reply) \
5204 _(one_use_petr_reply) \
5205 _(one_stats_enable_disable_reply) \
5206 _(one_add_del_l2_arp_entry_reply) \
5207 _(one_add_del_ndp_entry_reply) \
5208 _(one_stats_flush_reply) \
5209 _(one_enable_disable_xtr_mode_reply) \
5210 _(one_enable_disable_pitr_mode_reply) \
5211 _(one_enable_disable_petr_mode_reply) \
5212 _(gpe_enable_disable_reply) \
5213 _(gpe_set_encap_mode_reply) \
5214 _(gpe_add_del_iface_reply) \
5215 _(gpe_add_del_native_fwd_rpath_reply) \
5216 _(af_packet_delete_reply) \
5217 _(policer_classify_set_interface_reply) \
5218 _(netmap_create_reply) \
5219 _(netmap_delete_reply) \
5220 _(set_ipfix_exporter_reply) \
5221 _(set_ipfix_classify_stream_reply) \
5222 _(ipfix_classify_table_add_del_reply) \
5223 _(flow_classify_set_interface_reply) \
5224 _(sw_interface_span_enable_disable_reply) \
5225 _(pg_capture_reply) \
5226 _(pg_enable_disable_reply) \
5227 _(ip_source_and_port_range_check_add_del_reply) \
5228 _(ip_source_and_port_range_check_interface_add_del_reply)\
5229 _(delete_subif_reply) \
5230 _(l2_interface_pbb_tag_rewrite_reply) \
5232 _(feature_enable_disable_reply) \
5233 _(sw_interface_tag_add_del_reply) \
5234 _(hw_interface_set_mtu_reply) \
5235 _(p2p_ethernet_add_reply) \
5236 _(p2p_ethernet_del_reply) \
5237 _(lldp_config_reply) \
5238 _(sw_interface_set_lldp_reply) \
5239 _(tcp_configure_src_addresses_reply) \
5240 _(dns_enable_disable_reply) \
5241 _(dns_name_server_add_del_reply) \
5242 _(session_rule_add_del_reply) \
5243 _(ip_container_proxy_add_del_reply) \
5244 _(output_acl_set_interface_reply) \
5245 _(qos_record_enable_disable_reply)
5248 static void vl_api_##n##_t_handler \
5249 (vl_api_##n##_t * mp) \
5251 vat_main_t * vam = &vat_main; \
5252 i32 retval = ntohl(mp->retval); \
5253 if (vam->async_mode) { \
5254 vam->async_errors += (retval < 0); \
5256 vam->retval = retval; \
5257 vam->result_ready = 1; \
5260 foreach_standard_reply_retval_handler;
5264 static void vl_api_##n##_t_handler_json \
5265 (vl_api_##n##_t * mp) \
5267 vat_main_t * vam = &vat_main; \
5268 vat_json_node_t node; \
5269 vat_json_init_object(&node); \
5270 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5271 vat_json_print(vam->ofp, &node); \
5272 vam->retval = ntohl(mp->retval); \
5273 vam->result_ready = 1; \
5275 foreach_standard_reply_retval_handler;
5279 * Table of message reply handlers, must include boilerplate handlers
5283 #define foreach_vpe_api_reply_msg \
5284 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5285 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5286 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5287 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5288 _(CONTROL_PING_REPLY, control_ping_reply) \
5289 _(CLI_REPLY, cli_reply) \
5290 _(CLI_INBAND_REPLY, cli_inband_reply) \
5291 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5292 sw_interface_add_del_address_reply) \
5293 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5294 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5295 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5296 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5297 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5298 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5299 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5300 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5301 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5302 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5303 sw_interface_set_l2_xconnect_reply) \
5304 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5305 sw_interface_set_l2_bridge_reply) \
5306 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5307 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5308 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5309 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5310 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5311 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5312 _(L2_FLAGS_REPLY, l2_flags_reply) \
5313 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5314 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5315 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5316 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5317 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5318 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5319 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5320 _(BOND_CREATE_REPLY, bond_create_reply) \
5321 _(BOND_DELETE_REPLY, bond_delete_reply) \
5322 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5323 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5324 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5325 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5326 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5327 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5328 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5329 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5330 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5331 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5332 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5333 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5334 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5335 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5336 proxy_arp_intfc_enable_disable_reply) \
5337 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5338 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5339 sw_interface_set_unnumbered_reply) \
5340 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5341 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5342 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5343 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5344 _(RESET_FIB_REPLY, reset_fib_reply) \
5345 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5346 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5347 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5348 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5349 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5350 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5351 sw_interface_ip6_enable_disable_reply) \
5352 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5353 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5354 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5355 sw_interface_ip6nd_ra_prefix_reply) \
5356 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5357 sw_interface_ip6nd_ra_config_reply) \
5358 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5359 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5360 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5361 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5362 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5363 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5364 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5365 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5366 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5367 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5368 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5369 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5370 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5371 classify_set_interface_ip_table_reply) \
5372 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5373 classify_set_interface_l2_tables_reply) \
5374 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5375 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5376 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5377 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5378 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5379 l2tpv3_interface_enable_disable_reply) \
5380 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5381 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5382 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5383 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5384 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5385 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5386 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5387 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
5388 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5389 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5390 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5391 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5392 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5393 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5394 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5395 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5396 _(SHOW_VERSION_REPLY, show_version_reply) \
5397 _(SHOW_THREADS_REPLY, show_threads_reply) \
5398 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5399 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5400 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5401 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5402 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5403 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5404 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5405 _(IP4_ARP_EVENT, ip4_arp_event) \
5406 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5407 _(IP6_ND_EVENT, ip6_nd_event) \
5408 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5409 _(L2_MACS_EVENT, l2_macs_event) \
5410 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5411 _(IP_ADDRESS_DETAILS, ip_address_details) \
5412 _(IP_DETAILS, ip_details) \
5413 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5414 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5415 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5416 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5417 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5418 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5419 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5420 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5421 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5422 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5423 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5424 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5425 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5426 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5427 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5428 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5429 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5430 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5431 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5432 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5433 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5434 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5435 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5436 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5437 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5438 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5439 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5440 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5441 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5442 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5443 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5444 one_map_register_enable_disable_reply) \
5445 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5446 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5447 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5448 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5449 one_map_register_fallback_threshold_reply) \
5450 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5451 one_rloc_probe_enable_disable_reply) \
5452 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5453 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5454 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5455 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5456 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5457 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5458 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5459 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5460 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5461 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5462 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5463 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5464 _(ONE_STATS_DETAILS, one_stats_details) \
5465 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5466 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5467 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5468 show_one_stats_enable_disable_reply) \
5469 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5470 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5471 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5472 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5473 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5474 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5475 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5476 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5477 one_enable_disable_pitr_mode_reply) \
5478 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5479 one_enable_disable_petr_mode_reply) \
5480 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5481 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5482 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5483 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5484 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5485 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5486 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5487 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5488 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5489 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5490 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5491 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5492 gpe_add_del_native_fwd_rpath_reply) \
5493 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5494 gpe_fwd_entry_path_details) \
5495 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5496 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5497 one_add_del_map_request_itr_rlocs_reply) \
5498 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5499 one_get_map_request_itr_rlocs_reply) \
5500 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5501 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5502 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5503 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5504 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5505 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5506 show_one_map_register_state_reply) \
5507 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5508 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5509 show_one_map_register_fallback_threshold_reply) \
5510 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5511 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5512 _(AF_PACKET_DETAILS, af_packet_details) \
5513 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5514 _(POLICER_DETAILS, policer_details) \
5515 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5516 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5517 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5518 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5519 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5520 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5521 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5522 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5523 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5524 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5525 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5526 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5527 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5528 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5529 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5530 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5531 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5532 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5533 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5534 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5535 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5536 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5537 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5538 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5539 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5540 ip_source_and_port_range_check_add_del_reply) \
5541 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5542 ip_source_and_port_range_check_interface_add_del_reply) \
5543 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5544 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5545 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5546 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5547 _(SET_PUNT_REPLY, set_punt_reply) \
5548 _(IP_FIB_DETAILS, ip_fib_details) \
5549 _(IP6_FIB_DETAILS, ip6_fib_details) \
5550 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5551 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5552 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5553 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5554 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5555 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5556 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5557 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5558 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5559 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5560 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5561 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5562 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5563 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5564 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5565 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5566 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5567 _(SESSION_RULES_DETAILS, session_rules_details) \
5568 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5569 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5570 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5572 #define foreach_standalone_reply_msg \
5573 _(SW_INTERFACE_EVENT, sw_interface_event)
5581 #define STR_VTR_OP_CASE(op) \
5582 case L2_VTR_ ## op: \
5586 str_vtr_op (u32 vtr_op)
5590 STR_VTR_OP_CASE (DISABLED);
5591 STR_VTR_OP_CASE (PUSH_1);
5592 STR_VTR_OP_CASE (PUSH_2);
5593 STR_VTR_OP_CASE (POP_1);
5594 STR_VTR_OP_CASE (POP_2);
5595 STR_VTR_OP_CASE (TRANSLATE_1_1);
5596 STR_VTR_OP_CASE (TRANSLATE_1_2);
5597 STR_VTR_OP_CASE (TRANSLATE_2_1);
5598 STR_VTR_OP_CASE (TRANSLATE_2_2);
5605 dump_sub_interface_table (vat_main_t * vam)
5607 const sw_interface_subif_t *sub = NULL;
5609 if (vam->json_output)
5612 ("JSON output supported only for VPE API calls and dump_stats_table");
5617 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5618 "Interface", "sw_if_index",
5619 "sub id", "dot1ad", "tags", "outer id",
5620 "inner id", "exact", "default", "outer any", "inner any");
5622 vec_foreach (sub, vam->sw_if_subif_table)
5625 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5626 sub->interface_name,
5628 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5629 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5630 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5631 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5632 if (sub->vtr_op != L2_VTR_DISABLED)
5635 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5636 "tag1: %d tag2: %d ]",
5637 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5638 sub->vtr_tag1, sub->vtr_tag2);
5646 name_sort_cmp (void *a1, void *a2)
5648 name_sort_t *n1 = a1;
5649 name_sort_t *n2 = a2;
5651 return strcmp ((char *) n1->name, (char *) n2->name);
5655 dump_interface_table (vat_main_t * vam)
5658 name_sort_t *nses = 0, *ns;
5660 if (vam->json_output)
5663 ("JSON output supported only for VPE API calls and dump_stats_table");
5668 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5670 vec_add2 (nses, ns, 1);
5671 ns->name = (u8 *)(p->key);
5672 ns->value = (u32) p->value[0];
5676 vec_sort_with_function (nses, name_sort_cmp);
5678 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5679 vec_foreach (ns, nses)
5681 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5688 dump_ip_table (vat_main_t * vam, int is_ipv6)
5690 const ip_details_t *det = NULL;
5691 const ip_address_details_t *address = NULL;
5694 print (vam->ofp, "%-12s", "sw_if_index");
5696 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5703 print (vam->ofp, "%-12d", i);
5704 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5709 vec_foreach (address, det->addr)
5713 is_ipv6 ? format_ip6_address : format_ip4_address,
5714 address->ip, address->prefix_length);
5722 dump_ipv4_table (vat_main_t * vam)
5724 if (vam->json_output)
5727 ("JSON output supported only for VPE API calls and dump_stats_table");
5731 return dump_ip_table (vam, 0);
5735 dump_ipv6_table (vat_main_t * vam)
5737 if (vam->json_output)
5740 ("JSON output supported only for VPE API calls and dump_stats_table");
5744 return dump_ip_table (vam, 1);
5748 * Pass CLI buffers directly in the CLI_INBAND API message,
5749 * instead of an additional shared memory area.
5752 exec_inband (vat_main_t * vam)
5754 vl_api_cli_inband_t *mp;
5755 unformat_input_t *i = vam->input;
5758 if (vec_len (i->buffer) == 0)
5761 if (vam->exec_mode == 0 && unformat (i, "mode"))
5766 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5773 * In order for the CLI command to work, it
5774 * must be a vector ending in \n, not a C-string ending
5777 u32 len = vec_len (vam->input->buffer);
5778 M2 (CLI_INBAND, mp, len);
5779 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5783 /* json responses may or may not include a useful reply... */
5784 if (vec_len (vam->cmd_reply))
5785 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5790 exec (vat_main_t * vam)
5792 return exec_inband (vam);
5796 api_create_loopback (vat_main_t * vam)
5798 unformat_input_t *i = vam->input;
5799 vl_api_create_loopback_t *mp;
5800 vl_api_create_loopback_instance_t *mp_lbi;
5803 u8 is_specified = 0;
5804 u32 user_instance = 0;
5807 clib_memset (mac_address, 0, sizeof (mac_address));
5809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5811 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5813 if (unformat (i, "instance %d", &user_instance))
5821 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5822 mp_lbi->is_specified = is_specified;
5824 mp_lbi->user_instance = htonl (user_instance);
5826 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5831 /* Construct the API message */
5832 M (CREATE_LOOPBACK, mp);
5834 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5843 api_delete_loopback (vat_main_t * vam)
5845 unformat_input_t *i = vam->input;
5846 vl_api_delete_loopback_t *mp;
5847 u32 sw_if_index = ~0;
5850 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5852 if (unformat (i, "sw_if_index %d", &sw_if_index))
5858 if (sw_if_index == ~0)
5860 errmsg ("missing sw_if_index");
5864 /* Construct the API message */
5865 M (DELETE_LOOPBACK, mp);
5866 mp->sw_if_index = ntohl (sw_if_index);
5874 api_want_interface_events (vat_main_t * vam)
5876 unformat_input_t *i = vam->input;
5877 vl_api_want_interface_events_t *mp;
5881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5883 if (unformat (i, "enable"))
5885 else if (unformat (i, "disable"))
5893 errmsg ("missing enable|disable");
5897 M (WANT_INTERFACE_EVENTS, mp);
5898 mp->enable_disable = enable;
5900 vam->interface_event_display = enable;
5908 /* Note: non-static, called once to set up the initial intfc table */
5910 api_sw_interface_dump (vat_main_t * vam)
5912 vl_api_sw_interface_dump_t *mp;
5913 vl_api_control_ping_t *mp_ping;
5915 name_sort_t *nses = 0, *ns;
5916 sw_interface_subif_t *sub = NULL;
5919 /* Toss the old name table */
5921 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5923 vec_add2 (nses, ns, 1);
5924 ns->name = (u8 *)(p->key);
5925 ns->value = (u32) p->value[0];
5929 hash_free (vam->sw_if_index_by_interface_name);
5931 vec_foreach (ns, nses) vec_free (ns->name);
5935 vec_foreach (sub, vam->sw_if_subif_table)
5937 vec_free (sub->interface_name);
5939 vec_free (vam->sw_if_subif_table);
5941 /* recreate the interface name hash table */
5942 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5945 * Ask for all interface names. Otherwise, the epic catalog of
5946 * name filters becomes ridiculously long, and vat ends up needing
5947 * to be taught about new interface types.
5949 M (SW_INTERFACE_DUMP, mp);
5952 /* Use a control ping for synchronization */
5953 MPING (CONTROL_PING, mp_ping);
5961 api_sw_interface_set_flags (vat_main_t * vam)
5963 unformat_input_t *i = vam->input;
5964 vl_api_sw_interface_set_flags_t *mp;
5966 u8 sw_if_index_set = 0;
5970 /* Parse args required to build the message */
5971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5973 if (unformat (i, "admin-up"))
5975 else if (unformat (i, "admin-down"))
5978 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5979 sw_if_index_set = 1;
5980 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5981 sw_if_index_set = 1;
5986 if (sw_if_index_set == 0)
5988 errmsg ("missing interface name or sw_if_index");
5992 /* Construct the API message */
5993 M (SW_INTERFACE_SET_FLAGS, mp);
5994 mp->sw_if_index = ntohl (sw_if_index);
5995 mp->flags = ntohl ((admin_up) ? IF_STATUS_API_FLAG_ADMIN_UP : 0);
6000 /* Wait for a reply, return the good/bad news... */
6006 api_sw_interface_set_rx_mode (vat_main_t * vam)
6008 unformat_input_t *i = vam->input;
6009 vl_api_sw_interface_set_rx_mode_t *mp;
6011 u8 sw_if_index_set = 0;
6013 u8 queue_id_valid = 0;
6015 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6017 /* Parse args required to build the message */
6018 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6020 if (unformat (i, "queue %d", &queue_id))
6022 else if (unformat (i, "polling"))
6023 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6024 else if (unformat (i, "interrupt"))
6025 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6026 else if (unformat (i, "adaptive"))
6027 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6030 sw_if_index_set = 1;
6031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6032 sw_if_index_set = 1;
6037 if (sw_if_index_set == 0)
6039 errmsg ("missing interface name or sw_if_index");
6042 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6044 errmsg ("missing rx-mode");
6048 /* Construct the API message */
6049 M (SW_INTERFACE_SET_RX_MODE, mp);
6050 mp->sw_if_index = ntohl (sw_if_index);
6052 mp->queue_id_valid = queue_id_valid;
6053 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6058 /* Wait for a reply, return the good/bad news... */
6064 api_sw_interface_set_rx_placement (vat_main_t * vam)
6066 unformat_input_t *i = vam->input;
6067 vl_api_sw_interface_set_rx_placement_t *mp;
6069 u8 sw_if_index_set = 0;
6072 u32 queue_id, thread_index;
6074 /* Parse args required to build the message */
6075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6077 if (unformat (i, "queue %d", &queue_id))
6079 else if (unformat (i, "main"))
6081 else if (unformat (i, "worker %d", &thread_index))
6084 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6085 sw_if_index_set = 1;
6086 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6087 sw_if_index_set = 1;
6092 if (sw_if_index_set == 0)
6094 errmsg ("missing interface name or sw_if_index");
6100 /* Construct the API message */
6101 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6102 mp->sw_if_index = ntohl (sw_if_index);
6103 mp->worker_id = ntohl (thread_index);
6104 mp->queue_id = ntohl (queue_id);
6105 mp->is_main = is_main;
6109 /* Wait for a reply, return the good/bad news... */
6114 static void vl_api_sw_interface_rx_placement_details_t_handler
6115 (vl_api_sw_interface_rx_placement_details_t * mp)
6117 vat_main_t *vam = &vat_main;
6118 u32 worker_id = ntohl (mp->worker_id);
6121 "\n%-11d %-11s %-6d %-5d %-9s",
6122 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6123 worker_id, ntohl (mp->queue_id),
6125 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6128 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6129 (vl_api_sw_interface_rx_placement_details_t * mp)
6131 vat_main_t *vam = &vat_main;
6132 vat_json_node_t *node = NULL;
6134 if (VAT_JSON_ARRAY != vam->json_tree.type)
6136 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6137 vat_json_init_array (&vam->json_tree);
6139 node = vat_json_array_add (&vam->json_tree);
6141 vat_json_init_object (node);
6142 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6143 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6144 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6145 vat_json_object_add_uint (node, "mode", mp->mode);
6149 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6151 unformat_input_t *i = vam->input;
6152 vl_api_sw_interface_rx_placement_dump_t *mp;
6153 vl_api_control_ping_t *mp_ping;
6156 u8 sw_if_index_set = 0;
6158 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6160 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6162 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6169 "\n%-11s %-11s %-6s %-5s %-4s",
6170 "sw_if_index", "main/worker", "thread", "queue", "mode");
6172 /* Dump Interface rx placement */
6173 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6175 if (sw_if_index_set)
6176 mp->sw_if_index = htonl (sw_if_index);
6178 mp->sw_if_index = ~0;
6182 /* Use a control ping for synchronization */
6183 MPING (CONTROL_PING, mp_ping);
6191 api_sw_interface_clear_stats (vat_main_t * vam)
6193 unformat_input_t *i = vam->input;
6194 vl_api_sw_interface_clear_stats_t *mp;
6196 u8 sw_if_index_set = 0;
6199 /* Parse args required to build the message */
6200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6202 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6203 sw_if_index_set = 1;
6204 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6205 sw_if_index_set = 1;
6210 /* Construct the API message */
6211 M (SW_INTERFACE_CLEAR_STATS, mp);
6213 if (sw_if_index_set == 1)
6214 mp->sw_if_index = ntohl (sw_if_index);
6216 mp->sw_if_index = ~0;
6221 /* Wait for a reply, return the good/bad news... */
6227 api_sw_interface_add_del_address (vat_main_t * vam)
6229 unformat_input_t *i = vam->input;
6230 vl_api_sw_interface_add_del_address_t *mp;
6232 u8 sw_if_index_set = 0;
6233 u8 is_add = 1, del_all = 0;
6234 u32 address_length = 0;
6235 u8 v4_address_set = 0;
6236 u8 v6_address_set = 0;
6237 ip4_address_t v4address;
6238 ip6_address_t v6address;
6241 /* Parse args required to build the message */
6242 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6244 if (unformat (i, "del-all"))
6246 else if (unformat (i, "del"))
6249 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6250 sw_if_index_set = 1;
6251 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6252 sw_if_index_set = 1;
6253 else if (unformat (i, "%U/%d",
6254 unformat_ip4_address, &v4address, &address_length))
6256 else if (unformat (i, "%U/%d",
6257 unformat_ip6_address, &v6address, &address_length))
6263 if (sw_if_index_set == 0)
6265 errmsg ("missing interface name or sw_if_index");
6268 if (v4_address_set && v6_address_set)
6270 errmsg ("both v4 and v6 addresses set");
6273 if (!v4_address_set && !v6_address_set && !del_all)
6275 errmsg ("no addresses set");
6279 /* Construct the API message */
6280 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6282 mp->sw_if_index = ntohl (sw_if_index);
6283 mp->is_add = is_add;
6284 mp->del_all = del_all;
6287 mp->prefix.address.af = ADDRESS_IP6;
6288 clib_memcpy (mp->prefix.address.un.ip6, &v6address, sizeof (v6address));
6292 mp->prefix.address.af = ADDRESS_IP4;
6293 clib_memcpy (mp->prefix.address.un.ip4, &v4address, sizeof (v4address));
6295 mp->prefix.address_length = address_length;
6300 /* Wait for a reply, return good/bad news */
6306 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6308 unformat_input_t *i = vam->input;
6309 vl_api_sw_interface_set_mpls_enable_t *mp;
6311 u8 sw_if_index_set = 0;
6315 /* Parse args required to build the message */
6316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6318 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6319 sw_if_index_set = 1;
6320 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6321 sw_if_index_set = 1;
6322 else if (unformat (i, "disable"))
6324 else if (unformat (i, "dis"))
6330 if (sw_if_index_set == 0)
6332 errmsg ("missing interface name or sw_if_index");
6336 /* Construct the API message */
6337 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6339 mp->sw_if_index = ntohl (sw_if_index);
6340 mp->enable = enable;
6345 /* Wait for a reply... */
6351 api_sw_interface_set_table (vat_main_t * vam)
6353 unformat_input_t *i = vam->input;
6354 vl_api_sw_interface_set_table_t *mp;
6355 u32 sw_if_index, vrf_id = 0;
6356 u8 sw_if_index_set = 0;
6360 /* Parse args required to build the message */
6361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6363 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6364 sw_if_index_set = 1;
6365 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6366 sw_if_index_set = 1;
6367 else if (unformat (i, "vrf %d", &vrf_id))
6369 else if (unformat (i, "ipv6"))
6375 if (sw_if_index_set == 0)
6377 errmsg ("missing interface name or sw_if_index");
6381 /* Construct the API message */
6382 M (SW_INTERFACE_SET_TABLE, mp);
6384 mp->sw_if_index = ntohl (sw_if_index);
6385 mp->is_ipv6 = is_ipv6;
6386 mp->vrf_id = ntohl (vrf_id);
6391 /* Wait for a reply... */
6396 static void vl_api_sw_interface_get_table_reply_t_handler
6397 (vl_api_sw_interface_get_table_reply_t * mp)
6399 vat_main_t *vam = &vat_main;
6401 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6403 vam->retval = ntohl (mp->retval);
6404 vam->result_ready = 1;
6408 static void vl_api_sw_interface_get_table_reply_t_handler_json
6409 (vl_api_sw_interface_get_table_reply_t * mp)
6411 vat_main_t *vam = &vat_main;
6412 vat_json_node_t node;
6414 vat_json_init_object (&node);
6415 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6416 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6418 vat_json_print (vam->ofp, &node);
6419 vat_json_free (&node);
6421 vam->retval = ntohl (mp->retval);
6422 vam->result_ready = 1;
6426 api_sw_interface_get_table (vat_main_t * vam)
6428 unformat_input_t *i = vam->input;
6429 vl_api_sw_interface_get_table_t *mp;
6431 u8 sw_if_index_set = 0;
6435 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6437 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6438 sw_if_index_set = 1;
6439 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6440 sw_if_index_set = 1;
6441 else if (unformat (i, "ipv6"))
6447 if (sw_if_index_set == 0)
6449 errmsg ("missing interface name or sw_if_index");
6453 M (SW_INTERFACE_GET_TABLE, mp);
6454 mp->sw_if_index = htonl (sw_if_index);
6455 mp->is_ipv6 = is_ipv6;
6463 api_sw_interface_set_vpath (vat_main_t * vam)
6465 unformat_input_t *i = vam->input;
6466 vl_api_sw_interface_set_vpath_t *mp;
6467 u32 sw_if_index = 0;
6468 u8 sw_if_index_set = 0;
6472 /* Parse args required to build the message */
6473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6475 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6476 sw_if_index_set = 1;
6477 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6478 sw_if_index_set = 1;
6479 else if (unformat (i, "enable"))
6481 else if (unformat (i, "disable"))
6487 if (sw_if_index_set == 0)
6489 errmsg ("missing interface name or sw_if_index");
6493 /* Construct the API message */
6494 M (SW_INTERFACE_SET_VPATH, mp);
6496 mp->sw_if_index = ntohl (sw_if_index);
6497 mp->enable = is_enable;
6502 /* Wait for a reply... */
6508 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6510 unformat_input_t *i = vam->input;
6511 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6512 u32 sw_if_index = 0;
6513 u8 sw_if_index_set = 0;
6518 /* Parse args required to build the message */
6519 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6521 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6522 sw_if_index_set = 1;
6523 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6524 sw_if_index_set = 1;
6525 else if (unformat (i, "enable"))
6527 else if (unformat (i, "disable"))
6529 else if (unformat (i, "ip4"))
6531 else if (unformat (i, "ip6"))
6537 if (sw_if_index_set == 0)
6539 errmsg ("missing interface name or sw_if_index");
6543 /* Construct the API message */
6544 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6546 mp->sw_if_index = ntohl (sw_if_index);
6547 mp->enable = is_enable;
6548 mp->is_ipv6 = is_ipv6;
6553 /* Wait for a reply... */
6559 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6561 unformat_input_t *i = vam->input;
6562 vl_api_sw_interface_set_geneve_bypass_t *mp;
6563 u32 sw_if_index = 0;
6564 u8 sw_if_index_set = 0;
6569 /* Parse args required to build the message */
6570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6572 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6573 sw_if_index_set = 1;
6574 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6575 sw_if_index_set = 1;
6576 else if (unformat (i, "enable"))
6578 else if (unformat (i, "disable"))
6580 else if (unformat (i, "ip4"))
6582 else if (unformat (i, "ip6"))
6588 if (sw_if_index_set == 0)
6590 errmsg ("missing interface name or sw_if_index");
6594 /* Construct the API message */
6595 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6597 mp->sw_if_index = ntohl (sw_if_index);
6598 mp->enable = is_enable;
6599 mp->is_ipv6 = is_ipv6;
6604 /* Wait for a reply... */
6610 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6612 unformat_input_t *i = vam->input;
6613 vl_api_sw_interface_set_l2_xconnect_t *mp;
6615 u8 rx_sw_if_index_set = 0;
6617 u8 tx_sw_if_index_set = 0;
6621 /* Parse args required to build the message */
6622 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6624 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6625 rx_sw_if_index_set = 1;
6626 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6627 tx_sw_if_index_set = 1;
6628 else if (unformat (i, "rx"))
6630 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6632 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6634 rx_sw_if_index_set = 1;
6639 else if (unformat (i, "tx"))
6641 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6643 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6645 tx_sw_if_index_set = 1;
6650 else if (unformat (i, "enable"))
6652 else if (unformat (i, "disable"))
6658 if (rx_sw_if_index_set == 0)
6660 errmsg ("missing rx interface name or rx_sw_if_index");
6664 if (enable && (tx_sw_if_index_set == 0))
6666 errmsg ("missing tx interface name or tx_sw_if_index");
6670 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6672 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6673 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6674 mp->enable = enable;
6682 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6684 unformat_input_t *i = vam->input;
6685 vl_api_sw_interface_set_l2_bridge_t *mp;
6686 vl_api_l2_port_type_t port_type;
6688 u8 rx_sw_if_index_set = 0;
6695 port_type = L2_API_PORT_TYPE_NORMAL;
6697 /* Parse args required to build the message */
6698 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6700 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6701 rx_sw_if_index_set = 1;
6702 else if (unformat (i, "bd_id %d", &bd_id))
6706 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6707 rx_sw_if_index_set = 1;
6708 else if (unformat (i, "shg %d", &shg))
6710 else if (unformat (i, "bvi"))
6711 port_type = L2_API_PORT_TYPE_BVI;
6712 else if (unformat (i, "uu-fwd"))
6713 port_type = L2_API_PORT_TYPE_UU_FWD;
6714 else if (unformat (i, "enable"))
6716 else if (unformat (i, "disable"))
6722 if (rx_sw_if_index_set == 0)
6724 errmsg ("missing rx interface name or sw_if_index");
6728 if (enable && (bd_id_set == 0))
6730 errmsg ("missing bridge domain");
6734 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6736 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6737 mp->bd_id = ntohl (bd_id);
6739 mp->port_type = ntohl (port_type);
6740 mp->enable = enable;
6748 api_bridge_domain_dump (vat_main_t * vam)
6750 unformat_input_t *i = vam->input;
6751 vl_api_bridge_domain_dump_t *mp;
6752 vl_api_control_ping_t *mp_ping;
6756 /* Parse args required to build the message */
6757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6759 if (unformat (i, "bd_id %d", &bd_id))
6765 M (BRIDGE_DOMAIN_DUMP, mp);
6766 mp->bd_id = ntohl (bd_id);
6769 /* Use a control ping for synchronization */
6770 MPING (CONTROL_PING, mp_ping);
6778 api_bridge_domain_add_del (vat_main_t * vam)
6780 unformat_input_t *i = vam->input;
6781 vl_api_bridge_domain_add_del_t *mp;
6784 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6789 /* Parse args required to build the message */
6790 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6792 if (unformat (i, "bd_id %d", &bd_id))
6794 else if (unformat (i, "flood %d", &flood))
6796 else if (unformat (i, "uu-flood %d", &uu_flood))
6798 else if (unformat (i, "forward %d", &forward))
6800 else if (unformat (i, "learn %d", &learn))
6802 else if (unformat (i, "arp-term %d", &arp_term))
6804 else if (unformat (i, "mac-age %d", &mac_age))
6806 else if (unformat (i, "bd-tag %s", &bd_tag))
6808 else if (unformat (i, "del"))
6811 flood = uu_flood = forward = learn = 0;
6819 errmsg ("missing bridge domain");
6826 errmsg ("mac age must be less than 256 ");
6831 if ((bd_tag) && (vec_len (bd_tag) > 63))
6833 errmsg ("bd-tag cannot be longer than 63");
6838 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6840 mp->bd_id = ntohl (bd_id);
6842 mp->uu_flood = uu_flood;
6843 mp->forward = forward;
6845 mp->arp_term = arp_term;
6846 mp->is_add = is_add;
6847 mp->mac_age = (u8) mac_age;
6850 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6851 mp->bd_tag[vec_len (bd_tag)] = 0;
6862 api_l2fib_flush_bd (vat_main_t * vam)
6864 unformat_input_t *i = vam->input;
6865 vl_api_l2fib_flush_bd_t *mp;
6869 /* Parse args required to build the message */
6870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6872 if (unformat (i, "bd_id %d", &bd_id));
6879 errmsg ("missing bridge domain");
6883 M (L2FIB_FLUSH_BD, mp);
6885 mp->bd_id = htonl (bd_id);
6893 api_l2fib_flush_int (vat_main_t * vam)
6895 unformat_input_t *i = vam->input;
6896 vl_api_l2fib_flush_int_t *mp;
6897 u32 sw_if_index = ~0;
6900 /* Parse args required to build the message */
6901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6903 if (unformat (i, "sw_if_index %d", &sw_if_index));
6905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6910 if (sw_if_index == ~0)
6912 errmsg ("missing interface name or sw_if_index");
6916 M (L2FIB_FLUSH_INT, mp);
6918 mp->sw_if_index = ntohl (sw_if_index);
6926 api_l2fib_add_del (vat_main_t * vam)
6928 unformat_input_t *i = vam->input;
6929 vl_api_l2fib_add_del_t *mp;
6935 u32 sw_if_index = 0;
6936 u8 sw_if_index_set = 0;
6945 /* Parse args required to build the message */
6946 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6948 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6950 else if (unformat (i, "bd_id %d", &bd_id))
6952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6953 sw_if_index_set = 1;
6954 else if (unformat (i, "sw_if"))
6956 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6959 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6960 sw_if_index_set = 1;
6965 else if (unformat (i, "static"))
6967 else if (unformat (i, "filter"))
6972 else if (unformat (i, "bvi"))
6977 else if (unformat (i, "del"))
6979 else if (unformat (i, "count %d", &count))
6987 errmsg ("missing mac address");
6993 errmsg ("missing bridge domain");
6997 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6999 errmsg ("missing interface name or sw_if_index");
7005 /* Turn on async mode */
7006 vam->async_mode = 1;
7007 vam->async_errors = 0;
7008 before = vat_time_now (vam);
7011 for (j = 0; j < count; j++)
7013 M (L2FIB_ADD_DEL, mp);
7015 clib_memcpy (mp->mac, mac, 6);
7016 mp->bd_id = ntohl (bd_id);
7017 mp->is_add = is_add;
7018 mp->sw_if_index = ntohl (sw_if_index);
7022 mp->static_mac = static_mac;
7023 mp->filter_mac = filter_mac;
7024 mp->bvi_mac = bvi_mac;
7026 increment_mac_address (mac);
7033 vl_api_control_ping_t *mp_ping;
7036 /* Shut off async mode */
7037 vam->async_mode = 0;
7039 MPING (CONTROL_PING, mp_ping);
7042 timeout = vat_time_now (vam) + 1.0;
7043 while (vat_time_now (vam) < timeout)
7044 if (vam->result_ready == 1)
7049 if (vam->retval == -99)
7052 if (vam->async_errors > 0)
7054 errmsg ("%d asynchronous errors", vam->async_errors);
7057 vam->async_errors = 0;
7058 after = vat_time_now (vam);
7060 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7061 count, after - before, count / (after - before));
7067 /* Wait for a reply... */
7071 /* Return the good/bad news */
7072 return (vam->retval);
7076 api_bridge_domain_set_mac_age (vat_main_t * vam)
7078 unformat_input_t *i = vam->input;
7079 vl_api_bridge_domain_set_mac_age_t *mp;
7084 /* Parse args required to build the message */
7085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7087 if (unformat (i, "bd_id %d", &bd_id));
7088 else if (unformat (i, "mac-age %d", &mac_age));
7095 errmsg ("missing bridge domain");
7101 errmsg ("mac age must be less than 256 ");
7105 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7107 mp->bd_id = htonl (bd_id);
7108 mp->mac_age = (u8) mac_age;
7116 api_l2_flags (vat_main_t * vam)
7118 unformat_input_t *i = vam->input;
7119 vl_api_l2_flags_t *mp;
7122 u8 sw_if_index_set = 0;
7126 /* Parse args required to build the message */
7127 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7129 if (unformat (i, "sw_if_index %d", &sw_if_index))
7130 sw_if_index_set = 1;
7131 else if (unformat (i, "sw_if"))
7133 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7136 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7137 sw_if_index_set = 1;
7142 else if (unformat (i, "learn"))
7144 else if (unformat (i, "forward"))
7146 else if (unformat (i, "flood"))
7148 else if (unformat (i, "uu-flood"))
7149 flags |= L2_UU_FLOOD;
7150 else if (unformat (i, "arp-term"))
7151 flags |= L2_ARP_TERM;
7152 else if (unformat (i, "off"))
7154 else if (unformat (i, "disable"))
7160 if (sw_if_index_set == 0)
7162 errmsg ("missing interface name or sw_if_index");
7168 mp->sw_if_index = ntohl (sw_if_index);
7169 mp->feature_bitmap = ntohl (flags);
7170 mp->is_set = is_set;
7178 api_bridge_flags (vat_main_t * vam)
7180 unformat_input_t *i = vam->input;
7181 vl_api_bridge_flags_t *mp;
7185 bd_flags_t flags = 0;
7188 /* Parse args required to build the message */
7189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7191 if (unformat (i, "bd_id %d", &bd_id))
7193 else if (unformat (i, "learn"))
7194 flags |= BRIDGE_API_FLAG_LEARN;
7195 else if (unformat (i, "forward"))
7196 flags |= BRIDGE_API_FLAG_FWD;
7197 else if (unformat (i, "flood"))
7198 flags |= BRIDGE_API_FLAG_FLOOD;
7199 else if (unformat (i, "uu-flood"))
7200 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7201 else if (unformat (i, "arp-term"))
7202 flags |= BRIDGE_API_FLAG_ARP_TERM;
7203 else if (unformat (i, "off"))
7205 else if (unformat (i, "disable"))
7213 errmsg ("missing bridge domain");
7217 M (BRIDGE_FLAGS, mp);
7219 mp->bd_id = ntohl (bd_id);
7220 mp->flags = ntohl (flags);
7221 mp->is_set = is_set;
7229 api_bd_ip_mac_add_del (vat_main_t * vam)
7231 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7232 vl_api_mac_address_t mac = { 0 };
7233 unformat_input_t *i = vam->input;
7234 vl_api_bd_ip_mac_add_del_t *mp;
7246 /* Parse args required to build the message */
7247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7249 if (unformat (i, "bd_id %d", &bd_id))
7253 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7257 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7261 else if (unformat (i, "del"))
7269 errmsg ("missing bridge domain");
7272 else if (ip_set == 0)
7274 errmsg ("missing IP address");
7277 else if (mac_set == 0)
7279 errmsg ("missing MAC address");
7283 M (BD_IP_MAC_ADD_DEL, mp);
7285 mp->bd_id = ntohl (bd_id);
7286 mp->is_add = is_add;
7288 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7289 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7297 api_bd_ip_mac_flush (vat_main_t * vam)
7299 unformat_input_t *i = vam->input;
7300 vl_api_bd_ip_mac_flush_t *mp;
7305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7307 if (unformat (i, "bd_id %d", &bd_id))
7317 errmsg ("missing bridge domain");
7321 M (BD_IP_MAC_FLUSH, mp);
7323 mp->bd_id = ntohl (bd_id);
7330 static void vl_api_bd_ip_mac_details_t_handler
7331 (vl_api_bd_ip_mac_details_t * mp)
7333 vat_main_t *vam = &vat_main;
7338 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7341 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7344 "\n%-5d %-7s %-20U %-30s",
7345 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7346 format_ethernet_address, mp->mac_address, ip);
7351 static void vl_api_bd_ip_mac_details_t_handler_json
7352 (vl_api_bd_ip_mac_details_t * mp)
7354 vat_main_t *vam = &vat_main;
7355 vat_json_node_t *node = NULL;
7357 if (VAT_JSON_ARRAY != vam->json_tree.type)
7359 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7360 vat_json_init_array (&vam->json_tree);
7362 node = vat_json_array_add (&vam->json_tree);
7364 vat_json_init_object (node);
7365 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7366 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7367 vat_json_object_add_string_copy (node, "mac_address",
7368 format (0, "%U", format_ethernet_address,
7374 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7377 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7378 vat_json_object_add_string_copy (node, "ip_address", ip);
7383 api_bd_ip_mac_dump (vat_main_t * vam)
7385 unformat_input_t *i = vam->input;
7386 vl_api_bd_ip_mac_dump_t *mp;
7387 vl_api_control_ping_t *mp_ping;
7392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7394 if (unformat (i, "bd_id %d", &bd_id))
7403 "\n%-5s %-7s %-20s %-30s",
7404 "bd_id", "is_ipv6", "mac_address", "ip_address");
7406 /* Dump Bridge Domain Ip to Mac entries */
7407 M (BD_IP_MAC_DUMP, mp);
7410 mp->bd_id = htonl (bd_id);
7416 /* Use a control ping for synchronization */
7417 MPING (CONTROL_PING, mp_ping);
7425 api_tap_create_v2 (vat_main_t * vam)
7427 unformat_input_t *i = vam->input;
7428 vl_api_tap_create_v2_t *mp;
7432 u8 *host_if_name = 0;
7434 u8 host_mac_addr[6];
7435 u8 host_mac_addr_set = 0;
7436 u8 *host_bridge = 0;
7437 ip4_address_t host_ip4_addr;
7438 ip4_address_t host_ip4_gw;
7439 u8 host_ip4_gw_set = 0;
7440 u32 host_ip4_prefix_len = 0;
7441 ip6_address_t host_ip6_addr;
7442 ip6_address_t host_ip6_gw;
7443 u8 host_ip6_gw_set = 0;
7444 u32 host_ip6_prefix_len = 0;
7446 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7448 clib_memset (mac_address, 0, sizeof (mac_address));
7450 /* Parse args required to build the message */
7451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7453 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7457 else if (unformat (i, "id %u", &id))
7459 else if (unformat (i, "host-if-name %s", &host_if_name))
7461 else if (unformat (i, "host-ns %s", &host_ns))
7463 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7465 host_mac_addr_set = 1;
7466 else if (unformat (i, "host-bridge %s", &host_bridge))
7468 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7469 &host_ip4_addr, &host_ip4_prefix_len))
7471 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7472 &host_ip6_addr, &host_ip6_prefix_len))
7474 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7476 host_ip4_gw_set = 1;
7477 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7479 host_ip6_gw_set = 1;
7480 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7482 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7488 if (vec_len (host_if_name) > 63)
7490 errmsg ("tap name too long. ");
7493 if (vec_len (host_ns) > 63)
7495 errmsg ("host name space too long. ");
7498 if (vec_len (host_bridge) > 63)
7500 errmsg ("host bridge name too long. ");
7503 if (host_ip4_prefix_len > 32)
7505 errmsg ("host ip4 prefix length not valid. ");
7508 if (host_ip6_prefix_len > 128)
7510 errmsg ("host ip6 prefix length not valid. ");
7513 if (!is_pow2 (rx_ring_sz))
7515 errmsg ("rx ring size must be power of 2. ");
7518 if (rx_ring_sz > 32768)
7520 errmsg ("rx ring size must be 32768 or lower. ");
7523 if (!is_pow2 (tx_ring_sz))
7525 errmsg ("tx ring size must be power of 2. ");
7528 if (tx_ring_sz > 32768)
7530 errmsg ("tx ring size must be 32768 or lower. ");
7534 /* Construct the API message */
7535 M (TAP_CREATE_V2, mp);
7537 mp->use_random_mac = random_mac;
7539 mp->id = ntohl (id);
7540 mp->host_namespace_set = host_ns != 0;
7541 mp->host_bridge_set = host_bridge != 0;
7542 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7543 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7544 mp->rx_ring_sz = ntohs (rx_ring_sz);
7545 mp->tx_ring_sz = ntohs (tx_ring_sz);
7547 if (random_mac == 0)
7548 clib_memcpy (mp->mac_address, mac_address, 6);
7549 if (host_mac_addr_set)
7550 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7552 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7554 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7556 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7557 if (host_ip4_prefix_len)
7558 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7559 if (host_ip6_prefix_len)
7560 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7561 if (host_ip4_gw_set)
7562 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7563 if (host_ip6_gw_set)
7564 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7567 vec_free (host_if_name);
7568 vec_free (host_bridge);
7573 /* Wait for a reply... */
7579 api_tap_delete_v2 (vat_main_t * vam)
7581 unformat_input_t *i = vam->input;
7582 vl_api_tap_delete_v2_t *mp;
7583 u32 sw_if_index = ~0;
7584 u8 sw_if_index_set = 0;
7587 /* Parse args required to build the message */
7588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7590 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7591 sw_if_index_set = 1;
7592 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7593 sw_if_index_set = 1;
7598 if (sw_if_index_set == 0)
7600 errmsg ("missing vpp interface name. ");
7604 /* Construct the API message */
7605 M (TAP_DELETE_V2, mp);
7607 mp->sw_if_index = ntohl (sw_if_index);
7612 /* Wait for a reply... */
7618 unformat_pci_addr (unformat_input_t * input, va_list * args)
7627 addr = va_arg (*args, struct pci_addr_t *);
7630 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7633 addr->domain = x[0];
7636 addr->function = x[3];
7642 api_virtio_pci_create (vat_main_t * vam)
7644 unformat_input_t *i = vam->input;
7645 vl_api_virtio_pci_create_t *mp;
7649 u64 features = (u64) ~ (0ULL);
7650 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7653 clib_memset (mac_address, 0, sizeof (mac_address));
7655 /* Parse args required to build the message */
7656 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7658 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7662 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7664 else if (unformat (i, "features 0x%llx", &features))
7666 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7668 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7676 errmsg ("pci address must be non zero. ");
7679 if (!is_pow2 (rx_ring_sz))
7681 errmsg ("rx ring size must be power of 2. ");
7684 if (rx_ring_sz > 32768)
7686 errmsg ("rx ring size must be 32768 or lower. ");
7689 if (!is_pow2 (tx_ring_sz))
7691 errmsg ("tx ring size must be power of 2. ");
7694 if (tx_ring_sz > 32768)
7696 errmsg ("tx ring size must be 32768 or lower. ");
7700 /* Construct the API message */
7701 M (VIRTIO_PCI_CREATE, mp);
7703 mp->use_random_mac = random_mac;
7705 mp->pci_addr = htonl (pci_addr);
7706 mp->features = clib_host_to_net_u64 (features);
7707 mp->rx_ring_sz = htons (rx_ring_sz);
7708 mp->tx_ring_sz = htons (tx_ring_sz);
7710 if (random_mac == 0)
7711 clib_memcpy (mp->mac_address, mac_address, 6);
7716 /* Wait for a reply... */
7722 api_virtio_pci_delete (vat_main_t * vam)
7724 unformat_input_t *i = vam->input;
7725 vl_api_virtio_pci_delete_t *mp;
7726 u32 sw_if_index = ~0;
7727 u8 sw_if_index_set = 0;
7730 /* Parse args required to build the message */
7731 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7733 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7734 sw_if_index_set = 1;
7735 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7736 sw_if_index_set = 1;
7741 if (sw_if_index_set == 0)
7743 errmsg ("missing vpp interface name. ");
7747 /* Construct the API message */
7748 M (VIRTIO_PCI_DELETE, mp);
7750 mp->sw_if_index = htonl (sw_if_index);
7755 /* Wait for a reply... */
7761 api_bond_create (vat_main_t * vam)
7763 unformat_input_t *i = vam->input;
7764 vl_api_bond_create_t *mp;
7773 clib_memset (mac_address, 0, sizeof (mac_address));
7776 /* Parse args required to build the message */
7777 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7779 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7781 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7782 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7784 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7787 else if (unformat (i, "id %u", &id))
7793 if (mode_is_set == 0)
7795 errmsg ("Missing bond mode. ");
7799 /* Construct the API message */
7800 M (BOND_CREATE, mp);
7802 mp->use_custom_mac = custom_mac;
7806 mp->id = htonl (id);
7809 clib_memcpy (mp->mac_address, mac_address, 6);
7814 /* Wait for a reply... */
7820 api_bond_delete (vat_main_t * vam)
7822 unformat_input_t *i = vam->input;
7823 vl_api_bond_delete_t *mp;
7824 u32 sw_if_index = ~0;
7825 u8 sw_if_index_set = 0;
7828 /* Parse args required to build the message */
7829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7832 sw_if_index_set = 1;
7833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7834 sw_if_index_set = 1;
7839 if (sw_if_index_set == 0)
7841 errmsg ("missing vpp interface name. ");
7845 /* Construct the API message */
7846 M (BOND_DELETE, mp);
7848 mp->sw_if_index = ntohl (sw_if_index);
7853 /* Wait for a reply... */
7859 api_bond_enslave (vat_main_t * vam)
7861 unformat_input_t *i = vam->input;
7862 vl_api_bond_enslave_t *mp;
7863 u32 bond_sw_if_index;
7867 u32 bond_sw_if_index_is_set = 0;
7869 u8 sw_if_index_is_set = 0;
7871 /* Parse args required to build the message */
7872 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7874 if (unformat (i, "sw_if_index %d", &sw_if_index))
7875 sw_if_index_is_set = 1;
7876 else if (unformat (i, "bond %u", &bond_sw_if_index))
7877 bond_sw_if_index_is_set = 1;
7878 else if (unformat (i, "passive %d", &is_passive))
7880 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7886 if (bond_sw_if_index_is_set == 0)
7888 errmsg ("Missing bond sw_if_index. ");
7891 if (sw_if_index_is_set == 0)
7893 errmsg ("Missing slave sw_if_index. ");
7897 /* Construct the API message */
7898 M (BOND_ENSLAVE, mp);
7900 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7901 mp->sw_if_index = ntohl (sw_if_index);
7902 mp->is_long_timeout = is_long_timeout;
7903 mp->is_passive = is_passive;
7908 /* Wait for a reply... */
7914 api_bond_detach_slave (vat_main_t * vam)
7916 unformat_input_t *i = vam->input;
7917 vl_api_bond_detach_slave_t *mp;
7918 u32 sw_if_index = ~0;
7919 u8 sw_if_index_set = 0;
7922 /* Parse args required to build the message */
7923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7925 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7926 sw_if_index_set = 1;
7927 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7928 sw_if_index_set = 1;
7933 if (sw_if_index_set == 0)
7935 errmsg ("missing vpp interface name. ");
7939 /* Construct the API message */
7940 M (BOND_DETACH_SLAVE, mp);
7942 mp->sw_if_index = ntohl (sw_if_index);
7947 /* Wait for a reply... */
7953 api_ip_table_add_del (vat_main_t * vam)
7955 unformat_input_t *i = vam->input;
7956 vl_api_ip_table_add_del_t *mp;
7962 /* Parse args required to build the message */
7963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7965 if (unformat (i, "ipv6"))
7967 else if (unformat (i, "del"))
7969 else if (unformat (i, "add"))
7971 else if (unformat (i, "table %d", &table_id))
7975 clib_warning ("parse error '%U'", format_unformat_error, i);
7982 errmsg ("missing table-ID");
7986 /* Construct the API message */
7987 M (IP_TABLE_ADD_DEL, mp);
7989 mp->table_id = ntohl (table_id);
7990 mp->is_ipv6 = is_ipv6;
7991 mp->is_add = is_add;
7996 /* Wait for a reply... */
8003 api_ip_add_del_route (vat_main_t * vam)
8005 unformat_input_t *i = vam->input;
8006 vl_api_ip_add_del_route_t *mp;
8007 u32 sw_if_index = ~0, vrf_id = 0;
8009 u8 is_local = 0, is_drop = 0;
8010 u8 is_unreach = 0, is_prohibit = 0;
8012 u32 next_hop_weight = 1;
8013 u8 is_multipath = 0;
8015 u8 address_length_set = 0;
8016 u32 next_hop_table_id = 0;
8017 u32 resolve_attempts = 0;
8018 u32 dst_address_length = 0;
8019 u8 next_hop_set = 0;
8020 ip4_address_t v4_dst_address, v4_next_hop_address;
8021 ip6_address_t v6_dst_address, v6_next_hop_address;
8025 u32 random_add_del = 0;
8026 u32 *random_vector = 0;
8028 u32 random_seed = 0xdeaddabe;
8029 u32 classify_table_index = ~0;
8031 u8 resolve_host = 0, resolve_attached = 0;
8032 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8033 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8034 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8036 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8037 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8038 /* Parse args required to build the message */
8039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8045 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8050 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8055 else if (unformat (i, "/%d", &dst_address_length))
8057 address_length_set = 1;
8060 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8061 &v4_next_hop_address))
8065 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8066 &v6_next_hop_address))
8072 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8076 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8080 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8082 else if (unformat (i, "weight %d", &next_hop_weight))
8084 else if (unformat (i, "drop"))
8088 else if (unformat (i, "null-send-unreach"))
8092 else if (unformat (i, "null-send-prohibit"))
8096 else if (unformat (i, "local"))
8100 else if (unformat (i, "classify %d", &classify_table_index))
8104 else if (unformat (i, "del"))
8106 else if (unformat (i, "add"))
8108 else if (unformat (i, "resolve-via-host"))
8110 else if (unformat (i, "resolve-via-attached"))
8111 resolve_attached = 1;
8112 else if (unformat (i, "multipath"))
8114 else if (unformat (i, "vrf %d", &vrf_id))
8116 else if (unformat (i, "count %d", &count))
8118 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8120 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8122 else if (unformat (i, "out-label %d", &next_hop_out_label))
8124 vl_api_fib_mpls_label_t fib_label = {
8125 .label = ntohl (next_hop_out_label),
8129 vec_add1 (next_hop_out_label_stack, fib_label);
8131 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8133 else if (unformat (i, "random"))
8135 else if (unformat (i, "seed %d", &random_seed))
8139 clib_warning ("parse error '%U'", format_unformat_error, i);
8144 if (!next_hop_set && !is_drop && !is_local &&
8145 !is_classify && !is_unreach && !is_prohibit &&
8146 MPLS_LABEL_INVALID == next_hop_via_label)
8149 ("next hop / local / drop / unreach / prohibit / classify not set");
8153 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8155 errmsg ("next hop and next-hop via label set");
8158 if (address_set == 0)
8160 errmsg ("missing addresses");
8164 if (address_length_set == 0)
8166 errmsg ("missing address length");
8170 /* Generate a pile of unique, random routes */
8173 u32 this_random_address;
8174 random_hash = hash_create (count, sizeof (uword));
8176 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8177 for (j = 0; j <= count; j++)
8181 this_random_address = random_u32 (&random_seed);
8182 this_random_address =
8183 clib_host_to_net_u32 (this_random_address);
8185 while (hash_get (random_hash, this_random_address));
8186 vec_add1 (random_vector, this_random_address);
8187 hash_set (random_hash, this_random_address, 1);
8189 hash_free (random_hash);
8190 v4_dst_address.as_u32 = random_vector[0];
8195 /* Turn on async mode */
8196 vam->async_mode = 1;
8197 vam->async_errors = 0;
8198 before = vat_time_now (vam);
8201 for (j = 0; j < count; j++)
8203 /* Construct the API message */
8204 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8205 vec_len (next_hop_out_label_stack));
8207 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8208 mp->table_id = ntohl (vrf_id);
8210 mp->is_add = is_add;
8211 mp->is_drop = is_drop;
8212 mp->is_unreach = is_unreach;
8213 mp->is_prohibit = is_prohibit;
8214 mp->is_ipv6 = is_ipv6;
8215 mp->is_local = is_local;
8216 mp->is_classify = is_classify;
8217 mp->is_multipath = is_multipath;
8218 mp->is_resolve_host = resolve_host;
8219 mp->is_resolve_attached = resolve_attached;
8220 mp->next_hop_weight = next_hop_weight;
8221 mp->next_hop_preference = 0;
8222 mp->dst_address_length = dst_address_length;
8223 mp->next_hop_table_id = ntohl (next_hop_table_id);
8224 mp->classify_table_index = ntohl (classify_table_index);
8225 mp->next_hop_via_label = ntohl (next_hop_via_label);
8226 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8227 if (0 != mp->next_hop_n_out_labels)
8229 memcpy (mp->next_hop_out_label_stack,
8230 next_hop_out_label_stack,
8231 (vec_len (next_hop_out_label_stack) *
8232 sizeof (vl_api_fib_mpls_label_t)));
8233 vec_free (next_hop_out_label_stack);
8238 clib_memcpy (mp->dst_address, &v6_dst_address,
8239 sizeof (v6_dst_address));
8241 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8242 sizeof (v6_next_hop_address));
8243 increment_v6_address (&v6_dst_address);
8247 clib_memcpy (mp->dst_address, &v4_dst_address,
8248 sizeof (v4_dst_address));
8250 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8251 sizeof (v4_next_hop_address));
8253 v4_dst_address.as_u32 = random_vector[j + 1];
8255 increment_v4_address (&v4_dst_address);
8259 /* If we receive SIGTERM, stop now... */
8264 /* When testing multiple add/del ops, use a control-ping to sync */
8267 vl_api_control_ping_t *mp_ping;
8271 /* Shut off async mode */
8272 vam->async_mode = 0;
8274 MPING (CONTROL_PING, mp_ping);
8277 timeout = vat_time_now (vam) + 1.0;
8278 while (vat_time_now (vam) < timeout)
8279 if (vam->result_ready == 1)
8284 if (vam->retval == -99)
8287 if (vam->async_errors > 0)
8289 errmsg ("%d asynchronous errors", vam->async_errors);
8292 vam->async_errors = 0;
8293 after = vat_time_now (vam);
8295 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8299 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8300 count, after - before, count / (after - before));
8306 /* Wait for a reply... */
8311 /* Return the good/bad news */
8312 return (vam->retval);
8316 api_ip_mroute_add_del (vat_main_t * vam)
8318 unformat_input_t *i = vam->input;
8319 vl_api_ip_mroute_add_del_t *mp;
8320 u32 sw_if_index = ~0, vrf_id = 0;
8325 u32 grp_address_length = 0;
8326 ip4_address_t v4_grp_address, v4_src_address;
8327 ip6_address_t v6_grp_address, v6_src_address;
8328 mfib_itf_flags_t iflags = 0;
8329 mfib_entry_flags_t eflags = 0;
8332 /* Parse args required to build the message */
8333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8335 if (unformat (i, "sw_if_index %d", &sw_if_index))
8337 else if (unformat (i, "%U %U",
8338 unformat_ip4_address, &v4_src_address,
8339 unformat_ip4_address, &v4_grp_address))
8341 grp_address_length = 64;
8345 else if (unformat (i, "%U %U",
8346 unformat_ip6_address, &v6_src_address,
8347 unformat_ip6_address, &v6_grp_address))
8349 grp_address_length = 256;
8353 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8355 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8356 grp_address_length = 32;
8360 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8362 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8363 grp_address_length = 128;
8367 else if (unformat (i, "/%d", &grp_address_length))
8369 else if (unformat (i, "local"))
8373 else if (unformat (i, "del"))
8375 else if (unformat (i, "add"))
8377 else if (unformat (i, "vrf %d", &vrf_id))
8379 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8381 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8385 clib_warning ("parse error '%U'", format_unformat_error, i);
8390 if (address_set == 0)
8392 errmsg ("missing addresses\n");
8396 /* Construct the API message */
8397 M (IP_MROUTE_ADD_DEL, mp);
8399 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8400 mp->table_id = ntohl (vrf_id);
8402 mp->is_add = is_add;
8403 mp->is_ipv6 = is_ipv6;
8404 mp->is_local = is_local;
8405 mp->itf_flags = ntohl (iflags);
8406 mp->entry_flags = ntohl (eflags);
8407 mp->grp_address_length = grp_address_length;
8408 mp->grp_address_length = ntohs (mp->grp_address_length);
8412 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8413 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8417 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8418 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8424 /* Wait for a reply... */
8430 api_mpls_table_add_del (vat_main_t * vam)
8432 unformat_input_t *i = vam->input;
8433 vl_api_mpls_table_add_del_t *mp;
8438 /* Parse args required to build the message */
8439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8441 if (unformat (i, "table %d", &table_id))
8443 else if (unformat (i, "del"))
8445 else if (unformat (i, "add"))
8449 clib_warning ("parse error '%U'", format_unformat_error, i);
8456 errmsg ("missing table-ID");
8460 /* Construct the API message */
8461 M (MPLS_TABLE_ADD_DEL, mp);
8463 mp->mt_table_id = ntohl (table_id);
8464 mp->mt_is_add = is_add;
8469 /* Wait for a reply... */
8476 api_mpls_route_add_del (vat_main_t * vam)
8478 unformat_input_t *i = vam->input;
8479 vl_api_mpls_route_add_del_t *mp;
8480 u32 sw_if_index = ~0, table_id = 0;
8482 u32 next_hop_weight = 1;
8483 u8 is_multipath = 0;
8484 u32 next_hop_table_id = 0;
8485 u8 next_hop_set = 0;
8486 ip4_address_t v4_next_hop_address = {
8489 ip6_address_t v6_next_hop_address = { {0} };
8493 u32 classify_table_index = ~0;
8495 u8 resolve_host = 0, resolve_attached = 0;
8496 u8 is_interface_rx = 0;
8497 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8498 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8499 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8500 mpls_label_t local_label = MPLS_LABEL_INVALID;
8502 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8504 /* Parse args required to build the message */
8505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8507 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8509 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8511 else if (unformat (i, "%d", &local_label))
8513 else if (unformat (i, "eos"))
8515 else if (unformat (i, "non-eos"))
8517 else if (unformat (i, "via %U", unformat_ip4_address,
8518 &v4_next_hop_address))
8521 next_hop_proto = DPO_PROTO_IP4;
8523 else if (unformat (i, "via %U", unformat_ip6_address,
8524 &v6_next_hop_address))
8527 next_hop_proto = DPO_PROTO_IP6;
8529 else if (unformat (i, "weight %d", &next_hop_weight))
8531 else if (unformat (i, "classify %d", &classify_table_index))
8535 else if (unformat (i, "del"))
8537 else if (unformat (i, "add"))
8539 else if (unformat (i, "resolve-via-host"))
8541 else if (unformat (i, "resolve-via-attached"))
8542 resolve_attached = 1;
8543 else if (unformat (i, "multipath"))
8545 else if (unformat (i, "count %d", &count))
8547 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8550 next_hop_proto = DPO_PROTO_IP4;
8552 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8555 next_hop_proto = DPO_PROTO_IP6;
8559 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8563 next_hop_proto = DPO_PROTO_ETHERNET;
8564 is_interface_rx = 1;
8566 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8569 next_hop_proto = DPO_PROTO_ETHERNET;
8570 is_interface_rx = 1;
8572 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8574 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8576 else if (unformat (i, "out-label %d", &next_hop_out_label))
8578 vl_api_fib_mpls_label_t fib_label = {
8579 .label = ntohl (next_hop_out_label),
8583 vec_add1 (next_hop_out_label_stack, fib_label);
8587 clib_warning ("parse error '%U'", format_unformat_error, i);
8592 if (!next_hop_set && !is_classify)
8594 errmsg ("next hop / classify not set");
8598 if (MPLS_LABEL_INVALID == local_label)
8600 errmsg ("missing label");
8606 /* Turn on async mode */
8607 vam->async_mode = 1;
8608 vam->async_errors = 0;
8609 before = vat_time_now (vam);
8612 for (j = 0; j < count; j++)
8614 /* Construct the API message */
8615 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8616 vec_len (next_hop_out_label_stack));
8618 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8619 mp->mr_table_id = ntohl (table_id);
8621 mp->mr_is_add = is_add;
8622 mp->mr_next_hop_proto = next_hop_proto;
8623 mp->mr_is_classify = is_classify;
8624 mp->mr_is_multipath = is_multipath;
8625 mp->mr_is_resolve_host = resolve_host;
8626 mp->mr_is_resolve_attached = resolve_attached;
8627 mp->mr_is_interface_rx = is_interface_rx;
8628 mp->mr_next_hop_weight = next_hop_weight;
8629 mp->mr_next_hop_preference = 0;
8630 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8631 mp->mr_classify_table_index = ntohl (classify_table_index);
8632 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8633 mp->mr_label = ntohl (local_label);
8634 mp->mr_eos = is_eos;
8636 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8637 if (0 != mp->mr_next_hop_n_out_labels)
8639 memcpy (mp->mr_next_hop_out_label_stack,
8640 next_hop_out_label_stack,
8641 vec_len (next_hop_out_label_stack) *
8642 sizeof (vl_api_fib_mpls_label_t));
8643 vec_free (next_hop_out_label_stack);
8648 if (DPO_PROTO_IP4 == next_hop_proto)
8650 clib_memcpy (mp->mr_next_hop,
8651 &v4_next_hop_address,
8652 sizeof (v4_next_hop_address));
8654 else if (DPO_PROTO_IP6 == next_hop_proto)
8657 clib_memcpy (mp->mr_next_hop,
8658 &v6_next_hop_address,
8659 sizeof (v6_next_hop_address));
8666 /* If we receive SIGTERM, stop now... */
8671 /* When testing multiple add/del ops, use a control-ping to sync */
8674 vl_api_control_ping_t *mp_ping;
8678 /* Shut off async mode */
8679 vam->async_mode = 0;
8681 MPING (CONTROL_PING, mp_ping);
8684 timeout = vat_time_now (vam) + 1.0;
8685 while (vat_time_now (vam) < timeout)
8686 if (vam->result_ready == 1)
8691 if (vam->retval == -99)
8694 if (vam->async_errors > 0)
8696 errmsg ("%d asynchronous errors", vam->async_errors);
8699 vam->async_errors = 0;
8700 after = vat_time_now (vam);
8702 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8706 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8707 count, after - before, count / (after - before));
8713 /* Wait for a reply... */
8718 /* Return the good/bad news */
8719 return (vam->retval);
8723 api_mpls_ip_bind_unbind (vat_main_t * vam)
8725 unformat_input_t *i = vam->input;
8726 vl_api_mpls_ip_bind_unbind_t *mp;
8727 u32 ip_table_id = 0;
8730 ip4_address_t v4_address;
8731 ip6_address_t v6_address;
8734 mpls_label_t local_label = MPLS_LABEL_INVALID;
8737 /* Parse args required to build the message */
8738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8740 if (unformat (i, "%U/%d", unformat_ip4_address,
8741 &v4_address, &address_length))
8746 else if (unformat (i, "%U/%d", unformat_ip6_address,
8747 &v6_address, &address_length))
8752 else if (unformat (i, "%d", &local_label))
8754 else if (unformat (i, "table-id %d", &ip_table_id))
8756 else if (unformat (i, "unbind"))
8758 else if (unformat (i, "bind"))
8762 clib_warning ("parse error '%U'", format_unformat_error, i);
8769 errmsg ("IP address not set");
8773 if (MPLS_LABEL_INVALID == local_label)
8775 errmsg ("missing label");
8779 /* Construct the API message */
8780 M (MPLS_IP_BIND_UNBIND, mp);
8782 mp->mb_is_bind = is_bind;
8783 mp->mb_is_ip4 = is_ip4;
8784 mp->mb_ip_table_id = ntohl (ip_table_id);
8785 mp->mb_mpls_table_id = 0;
8786 mp->mb_label = ntohl (local_label);
8787 mp->mb_address_length = address_length;
8790 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8792 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8797 /* Wait for a reply... */
8803 api_sr_mpls_policy_add (vat_main_t * vam)
8805 unformat_input_t *i = vam->input;
8806 vl_api_sr_mpls_policy_add_t *mp;
8812 u32 *segments = NULL;
8815 /* Parse args required to build the message */
8816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8818 if (unformat (i, "bsid %d", &bsid))
8820 else if (unformat (i, "weight %d", &weight))
8822 else if (unformat (i, "spray"))
8824 else if (unformat (i, "next %d", &sid))
8827 vec_add1 (segments, htonl (sid));
8831 clib_warning ("parse error '%U'", format_unformat_error, i);
8838 errmsg ("bsid not set");
8842 if (n_segments == 0)
8844 errmsg ("no sid in segment stack");
8848 /* Construct the API message */
8849 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8851 mp->bsid = htonl (bsid);
8852 mp->weight = htonl (weight);
8854 mp->n_segments = n_segments;
8855 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8856 vec_free (segments);
8861 /* Wait for a reply... */
8867 api_sr_mpls_policy_del (vat_main_t * vam)
8869 unformat_input_t *i = vam->input;
8870 vl_api_sr_mpls_policy_del_t *mp;
8874 /* Parse args required to build the message */
8875 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8877 if (unformat (i, "bsid %d", &bsid))
8881 clib_warning ("parse error '%U'", format_unformat_error, i);
8888 errmsg ("bsid not set");
8892 /* Construct the API message */
8893 M (SR_MPLS_POLICY_DEL, mp);
8895 mp->bsid = htonl (bsid);
8900 /* Wait for a reply... */
8906 api_bier_table_add_del (vat_main_t * vam)
8908 unformat_input_t *i = vam->input;
8909 vl_api_bier_table_add_del_t *mp;
8911 u32 set = 0, sub_domain = 0, hdr_len = 3;
8912 mpls_label_t local_label = MPLS_LABEL_INVALID;
8915 /* Parse args required to build the message */
8916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8918 if (unformat (i, "sub-domain %d", &sub_domain))
8920 else if (unformat (i, "set %d", &set))
8922 else if (unformat (i, "label %d", &local_label))
8924 else if (unformat (i, "hdr-len %d", &hdr_len))
8926 else if (unformat (i, "add"))
8928 else if (unformat (i, "del"))
8932 clib_warning ("parse error '%U'", format_unformat_error, i);
8937 if (MPLS_LABEL_INVALID == local_label)
8939 errmsg ("missing label\n");
8943 /* Construct the API message */
8944 M (BIER_TABLE_ADD_DEL, mp);
8946 mp->bt_is_add = is_add;
8947 mp->bt_label = ntohl (local_label);
8948 mp->bt_tbl_id.bt_set = set;
8949 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8950 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8955 /* Wait for a reply... */
8962 api_bier_route_add_del (vat_main_t * vam)
8964 unformat_input_t *i = vam->input;
8965 vl_api_bier_route_add_del_t *mp;
8967 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8968 ip4_address_t v4_next_hop_address;
8969 ip6_address_t v6_next_hop_address;
8970 u8 next_hop_set = 0;
8971 u8 next_hop_proto_is_ip4 = 1;
8972 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8975 /* Parse args required to build the message */
8976 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8978 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
8980 next_hop_proto_is_ip4 = 1;
8983 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
8985 next_hop_proto_is_ip4 = 0;
8988 if (unformat (i, "sub-domain %d", &sub_domain))
8990 else if (unformat (i, "set %d", &set))
8992 else if (unformat (i, "hdr-len %d", &hdr_len))
8994 else if (unformat (i, "bp %d", &bp))
8996 else if (unformat (i, "add"))
8998 else if (unformat (i, "del"))
9000 else if (unformat (i, "out-label %d", &next_hop_out_label))
9004 clib_warning ("parse error '%U'", format_unformat_error, i);
9009 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9011 errmsg ("next hop / label set\n");
9016 errmsg ("bit=position not set\n");
9020 /* Construct the API message */
9021 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9023 mp->br_is_add = is_add;
9024 mp->br_tbl_id.bt_set = set;
9025 mp->br_tbl_id.bt_sub_domain = sub_domain;
9026 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9027 mp->br_bp = ntohs (bp);
9029 mp->br_paths[0].n_labels = 1;
9030 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9031 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9033 if (next_hop_proto_is_ip4)
9035 clib_memcpy (mp->br_paths[0].next_hop,
9036 &v4_next_hop_address, sizeof (v4_next_hop_address));
9040 clib_memcpy (mp->br_paths[0].next_hop,
9041 &v6_next_hop_address, sizeof (v6_next_hop_address));
9047 /* Wait for a reply... */
9054 api_proxy_arp_add_del (vat_main_t * vam)
9056 unformat_input_t *i = vam->input;
9057 vl_api_proxy_arp_add_del_t *mp;
9060 vl_api_ip4_address_t lo, hi;
9064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9066 if (unformat (i, "vrf %d", &vrf_id))
9068 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
9069 unformat_vl_api_ip4_address, &hi))
9071 else if (unformat (i, "del"))
9075 clib_warning ("parse error '%U'", format_unformat_error, i);
9082 errmsg ("address range not set");
9086 M (PROXY_ARP_ADD_DEL, mp);
9088 mp->proxy.table_id = ntohl (vrf_id);
9089 mp->is_add = is_add;
9090 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
9091 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
9099 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9101 unformat_input_t *i = vam->input;
9102 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9105 u8 sw_if_index_set = 0;
9108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9111 sw_if_index_set = 1;
9112 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9113 sw_if_index_set = 1;
9114 else if (unformat (i, "enable"))
9116 else if (unformat (i, "disable"))
9120 clib_warning ("parse error '%U'", format_unformat_error, i);
9125 if (sw_if_index_set == 0)
9127 errmsg ("missing interface name or sw_if_index");
9131 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9133 mp->sw_if_index = ntohl (sw_if_index);
9134 mp->enable_disable = enable;
9142 api_mpls_tunnel_add_del (vat_main_t * vam)
9144 unformat_input_t *i = vam->input;
9145 vl_api_mpls_tunnel_add_del_t *mp;
9149 u32 sw_if_index = ~0;
9150 u32 next_hop_sw_if_index = ~0;
9151 u32 next_hop_proto_is_ip4 = 1;
9153 u32 next_hop_table_id = 0;
9154 ip4_address_t v4_next_hop_address = {
9157 ip6_address_t v6_next_hop_address = { {0} };
9158 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9159 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9160 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9165 if (unformat (i, "add"))
9169 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9171 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9173 else if (unformat (i, "via %U",
9174 unformat_ip4_address, &v4_next_hop_address))
9176 next_hop_proto_is_ip4 = 1;
9178 else if (unformat (i, "via %U",
9179 unformat_ip6_address, &v6_next_hop_address))
9181 next_hop_proto_is_ip4 = 0;
9183 else if (unformat (i, "via-label %d", &next_hop_via_label))
9187 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9189 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9191 else if (unformat (i, "l2-only"))
9193 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9195 else if (unformat (i, "out-label %d", &next_hop_out_label))
9197 vl_api_fib_mpls_label_t fib_label = {
9198 .label = ntohl (next_hop_out_label),
9202 vec_add1 (next_hop_out_label_stack, fib_label);
9206 clib_warning ("parse error '%U'", format_unformat_error, i);
9211 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9212 vec_len (next_hop_out_label_stack));
9214 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9215 mp->mt_sw_if_index = ntohl (sw_if_index);
9216 mp->mt_is_add = is_add;
9217 mp->mt_l2_only = l2_only;
9218 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9219 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9220 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9221 mp->mt_next_hop_weight = 1;
9222 mp->mt_next_hop_preference = 0;
9224 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9226 if (0 != mp->mt_next_hop_n_out_labels)
9228 clib_memcpy (mp->mt_next_hop_out_label_stack,
9229 next_hop_out_label_stack,
9230 (vec_len (next_hop_out_label_stack) *
9231 sizeof (vl_api_fib_mpls_label_t)));
9232 vec_free (next_hop_out_label_stack);
9235 if (next_hop_proto_is_ip4)
9237 clib_memcpy (mp->mt_next_hop,
9238 &v4_next_hop_address, sizeof (v4_next_hop_address));
9242 clib_memcpy (mp->mt_next_hop,
9243 &v6_next_hop_address, sizeof (v6_next_hop_address));
9252 api_sw_interface_set_unnumbered (vat_main_t * vam)
9254 unformat_input_t *i = vam->input;
9255 vl_api_sw_interface_set_unnumbered_t *mp;
9257 u32 unnum_sw_index = ~0;
9259 u8 sw_if_index_set = 0;
9262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9264 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9265 sw_if_index_set = 1;
9266 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9267 sw_if_index_set = 1;
9268 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9270 else if (unformat (i, "del"))
9274 clib_warning ("parse error '%U'", format_unformat_error, i);
9279 if (sw_if_index_set == 0)
9281 errmsg ("missing interface name or sw_if_index");
9285 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9287 mp->sw_if_index = ntohl (sw_if_index);
9288 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9289 mp->is_add = is_add;
9297 api_ip_neighbor_add_del (vat_main_t * vam)
9299 vl_api_mac_address_t mac_address;
9300 unformat_input_t *i = vam->input;
9301 vl_api_ip_neighbor_add_del_t *mp;
9302 vl_api_address_t ip_address;
9304 u8 sw_if_index_set = 0;
9309 ip_neighbor_flags_t flags;
9311 flags = IP_NEIGHBOR_FLAG_NONE;
9312 clib_memset (&ip_address, 0, sizeof (ip_address));
9313 clib_memset (&mac_address, 0, sizeof (mac_address));
9314 /* Parse args required to build the message */
9315 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9317 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9321 else if (unformat (i, "del"))
9324 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9325 sw_if_index_set = 1;
9326 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9327 sw_if_index_set = 1;
9328 else if (unformat (i, "static"))
9329 flags |= IP_NEIGHBOR_FLAG_STATIC;
9330 else if (unformat (i, "no-fib-entry"))
9331 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9332 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9336 clib_warning ("parse error '%U'", format_unformat_error, i);
9341 if (sw_if_index_set == 0)
9343 errmsg ("missing interface name or sw_if_index");
9348 errmsg ("no address set");
9352 /* Construct the API message */
9353 M (IP_NEIGHBOR_ADD_DEL, mp);
9355 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9356 mp->is_add = is_add;
9357 mp->neighbor.flags = htonl (flags);
9359 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9360 sizeof (mac_address));
9362 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9367 /* Wait for a reply, return good/bad news */
9373 api_create_vlan_subif (vat_main_t * vam)
9375 unformat_input_t *i = vam->input;
9376 vl_api_create_vlan_subif_t *mp;
9378 u8 sw_if_index_set = 0;
9383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9385 if (unformat (i, "sw_if_index %d", &sw_if_index))
9386 sw_if_index_set = 1;
9388 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9389 sw_if_index_set = 1;
9390 else if (unformat (i, "vlan %d", &vlan_id))
9394 clib_warning ("parse error '%U'", format_unformat_error, i);
9399 if (sw_if_index_set == 0)
9401 errmsg ("missing interface name or sw_if_index");
9405 if (vlan_id_set == 0)
9407 errmsg ("missing vlan_id");
9410 M (CREATE_VLAN_SUBIF, mp);
9412 mp->sw_if_index = ntohl (sw_if_index);
9413 mp->vlan_id = ntohl (vlan_id);
9420 #define foreach_create_subif_bit \
9427 _(outer_vlan_id_any) \
9428 _(inner_vlan_id_any)
9430 #define foreach_create_subif_flag \
9435 _(4, "exact_match") \
9436 _(5, "default_sub") \
9437 _(6, "outer_vlan_id_any") \
9438 _(7, "inner_vlan_id_any")
9441 api_create_subif (vat_main_t * vam)
9443 unformat_input_t *i = vam->input;
9444 vl_api_create_subif_t *mp;
9446 u8 sw_if_index_set = 0;
9453 u32 exact_match = 0;
9454 u32 default_sub = 0;
9455 u32 outer_vlan_id_any = 0;
9456 u32 inner_vlan_id_any = 0;
9458 u16 outer_vlan_id = 0;
9459 u16 inner_vlan_id = 0;
9462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9464 if (unformat (i, "sw_if_index %d", &sw_if_index))
9465 sw_if_index_set = 1;
9467 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9468 sw_if_index_set = 1;
9469 else if (unformat (i, "sub_id %d", &sub_id))
9471 else if (unformat (i, "outer_vlan_id %d", &tmp))
9472 outer_vlan_id = tmp;
9473 else if (unformat (i, "inner_vlan_id %d", &tmp))
9474 inner_vlan_id = tmp;
9476 #define _(a) else if (unformat (i, #a)) a = 1 ;
9477 foreach_create_subif_bit
9481 clib_warning ("parse error '%U'", format_unformat_error, i);
9486 if (sw_if_index_set == 0)
9488 errmsg ("missing interface name or sw_if_index");
9492 if (sub_id_set == 0)
9494 errmsg ("missing sub_id");
9497 M (CREATE_SUBIF, mp);
9499 mp->sw_if_index = ntohl (sw_if_index);
9500 mp->sub_id = ntohl (sub_id);
9502 #define _(a,b) mp->sub_if_flags |= (1 << a);
9503 foreach_create_subif_flag;
9506 mp->outer_vlan_id = ntohs (outer_vlan_id);
9507 mp->inner_vlan_id = ntohs (inner_vlan_id);
9515 api_oam_add_del (vat_main_t * vam)
9517 unformat_input_t *i = vam->input;
9518 vl_api_oam_add_del_t *mp;
9521 ip4_address_t src, dst;
9526 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9528 if (unformat (i, "vrf %d", &vrf_id))
9530 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9532 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9534 else if (unformat (i, "del"))
9538 clib_warning ("parse error '%U'", format_unformat_error, i);
9545 errmsg ("missing src addr");
9551 errmsg ("missing dst addr");
9555 M (OAM_ADD_DEL, mp);
9557 mp->vrf_id = ntohl (vrf_id);
9558 mp->is_add = is_add;
9559 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9560 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9568 api_reset_fib (vat_main_t * vam)
9570 unformat_input_t *i = vam->input;
9571 vl_api_reset_fib_t *mp;
9577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9579 if (unformat (i, "vrf %d", &vrf_id))
9581 else if (unformat (i, "ipv6"))
9585 clib_warning ("parse error '%U'", format_unformat_error, i);
9590 if (vrf_id_set == 0)
9592 errmsg ("missing vrf id");
9598 mp->vrf_id = ntohl (vrf_id);
9599 mp->is_ipv6 = is_ipv6;
9607 api_dhcp_proxy_config (vat_main_t * vam)
9609 unformat_input_t *i = vam->input;
9610 vl_api_dhcp_proxy_config_t *mp;
9612 u32 server_vrf_id = 0;
9614 u8 v4_address_set = 0;
9615 u8 v6_address_set = 0;
9616 ip4_address_t v4address;
9617 ip6_address_t v6address;
9618 u8 v4_src_address_set = 0;
9619 u8 v6_src_address_set = 0;
9620 ip4_address_t v4srcaddress;
9621 ip6_address_t v6srcaddress;
9624 /* Parse args required to build the message */
9625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9627 if (unformat (i, "del"))
9629 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9631 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9633 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9635 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9637 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9638 v4_src_address_set = 1;
9639 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9640 v6_src_address_set = 1;
9645 if (v4_address_set && v6_address_set)
9647 errmsg ("both v4 and v6 server addresses set");
9650 if (!v4_address_set && !v6_address_set)
9652 errmsg ("no server addresses set");
9656 if (v4_src_address_set && v6_src_address_set)
9658 errmsg ("both v4 and v6 src addresses set");
9661 if (!v4_src_address_set && !v6_src_address_set)
9663 errmsg ("no src addresses set");
9667 if (!(v4_src_address_set && v4_address_set) &&
9668 !(v6_src_address_set && v6_address_set))
9670 errmsg ("no matching server and src addresses set");
9674 /* Construct the API message */
9675 M (DHCP_PROXY_CONFIG, mp);
9677 mp->is_add = is_add;
9678 mp->rx_vrf_id = ntohl (rx_vrf_id);
9679 mp->server_vrf_id = ntohl (server_vrf_id);
9683 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9684 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9688 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9689 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9695 /* Wait for a reply, return good/bad news */
9700 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9701 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9704 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9706 vat_main_t *vam = &vat_main;
9707 u32 i, count = mp->count;
9708 vl_api_dhcp_server_t *s;
9712 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9713 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9714 ntohl (mp->rx_vrf_id),
9715 format_ip6_address, mp->dhcp_src_address,
9716 mp->vss_type, mp->vss_vpn_ascii_id,
9717 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9720 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9721 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9722 ntohl (mp->rx_vrf_id),
9723 format_ip4_address, mp->dhcp_src_address,
9724 mp->vss_type, mp->vss_vpn_ascii_id,
9725 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9727 for (i = 0; i < count; i++)
9729 s = &mp->servers[i];
9733 " Server Table-ID %d, Server Address %U",
9734 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9737 " Server Table-ID %d, Server Address %U",
9738 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9742 static void vl_api_dhcp_proxy_details_t_handler_json
9743 (vl_api_dhcp_proxy_details_t * mp)
9745 vat_main_t *vam = &vat_main;
9746 vat_json_node_t *node = NULL;
9747 u32 i, count = mp->count;
9749 struct in6_addr ip6;
9750 vl_api_dhcp_server_t *s;
9752 if (VAT_JSON_ARRAY != vam->json_tree.type)
9754 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9755 vat_json_init_array (&vam->json_tree);
9757 node = vat_json_array_add (&vam->json_tree);
9759 vat_json_init_object (node);
9760 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9761 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9762 sizeof (mp->vss_type));
9763 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9764 mp->vss_vpn_ascii_id);
9765 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9766 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9770 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9771 vat_json_object_add_ip6 (node, "src_address", ip6);
9775 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9776 vat_json_object_add_ip4 (node, "src_address", ip4);
9779 for (i = 0; i < count; i++)
9781 s = &mp->servers[i];
9783 vat_json_object_add_uint (node, "server-table-id",
9784 ntohl (s->server_vrf_id));
9788 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9789 vat_json_object_add_ip4 (node, "src_address", ip4);
9793 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9794 vat_json_object_add_ip6 (node, "server_address", ip6);
9800 api_dhcp_proxy_dump (vat_main_t * vam)
9802 unformat_input_t *i = vam->input;
9803 vl_api_control_ping_t *mp_ping;
9804 vl_api_dhcp_proxy_dump_t *mp;
9808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9810 if (unformat (i, "ipv6"))
9814 clib_warning ("parse error '%U'", format_unformat_error, i);
9819 M (DHCP_PROXY_DUMP, mp);
9821 mp->is_ip6 = is_ipv6;
9824 /* Use a control ping for synchronization */
9825 MPING (CONTROL_PING, mp_ping);
9833 api_dhcp_proxy_set_vss (vat_main_t * vam)
9835 unformat_input_t *i = vam->input;
9836 vl_api_dhcp_proxy_set_vss_t *mp;
9840 u8 vss_type = VSS_TYPE_DEFAULT;
9841 u8 *vpn_ascii_id = 0;
9846 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9848 if (unformat (i, "tbl_id %d", &tbl_id))
9850 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9851 vss_type = VSS_TYPE_ASCII;
9852 else if (unformat (i, "fib_id %d", &fib_id))
9853 vss_type = VSS_TYPE_VPN_ID;
9854 else if (unformat (i, "oui %d", &oui))
9855 vss_type = VSS_TYPE_VPN_ID;
9856 else if (unformat (i, "ipv6"))
9858 else if (unformat (i, "del"))
9866 errmsg ("missing tbl_id ");
9867 vec_free (vpn_ascii_id);
9871 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9873 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9874 vec_free (vpn_ascii_id);
9878 M (DHCP_PROXY_SET_VSS, mp);
9879 mp->tbl_id = ntohl (tbl_id);
9880 mp->vss_type = vss_type;
9883 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9884 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9886 mp->vpn_index = ntohl (fib_id);
9887 mp->oui = ntohl (oui);
9888 mp->is_ipv6 = is_ipv6;
9889 mp->is_add = is_add;
9894 vec_free (vpn_ascii_id);
9899 api_dhcp_client_config (vat_main_t * vam)
9901 unformat_input_t *i = vam->input;
9902 vl_api_dhcp_client_config_t *mp;
9904 u8 sw_if_index_set = 0;
9907 u8 disable_event = 0;
9910 /* Parse args required to build the message */
9911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9913 if (unformat (i, "del"))
9916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9917 sw_if_index_set = 1;
9918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9919 sw_if_index_set = 1;
9920 else if (unformat (i, "hostname %s", &hostname))
9922 else if (unformat (i, "disable_event"))
9928 if (sw_if_index_set == 0)
9930 errmsg ("missing interface name or sw_if_index");
9934 if (vec_len (hostname) > 63)
9936 errmsg ("hostname too long");
9938 vec_add1 (hostname, 0);
9940 /* Construct the API message */
9941 M (DHCP_CLIENT_CONFIG, mp);
9943 mp->is_add = is_add;
9944 mp->client.sw_if_index = htonl (sw_if_index);
9945 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9946 vec_free (hostname);
9947 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9948 mp->client.pid = htonl (getpid ());
9953 /* Wait for a reply, return good/bad news */
9959 api_set_ip_flow_hash (vat_main_t * vam)
9961 unformat_input_t *i = vam->input;
9962 vl_api_set_ip_flow_hash_t *mp;
9974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9976 if (unformat (i, "vrf %d", &vrf_id))
9978 else if (unformat (i, "ipv6"))
9980 else if (unformat (i, "src"))
9982 else if (unformat (i, "dst"))
9984 else if (unformat (i, "sport"))
9986 else if (unformat (i, "dport"))
9988 else if (unformat (i, "proto"))
9990 else if (unformat (i, "reverse"))
9995 clib_warning ("parse error '%U'", format_unformat_error, i);
10000 if (vrf_id_set == 0)
10002 errmsg ("missing vrf id");
10006 M (SET_IP_FLOW_HASH, mp);
10012 mp->reverse = reverse;
10013 mp->vrf_id = ntohl (vrf_id);
10014 mp->is_ipv6 = is_ipv6;
10022 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10024 unformat_input_t *i = vam->input;
10025 vl_api_sw_interface_ip6_enable_disable_t *mp;
10027 u8 sw_if_index_set = 0;
10031 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10033 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10034 sw_if_index_set = 1;
10035 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10036 sw_if_index_set = 1;
10037 else if (unformat (i, "enable"))
10039 else if (unformat (i, "disable"))
10043 clib_warning ("parse error '%U'", format_unformat_error, i);
10048 if (sw_if_index_set == 0)
10050 errmsg ("missing interface name or sw_if_index");
10054 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10056 mp->sw_if_index = ntohl (sw_if_index);
10057 mp->enable = enable;
10065 api_ip6nd_proxy_add_del (vat_main_t * vam)
10067 unformat_input_t *i = vam->input;
10068 vl_api_ip6nd_proxy_add_del_t *mp;
10069 u32 sw_if_index = ~0;
10070 u8 v6_address_set = 0;
10071 vl_api_ip6_address_t v6address;
10075 /* Parse args required to build the message */
10076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10078 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10080 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10082 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
10083 v6_address_set = 1;
10084 if (unformat (i, "del"))
10088 clib_warning ("parse error '%U'", format_unformat_error, i);
10093 if (sw_if_index == ~0)
10095 errmsg ("missing interface name or sw_if_index");
10098 if (!v6_address_set)
10100 errmsg ("no address set");
10104 /* Construct the API message */
10105 M (IP6ND_PROXY_ADD_DEL, mp);
10107 mp->is_del = is_del;
10108 mp->sw_if_index = ntohl (sw_if_index);
10109 clib_memcpy (mp->ip, v6address, sizeof (v6address));
10114 /* Wait for a reply, return good/bad news */
10120 api_ip6nd_proxy_dump (vat_main_t * vam)
10122 vl_api_ip6nd_proxy_dump_t *mp;
10123 vl_api_control_ping_t *mp_ping;
10126 M (IP6ND_PROXY_DUMP, mp);
10130 /* Use a control ping for synchronization */
10131 MPING (CONTROL_PING, mp_ping);
10138 static void vl_api_ip6nd_proxy_details_t_handler
10139 (vl_api_ip6nd_proxy_details_t * mp)
10141 vat_main_t *vam = &vat_main;
10143 print (vam->ofp, "host %U sw_if_index %d",
10144 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
10147 static void vl_api_ip6nd_proxy_details_t_handler_json
10148 (vl_api_ip6nd_proxy_details_t * mp)
10150 vat_main_t *vam = &vat_main;
10151 struct in6_addr ip6;
10152 vat_json_node_t *node = NULL;
10154 if (VAT_JSON_ARRAY != vam->json_tree.type)
10156 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10157 vat_json_init_array (&vam->json_tree);
10159 node = vat_json_array_add (&vam->json_tree);
10161 vat_json_init_object (node);
10162 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10164 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
10165 vat_json_object_add_ip6 (node, "host", ip6);
10169 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10171 unformat_input_t *i = vam->input;
10172 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10174 u8 sw_if_index_set = 0;
10175 u32 address_length = 0;
10176 u8 v6_address_set = 0;
10177 vl_api_prefix_t pfx;
10178 u8 use_default = 0;
10179 u8 no_advertise = 0;
10181 u8 no_autoconfig = 0;
10184 u32 val_lifetime = 0;
10185 u32 pref_lifetime = 0;
10188 /* Parse args required to build the message */
10189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10192 sw_if_index_set = 1;
10193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10194 sw_if_index_set = 1;
10195 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
10196 v6_address_set = 1;
10197 else if (unformat (i, "val_life %d", &val_lifetime))
10199 else if (unformat (i, "pref_life %d", &pref_lifetime))
10201 else if (unformat (i, "def"))
10203 else if (unformat (i, "noadv"))
10205 else if (unformat (i, "offl"))
10207 else if (unformat (i, "noauto"))
10209 else if (unformat (i, "nolink"))
10211 else if (unformat (i, "isno"))
10215 clib_warning ("parse error '%U'", format_unformat_error, i);
10220 if (sw_if_index_set == 0)
10222 errmsg ("missing interface name or sw_if_index");
10225 if (!v6_address_set)
10227 errmsg ("no address set");
10231 /* Construct the API message */
10232 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10234 mp->sw_if_index = ntohl (sw_if_index);
10235 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
10236 mp->use_default = use_default;
10237 mp->no_advertise = no_advertise;
10238 mp->off_link = off_link;
10239 mp->no_autoconfig = no_autoconfig;
10240 mp->no_onlink = no_onlink;
10242 mp->val_lifetime = ntohl (val_lifetime);
10243 mp->pref_lifetime = ntohl (pref_lifetime);
10248 /* Wait for a reply, return good/bad news */
10254 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10256 unformat_input_t *i = vam->input;
10257 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10259 u8 sw_if_index_set = 0;
10264 u8 send_unicast = 0;
10267 u8 default_router = 0;
10268 u32 max_interval = 0;
10269 u32 min_interval = 0;
10271 u32 initial_count = 0;
10272 u32 initial_interval = 0;
10276 /* Parse args required to build the message */
10277 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10279 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10280 sw_if_index_set = 1;
10281 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10282 sw_if_index_set = 1;
10283 else if (unformat (i, "maxint %d", &max_interval))
10285 else if (unformat (i, "minint %d", &min_interval))
10287 else if (unformat (i, "life %d", &lifetime))
10289 else if (unformat (i, "count %d", &initial_count))
10291 else if (unformat (i, "interval %d", &initial_interval))
10293 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10295 else if (unformat (i, "managed"))
10297 else if (unformat (i, "other"))
10299 else if (unformat (i, "ll"))
10301 else if (unformat (i, "send"))
10303 else if (unformat (i, "cease"))
10305 else if (unformat (i, "isno"))
10307 else if (unformat (i, "def"))
10308 default_router = 1;
10311 clib_warning ("parse error '%U'", format_unformat_error, i);
10316 if (sw_if_index_set == 0)
10318 errmsg ("missing interface name or sw_if_index");
10322 /* Construct the API message */
10323 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10325 mp->sw_if_index = ntohl (sw_if_index);
10326 mp->max_interval = ntohl (max_interval);
10327 mp->min_interval = ntohl (min_interval);
10328 mp->lifetime = ntohl (lifetime);
10329 mp->initial_count = ntohl (initial_count);
10330 mp->initial_interval = ntohl (initial_interval);
10331 mp->suppress = suppress;
10332 mp->managed = managed;
10334 mp->ll_option = ll_option;
10335 mp->send_unicast = send_unicast;
10338 mp->default_router = default_router;
10343 /* Wait for a reply, return good/bad news */
10349 api_set_arp_neighbor_limit (vat_main_t * vam)
10351 unformat_input_t *i = vam->input;
10352 vl_api_set_arp_neighbor_limit_t *mp;
10358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10360 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10362 else if (unformat (i, "ipv6"))
10366 clib_warning ("parse error '%U'", format_unformat_error, i);
10371 if (limit_set == 0)
10373 errmsg ("missing limit value");
10377 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10379 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10380 mp->is_ipv6 = is_ipv6;
10388 api_l2_patch_add_del (vat_main_t * vam)
10390 unformat_input_t *i = vam->input;
10391 vl_api_l2_patch_add_del_t *mp;
10392 u32 rx_sw_if_index;
10393 u8 rx_sw_if_index_set = 0;
10394 u32 tx_sw_if_index;
10395 u8 tx_sw_if_index_set = 0;
10399 /* Parse args required to build the message */
10400 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10402 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10403 rx_sw_if_index_set = 1;
10404 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10405 tx_sw_if_index_set = 1;
10406 else if (unformat (i, "rx"))
10408 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10410 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10412 rx_sw_if_index_set = 1;
10417 else if (unformat (i, "tx"))
10419 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10421 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10423 tx_sw_if_index_set = 1;
10428 else if (unformat (i, "del"))
10434 if (rx_sw_if_index_set == 0)
10436 errmsg ("missing rx interface name or rx_sw_if_index");
10440 if (tx_sw_if_index_set == 0)
10442 errmsg ("missing tx interface name or tx_sw_if_index");
10446 M (L2_PATCH_ADD_DEL, mp);
10448 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10449 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10450 mp->is_add = is_add;
10458 u8 localsid_addr[16];
10467 api_sr_localsid_add_del (vat_main_t * vam)
10469 unformat_input_t *i = vam->input;
10470 vl_api_sr_localsid_add_del_t *mp;
10473 ip6_address_t localsid;
10477 u32 fib_table = ~(u32) 0;
10478 ip6_address_t nh_addr6;
10479 ip4_address_t nh_addr4;
10480 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10481 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10483 bool nexthop_set = 0;
10487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10489 if (unformat (i, "del"))
10491 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10492 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10494 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10496 else if (unformat (i, "behavior %u", &behavior));
10497 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10498 else if (unformat (i, "fib-table %u", &fib_table));
10499 else if (unformat (i, "end.psp %u", &behavior));
10504 M (SR_LOCALSID_ADD_DEL, mp);
10506 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10509 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10510 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10512 mp->behavior = behavior;
10513 mp->sw_if_index = ntohl (sw_if_index);
10514 mp->fib_table = ntohl (fib_table);
10515 mp->end_psp = end_psp;
10516 mp->is_del = is_del;
10524 api_ioam_enable (vat_main_t * vam)
10526 unformat_input_t *input = vam->input;
10527 vl_api_ioam_enable_t *mp;
10529 int has_trace_option = 0;
10530 int has_pot_option = 0;
10531 int has_seqno_option = 0;
10532 int has_analyse_option = 0;
10535 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10537 if (unformat (input, "trace"))
10538 has_trace_option = 1;
10539 else if (unformat (input, "pot"))
10540 has_pot_option = 1;
10541 else if (unformat (input, "seqno"))
10542 has_seqno_option = 1;
10543 else if (unformat (input, "analyse"))
10544 has_analyse_option = 1;
10548 M (IOAM_ENABLE, mp);
10549 mp->id = htons (id);
10550 mp->seqno = has_seqno_option;
10551 mp->analyse = has_analyse_option;
10552 mp->pot_enable = has_pot_option;
10553 mp->trace_enable = has_trace_option;
10562 api_ioam_disable (vat_main_t * vam)
10564 vl_api_ioam_disable_t *mp;
10567 M (IOAM_DISABLE, mp);
10573 #define foreach_tcp_proto_field \
10577 #define foreach_udp_proto_field \
10581 #define foreach_ip4_proto_field \
10593 u16 src_port, dst_port;
10596 #if VPP_API_TEST_BUILTIN == 0
10598 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10600 u8 **maskp = va_arg (*args, u8 **);
10602 u8 found_something = 0;
10605 #define _(a) u8 a=0;
10606 foreach_tcp_proto_field;
10609 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10612 #define _(a) else if (unformat (input, #a)) a=1;
10613 foreach_tcp_proto_field
10619 #define _(a) found_something += a;
10620 foreach_tcp_proto_field;
10623 if (found_something == 0)
10626 vec_validate (mask, sizeof (*tcp) - 1);
10628 tcp = (tcp_header_t *) mask;
10630 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10631 foreach_tcp_proto_field;
10639 unformat_udp_mask (unformat_input_t * input, va_list * args)
10641 u8 **maskp = va_arg (*args, u8 **);
10643 u8 found_something = 0;
10646 #define _(a) u8 a=0;
10647 foreach_udp_proto_field;
10650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10653 #define _(a) else if (unformat (input, #a)) a=1;
10654 foreach_udp_proto_field
10660 #define _(a) found_something += a;
10661 foreach_udp_proto_field;
10664 if (found_something == 0)
10667 vec_validate (mask, sizeof (*udp) - 1);
10669 udp = (udp_header_t *) mask;
10671 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10672 foreach_udp_proto_field;
10680 unformat_l4_mask (unformat_input_t * input, va_list * args)
10682 u8 **maskp = va_arg (*args, u8 **);
10683 u16 src_port = 0, dst_port = 0;
10684 tcpudp_header_t *tcpudp;
10686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10688 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10690 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10692 else if (unformat (input, "src_port"))
10694 else if (unformat (input, "dst_port"))
10700 if (!src_port && !dst_port)
10704 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10706 tcpudp = (tcpudp_header_t *) mask;
10707 tcpudp->src_port = src_port;
10708 tcpudp->dst_port = dst_port;
10716 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10718 u8 **maskp = va_arg (*args, u8 **);
10720 u8 found_something = 0;
10723 #define _(a) u8 a=0;
10724 foreach_ip4_proto_field;
10730 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10732 if (unformat (input, "version"))
10734 else if (unformat (input, "hdr_length"))
10736 else if (unformat (input, "src"))
10738 else if (unformat (input, "dst"))
10740 else if (unformat (input, "proto"))
10743 #define _(a) else if (unformat (input, #a)) a=1;
10744 foreach_ip4_proto_field
10750 #define _(a) found_something += a;
10751 foreach_ip4_proto_field;
10754 if (found_something == 0)
10757 vec_validate (mask, sizeof (*ip) - 1);
10759 ip = (ip4_header_t *) mask;
10761 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10762 foreach_ip4_proto_field;
10765 ip->ip_version_and_header_length = 0;
10768 ip->ip_version_and_header_length |= 0xF0;
10771 ip->ip_version_and_header_length |= 0x0F;
10777 #define foreach_ip6_proto_field \
10780 _(payload_length) \
10785 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10787 u8 **maskp = va_arg (*args, u8 **);
10789 u8 found_something = 0;
10791 u32 ip_version_traffic_class_and_flow_label;
10793 #define _(a) u8 a=0;
10794 foreach_ip6_proto_field;
10797 u8 traffic_class = 0;
10800 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10802 if (unformat (input, "version"))
10804 else if (unformat (input, "traffic-class"))
10806 else if (unformat (input, "flow-label"))
10808 else if (unformat (input, "src"))
10810 else if (unformat (input, "dst"))
10812 else if (unformat (input, "proto"))
10815 #define _(a) else if (unformat (input, #a)) a=1;
10816 foreach_ip6_proto_field
10822 #define _(a) found_something += a;
10823 foreach_ip6_proto_field;
10826 if (found_something == 0)
10829 vec_validate (mask, sizeof (*ip) - 1);
10831 ip = (ip6_header_t *) mask;
10833 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10834 foreach_ip6_proto_field;
10837 ip_version_traffic_class_and_flow_label = 0;
10840 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10843 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10846 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10848 ip->ip_version_traffic_class_and_flow_label =
10849 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10856 unformat_l3_mask (unformat_input_t * input, va_list * args)
10858 u8 **maskp = va_arg (*args, u8 **);
10860 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10862 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10864 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10873 unformat_l2_mask (unformat_input_t * input, va_list * args)
10875 u8 **maskp = va_arg (*args, u8 **);
10882 u8 ignore_tag1 = 0;
10883 u8 ignore_tag2 = 0;
10890 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10892 if (unformat (input, "src"))
10894 else if (unformat (input, "dst"))
10896 else if (unformat (input, "proto"))
10898 else if (unformat (input, "tag1"))
10900 else if (unformat (input, "tag2"))
10902 else if (unformat (input, "ignore-tag1"))
10904 else if (unformat (input, "ignore-tag2"))
10906 else if (unformat (input, "cos1"))
10908 else if (unformat (input, "cos2"))
10910 else if (unformat (input, "dot1q"))
10912 else if (unformat (input, "dot1ad"))
10917 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10918 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10921 if (tag1 || ignore_tag1 || cos1 || dot1q)
10923 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10926 vec_validate (mask, len - 1);
10929 clib_memset (mask, 0xff, 6);
10932 clib_memset (mask + 6, 0xff, 6);
10934 if (tag2 || dot1ad)
10936 /* inner vlan tag */
10945 mask[21] = mask[20] = 0xff;
10966 mask[16] = mask[17] = 0xff;
10976 mask[12] = mask[13] = 0xff;
10983 unformat_classify_mask (unformat_input_t * input, va_list * args)
10985 u8 **maskp = va_arg (*args, u8 **);
10986 u32 *skipp = va_arg (*args, u32 *);
10987 u32 *matchp = va_arg (*args, u32 *);
10995 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10997 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10999 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11001 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11003 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11017 if (mask || l2 || l3 || l4)
11019 if (l2 || l3 || l4)
11021 /* "With a free Ethernet header in every package" */
11023 vec_validate (l2, 13);
11027 vec_append (mask, l3);
11032 vec_append (mask, l4);
11037 /* Scan forward looking for the first significant mask octet */
11038 for (i = 0; i < vec_len (mask); i++)
11042 /* compute (skip, match) params */
11043 *skipp = i / sizeof (u32x4);
11044 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11046 /* Pad mask to an even multiple of the vector size */
11047 while (vec_len (mask) % sizeof (u32x4))
11048 vec_add1 (mask, 0);
11050 match = vec_len (mask) / sizeof (u32x4);
11052 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11054 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11055 if (*tmp || *(tmp + 1))
11060 clib_warning ("BUG: match 0");
11062 _vec_len (mask) = match * sizeof (u32x4);
11072 #endif /* VPP_API_TEST_BUILTIN */
11074 #define foreach_l2_next \
11076 _(ethernet, ETHERNET_INPUT) \
11077 _(ip4, IP4_INPUT) \
11081 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11083 u32 *miss_next_indexp = va_arg (*args, u32 *);
11084 u32 next_index = 0;
11088 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11092 if (unformat (input, "%d", &tmp))
11101 *miss_next_indexp = next_index;
11105 #define foreach_ip_next \
11108 _(rewrite, REWRITE)
11111 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11113 u32 *miss_next_indexp = va_arg (*args, u32 *);
11114 u32 next_index = 0;
11118 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11122 if (unformat (input, "%d", &tmp))
11131 *miss_next_indexp = next_index;
11135 #define foreach_acl_next \
11139 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11141 u32 *miss_next_indexp = va_arg (*args, u32 *);
11142 u32 next_index = 0;
11146 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11150 if (unformat (input, "permit"))
11155 else if (unformat (input, "%d", &tmp))
11164 *miss_next_indexp = next_index;
11169 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11171 u32 *r = va_arg (*args, u32 *);
11173 if (unformat (input, "conform-color"))
11174 *r = POLICE_CONFORM;
11175 else if (unformat (input, "exceed-color"))
11176 *r = POLICE_EXCEED;
11184 api_classify_add_del_table (vat_main_t * vam)
11186 unformat_input_t *i = vam->input;
11187 vl_api_classify_add_del_table_t *mp;
11194 u32 table_index = ~0;
11195 u32 next_table_index = ~0;
11196 u32 miss_next_index = ~0;
11197 u32 memory_size = 32 << 20;
11199 u32 current_data_flag = 0;
11200 int current_data_offset = 0;
11203 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11205 if (unformat (i, "del"))
11207 else if (unformat (i, "del-chain"))
11212 else if (unformat (i, "buckets %d", &nbuckets))
11214 else if (unformat (i, "memory_size %d", &memory_size))
11216 else if (unformat (i, "skip %d", &skip))
11218 else if (unformat (i, "match %d", &match))
11220 else if (unformat (i, "table %d", &table_index))
11222 else if (unformat (i, "mask %U", unformat_classify_mask,
11223 &mask, &skip, &match))
11225 else if (unformat (i, "next-table %d", &next_table_index))
11227 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11230 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11233 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11236 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11238 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11244 if (is_add && mask == 0)
11246 errmsg ("Mask required");
11250 if (is_add && skip == ~0)
11252 errmsg ("skip count required");
11256 if (is_add && match == ~0)
11258 errmsg ("match count required");
11262 if (!is_add && table_index == ~0)
11264 errmsg ("table index required for delete");
11268 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11270 mp->is_add = is_add;
11271 mp->del_chain = del_chain;
11272 mp->table_index = ntohl (table_index);
11273 mp->nbuckets = ntohl (nbuckets);
11274 mp->memory_size = ntohl (memory_size);
11275 mp->skip_n_vectors = ntohl (skip);
11276 mp->match_n_vectors = ntohl (match);
11277 mp->next_table_index = ntohl (next_table_index);
11278 mp->miss_next_index = ntohl (miss_next_index);
11279 mp->current_data_flag = ntohl (current_data_flag);
11280 mp->current_data_offset = ntohl (current_data_offset);
11281 mp->mask_len = ntohl (vec_len (mask));
11282 clib_memcpy (mp->mask, mask, vec_len (mask));
11291 #if VPP_API_TEST_BUILTIN == 0
11293 unformat_l4_match (unformat_input_t * input, va_list * args)
11295 u8 **matchp = va_arg (*args, u8 **);
11297 u8 *proto_header = 0;
11303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11305 if (unformat (input, "src_port %d", &src_port))
11307 else if (unformat (input, "dst_port %d", &dst_port))
11313 h.src_port = clib_host_to_net_u16 (src_port);
11314 h.dst_port = clib_host_to_net_u16 (dst_port);
11315 vec_validate (proto_header, sizeof (h) - 1);
11316 memcpy (proto_header, &h, sizeof (h));
11318 *matchp = proto_header;
11324 unformat_ip4_match (unformat_input_t * input, va_list * args)
11326 u8 **matchp = va_arg (*args, u8 **);
11331 int hdr_length = 0;
11332 u32 hdr_length_val;
11333 int src = 0, dst = 0;
11334 ip4_address_t src_val, dst_val;
11341 int fragment_id = 0;
11342 u32 fragment_id_val;
11348 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11350 if (unformat (input, "version %d", &version_val))
11352 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11354 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11356 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11358 else if (unformat (input, "proto %d", &proto_val))
11360 else if (unformat (input, "tos %d", &tos_val))
11362 else if (unformat (input, "length %d", &length_val))
11364 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11366 else if (unformat (input, "ttl %d", &ttl_val))
11368 else if (unformat (input, "checksum %d", &checksum_val))
11374 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11375 + ttl + checksum == 0)
11379 * Aligned because we use the real comparison functions
11381 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11383 ip = (ip4_header_t *) match;
11385 /* These are realistically matched in practice */
11387 ip->src_address.as_u32 = src_val.as_u32;
11390 ip->dst_address.as_u32 = dst_val.as_u32;
11393 ip->protocol = proto_val;
11396 /* These are not, but they're included for completeness */
11398 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11401 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11407 ip->length = clib_host_to_net_u16 (length_val);
11413 ip->checksum = clib_host_to_net_u16 (checksum_val);
11420 unformat_ip6_match (unformat_input_t * input, va_list * args)
11422 u8 **matchp = va_arg (*args, u8 **);
11427 u8 traffic_class = 0;
11428 u32 traffic_class_val = 0;
11431 int src = 0, dst = 0;
11432 ip6_address_t src_val, dst_val;
11435 int payload_length = 0;
11436 u32 payload_length_val;
11439 u32 ip_version_traffic_class_and_flow_label;
11441 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11443 if (unformat (input, "version %d", &version_val))
11445 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11447 else if (unformat (input, "flow_label %d", &flow_label_val))
11449 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11451 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11453 else if (unformat (input, "proto %d", &proto_val))
11455 else if (unformat (input, "payload_length %d", &payload_length_val))
11456 payload_length = 1;
11457 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11463 if (version + traffic_class + flow_label + src + dst + proto +
11464 payload_length + hop_limit == 0)
11468 * Aligned because we use the real comparison functions
11470 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11472 ip = (ip6_header_t *) match;
11475 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11478 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11481 ip->protocol = proto_val;
11483 ip_version_traffic_class_and_flow_label = 0;
11486 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11489 ip_version_traffic_class_and_flow_label |=
11490 (traffic_class_val & 0xFF) << 20;
11493 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11495 ip->ip_version_traffic_class_and_flow_label =
11496 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11498 if (payload_length)
11499 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11502 ip->hop_limit = hop_limit_val;
11509 unformat_l3_match (unformat_input_t * input, va_list * args)
11511 u8 **matchp = va_arg (*args, u8 **);
11513 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11515 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11517 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11526 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11528 u8 *tagp = va_arg (*args, u8 *);
11531 if (unformat (input, "%d", &tag))
11533 tagp[0] = (tag >> 8) & 0x0F;
11534 tagp[1] = tag & 0xFF;
11542 unformat_l2_match (unformat_input_t * input, va_list * args)
11544 u8 **matchp = va_arg (*args, u8 **);
11557 u8 ignore_tag1 = 0;
11558 u8 ignore_tag2 = 0;
11564 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11566 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11569 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11571 else if (unformat (input, "proto %U",
11572 unformat_ethernet_type_host_byte_order, &proto_val))
11574 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11576 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11578 else if (unformat (input, "ignore-tag1"))
11580 else if (unformat (input, "ignore-tag2"))
11582 else if (unformat (input, "cos1 %d", &cos1_val))
11584 else if (unformat (input, "cos2 %d", &cos2_val))
11589 if ((src + dst + proto + tag1 + tag2 +
11590 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11593 if (tag1 || ignore_tag1 || cos1)
11595 if (tag2 || ignore_tag2 || cos2)
11598 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11601 clib_memcpy (match, dst_val, 6);
11604 clib_memcpy (match + 6, src_val, 6);
11608 /* inner vlan tag */
11609 match[19] = tag2_val[1];
11610 match[18] = tag2_val[0];
11612 match[18] |= (cos2_val & 0x7) << 5;
11615 match[21] = proto_val & 0xff;
11616 match[20] = proto_val >> 8;
11620 match[15] = tag1_val[1];
11621 match[14] = tag1_val[0];
11624 match[14] |= (cos1_val & 0x7) << 5;
11630 match[15] = tag1_val[1];
11631 match[14] = tag1_val[0];
11634 match[17] = proto_val & 0xff;
11635 match[16] = proto_val >> 8;
11638 match[14] |= (cos1_val & 0x7) << 5;
11644 match[18] |= (cos2_val & 0x7) << 5;
11646 match[14] |= (cos1_val & 0x7) << 5;
11649 match[13] = proto_val & 0xff;
11650 match[12] = proto_val >> 8;
11658 unformat_qos_source (unformat_input_t * input, va_list * args)
11660 int *qs = va_arg (*args, int *);
11662 if (unformat (input, "ip"))
11663 *qs = QOS_SOURCE_IP;
11664 else if (unformat (input, "mpls"))
11665 *qs = QOS_SOURCE_MPLS;
11666 else if (unformat (input, "ext"))
11667 *qs = QOS_SOURCE_EXT;
11668 else if (unformat (input, "vlan"))
11669 *qs = QOS_SOURCE_VLAN;
11678 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11680 u8 **matchp = va_arg (*args, u8 **);
11681 u32 skip_n_vectors = va_arg (*args, u32);
11682 u32 match_n_vectors = va_arg (*args, u32);
11689 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11691 if (unformat (input, "hex %U", unformat_hex_string, &match))
11693 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11695 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11697 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11711 if (match || l2 || l3 || l4)
11713 if (l2 || l3 || l4)
11715 /* "Win a free Ethernet header in every packet" */
11717 vec_validate_aligned (l2, 13, sizeof (u32x4));
11721 vec_append_aligned (match, l3, sizeof (u32x4));
11726 vec_append_aligned (match, l4, sizeof (u32x4));
11731 /* Make sure the vector is big enough even if key is all 0's */
11732 vec_validate_aligned
11733 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11736 /* Set size, include skipped vectors */
11737 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11748 api_classify_add_del_session (vat_main_t * vam)
11750 unformat_input_t *i = vam->input;
11751 vl_api_classify_add_del_session_t *mp;
11753 u32 table_index = ~0;
11754 u32 hit_next_index = ~0;
11755 u32 opaque_index = ~0;
11758 u32 skip_n_vectors = 0;
11759 u32 match_n_vectors = 0;
11765 * Warning: you have to supply skip_n and match_n
11766 * because the API client cant simply look at the classify
11770 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11772 if (unformat (i, "del"))
11774 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11777 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11780 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11783 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11785 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11787 else if (unformat (i, "opaque-index %d", &opaque_index))
11789 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11791 else if (unformat (i, "match_n %d", &match_n_vectors))
11793 else if (unformat (i, "match %U", api_unformat_classify_match,
11794 &match, skip_n_vectors, match_n_vectors))
11796 else if (unformat (i, "advance %d", &advance))
11798 else if (unformat (i, "table-index %d", &table_index))
11800 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11802 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11804 else if (unformat (i, "action %d", &action))
11806 else if (unformat (i, "metadata %d", &metadata))
11812 if (table_index == ~0)
11814 errmsg ("Table index required");
11818 if (is_add && match == 0)
11820 errmsg ("Match value required");
11824 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11826 mp->is_add = is_add;
11827 mp->table_index = ntohl (table_index);
11828 mp->hit_next_index = ntohl (hit_next_index);
11829 mp->opaque_index = ntohl (opaque_index);
11830 mp->advance = ntohl (advance);
11831 mp->action = action;
11832 mp->metadata = ntohl (metadata);
11833 mp->match_len = ntohl (vec_len (match));
11834 clib_memcpy (mp->match, match, vec_len (match));
11843 api_classify_set_interface_ip_table (vat_main_t * vam)
11845 unformat_input_t *i = vam->input;
11846 vl_api_classify_set_interface_ip_table_t *mp;
11848 int sw_if_index_set;
11849 u32 table_index = ~0;
11853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11855 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11856 sw_if_index_set = 1;
11857 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11858 sw_if_index_set = 1;
11859 else if (unformat (i, "table %d", &table_index))
11863 clib_warning ("parse error '%U'", format_unformat_error, i);
11868 if (sw_if_index_set == 0)
11870 errmsg ("missing interface name or sw_if_index");
11875 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11877 mp->sw_if_index = ntohl (sw_if_index);
11878 mp->table_index = ntohl (table_index);
11879 mp->is_ipv6 = is_ipv6;
11887 api_classify_set_interface_l2_tables (vat_main_t * vam)
11889 unformat_input_t *i = vam->input;
11890 vl_api_classify_set_interface_l2_tables_t *mp;
11892 int sw_if_index_set;
11893 u32 ip4_table_index = ~0;
11894 u32 ip6_table_index = ~0;
11895 u32 other_table_index = ~0;
11899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11902 sw_if_index_set = 1;
11903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11904 sw_if_index_set = 1;
11905 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11907 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11909 else if (unformat (i, "other-table %d", &other_table_index))
11911 else if (unformat (i, "is-input %d", &is_input))
11915 clib_warning ("parse error '%U'", format_unformat_error, i);
11920 if (sw_if_index_set == 0)
11922 errmsg ("missing interface name or sw_if_index");
11927 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11929 mp->sw_if_index = ntohl (sw_if_index);
11930 mp->ip4_table_index = ntohl (ip4_table_index);
11931 mp->ip6_table_index = ntohl (ip6_table_index);
11932 mp->other_table_index = ntohl (other_table_index);
11933 mp->is_input = (u8) is_input;
11941 api_set_ipfix_exporter (vat_main_t * vam)
11943 unformat_input_t *i = vam->input;
11944 vl_api_set_ipfix_exporter_t *mp;
11945 ip4_address_t collector_address;
11946 u8 collector_address_set = 0;
11947 u32 collector_port = ~0;
11948 ip4_address_t src_address;
11949 u8 src_address_set = 0;
11952 u32 template_interval = ~0;
11953 u8 udp_checksum = 0;
11956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11958 if (unformat (i, "collector_address %U", unformat_ip4_address,
11959 &collector_address))
11960 collector_address_set = 1;
11961 else if (unformat (i, "collector_port %d", &collector_port))
11963 else if (unformat (i, "src_address %U", unformat_ip4_address,
11965 src_address_set = 1;
11966 else if (unformat (i, "vrf_id %d", &vrf_id))
11968 else if (unformat (i, "path_mtu %d", &path_mtu))
11970 else if (unformat (i, "template_interval %d", &template_interval))
11972 else if (unformat (i, "udp_checksum"))
11978 if (collector_address_set == 0)
11980 errmsg ("collector_address required");
11984 if (src_address_set == 0)
11986 errmsg ("src_address required");
11990 M (SET_IPFIX_EXPORTER, mp);
11992 memcpy (mp->collector_address, collector_address.data,
11993 sizeof (collector_address.data));
11994 mp->collector_port = htons ((u16) collector_port);
11995 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
11996 mp->vrf_id = htonl (vrf_id);
11997 mp->path_mtu = htonl (path_mtu);
11998 mp->template_interval = htonl (template_interval);
11999 mp->udp_checksum = udp_checksum;
12007 api_set_ipfix_classify_stream (vat_main_t * vam)
12009 unformat_input_t *i = vam->input;
12010 vl_api_set_ipfix_classify_stream_t *mp;
12012 u32 src_port = UDP_DST_PORT_ipfix;
12015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12017 if (unformat (i, "domain %d", &domain_id))
12019 else if (unformat (i, "src_port %d", &src_port))
12023 errmsg ("unknown input `%U'", format_unformat_error, i);
12028 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12030 mp->domain_id = htonl (domain_id);
12031 mp->src_port = htons ((u16) src_port);
12039 api_ipfix_classify_table_add_del (vat_main_t * vam)
12041 unformat_input_t *i = vam->input;
12042 vl_api_ipfix_classify_table_add_del_t *mp;
12044 u32 classify_table_index = ~0;
12046 u8 transport_protocol = 255;
12049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12051 if (unformat (i, "add"))
12053 else if (unformat (i, "del"))
12055 else if (unformat (i, "table %d", &classify_table_index))
12057 else if (unformat (i, "ip4"))
12059 else if (unformat (i, "ip6"))
12061 else if (unformat (i, "tcp"))
12062 transport_protocol = 6;
12063 else if (unformat (i, "udp"))
12064 transport_protocol = 17;
12067 errmsg ("unknown input `%U'", format_unformat_error, i);
12074 errmsg ("expecting: add|del");
12077 if (classify_table_index == ~0)
12079 errmsg ("classifier table not specified");
12082 if (ip_version == 0)
12084 errmsg ("IP version not specified");
12088 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12090 mp->is_add = is_add;
12091 mp->table_id = htonl (classify_table_index);
12092 mp->ip_version = ip_version;
12093 mp->transport_protocol = transport_protocol;
12101 api_get_node_index (vat_main_t * vam)
12103 unformat_input_t *i = vam->input;
12104 vl_api_get_node_index_t *mp;
12108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12110 if (unformat (i, "node %s", &name))
12117 errmsg ("node name required");
12120 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12122 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12126 M (GET_NODE_INDEX, mp);
12127 clib_memcpy (mp->node_name, name, vec_len (name));
12136 api_get_next_index (vat_main_t * vam)
12138 unformat_input_t *i = vam->input;
12139 vl_api_get_next_index_t *mp;
12140 u8 *node_name = 0, *next_node_name = 0;
12143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12145 if (unformat (i, "node-name %s", &node_name))
12147 else if (unformat (i, "next-node-name %s", &next_node_name))
12151 if (node_name == 0)
12153 errmsg ("node name required");
12156 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12158 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12162 if (next_node_name == 0)
12164 errmsg ("next node name required");
12167 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12169 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12173 M (GET_NEXT_INDEX, mp);
12174 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12175 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12176 vec_free (node_name);
12177 vec_free (next_node_name);
12185 api_add_node_next (vat_main_t * vam)
12187 unformat_input_t *i = vam->input;
12188 vl_api_add_node_next_t *mp;
12193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12195 if (unformat (i, "node %s", &name))
12197 else if (unformat (i, "next %s", &next))
12204 errmsg ("node name required");
12207 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12209 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12214 errmsg ("next node required");
12217 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12219 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12223 M (ADD_NODE_NEXT, mp);
12224 clib_memcpy (mp->node_name, name, vec_len (name));
12225 clib_memcpy (mp->next_name, next, vec_len (next));
12235 api_l2tpv3_create_tunnel (vat_main_t * vam)
12237 unformat_input_t *i = vam->input;
12238 ip6_address_t client_address, our_address;
12239 int client_address_set = 0;
12240 int our_address_set = 0;
12241 u32 local_session_id = 0;
12242 u32 remote_session_id = 0;
12243 u64 local_cookie = 0;
12244 u64 remote_cookie = 0;
12245 u8 l2_sublayer_present = 0;
12246 vl_api_l2tpv3_create_tunnel_t *mp;
12249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12251 if (unformat (i, "client_address %U", unformat_ip6_address,
12253 client_address_set = 1;
12254 else if (unformat (i, "our_address %U", unformat_ip6_address,
12256 our_address_set = 1;
12257 else if (unformat (i, "local_session_id %d", &local_session_id))
12259 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12261 else if (unformat (i, "local_cookie %lld", &local_cookie))
12263 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12265 else if (unformat (i, "l2-sublayer-present"))
12266 l2_sublayer_present = 1;
12271 if (client_address_set == 0)
12273 errmsg ("client_address required");
12277 if (our_address_set == 0)
12279 errmsg ("our_address required");
12283 M (L2TPV3_CREATE_TUNNEL, mp);
12285 clib_memcpy (mp->client_address, client_address.as_u8,
12286 sizeof (mp->client_address));
12288 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12290 mp->local_session_id = ntohl (local_session_id);
12291 mp->remote_session_id = ntohl (remote_session_id);
12292 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12293 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12294 mp->l2_sublayer_present = l2_sublayer_present;
12303 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12305 unformat_input_t *i = vam->input;
12307 u8 sw_if_index_set = 0;
12308 u64 new_local_cookie = 0;
12309 u64 new_remote_cookie = 0;
12310 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12315 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12316 sw_if_index_set = 1;
12317 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12318 sw_if_index_set = 1;
12319 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12321 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12327 if (sw_if_index_set == 0)
12329 errmsg ("missing interface name or sw_if_index");
12333 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12335 mp->sw_if_index = ntohl (sw_if_index);
12336 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12337 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12345 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12347 unformat_input_t *i = vam->input;
12348 vl_api_l2tpv3_interface_enable_disable_t *mp;
12350 u8 sw_if_index_set = 0;
12351 u8 enable_disable = 1;
12354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12356 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12357 sw_if_index_set = 1;
12358 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12359 sw_if_index_set = 1;
12360 else if (unformat (i, "enable"))
12361 enable_disable = 1;
12362 else if (unformat (i, "disable"))
12363 enable_disable = 0;
12368 if (sw_if_index_set == 0)
12370 errmsg ("missing interface name or sw_if_index");
12374 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12376 mp->sw_if_index = ntohl (sw_if_index);
12377 mp->enable_disable = enable_disable;
12385 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12387 unformat_input_t *i = vam->input;
12388 vl_api_l2tpv3_set_lookup_key_t *mp;
12392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12394 if (unformat (i, "lookup_v6_src"))
12395 key = L2T_LOOKUP_SRC_ADDRESS;
12396 else if (unformat (i, "lookup_v6_dst"))
12397 key = L2T_LOOKUP_DST_ADDRESS;
12398 else if (unformat (i, "lookup_session_id"))
12399 key = L2T_LOOKUP_SESSION_ID;
12404 if (key == (u8) ~ 0)
12406 errmsg ("l2tp session lookup key unset");
12410 M (L2TPV3_SET_LOOKUP_KEY, mp);
12419 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12420 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12422 vat_main_t *vam = &vat_main;
12424 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12425 format_ip6_address, mp->our_address,
12426 format_ip6_address, mp->client_address,
12427 clib_net_to_host_u32 (mp->sw_if_index));
12430 " local cookies %016llx %016llx remote cookie %016llx",
12431 clib_net_to_host_u64 (mp->local_cookie[0]),
12432 clib_net_to_host_u64 (mp->local_cookie[1]),
12433 clib_net_to_host_u64 (mp->remote_cookie));
12435 print (vam->ofp, " local session-id %d remote session-id %d",
12436 clib_net_to_host_u32 (mp->local_session_id),
12437 clib_net_to_host_u32 (mp->remote_session_id));
12439 print (vam->ofp, " l2 specific sublayer %s\n",
12440 mp->l2_sublayer_present ? "preset" : "absent");
12444 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12445 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12447 vat_main_t *vam = &vat_main;
12448 vat_json_node_t *node = NULL;
12449 struct in6_addr addr;
12451 if (VAT_JSON_ARRAY != vam->json_tree.type)
12453 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12454 vat_json_init_array (&vam->json_tree);
12456 node = vat_json_array_add (&vam->json_tree);
12458 vat_json_init_object (node);
12460 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12461 vat_json_object_add_ip6 (node, "our_address", addr);
12462 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12463 vat_json_object_add_ip6 (node, "client_address", addr);
12465 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12466 vat_json_init_array (lc);
12467 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12468 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12469 vat_json_object_add_uint (node, "remote_cookie",
12470 clib_net_to_host_u64 (mp->remote_cookie));
12472 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12473 vat_json_object_add_uint (node, "local_session_id",
12474 clib_net_to_host_u32 (mp->local_session_id));
12475 vat_json_object_add_uint (node, "remote_session_id",
12476 clib_net_to_host_u32 (mp->remote_session_id));
12477 vat_json_object_add_string_copy (node, "l2_sublayer",
12478 mp->l2_sublayer_present ? (u8 *) "present"
12479 : (u8 *) "absent");
12483 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12485 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12486 vl_api_control_ping_t *mp_ping;
12489 /* Get list of l2tpv3-tunnel interfaces */
12490 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12493 /* Use a control ping for synchronization */
12494 MPING (CONTROL_PING, mp_ping);
12502 static void vl_api_sw_interface_tap_v2_details_t_handler
12503 (vl_api_sw_interface_tap_v2_details_t * mp)
12505 vat_main_t *vam = &vat_main;
12507 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12508 mp->host_ip4_prefix_len);
12509 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12510 mp->host_ip6_prefix_len);
12513 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12514 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12515 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12516 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12517 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12523 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12524 (vl_api_sw_interface_tap_v2_details_t * mp)
12526 vat_main_t *vam = &vat_main;
12527 vat_json_node_t *node = NULL;
12529 if (VAT_JSON_ARRAY != vam->json_tree.type)
12531 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12532 vat_json_init_array (&vam->json_tree);
12534 node = vat_json_array_add (&vam->json_tree);
12536 vat_json_init_object (node);
12537 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12538 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12539 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12540 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12541 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12542 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12543 vat_json_object_add_string_copy (node, "host_mac_addr",
12544 format (0, "%U", format_ethernet_address,
12545 &mp->host_mac_addr));
12546 vat_json_object_add_string_copy (node, "host_namespace",
12547 mp->host_namespace);
12548 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12549 vat_json_object_add_string_copy (node, "host_ip4_addr",
12550 format (0, "%U/%d", format_ip4_address,
12552 mp->host_ip4_prefix_len));
12553 vat_json_object_add_string_copy (node, "host_ip6_addr",
12554 format (0, "%U/%d", format_ip6_address,
12556 mp->host_ip6_prefix_len));
12561 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12563 vl_api_sw_interface_tap_v2_dump_t *mp;
12564 vl_api_control_ping_t *mp_ping;
12568 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12569 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12570 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12573 /* Get list of tap interfaces */
12574 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12577 /* Use a control ping for synchronization */
12578 MPING (CONTROL_PING, mp_ping);
12585 static void vl_api_sw_interface_virtio_pci_details_t_handler
12586 (vl_api_sw_interface_virtio_pci_details_t * mp)
12588 vat_main_t *vam = &vat_main;
12602 addr.as_u32 = ntohl (mp->pci_addr);
12603 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12604 addr.slot, addr.function);
12607 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12608 pci_addr, ntohl (mp->sw_if_index),
12609 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12610 format_ethernet_address, mp->mac_addr,
12611 clib_net_to_host_u64 (mp->features));
12612 vec_free (pci_addr);
12615 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12616 (vl_api_sw_interface_virtio_pci_details_t * mp)
12618 vat_main_t *vam = &vat_main;
12619 vat_json_node_t *node = NULL;
12621 if (VAT_JSON_ARRAY != vam->json_tree.type)
12623 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12624 vat_json_init_array (&vam->json_tree);
12626 node = vat_json_array_add (&vam->json_tree);
12628 vat_json_init_object (node);
12629 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12630 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12631 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12632 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12633 vat_json_object_add_uint (node, "features",
12634 clib_net_to_host_u64 (mp->features));
12635 vat_json_object_add_string_copy (node, "mac_addr",
12636 format (0, "%U", format_ethernet_address,
12641 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12643 vl_api_sw_interface_virtio_pci_dump_t *mp;
12644 vl_api_control_ping_t *mp_ping;
12648 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12649 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12650 "mac_addr", "features");
12652 /* Get list of tap interfaces */
12653 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12656 /* Use a control ping for synchronization */
12657 MPING (CONTROL_PING, mp_ping);
12665 api_vxlan_offload_rx (vat_main_t * vam)
12667 unformat_input_t *line_input = vam->input;
12668 vl_api_vxlan_offload_rx_t *mp;
12669 u32 hw_if_index = ~0, rx_if_index = ~0;
12673 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12675 if (unformat (line_input, "del"))
12677 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12680 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12682 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12685 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12689 errmsg ("parse error '%U'", format_unformat_error, line_input);
12694 if (hw_if_index == ~0)
12696 errmsg ("no hw interface");
12700 if (rx_if_index == ~0)
12702 errmsg ("no rx tunnel");
12706 M (VXLAN_OFFLOAD_RX, mp);
12708 mp->hw_if_index = ntohl (hw_if_index);
12709 mp->sw_if_index = ntohl (rx_if_index);
12710 mp->enable = is_add;
12717 static uword unformat_vxlan_decap_next
12718 (unformat_input_t * input, va_list * args)
12720 u32 *result = va_arg (*args, u32 *);
12723 if (unformat (input, "l2"))
12724 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12725 else if (unformat (input, "%d", &tmp))
12733 api_vxlan_add_del_tunnel (vat_main_t * vam)
12735 unformat_input_t *line_input = vam->input;
12736 vl_api_vxlan_add_del_tunnel_t *mp;
12737 ip46_address_t src, dst;
12739 u8 ipv4_set = 0, ipv6_set = 0;
12744 u32 mcast_sw_if_index = ~0;
12745 u32 encap_vrf_id = 0;
12746 u32 decap_next_index = ~0;
12750 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12751 clib_memset (&src, 0, sizeof src);
12752 clib_memset (&dst, 0, sizeof dst);
12754 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12756 if (unformat (line_input, "del"))
12758 else if (unformat (line_input, "instance %d", &instance))
12761 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12767 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12773 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12779 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12784 else if (unformat (line_input, "group %U %U",
12785 unformat_ip4_address, &dst.ip4,
12786 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12788 grp_set = dst_set = 1;
12791 else if (unformat (line_input, "group %U",
12792 unformat_ip4_address, &dst.ip4))
12794 grp_set = dst_set = 1;
12797 else if (unformat (line_input, "group %U %U",
12798 unformat_ip6_address, &dst.ip6,
12799 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12801 grp_set = dst_set = 1;
12804 else if (unformat (line_input, "group %U",
12805 unformat_ip6_address, &dst.ip6))
12807 grp_set = dst_set = 1;
12811 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12813 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12815 else if (unformat (line_input, "decap-next %U",
12816 unformat_vxlan_decap_next, &decap_next_index))
12818 else if (unformat (line_input, "vni %d", &vni))
12822 errmsg ("parse error '%U'", format_unformat_error, line_input);
12829 errmsg ("tunnel src address not specified");
12834 errmsg ("tunnel dst address not specified");
12838 if (grp_set && !ip46_address_is_multicast (&dst))
12840 errmsg ("tunnel group address not multicast");
12843 if (grp_set && mcast_sw_if_index == ~0)
12845 errmsg ("tunnel nonexistent multicast device");
12848 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12850 errmsg ("tunnel dst address must be unicast");
12855 if (ipv4_set && ipv6_set)
12857 errmsg ("both IPv4 and IPv6 addresses specified");
12861 if ((vni == 0) || (vni >> 24))
12863 errmsg ("vni not specified or out of range");
12867 M (VXLAN_ADD_DEL_TUNNEL, mp);
12871 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12872 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12876 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12877 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12880 mp->instance = htonl (instance);
12881 mp->encap_vrf_id = ntohl (encap_vrf_id);
12882 mp->decap_next_index = ntohl (decap_next_index);
12883 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12884 mp->vni = ntohl (vni);
12885 mp->is_add = is_add;
12886 mp->is_ipv6 = ipv6_set;
12893 static void vl_api_vxlan_tunnel_details_t_handler
12894 (vl_api_vxlan_tunnel_details_t * mp)
12896 vat_main_t *vam = &vat_main;
12897 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12898 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12900 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12901 ntohl (mp->sw_if_index),
12902 ntohl (mp->instance),
12903 format_ip46_address, &src, IP46_TYPE_ANY,
12904 format_ip46_address, &dst, IP46_TYPE_ANY,
12905 ntohl (mp->encap_vrf_id),
12906 ntohl (mp->decap_next_index), ntohl (mp->vni),
12907 ntohl (mp->mcast_sw_if_index));
12910 static void vl_api_vxlan_tunnel_details_t_handler_json
12911 (vl_api_vxlan_tunnel_details_t * mp)
12913 vat_main_t *vam = &vat_main;
12914 vat_json_node_t *node = NULL;
12916 if (VAT_JSON_ARRAY != vam->json_tree.type)
12918 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12919 vat_json_init_array (&vam->json_tree);
12921 node = vat_json_array_add (&vam->json_tree);
12923 vat_json_init_object (node);
12924 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12926 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12930 struct in6_addr ip6;
12932 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12933 vat_json_object_add_ip6 (node, "src_address", ip6);
12934 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12935 vat_json_object_add_ip6 (node, "dst_address", ip6);
12939 struct in_addr ip4;
12941 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12942 vat_json_object_add_ip4 (node, "src_address", ip4);
12943 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12944 vat_json_object_add_ip4 (node, "dst_address", ip4);
12946 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12947 vat_json_object_add_uint (node, "decap_next_index",
12948 ntohl (mp->decap_next_index));
12949 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12950 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12951 vat_json_object_add_uint (node, "mcast_sw_if_index",
12952 ntohl (mp->mcast_sw_if_index));
12956 api_vxlan_tunnel_dump (vat_main_t * vam)
12958 unformat_input_t *i = vam->input;
12959 vl_api_vxlan_tunnel_dump_t *mp;
12960 vl_api_control_ping_t *mp_ping;
12962 u8 sw_if_index_set = 0;
12965 /* Parse args required to build the message */
12966 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12968 if (unformat (i, "sw_if_index %d", &sw_if_index))
12969 sw_if_index_set = 1;
12974 if (sw_if_index_set == 0)
12979 if (!vam->json_output)
12981 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
12982 "sw_if_index", "instance", "src_address", "dst_address",
12983 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
12986 /* Get list of vxlan-tunnel interfaces */
12987 M (VXLAN_TUNNEL_DUMP, mp);
12989 mp->sw_if_index = htonl (sw_if_index);
12993 /* Use a control ping for synchronization */
12994 MPING (CONTROL_PING, mp_ping);
13001 static uword unformat_geneve_decap_next
13002 (unformat_input_t * input, va_list * args)
13004 u32 *result = va_arg (*args, u32 *);
13007 if (unformat (input, "l2"))
13008 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13009 else if (unformat (input, "%d", &tmp))
13017 api_geneve_add_del_tunnel (vat_main_t * vam)
13019 unformat_input_t *line_input = vam->input;
13020 vl_api_geneve_add_del_tunnel_t *mp;
13021 ip46_address_t src, dst;
13023 u8 ipv4_set = 0, ipv6_set = 0;
13027 u32 mcast_sw_if_index = ~0;
13028 u32 encap_vrf_id = 0;
13029 u32 decap_next_index = ~0;
13033 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13034 clib_memset (&src, 0, sizeof src);
13035 clib_memset (&dst, 0, sizeof dst);
13037 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13039 if (unformat (line_input, "del"))
13042 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13048 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13054 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13060 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13065 else if (unformat (line_input, "group %U %U",
13066 unformat_ip4_address, &dst.ip4,
13067 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13069 grp_set = dst_set = 1;
13072 else if (unformat (line_input, "group %U",
13073 unformat_ip4_address, &dst.ip4))
13075 grp_set = dst_set = 1;
13078 else if (unformat (line_input, "group %U %U",
13079 unformat_ip6_address, &dst.ip6,
13080 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13082 grp_set = dst_set = 1;
13085 else if (unformat (line_input, "group %U",
13086 unformat_ip6_address, &dst.ip6))
13088 grp_set = dst_set = 1;
13092 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13094 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13096 else if (unformat (line_input, "decap-next %U",
13097 unformat_geneve_decap_next, &decap_next_index))
13099 else if (unformat (line_input, "vni %d", &vni))
13103 errmsg ("parse error '%U'", format_unformat_error, line_input);
13110 errmsg ("tunnel src address not specified");
13115 errmsg ("tunnel dst address not specified");
13119 if (grp_set && !ip46_address_is_multicast (&dst))
13121 errmsg ("tunnel group address not multicast");
13124 if (grp_set && mcast_sw_if_index == ~0)
13126 errmsg ("tunnel nonexistent multicast device");
13129 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13131 errmsg ("tunnel dst address must be unicast");
13136 if (ipv4_set && ipv6_set)
13138 errmsg ("both IPv4 and IPv6 addresses specified");
13142 if ((vni == 0) || (vni >> 24))
13144 errmsg ("vni not specified or out of range");
13148 M (GENEVE_ADD_DEL_TUNNEL, mp);
13152 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13153 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13157 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13158 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13160 mp->encap_vrf_id = ntohl (encap_vrf_id);
13161 mp->decap_next_index = ntohl (decap_next_index);
13162 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13163 mp->vni = ntohl (vni);
13164 mp->is_add = is_add;
13165 mp->is_ipv6 = ipv6_set;
13172 static void vl_api_geneve_tunnel_details_t_handler
13173 (vl_api_geneve_tunnel_details_t * mp)
13175 vat_main_t *vam = &vat_main;
13176 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13177 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13179 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13180 ntohl (mp->sw_if_index),
13181 format_ip46_address, &src, IP46_TYPE_ANY,
13182 format_ip46_address, &dst, IP46_TYPE_ANY,
13183 ntohl (mp->encap_vrf_id),
13184 ntohl (mp->decap_next_index), ntohl (mp->vni),
13185 ntohl (mp->mcast_sw_if_index));
13188 static void vl_api_geneve_tunnel_details_t_handler_json
13189 (vl_api_geneve_tunnel_details_t * mp)
13191 vat_main_t *vam = &vat_main;
13192 vat_json_node_t *node = NULL;
13194 if (VAT_JSON_ARRAY != vam->json_tree.type)
13196 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13197 vat_json_init_array (&vam->json_tree);
13199 node = vat_json_array_add (&vam->json_tree);
13201 vat_json_init_object (node);
13202 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13205 struct in6_addr ip6;
13207 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13208 vat_json_object_add_ip6 (node, "src_address", ip6);
13209 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13210 vat_json_object_add_ip6 (node, "dst_address", ip6);
13214 struct in_addr ip4;
13216 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13217 vat_json_object_add_ip4 (node, "src_address", ip4);
13218 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13219 vat_json_object_add_ip4 (node, "dst_address", ip4);
13221 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13222 vat_json_object_add_uint (node, "decap_next_index",
13223 ntohl (mp->decap_next_index));
13224 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13225 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13226 vat_json_object_add_uint (node, "mcast_sw_if_index",
13227 ntohl (mp->mcast_sw_if_index));
13231 api_geneve_tunnel_dump (vat_main_t * vam)
13233 unformat_input_t *i = vam->input;
13234 vl_api_geneve_tunnel_dump_t *mp;
13235 vl_api_control_ping_t *mp_ping;
13237 u8 sw_if_index_set = 0;
13240 /* Parse args required to build the message */
13241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13243 if (unformat (i, "sw_if_index %d", &sw_if_index))
13244 sw_if_index_set = 1;
13249 if (sw_if_index_set == 0)
13254 if (!vam->json_output)
13256 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13257 "sw_if_index", "local_address", "remote_address",
13258 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13261 /* Get list of geneve-tunnel interfaces */
13262 M (GENEVE_TUNNEL_DUMP, mp);
13264 mp->sw_if_index = htonl (sw_if_index);
13268 /* Use a control ping for synchronization */
13269 M (CONTROL_PING, mp_ping);
13277 api_gre_add_del_tunnel (vat_main_t * vam)
13279 unformat_input_t *line_input = vam->input;
13280 vl_api_gre_add_del_tunnel_t *mp;
13281 ip4_address_t src4, dst4;
13282 ip6_address_t src6, dst6;
13286 u8 t_type = GRE_TUNNEL_TYPE_L3;
13289 u32 outer_fib_id = 0;
13290 u32 session_id = 0;
13294 clib_memset (&src4, 0, sizeof src4);
13295 clib_memset (&dst4, 0, sizeof dst4);
13296 clib_memset (&src6, 0, sizeof src6);
13297 clib_memset (&dst6, 0, sizeof dst6);
13299 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13301 if (unformat (line_input, "del"))
13303 else if (unformat (line_input, "instance %d", &instance))
13305 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
13310 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
13315 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
13320 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
13325 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13327 else if (unformat (line_input, "teb"))
13328 t_type = GRE_TUNNEL_TYPE_TEB;
13329 else if (unformat (line_input, "erspan %d", &session_id))
13330 t_type = GRE_TUNNEL_TYPE_ERSPAN;
13333 errmsg ("parse error '%U'", format_unformat_error, line_input);
13340 errmsg ("tunnel src address not specified");
13345 errmsg ("tunnel dst address not specified");
13348 if (ipv4_set && ipv6_set)
13350 errmsg ("both IPv4 and IPv6 addresses specified");
13355 M (GRE_ADD_DEL_TUNNEL, mp);
13359 clib_memcpy (&mp->src_address, &src4, 4);
13360 clib_memcpy (&mp->dst_address, &dst4, 4);
13364 clib_memcpy (&mp->src_address, &src6, 16);
13365 clib_memcpy (&mp->dst_address, &dst6, 16);
13367 mp->instance = htonl (instance);
13368 mp->outer_fib_id = htonl (outer_fib_id);
13369 mp->is_add = is_add;
13370 mp->session_id = htons ((u16) session_id);
13371 mp->tunnel_type = t_type;
13372 mp->is_ipv6 = ipv6_set;
13379 static void vl_api_gre_tunnel_details_t_handler
13380 (vl_api_gre_tunnel_details_t * mp)
13382 vat_main_t *vam = &vat_main;
13383 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
13384 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
13386 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13387 ntohl (mp->sw_if_index),
13388 ntohl (mp->instance),
13389 format_ip46_address, &src, IP46_TYPE_ANY,
13390 format_ip46_address, &dst, IP46_TYPE_ANY,
13391 mp->tunnel_type, ntohl (mp->outer_fib_id), ntohl (mp->session_id));
13394 static void vl_api_gre_tunnel_details_t_handler_json
13395 (vl_api_gre_tunnel_details_t * mp)
13397 vat_main_t *vam = &vat_main;
13398 vat_json_node_t *node = NULL;
13399 struct in_addr ip4;
13400 struct in6_addr ip6;
13402 if (VAT_JSON_ARRAY != vam->json_tree.type)
13404 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13405 vat_json_init_array (&vam->json_tree);
13407 node = vat_json_array_add (&vam->json_tree);
13409 vat_json_init_object (node);
13410 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13411 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
13414 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
13415 vat_json_object_add_ip4 (node, "src_address", ip4);
13416 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
13417 vat_json_object_add_ip4 (node, "dst_address", ip4);
13421 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
13422 vat_json_object_add_ip6 (node, "src_address", ip6);
13423 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
13424 vat_json_object_add_ip6 (node, "dst_address", ip6);
13426 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel_type);
13427 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
13428 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
13429 vat_json_object_add_uint (node, "session_id", mp->session_id);
13433 api_gre_tunnel_dump (vat_main_t * vam)
13435 unformat_input_t *i = vam->input;
13436 vl_api_gre_tunnel_dump_t *mp;
13437 vl_api_control_ping_t *mp_ping;
13439 u8 sw_if_index_set = 0;
13442 /* Parse args required to build the message */
13443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13445 if (unformat (i, "sw_if_index %d", &sw_if_index))
13446 sw_if_index_set = 1;
13451 if (sw_if_index_set == 0)
13456 if (!vam->json_output)
13458 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13459 "sw_if_index", "instance", "src_address", "dst_address",
13460 "tunnel_type", "outer_fib_id", "session_id");
13463 /* Get list of gre-tunnel interfaces */
13464 M (GRE_TUNNEL_DUMP, mp);
13466 mp->sw_if_index = htonl (sw_if_index);
13470 /* Use a control ping for synchronization */
13471 MPING (CONTROL_PING, mp_ping);
13479 api_l2_fib_clear_table (vat_main_t * vam)
13481 // unformat_input_t * i = vam->input;
13482 vl_api_l2_fib_clear_table_t *mp;
13485 M (L2_FIB_CLEAR_TABLE, mp);
13493 api_l2_interface_efp_filter (vat_main_t * vam)
13495 unformat_input_t *i = vam->input;
13496 vl_api_l2_interface_efp_filter_t *mp;
13499 u8 sw_if_index_set = 0;
13502 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13504 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13505 sw_if_index_set = 1;
13506 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13507 sw_if_index_set = 1;
13508 else if (unformat (i, "enable"))
13510 else if (unformat (i, "disable"))
13514 clib_warning ("parse error '%U'", format_unformat_error, i);
13519 if (sw_if_index_set == 0)
13521 errmsg ("missing sw_if_index");
13525 M (L2_INTERFACE_EFP_FILTER, mp);
13527 mp->sw_if_index = ntohl (sw_if_index);
13528 mp->enable_disable = enable;
13535 #define foreach_vtr_op \
13536 _("disable", L2_VTR_DISABLED) \
13537 _("push-1", L2_VTR_PUSH_1) \
13538 _("push-2", L2_VTR_PUSH_2) \
13539 _("pop-1", L2_VTR_POP_1) \
13540 _("pop-2", L2_VTR_POP_2) \
13541 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13542 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13543 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13544 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13547 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13549 unformat_input_t *i = vam->input;
13550 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13552 u8 sw_if_index_set = 0;
13555 u32 push_dot1q = 1;
13560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13562 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13563 sw_if_index_set = 1;
13564 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13565 sw_if_index_set = 1;
13566 else if (unformat (i, "vtr_op %d", &vtr_op))
13568 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13571 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13573 else if (unformat (i, "tag1 %d", &tag1))
13575 else if (unformat (i, "tag2 %d", &tag2))
13579 clib_warning ("parse error '%U'", format_unformat_error, i);
13584 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13586 errmsg ("missing vtr operation or sw_if_index");
13590 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13591 mp->sw_if_index = ntohl (sw_if_index);
13592 mp->vtr_op = ntohl (vtr_op);
13593 mp->push_dot1q = ntohl (push_dot1q);
13594 mp->tag1 = ntohl (tag1);
13595 mp->tag2 = ntohl (tag2);
13603 api_create_vhost_user_if (vat_main_t * vam)
13605 unformat_input_t *i = vam->input;
13606 vl_api_create_vhost_user_if_t *mp;
13609 u8 file_name_set = 0;
13610 u32 custom_dev_instance = ~0;
13612 u8 use_custom_mac = 0;
13613 u8 disable_mrg_rxbuf = 0;
13614 u8 disable_indirect_desc = 0;
13618 /* Shut up coverity */
13619 clib_memset (hwaddr, 0, sizeof (hwaddr));
13621 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13623 if (unformat (i, "socket %s", &file_name))
13627 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13629 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13630 use_custom_mac = 1;
13631 else if (unformat (i, "server"))
13633 else if (unformat (i, "disable_mrg_rxbuf"))
13634 disable_mrg_rxbuf = 1;
13635 else if (unformat (i, "disable_indirect_desc"))
13636 disable_indirect_desc = 1;
13637 else if (unformat (i, "tag %s", &tag))
13643 if (file_name_set == 0)
13645 errmsg ("missing socket file name");
13649 if (vec_len (file_name) > 255)
13651 errmsg ("socket file name too long");
13654 vec_add1 (file_name, 0);
13656 M (CREATE_VHOST_USER_IF, mp);
13658 mp->is_server = is_server;
13659 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13660 mp->disable_indirect_desc = disable_indirect_desc;
13661 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13662 vec_free (file_name);
13663 if (custom_dev_instance != ~0)
13666 mp->custom_dev_instance = ntohl (custom_dev_instance);
13669 mp->use_custom_mac = use_custom_mac;
13670 clib_memcpy (mp->mac_address, hwaddr, 6);
13672 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13681 api_modify_vhost_user_if (vat_main_t * vam)
13683 unformat_input_t *i = vam->input;
13684 vl_api_modify_vhost_user_if_t *mp;
13687 u8 file_name_set = 0;
13688 u32 custom_dev_instance = ~0;
13689 u8 sw_if_index_set = 0;
13690 u32 sw_if_index = (u32) ~ 0;
13693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13695 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13696 sw_if_index_set = 1;
13697 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13698 sw_if_index_set = 1;
13699 else if (unformat (i, "socket %s", &file_name))
13703 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13705 else if (unformat (i, "server"))
13711 if (sw_if_index_set == 0)
13713 errmsg ("missing sw_if_index or interface name");
13717 if (file_name_set == 0)
13719 errmsg ("missing socket file name");
13723 if (vec_len (file_name) > 255)
13725 errmsg ("socket file name too long");
13728 vec_add1 (file_name, 0);
13730 M (MODIFY_VHOST_USER_IF, mp);
13732 mp->sw_if_index = ntohl (sw_if_index);
13733 mp->is_server = is_server;
13734 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13735 vec_free (file_name);
13736 if (custom_dev_instance != ~0)
13739 mp->custom_dev_instance = ntohl (custom_dev_instance);
13748 api_delete_vhost_user_if (vat_main_t * vam)
13750 unformat_input_t *i = vam->input;
13751 vl_api_delete_vhost_user_if_t *mp;
13752 u32 sw_if_index = ~0;
13753 u8 sw_if_index_set = 0;
13756 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13758 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13759 sw_if_index_set = 1;
13760 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13761 sw_if_index_set = 1;
13766 if (sw_if_index_set == 0)
13768 errmsg ("missing sw_if_index or interface name");
13773 M (DELETE_VHOST_USER_IF, mp);
13775 mp->sw_if_index = ntohl (sw_if_index);
13782 static void vl_api_sw_interface_vhost_user_details_t_handler
13783 (vl_api_sw_interface_vhost_user_details_t * mp)
13785 vat_main_t *vam = &vat_main;
13787 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13788 (char *) mp->interface_name,
13789 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13790 clib_net_to_host_u64 (mp->features), mp->is_server,
13791 ntohl (mp->num_regions), (char *) mp->sock_filename);
13792 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13795 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13796 (vl_api_sw_interface_vhost_user_details_t * mp)
13798 vat_main_t *vam = &vat_main;
13799 vat_json_node_t *node = NULL;
13801 if (VAT_JSON_ARRAY != vam->json_tree.type)
13803 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13804 vat_json_init_array (&vam->json_tree);
13806 node = vat_json_array_add (&vam->json_tree);
13808 vat_json_init_object (node);
13809 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13810 vat_json_object_add_string_copy (node, "interface_name",
13811 mp->interface_name);
13812 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13813 ntohl (mp->virtio_net_hdr_sz));
13814 vat_json_object_add_uint (node, "features",
13815 clib_net_to_host_u64 (mp->features));
13816 vat_json_object_add_uint (node, "is_server", mp->is_server);
13817 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13818 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13819 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13823 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13825 vl_api_sw_interface_vhost_user_dump_t *mp;
13826 vl_api_control_ping_t *mp_ping;
13829 "Interface name idx hdr_sz features server regions filename");
13831 /* Get list of vhost-user interfaces */
13832 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13835 /* Use a control ping for synchronization */
13836 MPING (CONTROL_PING, mp_ping);
13844 api_show_version (vat_main_t * vam)
13846 vl_api_show_version_t *mp;
13849 M (SHOW_VERSION, mp);
13858 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13860 unformat_input_t *line_input = vam->input;
13861 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13862 ip4_address_t local4, remote4;
13863 ip6_address_t local6, remote6;
13865 u8 ipv4_set = 0, ipv6_set = 0;
13869 u32 mcast_sw_if_index = ~0;
13870 u32 encap_vrf_id = 0;
13871 u32 decap_vrf_id = 0;
13877 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13878 clib_memset (&local4, 0, sizeof local4);
13879 clib_memset (&remote4, 0, sizeof remote4);
13880 clib_memset (&local6, 0, sizeof local6);
13881 clib_memset (&remote6, 0, sizeof remote6);
13883 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13885 if (unformat (line_input, "del"))
13887 else if (unformat (line_input, "local %U",
13888 unformat_ip4_address, &local4))
13893 else if (unformat (line_input, "remote %U",
13894 unformat_ip4_address, &remote4))
13899 else if (unformat (line_input, "local %U",
13900 unformat_ip6_address, &local6))
13905 else if (unformat (line_input, "remote %U",
13906 unformat_ip6_address, &remote6))
13911 else if (unformat (line_input, "group %U %U",
13912 unformat_ip4_address, &remote4,
13913 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13915 grp_set = remote_set = 1;
13918 else if (unformat (line_input, "group %U",
13919 unformat_ip4_address, &remote4))
13921 grp_set = remote_set = 1;
13924 else if (unformat (line_input, "group %U %U",
13925 unformat_ip6_address, &remote6,
13926 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13928 grp_set = remote_set = 1;
13931 else if (unformat (line_input, "group %U",
13932 unformat_ip6_address, &remote6))
13934 grp_set = remote_set = 1;
13938 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13940 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13942 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13944 else if (unformat (line_input, "vni %d", &vni))
13946 else if (unformat (line_input, "next-ip4"))
13948 else if (unformat (line_input, "next-ip6"))
13950 else if (unformat (line_input, "next-ethernet"))
13952 else if (unformat (line_input, "next-nsh"))
13956 errmsg ("parse error '%U'", format_unformat_error, line_input);
13961 if (local_set == 0)
13963 errmsg ("tunnel local address not specified");
13966 if (remote_set == 0)
13968 errmsg ("tunnel remote address not specified");
13971 if (grp_set && mcast_sw_if_index == ~0)
13973 errmsg ("tunnel nonexistent multicast device");
13976 if (ipv4_set && ipv6_set)
13978 errmsg ("both IPv4 and IPv6 addresses specified");
13984 errmsg ("vni not specified");
13988 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13993 clib_memcpy (&mp->local, &local6, sizeof (local6));
13994 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13998 clib_memcpy (&mp->local, &local4, sizeof (local4));
13999 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14002 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14003 mp->encap_vrf_id = ntohl (encap_vrf_id);
14004 mp->decap_vrf_id = ntohl (decap_vrf_id);
14005 mp->protocol = protocol;
14006 mp->vni = ntohl (vni);
14007 mp->is_add = is_add;
14008 mp->is_ipv6 = ipv6_set;
14015 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14016 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14018 vat_main_t *vam = &vat_main;
14019 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14020 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14022 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14023 ntohl (mp->sw_if_index),
14024 format_ip46_address, &local, IP46_TYPE_ANY,
14025 format_ip46_address, &remote, IP46_TYPE_ANY,
14026 ntohl (mp->vni), mp->protocol,
14027 ntohl (mp->mcast_sw_if_index),
14028 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14032 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14033 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14035 vat_main_t *vam = &vat_main;
14036 vat_json_node_t *node = NULL;
14037 struct in_addr ip4;
14038 struct in6_addr ip6;
14040 if (VAT_JSON_ARRAY != vam->json_tree.type)
14042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14043 vat_json_init_array (&vam->json_tree);
14045 node = vat_json_array_add (&vam->json_tree);
14047 vat_json_init_object (node);
14048 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14051 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14052 vat_json_object_add_ip6 (node, "local", ip6);
14053 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14054 vat_json_object_add_ip6 (node, "remote", ip6);
14058 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14059 vat_json_object_add_ip4 (node, "local", ip4);
14060 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14061 vat_json_object_add_ip4 (node, "remote", ip4);
14063 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14064 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14065 vat_json_object_add_uint (node, "mcast_sw_if_index",
14066 ntohl (mp->mcast_sw_if_index));
14067 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14068 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14069 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14073 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14075 unformat_input_t *i = vam->input;
14076 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14077 vl_api_control_ping_t *mp_ping;
14079 u8 sw_if_index_set = 0;
14082 /* Parse args required to build the message */
14083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14085 if (unformat (i, "sw_if_index %d", &sw_if_index))
14086 sw_if_index_set = 1;
14091 if (sw_if_index_set == 0)
14096 if (!vam->json_output)
14098 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14099 "sw_if_index", "local", "remote", "vni",
14100 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14103 /* Get list of vxlan-tunnel interfaces */
14104 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14106 mp->sw_if_index = htonl (sw_if_index);
14110 /* Use a control ping for synchronization */
14111 MPING (CONTROL_PING, mp_ping);
14118 static void vl_api_l2_fib_table_details_t_handler
14119 (vl_api_l2_fib_table_details_t * mp)
14121 vat_main_t *vam = &vat_main;
14123 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14125 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14126 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14130 static void vl_api_l2_fib_table_details_t_handler_json
14131 (vl_api_l2_fib_table_details_t * mp)
14133 vat_main_t *vam = &vat_main;
14134 vat_json_node_t *node = NULL;
14136 if (VAT_JSON_ARRAY != vam->json_tree.type)
14138 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14139 vat_json_init_array (&vam->json_tree);
14141 node = vat_json_array_add (&vam->json_tree);
14143 vat_json_init_object (node);
14144 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14145 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14146 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14147 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14148 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14149 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14153 api_l2_fib_table_dump (vat_main_t * vam)
14155 unformat_input_t *i = vam->input;
14156 vl_api_l2_fib_table_dump_t *mp;
14157 vl_api_control_ping_t *mp_ping;
14162 /* Parse args required to build the message */
14163 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14165 if (unformat (i, "bd_id %d", &bd_id))
14171 if (bd_id_set == 0)
14173 errmsg ("missing bridge domain");
14177 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14179 /* Get list of l2 fib entries */
14180 M (L2_FIB_TABLE_DUMP, mp);
14182 mp->bd_id = ntohl (bd_id);
14185 /* Use a control ping for synchronization */
14186 MPING (CONTROL_PING, mp_ping);
14195 api_interface_name_renumber (vat_main_t * vam)
14197 unformat_input_t *line_input = vam->input;
14198 vl_api_interface_name_renumber_t *mp;
14199 u32 sw_if_index = ~0;
14200 u32 new_show_dev_instance = ~0;
14203 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14205 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14208 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14210 else if (unformat (line_input, "new_show_dev_instance %d",
14211 &new_show_dev_instance))
14217 if (sw_if_index == ~0)
14219 errmsg ("missing interface name or sw_if_index");
14223 if (new_show_dev_instance == ~0)
14225 errmsg ("missing new_show_dev_instance");
14229 M (INTERFACE_NAME_RENUMBER, mp);
14231 mp->sw_if_index = ntohl (sw_if_index);
14232 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14240 api_ip_probe_neighbor (vat_main_t * vam)
14242 unformat_input_t *i = vam->input;
14243 vl_api_ip_probe_neighbor_t *mp;
14244 vl_api_address_t dst_adr;
14250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14252 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14254 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14256 else if (unformat (i, "address %U", unformat_vl_api_address, dst_adr))
14264 errmsg ("missing interface");
14270 errmsg ("missing addresses");
14274 M (IP_PROBE_NEIGHBOR, mp);
14276 mp->sw_if_index = ntohl (sw_if_index);
14277 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
14285 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14287 unformat_input_t *i = vam->input;
14288 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14289 u8 mode = IP_SCAN_V46_NEIGHBORS;
14290 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14293 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14295 if (unformat (i, "ip4"))
14296 mode = IP_SCAN_V4_NEIGHBORS;
14297 else if (unformat (i, "ip6"))
14298 mode = IP_SCAN_V6_NEIGHBORS;
14299 if (unformat (i, "both"))
14300 mode = IP_SCAN_V46_NEIGHBORS;
14301 else if (unformat (i, "disable"))
14302 mode = IP_SCAN_DISABLED;
14303 else if (unformat (i, "interval %d", &interval))
14305 else if (unformat (i, "max-time %d", &time))
14307 else if (unformat (i, "max-update %d", &update))
14309 else if (unformat (i, "delay %d", &delay))
14311 else if (unformat (i, "stale %d", &stale))
14317 if (interval > 255)
14319 errmsg ("interval cannot exceed 255 minutes.");
14324 errmsg ("max-time cannot exceed 255 usec.");
14329 errmsg ("max-update cannot exceed 255.");
14334 errmsg ("delay cannot exceed 255 msec.");
14339 errmsg ("stale cannot exceed 255 minutes.");
14343 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14345 mp->scan_interval = interval;
14346 mp->max_proc_time = time;
14347 mp->max_update = update;
14348 mp->scan_int_delay = delay;
14349 mp->stale_threshold = stale;
14357 api_want_ip4_arp_events (vat_main_t * vam)
14359 unformat_input_t *line_input = vam->input;
14360 vl_api_want_ip4_arp_events_t *mp;
14361 ip4_address_t address;
14362 int address_set = 0;
14363 u32 enable_disable = 1;
14366 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14368 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14370 else if (unformat (line_input, "del"))
14371 enable_disable = 0;
14376 if (address_set == 0)
14378 errmsg ("missing addresses");
14382 M (WANT_IP4_ARP_EVENTS, mp);
14383 mp->enable_disable = enable_disable;
14384 mp->pid = htonl (getpid ());
14385 clib_memcpy (mp->ip, &address, sizeof (address));
14393 api_want_ip6_nd_events (vat_main_t * vam)
14395 unformat_input_t *line_input = vam->input;
14396 vl_api_want_ip6_nd_events_t *mp;
14397 vl_api_ip6_address_t address;
14398 int address_set = 0;
14399 u32 enable_disable = 1;
14402 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14405 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14407 else if (unformat (line_input, "del"))
14408 enable_disable = 0;
14413 if (address_set == 0)
14415 errmsg ("missing addresses");
14419 M (WANT_IP6_ND_EVENTS, mp);
14420 mp->enable_disable = enable_disable;
14421 mp->pid = htonl (getpid ());
14422 clib_memcpy (&mp->ip, &address, sizeof (address));
14430 api_want_l2_macs_events (vat_main_t * vam)
14432 unformat_input_t *line_input = vam->input;
14433 vl_api_want_l2_macs_events_t *mp;
14434 u8 enable_disable = 1;
14435 u32 scan_delay = 0;
14436 u32 max_macs_in_event = 0;
14437 u32 learn_limit = 0;
14440 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14442 if (unformat (line_input, "learn-limit %d", &learn_limit))
14444 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14446 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14448 else if (unformat (line_input, "disable"))
14449 enable_disable = 0;
14454 M (WANT_L2_MACS_EVENTS, mp);
14455 mp->enable_disable = enable_disable;
14456 mp->pid = htonl (getpid ());
14457 mp->learn_limit = htonl (learn_limit);
14458 mp->scan_delay = (u8) scan_delay;
14459 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14466 api_input_acl_set_interface (vat_main_t * vam)
14468 unformat_input_t *i = vam->input;
14469 vl_api_input_acl_set_interface_t *mp;
14471 int sw_if_index_set;
14472 u32 ip4_table_index = ~0;
14473 u32 ip6_table_index = ~0;
14474 u32 l2_table_index = ~0;
14478 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14480 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14481 sw_if_index_set = 1;
14482 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14483 sw_if_index_set = 1;
14484 else if (unformat (i, "del"))
14486 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14488 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14490 else if (unformat (i, "l2-table %d", &l2_table_index))
14494 clib_warning ("parse error '%U'", format_unformat_error, i);
14499 if (sw_if_index_set == 0)
14501 errmsg ("missing interface name or sw_if_index");
14505 M (INPUT_ACL_SET_INTERFACE, mp);
14507 mp->sw_if_index = ntohl (sw_if_index);
14508 mp->ip4_table_index = ntohl (ip4_table_index);
14509 mp->ip6_table_index = ntohl (ip6_table_index);
14510 mp->l2_table_index = ntohl (l2_table_index);
14511 mp->is_add = is_add;
14519 api_output_acl_set_interface (vat_main_t * vam)
14521 unformat_input_t *i = vam->input;
14522 vl_api_output_acl_set_interface_t *mp;
14524 int sw_if_index_set;
14525 u32 ip4_table_index = ~0;
14526 u32 ip6_table_index = ~0;
14527 u32 l2_table_index = ~0;
14531 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14533 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14534 sw_if_index_set = 1;
14535 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14536 sw_if_index_set = 1;
14537 else if (unformat (i, "del"))
14539 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14541 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14543 else if (unformat (i, "l2-table %d", &l2_table_index))
14547 clib_warning ("parse error '%U'", format_unformat_error, i);
14552 if (sw_if_index_set == 0)
14554 errmsg ("missing interface name or sw_if_index");
14558 M (OUTPUT_ACL_SET_INTERFACE, mp);
14560 mp->sw_if_index = ntohl (sw_if_index);
14561 mp->ip4_table_index = ntohl (ip4_table_index);
14562 mp->ip6_table_index = ntohl (ip6_table_index);
14563 mp->l2_table_index = ntohl (l2_table_index);
14564 mp->is_add = is_add;
14572 api_ip_address_dump (vat_main_t * vam)
14574 unformat_input_t *i = vam->input;
14575 vl_api_ip_address_dump_t *mp;
14576 vl_api_control_ping_t *mp_ping;
14577 u32 sw_if_index = ~0;
14578 u8 sw_if_index_set = 0;
14583 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14585 if (unformat (i, "sw_if_index %d", &sw_if_index))
14586 sw_if_index_set = 1;
14588 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14589 sw_if_index_set = 1;
14590 else if (unformat (i, "ipv4"))
14592 else if (unformat (i, "ipv6"))
14598 if (ipv4_set && ipv6_set)
14600 errmsg ("ipv4 and ipv6 flags cannot be both set");
14604 if ((!ipv4_set) && (!ipv6_set))
14606 errmsg ("no ipv4 nor ipv6 flag set");
14610 if (sw_if_index_set == 0)
14612 errmsg ("missing interface name or sw_if_index");
14616 vam->current_sw_if_index = sw_if_index;
14617 vam->is_ipv6 = ipv6_set;
14619 M (IP_ADDRESS_DUMP, mp);
14620 mp->sw_if_index = ntohl (sw_if_index);
14621 mp->is_ipv6 = ipv6_set;
14624 /* Use a control ping for synchronization */
14625 MPING (CONTROL_PING, mp_ping);
14633 api_ip_dump (vat_main_t * vam)
14635 vl_api_ip_dump_t *mp;
14636 vl_api_control_ping_t *mp_ping;
14637 unformat_input_t *in = vam->input;
14644 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14646 if (unformat (in, "ipv4"))
14648 else if (unformat (in, "ipv6"))
14654 if (ipv4_set && ipv6_set)
14656 errmsg ("ipv4 and ipv6 flags cannot be both set");
14660 if ((!ipv4_set) && (!ipv6_set))
14662 errmsg ("no ipv4 nor ipv6 flag set");
14666 is_ipv6 = ipv6_set;
14667 vam->is_ipv6 = is_ipv6;
14669 /* free old data */
14670 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14672 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14674 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14677 mp->is_ipv6 = ipv6_set;
14680 /* Use a control ping for synchronization */
14681 MPING (CONTROL_PING, mp_ping);
14689 api_ipsec_spd_add_del (vat_main_t * vam)
14691 unformat_input_t *i = vam->input;
14692 vl_api_ipsec_spd_add_del_t *mp;
14697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14699 if (unformat (i, "spd_id %d", &spd_id))
14701 else if (unformat (i, "del"))
14705 clib_warning ("parse error '%U'", format_unformat_error, i);
14711 errmsg ("spd_id must be set");
14715 M (IPSEC_SPD_ADD_DEL, mp);
14717 mp->spd_id = ntohl (spd_id);
14718 mp->is_add = is_add;
14726 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14728 unformat_input_t *i = vam->input;
14729 vl_api_ipsec_interface_add_del_spd_t *mp;
14731 u8 sw_if_index_set = 0;
14732 u32 spd_id = (u32) ~ 0;
14736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14738 if (unformat (i, "del"))
14740 else if (unformat (i, "spd_id %d", &spd_id))
14743 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14744 sw_if_index_set = 1;
14745 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14746 sw_if_index_set = 1;
14749 clib_warning ("parse error '%U'", format_unformat_error, i);
14755 if (spd_id == (u32) ~ 0)
14757 errmsg ("spd_id must be set");
14761 if (sw_if_index_set == 0)
14763 errmsg ("missing interface name or sw_if_index");
14767 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14769 mp->spd_id = ntohl (spd_id);
14770 mp->sw_if_index = ntohl (sw_if_index);
14771 mp->is_add = is_add;
14779 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14781 unformat_input_t *i = vam->input;
14782 vl_api_ipsec_spd_entry_add_del_t *mp;
14783 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14784 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14786 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14787 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14788 vl_api_address_t laddr_start = { }, laddr_stop =
14797 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14799 if (unformat (i, "del"))
14801 if (unformat (i, "outbound"))
14803 if (unformat (i, "inbound"))
14805 else if (unformat (i, "spd_id %d", &spd_id))
14807 else if (unformat (i, "sa_id %d", &sa_id))
14809 else if (unformat (i, "priority %d", &priority))
14811 else if (unformat (i, "protocol %d", &protocol))
14813 else if (unformat (i, "lport_start %d", &lport_start))
14815 else if (unformat (i, "lport_stop %d", &lport_stop))
14817 else if (unformat (i, "rport_start %d", &rport_start))
14819 else if (unformat (i, "rport_stop %d", &rport_stop))
14821 else if (unformat (i, "laddr_start %U",
14822 unformat_vl_api_address, &laddr_start))
14824 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14827 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14830 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14834 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14836 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14838 clib_warning ("unsupported action: 'resolve'");
14844 clib_warning ("parse error '%U'", format_unformat_error, i);
14850 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14852 mp->is_add = is_add;
14854 mp->entry.spd_id = ntohl (spd_id);
14855 mp->entry.priority = ntohl (priority);
14856 mp->entry.is_outbound = is_outbound;
14858 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14859 sizeof (vl_api_address_t));
14860 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14861 sizeof (vl_api_address_t));
14862 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14863 sizeof (vl_api_address_t));
14864 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14865 sizeof (vl_api_address_t));
14867 mp->entry.protocol = (u8) protocol;
14868 mp->entry.local_port_start = ntohs ((u16) lport_start);
14869 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14870 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14871 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14872 mp->entry.policy = (u8) policy;
14873 mp->entry.sa_id = ntohl (sa_id);
14881 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14883 unformat_input_t *i = vam->input;
14884 vl_api_ipsec_sad_entry_add_del_t *mp;
14885 u32 sad_id = 0, spi = 0;
14886 u8 *ck = 0, *ik = 0;
14889 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14890 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14891 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14892 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14893 vl_api_address_t tun_src, tun_dst;
14896 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14898 if (unformat (i, "del"))
14900 else if (unformat (i, "sad_id %d", &sad_id))
14902 else if (unformat (i, "spi %d", &spi))
14904 else if (unformat (i, "esp"))
14905 protocol = IPSEC_API_PROTO_ESP;
14907 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14909 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14910 if (ADDRESS_IP6 == tun_src.af)
14911 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14914 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14916 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14917 if (ADDRESS_IP6 == tun_src.af)
14918 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14921 if (unformat (i, "crypto_alg %U",
14922 unformat_ipsec_api_crypto_alg, &crypto_alg))
14924 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14926 else if (unformat (i, "integ_alg %U",
14927 unformat_ipsec_api_integ_alg, &integ_alg))
14929 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14933 clib_warning ("parse error '%U'", format_unformat_error, i);
14939 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14941 mp->is_add = is_add;
14942 mp->entry.sad_id = ntohl (sad_id);
14943 mp->entry.protocol = protocol;
14944 mp->entry.spi = ntohl (spi);
14945 mp->entry.flags = flags;
14947 mp->entry.crypto_algorithm = crypto_alg;
14948 mp->entry.integrity_algorithm = integ_alg;
14949 mp->entry.crypto_key.length = vec_len (ck);
14950 mp->entry.integrity_key.length = vec_len (ik);
14952 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14953 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14955 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14956 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14959 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14961 clib_memcpy (mp->entry.integrity_key.data, ik,
14962 mp->entry.integrity_key.length);
14964 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14966 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14967 sizeof (mp->entry.tunnel_src));
14968 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14969 sizeof (mp->entry.tunnel_dst));
14978 api_ipsec_sa_set_key (vat_main_t * vam)
14980 unformat_input_t *i = vam->input;
14981 vl_api_ipsec_sa_set_key_t *mp;
14983 u8 *ck = 0, *ik = 0;
14986 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14988 if (unformat (i, "sa_id %d", &sa_id))
14990 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14992 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14996 clib_warning ("parse error '%U'", format_unformat_error, i);
15001 M (IPSEC_SA_SET_KEY, mp);
15003 mp->sa_id = ntohl (sa_id);
15004 mp->crypto_key.length = vec_len (ck);
15005 mp->integrity_key.length = vec_len (ik);
15007 if (mp->crypto_key.length > sizeof (mp->crypto_key.data))
15008 mp->crypto_key.length = sizeof (mp->crypto_key.data);
15010 if (mp->integrity_key.length > sizeof (mp->integrity_key.data))
15011 mp->integrity_key.length = sizeof (mp->integrity_key.data);
15014 clib_memcpy (mp->crypto_key.data, ck, mp->crypto_key.length);
15016 clib_memcpy (mp->integrity_key.data, ik, mp->integrity_key.length);
15024 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15026 unformat_input_t *i = vam->input;
15027 vl_api_ipsec_tunnel_if_add_del_t *mp;
15028 u32 local_spi = 0, remote_spi = 0;
15029 u32 crypto_alg = 0, integ_alg = 0;
15030 u8 *lck = NULL, *rck = NULL;
15031 u8 *lik = NULL, *rik = NULL;
15032 ip4_address_t local_ip = { {0} };
15033 ip4_address_t remote_ip = { {0} };
15036 u8 anti_replay = 0;
15041 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15043 if (unformat (i, "del"))
15045 else if (unformat (i, "esn"))
15047 else if (unformat (i, "anti_replay"))
15049 else if (unformat (i, "local_spi %d", &local_spi))
15051 else if (unformat (i, "remote_spi %d", &remote_spi))
15053 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
15055 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
15057 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15060 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15062 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15064 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15068 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
15070 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15072 errmsg ("unsupported crypto-alg: '%U'\n",
15073 format_ipsec_crypto_alg, crypto_alg);
15079 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
15081 if (integ_alg >= IPSEC_INTEG_N_ALG)
15083 errmsg ("unsupported integ-alg: '%U'\n",
15084 format_ipsec_integ_alg, integ_alg);
15088 else if (unformat (i, "instance %u", &instance))
15092 errmsg ("parse error '%U'\n", format_unformat_error, i);
15097 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15099 mp->is_add = is_add;
15101 mp->anti_replay = anti_replay;
15103 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
15104 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
15106 mp->local_spi = htonl (local_spi);
15107 mp->remote_spi = htonl (remote_spi);
15108 mp->crypto_alg = (u8) crypto_alg;
15110 mp->local_crypto_key_len = 0;
15113 mp->local_crypto_key_len = vec_len (lck);
15114 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15115 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15116 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15119 mp->remote_crypto_key_len = 0;
15122 mp->remote_crypto_key_len = vec_len (rck);
15123 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15124 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15125 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15128 mp->integ_alg = (u8) integ_alg;
15130 mp->local_integ_key_len = 0;
15133 mp->local_integ_key_len = vec_len (lik);
15134 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15135 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15136 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15139 mp->remote_integ_key_len = 0;
15142 mp->remote_integ_key_len = vec_len (rik);
15143 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15144 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15145 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15150 mp->renumber = renumber;
15151 mp->show_instance = ntohl (instance);
15160 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15162 vat_main_t *vam = &vat_main;
15164 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15165 "crypto_key %U integ_alg %u integ_key %U flags %x "
15166 "tunnel_src_addr %U tunnel_dst_addr %U "
15167 "salt %u seq_outbound %lu last_seq_inbound %lu "
15168 "replay_window %lu\n",
15169 ntohl (mp->entry.sad_id),
15170 ntohl (mp->sw_if_index),
15171 ntohl (mp->entry.spi),
15172 ntohl (mp->entry.protocol),
15173 ntohl (mp->entry.crypto_algorithm),
15174 format_hex_bytes, mp->entry.crypto_key.data,
15175 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
15176 format_hex_bytes, mp->entry.integrity_key.data,
15177 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
15178 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
15179 &mp->entry.tunnel_dst, ntohl (mp->salt),
15180 clib_net_to_host_u64 (mp->seq_outbound),
15181 clib_net_to_host_u64 (mp->last_seq_inbound),
15182 clib_net_to_host_u64 (mp->replay_window));
15185 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15186 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15189 vat_json_object_add_address (vat_json_node_t * node,
15190 const vl_api_address_t * addr)
15192 if (ADDRESS_IP6 == addr->af)
15194 struct in6_addr ip6;
15196 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
15197 vat_json_object_add_ip6 (node, "ip_address", ip6);
15201 struct in_addr ip4;
15203 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
15204 vat_json_object_add_ip4 (node, "ip_address", ip4);
15208 static void vl_api_ipsec_sa_details_t_handler_json
15209 (vl_api_ipsec_sa_details_t * mp)
15211 vat_main_t *vam = &vat_main;
15212 vat_json_node_t *node = NULL;
15213 vl_api_ipsec_sad_flags_t flags;
15215 if (VAT_JSON_ARRAY != vam->json_tree.type)
15217 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15218 vat_json_init_array (&vam->json_tree);
15220 node = vat_json_array_add (&vam->json_tree);
15222 vat_json_init_object (node);
15223 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
15224 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15225 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
15226 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
15227 vat_json_object_add_uint (node, "crypto_alg",
15228 ntohl (mp->entry.crypto_algorithm));
15229 vat_json_object_add_uint (node, "integ_alg",
15230 ntohl (mp->entry.integrity_algorithm));
15231 flags = ntohl (mp->entry.flags);
15232 vat_json_object_add_uint (node, "use_esn",
15234 IPSEC_API_SAD_FLAG_USE_EXTENDED_SEQ_NUM));
15235 vat_json_object_add_uint (node, "use_anti_replay",
15236 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
15237 vat_json_object_add_uint (node, "is_tunnel",
15238 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
15239 vat_json_object_add_uint (node, "is_tunnel_ip6",
15240 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
15241 vat_json_object_add_uint (node, "udp_encap",
15242 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
15243 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
15244 mp->entry.crypto_key.length);
15245 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
15246 mp->entry.integrity_key.length);
15247 vat_json_object_add_address (node, &mp->entry.tunnel_src);
15248 vat_json_object_add_address (node, &mp->entry.tunnel_dst);
15249 vat_json_object_add_uint (node, "replay_window",
15250 clib_net_to_host_u64 (mp->replay_window));
15254 api_ipsec_sa_dump (vat_main_t * vam)
15256 unformat_input_t *i = vam->input;
15257 vl_api_ipsec_sa_dump_t *mp;
15258 vl_api_control_ping_t *mp_ping;
15262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15264 if (unformat (i, "sa_id %d", &sa_id))
15268 clib_warning ("parse error '%U'", format_unformat_error, i);
15273 M (IPSEC_SA_DUMP, mp);
15275 mp->sa_id = ntohl (sa_id);
15279 /* Use a control ping for synchronization */
15280 M (CONTROL_PING, mp_ping);
15288 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15290 unformat_input_t *i = vam->input;
15291 vl_api_ipsec_tunnel_if_set_key_t *mp;
15292 u32 sw_if_index = ~0;
15293 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15300 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15304 (i, "local crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15305 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15308 (i, "remote crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15309 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15312 (i, "local integ %U", unformat_ipsec_api_integ_alg, &alg))
15313 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15316 (i, "remote integ %U", unformat_ipsec_api_integ_alg, &alg))
15317 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15318 else if (unformat (i, "%U", unformat_hex_string, &key))
15322 clib_warning ("parse error '%U'", format_unformat_error, i);
15327 if (sw_if_index == ~0)
15329 errmsg ("interface must be specified");
15333 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15335 errmsg ("key type must be specified");
15341 errmsg ("algorithm must be specified");
15345 if (vec_len (key) == 0)
15347 errmsg ("key must be specified");
15351 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15353 mp->sw_if_index = htonl (sw_if_index);
15355 mp->key_type = key_type;
15356 mp->key_len = vec_len (key);
15357 clib_memcpy (mp->key, key, vec_len (key));
15366 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15368 unformat_input_t *i = vam->input;
15369 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15370 u32 sw_if_index = ~0;
15372 u8 is_outbound = (u8) ~ 0;
15375 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15377 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15379 else if (unformat (i, "sa_id %d", &sa_id))
15381 else if (unformat (i, "outbound"))
15383 else if (unformat (i, "inbound"))
15387 clib_warning ("parse error '%U'", format_unformat_error, i);
15392 if (sw_if_index == ~0)
15394 errmsg ("interface must be specified");
15400 errmsg ("SA ID must be specified");
15404 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15406 mp->sw_if_index = htonl (sw_if_index);
15407 mp->sa_id = htonl (sa_id);
15408 mp->is_outbound = is_outbound;
15417 api_get_first_msg_id (vat_main_t * vam)
15419 vl_api_get_first_msg_id_t *mp;
15420 unformat_input_t *i = vam->input;
15425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15427 if (unformat (i, "client %s", &name))
15435 errmsg ("missing client name");
15438 vec_add1 (name, 0);
15440 if (vec_len (name) > 63)
15442 errmsg ("client name too long");
15446 M (GET_FIRST_MSG_ID, mp);
15447 clib_memcpy (mp->name, name, vec_len (name));
15454 api_cop_interface_enable_disable (vat_main_t * vam)
15456 unformat_input_t *line_input = vam->input;
15457 vl_api_cop_interface_enable_disable_t *mp;
15458 u32 sw_if_index = ~0;
15459 u8 enable_disable = 1;
15462 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15464 if (unformat (line_input, "disable"))
15465 enable_disable = 0;
15466 if (unformat (line_input, "enable"))
15467 enable_disable = 1;
15468 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15469 vam, &sw_if_index))
15471 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15477 if (sw_if_index == ~0)
15479 errmsg ("missing interface name or sw_if_index");
15483 /* Construct the API message */
15484 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15485 mp->sw_if_index = ntohl (sw_if_index);
15486 mp->enable_disable = enable_disable;
15490 /* Wait for the reply */
15496 api_cop_whitelist_enable_disable (vat_main_t * vam)
15498 unformat_input_t *line_input = vam->input;
15499 vl_api_cop_whitelist_enable_disable_t *mp;
15500 u32 sw_if_index = ~0;
15501 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15505 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15507 if (unformat (line_input, "ip4"))
15509 else if (unformat (line_input, "ip6"))
15511 else if (unformat (line_input, "default"))
15513 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15514 vam, &sw_if_index))
15516 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15518 else if (unformat (line_input, "fib-id %d", &fib_id))
15524 if (sw_if_index == ~0)
15526 errmsg ("missing interface name or sw_if_index");
15530 /* Construct the API message */
15531 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15532 mp->sw_if_index = ntohl (sw_if_index);
15533 mp->fib_id = ntohl (fib_id);
15536 mp->default_cop = default_cop;
15540 /* Wait for the reply */
15546 api_get_node_graph (vat_main_t * vam)
15548 vl_api_get_node_graph_t *mp;
15551 M (GET_NODE_GRAPH, mp);
15555 /* Wait for the reply */
15561 /** Used for parsing LISP eids */
15562 typedef CLIB_PACKED(struct{
15563 u8 addr[16]; /**< eid address */
15564 u32 len; /**< prefix length if IP */
15565 u8 type; /**< type of eid */
15570 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15572 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15574 clib_memset (a, 0, sizeof (a[0]));
15576 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15578 a->type = 0; /* ipv4 type */
15580 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15582 a->type = 1; /* ipv6 type */
15584 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15586 a->type = 2; /* mac type */
15588 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15590 a->type = 3; /* NSH type */
15591 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15592 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15599 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15608 lisp_eid_size_vat (u8 type)
15625 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15627 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15631 api_one_add_del_locator_set (vat_main_t * vam)
15633 unformat_input_t *input = vam->input;
15634 vl_api_one_add_del_locator_set_t *mp;
15636 u8 *locator_set_name = NULL;
15637 u8 locator_set_name_set = 0;
15638 vl_api_local_locator_t locator, *locators = 0;
15639 u32 sw_if_index, priority, weight;
15643 /* Parse args required to build the message */
15644 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15646 if (unformat (input, "del"))
15650 else if (unformat (input, "locator-set %s", &locator_set_name))
15652 locator_set_name_set = 1;
15654 else if (unformat (input, "sw_if_index %u p %u w %u",
15655 &sw_if_index, &priority, &weight))
15657 locator.sw_if_index = htonl (sw_if_index);
15658 locator.priority = priority;
15659 locator.weight = weight;
15660 vec_add1 (locators, locator);
15664 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15665 &sw_if_index, &priority, &weight))
15667 locator.sw_if_index = htonl (sw_if_index);
15668 locator.priority = priority;
15669 locator.weight = weight;
15670 vec_add1 (locators, locator);
15676 if (locator_set_name_set == 0)
15678 errmsg ("missing locator-set name");
15679 vec_free (locators);
15683 if (vec_len (locator_set_name) > 64)
15685 errmsg ("locator-set name too long");
15686 vec_free (locator_set_name);
15687 vec_free (locators);
15690 vec_add1 (locator_set_name, 0);
15692 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15694 /* Construct the API message */
15695 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15697 mp->is_add = is_add;
15698 clib_memcpy (mp->locator_set_name, locator_set_name,
15699 vec_len (locator_set_name));
15700 vec_free (locator_set_name);
15702 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15704 clib_memcpy (mp->locators, locators, data_len);
15705 vec_free (locators);
15710 /* Wait for a reply... */
15715 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15718 api_one_add_del_locator (vat_main_t * vam)
15720 unformat_input_t *input = vam->input;
15721 vl_api_one_add_del_locator_t *mp;
15722 u32 tmp_if_index = ~0;
15723 u32 sw_if_index = ~0;
15724 u8 sw_if_index_set = 0;
15725 u8 sw_if_index_if_name_set = 0;
15727 u8 priority_set = 0;
15731 u8 *locator_set_name = NULL;
15732 u8 locator_set_name_set = 0;
15735 /* Parse args required to build the message */
15736 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15738 if (unformat (input, "del"))
15742 else if (unformat (input, "locator-set %s", &locator_set_name))
15744 locator_set_name_set = 1;
15746 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15749 sw_if_index_if_name_set = 1;
15750 sw_if_index = tmp_if_index;
15752 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15754 sw_if_index_set = 1;
15755 sw_if_index = tmp_if_index;
15757 else if (unformat (input, "p %d", &priority))
15761 else if (unformat (input, "w %d", &weight))
15769 if (locator_set_name_set == 0)
15771 errmsg ("missing locator-set name");
15775 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15777 errmsg ("missing sw_if_index");
15778 vec_free (locator_set_name);
15782 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15784 errmsg ("cannot use both params interface name and sw_if_index");
15785 vec_free (locator_set_name);
15789 if (priority_set == 0)
15791 errmsg ("missing locator-set priority");
15792 vec_free (locator_set_name);
15796 if (weight_set == 0)
15798 errmsg ("missing locator-set weight");
15799 vec_free (locator_set_name);
15803 if (vec_len (locator_set_name) > 64)
15805 errmsg ("locator-set name too long");
15806 vec_free (locator_set_name);
15809 vec_add1 (locator_set_name, 0);
15811 /* Construct the API message */
15812 M (ONE_ADD_DEL_LOCATOR, mp);
15814 mp->is_add = is_add;
15815 mp->sw_if_index = ntohl (sw_if_index);
15816 mp->priority = priority;
15817 mp->weight = weight;
15818 clib_memcpy (mp->locator_set_name, locator_set_name,
15819 vec_len (locator_set_name));
15820 vec_free (locator_set_name);
15825 /* Wait for a reply... */
15830 #define api_lisp_add_del_locator api_one_add_del_locator
15833 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15835 u32 *key_id = va_arg (*args, u32 *);
15838 if (unformat (input, "%s", &s))
15840 if (!strcmp ((char *) s, "sha1"))
15841 key_id[0] = HMAC_SHA_1_96;
15842 else if (!strcmp ((char *) s, "sha256"))
15843 key_id[0] = HMAC_SHA_256_128;
15846 clib_warning ("invalid key_id: '%s'", s);
15847 key_id[0] = HMAC_NO_KEY;
15858 api_one_add_del_local_eid (vat_main_t * vam)
15860 unformat_input_t *input = vam->input;
15861 vl_api_one_add_del_local_eid_t *mp;
15864 lisp_eid_vat_t _eid, *eid = &_eid;
15865 u8 *locator_set_name = 0;
15866 u8 locator_set_name_set = 0;
15872 /* Parse args required to build the message */
15873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15875 if (unformat (input, "del"))
15879 else if (unformat (input, "vni %d", &vni))
15883 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15887 else if (unformat (input, "locator-set %s", &locator_set_name))
15889 locator_set_name_set = 1;
15891 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15893 else if (unformat (input, "secret-key %_%v%_", &key))
15899 if (locator_set_name_set == 0)
15901 errmsg ("missing locator-set name");
15907 errmsg ("EID address not set!");
15908 vec_free (locator_set_name);
15912 if (key && (0 == key_id))
15914 errmsg ("invalid key_id!");
15918 if (vec_len (key) > 64)
15920 errmsg ("key too long");
15925 if (vec_len (locator_set_name) > 64)
15927 errmsg ("locator-set name too long");
15928 vec_free (locator_set_name);
15931 vec_add1 (locator_set_name, 0);
15933 /* Construct the API message */
15934 M (ONE_ADD_DEL_LOCAL_EID, mp);
15936 mp->is_add = is_add;
15937 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15938 mp->eid_type = eid->type;
15939 mp->prefix_len = eid->len;
15940 mp->vni = clib_host_to_net_u32 (vni);
15941 mp->key_id = clib_host_to_net_u16 (key_id);
15942 clib_memcpy (mp->locator_set_name, locator_set_name,
15943 vec_len (locator_set_name));
15944 clib_memcpy (mp->key, key, vec_len (key));
15946 vec_free (locator_set_name);
15952 /* Wait for a reply... */
15957 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15960 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15962 u32 dp_table = 0, vni = 0;;
15963 unformat_input_t *input = vam->input;
15964 vl_api_gpe_add_del_fwd_entry_t *mp;
15966 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15967 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15968 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15969 u32 action = ~0, w;
15970 ip4_address_t rmt_rloc4, lcl_rloc4;
15971 ip6_address_t rmt_rloc6, lcl_rloc6;
15972 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15975 clib_memset (&rloc, 0, sizeof (rloc));
15977 /* Parse args required to build the message */
15978 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15980 if (unformat (input, "del"))
15982 else if (unformat (input, "add"))
15984 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15988 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15992 else if (unformat (input, "vrf %d", &dp_table))
15994 else if (unformat (input, "bd %d", &dp_table))
15996 else if (unformat (input, "vni %d", &vni))
15998 else if (unformat (input, "w %d", &w))
16002 errmsg ("No RLOC configured for setting priority/weight!");
16005 curr_rloc->weight = w;
16007 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16008 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16012 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16014 vec_add1 (lcl_locs, rloc);
16016 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16017 vec_add1 (rmt_locs, rloc);
16018 /* weight saved in rmt loc */
16019 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16021 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16022 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16025 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16027 vec_add1 (lcl_locs, rloc);
16029 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16030 vec_add1 (rmt_locs, rloc);
16031 /* weight saved in rmt loc */
16032 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16034 else if (unformat (input, "action %d", &action))
16040 clib_warning ("parse error '%U'", format_unformat_error, input);
16047 errmsg ("remote eid addresses not set");
16051 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16053 errmsg ("eid types don't match");
16057 if (0 == rmt_locs && (u32) ~ 0 == action)
16059 errmsg ("action not set for negative mapping");
16063 /* Construct the API message */
16064 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16065 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16067 mp->is_add = is_add;
16068 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16069 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16070 mp->eid_type = rmt_eid->type;
16071 mp->dp_table = clib_host_to_net_u32 (dp_table);
16072 mp->vni = clib_host_to_net_u32 (vni);
16073 mp->rmt_len = rmt_eid->len;
16074 mp->lcl_len = lcl_eid->len;
16075 mp->action = action;
16077 if (0 != rmt_locs && 0 != lcl_locs)
16079 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16080 clib_memcpy (mp->locs, lcl_locs,
16081 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16083 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16084 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16085 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16087 vec_free (lcl_locs);
16088 vec_free (rmt_locs);
16093 /* Wait for a reply... */
16099 api_one_add_del_map_server (vat_main_t * vam)
16101 unformat_input_t *input = vam->input;
16102 vl_api_one_add_del_map_server_t *mp;
16106 ip4_address_t ipv4;
16107 ip6_address_t ipv6;
16110 /* Parse args required to build the message */
16111 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16113 if (unformat (input, "del"))
16117 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16121 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16129 if (ipv4_set && ipv6_set)
16131 errmsg ("both eid v4 and v6 addresses set");
16135 if (!ipv4_set && !ipv6_set)
16137 errmsg ("eid addresses not set");
16141 /* Construct the API message */
16142 M (ONE_ADD_DEL_MAP_SERVER, mp);
16144 mp->is_add = is_add;
16148 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16153 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16159 /* Wait for a reply... */
16164 #define api_lisp_add_del_map_server api_one_add_del_map_server
16167 api_one_add_del_map_resolver (vat_main_t * vam)
16169 unformat_input_t *input = vam->input;
16170 vl_api_one_add_del_map_resolver_t *mp;
16174 ip4_address_t ipv4;
16175 ip6_address_t ipv6;
16178 /* Parse args required to build the message */
16179 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16181 if (unformat (input, "del"))
16185 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16189 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16197 if (ipv4_set && ipv6_set)
16199 errmsg ("both eid v4 and v6 addresses set");
16203 if (!ipv4_set && !ipv6_set)
16205 errmsg ("eid addresses not set");
16209 /* Construct the API message */
16210 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16212 mp->is_add = is_add;
16216 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16221 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16227 /* Wait for a reply... */
16232 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16235 api_lisp_gpe_enable_disable (vat_main_t * vam)
16237 unformat_input_t *input = vam->input;
16238 vl_api_gpe_enable_disable_t *mp;
16243 /* Parse args required to build the message */
16244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16246 if (unformat (input, "enable"))
16251 else if (unformat (input, "disable"))
16262 errmsg ("Value not set");
16266 /* Construct the API message */
16267 M (GPE_ENABLE_DISABLE, mp);
16274 /* Wait for a reply... */
16280 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16282 unformat_input_t *input = vam->input;
16283 vl_api_one_rloc_probe_enable_disable_t *mp;
16288 /* Parse args required to build the message */
16289 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16291 if (unformat (input, "enable"))
16296 else if (unformat (input, "disable"))
16304 errmsg ("Value not set");
16308 /* Construct the API message */
16309 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16311 mp->is_enabled = is_en;
16316 /* Wait for a reply... */
16321 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16324 api_one_map_register_enable_disable (vat_main_t * vam)
16326 unformat_input_t *input = vam->input;
16327 vl_api_one_map_register_enable_disable_t *mp;
16332 /* Parse args required to build the message */
16333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16335 if (unformat (input, "enable"))
16340 else if (unformat (input, "disable"))
16348 errmsg ("Value not set");
16352 /* Construct the API message */
16353 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16355 mp->is_enabled = is_en;
16360 /* Wait for a reply... */
16365 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16368 api_one_enable_disable (vat_main_t * vam)
16370 unformat_input_t *input = vam->input;
16371 vl_api_one_enable_disable_t *mp;
16376 /* Parse args required to build the message */
16377 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16379 if (unformat (input, "enable"))
16384 else if (unformat (input, "disable"))
16394 errmsg ("Value not set");
16398 /* Construct the API message */
16399 M (ONE_ENABLE_DISABLE, mp);
16406 /* Wait for a reply... */
16411 #define api_lisp_enable_disable api_one_enable_disable
16414 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16416 unformat_input_t *input = vam->input;
16417 vl_api_one_enable_disable_xtr_mode_t *mp;
16422 /* Parse args required to build the message */
16423 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16425 if (unformat (input, "enable"))
16430 else if (unformat (input, "disable"))
16440 errmsg ("Value not set");
16444 /* Construct the API message */
16445 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16452 /* Wait for a reply... */
16458 api_one_show_xtr_mode (vat_main_t * vam)
16460 vl_api_one_show_xtr_mode_t *mp;
16463 /* Construct the API message */
16464 M (ONE_SHOW_XTR_MODE, mp);
16469 /* Wait for a reply... */
16475 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16477 unformat_input_t *input = vam->input;
16478 vl_api_one_enable_disable_pitr_mode_t *mp;
16483 /* Parse args required to build the message */
16484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16486 if (unformat (input, "enable"))
16491 else if (unformat (input, "disable"))
16501 errmsg ("Value not set");
16505 /* Construct the API message */
16506 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16513 /* Wait for a reply... */
16519 api_one_show_pitr_mode (vat_main_t * vam)
16521 vl_api_one_show_pitr_mode_t *mp;
16524 /* Construct the API message */
16525 M (ONE_SHOW_PITR_MODE, mp);
16530 /* Wait for a reply... */
16536 api_one_enable_disable_petr_mode (vat_main_t * vam)
16538 unformat_input_t *input = vam->input;
16539 vl_api_one_enable_disable_petr_mode_t *mp;
16544 /* Parse args required to build the message */
16545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16547 if (unformat (input, "enable"))
16552 else if (unformat (input, "disable"))
16562 errmsg ("Value not set");
16566 /* Construct the API message */
16567 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16574 /* Wait for a reply... */
16580 api_one_show_petr_mode (vat_main_t * vam)
16582 vl_api_one_show_petr_mode_t *mp;
16585 /* Construct the API message */
16586 M (ONE_SHOW_PETR_MODE, mp);
16591 /* Wait for a reply... */
16597 api_show_one_map_register_state (vat_main_t * vam)
16599 vl_api_show_one_map_register_state_t *mp;
16602 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16607 /* wait for reply */
16612 #define api_show_lisp_map_register_state api_show_one_map_register_state
16615 api_show_one_rloc_probe_state (vat_main_t * vam)
16617 vl_api_show_one_rloc_probe_state_t *mp;
16620 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16625 /* wait for reply */
16630 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16633 api_one_add_del_ndp_entry (vat_main_t * vam)
16635 vl_api_one_add_del_ndp_entry_t *mp;
16636 unformat_input_t *input = vam->input;
16641 u8 mac[6] = { 0, };
16642 u8 ip6[16] = { 0, };
16646 /* Parse args required to build the message */
16647 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16649 if (unformat (input, "del"))
16651 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16653 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16655 else if (unformat (input, "bd %d", &bd))
16659 errmsg ("parse error '%U'", format_unformat_error, input);
16664 if (!bd_set || !ip_set || (!mac_set && is_add))
16666 errmsg ("Missing BD, IP or MAC!");
16670 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16671 mp->is_add = is_add;
16672 clib_memcpy (mp->mac, mac, 6);
16673 mp->bd = clib_host_to_net_u32 (bd);
16674 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16679 /* wait for reply */
16685 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16687 vl_api_one_add_del_l2_arp_entry_t *mp;
16688 unformat_input_t *input = vam->input;
16693 u8 mac[6] = { 0, };
16694 u32 ip4 = 0, bd = ~0;
16697 /* Parse args required to build the message */
16698 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16700 if (unformat (input, "del"))
16702 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16704 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16706 else if (unformat (input, "bd %d", &bd))
16710 errmsg ("parse error '%U'", format_unformat_error, input);
16715 if (!bd_set || !ip_set || (!mac_set && is_add))
16717 errmsg ("Missing BD, IP or MAC!");
16721 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16722 mp->is_add = is_add;
16723 clib_memcpy (mp->mac, mac, 6);
16724 mp->bd = clib_host_to_net_u32 (bd);
16730 /* wait for reply */
16736 api_one_ndp_bd_get (vat_main_t * vam)
16738 vl_api_one_ndp_bd_get_t *mp;
16741 M (ONE_NDP_BD_GET, mp);
16746 /* wait for reply */
16752 api_one_ndp_entries_get (vat_main_t * vam)
16754 vl_api_one_ndp_entries_get_t *mp;
16755 unformat_input_t *input = vam->input;
16760 /* Parse args required to build the message */
16761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16763 if (unformat (input, "bd %d", &bd))
16767 errmsg ("parse error '%U'", format_unformat_error, input);
16774 errmsg ("Expected bridge domain!");
16778 M (ONE_NDP_ENTRIES_GET, mp);
16779 mp->bd = clib_host_to_net_u32 (bd);
16784 /* wait for reply */
16790 api_one_l2_arp_bd_get (vat_main_t * vam)
16792 vl_api_one_l2_arp_bd_get_t *mp;
16795 M (ONE_L2_ARP_BD_GET, mp);
16800 /* wait for reply */
16806 api_one_l2_arp_entries_get (vat_main_t * vam)
16808 vl_api_one_l2_arp_entries_get_t *mp;
16809 unformat_input_t *input = vam->input;
16814 /* Parse args required to build the message */
16815 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16817 if (unformat (input, "bd %d", &bd))
16821 errmsg ("parse error '%U'", format_unformat_error, input);
16828 errmsg ("Expected bridge domain!");
16832 M (ONE_L2_ARP_ENTRIES_GET, mp);
16833 mp->bd = clib_host_to_net_u32 (bd);
16838 /* wait for reply */
16844 api_one_stats_enable_disable (vat_main_t * vam)
16846 vl_api_one_stats_enable_disable_t *mp;
16847 unformat_input_t *input = vam->input;
16852 /* Parse args required to build the message */
16853 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16855 if (unformat (input, "enable"))
16860 else if (unformat (input, "disable"))
16870 errmsg ("Value not set");
16874 M (ONE_STATS_ENABLE_DISABLE, mp);
16880 /* wait for reply */
16886 api_show_one_stats_enable_disable (vat_main_t * vam)
16888 vl_api_show_one_stats_enable_disable_t *mp;
16891 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16896 /* wait for reply */
16902 api_show_one_map_request_mode (vat_main_t * vam)
16904 vl_api_show_one_map_request_mode_t *mp;
16907 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16912 /* wait for reply */
16917 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16920 api_one_map_request_mode (vat_main_t * vam)
16922 unformat_input_t *input = vam->input;
16923 vl_api_one_map_request_mode_t *mp;
16927 /* Parse args required to build the message */
16928 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16930 if (unformat (input, "dst-only"))
16932 else if (unformat (input, "src-dst"))
16936 errmsg ("parse error '%U'", format_unformat_error, input);
16941 M (ONE_MAP_REQUEST_MODE, mp);
16948 /* wait for reply */
16953 #define api_lisp_map_request_mode api_one_map_request_mode
16956 * Enable/disable ONE proxy ITR.
16958 * @param vam vpp API test context
16959 * @return return code
16962 api_one_pitr_set_locator_set (vat_main_t * vam)
16964 u8 ls_name_set = 0;
16965 unformat_input_t *input = vam->input;
16966 vl_api_one_pitr_set_locator_set_t *mp;
16971 /* Parse args required to build the message */
16972 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16974 if (unformat (input, "del"))
16976 else if (unformat (input, "locator-set %s", &ls_name))
16980 errmsg ("parse error '%U'", format_unformat_error, input);
16987 errmsg ("locator-set name not set!");
16991 M (ONE_PITR_SET_LOCATOR_SET, mp);
16993 mp->is_add = is_add;
16994 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
16995 vec_free (ls_name);
17000 /* wait for reply */
17005 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17008 api_one_nsh_set_locator_set (vat_main_t * vam)
17010 u8 ls_name_set = 0;
17011 unformat_input_t *input = vam->input;
17012 vl_api_one_nsh_set_locator_set_t *mp;
17017 /* Parse args required to build the message */
17018 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17020 if (unformat (input, "del"))
17022 else if (unformat (input, "ls %s", &ls_name))
17026 errmsg ("parse error '%U'", format_unformat_error, input);
17031 if (!ls_name_set && is_add)
17033 errmsg ("locator-set name not set!");
17037 M (ONE_NSH_SET_LOCATOR_SET, mp);
17039 mp->is_add = is_add;
17040 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17041 vec_free (ls_name);
17046 /* wait for reply */
17052 api_show_one_pitr (vat_main_t * vam)
17054 vl_api_show_one_pitr_t *mp;
17057 if (!vam->json_output)
17059 print (vam->ofp, "%=20s", "lisp status:");
17062 M (SHOW_ONE_PITR, mp);
17066 /* Wait for a reply... */
17071 #define api_show_lisp_pitr api_show_one_pitr
17074 api_one_use_petr (vat_main_t * vam)
17076 unformat_input_t *input = vam->input;
17077 vl_api_one_use_petr_t *mp;
17082 clib_memset (&ip, 0, sizeof (ip));
17084 /* Parse args required to build the message */
17085 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17087 if (unformat (input, "disable"))
17090 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17093 ip_addr_version (&ip) = IP4;
17096 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17099 ip_addr_version (&ip) = IP6;
17103 errmsg ("parse error '%U'", format_unformat_error, input);
17108 M (ONE_USE_PETR, mp);
17110 mp->is_add = is_add;
17113 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17115 clib_memcpy (mp->address, &ip, 4);
17117 clib_memcpy (mp->address, &ip, 16);
17123 /* wait for reply */
17128 #define api_lisp_use_petr api_one_use_petr
17131 api_show_one_nsh_mapping (vat_main_t * vam)
17133 vl_api_show_one_use_petr_t *mp;
17136 if (!vam->json_output)
17138 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17141 M (SHOW_ONE_NSH_MAPPING, mp);
17145 /* Wait for a reply... */
17151 api_show_one_use_petr (vat_main_t * vam)
17153 vl_api_show_one_use_petr_t *mp;
17156 if (!vam->json_output)
17158 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17161 M (SHOW_ONE_USE_PETR, mp);
17165 /* Wait for a reply... */
17170 #define api_show_lisp_use_petr api_show_one_use_petr
17173 * Add/delete mapping between vni and vrf
17176 api_one_eid_table_add_del_map (vat_main_t * vam)
17178 unformat_input_t *input = vam->input;
17179 vl_api_one_eid_table_add_del_map_t *mp;
17180 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17181 u32 vni, vrf, bd_index;
17184 /* Parse args required to build the message */
17185 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17187 if (unformat (input, "del"))
17189 else if (unformat (input, "vrf %d", &vrf))
17191 else if (unformat (input, "bd_index %d", &bd_index))
17193 else if (unformat (input, "vni %d", &vni))
17199 if (!vni_set || (!vrf_set && !bd_index_set))
17201 errmsg ("missing arguments!");
17205 if (vrf_set && bd_index_set)
17207 errmsg ("error: both vrf and bd entered!");
17211 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17213 mp->is_add = is_add;
17214 mp->vni = htonl (vni);
17215 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17216 mp->is_l2 = bd_index_set;
17221 /* wait for reply */
17226 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17229 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17231 u32 *action = va_arg (*args, u32 *);
17234 if (unformat (input, "%s", &s))
17236 if (!strcmp ((char *) s, "no-action"))
17238 else if (!strcmp ((char *) s, "natively-forward"))
17240 else if (!strcmp ((char *) s, "send-map-request"))
17242 else if (!strcmp ((char *) s, "drop"))
17246 clib_warning ("invalid action: '%s'", s);
17258 * Add/del remote mapping to/from ONE control plane
17260 * @param vam vpp API test context
17261 * @return return code
17264 api_one_add_del_remote_mapping (vat_main_t * vam)
17266 unformat_input_t *input = vam->input;
17267 vl_api_one_add_del_remote_mapping_t *mp;
17269 lisp_eid_vat_t _eid, *eid = &_eid;
17270 lisp_eid_vat_t _seid, *seid = &_seid;
17271 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17272 u32 action = ~0, p, w, data_len;
17273 ip4_address_t rloc4;
17274 ip6_address_t rloc6;
17275 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17278 clib_memset (&rloc, 0, sizeof (rloc));
17280 /* Parse args required to build the message */
17281 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17283 if (unformat (input, "del-all"))
17287 else if (unformat (input, "del"))
17291 else if (unformat (input, "add"))
17295 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17299 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17303 else if (unformat (input, "vni %d", &vni))
17307 else if (unformat (input, "p %d w %d", &p, &w))
17311 errmsg ("No RLOC configured for setting priority/weight!");
17314 curr_rloc->priority = p;
17315 curr_rloc->weight = w;
17317 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17320 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17321 vec_add1 (rlocs, rloc);
17322 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17324 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17327 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17328 vec_add1 (rlocs, rloc);
17329 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17331 else if (unformat (input, "action %U",
17332 unformat_negative_mapping_action, &action))
17338 clib_warning ("parse error '%U'", format_unformat_error, input);
17345 errmsg ("missing params!");
17349 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17351 errmsg ("no action set for negative map-reply!");
17355 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17357 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17358 mp->is_add = is_add;
17359 mp->vni = htonl (vni);
17360 mp->action = (u8) action;
17361 mp->is_src_dst = seid_set;
17362 mp->eid_len = eid->len;
17363 mp->seid_len = seid->len;
17364 mp->del_all = del_all;
17365 mp->eid_type = eid->type;
17366 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17367 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17369 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17370 clib_memcpy (mp->rlocs, rlocs, data_len);
17376 /* Wait for a reply... */
17381 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17384 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17385 * forwarding entries in data-plane accordingly.
17387 * @param vam vpp API test context
17388 * @return return code
17391 api_one_add_del_adjacency (vat_main_t * vam)
17393 unformat_input_t *input = vam->input;
17394 vl_api_one_add_del_adjacency_t *mp;
17396 ip4_address_t leid4, reid4;
17397 ip6_address_t leid6, reid6;
17398 u8 reid_mac[6] = { 0 };
17399 u8 leid_mac[6] = { 0 };
17400 u8 reid_type, leid_type;
17401 u32 leid_len = 0, reid_len = 0, len;
17405 leid_type = reid_type = (u8) ~ 0;
17407 /* Parse args required to build the message */
17408 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17410 if (unformat (input, "del"))
17414 else if (unformat (input, "add"))
17418 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17421 reid_type = 0; /* ipv4 */
17424 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17427 reid_type = 1; /* ipv6 */
17430 else if (unformat (input, "reid %U", unformat_ethernet_address,
17433 reid_type = 2; /* mac */
17435 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17438 leid_type = 0; /* ipv4 */
17441 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17444 leid_type = 1; /* ipv6 */
17447 else if (unformat (input, "leid %U", unformat_ethernet_address,
17450 leid_type = 2; /* mac */
17452 else if (unformat (input, "vni %d", &vni))
17458 errmsg ("parse error '%U'", format_unformat_error, input);
17463 if ((u8) ~ 0 == reid_type)
17465 errmsg ("missing params!");
17469 if (leid_type != reid_type)
17471 errmsg ("remote and local EIDs are of different types!");
17475 M (ONE_ADD_DEL_ADJACENCY, mp);
17476 mp->is_add = is_add;
17477 mp->vni = htonl (vni);
17478 mp->leid_len = leid_len;
17479 mp->reid_len = reid_len;
17480 mp->eid_type = reid_type;
17482 switch (mp->eid_type)
17485 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17486 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17489 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17490 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17493 clib_memcpy (mp->leid, leid_mac, 6);
17494 clib_memcpy (mp->reid, reid_mac, 6);
17497 errmsg ("unknown EID type %d!", mp->eid_type);
17504 /* Wait for a reply... */
17509 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17512 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17514 u32 *mode = va_arg (*args, u32 *);
17516 if (unformat (input, "lisp"))
17518 else if (unformat (input, "vxlan"))
17527 api_gpe_get_encap_mode (vat_main_t * vam)
17529 vl_api_gpe_get_encap_mode_t *mp;
17532 /* Construct the API message */
17533 M (GPE_GET_ENCAP_MODE, mp);
17538 /* Wait for a reply... */
17544 api_gpe_set_encap_mode (vat_main_t * vam)
17546 unformat_input_t *input = vam->input;
17547 vl_api_gpe_set_encap_mode_t *mp;
17551 /* Parse args required to build the message */
17552 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17554 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17560 /* Construct the API message */
17561 M (GPE_SET_ENCAP_MODE, mp);
17568 /* Wait for a reply... */
17574 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17576 unformat_input_t *input = vam->input;
17577 vl_api_gpe_add_del_iface_t *mp;
17578 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17579 u32 dp_table = 0, vni = 0;
17582 /* Parse args required to build the message */
17583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17585 if (unformat (input, "up"))
17590 else if (unformat (input, "down"))
17595 else if (unformat (input, "table_id %d", &dp_table))
17599 else if (unformat (input, "bd_id %d", &dp_table))
17604 else if (unformat (input, "vni %d", &vni))
17612 if (action_set == 0)
17614 errmsg ("Action not set");
17617 if (dp_table_set == 0 || vni_set == 0)
17619 errmsg ("vni and dp_table must be set");
17623 /* Construct the API message */
17624 M (GPE_ADD_DEL_IFACE, mp);
17626 mp->is_add = is_add;
17627 mp->dp_table = clib_host_to_net_u32 (dp_table);
17629 mp->vni = clib_host_to_net_u32 (vni);
17634 /* Wait for a reply... */
17640 api_one_map_register_fallback_threshold (vat_main_t * vam)
17642 unformat_input_t *input = vam->input;
17643 vl_api_one_map_register_fallback_threshold_t *mp;
17648 /* Parse args required to build the message */
17649 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17651 if (unformat (input, "%u", &value))
17655 clib_warning ("parse error '%U'", format_unformat_error, input);
17662 errmsg ("fallback threshold value is missing!");
17666 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17667 mp->value = clib_host_to_net_u32 (value);
17672 /* Wait for a reply... */
17678 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17680 vl_api_show_one_map_register_fallback_threshold_t *mp;
17683 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17688 /* Wait for a reply... */
17694 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17696 u32 *proto = va_arg (*args, u32 *);
17698 if (unformat (input, "udp"))
17700 else if (unformat (input, "api"))
17709 api_one_set_transport_protocol (vat_main_t * vam)
17711 unformat_input_t *input = vam->input;
17712 vl_api_one_set_transport_protocol_t *mp;
17717 /* Parse args required to build the message */
17718 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17720 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17724 clib_warning ("parse error '%U'", format_unformat_error, input);
17731 errmsg ("Transport protocol missing!");
17735 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17736 mp->protocol = (u8) protocol;
17741 /* Wait for a reply... */
17747 api_one_get_transport_protocol (vat_main_t * vam)
17749 vl_api_one_get_transport_protocol_t *mp;
17752 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17757 /* Wait for a reply... */
17763 api_one_map_register_set_ttl (vat_main_t * vam)
17765 unformat_input_t *input = vam->input;
17766 vl_api_one_map_register_set_ttl_t *mp;
17771 /* Parse args required to build the message */
17772 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17774 if (unformat (input, "%u", &ttl))
17778 clib_warning ("parse error '%U'", format_unformat_error, input);
17785 errmsg ("TTL value missing!");
17789 M (ONE_MAP_REGISTER_SET_TTL, mp);
17790 mp->ttl = clib_host_to_net_u32 (ttl);
17795 /* Wait for a reply... */
17801 api_show_one_map_register_ttl (vat_main_t * vam)
17803 vl_api_show_one_map_register_ttl_t *mp;
17806 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17811 /* Wait for a reply... */
17817 * Add/del map request itr rlocs from ONE control plane and updates
17819 * @param vam vpp API test context
17820 * @return return code
17823 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17825 unformat_input_t *input = vam->input;
17826 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17827 u8 *locator_set_name = 0;
17828 u8 locator_set_name_set = 0;
17832 /* Parse args required to build the message */
17833 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17835 if (unformat (input, "del"))
17839 else if (unformat (input, "%_%v%_", &locator_set_name))
17841 locator_set_name_set = 1;
17845 clib_warning ("parse error '%U'", format_unformat_error, input);
17850 if (is_add && !locator_set_name_set)
17852 errmsg ("itr-rloc is not set!");
17856 if (is_add && vec_len (locator_set_name) > 64)
17858 errmsg ("itr-rloc locator-set name too long");
17859 vec_free (locator_set_name);
17863 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17864 mp->is_add = is_add;
17867 clib_memcpy (mp->locator_set_name, locator_set_name,
17868 vec_len (locator_set_name));
17872 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17874 vec_free (locator_set_name);
17879 /* Wait for a reply... */
17884 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17887 api_one_locator_dump (vat_main_t * vam)
17889 unformat_input_t *input = vam->input;
17890 vl_api_one_locator_dump_t *mp;
17891 vl_api_control_ping_t *mp_ping;
17892 u8 is_index_set = 0, is_name_set = 0;
17897 /* Parse args required to build the message */
17898 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17900 if (unformat (input, "ls_name %_%v%_", &ls_name))
17904 else if (unformat (input, "ls_index %d", &ls_index))
17910 errmsg ("parse error '%U'", format_unformat_error, input);
17915 if (!is_index_set && !is_name_set)
17917 errmsg ("error: expected one of index or name!");
17921 if (is_index_set && is_name_set)
17923 errmsg ("error: only one param expected!");
17927 if (vec_len (ls_name) > 62)
17929 errmsg ("error: locator set name too long!");
17933 if (!vam->json_output)
17935 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17938 M (ONE_LOCATOR_DUMP, mp);
17939 mp->is_index_set = is_index_set;
17942 mp->ls_index = clib_host_to_net_u32 (ls_index);
17945 vec_add1 (ls_name, 0);
17946 strncpy ((char *) mp->ls_name, (char *) ls_name,
17947 sizeof (mp->ls_name) - 1);
17953 /* Use a control ping for synchronization */
17954 MPING (CONTROL_PING, mp_ping);
17957 /* Wait for a reply... */
17962 #define api_lisp_locator_dump api_one_locator_dump
17965 api_one_locator_set_dump (vat_main_t * vam)
17967 vl_api_one_locator_set_dump_t *mp;
17968 vl_api_control_ping_t *mp_ping;
17969 unformat_input_t *input = vam->input;
17973 /* Parse args required to build the message */
17974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17976 if (unformat (input, "local"))
17980 else if (unformat (input, "remote"))
17986 errmsg ("parse error '%U'", format_unformat_error, input);
17991 if (!vam->json_output)
17993 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
17996 M (ONE_LOCATOR_SET_DUMP, mp);
17998 mp->filter = filter;
18003 /* Use a control ping for synchronization */
18004 MPING (CONTROL_PING, mp_ping);
18007 /* Wait for a reply... */
18012 #define api_lisp_locator_set_dump api_one_locator_set_dump
18015 api_one_eid_table_map_dump (vat_main_t * vam)
18019 unformat_input_t *input = vam->input;
18020 vl_api_one_eid_table_map_dump_t *mp;
18021 vl_api_control_ping_t *mp_ping;
18024 /* Parse args required to build the message */
18025 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18027 if (unformat (input, "l2"))
18032 else if (unformat (input, "l3"))
18039 errmsg ("parse error '%U'", format_unformat_error, input);
18046 errmsg ("expected one of 'l2' or 'l3' parameter!");
18050 if (!vam->json_output)
18052 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18055 M (ONE_EID_TABLE_MAP_DUMP, mp);
18061 /* Use a control ping for synchronization */
18062 MPING (CONTROL_PING, mp_ping);
18065 /* Wait for a reply... */
18070 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18073 api_one_eid_table_vni_dump (vat_main_t * vam)
18075 vl_api_one_eid_table_vni_dump_t *mp;
18076 vl_api_control_ping_t *mp_ping;
18079 if (!vam->json_output)
18081 print (vam->ofp, "VNI");
18084 M (ONE_EID_TABLE_VNI_DUMP, mp);
18089 /* Use a control ping for synchronization */
18090 MPING (CONTROL_PING, mp_ping);
18093 /* Wait for a reply... */
18098 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18101 api_one_eid_table_dump (vat_main_t * vam)
18103 unformat_input_t *i = vam->input;
18104 vl_api_one_eid_table_dump_t *mp;
18105 vl_api_control_ping_t *mp_ping;
18106 struct in_addr ip4;
18107 struct in6_addr ip6;
18109 u8 eid_type = ~0, eid_set = 0;
18110 u32 prefix_length = ~0, t, vni = 0;
18113 lisp_nsh_api_t nsh;
18115 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18117 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18123 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18129 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18134 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18139 else if (unformat (i, "vni %d", &t))
18143 else if (unformat (i, "local"))
18147 else if (unformat (i, "remote"))
18153 errmsg ("parse error '%U'", format_unformat_error, i);
18158 if (!vam->json_output)
18160 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18161 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18164 M (ONE_EID_TABLE_DUMP, mp);
18166 mp->filter = filter;
18170 mp->vni = htonl (vni);
18171 mp->eid_type = eid_type;
18175 mp->prefix_length = prefix_length;
18176 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18179 mp->prefix_length = prefix_length;
18180 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18183 clib_memcpy (mp->eid, mac, sizeof (mac));
18186 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18189 errmsg ("unknown EID type %d!", eid_type);
18197 /* Use a control ping for synchronization */
18198 MPING (CONTROL_PING, mp_ping);
18201 /* Wait for a reply... */
18206 #define api_lisp_eid_table_dump api_one_eid_table_dump
18209 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18211 unformat_input_t *i = vam->input;
18212 vl_api_gpe_fwd_entries_get_t *mp;
18217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18219 if (unformat (i, "vni %d", &vni))
18225 errmsg ("parse error '%U'", format_unformat_error, i);
18232 errmsg ("vni not set!");
18236 if (!vam->json_output)
18238 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18242 M (GPE_FWD_ENTRIES_GET, mp);
18243 mp->vni = clib_host_to_net_u32 (vni);
18248 /* Wait for a reply... */
18253 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18254 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18255 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18256 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18257 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18258 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18259 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18260 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18263 api_one_adjacencies_get (vat_main_t * vam)
18265 unformat_input_t *i = vam->input;
18266 vl_api_one_adjacencies_get_t *mp;
18271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18273 if (unformat (i, "vni %d", &vni))
18279 errmsg ("parse error '%U'", format_unformat_error, i);
18286 errmsg ("vni not set!");
18290 if (!vam->json_output)
18292 print (vam->ofp, "%s %40s", "leid", "reid");
18295 M (ONE_ADJACENCIES_GET, mp);
18296 mp->vni = clib_host_to_net_u32 (vni);
18301 /* Wait for a reply... */
18306 #define api_lisp_adjacencies_get api_one_adjacencies_get
18309 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18311 unformat_input_t *i = vam->input;
18312 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18314 u8 ip_family_set = 0, is_ip4 = 1;
18316 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18318 if (unformat (i, "ip4"))
18323 else if (unformat (i, "ip6"))
18330 errmsg ("parse error '%U'", format_unformat_error, i);
18335 if (!ip_family_set)
18337 errmsg ("ip family not set!");
18341 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18342 mp->is_ip4 = is_ip4;
18347 /* Wait for a reply... */
18353 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18355 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18358 if (!vam->json_output)
18360 print (vam->ofp, "VNIs");
18363 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18368 /* Wait for a reply... */
18374 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18376 unformat_input_t *i = vam->input;
18377 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18379 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18380 struct in_addr ip4;
18381 struct in6_addr ip6;
18382 u32 table_id = 0, nh_sw_if_index = ~0;
18384 clib_memset (&ip4, 0, sizeof (ip4));
18385 clib_memset (&ip6, 0, sizeof (ip6));
18387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18389 if (unformat (i, "del"))
18391 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18392 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18397 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18398 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18403 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18407 nh_sw_if_index = ~0;
18409 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18413 nh_sw_if_index = ~0;
18415 else if (unformat (i, "table %d", &table_id))
18419 errmsg ("parse error '%U'", format_unformat_error, i);
18426 errmsg ("nh addr not set!");
18430 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18431 mp->is_add = is_add;
18432 mp->table_id = clib_host_to_net_u32 (table_id);
18433 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18434 mp->is_ip4 = is_ip4;
18436 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18438 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18443 /* Wait for a reply... */
18449 api_one_map_server_dump (vat_main_t * vam)
18451 vl_api_one_map_server_dump_t *mp;
18452 vl_api_control_ping_t *mp_ping;
18455 if (!vam->json_output)
18457 print (vam->ofp, "%=20s", "Map server");
18460 M (ONE_MAP_SERVER_DUMP, mp);
18464 /* Use a control ping for synchronization */
18465 MPING (CONTROL_PING, mp_ping);
18468 /* Wait for a reply... */
18473 #define api_lisp_map_server_dump api_one_map_server_dump
18476 api_one_map_resolver_dump (vat_main_t * vam)
18478 vl_api_one_map_resolver_dump_t *mp;
18479 vl_api_control_ping_t *mp_ping;
18482 if (!vam->json_output)
18484 print (vam->ofp, "%=20s", "Map resolver");
18487 M (ONE_MAP_RESOLVER_DUMP, mp);
18491 /* Use a control ping for synchronization */
18492 MPING (CONTROL_PING, mp_ping);
18495 /* Wait for a reply... */
18500 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18503 api_one_stats_flush (vat_main_t * vam)
18505 vl_api_one_stats_flush_t *mp;
18508 M (ONE_STATS_FLUSH, mp);
18515 api_one_stats_dump (vat_main_t * vam)
18517 vl_api_one_stats_dump_t *mp;
18518 vl_api_control_ping_t *mp_ping;
18521 M (ONE_STATS_DUMP, mp);
18525 /* Use a control ping for synchronization */
18526 MPING (CONTROL_PING, mp_ping);
18529 /* Wait for a reply... */
18535 api_show_one_status (vat_main_t * vam)
18537 vl_api_show_one_status_t *mp;
18540 if (!vam->json_output)
18542 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18545 M (SHOW_ONE_STATUS, mp);
18548 /* Wait for a reply... */
18553 #define api_show_lisp_status api_show_one_status
18556 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18558 vl_api_gpe_fwd_entry_path_dump_t *mp;
18559 vl_api_control_ping_t *mp_ping;
18560 unformat_input_t *i = vam->input;
18561 u32 fwd_entry_index = ~0;
18564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18566 if (unformat (i, "index %d", &fwd_entry_index))
18572 if (~0 == fwd_entry_index)
18574 errmsg ("no index specified!");
18578 if (!vam->json_output)
18580 print (vam->ofp, "first line");
18583 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18587 /* Use a control ping for synchronization */
18588 MPING (CONTROL_PING, mp_ping);
18591 /* Wait for a reply... */
18597 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18599 vl_api_one_get_map_request_itr_rlocs_t *mp;
18602 if (!vam->json_output)
18604 print (vam->ofp, "%=20s", "itr-rlocs:");
18607 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18610 /* Wait for a reply... */
18615 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18618 api_af_packet_create (vat_main_t * vam)
18620 unformat_input_t *i = vam->input;
18621 vl_api_af_packet_create_t *mp;
18622 u8 *host_if_name = 0;
18624 u8 random_hw_addr = 1;
18627 clib_memset (hw_addr, 0, sizeof (hw_addr));
18629 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18631 if (unformat (i, "name %s", &host_if_name))
18632 vec_add1 (host_if_name, 0);
18633 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18634 random_hw_addr = 0;
18639 if (!vec_len (host_if_name))
18641 errmsg ("host-interface name must be specified");
18645 if (vec_len (host_if_name) > 64)
18647 errmsg ("host-interface name too long");
18651 M (AF_PACKET_CREATE, mp);
18653 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18654 clib_memcpy (mp->hw_addr, hw_addr, 6);
18655 mp->use_random_hw_addr = random_hw_addr;
18656 vec_free (host_if_name);
18664 fprintf (vam->ofp ? vam->ofp : stderr,
18665 " new sw_if_index = %d\n", vam->sw_if_index);
18672 api_af_packet_delete (vat_main_t * vam)
18674 unformat_input_t *i = vam->input;
18675 vl_api_af_packet_delete_t *mp;
18676 u8 *host_if_name = 0;
18679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18681 if (unformat (i, "name %s", &host_if_name))
18682 vec_add1 (host_if_name, 0);
18687 if (!vec_len (host_if_name))
18689 errmsg ("host-interface name must be specified");
18693 if (vec_len (host_if_name) > 64)
18695 errmsg ("host-interface name too long");
18699 M (AF_PACKET_DELETE, mp);
18701 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18702 vec_free (host_if_name);
18709 static void vl_api_af_packet_details_t_handler
18710 (vl_api_af_packet_details_t * mp)
18712 vat_main_t *vam = &vat_main;
18714 print (vam->ofp, "%-16s %d",
18715 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18718 static void vl_api_af_packet_details_t_handler_json
18719 (vl_api_af_packet_details_t * mp)
18721 vat_main_t *vam = &vat_main;
18722 vat_json_node_t *node = NULL;
18724 if (VAT_JSON_ARRAY != vam->json_tree.type)
18726 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18727 vat_json_init_array (&vam->json_tree);
18729 node = vat_json_array_add (&vam->json_tree);
18731 vat_json_init_object (node);
18732 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18733 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18737 api_af_packet_dump (vat_main_t * vam)
18739 vl_api_af_packet_dump_t *mp;
18740 vl_api_control_ping_t *mp_ping;
18743 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18744 /* Get list of tap interfaces */
18745 M (AF_PACKET_DUMP, mp);
18748 /* Use a control ping for synchronization */
18749 MPING (CONTROL_PING, mp_ping);
18757 api_policer_add_del (vat_main_t * vam)
18759 unformat_input_t *i = vam->input;
18760 vl_api_policer_add_del_t *mp;
18770 u8 color_aware = 0;
18771 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18774 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18775 conform_action.dscp = 0;
18776 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18777 exceed_action.dscp = 0;
18778 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18779 violate_action.dscp = 0;
18781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18783 if (unformat (i, "del"))
18785 else if (unformat (i, "name %s", &name))
18786 vec_add1 (name, 0);
18787 else if (unformat (i, "cir %u", &cir))
18789 else if (unformat (i, "eir %u", &eir))
18791 else if (unformat (i, "cb %u", &cb))
18793 else if (unformat (i, "eb %u", &eb))
18795 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18798 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18801 else if (unformat (i, "type %U", unformat_policer_type, &type))
18803 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18806 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18809 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18812 else if (unformat (i, "color-aware"))
18818 if (!vec_len (name))
18820 errmsg ("policer name must be specified");
18824 if (vec_len (name) > 64)
18826 errmsg ("policer name too long");
18830 M (POLICER_ADD_DEL, mp);
18832 clib_memcpy (mp->name, name, vec_len (name));
18834 mp->is_add = is_add;
18835 mp->cir = ntohl (cir);
18836 mp->eir = ntohl (eir);
18837 mp->cb = clib_net_to_host_u64 (cb);
18838 mp->eb = clib_net_to_host_u64 (eb);
18839 mp->rate_type = rate_type;
18840 mp->round_type = round_type;
18842 mp->conform_action_type = conform_action.action_type;
18843 mp->conform_dscp = conform_action.dscp;
18844 mp->exceed_action_type = exceed_action.action_type;
18845 mp->exceed_dscp = exceed_action.dscp;
18846 mp->violate_action_type = violate_action.action_type;
18847 mp->violate_dscp = violate_action.dscp;
18848 mp->color_aware = color_aware;
18856 api_policer_dump (vat_main_t * vam)
18858 unformat_input_t *i = vam->input;
18859 vl_api_policer_dump_t *mp;
18860 vl_api_control_ping_t *mp_ping;
18861 u8 *match_name = 0;
18862 u8 match_name_valid = 0;
18865 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18867 if (unformat (i, "name %s", &match_name))
18869 vec_add1 (match_name, 0);
18870 match_name_valid = 1;
18876 M (POLICER_DUMP, mp);
18877 mp->match_name_valid = match_name_valid;
18878 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18879 vec_free (match_name);
18883 /* Use a control ping for synchronization */
18884 MPING (CONTROL_PING, mp_ping);
18887 /* Wait for a reply... */
18893 api_policer_classify_set_interface (vat_main_t * vam)
18895 unformat_input_t *i = vam->input;
18896 vl_api_policer_classify_set_interface_t *mp;
18898 int sw_if_index_set;
18899 u32 ip4_table_index = ~0;
18900 u32 ip6_table_index = ~0;
18901 u32 l2_table_index = ~0;
18905 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18907 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18908 sw_if_index_set = 1;
18909 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18910 sw_if_index_set = 1;
18911 else if (unformat (i, "del"))
18913 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18915 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18917 else if (unformat (i, "l2-table %d", &l2_table_index))
18921 clib_warning ("parse error '%U'", format_unformat_error, i);
18926 if (sw_if_index_set == 0)
18928 errmsg ("missing interface name or sw_if_index");
18932 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18934 mp->sw_if_index = ntohl (sw_if_index);
18935 mp->ip4_table_index = ntohl (ip4_table_index);
18936 mp->ip6_table_index = ntohl (ip6_table_index);
18937 mp->l2_table_index = ntohl (l2_table_index);
18938 mp->is_add = is_add;
18946 api_policer_classify_dump (vat_main_t * vam)
18948 unformat_input_t *i = vam->input;
18949 vl_api_policer_classify_dump_t *mp;
18950 vl_api_control_ping_t *mp_ping;
18951 u8 type = POLICER_CLASSIFY_N_TABLES;
18954 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
18958 errmsg ("classify table type must be specified");
18962 if (!vam->json_output)
18964 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
18967 M (POLICER_CLASSIFY_DUMP, mp);
18972 /* Use a control ping for synchronization */
18973 MPING (CONTROL_PING, mp_ping);
18976 /* Wait for a reply... */
18982 api_netmap_create (vat_main_t * vam)
18984 unformat_input_t *i = vam->input;
18985 vl_api_netmap_create_t *mp;
18988 u8 random_hw_addr = 1;
18993 clib_memset (hw_addr, 0, sizeof (hw_addr));
18995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18997 if (unformat (i, "name %s", &if_name))
18998 vec_add1 (if_name, 0);
18999 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19000 random_hw_addr = 0;
19001 else if (unformat (i, "pipe"))
19003 else if (unformat (i, "master"))
19005 else if (unformat (i, "slave"))
19011 if (!vec_len (if_name))
19013 errmsg ("interface name must be specified");
19017 if (vec_len (if_name) > 64)
19019 errmsg ("interface name too long");
19023 M (NETMAP_CREATE, mp);
19025 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19026 clib_memcpy (mp->hw_addr, hw_addr, 6);
19027 mp->use_random_hw_addr = random_hw_addr;
19028 mp->is_pipe = is_pipe;
19029 mp->is_master = is_master;
19030 vec_free (if_name);
19038 api_netmap_delete (vat_main_t * vam)
19040 unformat_input_t *i = vam->input;
19041 vl_api_netmap_delete_t *mp;
19045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19047 if (unformat (i, "name %s", &if_name))
19048 vec_add1 (if_name, 0);
19053 if (!vec_len (if_name))
19055 errmsg ("interface name must be specified");
19059 if (vec_len (if_name) > 64)
19061 errmsg ("interface name too long");
19065 M (NETMAP_DELETE, mp);
19067 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19068 vec_free (if_name);
19076 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19078 if (fp->afi == IP46_TYPE_IP6)
19080 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19081 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19082 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19083 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19084 format_ip6_address, fp->next_hop);
19085 else if (fp->afi == IP46_TYPE_IP4)
19087 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19088 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19089 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19090 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19091 format_ip4_address, fp->next_hop);
19095 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19096 vl_api_fib_path_t * fp)
19098 struct in_addr ip4;
19099 struct in6_addr ip6;
19101 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19102 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19103 vat_json_object_add_uint (node, "is_local", fp->is_local);
19104 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19105 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19106 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19107 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19108 if (fp->afi == IP46_TYPE_IP4)
19110 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19111 vat_json_object_add_ip4 (node, "next_hop", ip4);
19113 else if (fp->afi == IP46_TYPE_IP6)
19115 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19116 vat_json_object_add_ip6 (node, "next_hop", ip6);
19121 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19123 vat_main_t *vam = &vat_main;
19124 int count = ntohl (mp->mt_count);
19125 vl_api_fib_path_t *fp;
19128 print (vam->ofp, "[%d]: sw_if_index %d via:",
19129 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19131 for (i = 0; i < count; i++)
19133 vl_api_mpls_fib_path_print (vam, fp);
19137 print (vam->ofp, "");
19140 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19141 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19144 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19146 vat_main_t *vam = &vat_main;
19147 vat_json_node_t *node = NULL;
19148 int count = ntohl (mp->mt_count);
19149 vl_api_fib_path_t *fp;
19152 if (VAT_JSON_ARRAY != vam->json_tree.type)
19154 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19155 vat_json_init_array (&vam->json_tree);
19157 node = vat_json_array_add (&vam->json_tree);
19159 vat_json_init_object (node);
19160 vat_json_object_add_uint (node, "tunnel_index",
19161 ntohl (mp->mt_tunnel_index));
19162 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19164 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19167 for (i = 0; i < count; i++)
19169 vl_api_mpls_fib_path_json_print (node, fp);
19175 api_mpls_tunnel_dump (vat_main_t * vam)
19177 vl_api_mpls_tunnel_dump_t *mp;
19178 vl_api_control_ping_t *mp_ping;
19179 u32 sw_if_index = ~0;
19182 /* Parse args required to build the message */
19183 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19185 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19189 print (vam->ofp, " sw_if_index %d", sw_if_index);
19191 M (MPLS_TUNNEL_DUMP, mp);
19192 mp->sw_if_index = htonl (sw_if_index);
19195 /* Use a control ping for synchronization */
19196 MPING (CONTROL_PING, mp_ping);
19203 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19204 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19208 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19210 vat_main_t *vam = &vat_main;
19211 int count = ntohl (mp->count);
19212 vl_api_fib_path_t *fp;
19216 "table-id %d, label %u, ess_bit %u",
19217 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19219 for (i = 0; i < count; i++)
19221 vl_api_mpls_fib_path_print (vam, fp);
19226 static void vl_api_mpls_fib_details_t_handler_json
19227 (vl_api_mpls_fib_details_t * mp)
19229 vat_main_t *vam = &vat_main;
19230 int count = ntohl (mp->count);
19231 vat_json_node_t *node = NULL;
19232 vl_api_fib_path_t *fp;
19235 if (VAT_JSON_ARRAY != vam->json_tree.type)
19237 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19238 vat_json_init_array (&vam->json_tree);
19240 node = vat_json_array_add (&vam->json_tree);
19242 vat_json_init_object (node);
19243 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19244 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19245 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19246 vat_json_object_add_uint (node, "path_count", count);
19248 for (i = 0; i < count; i++)
19250 vl_api_mpls_fib_path_json_print (node, fp);
19256 api_mpls_fib_dump (vat_main_t * vam)
19258 vl_api_mpls_fib_dump_t *mp;
19259 vl_api_control_ping_t *mp_ping;
19262 M (MPLS_FIB_DUMP, mp);
19265 /* Use a control ping for synchronization */
19266 MPING (CONTROL_PING, mp_ping);
19273 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19274 #define vl_api_ip_fib_details_t_print vl_noop_handler
19277 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19279 vat_main_t *vam = &vat_main;
19280 int count = ntohl (mp->count);
19281 vl_api_fib_path_t *fp;
19285 "table-id %d, prefix %U/%d stats-index %d",
19286 ntohl (mp->table_id), format_ip4_address, mp->address,
19287 mp->address_length, ntohl (mp->stats_index));
19289 for (i = 0; i < count; i++)
19291 if (fp->afi == IP46_TYPE_IP6)
19293 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19294 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19295 "next_hop_table %d",
19296 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19297 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19298 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
19299 else if (fp->afi == IP46_TYPE_IP4)
19301 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19302 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19303 "next_hop_table %d",
19304 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19305 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19306 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
19311 static void vl_api_ip_fib_details_t_handler_json
19312 (vl_api_ip_fib_details_t * mp)
19314 vat_main_t *vam = &vat_main;
19315 int count = ntohl (mp->count);
19316 vat_json_node_t *node = NULL;
19317 struct in_addr ip4;
19318 struct in6_addr ip6;
19319 vl_api_fib_path_t *fp;
19322 if (VAT_JSON_ARRAY != vam->json_tree.type)
19324 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19325 vat_json_init_array (&vam->json_tree);
19327 node = vat_json_array_add (&vam->json_tree);
19329 vat_json_init_object (node);
19330 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19331 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19332 vat_json_object_add_ip4 (node, "prefix", ip4);
19333 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19334 vat_json_object_add_uint (node, "path_count", count);
19336 for (i = 0; i < count; i++)
19338 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19339 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19340 vat_json_object_add_uint (node, "is_local", fp->is_local);
19341 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19342 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19343 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19344 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19345 if (fp->afi == IP46_TYPE_IP4)
19347 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19348 vat_json_object_add_ip4 (node, "next_hop", ip4);
19350 else if (fp->afi == IP46_TYPE_IP6)
19352 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19353 vat_json_object_add_ip6 (node, "next_hop", ip6);
19359 api_ip_fib_dump (vat_main_t * vam)
19361 vl_api_ip_fib_dump_t *mp;
19362 vl_api_control_ping_t *mp_ping;
19365 M (IP_FIB_DUMP, mp);
19368 /* Use a control ping for synchronization */
19369 MPING (CONTROL_PING, mp_ping);
19377 api_ip_mfib_dump (vat_main_t * vam)
19379 vl_api_ip_mfib_dump_t *mp;
19380 vl_api_control_ping_t *mp_ping;
19383 M (IP_MFIB_DUMP, mp);
19386 /* Use a control ping for synchronization */
19387 MPING (CONTROL_PING, mp_ping);
19394 static void vl_api_ip_neighbor_details_t_handler
19395 (vl_api_ip_neighbor_details_t * mp)
19397 vat_main_t *vam = &vat_main;
19399 print (vam->ofp, "%c %U %U",
19400 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19401 format_vl_api_mac_address, &mp->neighbor.mac_address,
19402 format_vl_api_address, &mp->neighbor.ip_address);
19405 static void vl_api_ip_neighbor_details_t_handler_json
19406 (vl_api_ip_neighbor_details_t * mp)
19409 vat_main_t *vam = &vat_main;
19410 vat_json_node_t *node;
19412 if (VAT_JSON_ARRAY != vam->json_tree.type)
19414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19415 vat_json_init_array (&vam->json_tree);
19417 node = vat_json_array_add (&vam->json_tree);
19419 vat_json_init_object (node);
19420 vat_json_object_add_string_copy
19422 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19423 (u8 *) "static" : (u8 *) "dynamic"));
19425 vat_json_object_add_string_copy (node, "link_layer",
19426 format (0, "%U", format_vl_api_mac_address,
19427 &mp->neighbor.mac_address));
19428 vat_json_object_add_address (node, &mp->neighbor.ip_address);
19432 api_ip_neighbor_dump (vat_main_t * vam)
19434 unformat_input_t *i = vam->input;
19435 vl_api_ip_neighbor_dump_t *mp;
19436 vl_api_control_ping_t *mp_ping;
19438 u32 sw_if_index = ~0;
19441 /* Parse args required to build the message */
19442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19444 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19446 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19448 else if (unformat (i, "ip6"))
19454 if (sw_if_index == ~0)
19456 errmsg ("missing interface name or sw_if_index");
19460 M (IP_NEIGHBOR_DUMP, mp);
19461 mp->is_ipv6 = (u8) is_ipv6;
19462 mp->sw_if_index = ntohl (sw_if_index);
19465 /* Use a control ping for synchronization */
19466 MPING (CONTROL_PING, mp_ping);
19473 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19474 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19477 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19479 vat_main_t *vam = &vat_main;
19480 int count = ntohl (mp->count);
19481 vl_api_fib_path_t *fp;
19485 "table-id %d, prefix %U/%d stats-index %d",
19486 ntohl (mp->table_id), format_ip6_address, mp->address,
19487 mp->address_length, ntohl (mp->stats_index));
19489 for (i = 0; i < count; i++)
19491 if (fp->afi == IP46_TYPE_IP6)
19493 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19494 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19495 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19496 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19497 format_ip6_address, fp->next_hop);
19498 else if (fp->afi == IP46_TYPE_IP4)
19500 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19501 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19502 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19503 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19504 format_ip4_address, fp->next_hop);
19509 static void vl_api_ip6_fib_details_t_handler_json
19510 (vl_api_ip6_fib_details_t * mp)
19512 vat_main_t *vam = &vat_main;
19513 int count = ntohl (mp->count);
19514 vat_json_node_t *node = NULL;
19515 struct in_addr ip4;
19516 struct in6_addr ip6;
19517 vl_api_fib_path_t *fp;
19520 if (VAT_JSON_ARRAY != vam->json_tree.type)
19522 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19523 vat_json_init_array (&vam->json_tree);
19525 node = vat_json_array_add (&vam->json_tree);
19527 vat_json_init_object (node);
19528 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19529 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19530 vat_json_object_add_ip6 (node, "prefix", ip6);
19531 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19532 vat_json_object_add_uint (node, "path_count", count);
19534 for (i = 0; i < count; i++)
19536 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19537 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19538 vat_json_object_add_uint (node, "is_local", fp->is_local);
19539 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19540 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19541 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19542 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19543 if (fp->afi == IP46_TYPE_IP4)
19545 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19546 vat_json_object_add_ip4 (node, "next_hop", ip4);
19548 else if (fp->afi == IP46_TYPE_IP6)
19550 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19551 vat_json_object_add_ip6 (node, "next_hop", ip6);
19557 api_ip6_fib_dump (vat_main_t * vam)
19559 vl_api_ip6_fib_dump_t *mp;
19560 vl_api_control_ping_t *mp_ping;
19563 M (IP6_FIB_DUMP, mp);
19566 /* Use a control ping for synchronization */
19567 MPING (CONTROL_PING, mp_ping);
19575 api_ip6_mfib_dump (vat_main_t * vam)
19577 vl_api_ip6_mfib_dump_t *mp;
19578 vl_api_control_ping_t *mp_ping;
19581 M (IP6_MFIB_DUMP, mp);
19584 /* Use a control ping for synchronization */
19585 MPING (CONTROL_PING, mp_ping);
19593 api_classify_table_ids (vat_main_t * vam)
19595 vl_api_classify_table_ids_t *mp;
19598 /* Construct the API message */
19599 M (CLASSIFY_TABLE_IDS, mp);
19608 api_classify_table_by_interface (vat_main_t * vam)
19610 unformat_input_t *input = vam->input;
19611 vl_api_classify_table_by_interface_t *mp;
19613 u32 sw_if_index = ~0;
19615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19617 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19619 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19624 if (sw_if_index == ~0)
19626 errmsg ("missing interface name or sw_if_index");
19630 /* Construct the API message */
19631 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19633 mp->sw_if_index = ntohl (sw_if_index);
19641 api_classify_table_info (vat_main_t * vam)
19643 unformat_input_t *input = vam->input;
19644 vl_api_classify_table_info_t *mp;
19648 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19650 if (unformat (input, "table_id %d", &table_id))
19655 if (table_id == ~0)
19657 errmsg ("missing table id");
19661 /* Construct the API message */
19662 M (CLASSIFY_TABLE_INFO, mp);
19664 mp->table_id = ntohl (table_id);
19672 api_classify_session_dump (vat_main_t * vam)
19674 unformat_input_t *input = vam->input;
19675 vl_api_classify_session_dump_t *mp;
19676 vl_api_control_ping_t *mp_ping;
19680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19682 if (unformat (input, "table_id %d", &table_id))
19687 if (table_id == ~0)
19689 errmsg ("missing table id");
19693 /* Construct the API message */
19694 M (CLASSIFY_SESSION_DUMP, mp);
19696 mp->table_id = ntohl (table_id);
19699 /* Use a control ping for synchronization */
19700 MPING (CONTROL_PING, mp_ping);
19708 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19710 vat_main_t *vam = &vat_main;
19712 print (vam->ofp, "collector_address %U, collector_port %d, "
19713 "src_address %U, vrf_id %d, path_mtu %u, "
19714 "template_interval %u, udp_checksum %d",
19715 format_ip4_address, mp->collector_address,
19716 ntohs (mp->collector_port),
19717 format_ip4_address, mp->src_address,
19718 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19719 ntohl (mp->template_interval), mp->udp_checksum);
19722 vam->result_ready = 1;
19726 vl_api_ipfix_exporter_details_t_handler_json
19727 (vl_api_ipfix_exporter_details_t * mp)
19729 vat_main_t *vam = &vat_main;
19730 vat_json_node_t node;
19731 struct in_addr collector_address;
19732 struct in_addr src_address;
19734 vat_json_init_object (&node);
19735 clib_memcpy (&collector_address, &mp->collector_address,
19736 sizeof (collector_address));
19737 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19738 vat_json_object_add_uint (&node, "collector_port",
19739 ntohs (mp->collector_port));
19740 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19741 vat_json_object_add_ip4 (&node, "src_address", src_address);
19742 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19743 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19744 vat_json_object_add_uint (&node, "template_interval",
19745 ntohl (mp->template_interval));
19746 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19748 vat_json_print (vam->ofp, &node);
19749 vat_json_free (&node);
19751 vam->result_ready = 1;
19755 api_ipfix_exporter_dump (vat_main_t * vam)
19757 vl_api_ipfix_exporter_dump_t *mp;
19760 /* Construct the API message */
19761 M (IPFIX_EXPORTER_DUMP, mp);
19770 api_ipfix_classify_stream_dump (vat_main_t * vam)
19772 vl_api_ipfix_classify_stream_dump_t *mp;
19775 /* Construct the API message */
19776 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19787 vl_api_ipfix_classify_stream_details_t_handler
19788 (vl_api_ipfix_classify_stream_details_t * mp)
19790 vat_main_t *vam = &vat_main;
19791 print (vam->ofp, "domain_id %d, src_port %d",
19792 ntohl (mp->domain_id), ntohs (mp->src_port));
19794 vam->result_ready = 1;
19798 vl_api_ipfix_classify_stream_details_t_handler_json
19799 (vl_api_ipfix_classify_stream_details_t * mp)
19801 vat_main_t *vam = &vat_main;
19802 vat_json_node_t node;
19804 vat_json_init_object (&node);
19805 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19806 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19808 vat_json_print (vam->ofp, &node);
19809 vat_json_free (&node);
19811 vam->result_ready = 1;
19815 api_ipfix_classify_table_dump (vat_main_t * vam)
19817 vl_api_ipfix_classify_table_dump_t *mp;
19818 vl_api_control_ping_t *mp_ping;
19821 if (!vam->json_output)
19823 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19824 "transport_protocol");
19827 /* Construct the API message */
19828 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19833 /* Use a control ping for synchronization */
19834 MPING (CONTROL_PING, mp_ping);
19842 vl_api_ipfix_classify_table_details_t_handler
19843 (vl_api_ipfix_classify_table_details_t * mp)
19845 vat_main_t *vam = &vat_main;
19846 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19847 mp->transport_protocol);
19851 vl_api_ipfix_classify_table_details_t_handler_json
19852 (vl_api_ipfix_classify_table_details_t * mp)
19854 vat_json_node_t *node = NULL;
19855 vat_main_t *vam = &vat_main;
19857 if (VAT_JSON_ARRAY != vam->json_tree.type)
19859 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19860 vat_json_init_array (&vam->json_tree);
19863 node = vat_json_array_add (&vam->json_tree);
19864 vat_json_init_object (node);
19866 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19867 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19868 vat_json_object_add_uint (node, "transport_protocol",
19869 mp->transport_protocol);
19873 api_sw_interface_span_enable_disable (vat_main_t * vam)
19875 unformat_input_t *i = vam->input;
19876 vl_api_sw_interface_span_enable_disable_t *mp;
19877 u32 src_sw_if_index = ~0;
19878 u32 dst_sw_if_index = ~0;
19883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19886 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19888 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19892 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19894 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19896 else if (unformat (i, "disable"))
19898 else if (unformat (i, "rx"))
19900 else if (unformat (i, "tx"))
19902 else if (unformat (i, "both"))
19904 else if (unformat (i, "l2"))
19910 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19912 mp->sw_if_index_from = htonl (src_sw_if_index);
19913 mp->sw_if_index_to = htonl (dst_sw_if_index);
19923 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19926 vat_main_t *vam = &vat_main;
19927 u8 *sw_if_from_name = 0;
19928 u8 *sw_if_to_name = 0;
19929 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19930 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19931 char *states[] = { "none", "rx", "tx", "both" };
19935 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19937 if ((u32) p->value[0] == sw_if_index_from)
19939 sw_if_from_name = (u8 *)(p->key);
19943 if ((u32) p->value[0] == sw_if_index_to)
19945 sw_if_to_name = (u8 *)(p->key);
19946 if (sw_if_from_name)
19951 print (vam->ofp, "%20s => %20s (%s) %s",
19952 sw_if_from_name, sw_if_to_name, states[mp->state],
19953 mp->is_l2 ? "l2" : "device");
19957 vl_api_sw_interface_span_details_t_handler_json
19958 (vl_api_sw_interface_span_details_t * mp)
19960 vat_main_t *vam = &vat_main;
19961 vat_json_node_t *node = NULL;
19962 u8 *sw_if_from_name = 0;
19963 u8 *sw_if_to_name = 0;
19964 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19965 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19969 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19971 if ((u32) p->value[0] == sw_if_index_from)
19973 sw_if_from_name = (u8 *)(p->key);
19977 if ((u32) p->value[0] == sw_if_index_to)
19979 sw_if_to_name = (u8 *)(p->key);
19980 if (sw_if_from_name)
19986 if (VAT_JSON_ARRAY != vam->json_tree.type)
19988 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19989 vat_json_init_array (&vam->json_tree);
19991 node = vat_json_array_add (&vam->json_tree);
19993 vat_json_init_object (node);
19994 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
19995 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
19996 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
19997 if (0 != sw_if_to_name)
19999 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20001 vat_json_object_add_uint (node, "state", mp->state);
20002 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20006 api_sw_interface_span_dump (vat_main_t * vam)
20008 unformat_input_t *input = vam->input;
20009 vl_api_sw_interface_span_dump_t *mp;
20010 vl_api_control_ping_t *mp_ping;
20014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20016 if (unformat (input, "l2"))
20022 M (SW_INTERFACE_SPAN_DUMP, mp);
20026 /* Use a control ping for synchronization */
20027 MPING (CONTROL_PING, mp_ping);
20035 api_pg_create_interface (vat_main_t * vam)
20037 unformat_input_t *input = vam->input;
20038 vl_api_pg_create_interface_t *mp;
20042 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20044 if (unformat (input, "if_id %d", &if_id))
20051 errmsg ("missing pg interface index");
20055 /* Construct the API message */
20056 M (PG_CREATE_INTERFACE, mp);
20058 mp->interface_id = ntohl (if_id);
20066 api_pg_capture (vat_main_t * vam)
20068 unformat_input_t *input = vam->input;
20069 vl_api_pg_capture_t *mp;
20074 u8 pcap_file_set = 0;
20077 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20079 if (unformat (input, "if_id %d", &if_id))
20081 else if (unformat (input, "pcap %s", &pcap_file))
20083 else if (unformat (input, "count %d", &count))
20085 else if (unformat (input, "disable"))
20092 errmsg ("missing pg interface index");
20095 if (pcap_file_set > 0)
20097 if (vec_len (pcap_file) > 255)
20099 errmsg ("pcap file name is too long");
20104 u32 name_len = vec_len (pcap_file);
20105 /* Construct the API message */
20106 M (PG_CAPTURE, mp);
20108 mp->interface_id = ntohl (if_id);
20109 mp->is_enabled = enable;
20110 mp->count = ntohl (count);
20111 mp->pcap_name_length = ntohl (name_len);
20112 if (pcap_file_set != 0)
20114 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20116 vec_free (pcap_file);
20124 api_pg_enable_disable (vat_main_t * vam)
20126 unformat_input_t *input = vam->input;
20127 vl_api_pg_enable_disable_t *mp;
20130 u8 stream_name_set = 0;
20131 u8 *stream_name = 0;
20133 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20135 if (unformat (input, "stream %s", &stream_name))
20136 stream_name_set = 1;
20137 else if (unformat (input, "disable"))
20143 if (stream_name_set > 0)
20145 if (vec_len (stream_name) > 255)
20147 errmsg ("stream name too long");
20152 u32 name_len = vec_len (stream_name);
20153 /* Construct the API message */
20154 M (PG_ENABLE_DISABLE, mp);
20156 mp->is_enabled = enable;
20157 if (stream_name_set != 0)
20159 mp->stream_name_length = ntohl (name_len);
20160 clib_memcpy (mp->stream_name, stream_name, name_len);
20162 vec_free (stream_name);
20170 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20172 unformat_input_t *input = vam->input;
20173 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20175 u16 *low_ports = 0;
20176 u16 *high_ports = 0;
20179 vl_api_prefix_t prefix;
20187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20189 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
20191 else if (unformat (input, "vrf %d", &vrf_id))
20193 else if (unformat (input, "del"))
20195 else if (unformat (input, "port %d", &tmp))
20197 if (tmp == 0 || tmp > 65535)
20199 errmsg ("port %d out of range", tmp);
20203 this_hi = this_low + 1;
20204 vec_add1 (low_ports, this_low);
20205 vec_add1 (high_ports, this_hi);
20207 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20209 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20211 errmsg ("incorrect range parameters");
20215 /* Note: in debug CLI +1 is added to high before
20216 passing to real fn that does "the work"
20217 (ip_source_and_port_range_check_add_del).
20218 This fn is a wrapper around the binary API fn a
20219 control plane will call, which expects this increment
20220 to have occurred. Hence letting the binary API control
20221 plane fn do the increment for consistency between VAT
20222 and other control planes.
20225 vec_add1 (low_ports, this_low);
20226 vec_add1 (high_ports, this_hi);
20232 if (prefix_set == 0)
20234 errmsg ("<address>/<mask> not specified");
20240 errmsg ("VRF ID required, not specified");
20247 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20251 if (vec_len (low_ports) == 0)
20253 errmsg ("At least one port or port range required");
20257 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20259 mp->is_add = is_add;
20261 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
20263 mp->number_of_ranges = vec_len (low_ports);
20265 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20266 vec_free (low_ports);
20268 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20269 vec_free (high_ports);
20271 mp->vrf_id = ntohl (vrf_id);
20279 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20281 unformat_input_t *input = vam->input;
20282 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20283 u32 sw_if_index = ~0;
20285 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20286 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20290 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20292 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20294 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20296 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20298 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20300 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20302 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20304 else if (unformat (input, "del"))
20310 if (sw_if_index == ~0)
20312 errmsg ("Interface required but not specified");
20318 errmsg ("VRF ID required but not specified");
20322 if (tcp_out_vrf_id == 0
20323 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20326 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20330 /* Construct the API message */
20331 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20333 mp->sw_if_index = ntohl (sw_if_index);
20334 mp->is_add = is_add;
20335 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20336 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20337 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20338 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20343 /* Wait for a reply... */
20349 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
20351 unformat_input_t *i = vam->input;
20352 vl_api_ipsec_gre_add_del_tunnel_t *mp;
20353 u32 local_sa_id = 0;
20354 u32 remote_sa_id = 0;
20355 ip4_address_t src_address;
20356 ip4_address_t dst_address;
20360 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20362 if (unformat (i, "local_sa %d", &local_sa_id))
20364 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20366 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
20368 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
20370 else if (unformat (i, "del"))
20374 clib_warning ("parse error '%U'", format_unformat_error, i);
20379 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
20381 mp->local_sa_id = ntohl (local_sa_id);
20382 mp->remote_sa_id = ntohl (remote_sa_id);
20383 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
20384 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
20385 mp->is_add = is_add;
20393 api_set_punt (vat_main_t * vam)
20395 unformat_input_t *i = vam->input;
20396 vl_api_set_punt_t *mp;
20403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20405 if (unformat (i, "ip %d", &ipv))
20407 else if (unformat (i, "protocol %d", &protocol))
20409 else if (unformat (i, "port %d", &port))
20411 else if (unformat (i, "del"))
20415 clib_warning ("parse error '%U'", format_unformat_error, i);
20422 mp->is_add = (u8) is_add;
20423 mp->punt.ipv = (u8) ipv;
20424 mp->punt.l4_protocol = (u8) protocol;
20425 mp->punt.l4_port = htons ((u16) port);
20432 static void vl_api_ipsec_gre_tunnel_details_t_handler
20433 (vl_api_ipsec_gre_tunnel_details_t * mp)
20435 vat_main_t *vam = &vat_main;
20437 print (vam->ofp, "%11d%15U%15U%14d%14d",
20438 ntohl (mp->sw_if_index),
20439 format_ip4_address, &mp->src_address,
20440 format_ip4_address, &mp->dst_address,
20441 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
20444 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20445 (vl_api_ipsec_gre_tunnel_details_t * mp)
20447 vat_main_t *vam = &vat_main;
20448 vat_json_node_t *node = NULL;
20449 struct in_addr ip4;
20451 if (VAT_JSON_ARRAY != vam->json_tree.type)
20453 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20454 vat_json_init_array (&vam->json_tree);
20456 node = vat_json_array_add (&vam->json_tree);
20458 vat_json_init_object (node);
20459 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
20460 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
20461 vat_json_object_add_ip4 (node, "src_address", ip4);
20462 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
20463 vat_json_object_add_ip4 (node, "dst_address", ip4);
20464 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
20465 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
20469 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20471 unformat_input_t *i = vam->input;
20472 vl_api_ipsec_gre_tunnel_dump_t *mp;
20473 vl_api_control_ping_t *mp_ping;
20475 u8 sw_if_index_set = 0;
20478 /* Parse args required to build the message */
20479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20481 if (unformat (i, "sw_if_index %d", &sw_if_index))
20482 sw_if_index_set = 1;
20487 if (sw_if_index_set == 0)
20492 if (!vam->json_output)
20494 print (vam->ofp, "%11s%15s%15s%14s%14s",
20495 "sw_if_index", "src_address", "dst_address",
20496 "local_sa_id", "remote_sa_id");
20499 /* Get list of gre-tunnel interfaces */
20500 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20502 mp->sw_if_index = htonl (sw_if_index);
20506 /* Use a control ping for synchronization */
20507 MPING (CONTROL_PING, mp_ping);
20515 api_delete_subif (vat_main_t * vam)
20517 unformat_input_t *i = vam->input;
20518 vl_api_delete_subif_t *mp;
20519 u32 sw_if_index = ~0;
20522 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20524 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20526 if (unformat (i, "sw_if_index %d", &sw_if_index))
20532 if (sw_if_index == ~0)
20534 errmsg ("missing sw_if_index");
20538 /* Construct the API message */
20539 M (DELETE_SUBIF, mp);
20540 mp->sw_if_index = ntohl (sw_if_index);
20547 #define foreach_pbb_vtr_op \
20548 _("disable", L2_VTR_DISABLED) \
20549 _("pop", L2_VTR_POP_2) \
20550 _("push", L2_VTR_PUSH_2)
20553 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20555 unformat_input_t *i = vam->input;
20556 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20557 u32 sw_if_index = ~0, vtr_op = ~0;
20558 u16 outer_tag = ~0;
20559 u8 dmac[6], smac[6];
20560 u8 dmac_set = 0, smac_set = 0;
20566 /* Shut up coverity */
20567 clib_memset (dmac, 0, sizeof (dmac));
20568 clib_memset (smac, 0, sizeof (smac));
20570 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20572 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20574 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20576 else if (unformat (i, "vtr_op %d", &vtr_op))
20578 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20581 else if (unformat (i, "translate_pbb_stag"))
20583 if (unformat (i, "%d", &tmp))
20585 vtr_op = L2_VTR_TRANSLATE_2_1;
20591 ("translate_pbb_stag operation requires outer tag definition");
20595 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20597 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20599 else if (unformat (i, "sid %d", &sid))
20601 else if (unformat (i, "vlanid %d", &tmp))
20605 clib_warning ("parse error '%U'", format_unformat_error, i);
20610 if ((sw_if_index == ~0) || (vtr_op == ~0))
20612 errmsg ("missing sw_if_index or vtr operation");
20615 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20616 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20619 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20623 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20624 mp->sw_if_index = ntohl (sw_if_index);
20625 mp->vtr_op = ntohl (vtr_op);
20626 mp->outer_tag = ntohs (outer_tag);
20627 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20628 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20629 mp->b_vlanid = ntohs (vlanid);
20630 mp->i_sid = ntohl (sid);
20638 api_flow_classify_set_interface (vat_main_t * vam)
20640 unformat_input_t *i = vam->input;
20641 vl_api_flow_classify_set_interface_t *mp;
20643 int sw_if_index_set;
20644 u32 ip4_table_index = ~0;
20645 u32 ip6_table_index = ~0;
20649 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20651 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20652 sw_if_index_set = 1;
20653 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20654 sw_if_index_set = 1;
20655 else if (unformat (i, "del"))
20657 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20659 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20663 clib_warning ("parse error '%U'", format_unformat_error, i);
20668 if (sw_if_index_set == 0)
20670 errmsg ("missing interface name or sw_if_index");
20674 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20676 mp->sw_if_index = ntohl (sw_if_index);
20677 mp->ip4_table_index = ntohl (ip4_table_index);
20678 mp->ip6_table_index = ntohl (ip6_table_index);
20679 mp->is_add = is_add;
20687 api_flow_classify_dump (vat_main_t * vam)
20689 unformat_input_t *i = vam->input;
20690 vl_api_flow_classify_dump_t *mp;
20691 vl_api_control_ping_t *mp_ping;
20692 u8 type = FLOW_CLASSIFY_N_TABLES;
20695 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20699 errmsg ("classify table type must be specified");
20703 if (!vam->json_output)
20705 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20708 M (FLOW_CLASSIFY_DUMP, mp);
20713 /* Use a control ping for synchronization */
20714 MPING (CONTROL_PING, mp_ping);
20717 /* Wait for a reply... */
20723 api_feature_enable_disable (vat_main_t * vam)
20725 unformat_input_t *i = vam->input;
20726 vl_api_feature_enable_disable_t *mp;
20728 u8 *feature_name = 0;
20729 u32 sw_if_index = ~0;
20733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20735 if (unformat (i, "arc_name %s", &arc_name))
20737 else if (unformat (i, "feature_name %s", &feature_name))
20740 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20742 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20744 else if (unformat (i, "disable"))
20752 errmsg ("missing arc name");
20755 if (vec_len (arc_name) > 63)
20757 errmsg ("arc name too long");
20760 if (feature_name == 0)
20762 errmsg ("missing feature name");
20765 if (vec_len (feature_name) > 63)
20767 errmsg ("feature name too long");
20770 if (sw_if_index == ~0)
20772 errmsg ("missing interface name or sw_if_index");
20776 /* Construct the API message */
20777 M (FEATURE_ENABLE_DISABLE, mp);
20778 mp->sw_if_index = ntohl (sw_if_index);
20779 mp->enable = enable;
20780 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20781 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20782 vec_free (arc_name);
20783 vec_free (feature_name);
20791 api_sw_interface_tag_add_del (vat_main_t * vam)
20793 unformat_input_t *i = vam->input;
20794 vl_api_sw_interface_tag_add_del_t *mp;
20795 u32 sw_if_index = ~0;
20800 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20802 if (unformat (i, "tag %s", &tag))
20804 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20806 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20808 else if (unformat (i, "del"))
20814 if (sw_if_index == ~0)
20816 errmsg ("missing interface name or sw_if_index");
20820 if (enable && (tag == 0))
20822 errmsg ("no tag specified");
20826 /* Construct the API message */
20827 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20828 mp->sw_if_index = ntohl (sw_if_index);
20829 mp->is_add = enable;
20831 vl_api_to_api_string (strlen ((char *) tag), tag, &mp->tag);
20839 static void vl_api_l2_xconnect_details_t_handler
20840 (vl_api_l2_xconnect_details_t * mp)
20842 vat_main_t *vam = &vat_main;
20844 print (vam->ofp, "%15d%15d",
20845 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20848 static void vl_api_l2_xconnect_details_t_handler_json
20849 (vl_api_l2_xconnect_details_t * mp)
20851 vat_main_t *vam = &vat_main;
20852 vat_json_node_t *node = NULL;
20854 if (VAT_JSON_ARRAY != vam->json_tree.type)
20856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20857 vat_json_init_array (&vam->json_tree);
20859 node = vat_json_array_add (&vam->json_tree);
20861 vat_json_init_object (node);
20862 vat_json_object_add_uint (node, "rx_sw_if_index",
20863 ntohl (mp->rx_sw_if_index));
20864 vat_json_object_add_uint (node, "tx_sw_if_index",
20865 ntohl (mp->tx_sw_if_index));
20869 api_l2_xconnect_dump (vat_main_t * vam)
20871 vl_api_l2_xconnect_dump_t *mp;
20872 vl_api_control_ping_t *mp_ping;
20875 if (!vam->json_output)
20877 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20880 M (L2_XCONNECT_DUMP, mp);
20884 /* Use a control ping for synchronization */
20885 MPING (CONTROL_PING, mp_ping);
20893 api_hw_interface_set_mtu (vat_main_t * vam)
20895 unformat_input_t *i = vam->input;
20896 vl_api_hw_interface_set_mtu_t *mp;
20897 u32 sw_if_index = ~0;
20901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20903 if (unformat (i, "mtu %d", &mtu))
20905 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20907 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20913 if (sw_if_index == ~0)
20915 errmsg ("missing interface name or sw_if_index");
20921 errmsg ("no mtu specified");
20925 /* Construct the API message */
20926 M (HW_INTERFACE_SET_MTU, mp);
20927 mp->sw_if_index = ntohl (sw_if_index);
20928 mp->mtu = ntohs ((u16) mtu);
20936 api_p2p_ethernet_add (vat_main_t * vam)
20938 unformat_input_t *i = vam->input;
20939 vl_api_p2p_ethernet_add_t *mp;
20940 u32 parent_if_index = ~0;
20946 clib_memset (remote_mac, 0, sizeof (remote_mac));
20947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
20951 else if (unformat (i, "sw_if_index %d", &parent_if_index))
20955 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
20957 else if (unformat (i, "sub_id %d", &sub_id))
20961 clib_warning ("parse error '%U'", format_unformat_error, i);
20966 if (parent_if_index == ~0)
20968 errmsg ("missing interface name or sw_if_index");
20973 errmsg ("missing remote mac address");
20978 errmsg ("missing sub-interface id");
20982 M (P2P_ETHERNET_ADD, mp);
20983 mp->parent_if_index = ntohl (parent_if_index);
20984 mp->subif_id = ntohl (sub_id);
20985 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
20993 api_p2p_ethernet_del (vat_main_t * vam)
20995 unformat_input_t *i = vam->input;
20996 vl_api_p2p_ethernet_del_t *mp;
20997 u32 parent_if_index = ~0;
21002 clib_memset (remote_mac, 0, sizeof (remote_mac));
21003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21007 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21011 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21015 clib_warning ("parse error '%U'", format_unformat_error, i);
21020 if (parent_if_index == ~0)
21022 errmsg ("missing interface name or sw_if_index");
21027 errmsg ("missing remote mac address");
21031 M (P2P_ETHERNET_DEL, mp);
21032 mp->parent_if_index = ntohl (parent_if_index);
21033 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21041 api_lldp_config (vat_main_t * vam)
21043 unformat_input_t *i = vam->input;
21044 vl_api_lldp_config_t *mp;
21046 int tx_interval = 0;
21047 u8 *sys_name = NULL;
21050 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21052 if (unformat (i, "system-name %s", &sys_name))
21054 else if (unformat (i, "tx-hold %d", &tx_hold))
21056 else if (unformat (i, "tx-interval %d", &tx_interval))
21060 clib_warning ("parse error '%U'", format_unformat_error, i);
21065 vec_add1 (sys_name, 0);
21067 M (LLDP_CONFIG, mp);
21068 mp->tx_hold = htonl (tx_hold);
21069 mp->tx_interval = htonl (tx_interval);
21070 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21071 vec_free (sys_name);
21079 api_sw_interface_set_lldp (vat_main_t * vam)
21081 unformat_input_t *i = vam->input;
21082 vl_api_sw_interface_set_lldp_t *mp;
21083 u32 sw_if_index = ~0;
21085 u8 *port_desc = NULL, *mgmt_oid = NULL;
21086 ip4_address_t ip4_addr;
21087 ip6_address_t ip6_addr;
21090 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21091 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21093 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21095 if (unformat (i, "disable"))
21098 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21100 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21102 else if (unformat (i, "port-desc %s", &port_desc))
21104 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21106 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21108 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21114 if (sw_if_index == ~0)
21116 errmsg ("missing interface name or sw_if_index");
21120 /* Construct the API message */
21121 vec_add1 (port_desc, 0);
21122 vec_add1 (mgmt_oid, 0);
21123 M (SW_INTERFACE_SET_LLDP, mp);
21124 mp->sw_if_index = ntohl (sw_if_index);
21125 mp->enable = enable;
21126 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21127 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21128 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21129 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21130 vec_free (port_desc);
21131 vec_free (mgmt_oid);
21139 api_tcp_configure_src_addresses (vat_main_t * vam)
21141 vl_api_tcp_configure_src_addresses_t *mp;
21142 unformat_input_t *i = vam->input;
21143 ip4_address_t v4first, v4last;
21144 ip6_address_t v6first, v6last;
21149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21151 if (unformat (i, "%U - %U",
21152 unformat_ip4_address, &v4first,
21153 unformat_ip4_address, &v4last))
21157 errmsg ("one range per message (range already set)");
21162 else if (unformat (i, "%U - %U",
21163 unformat_ip6_address, &v6first,
21164 unformat_ip6_address, &v6last))
21168 errmsg ("one range per message (range already set)");
21173 else if (unformat (i, "vrf %d", &vrf_id))
21179 if (range_set == 0)
21181 errmsg ("address range not set");
21185 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21186 mp->vrf_id = ntohl (vrf_id);
21188 if (range_set == 2)
21191 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21192 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21197 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21198 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21205 static void vl_api_app_namespace_add_del_reply_t_handler
21206 (vl_api_app_namespace_add_del_reply_t * mp)
21208 vat_main_t *vam = &vat_main;
21209 i32 retval = ntohl (mp->retval);
21210 if (vam->async_mode)
21212 vam->async_errors += (retval < 0);
21216 vam->retval = retval;
21218 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21219 vam->result_ready = 1;
21223 static void vl_api_app_namespace_add_del_reply_t_handler_json
21224 (vl_api_app_namespace_add_del_reply_t * mp)
21226 vat_main_t *vam = &vat_main;
21227 vat_json_node_t node;
21229 vat_json_init_object (&node);
21230 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21231 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21233 vat_json_print (vam->ofp, &node);
21234 vat_json_free (&node);
21236 vam->retval = ntohl (mp->retval);
21237 vam->result_ready = 1;
21241 api_app_namespace_add_del (vat_main_t * vam)
21243 vl_api_app_namespace_add_del_t *mp;
21244 unformat_input_t *i = vam->input;
21245 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21246 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21250 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21252 if (unformat (i, "id %_%v%_", &ns_id))
21254 else if (unformat (i, "secret %lu", &secret))
21256 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21257 sw_if_index_set = 1;
21258 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21260 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21265 if (!ns_id || !secret_set || !sw_if_index_set)
21267 errmsg ("namespace id, secret and sw_if_index must be set");
21270 if (vec_len (ns_id) > 64)
21272 errmsg ("namespace id too long");
21275 M (APP_NAMESPACE_ADD_DEL, mp);
21277 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21278 mp->namespace_id_len = vec_len (ns_id);
21279 mp->secret = clib_host_to_net_u64 (secret);
21280 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21281 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21282 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21290 api_sock_init_shm (vat_main_t * vam)
21292 #if VPP_API_TEST_BUILTIN == 0
21293 unformat_input_t *i = vam->input;
21294 vl_api_shm_elem_config_t *config = 0;
21295 u64 size = 64 << 20;
21298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21300 if (unformat (i, "size %U", unformat_memory_size, &size))
21307 * Canned custom ring allocator config.
21308 * Should probably parse all of this
21310 vec_validate (config, 6);
21311 config[0].type = VL_API_VLIB_RING;
21312 config[0].size = 256;
21313 config[0].count = 32;
21315 config[1].type = VL_API_VLIB_RING;
21316 config[1].size = 1024;
21317 config[1].count = 16;
21319 config[2].type = VL_API_VLIB_RING;
21320 config[2].size = 4096;
21321 config[2].count = 2;
21323 config[3].type = VL_API_CLIENT_RING;
21324 config[3].size = 256;
21325 config[3].count = 32;
21327 config[4].type = VL_API_CLIENT_RING;
21328 config[4].size = 1024;
21329 config[4].count = 16;
21331 config[5].type = VL_API_CLIENT_RING;
21332 config[5].size = 4096;
21333 config[5].count = 2;
21335 config[6].type = VL_API_QUEUE;
21336 config[6].count = 128;
21337 config[6].size = sizeof (uword);
21339 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
21341 vam->client_index_invalid = 1;
21349 api_dns_enable_disable (vat_main_t * vam)
21351 unformat_input_t *line_input = vam->input;
21352 vl_api_dns_enable_disable_t *mp;
21353 u8 enable_disable = 1;
21356 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21358 if (unformat (line_input, "disable"))
21359 enable_disable = 0;
21360 if (unformat (line_input, "enable"))
21361 enable_disable = 1;
21366 /* Construct the API message */
21367 M (DNS_ENABLE_DISABLE, mp);
21368 mp->enable = enable_disable;
21372 /* Wait for the reply */
21378 api_dns_resolve_name (vat_main_t * vam)
21380 unformat_input_t *line_input = vam->input;
21381 vl_api_dns_resolve_name_t *mp;
21385 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21387 if (unformat (line_input, "%s", &name))
21393 if (vec_len (name) > 127)
21395 errmsg ("name too long");
21399 /* Construct the API message */
21400 M (DNS_RESOLVE_NAME, mp);
21401 memcpy (mp->name, name, vec_len (name));
21406 /* Wait for the reply */
21412 api_dns_resolve_ip (vat_main_t * vam)
21414 unformat_input_t *line_input = vam->input;
21415 vl_api_dns_resolve_ip_t *mp;
21417 ip4_address_t addr4;
21418 ip6_address_t addr6;
21421 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21423 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21425 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21433 errmsg ("missing address");
21437 /* Construct the API message */
21438 M (DNS_RESOLVE_IP, mp);
21439 mp->is_ip6 = is_ip6;
21441 memcpy (mp->address, &addr6, sizeof (addr6));
21443 memcpy (mp->address, &addr4, sizeof (addr4));
21447 /* Wait for the reply */
21453 api_dns_name_server_add_del (vat_main_t * vam)
21455 unformat_input_t *i = vam->input;
21456 vl_api_dns_name_server_add_del_t *mp;
21458 ip6_address_t ip6_server;
21459 ip4_address_t ip4_server;
21464 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21466 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21468 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21470 else if (unformat (i, "del"))
21474 clib_warning ("parse error '%U'", format_unformat_error, i);
21479 if (ip4_set && ip6_set)
21481 errmsg ("Only one server address allowed per message");
21484 if ((ip4_set + ip6_set) == 0)
21486 errmsg ("Server address required");
21490 /* Construct the API message */
21491 M (DNS_NAME_SERVER_ADD_DEL, mp);
21495 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21500 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21504 mp->is_add = is_add;
21509 /* Wait for a reply, return good/bad news */
21515 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21517 vat_main_t *vam = &vat_main;
21522 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21523 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21524 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21525 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21526 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21527 clib_net_to_host_u32 (mp->action_index), mp->tag);
21532 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21533 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21534 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21535 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21536 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21537 clib_net_to_host_u32 (mp->action_index), mp->tag);
21542 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21545 vat_main_t *vam = &vat_main;
21546 vat_json_node_t *node = NULL;
21547 struct in6_addr ip6;
21548 struct in_addr ip4;
21550 if (VAT_JSON_ARRAY != vam->json_tree.type)
21552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21553 vat_json_init_array (&vam->json_tree);
21555 node = vat_json_array_add (&vam->json_tree);
21556 vat_json_init_object (node);
21558 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21559 vat_json_object_add_uint (node, "appns_index",
21560 clib_net_to_host_u32 (mp->appns_index));
21561 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21562 vat_json_object_add_uint (node, "scope", mp->scope);
21563 vat_json_object_add_uint (node, "action_index",
21564 clib_net_to_host_u32 (mp->action_index));
21565 vat_json_object_add_uint (node, "lcl_port",
21566 clib_net_to_host_u16 (mp->lcl_port));
21567 vat_json_object_add_uint (node, "rmt_port",
21568 clib_net_to_host_u16 (mp->rmt_port));
21569 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21570 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21571 vat_json_object_add_string_copy (node, "tag", mp->tag);
21574 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21575 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21576 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21577 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21581 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21582 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21583 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21584 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21589 api_session_rule_add_del (vat_main_t * vam)
21591 vl_api_session_rule_add_del_t *mp;
21592 unformat_input_t *i = vam->input;
21593 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21594 u32 appns_index = 0, scope = 0;
21595 ip4_address_t lcl_ip4, rmt_ip4;
21596 ip6_address_t lcl_ip6, rmt_ip6;
21597 u8 is_ip4 = 1, conn_set = 0;
21598 u8 is_add = 1, *tag = 0;
21601 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21603 if (unformat (i, "del"))
21605 else if (unformat (i, "add"))
21607 else if (unformat (i, "proto tcp"))
21609 else if (unformat (i, "proto udp"))
21611 else if (unformat (i, "appns %d", &appns_index))
21613 else if (unformat (i, "scope %d", &scope))
21615 else if (unformat (i, "tag %_%v%_", &tag))
21619 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21620 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21628 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21629 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21635 else if (unformat (i, "action %d", &action))
21640 if (proto == ~0 || !conn_set || action == ~0)
21642 errmsg ("transport proto, connection and action must be set");
21648 errmsg ("scope should be 0-3");
21652 M (SESSION_RULE_ADD_DEL, mp);
21654 mp->is_ip4 = is_ip4;
21655 mp->transport_proto = proto;
21656 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21657 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21658 mp->lcl_plen = lcl_plen;
21659 mp->rmt_plen = rmt_plen;
21660 mp->action_index = clib_host_to_net_u32 (action);
21661 mp->appns_index = clib_host_to_net_u32 (appns_index);
21663 mp->is_add = is_add;
21666 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21667 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21671 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21672 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21676 clib_memcpy (mp->tag, tag, vec_len (tag));
21686 api_session_rules_dump (vat_main_t * vam)
21688 vl_api_session_rules_dump_t *mp;
21689 vl_api_control_ping_t *mp_ping;
21692 if (!vam->json_output)
21694 print (vam->ofp, "%=20s", "Session Rules");
21697 M (SESSION_RULES_DUMP, mp);
21701 /* Use a control ping for synchronization */
21702 MPING (CONTROL_PING, mp_ping);
21705 /* Wait for a reply... */
21711 api_ip_container_proxy_add_del (vat_main_t * vam)
21713 vl_api_ip_container_proxy_add_del_t *mp;
21714 unformat_input_t *i = vam->input;
21715 u32 sw_if_index = ~0;
21716 vl_api_prefix_t pfx = { };
21720 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21722 if (unformat (i, "del"))
21724 else if (unformat (i, "add"))
21726 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21728 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21733 if (sw_if_index == ~0 || pfx.address_length == 0)
21735 errmsg ("address and sw_if_index must be set");
21739 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21741 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21742 mp->is_add = is_add;
21743 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21751 api_qos_record_enable_disable (vat_main_t * vam)
21753 unformat_input_t *i = vam->input;
21754 vl_api_qos_record_enable_disable_t *mp;
21755 u32 sw_if_index, qs = 0xff;
21756 u8 sw_if_index_set = 0;
21760 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21762 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21763 sw_if_index_set = 1;
21764 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21765 sw_if_index_set = 1;
21766 else if (unformat (i, "%U", unformat_qos_source, &qs))
21768 else if (unformat (i, "disable"))
21772 clib_warning ("parse error '%U'", format_unformat_error, i);
21777 if (sw_if_index_set == 0)
21779 errmsg ("missing interface name or sw_if_index");
21784 errmsg ("input location must be specified");
21788 M (QOS_RECORD_ENABLE_DISABLE, mp);
21790 mp->sw_if_index = ntohl (sw_if_index);
21791 mp->input_source = qs;
21792 mp->enable = enable;
21801 q_or_quit (vat_main_t * vam)
21803 #if VPP_API_TEST_BUILTIN == 0
21804 longjmp (vam->jump_buf, 1);
21806 return 0; /* not so much */
21810 q (vat_main_t * vam)
21812 return q_or_quit (vam);
21816 quit (vat_main_t * vam)
21818 return q_or_quit (vam);
21822 comment (vat_main_t * vam)
21828 statseg (vat_main_t * vam)
21830 ssvm_private_t *ssvmp = &vam->stat_segment;
21831 ssvm_shared_header_t *shared_header = ssvmp->sh;
21832 vlib_counter_t **counters;
21833 u64 thread0_index1_packets;
21834 u64 thread0_index1_bytes;
21835 f64 vector_rate, input_rate;
21838 uword *counter_vector_by_name;
21839 if (vam->stat_segment_lockp == 0)
21841 errmsg ("Stat segment not mapped...");
21845 /* look up "/if/rx for sw_if_index 1 as a test */
21847 clib_spinlock_lock (vam->stat_segment_lockp);
21849 counter_vector_by_name = (uword *) shared_header->opaque[1];
21851 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21854 clib_spinlock_unlock (vam->stat_segment_lockp);
21855 errmsg ("/if/tx not found?");
21859 /* Fish per-thread vector of combined counters from shared memory */
21860 counters = (vlib_counter_t **) p[0];
21862 if (vec_len (counters[0]) < 2)
21864 clib_spinlock_unlock (vam->stat_segment_lockp);
21865 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21869 /* Read thread 0 sw_if_index 1 counter */
21870 thread0_index1_packets = counters[0][1].packets;
21871 thread0_index1_bytes = counters[0][1].bytes;
21873 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21876 clib_spinlock_unlock (vam->stat_segment_lockp);
21877 errmsg ("vector_rate not found?");
21881 vector_rate = *(f64 *) (p[0]);
21882 p = hash_get_mem (counter_vector_by_name, "input_rate");
21885 clib_spinlock_unlock (vam->stat_segment_lockp);
21886 errmsg ("input_rate not found?");
21889 input_rate = *(f64 *) (p[0]);
21891 clib_spinlock_unlock (vam->stat_segment_lockp);
21893 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21894 vector_rate, input_rate);
21895 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21896 thread0_index1_packets, thread0_index1_bytes);
21902 cmd_cmp (void *a1, void *a2)
21907 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21911 help (vat_main_t * vam)
21916 unformat_input_t *i = vam->input;
21919 if (unformat (i, "%s", &name))
21923 vec_add1 (name, 0);
21925 hs = hash_get_mem (vam->help_by_name, name);
21927 print (vam->ofp, "usage: %s %s", name, hs[0]);
21929 print (vam->ofp, "No such msg / command '%s'", name);
21934 print (vam->ofp, "Help is available for the following:");
21937 hash_foreach_pair (p, vam->function_by_name,
21939 vec_add1 (cmds, (u8 *)(p->key));
21943 vec_sort_with_function (cmds, cmd_cmp);
21945 for (j = 0; j < vec_len (cmds); j++)
21946 print (vam->ofp, "%s", cmds[j]);
21953 set (vat_main_t * vam)
21955 u8 *name = 0, *value = 0;
21956 unformat_input_t *i = vam->input;
21958 if (unformat (i, "%s", &name))
21960 /* The input buffer is a vector, not a string. */
21961 value = vec_dup (i->buffer);
21962 vec_delete (value, i->index, 0);
21963 /* Almost certainly has a trailing newline */
21964 if (value[vec_len (value) - 1] == '\n')
21965 value[vec_len (value) - 1] = 0;
21966 /* Make sure it's a proper string, one way or the other */
21967 vec_add1 (value, 0);
21968 (void) clib_macro_set_value (&vam->macro_main,
21969 (char *) name, (char *) value);
21972 errmsg ("usage: set <name> <value>");
21980 unset (vat_main_t * vam)
21984 if (unformat (vam->input, "%s", &name))
21985 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
21986 errmsg ("unset: %s wasn't set", name);
21999 macro_sort_cmp (void *a1, void *a2)
22001 macro_sort_t *s1 = a1;
22002 macro_sort_t *s2 = a2;
22004 return strcmp ((char *) (s1->name), (char *) (s2->name));
22008 dump_macro_table (vat_main_t * vam)
22010 macro_sort_t *sort_me = 0, *sm;
22015 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22017 vec_add2 (sort_me, sm, 1);
22018 sm->name = (u8 *)(p->key);
22019 sm->value = (u8 *) (p->value[0]);
22023 vec_sort_with_function (sort_me, macro_sort_cmp);
22025 if (vec_len (sort_me))
22026 print (vam->ofp, "%-15s%s", "Name", "Value");
22028 print (vam->ofp, "The macro table is empty...");
22030 for (i = 0; i < vec_len (sort_me); i++)
22031 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22036 dump_node_table (vat_main_t * vam)
22039 vlib_node_t *node, *next_node;
22041 if (vec_len (vam->graph_nodes) == 0)
22043 print (vam->ofp, "Node table empty, issue get_node_graph...");
22047 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22049 node = vam->graph_nodes[0][i];
22050 print (vam->ofp, "[%d] %s", i, node->name);
22051 for (j = 0; j < vec_len (node->next_nodes); j++)
22053 if (node->next_nodes[j] != ~0)
22055 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22056 print (vam->ofp, " [%d] %s", j, next_node->name);
22064 value_sort_cmp (void *a1, void *a2)
22066 name_sort_t *n1 = a1;
22067 name_sort_t *n2 = a2;
22069 if (n1->value < n2->value)
22071 if (n1->value > n2->value)
22078 dump_msg_api_table (vat_main_t * vam)
22080 api_main_t *am = &api_main;
22081 name_sort_t *nses = 0, *ns;
22086 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22088 vec_add2 (nses, ns, 1);
22089 ns->name = (u8 *)(hp->key);
22090 ns->value = (u32) hp->value[0];
22094 vec_sort_with_function (nses, value_sort_cmp);
22096 for (i = 0; i < vec_len (nses); i++)
22097 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22103 get_msg_id (vat_main_t * vam)
22108 if (unformat (vam->input, "%s", &name_and_crc))
22110 message_index = vl_msg_api_get_msg_index (name_and_crc);
22111 if (message_index == ~0)
22113 print (vam->ofp, " '%s' not found", name_and_crc);
22116 print (vam->ofp, " '%s' has message index %d",
22117 name_and_crc, message_index);
22120 errmsg ("name_and_crc required...");
22125 search_node_table (vat_main_t * vam)
22127 unformat_input_t *line_input = vam->input;
22130 vlib_node_t *node, *next_node;
22133 if (vam->graph_node_index_by_name == 0)
22135 print (vam->ofp, "Node table empty, issue get_node_graph...");
22139 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22141 if (unformat (line_input, "%s", &node_to_find))
22143 vec_add1 (node_to_find, 0);
22144 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22147 print (vam->ofp, "%s not found...", node_to_find);
22150 node = vam->graph_nodes[0][p[0]];
22151 print (vam->ofp, "[%d] %s", p[0], node->name);
22152 for (j = 0; j < vec_len (node->next_nodes); j++)
22154 if (node->next_nodes[j] != ~0)
22156 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22157 print (vam->ofp, " [%d] %s", j, next_node->name);
22164 clib_warning ("parse error '%U'", format_unformat_error,
22170 vec_free (node_to_find);
22179 script (vat_main_t * vam)
22181 #if (VPP_API_TEST_BUILTIN==0)
22183 char *save_current_file;
22184 unformat_input_t save_input;
22185 jmp_buf save_jump_buf;
22186 u32 save_line_number;
22188 FILE *new_fp, *save_ifp;
22190 if (unformat (vam->input, "%s", &s))
22192 new_fp = fopen ((char *) s, "r");
22195 errmsg ("Couldn't open script file %s", s);
22202 errmsg ("Missing script name");
22206 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22207 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22208 save_ifp = vam->ifp;
22209 save_line_number = vam->input_line_number;
22210 save_current_file = (char *) vam->current_file;
22212 vam->input_line_number = 0;
22214 vam->current_file = s;
22217 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
22218 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22219 vam->ifp = save_ifp;
22220 vam->input_line_number = save_line_number;
22221 vam->current_file = (u8 *) save_current_file;
22226 clib_warning ("use the exec command...");
22232 echo (vat_main_t * vam)
22234 print (vam->ofp, "%v", vam->input->buffer);
22238 /* List of API message constructors, CLI names map to api_xxx */
22239 #define foreach_vpe_api_msg \
22240 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22241 _(sw_interface_dump,"") \
22242 _(sw_interface_set_flags, \
22243 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22244 _(sw_interface_add_del_address, \
22245 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22246 _(sw_interface_set_rx_mode, \
22247 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22248 _(sw_interface_set_rx_placement, \
22249 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
22250 _(sw_interface_rx_placement_dump, \
22251 "[<intfc> | sw_if_index <id>]") \
22252 _(sw_interface_set_table, \
22253 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22254 _(sw_interface_set_mpls_enable, \
22255 "<intfc> | sw_if_index [disable | dis]") \
22256 _(sw_interface_set_vpath, \
22257 "<intfc> | sw_if_index <id> enable | disable") \
22258 _(sw_interface_set_vxlan_bypass, \
22259 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22260 _(sw_interface_set_geneve_bypass, \
22261 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22262 _(sw_interface_set_l2_xconnect, \
22263 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22264 "enable | disable") \
22265 _(sw_interface_set_l2_bridge, \
22266 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22267 "[shg <split-horizon-group>] [bvi]\n" \
22268 "enable | disable") \
22269 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22270 _(bridge_domain_add_del, \
22271 "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") \
22272 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22274 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22275 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22276 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22278 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22280 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22282 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22284 "<vpp-if-name> | sw_if_index <id>") \
22285 _(sw_interface_tap_v2_dump, "") \
22286 _(virtio_pci_create, \
22287 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
22288 _(virtio_pci_delete, \
22289 "<vpp-if-name> | sw_if_index <id>") \
22290 _(sw_interface_virtio_pci_dump, "") \
22292 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
22293 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
22296 "<vpp-if-name> | sw_if_index <id>") \
22298 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
22299 _(bond_detach_slave, \
22300 "sw_if_index <n>") \
22301 _(sw_interface_bond_dump, "") \
22302 _(sw_interface_slave_dump, \
22303 "<vpp-if-name> | sw_if_index <id>") \
22304 _(ip_table_add_del, \
22305 "table <n> [ipv6] [add | del]\n") \
22306 _(ip_add_del_route, \
22307 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
22308 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
22309 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
22310 "[multipath] [count <n>] [del]") \
22311 _(ip_mroute_add_del, \
22312 "<src> <grp>/<mask> [table-id <n>]\n" \
22313 "[<intfc> | sw_if_index <id>] [local] [del]") \
22314 _(mpls_table_add_del, \
22315 "table <n> [add | del]\n") \
22316 _(mpls_route_add_del, \
22317 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
22318 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
22319 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
22320 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
22321 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
22322 "[count <n>] [del]") \
22323 _(mpls_ip_bind_unbind, \
22324 "<label> <addr/len>") \
22325 _(mpls_tunnel_add_del, \
22326 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22327 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22328 "[l2-only] [out-label <n>]") \
22329 _(sr_mpls_policy_add, \
22330 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22331 _(sr_mpls_policy_del, \
22333 _(bier_table_add_del, \
22334 "<label> <sub-domain> <set> <bsl> [del]") \
22335 _(bier_route_add_del, \
22336 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22337 "[<intfc> | sw_if_index <id>]" \
22338 "[weight <n>] [del] [multipath]") \
22339 _(proxy_arp_add_del, \
22340 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22341 _(proxy_arp_intfc_enable_disable, \
22342 "<intfc> | sw_if_index <id> enable | disable") \
22343 _(sw_interface_set_unnumbered, \
22344 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22345 _(ip_neighbor_add_del, \
22346 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22347 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22348 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22349 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22350 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22351 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22352 "[outer_vlan_id_any][inner_vlan_id_any]") \
22353 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22354 _(reset_fib, "vrf <n> [ipv6]") \
22355 _(dhcp_proxy_config, \
22356 "svr <v46-address> src <v46-address>\n" \
22357 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22358 _(dhcp_proxy_set_vss, \
22359 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22360 _(dhcp_proxy_dump, "ip6") \
22361 _(dhcp_client_config, \
22362 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22363 _(set_ip_flow_hash, \
22364 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22365 _(sw_interface_ip6_enable_disable, \
22366 "<intfc> | sw_if_index <id> enable | disable") \
22367 _(ip6nd_proxy_add_del, \
22368 "<intfc> | sw_if_index <id> <ip6-address>") \
22369 _(ip6nd_proxy_dump, "") \
22370 _(sw_interface_ip6nd_ra_prefix, \
22371 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22372 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22373 "[nolink] [isno]") \
22374 _(sw_interface_ip6nd_ra_config, \
22375 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22376 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22377 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22378 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22379 _(l2_patch_add_del, \
22380 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22381 "enable | disable") \
22382 _(sr_localsid_add_del, \
22383 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22384 "fib-table <num> (end.psp) sw_if_index <num>") \
22385 _(classify_add_del_table, \
22386 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22387 " [del] [del-chain] mask <mask-value>\n" \
22388 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22389 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22390 _(classify_add_del_session, \
22391 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22392 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22393 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22394 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22395 _(classify_set_interface_ip_table, \
22396 "<intfc> | sw_if_index <nn> table <nn>") \
22397 _(classify_set_interface_l2_tables, \
22398 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22399 " [other-table <nn>]") \
22400 _(get_node_index, "node <node-name") \
22401 _(add_node_next, "node <node-name> next <next-node-name>") \
22402 _(l2tpv3_create_tunnel, \
22403 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22404 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22405 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22406 _(l2tpv3_set_tunnel_cookies, \
22407 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22408 "[new_remote_cookie <nn>]\n") \
22409 _(l2tpv3_interface_enable_disable, \
22410 "<intfc> | sw_if_index <nn> enable | disable") \
22411 _(l2tpv3_set_lookup_key, \
22412 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22413 _(sw_if_l2tpv3_tunnel_dump, "") \
22414 _(vxlan_offload_rx, \
22415 "hw { <interface name> | hw_if_index <nn>} " \
22416 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22417 _(vxlan_add_del_tunnel, \
22418 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22419 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22420 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22421 _(geneve_add_del_tunnel, \
22422 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22423 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22424 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22425 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22426 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22427 _(gre_add_del_tunnel, \
22428 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22429 "[teb | erspan <session-id>] [del]") \
22430 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22431 _(l2_fib_clear_table, "") \
22432 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22433 _(l2_interface_vlan_tag_rewrite, \
22434 "<intfc> | sw_if_index <nn> \n" \
22435 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22436 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22437 _(create_vhost_user_if, \
22438 "socket <filename> [server] [renumber <dev_instance>] " \
22439 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22440 "[mac <mac_address>]") \
22441 _(modify_vhost_user_if, \
22442 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22443 "[server] [renumber <dev_instance>]") \
22444 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22445 _(sw_interface_vhost_user_dump, "") \
22446 _(show_version, "") \
22447 _(show_threads, "") \
22448 _(vxlan_gpe_add_del_tunnel, \
22449 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22450 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22451 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22452 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22453 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22454 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22455 _(interface_name_renumber, \
22456 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22457 _(input_acl_set_interface, \
22458 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22459 " [l2-table <nn>] [del]") \
22460 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22461 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22462 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22463 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22464 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22465 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22466 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22467 _(ip_dump, "ipv4 | ipv6") \
22468 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22469 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22471 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22472 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22473 " integ_alg <alg> integ_key <hex>") \
22474 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22475 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22476 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22477 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22478 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22479 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22480 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22481 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22482 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22483 " [instance <n>]") \
22484 _(ipsec_sa_dump, "[sa_id <n>]") \
22485 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22486 " <alg> <hex>\n") \
22487 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22488 _(delete_loopback,"sw_if_index <nn>") \
22489 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22490 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22491 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22492 _(want_interface_events, "enable|disable") \
22493 _(get_first_msg_id, "client <name>") \
22494 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22495 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22496 "fib-id <nn> [ip4][ip6][default]") \
22497 _(get_node_graph, " ") \
22498 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22499 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22500 _(ioam_disable, "") \
22501 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22502 " sw_if_index <sw_if_index> p <priority> " \
22503 "w <weight>] [del]") \
22504 _(one_add_del_locator, "locator-set <locator_name> " \
22505 "iface <intf> | sw_if_index <sw_if_index> " \
22506 "p <priority> w <weight> [del]") \
22507 _(one_add_del_local_eid,"vni <vni> eid " \
22508 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22509 "locator-set <locator_name> [del]" \
22510 "[key-id sha1|sha256 secret-key <secret-key>]")\
22511 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22512 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22513 _(one_enable_disable, "enable|disable") \
22514 _(one_map_register_enable_disable, "enable|disable") \
22515 _(one_map_register_fallback_threshold, "<value>") \
22516 _(one_rloc_probe_enable_disable, "enable|disable") \
22517 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22519 "rloc <locator> p <prio> " \
22520 "w <weight> [rloc <loc> ... ] " \
22521 "action <action> [del-all]") \
22522 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22524 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22525 _(one_use_petr, "ip-address> | disable") \
22526 _(one_map_request_mode, "src-dst|dst-only") \
22527 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22528 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22529 _(one_locator_set_dump, "[local | remote]") \
22530 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22531 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22532 "[local] | [remote]") \
22533 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22534 _(one_ndp_bd_get, "") \
22535 _(one_ndp_entries_get, "bd <bridge-domain>") \
22536 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22537 _(one_l2_arp_bd_get, "") \
22538 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22539 _(one_stats_enable_disable, "enable|disable") \
22540 _(show_one_stats_enable_disable, "") \
22541 _(one_eid_table_vni_dump, "") \
22542 _(one_eid_table_map_dump, "l2|l3") \
22543 _(one_map_resolver_dump, "") \
22544 _(one_map_server_dump, "") \
22545 _(one_adjacencies_get, "vni <vni>") \
22546 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22547 _(show_one_rloc_probe_state, "") \
22548 _(show_one_map_register_state, "") \
22549 _(show_one_status, "") \
22550 _(one_stats_dump, "") \
22551 _(one_stats_flush, "") \
22552 _(one_get_map_request_itr_rlocs, "") \
22553 _(one_map_register_set_ttl, "<ttl>") \
22554 _(one_set_transport_protocol, "udp|api") \
22555 _(one_get_transport_protocol, "") \
22556 _(one_enable_disable_xtr_mode, "enable|disable") \
22557 _(one_show_xtr_mode, "") \
22558 _(one_enable_disable_pitr_mode, "enable|disable") \
22559 _(one_show_pitr_mode, "") \
22560 _(one_enable_disable_petr_mode, "enable|disable") \
22561 _(one_show_petr_mode, "") \
22562 _(show_one_nsh_mapping, "") \
22563 _(show_one_pitr, "") \
22564 _(show_one_use_petr, "") \
22565 _(show_one_map_request_mode, "") \
22566 _(show_one_map_register_ttl, "") \
22567 _(show_one_map_register_fallback_threshold, "") \
22568 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22569 " sw_if_index <sw_if_index> p <priority> " \
22570 "w <weight>] [del]") \
22571 _(lisp_add_del_locator, "locator-set <locator_name> " \
22572 "iface <intf> | sw_if_index <sw_if_index> " \
22573 "p <priority> w <weight> [del]") \
22574 _(lisp_add_del_local_eid,"vni <vni> eid " \
22575 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22576 "locator-set <locator_name> [del]" \
22577 "[key-id sha1|sha256 secret-key <secret-key>]") \
22578 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22579 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22580 _(lisp_enable_disable, "enable|disable") \
22581 _(lisp_map_register_enable_disable, "enable|disable") \
22582 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22583 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22585 "rloc <locator> p <prio> " \
22586 "w <weight> [rloc <loc> ... ] " \
22587 "action <action> [del-all]") \
22588 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22590 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22591 _(lisp_use_petr, "<ip-address> | disable") \
22592 _(lisp_map_request_mode, "src-dst|dst-only") \
22593 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22594 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22595 _(lisp_locator_set_dump, "[local | remote]") \
22596 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22597 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22598 "[local] | [remote]") \
22599 _(lisp_eid_table_vni_dump, "") \
22600 _(lisp_eid_table_map_dump, "l2|l3") \
22601 _(lisp_map_resolver_dump, "") \
22602 _(lisp_map_server_dump, "") \
22603 _(lisp_adjacencies_get, "vni <vni>") \
22604 _(gpe_fwd_entry_vnis_get, "") \
22605 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22606 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22607 "[table <table-id>]") \
22608 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22609 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22610 _(gpe_set_encap_mode, "lisp|vxlan") \
22611 _(gpe_get_encap_mode, "") \
22612 _(lisp_gpe_add_del_iface, "up|down") \
22613 _(lisp_gpe_enable_disable, "enable|disable") \
22614 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22615 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22616 _(show_lisp_rloc_probe_state, "") \
22617 _(show_lisp_map_register_state, "") \
22618 _(show_lisp_status, "") \
22619 _(lisp_get_map_request_itr_rlocs, "") \
22620 _(show_lisp_pitr, "") \
22621 _(show_lisp_use_petr, "") \
22622 _(show_lisp_map_request_mode, "") \
22623 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22624 _(af_packet_delete, "name <host interface name>") \
22625 _(af_packet_dump, "") \
22626 _(policer_add_del, "name <policer name> <params> [del]") \
22627 _(policer_dump, "[name <policer name>]") \
22628 _(policer_classify_set_interface, \
22629 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22630 " [l2-table <nn>] [del]") \
22631 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22632 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22633 "[master|slave]") \
22634 _(netmap_delete, "name <interface name>") \
22635 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22636 _(mpls_fib_dump, "") \
22637 _(classify_table_ids, "") \
22638 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22639 _(classify_table_info, "table_id <nn>") \
22640 _(classify_session_dump, "table_id <nn>") \
22641 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22642 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22643 "[template_interval <nn>] [udp_checksum]") \
22644 _(ipfix_exporter_dump, "") \
22645 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22646 _(ipfix_classify_stream_dump, "") \
22647 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22648 _(ipfix_classify_table_dump, "") \
22649 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22650 _(sw_interface_span_dump, "[l2]") \
22651 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22652 _(pg_create_interface, "if_id <nn>") \
22653 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22654 _(pg_enable_disable, "[stream <id>] disable") \
22655 _(ip_source_and_port_range_check_add_del, \
22656 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22657 _(ip_source_and_port_range_check_interface_add_del, \
22658 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22659 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22660 _(ipsec_gre_add_del_tunnel, \
22661 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22662 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22663 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22664 _(l2_interface_pbb_tag_rewrite, \
22665 "<intfc> | sw_if_index <nn> \n" \
22666 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22667 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22668 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22669 _(flow_classify_set_interface, \
22670 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22671 _(flow_classify_dump, "type [ip4|ip6]") \
22672 _(ip_fib_dump, "") \
22673 _(ip_mfib_dump, "") \
22674 _(ip6_fib_dump, "") \
22675 _(ip6_mfib_dump, "") \
22676 _(feature_enable_disable, "arc_name <arc_name> " \
22677 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22678 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22680 _(l2_xconnect_dump, "") \
22681 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22682 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22683 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22684 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22685 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22686 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22687 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22688 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22689 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22690 _(sock_init_shm, "size <nnn>") \
22691 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22692 _(dns_enable_disable, "[enable][disable]") \
22693 _(dns_name_server_add_del, "<ip-address> [del]") \
22694 _(dns_resolve_name, "<hostname>") \
22695 _(dns_resolve_ip, "<ip4|ip6>") \
22696 _(dns_name_server_add_del, "<ip-address> [del]") \
22697 _(dns_resolve_name, "<hostname>") \
22698 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22699 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22700 _(session_rules_dump, "") \
22701 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22702 _(output_acl_set_interface, \
22703 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22704 " [l2-table <nn>] [del]") \
22705 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22707 /* List of command functions, CLI names map directly to functions */
22708 #define foreach_cli_function \
22709 _(comment, "usage: comment <ignore-rest-of-line>") \
22710 _(dump_interface_table, "usage: dump_interface_table") \
22711 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22712 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22713 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22714 _(dump_macro_table, "usage: dump_macro_table ") \
22715 _(dump_node_table, "usage: dump_node_table") \
22716 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22717 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22718 _(echo, "usage: echo <message>") \
22719 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22720 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22721 _(help, "usage: help") \
22722 _(q, "usage: quit") \
22723 _(quit, "usage: quit") \
22724 _(search_node_table, "usage: search_node_table <name>...") \
22725 _(set, "usage: set <variable-name> <value>") \
22726 _(script, "usage: script <file-name>") \
22727 _(statseg, "usage: statseg"); \
22728 _(unset, "usage: unset <variable-name>")
22731 static void vl_api_##n##_t_handler_uni \
22732 (vl_api_##n##_t * mp) \
22734 vat_main_t * vam = &vat_main; \
22735 if (vam->json_output) { \
22736 vl_api_##n##_t_handler_json(mp); \
22738 vl_api_##n##_t_handler(mp); \
22741 foreach_vpe_api_reply_msg;
22742 #if VPP_API_TEST_BUILTIN == 0
22743 foreach_standalone_reply_msg;
22748 vat_api_hookup (vat_main_t * vam)
22751 vl_msg_api_set_handlers(VL_API_##N, #n, \
22752 vl_api_##n##_t_handler_uni, \
22754 vl_api_##n##_t_endian, \
22755 vl_api_##n##_t_print, \
22756 sizeof(vl_api_##n##_t), 1);
22757 foreach_vpe_api_reply_msg;
22758 #if VPP_API_TEST_BUILTIN == 0
22759 foreach_standalone_reply_msg;
22763 #if (VPP_API_TEST_BUILTIN==0)
22764 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22766 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22768 vam->function_by_name = hash_create_string (0, sizeof (uword));
22770 vam->help_by_name = hash_create_string (0, sizeof (uword));
22773 /* API messages we can send */
22774 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22775 foreach_vpe_api_msg;
22779 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22780 foreach_vpe_api_msg;
22783 /* CLI functions */
22784 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22785 foreach_cli_function;
22789 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22790 foreach_cli_function;
22794 #if VPP_API_TEST_BUILTIN
22795 static clib_error_t *
22796 vat_api_hookup_shim (vlib_main_t * vm)
22798 vat_api_hookup (&vat_main);
22802 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22806 * fd.io coding-style-patch-verification: ON
22809 * eval: (c-set-style "gnu")