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_vl_v4_address (vl_api_ip4_address_t * a)
724 clib_memcpy (a, &v, sizeof (v));
728 increment_vl_address (vl_api_address_t * a)
730 if (ADDRESS_IP4 == a->af)
731 increment_vl_v4_address (&a->un.ip4);
735 increment_v6_address (ip6_address_t * a)
739 v0 = clib_net_to_host_u64 (a->as_u64[0]);
740 v1 = clib_net_to_host_u64 (a->as_u64[1]);
745 a->as_u64[0] = clib_net_to_host_u64 (v0);
746 a->as_u64[1] = clib_net_to_host_u64 (v1);
750 increment_mac_address (u8 * mac)
752 u64 tmp = *((u64 *) mac);
753 tmp = clib_net_to_host_u64 (tmp);
754 tmp += 1 << 16; /* skip unused (least significant) octets */
755 tmp = clib_host_to_net_u64 (tmp);
757 clib_memcpy (mac, &tmp, 6);
760 static void vl_api_create_loopback_reply_t_handler
761 (vl_api_create_loopback_reply_t * mp)
763 vat_main_t *vam = &vat_main;
764 i32 retval = ntohl (mp->retval);
766 vam->retval = retval;
767 vam->regenerate_interface_table = 1;
768 vam->sw_if_index = ntohl (mp->sw_if_index);
769 vam->result_ready = 1;
772 static void vl_api_create_loopback_reply_t_handler_json
773 (vl_api_create_loopback_reply_t * mp)
775 vat_main_t *vam = &vat_main;
776 vat_json_node_t node;
778 vat_json_init_object (&node);
779 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
780 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
782 vat_json_print (vam->ofp, &node);
783 vat_json_free (&node);
784 vam->retval = ntohl (mp->retval);
785 vam->result_ready = 1;
788 static void vl_api_create_loopback_instance_reply_t_handler
789 (vl_api_create_loopback_instance_reply_t * mp)
791 vat_main_t *vam = &vat_main;
792 i32 retval = ntohl (mp->retval);
794 vam->retval = retval;
795 vam->regenerate_interface_table = 1;
796 vam->sw_if_index = ntohl (mp->sw_if_index);
797 vam->result_ready = 1;
800 static void vl_api_create_loopback_instance_reply_t_handler_json
801 (vl_api_create_loopback_instance_reply_t * mp)
803 vat_main_t *vam = &vat_main;
804 vat_json_node_t node;
806 vat_json_init_object (&node);
807 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
808 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
810 vat_json_print (vam->ofp, &node);
811 vat_json_free (&node);
812 vam->retval = ntohl (mp->retval);
813 vam->result_ready = 1;
816 static void vl_api_af_packet_create_reply_t_handler
817 (vl_api_af_packet_create_reply_t * mp)
819 vat_main_t *vam = &vat_main;
820 i32 retval = ntohl (mp->retval);
822 vam->retval = retval;
823 vam->regenerate_interface_table = 1;
824 vam->sw_if_index = ntohl (mp->sw_if_index);
825 vam->result_ready = 1;
828 static void vl_api_af_packet_create_reply_t_handler_json
829 (vl_api_af_packet_create_reply_t * mp)
831 vat_main_t *vam = &vat_main;
832 vat_json_node_t node;
834 vat_json_init_object (&node);
835 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
836 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
838 vat_json_print (vam->ofp, &node);
839 vat_json_free (&node);
841 vam->retval = ntohl (mp->retval);
842 vam->result_ready = 1;
845 static void vl_api_create_vlan_subif_reply_t_handler
846 (vl_api_create_vlan_subif_reply_t * mp)
848 vat_main_t *vam = &vat_main;
849 i32 retval = ntohl (mp->retval);
851 vam->retval = retval;
852 vam->regenerate_interface_table = 1;
853 vam->sw_if_index = ntohl (mp->sw_if_index);
854 vam->result_ready = 1;
857 static void vl_api_create_vlan_subif_reply_t_handler_json
858 (vl_api_create_vlan_subif_reply_t * mp)
860 vat_main_t *vam = &vat_main;
861 vat_json_node_t node;
863 vat_json_init_object (&node);
864 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
865 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
867 vat_json_print (vam->ofp, &node);
868 vat_json_free (&node);
870 vam->retval = ntohl (mp->retval);
871 vam->result_ready = 1;
874 static void vl_api_create_subif_reply_t_handler
875 (vl_api_create_subif_reply_t * mp)
877 vat_main_t *vam = &vat_main;
878 i32 retval = ntohl (mp->retval);
880 vam->retval = retval;
881 vam->regenerate_interface_table = 1;
882 vam->sw_if_index = ntohl (mp->sw_if_index);
883 vam->result_ready = 1;
886 static void vl_api_create_subif_reply_t_handler_json
887 (vl_api_create_subif_reply_t * mp)
889 vat_main_t *vam = &vat_main;
890 vat_json_node_t node;
892 vat_json_init_object (&node);
893 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
894 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
896 vat_json_print (vam->ofp, &node);
897 vat_json_free (&node);
899 vam->retval = ntohl (mp->retval);
900 vam->result_ready = 1;
903 static void vl_api_interface_name_renumber_reply_t_handler
904 (vl_api_interface_name_renumber_reply_t * mp)
906 vat_main_t *vam = &vat_main;
907 i32 retval = ntohl (mp->retval);
909 vam->retval = retval;
910 vam->regenerate_interface_table = 1;
911 vam->result_ready = 1;
914 static void vl_api_interface_name_renumber_reply_t_handler_json
915 (vl_api_interface_name_renumber_reply_t * mp)
917 vat_main_t *vam = &vat_main;
918 vat_json_node_t node;
920 vat_json_init_object (&node);
921 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
923 vat_json_print (vam->ofp, &node);
924 vat_json_free (&node);
926 vam->retval = ntohl (mp->retval);
927 vam->result_ready = 1;
931 * Special-case: build the interface table, maintain
932 * the next loopback sw_if_index vbl.
934 static void vl_api_sw_interface_details_t_handler
935 (vl_api_sw_interface_details_t * mp)
937 vat_main_t *vam = &vat_main;
938 u8 *s = format (0, "%s%c", mp->interface_name, 0);
940 hash_set_mem (vam->sw_if_index_by_interface_name, s,
941 ntohl (mp->sw_if_index));
943 /* In sub interface case, fill the sub interface table entry */
944 if (mp->sw_if_index != mp->sup_sw_if_index)
946 sw_interface_subif_t *sub = NULL;
948 vec_add2 (vam->sw_if_subif_table, sub, 1);
950 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
951 strncpy ((char *) sub->interface_name, (char *) s,
952 vec_len (sub->interface_name));
953 sub->sw_if_index = ntohl (mp->sw_if_index);
954 sub->sub_id = ntohl (mp->sub_id);
956 sub->sub_dot1ad = mp->sub_dot1ad;
957 sub->sub_number_of_tags = mp->sub_number_of_tags;
958 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
959 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
960 sub->sub_exact_match = mp->sub_exact_match;
961 sub->sub_default = mp->sub_default;
962 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
963 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
965 /* vlan tag rewrite */
966 sub->vtr_op = ntohl (mp->vtr_op);
967 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
968 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
969 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
973 static void vl_api_sw_interface_details_t_handler_json
974 (vl_api_sw_interface_details_t * mp)
976 vat_main_t *vam = &vat_main;
977 vat_json_node_t *node = NULL;
979 if (VAT_JSON_ARRAY != vam->json_tree.type)
981 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
982 vat_json_init_array (&vam->json_tree);
984 node = vat_json_array_add (&vam->json_tree);
986 vat_json_init_object (node);
987 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
988 vat_json_object_add_uint (node, "sup_sw_if_index",
989 ntohl (mp->sup_sw_if_index));
990 vat_json_object_add_uint (node, "l2_address_length",
991 ntohl (mp->l2_address_length));
992 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
993 sizeof (mp->l2_address));
994 vat_json_object_add_string_copy (node, "interface_name",
996 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
997 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
998 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
999 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
1000 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
1001 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
1002 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
1003 vat_json_object_add_uint (node, "sub_number_of_tags",
1004 mp->sub_number_of_tags);
1005 vat_json_object_add_uint (node, "sub_outer_vlan_id",
1006 ntohs (mp->sub_outer_vlan_id));
1007 vat_json_object_add_uint (node, "sub_inner_vlan_id",
1008 ntohs (mp->sub_inner_vlan_id));
1009 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
1010 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
1011 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
1012 mp->sub_outer_vlan_id_any);
1013 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
1014 mp->sub_inner_vlan_id_any);
1015 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
1016 vat_json_object_add_uint (node, "vtr_push_dot1q",
1017 ntohl (mp->vtr_push_dot1q));
1018 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
1019 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
1022 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
1024 format_ethernet_address,
1026 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
1028 format_ethernet_address,
1030 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
1031 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
1035 #if VPP_API_TEST_BUILTIN == 0
1036 static void vl_api_sw_interface_event_t_handler
1037 (vl_api_sw_interface_event_t * mp)
1039 vat_main_t *vam = &vat_main;
1040 if (vam->interface_event_display)
1041 errmsg ("interface flags: sw_if_index %d %s %s",
1042 ntohl (mp->sw_if_index),
1043 mp->admin_up_down ? "admin-up" : "admin-down",
1044 mp->link_up_down ? "link-up" : "link-down");
1048 static void vl_api_sw_interface_event_t_handler_json
1049 (vl_api_sw_interface_event_t * mp)
1051 /* JSON output not supported */
1055 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
1057 vat_main_t *vam = &vat_main;
1058 i32 retval = ntohl (mp->retval);
1060 vam->retval = retval;
1061 vam->shmem_result = uword_to_pointer (mp->reply_in_shmem, u8 *);
1062 vam->result_ready = 1;
1066 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1068 vat_main_t *vam = &vat_main;
1069 vat_json_node_t node;
1070 api_main_t *am = &api_main;
1074 vat_json_init_object (&node);
1075 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1076 vat_json_object_add_uint (&node, "reply_in_shmem",
1077 ntohl (mp->reply_in_shmem));
1078 /* Toss the shared-memory original... */
1079 pthread_mutex_lock (&am->vlib_rp->mutex);
1080 oldheap = svm_push_data_heap (am->vlib_rp);
1082 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
1085 svm_pop_heap (oldheap);
1086 pthread_mutex_unlock (&am->vlib_rp->mutex);
1088 vat_json_print (vam->ofp, &node);
1089 vat_json_free (&node);
1091 vam->retval = ntohl (mp->retval);
1092 vam->result_ready = 1;
1096 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1098 vat_main_t *vam = &vat_main;
1099 i32 retval = ntohl (mp->retval);
1100 u32 length = vl_api_string_len (&mp->reply);
1102 vec_reset_length (vam->cmd_reply);
1104 vam->retval = retval;
1107 vec_validate (vam->cmd_reply, length);
1108 clib_memcpy ((char *) (vam->cmd_reply),
1109 vl_api_from_api_string (&mp->reply), length);
1110 vam->cmd_reply[length] = 0;
1112 vam->result_ready = 1;
1116 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1118 vat_main_t *vam = &vat_main;
1119 vat_json_node_t node;
1121 vec_reset_length (vam->cmd_reply);
1123 vat_json_init_object (&node);
1124 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1125 vat_json_object_add_string_copy (&node, "reply",
1126 vl_api_from_api_string (&mp->reply));
1128 vat_json_print (vam->ofp, &node);
1129 vat_json_free (&node);
1131 vam->retval = ntohl (mp->retval);
1132 vam->result_ready = 1;
1135 static void vl_api_classify_add_del_table_reply_t_handler
1136 (vl_api_classify_add_del_table_reply_t * mp)
1138 vat_main_t *vam = &vat_main;
1139 i32 retval = ntohl (mp->retval);
1140 if (vam->async_mode)
1142 vam->async_errors += (retval < 0);
1146 vam->retval = retval;
1148 ((mp->new_table_index != 0xFFFFFFFF) ||
1149 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1150 (mp->match_n_vectors != 0xFFFFFFFF)))
1152 * Note: this is just barely thread-safe, depends on
1153 * the main thread spinning waiting for an answer...
1155 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1156 ntohl (mp->new_table_index),
1157 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1158 vam->result_ready = 1;
1162 static void vl_api_classify_add_del_table_reply_t_handler_json
1163 (vl_api_classify_add_del_table_reply_t * mp)
1165 vat_main_t *vam = &vat_main;
1166 vat_json_node_t node;
1168 vat_json_init_object (&node);
1169 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1170 vat_json_object_add_uint (&node, "new_table_index",
1171 ntohl (mp->new_table_index));
1172 vat_json_object_add_uint (&node, "skip_n_vectors",
1173 ntohl (mp->skip_n_vectors));
1174 vat_json_object_add_uint (&node, "match_n_vectors",
1175 ntohl (mp->match_n_vectors));
1177 vat_json_print (vam->ofp, &node);
1178 vat_json_free (&node);
1180 vam->retval = ntohl (mp->retval);
1181 vam->result_ready = 1;
1184 static void vl_api_get_node_index_reply_t_handler
1185 (vl_api_get_node_index_reply_t * mp)
1187 vat_main_t *vam = &vat_main;
1188 i32 retval = ntohl (mp->retval);
1189 if (vam->async_mode)
1191 vam->async_errors += (retval < 0);
1195 vam->retval = retval;
1197 errmsg ("node index %d", ntohl (mp->node_index));
1198 vam->result_ready = 1;
1202 static void vl_api_get_node_index_reply_t_handler_json
1203 (vl_api_get_node_index_reply_t * mp)
1205 vat_main_t *vam = &vat_main;
1206 vat_json_node_t node;
1208 vat_json_init_object (&node);
1209 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1210 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1212 vat_json_print (vam->ofp, &node);
1213 vat_json_free (&node);
1215 vam->retval = ntohl (mp->retval);
1216 vam->result_ready = 1;
1219 static void vl_api_get_next_index_reply_t_handler
1220 (vl_api_get_next_index_reply_t * mp)
1222 vat_main_t *vam = &vat_main;
1223 i32 retval = ntohl (mp->retval);
1224 if (vam->async_mode)
1226 vam->async_errors += (retval < 0);
1230 vam->retval = retval;
1232 errmsg ("next node index %d", ntohl (mp->next_index));
1233 vam->result_ready = 1;
1237 static void vl_api_get_next_index_reply_t_handler_json
1238 (vl_api_get_next_index_reply_t * mp)
1240 vat_main_t *vam = &vat_main;
1241 vat_json_node_t node;
1243 vat_json_init_object (&node);
1244 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1245 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1254 static void vl_api_add_node_next_reply_t_handler
1255 (vl_api_add_node_next_reply_t * mp)
1257 vat_main_t *vam = &vat_main;
1258 i32 retval = ntohl (mp->retval);
1259 if (vam->async_mode)
1261 vam->async_errors += (retval < 0);
1265 vam->retval = retval;
1267 errmsg ("next index %d", ntohl (mp->next_index));
1268 vam->result_ready = 1;
1272 static void vl_api_add_node_next_reply_t_handler_json
1273 (vl_api_add_node_next_reply_t * mp)
1275 vat_main_t *vam = &vat_main;
1276 vat_json_node_t node;
1278 vat_json_init_object (&node);
1279 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1280 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1282 vat_json_print (vam->ofp, &node);
1283 vat_json_free (&node);
1285 vam->retval = ntohl (mp->retval);
1286 vam->result_ready = 1;
1289 static void vl_api_show_version_reply_t_handler
1290 (vl_api_show_version_reply_t * mp)
1292 vat_main_t *vam = &vat_main;
1293 i32 retval = ntohl (mp->retval);
1298 char *p = (char *) &mp->program;
1300 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1301 errmsg (" program: %s\n", s);
1305 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1306 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1307 errmsg (" version: %s\n", s);
1311 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1312 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1313 errmsg (" build date: %s\n", s);
1317 vl_api_string_len ((vl_api_string_t *) p) + sizeof (vl_api_string_t);
1318 s = vl_api_from_api_string_c ((vl_api_string_t *) p);
1319 errmsg ("build directory: %s\n", s);
1322 vam->retval = retval;
1323 vam->result_ready = 1;
1326 static void vl_api_show_version_reply_t_handler_json
1327 (vl_api_show_version_reply_t * mp)
1329 vat_main_t *vam = &vat_main;
1330 vat_json_node_t node;
1332 vat_json_init_object (&node);
1333 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1334 char *p = (char *) &mp->program;
1335 vat_json_object_add_string_copy (&node, "program",
1336 vl_api_from_api_string ((vl_api_string_t *)
1338 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1339 vat_json_object_add_string_copy (&node, "version",
1340 vl_api_from_api_string ((vl_api_string_t *)
1342 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1343 vat_json_object_add_string_copy (&node, "build_date",
1344 vl_api_from_api_string ((vl_api_string_t *)
1346 p += vl_api_string_len ((vl_api_string_t *) p) + sizeof (u32);
1347 vat_json_object_add_string_copy (&node, "build_directory",
1348 vl_api_from_api_string ((vl_api_string_t *)
1351 vat_json_print (vam->ofp, &node);
1352 vat_json_free (&node);
1354 vam->retval = ntohl (mp->retval);
1355 vam->result_ready = 1;
1358 static void vl_api_show_threads_reply_t_handler
1359 (vl_api_show_threads_reply_t * mp)
1361 vat_main_t *vam = &vat_main;
1362 i32 retval = ntohl (mp->retval);
1366 count = ntohl (mp->count);
1368 for (i = 0; i < count; i++)
1370 "\n%-2d %-11s %-11s %-5d %-6d %-4d %-6d",
1371 ntohl (mp->thread_data[i].id), mp->thread_data[i].name,
1372 mp->thread_data[i].type, ntohl (mp->thread_data[i].pid),
1373 ntohl (mp->thread_data[i].cpu_id), ntohl (mp->thread_data[i].core),
1374 ntohl (mp->thread_data[i].cpu_socket));
1376 vam->retval = retval;
1377 vam->result_ready = 1;
1380 static void vl_api_show_threads_reply_t_handler_json
1381 (vl_api_show_threads_reply_t * mp)
1383 vat_main_t *vam = &vat_main;
1384 vat_json_node_t node;
1385 vl_api_thread_data_t *td;
1386 i32 retval = ntohl (mp->retval);
1390 count = ntohl (mp->count);
1392 vat_json_init_object (&node);
1393 vat_json_object_add_int (&node, "retval", retval);
1394 vat_json_object_add_uint (&node, "count", count);
1396 for (i = 0; i < count; i++)
1398 td = &mp->thread_data[i];
1399 vat_json_object_add_uint (&node, "id", ntohl (td->id));
1400 vat_json_object_add_string_copy (&node, "name", td->name);
1401 vat_json_object_add_string_copy (&node, "type", td->type);
1402 vat_json_object_add_uint (&node, "pid", ntohl (td->pid));
1403 vat_json_object_add_int (&node, "cpu_id", ntohl (td->cpu_id));
1404 vat_json_object_add_int (&node, "core", ntohl (td->id));
1405 vat_json_object_add_int (&node, "cpu_socket", ntohl (td->cpu_socket));
1408 vat_json_print (vam->ofp, &node);
1409 vat_json_free (&node);
1411 vam->retval = retval;
1412 vam->result_ready = 1;
1416 api_show_threads (vat_main_t * vam)
1418 vl_api_show_threads_t *mp;
1422 "\n%-2s %-11s %-11s %-5s %-6s %-4s %-6s",
1423 "ID", "Name", "Type", "LWP", "cpu_id", "Core", "Socket");
1425 M (SHOW_THREADS, mp);
1433 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1435 u32 sw_if_index = ntohl (mp->sw_if_index);
1436 errmsg ("arp %s event: pid %d address %U new mac %U sw_if_index %d\n",
1437 mp->mac_ip ? "mac/ip binding" : "address resolution",
1438 ntohl (mp->pid), format_ip4_address, mp->ip,
1439 format_vl_api_mac_address, &mp->mac, sw_if_index);
1443 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1445 /* JSON output not supported */
1449 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1451 u32 sw_if_index = ntohl (mp->sw_if_index);
1452 errmsg ("ip6 nd %s event: pid %d address %U new mac %U sw_if_index %d\n",
1453 mp->mac_ip ? "mac/ip binding" : "address resolution",
1454 ntohl (mp->pid), format_vl_api_ip6_address, mp->ip,
1455 format_vl_api_mac_address, mp->mac, sw_if_index);
1459 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1461 /* JSON output not supported */
1465 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1467 u32 n_macs = ntohl (mp->n_macs);
1468 errmsg ("L2MAC event received with pid %d cl-idx %d for %d macs: \n",
1469 ntohl (mp->pid), mp->client_index, n_macs);
1471 for (i = 0; i < n_macs; i++)
1473 vl_api_mac_entry_t *mac = &mp->mac[i];
1474 errmsg (" [%d] sw_if_index %d mac_addr %U action %d \n",
1475 i + 1, ntohl (mac->sw_if_index),
1476 format_ethernet_address, mac->mac_addr, mac->action);
1483 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1485 /* JSON output not supported */
1488 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1489 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1492 * Special-case: build the bridge domain table, maintain
1493 * the next bd id vbl.
1495 static void vl_api_bridge_domain_details_t_handler
1496 (vl_api_bridge_domain_details_t * mp)
1498 vat_main_t *vam = &vat_main;
1499 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1502 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-6s %-3s",
1503 " ID", "LRN", "FWD", "FLD", "BVI", "UU-FWD", "#IF");
1505 print (vam->ofp, "%3d %3d %3d %3d %3d %6d %3d",
1506 ntohl (mp->bd_id), mp->learn, mp->forward,
1507 mp->flood, ntohl (mp->bvi_sw_if_index),
1508 ntohl (mp->uu_fwd_sw_if_index), n_sw_ifs);
1512 vl_api_bridge_domain_sw_if_t *sw_ifs;
1513 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1516 sw_ifs = mp->sw_if_details;
1517 for (i = 0; i < n_sw_ifs; i++)
1523 sw_if_index = ntohl (sw_ifs->sw_if_index);
1526 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1528 if ((u32) p->value[0] == sw_if_index)
1530 sw_if_name = (u8 *)(p->key);
1535 print (vam->ofp, "%7d %3d %s", sw_if_index,
1536 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1537 "sw_if_index not found!");
1544 static void vl_api_bridge_domain_details_t_handler_json
1545 (vl_api_bridge_domain_details_t * mp)
1547 vat_main_t *vam = &vat_main;
1548 vat_json_node_t *node, *array = NULL;
1549 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1551 if (VAT_JSON_ARRAY != vam->json_tree.type)
1553 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1554 vat_json_init_array (&vam->json_tree);
1556 node = vat_json_array_add (&vam->json_tree);
1558 vat_json_init_object (node);
1559 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1560 vat_json_object_add_uint (node, "flood", mp->flood);
1561 vat_json_object_add_uint (node, "forward", mp->forward);
1562 vat_json_object_add_uint (node, "learn", mp->learn);
1563 vat_json_object_add_uint (node, "bvi_sw_if_index",
1564 ntohl (mp->bvi_sw_if_index));
1565 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1566 array = vat_json_object_add (node, "sw_if");
1567 vat_json_init_array (array);
1573 vl_api_bridge_domain_sw_if_t *sw_ifs;
1576 sw_ifs = mp->sw_if_details;
1577 for (i = 0; i < n_sw_ifs; i++)
1579 node = vat_json_array_add (array);
1580 vat_json_init_object (node);
1581 vat_json_object_add_uint (node, "sw_if_index",
1582 ntohl (sw_ifs->sw_if_index));
1583 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1589 static void vl_api_control_ping_reply_t_handler
1590 (vl_api_control_ping_reply_t * mp)
1592 vat_main_t *vam = &vat_main;
1593 i32 retval = ntohl (mp->retval);
1594 if (vam->async_mode)
1596 vam->async_errors += (retval < 0);
1600 vam->retval = retval;
1601 vam->result_ready = 1;
1603 if (vam->socket_client_main)
1604 vam->socket_client_main->control_pings_outstanding--;
1607 static void vl_api_control_ping_reply_t_handler_json
1608 (vl_api_control_ping_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 i32 retval = ntohl (mp->retval);
1613 if (VAT_JSON_NONE != vam->json_tree.type)
1615 vat_json_print (vam->ofp, &vam->json_tree);
1616 vat_json_free (&vam->json_tree);
1617 vam->json_tree.type = VAT_JSON_NONE;
1622 vat_json_init_array (&vam->json_tree);
1623 vat_json_print (vam->ofp, &vam->json_tree);
1624 vam->json_tree.type = VAT_JSON_NONE;
1627 vam->retval = retval;
1628 vam->result_ready = 1;
1632 vl_api_bridge_domain_set_mac_age_reply_t_handler
1633 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1635 vat_main_t *vam = &vat_main;
1636 i32 retval = ntohl (mp->retval);
1637 if (vam->async_mode)
1639 vam->async_errors += (retval < 0);
1643 vam->retval = retval;
1644 vam->result_ready = 1;
1648 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1649 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1651 vat_main_t *vam = &vat_main;
1652 vat_json_node_t node;
1654 vat_json_init_object (&node);
1655 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1657 vat_json_print (vam->ofp, &node);
1658 vat_json_free (&node);
1660 vam->retval = ntohl (mp->retval);
1661 vam->result_ready = 1;
1665 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1667 vat_main_t *vam = &vat_main;
1668 i32 retval = ntohl (mp->retval);
1669 if (vam->async_mode)
1671 vam->async_errors += (retval < 0);
1675 vam->retval = retval;
1676 vam->result_ready = 1;
1680 static void vl_api_l2_flags_reply_t_handler_json
1681 (vl_api_l2_flags_reply_t * mp)
1683 vat_main_t *vam = &vat_main;
1684 vat_json_node_t node;
1686 vat_json_init_object (&node);
1687 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1688 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1689 ntohl (mp->resulting_feature_bitmap));
1691 vat_json_print (vam->ofp, &node);
1692 vat_json_free (&node);
1694 vam->retval = ntohl (mp->retval);
1695 vam->result_ready = 1;
1698 static void vl_api_bridge_flags_reply_t_handler
1699 (vl_api_bridge_flags_reply_t * mp)
1701 vat_main_t *vam = &vat_main;
1702 i32 retval = ntohl (mp->retval);
1703 if (vam->async_mode)
1705 vam->async_errors += (retval < 0);
1709 vam->retval = retval;
1710 vam->result_ready = 1;
1714 static void vl_api_bridge_flags_reply_t_handler_json
1715 (vl_api_bridge_flags_reply_t * mp)
1717 vat_main_t *vam = &vat_main;
1718 vat_json_node_t node;
1720 vat_json_init_object (&node);
1721 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1722 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1723 ntohl (mp->resulting_feature_bitmap));
1725 vat_json_print (vam->ofp, &node);
1726 vat_json_free (&node);
1728 vam->retval = ntohl (mp->retval);
1729 vam->result_ready = 1;
1733 vl_api_tap_create_v2_reply_t_handler (vl_api_tap_create_v2_reply_t * mp)
1735 vat_main_t *vam = &vat_main;
1736 i32 retval = ntohl (mp->retval);
1737 if (vam->async_mode)
1739 vam->async_errors += (retval < 0);
1743 vam->retval = retval;
1744 vam->sw_if_index = ntohl (mp->sw_if_index);
1745 vam->result_ready = 1;
1750 static void vl_api_tap_create_v2_reply_t_handler_json
1751 (vl_api_tap_create_v2_reply_t * mp)
1753 vat_main_t *vam = &vat_main;
1754 vat_json_node_t node;
1756 vat_json_init_object (&node);
1757 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1758 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1760 vat_json_print (vam->ofp, &node);
1761 vat_json_free (&node);
1763 vam->retval = ntohl (mp->retval);
1764 vam->result_ready = 1;
1769 vl_api_tap_delete_v2_reply_t_handler (vl_api_tap_delete_v2_reply_t * mp)
1771 vat_main_t *vam = &vat_main;
1772 i32 retval = ntohl (mp->retval);
1773 if (vam->async_mode)
1775 vam->async_errors += (retval < 0);
1779 vam->retval = retval;
1780 vam->result_ready = 1;
1784 static void vl_api_tap_delete_v2_reply_t_handler_json
1785 (vl_api_tap_delete_v2_reply_t * mp)
1787 vat_main_t *vam = &vat_main;
1788 vat_json_node_t node;
1790 vat_json_init_object (&node);
1791 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1793 vat_json_print (vam->ofp, &node);
1794 vat_json_free (&node);
1796 vam->retval = ntohl (mp->retval);
1797 vam->result_ready = 1;
1801 vl_api_virtio_pci_create_reply_t_handler (vl_api_virtio_pci_create_reply_t *
1804 vat_main_t *vam = &vat_main;
1805 i32 retval = ntohl (mp->retval);
1806 if (vam->async_mode)
1808 vam->async_errors += (retval < 0);
1812 vam->retval = retval;
1813 vam->sw_if_index = ntohl (mp->sw_if_index);
1814 vam->result_ready = 1;
1818 static void vl_api_virtio_pci_create_reply_t_handler_json
1819 (vl_api_virtio_pci_create_reply_t * mp)
1821 vat_main_t *vam = &vat_main;
1822 vat_json_node_t node;
1824 vat_json_init_object (&node);
1825 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1826 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1828 vat_json_print (vam->ofp, &node);
1829 vat_json_free (&node);
1831 vam->retval = ntohl (mp->retval);
1832 vam->result_ready = 1;
1837 vl_api_virtio_pci_delete_reply_t_handler (vl_api_virtio_pci_delete_reply_t *
1840 vat_main_t *vam = &vat_main;
1841 i32 retval = ntohl (mp->retval);
1842 if (vam->async_mode)
1844 vam->async_errors += (retval < 0);
1848 vam->retval = retval;
1849 vam->result_ready = 1;
1853 static void vl_api_virtio_pci_delete_reply_t_handler_json
1854 (vl_api_virtio_pci_delete_reply_t * mp)
1856 vat_main_t *vam = &vat_main;
1857 vat_json_node_t node;
1859 vat_json_init_object (&node);
1860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1862 vat_json_print (vam->ofp, &node);
1863 vat_json_free (&node);
1865 vam->retval = ntohl (mp->retval);
1866 vam->result_ready = 1;
1870 vl_api_bond_create_reply_t_handler (vl_api_bond_create_reply_t * mp)
1872 vat_main_t *vam = &vat_main;
1873 i32 retval = ntohl (mp->retval);
1875 if (vam->async_mode)
1877 vam->async_errors += (retval < 0);
1881 vam->retval = retval;
1882 vam->sw_if_index = ntohl (mp->sw_if_index);
1883 vam->result_ready = 1;
1887 static void vl_api_bond_create_reply_t_handler_json
1888 (vl_api_bond_create_reply_t * mp)
1890 vat_main_t *vam = &vat_main;
1891 vat_json_node_t node;
1893 vat_json_init_object (&node);
1894 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1895 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1897 vat_json_print (vam->ofp, &node);
1898 vat_json_free (&node);
1900 vam->retval = ntohl (mp->retval);
1901 vam->result_ready = 1;
1905 vl_api_bond_delete_reply_t_handler (vl_api_bond_delete_reply_t * mp)
1907 vat_main_t *vam = &vat_main;
1908 i32 retval = ntohl (mp->retval);
1910 if (vam->async_mode)
1912 vam->async_errors += (retval < 0);
1916 vam->retval = retval;
1917 vam->result_ready = 1;
1921 static void vl_api_bond_delete_reply_t_handler_json
1922 (vl_api_bond_delete_reply_t * mp)
1924 vat_main_t *vam = &vat_main;
1925 vat_json_node_t node;
1927 vat_json_init_object (&node);
1928 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1930 vat_json_print (vam->ofp, &node);
1931 vat_json_free (&node);
1933 vam->retval = ntohl (mp->retval);
1934 vam->result_ready = 1;
1938 vl_api_bond_enslave_reply_t_handler (vl_api_bond_enslave_reply_t * mp)
1940 vat_main_t *vam = &vat_main;
1941 i32 retval = ntohl (mp->retval);
1943 if (vam->async_mode)
1945 vam->async_errors += (retval < 0);
1949 vam->retval = retval;
1950 vam->result_ready = 1;
1954 static void vl_api_bond_enslave_reply_t_handler_json
1955 (vl_api_bond_enslave_reply_t * mp)
1957 vat_main_t *vam = &vat_main;
1958 vat_json_node_t node;
1960 vat_json_init_object (&node);
1961 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1963 vat_json_print (vam->ofp, &node);
1964 vat_json_free (&node);
1966 vam->retval = ntohl (mp->retval);
1967 vam->result_ready = 1;
1971 vl_api_bond_detach_slave_reply_t_handler (vl_api_bond_detach_slave_reply_t *
1974 vat_main_t *vam = &vat_main;
1975 i32 retval = ntohl (mp->retval);
1977 if (vam->async_mode)
1979 vam->async_errors += (retval < 0);
1983 vam->retval = retval;
1984 vam->result_ready = 1;
1988 static void vl_api_bond_detach_slave_reply_t_handler_json
1989 (vl_api_bond_detach_slave_reply_t * mp)
1991 vat_main_t *vam = &vat_main;
1992 vat_json_node_t node;
1994 vat_json_init_object (&node);
1995 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1997 vat_json_print (vam->ofp, &node);
1998 vat_json_free (&node);
2000 vam->retval = ntohl (mp->retval);
2001 vam->result_ready = 1;
2004 static void vl_api_sw_interface_bond_details_t_handler
2005 (vl_api_sw_interface_bond_details_t * mp)
2007 vat_main_t *vam = &vat_main;
2010 "%-16s %-12d %-12U %-13U %-14u %-14u",
2011 mp->interface_name, ntohl (mp->sw_if_index),
2012 format_bond_mode, mp->mode, format_bond_load_balance, mp->lb,
2013 ntohl (mp->active_slaves), ntohl (mp->slaves));
2016 static void vl_api_sw_interface_bond_details_t_handler_json
2017 (vl_api_sw_interface_bond_details_t * mp)
2019 vat_main_t *vam = &vat_main;
2020 vat_json_node_t *node = NULL;
2022 if (VAT_JSON_ARRAY != vam->json_tree.type)
2024 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2025 vat_json_init_array (&vam->json_tree);
2027 node = vat_json_array_add (&vam->json_tree);
2029 vat_json_init_object (node);
2030 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2031 vat_json_object_add_string_copy (node, "interface_name",
2032 mp->interface_name);
2033 vat_json_object_add_uint (node, "mode", mp->mode);
2034 vat_json_object_add_uint (node, "load_balance", mp->lb);
2035 vat_json_object_add_uint (node, "active_slaves", ntohl (mp->active_slaves));
2036 vat_json_object_add_uint (node, "slaves", ntohl (mp->slaves));
2040 api_sw_interface_bond_dump (vat_main_t * vam)
2042 vl_api_sw_interface_bond_dump_t *mp;
2043 vl_api_control_ping_t *mp_ping;
2047 "\n%-16s %-12s %-12s %-13s %-14s %-14s",
2048 "interface name", "sw_if_index", "mode", "load balance",
2049 "active slaves", "slaves");
2051 /* Get list of bond interfaces */
2052 M (SW_INTERFACE_BOND_DUMP, mp);
2055 /* Use a control ping for synchronization */
2056 MPING (CONTROL_PING, mp_ping);
2063 static void vl_api_sw_interface_slave_details_t_handler
2064 (vl_api_sw_interface_slave_details_t * mp)
2066 vat_main_t *vam = &vat_main;
2069 "%-25s %-12d %-12d %d", mp->interface_name,
2070 ntohl (mp->sw_if_index), mp->is_passive, mp->is_long_timeout);
2073 static void vl_api_sw_interface_slave_details_t_handler_json
2074 (vl_api_sw_interface_slave_details_t * mp)
2076 vat_main_t *vam = &vat_main;
2077 vat_json_node_t *node = NULL;
2079 if (VAT_JSON_ARRAY != vam->json_tree.type)
2081 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2082 vat_json_init_array (&vam->json_tree);
2084 node = vat_json_array_add (&vam->json_tree);
2086 vat_json_init_object (node);
2087 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
2088 vat_json_object_add_string_copy (node, "interface_name",
2089 mp->interface_name);
2090 vat_json_object_add_uint (node, "passive", mp->is_passive);
2091 vat_json_object_add_uint (node, "long_timeout", mp->is_long_timeout);
2095 api_sw_interface_slave_dump (vat_main_t * vam)
2097 unformat_input_t *i = vam->input;
2098 vl_api_sw_interface_slave_dump_t *mp;
2099 vl_api_control_ping_t *mp_ping;
2100 u32 sw_if_index = ~0;
2101 u8 sw_if_index_set = 0;
2104 /* Parse args required to build the message */
2105 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
2107 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
2108 sw_if_index_set = 1;
2109 else if (unformat (i, "sw_if_index %d", &sw_if_index))
2110 sw_if_index_set = 1;
2115 if (sw_if_index_set == 0)
2117 errmsg ("missing vpp interface name. ");
2122 "\n%-25s %-12s %-12s %s",
2123 "slave interface name", "sw_if_index", "passive", "long_timeout");
2125 /* Get list of bond interfaces */
2126 M (SW_INTERFACE_SLAVE_DUMP, mp);
2127 mp->sw_if_index = ntohl (sw_if_index);
2130 /* Use a control ping for synchronization */
2131 MPING (CONTROL_PING, mp_ping);
2138 static void vl_api_mpls_tunnel_add_del_reply_t_handler
2139 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2141 vat_main_t *vam = &vat_main;
2142 i32 retval = ntohl (mp->retval);
2143 if (vam->async_mode)
2145 vam->async_errors += (retval < 0);
2149 vam->retval = retval;
2150 vam->sw_if_index = ntohl (mp->sw_if_index);
2151 vam->result_ready = 1;
2153 vam->regenerate_interface_table = 1;
2156 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
2157 (vl_api_mpls_tunnel_add_del_reply_t * mp)
2159 vat_main_t *vam = &vat_main;
2160 vat_json_node_t node;
2162 vat_json_init_object (&node);
2163 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2164 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
2165 ntohl (mp->sw_if_index));
2167 vat_json_print (vam->ofp, &node);
2168 vat_json_free (&node);
2170 vam->retval = ntohl (mp->retval);
2171 vam->result_ready = 1;
2174 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
2175 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2177 vat_main_t *vam = &vat_main;
2178 i32 retval = ntohl (mp->retval);
2179 if (vam->async_mode)
2181 vam->async_errors += (retval < 0);
2185 vam->retval = retval;
2186 vam->sw_if_index = ntohl (mp->sw_if_index);
2187 vam->result_ready = 1;
2191 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
2192 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
2194 vat_main_t *vam = &vat_main;
2195 vat_json_node_t node;
2197 vat_json_init_object (&node);
2198 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2199 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2201 vat_json_print (vam->ofp, &node);
2202 vat_json_free (&node);
2204 vam->retval = ntohl (mp->retval);
2205 vam->result_ready = 1;
2208 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
2209 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2211 vat_main_t *vam = &vat_main;
2212 i32 retval = ntohl (mp->retval);
2213 if (vam->async_mode)
2215 vam->async_errors += (retval < 0);
2219 vam->retval = retval;
2220 vam->result_ready = 1;
2224 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
2225 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
2227 vat_main_t *vam = &vat_main;
2228 vat_json_node_t node;
2230 vat_json_init_object (&node);
2231 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2232 vat_json_object_add_uint (&node, "fwd_entry_index",
2233 clib_net_to_host_u32 (mp->fwd_entry_index));
2235 vat_json_print (vam->ofp, &node);
2236 vat_json_free (&node);
2238 vam->retval = ntohl (mp->retval);
2239 vam->result_ready = 1;
2243 format_lisp_transport_protocol (u8 * s, va_list * args)
2245 u32 proto = va_arg (*args, u32);
2250 return format (s, "udp");
2252 return format (s, "api");
2259 static void vl_api_one_get_transport_protocol_reply_t_handler
2260 (vl_api_one_get_transport_protocol_reply_t * mp)
2262 vat_main_t *vam = &vat_main;
2263 i32 retval = ntohl (mp->retval);
2264 if (vam->async_mode)
2266 vam->async_errors += (retval < 0);
2270 u32 proto = mp->protocol;
2271 print (vam->ofp, "Transport protocol: %U",
2272 format_lisp_transport_protocol, proto);
2273 vam->retval = retval;
2274 vam->result_ready = 1;
2278 static void vl_api_one_get_transport_protocol_reply_t_handler_json
2279 (vl_api_one_get_transport_protocol_reply_t * mp)
2281 vat_main_t *vam = &vat_main;
2282 vat_json_node_t node;
2285 s = format (0, "%U", format_lisp_transport_protocol, mp->protocol);
2288 vat_json_init_object (&node);
2289 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2290 vat_json_object_add_string_copy (&node, "transport-protocol", s);
2293 vat_json_print (vam->ofp, &node);
2294 vat_json_free (&node);
2296 vam->retval = ntohl (mp->retval);
2297 vam->result_ready = 1;
2300 static void vl_api_one_add_del_locator_set_reply_t_handler
2301 (vl_api_one_add_del_locator_set_reply_t * mp)
2303 vat_main_t *vam = &vat_main;
2304 i32 retval = ntohl (mp->retval);
2305 if (vam->async_mode)
2307 vam->async_errors += (retval < 0);
2311 vam->retval = retval;
2312 vam->result_ready = 1;
2316 static void vl_api_one_add_del_locator_set_reply_t_handler_json
2317 (vl_api_one_add_del_locator_set_reply_t * mp)
2319 vat_main_t *vam = &vat_main;
2320 vat_json_node_t node;
2322 vat_json_init_object (&node);
2323 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2324 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
2326 vat_json_print (vam->ofp, &node);
2327 vat_json_free (&node);
2329 vam->retval = ntohl (mp->retval);
2330 vam->result_ready = 1;
2333 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
2334 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2336 vat_main_t *vam = &vat_main;
2337 i32 retval = ntohl (mp->retval);
2338 if (vam->async_mode)
2340 vam->async_errors += (retval < 0);
2344 vam->retval = retval;
2345 vam->sw_if_index = ntohl (mp->sw_if_index);
2346 vam->result_ready = 1;
2348 vam->regenerate_interface_table = 1;
2351 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
2352 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
2354 vat_main_t *vam = &vat_main;
2355 vat_json_node_t node;
2357 vat_json_init_object (&node);
2358 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2359 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2361 vat_json_print (vam->ofp, &node);
2362 vat_json_free (&node);
2364 vam->retval = ntohl (mp->retval);
2365 vam->result_ready = 1;
2368 static void vl_api_vxlan_offload_rx_reply_t_handler
2369 (vl_api_vxlan_offload_rx_reply_t * mp)
2371 vat_main_t *vam = &vat_main;
2372 i32 retval = ntohl (mp->retval);
2373 if (vam->async_mode)
2375 vam->async_errors += (retval < 0);
2379 vam->retval = retval;
2380 vam->result_ready = 1;
2384 static void vl_api_vxlan_offload_rx_reply_t_handler_json
2385 (vl_api_vxlan_offload_rx_reply_t * mp)
2387 vat_main_t *vam = &vat_main;
2388 vat_json_node_t node;
2390 vat_json_init_object (&node);
2391 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2393 vat_json_print (vam->ofp, &node);
2394 vat_json_free (&node);
2396 vam->retval = ntohl (mp->retval);
2397 vam->result_ready = 1;
2400 static void vl_api_geneve_add_del_tunnel_reply_t_handler
2401 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2403 vat_main_t *vam = &vat_main;
2404 i32 retval = ntohl (mp->retval);
2405 if (vam->async_mode)
2407 vam->async_errors += (retval < 0);
2411 vam->retval = retval;
2412 vam->sw_if_index = ntohl (mp->sw_if_index);
2413 vam->result_ready = 1;
2417 static void vl_api_geneve_add_del_tunnel_reply_t_handler_json
2418 (vl_api_geneve_add_del_tunnel_reply_t * mp)
2420 vat_main_t *vam = &vat_main;
2421 vat_json_node_t node;
2423 vat_json_init_object (&node);
2424 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2425 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2427 vat_json_print (vam->ofp, &node);
2428 vat_json_free (&node);
2430 vam->retval = ntohl (mp->retval);
2431 vam->result_ready = 1;
2434 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
2435 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2437 vat_main_t *vam = &vat_main;
2438 i32 retval = ntohl (mp->retval);
2439 if (vam->async_mode)
2441 vam->async_errors += (retval < 0);
2445 vam->retval = retval;
2446 vam->sw_if_index = ntohl (mp->sw_if_index);
2447 vam->result_ready = 1;
2449 vam->regenerate_interface_table = 1;
2452 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
2453 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
2455 vat_main_t *vam = &vat_main;
2456 vat_json_node_t node;
2458 vat_json_init_object (&node);
2459 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2460 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2462 vat_json_print (vam->ofp, &node);
2463 vat_json_free (&node);
2465 vam->retval = ntohl (mp->retval);
2466 vam->result_ready = 1;
2469 static void vl_api_gre_tunnel_add_del_reply_t_handler
2470 (vl_api_gre_tunnel_add_del_reply_t * mp)
2472 vat_main_t *vam = &vat_main;
2473 i32 retval = ntohl (mp->retval);
2474 if (vam->async_mode)
2476 vam->async_errors += (retval < 0);
2480 vam->retval = retval;
2481 vam->sw_if_index = ntohl (mp->sw_if_index);
2482 vam->result_ready = 1;
2486 static void vl_api_gre_tunnel_add_del_reply_t_handler_json
2487 (vl_api_gre_tunnel_add_del_reply_t * mp)
2489 vat_main_t *vam = &vat_main;
2490 vat_json_node_t node;
2492 vat_json_init_object (&node);
2493 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2494 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2496 vat_json_print (vam->ofp, &node);
2497 vat_json_free (&node);
2499 vam->retval = ntohl (mp->retval);
2500 vam->result_ready = 1;
2503 static void vl_api_create_vhost_user_if_reply_t_handler
2504 (vl_api_create_vhost_user_if_reply_t * mp)
2506 vat_main_t *vam = &vat_main;
2507 i32 retval = ntohl (mp->retval);
2508 if (vam->async_mode)
2510 vam->async_errors += (retval < 0);
2514 vam->retval = retval;
2515 vam->sw_if_index = ntohl (mp->sw_if_index);
2516 vam->result_ready = 1;
2518 vam->regenerate_interface_table = 1;
2521 static void vl_api_create_vhost_user_if_reply_t_handler_json
2522 (vl_api_create_vhost_user_if_reply_t * mp)
2524 vat_main_t *vam = &vat_main;
2525 vat_json_node_t node;
2527 vat_json_init_object (&node);
2528 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2529 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
2531 vat_json_print (vam->ofp, &node);
2532 vat_json_free (&node);
2534 vam->retval = ntohl (mp->retval);
2535 vam->result_ready = 1;
2538 static void vl_api_dns_resolve_name_reply_t_handler
2539 (vl_api_dns_resolve_name_reply_t * mp)
2541 vat_main_t *vam = &vat_main;
2542 i32 retval = ntohl (mp->retval);
2543 if (vam->async_mode)
2545 vam->async_errors += (retval < 0);
2549 vam->retval = retval;
2550 vam->result_ready = 1;
2555 clib_warning ("ip4 address %U", format_ip4_address,
2556 (ip4_address_t *) mp->ip4_address);
2558 clib_warning ("ip6 address %U", format_ip6_address,
2559 (ip6_address_t *) mp->ip6_address);
2562 clib_warning ("retval %d", retval);
2566 static void vl_api_dns_resolve_name_reply_t_handler_json
2567 (vl_api_dns_resolve_name_reply_t * mp)
2569 clib_warning ("not implemented");
2572 static void vl_api_dns_resolve_ip_reply_t_handler
2573 (vl_api_dns_resolve_ip_reply_t * mp)
2575 vat_main_t *vam = &vat_main;
2576 i32 retval = ntohl (mp->retval);
2577 if (vam->async_mode)
2579 vam->async_errors += (retval < 0);
2583 vam->retval = retval;
2584 vam->result_ready = 1;
2588 clib_warning ("canonical name %s", mp->name);
2591 clib_warning ("retval %d", retval);
2595 static void vl_api_dns_resolve_ip_reply_t_handler_json
2596 (vl_api_dns_resolve_ip_reply_t * mp)
2598 clib_warning ("not implemented");
2602 static void vl_api_ip_address_details_t_handler
2603 (vl_api_ip_address_details_t * mp)
2605 vat_main_t *vam = &vat_main;
2606 static ip_address_details_t empty_ip_address_details = { {0} };
2607 ip_address_details_t *address = NULL;
2608 ip_details_t *current_ip_details = NULL;
2609 ip_details_t *details = NULL;
2611 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
2613 if (!details || vam->current_sw_if_index >= vec_len (details)
2614 || !details[vam->current_sw_if_index].present)
2616 errmsg ("ip address details arrived but not stored");
2617 errmsg ("ip_dump should be called first");
2621 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
2623 #define addresses (current_ip_details->addr)
2625 vec_validate_init_empty (addresses, vec_len (addresses),
2626 empty_ip_address_details);
2628 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
2630 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
2631 address->prefix_length = mp->prefix_length;
2635 static void vl_api_ip_address_details_t_handler_json
2636 (vl_api_ip_address_details_t * mp)
2638 vat_main_t *vam = &vat_main;
2639 vat_json_node_t *node = NULL;
2640 struct in6_addr ip6;
2643 if (VAT_JSON_ARRAY != vam->json_tree.type)
2645 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2646 vat_json_init_array (&vam->json_tree);
2648 node = vat_json_array_add (&vam->json_tree);
2650 vat_json_init_object (node);
2653 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
2654 vat_json_object_add_ip6 (node, "ip", ip6);
2658 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
2659 vat_json_object_add_ip4 (node, "ip", ip4);
2661 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
2665 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
2667 vat_main_t *vam = &vat_main;
2668 static ip_details_t empty_ip_details = { 0 };
2669 ip_details_t *ip = NULL;
2670 u32 sw_if_index = ~0;
2672 sw_if_index = ntohl (mp->sw_if_index);
2674 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2675 sw_if_index, empty_ip_details);
2677 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2684 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2686 vat_main_t *vam = &vat_main;
2688 if (VAT_JSON_ARRAY != vam->json_tree.type)
2690 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2691 vat_json_init_array (&vam->json_tree);
2693 vat_json_array_add_uint (&vam->json_tree,
2694 clib_net_to_host_u32 (mp->sw_if_index));
2698 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2702 s = format (s, "DHCP compl event: pid %d %s hostname %s host_addr %U "
2703 "host_mac %U router_addr %U",
2704 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2706 format_ip4_address, mp->lease.host_address,
2707 format_ethernet_address, mp->lease.host_mac,
2708 format_ip4_address, mp->lease.router_address);
2710 for (i = 0; i < mp->lease.count; i++)
2712 format (s, " domain_server_addr %U", format_ip4_address,
2713 mp->lease.domain_server[i].address);
2715 errmsg ((char *) s);
2718 static void vl_api_dhcp_compl_event_t_handler_json
2719 (vl_api_dhcp_compl_event_t * mp)
2721 /* JSON output not supported */
2724 static void vl_api_get_first_msg_id_reply_t_handler
2725 (vl_api_get_first_msg_id_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 i32 retval = ntohl (mp->retval);
2730 if (vam->async_mode)
2732 vam->async_errors += (retval < 0);
2736 vam->retval = retval;
2737 vam->result_ready = 1;
2741 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2745 static void vl_api_get_first_msg_id_reply_t_handler_json
2746 (vl_api_get_first_msg_id_reply_t * mp)
2748 vat_main_t *vam = &vat_main;
2749 vat_json_node_t node;
2751 vat_json_init_object (&node);
2752 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2753 vat_json_object_add_uint (&node, "first_msg_id",
2754 (uint) ntohs (mp->first_msg_id));
2756 vat_json_print (vam->ofp, &node);
2757 vat_json_free (&node);
2759 vam->retval = ntohl (mp->retval);
2760 vam->result_ready = 1;
2763 static void vl_api_get_node_graph_reply_t_handler
2764 (vl_api_get_node_graph_reply_t * mp)
2766 vat_main_t *vam = &vat_main;
2767 api_main_t *am = &api_main;
2768 i32 retval = ntohl (mp->retval);
2769 u8 *pvt_copy, *reply;
2774 if (vam->async_mode)
2776 vam->async_errors += (retval < 0);
2780 vam->retval = retval;
2781 vam->result_ready = 1;
2784 /* "Should never happen..." */
2788 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2789 pvt_copy = vec_dup (reply);
2791 /* Toss the shared-memory original... */
2792 pthread_mutex_lock (&am->vlib_rp->mutex);
2793 oldheap = svm_push_data_heap (am->vlib_rp);
2797 svm_pop_heap (oldheap);
2798 pthread_mutex_unlock (&am->vlib_rp->mutex);
2800 if (vam->graph_nodes)
2802 hash_free (vam->graph_node_index_by_name);
2804 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2806 node = vam->graph_nodes[0][i];
2807 vec_free (node->name);
2808 vec_free (node->next_nodes);
2811 vec_free (vam->graph_nodes[0]);
2812 vec_free (vam->graph_nodes);
2815 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2816 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2817 vec_free (pvt_copy);
2819 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2821 node = vam->graph_nodes[0][i];
2822 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2826 static void vl_api_get_node_graph_reply_t_handler_json
2827 (vl_api_get_node_graph_reply_t * mp)
2829 vat_main_t *vam = &vat_main;
2830 api_main_t *am = &api_main;
2832 vat_json_node_t node;
2835 /* $$$$ make this real? */
2836 vat_json_init_object (&node);
2837 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2838 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2840 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2842 /* Toss the shared-memory original... */
2843 pthread_mutex_lock (&am->vlib_rp->mutex);
2844 oldheap = svm_push_data_heap (am->vlib_rp);
2848 svm_pop_heap (oldheap);
2849 pthread_mutex_unlock (&am->vlib_rp->mutex);
2851 vat_json_print (vam->ofp, &node);
2852 vat_json_free (&node);
2854 vam->retval = ntohl (mp->retval);
2855 vam->result_ready = 1;
2859 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2861 vat_main_t *vam = &vat_main;
2866 s = format (s, "%=16d%=16d%=16d",
2867 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2871 s = format (s, "%=16U%=16d%=16d",
2872 mp->is_ipv6 ? format_ip6_address :
2874 mp->ip_address, mp->priority, mp->weight);
2877 print (vam->ofp, "%v", s);
2882 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2884 vat_main_t *vam = &vat_main;
2885 vat_json_node_t *node = NULL;
2886 struct in6_addr ip6;
2889 if (VAT_JSON_ARRAY != vam->json_tree.type)
2891 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2892 vat_json_init_array (&vam->json_tree);
2894 node = vat_json_array_add (&vam->json_tree);
2895 vat_json_init_object (node);
2897 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2898 vat_json_object_add_uint (node, "priority", mp->priority);
2899 vat_json_object_add_uint (node, "weight", mp->weight);
2902 vat_json_object_add_uint (node, "sw_if_index",
2903 clib_net_to_host_u32 (mp->sw_if_index));
2908 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2909 vat_json_object_add_ip6 (node, "address", ip6);
2913 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2914 vat_json_object_add_ip4 (node, "address", ip4);
2920 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2923 vat_main_t *vam = &vat_main;
2926 ls_name = format (0, "%s", mp->ls_name);
2928 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2934 vl_api_one_locator_set_details_t_handler_json
2935 (vl_api_one_locator_set_details_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 vat_json_node_t *node = 0;
2941 ls_name = format (0, "%s", mp->ls_name);
2942 vec_add1 (ls_name, 0);
2944 if (VAT_JSON_ARRAY != vam->json_tree.type)
2946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2947 vat_json_init_array (&vam->json_tree);
2949 node = vat_json_array_add (&vam->json_tree);
2951 vat_json_init_object (node);
2952 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2953 vat_json_object_add_uint (node, "ls_index",
2954 clib_net_to_host_u32 (mp->ls_index));
2962 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2965 unformat_nsh_address (unformat_input_t * input, va_list * args)
2967 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2968 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2972 format_nsh_address_vat (u8 * s, va_list * args)
2974 nsh_t *a = va_arg (*args, nsh_t *);
2975 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2979 format_lisp_flat_eid (u8 * s, va_list * args)
2981 u32 type = va_arg (*args, u32);
2982 u8 *eid = va_arg (*args, u8 *);
2983 u32 eid_len = va_arg (*args, u32);
2988 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2990 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2992 return format (s, "%U", format_ethernet_address, eid);
2994 return format (s, "%U", format_nsh_address_vat, eid);
3000 format_lisp_eid_vat (u8 * s, va_list * args)
3002 u32 type = va_arg (*args, u32);
3003 u8 *eid = va_arg (*args, u8 *);
3004 u32 eid_len = va_arg (*args, u32);
3005 u8 *seid = va_arg (*args, u8 *);
3006 u32 seid_len = va_arg (*args, u32);
3007 u32 is_src_dst = va_arg (*args, u32);
3010 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3012 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3018 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3020 vat_main_t *vam = &vat_main;
3021 u8 *s = 0, *eid = 0;
3023 if (~0 == mp->locator_set_index)
3024 s = format (0, "action: %d", mp->action);
3026 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3028 eid = format (0, "%U", format_lisp_eid_vat,
3032 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3035 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3036 clib_net_to_host_u32 (mp->vni),
3038 mp->is_local ? "local" : "remote",
3039 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3040 clib_net_to_host_u16 (mp->key_id), mp->key);
3047 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3050 vat_main_t *vam = &vat_main;
3051 vat_json_node_t *node = 0;
3054 if (VAT_JSON_ARRAY != vam->json_tree.type)
3056 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3057 vat_json_init_array (&vam->json_tree);
3059 node = vat_json_array_add (&vam->json_tree);
3061 vat_json_init_object (node);
3062 if (~0 == mp->locator_set_index)
3063 vat_json_object_add_uint (node, "action", mp->action);
3065 vat_json_object_add_uint (node, "locator_set_index",
3066 clib_net_to_host_u32 (mp->locator_set_index));
3068 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3069 if (mp->eid_type == 3)
3071 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3072 vat_json_init_object (nsh_json);
3073 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3074 vat_json_object_add_uint (nsh_json, "spi",
3075 clib_net_to_host_u32 (nsh->spi));
3076 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3080 eid = format (0, "%U", format_lisp_eid_vat,
3084 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3086 vat_json_object_add_string_copy (node, "eid", eid);
3089 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3090 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3091 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3095 vat_json_object_add_uint (node, "key_id",
3096 clib_net_to_host_u16 (mp->key_id));
3097 vat_json_object_add_string_copy (node, "key", mp->key);
3102 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3104 vat_main_t *vam = &vat_main;
3105 u8 *seid = 0, *deid = 0;
3106 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3108 deid = format (0, "%U", format_lisp_eid_vat,
3109 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3111 seid = format (0, "%U", format_lisp_eid_vat,
3112 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3118 format_ip_address_fcn = format_ip4_address;
3120 format_ip_address_fcn = format_ip6_address;
3123 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3124 clib_net_to_host_u32 (mp->vni),
3126 format_ip_address_fcn, mp->lloc,
3127 format_ip_address_fcn, mp->rloc,
3128 clib_net_to_host_u32 (mp->pkt_count),
3129 clib_net_to_host_u32 (mp->bytes));
3136 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3138 struct in6_addr ip6;
3140 vat_main_t *vam = &vat_main;
3141 vat_json_node_t *node = 0;
3142 u8 *deid = 0, *seid = 0;
3144 if (VAT_JSON_ARRAY != vam->json_tree.type)
3146 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3147 vat_json_init_array (&vam->json_tree);
3149 node = vat_json_array_add (&vam->json_tree);
3151 vat_json_init_object (node);
3152 deid = format (0, "%U", format_lisp_eid_vat,
3153 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3155 seid = format (0, "%U", format_lisp_eid_vat,
3156 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3161 vat_json_object_add_string_copy (node, "seid", seid);
3162 vat_json_object_add_string_copy (node, "deid", deid);
3163 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3167 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3168 vat_json_object_add_ip4 (node, "lloc", ip4);
3169 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3170 vat_json_object_add_ip4 (node, "rloc", ip4);
3174 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3175 vat_json_object_add_ip6 (node, "lloc", ip6);
3176 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3177 vat_json_object_add_ip6 (node, "rloc", ip6);
3179 vat_json_object_add_uint (node, "pkt_count",
3180 clib_net_to_host_u32 (mp->pkt_count));
3181 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3188 vl_api_one_eid_table_map_details_t_handler
3189 (vl_api_one_eid_table_map_details_t * mp)
3191 vat_main_t *vam = &vat_main;
3193 u8 *line = format (0, "%=10d%=10d",
3194 clib_net_to_host_u32 (mp->vni),
3195 clib_net_to_host_u32 (mp->dp_table));
3196 print (vam->ofp, "%v", line);
3201 vl_api_one_eid_table_map_details_t_handler_json
3202 (vl_api_one_eid_table_map_details_t * mp)
3204 vat_main_t *vam = &vat_main;
3205 vat_json_node_t *node = NULL;
3207 if (VAT_JSON_ARRAY != vam->json_tree.type)
3209 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3210 vat_json_init_array (&vam->json_tree);
3212 node = vat_json_array_add (&vam->json_tree);
3213 vat_json_init_object (node);
3214 vat_json_object_add_uint (node, "dp_table",
3215 clib_net_to_host_u32 (mp->dp_table));
3216 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3220 vl_api_one_eid_table_vni_details_t_handler
3221 (vl_api_one_eid_table_vni_details_t * mp)
3223 vat_main_t *vam = &vat_main;
3225 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3226 print (vam->ofp, "%v", line);
3231 vl_api_one_eid_table_vni_details_t_handler_json
3232 (vl_api_one_eid_table_vni_details_t * mp)
3234 vat_main_t *vam = &vat_main;
3235 vat_json_node_t *node = NULL;
3237 if (VAT_JSON_ARRAY != vam->json_tree.type)
3239 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3240 vat_json_init_array (&vam->json_tree);
3242 node = vat_json_array_add (&vam->json_tree);
3243 vat_json_init_object (node);
3244 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3248 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3249 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3251 vat_main_t *vam = &vat_main;
3252 int retval = clib_net_to_host_u32 (mp->retval);
3254 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3255 print (vam->ofp, "fallback threshold value: %d", mp->value);
3257 vam->retval = retval;
3258 vam->result_ready = 1;
3262 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3263 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3265 vat_main_t *vam = &vat_main;
3266 vat_json_node_t _node, *node = &_node;
3267 int retval = clib_net_to_host_u32 (mp->retval);
3269 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3270 vat_json_init_object (node);
3271 vat_json_object_add_uint (node, "value", mp->value);
3273 vat_json_print (vam->ofp, node);
3274 vat_json_free (node);
3276 vam->retval = retval;
3277 vam->result_ready = 1;
3281 vl_api_show_one_map_register_state_reply_t_handler
3282 (vl_api_show_one_map_register_state_reply_t * mp)
3284 vat_main_t *vam = &vat_main;
3285 int retval = clib_net_to_host_u32 (mp->retval);
3287 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3289 vam->retval = retval;
3290 vam->result_ready = 1;
3294 vl_api_show_one_map_register_state_reply_t_handler_json
3295 (vl_api_show_one_map_register_state_reply_t * mp)
3297 vat_main_t *vam = &vat_main;
3298 vat_json_node_t _node, *node = &_node;
3299 int retval = clib_net_to_host_u32 (mp->retval);
3301 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3303 vat_json_init_object (node);
3304 vat_json_object_add_string_copy (node, "state", s);
3306 vat_json_print (vam->ofp, node);
3307 vat_json_free (node);
3309 vam->retval = retval;
3310 vam->result_ready = 1;
3315 vl_api_show_one_rloc_probe_state_reply_t_handler
3316 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3318 vat_main_t *vam = &vat_main;
3319 int retval = clib_net_to_host_u32 (mp->retval);
3324 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3326 vam->retval = retval;
3327 vam->result_ready = 1;
3331 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3332 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3334 vat_main_t *vam = &vat_main;
3335 vat_json_node_t _node, *node = &_node;
3336 int retval = clib_net_to_host_u32 (mp->retval);
3338 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3339 vat_json_init_object (node);
3340 vat_json_object_add_string_copy (node, "state", s);
3342 vat_json_print (vam->ofp, node);
3343 vat_json_free (node);
3345 vam->retval = retval;
3346 vam->result_ready = 1;
3351 vl_api_show_one_stats_enable_disable_reply_t_handler
3352 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3354 vat_main_t *vam = &vat_main;
3355 int retval = clib_net_to_host_u32 (mp->retval);
3360 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3362 vam->retval = retval;
3363 vam->result_ready = 1;
3367 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3368 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3370 vat_main_t *vam = &vat_main;
3371 vat_json_node_t _node, *node = &_node;
3372 int retval = clib_net_to_host_u32 (mp->retval);
3374 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3375 vat_json_init_object (node);
3376 vat_json_object_add_string_copy (node, "state", s);
3378 vat_json_print (vam->ofp, node);
3379 vat_json_free (node);
3381 vam->retval = retval;
3382 vam->result_ready = 1;
3387 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3389 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3390 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3391 e->vni = clib_net_to_host_u32 (e->vni);
3395 gpe_fwd_entries_get_reply_t_net_to_host
3396 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3400 mp->count = clib_net_to_host_u32 (mp->count);
3401 for (i = 0; i < mp->count; i++)
3403 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3408 format_gpe_encap_mode (u8 * s, va_list * args)
3410 u32 mode = va_arg (*args, u32);
3415 return format (s, "lisp");
3417 return format (s, "vxlan");
3423 vl_api_gpe_get_encap_mode_reply_t_handler
3424 (vl_api_gpe_get_encap_mode_reply_t * mp)
3426 vat_main_t *vam = &vat_main;
3428 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3429 vam->retval = ntohl (mp->retval);
3430 vam->result_ready = 1;
3434 vl_api_gpe_get_encap_mode_reply_t_handler_json
3435 (vl_api_gpe_get_encap_mode_reply_t * mp)
3437 vat_main_t *vam = &vat_main;
3438 vat_json_node_t node;
3440 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3441 vec_add1 (encap_mode, 0);
3443 vat_json_init_object (&node);
3444 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3446 vec_free (encap_mode);
3447 vat_json_print (vam->ofp, &node);
3448 vat_json_free (&node);
3450 vam->retval = ntohl (mp->retval);
3451 vam->result_ready = 1;
3455 vl_api_gpe_fwd_entry_path_details_t_handler
3456 (vl_api_gpe_fwd_entry_path_details_t * mp)
3458 vat_main_t *vam = &vat_main;
3459 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3461 if (mp->lcl_loc.is_ip4)
3462 format_ip_address_fcn = format_ip4_address;
3464 format_ip_address_fcn = format_ip6_address;
3466 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3467 format_ip_address_fcn, &mp->lcl_loc,
3468 format_ip_address_fcn, &mp->rmt_loc);
3472 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3474 struct in6_addr ip6;
3479 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3480 vat_json_object_add_ip4 (n, "address", ip4);
3484 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3485 vat_json_object_add_ip6 (n, "address", ip6);
3487 vat_json_object_add_uint (n, "weight", loc->weight);
3491 vl_api_gpe_fwd_entry_path_details_t_handler_json
3492 (vl_api_gpe_fwd_entry_path_details_t * mp)
3494 vat_main_t *vam = &vat_main;
3495 vat_json_node_t *node = NULL;
3496 vat_json_node_t *loc_node;
3498 if (VAT_JSON_ARRAY != vam->json_tree.type)
3500 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3501 vat_json_init_array (&vam->json_tree);
3503 node = vat_json_array_add (&vam->json_tree);
3504 vat_json_init_object (node);
3506 loc_node = vat_json_object_add (node, "local_locator");
3507 vat_json_init_object (loc_node);
3508 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3510 loc_node = vat_json_object_add (node, "remote_locator");
3511 vat_json_init_object (loc_node);
3512 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3516 vl_api_gpe_fwd_entries_get_reply_t_handler
3517 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3519 vat_main_t *vam = &vat_main;
3521 int retval = clib_net_to_host_u32 (mp->retval);
3522 vl_api_gpe_fwd_entry_t *e;
3527 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3529 for (i = 0; i < mp->count; i++)
3531 e = &mp->entries[i];
3532 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3533 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3534 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3538 vam->retval = retval;
3539 vam->result_ready = 1;
3543 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3544 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3548 vat_json_node_t *e = 0, root;
3550 int retval = clib_net_to_host_u32 (mp->retval);
3551 vl_api_gpe_fwd_entry_t *fwd;
3556 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3557 vat_json_init_array (&root);
3559 for (i = 0; i < mp->count; i++)
3561 e = vat_json_array_add (&root);
3562 fwd = &mp->entries[i];
3564 vat_json_init_object (e);
3565 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3566 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3567 vat_json_object_add_int (e, "vni", fwd->vni);
3568 vat_json_object_add_int (e, "action", fwd->action);
3570 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3571 fwd->leid_prefix_len);
3573 vat_json_object_add_string_copy (e, "leid", s);
3576 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3577 fwd->reid_prefix_len);
3579 vat_json_object_add_string_copy (e, "reid", s);
3583 vat_json_print (vam->ofp, &root);
3584 vat_json_free (&root);
3587 vam->retval = retval;
3588 vam->result_ready = 1;
3592 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3593 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3595 vat_main_t *vam = &vat_main;
3597 int retval = clib_net_to_host_u32 (mp->retval);
3598 vl_api_gpe_native_fwd_rpath_t *r;
3603 n = clib_net_to_host_u32 (mp->count);
3605 for (i = 0; i < n; i++)
3607 r = &mp->entries[i];
3608 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3609 clib_net_to_host_u32 (r->fib_index),
3610 clib_net_to_host_u32 (r->nh_sw_if_index),
3611 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3615 vam->retval = retval;
3616 vam->result_ready = 1;
3620 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3621 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3623 vat_main_t *vam = &vat_main;
3624 vat_json_node_t root, *e;
3626 int retval = clib_net_to_host_u32 (mp->retval);
3627 vl_api_gpe_native_fwd_rpath_t *r;
3633 n = clib_net_to_host_u32 (mp->count);
3634 vat_json_init_array (&root);
3636 for (i = 0; i < n; i++)
3638 e = vat_json_array_add (&root);
3639 vat_json_init_object (e);
3640 r = &mp->entries[i];
3642 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3645 vat_json_object_add_string_copy (e, "ip4", s);
3648 vat_json_object_add_uint (e, "fib_index",
3649 clib_net_to_host_u32 (r->fib_index));
3650 vat_json_object_add_uint (e, "nh_sw_if_index",
3651 clib_net_to_host_u32 (r->nh_sw_if_index));
3654 vat_json_print (vam->ofp, &root);
3655 vat_json_free (&root);
3658 vam->retval = retval;
3659 vam->result_ready = 1;
3663 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3664 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3666 vat_main_t *vam = &vat_main;
3668 int retval = clib_net_to_host_u32 (mp->retval);
3673 n = clib_net_to_host_u32 (mp->count);
3675 for (i = 0; i < n; i++)
3676 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3679 vam->retval = retval;
3680 vam->result_ready = 1;
3684 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3685 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3687 vat_main_t *vam = &vat_main;
3688 vat_json_node_t root;
3690 int retval = clib_net_to_host_u32 (mp->retval);
3695 n = clib_net_to_host_u32 (mp->count);
3696 vat_json_init_array (&root);
3698 for (i = 0; i < n; i++)
3699 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3701 vat_json_print (vam->ofp, &root);
3702 vat_json_free (&root);
3705 vam->retval = retval;
3706 vam->result_ready = 1;
3710 vl_api_one_ndp_entries_get_reply_t_handler
3711 (vl_api_one_ndp_entries_get_reply_t * mp)
3713 vat_main_t *vam = &vat_main;
3715 int retval = clib_net_to_host_u32 (mp->retval);
3720 n = clib_net_to_host_u32 (mp->count);
3722 for (i = 0; i < n; i++)
3723 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3724 format_ethernet_address, mp->entries[i].mac);
3727 vam->retval = retval;
3728 vam->result_ready = 1;
3732 vl_api_one_ndp_entries_get_reply_t_handler_json
3733 (vl_api_one_ndp_entries_get_reply_t * mp)
3736 vat_main_t *vam = &vat_main;
3737 vat_json_node_t *e = 0, root;
3739 int retval = clib_net_to_host_u32 (mp->retval);
3740 vl_api_one_ndp_entry_t *arp_entry;
3745 n = clib_net_to_host_u32 (mp->count);
3746 vat_json_init_array (&root);
3748 for (i = 0; i < n; i++)
3750 e = vat_json_array_add (&root);
3751 arp_entry = &mp->entries[i];
3753 vat_json_init_object (e);
3754 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3757 vat_json_object_add_string_copy (e, "mac", s);
3760 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3762 vat_json_object_add_string_copy (e, "ip6", s);
3766 vat_json_print (vam->ofp, &root);
3767 vat_json_free (&root);
3770 vam->retval = retval;
3771 vam->result_ready = 1;
3775 vl_api_one_l2_arp_entries_get_reply_t_handler
3776 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3778 vat_main_t *vam = &vat_main;
3780 int retval = clib_net_to_host_u32 (mp->retval);
3785 n = clib_net_to_host_u32 (mp->count);
3787 for (i = 0; i < n; i++)
3788 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3789 format_ethernet_address, mp->entries[i].mac);
3792 vam->retval = retval;
3793 vam->result_ready = 1;
3797 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3798 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3801 vat_main_t *vam = &vat_main;
3802 vat_json_node_t *e = 0, root;
3804 int retval = clib_net_to_host_u32 (mp->retval);
3805 vl_api_one_l2_arp_entry_t *arp_entry;
3810 n = clib_net_to_host_u32 (mp->count);
3811 vat_json_init_array (&root);
3813 for (i = 0; i < n; i++)
3815 e = vat_json_array_add (&root);
3816 arp_entry = &mp->entries[i];
3818 vat_json_init_object (e);
3819 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3822 vat_json_object_add_string_copy (e, "mac", s);
3825 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3827 vat_json_object_add_string_copy (e, "ip4", s);
3831 vat_json_print (vam->ofp, &root);
3832 vat_json_free (&root);
3835 vam->retval = retval;
3836 vam->result_ready = 1;
3840 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3842 vat_main_t *vam = &vat_main;
3844 int retval = clib_net_to_host_u32 (mp->retval);
3849 n = clib_net_to_host_u32 (mp->count);
3851 for (i = 0; i < n; i++)
3853 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3857 vam->retval = retval;
3858 vam->result_ready = 1;
3862 vl_api_one_ndp_bd_get_reply_t_handler_json
3863 (vl_api_one_ndp_bd_get_reply_t * mp)
3865 vat_main_t *vam = &vat_main;
3866 vat_json_node_t root;
3868 int retval = clib_net_to_host_u32 (mp->retval);
3873 n = clib_net_to_host_u32 (mp->count);
3874 vat_json_init_array (&root);
3876 for (i = 0; i < n; i++)
3878 vat_json_array_add_uint (&root,
3879 clib_net_to_host_u32 (mp->bridge_domains[i]));
3882 vat_json_print (vam->ofp, &root);
3883 vat_json_free (&root);
3886 vam->retval = retval;
3887 vam->result_ready = 1;
3891 vl_api_one_l2_arp_bd_get_reply_t_handler
3892 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3894 vat_main_t *vam = &vat_main;
3896 int retval = clib_net_to_host_u32 (mp->retval);
3901 n = clib_net_to_host_u32 (mp->count);
3903 for (i = 0; i < n; i++)
3905 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3909 vam->retval = retval;
3910 vam->result_ready = 1;
3914 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3915 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3917 vat_main_t *vam = &vat_main;
3918 vat_json_node_t root;
3920 int retval = clib_net_to_host_u32 (mp->retval);
3925 n = clib_net_to_host_u32 (mp->count);
3926 vat_json_init_array (&root);
3928 for (i = 0; i < n; i++)
3930 vat_json_array_add_uint (&root,
3931 clib_net_to_host_u32 (mp->bridge_domains[i]));
3934 vat_json_print (vam->ofp, &root);
3935 vat_json_free (&root);
3938 vam->retval = retval;
3939 vam->result_ready = 1;
3943 vl_api_one_adjacencies_get_reply_t_handler
3944 (vl_api_one_adjacencies_get_reply_t * mp)
3946 vat_main_t *vam = &vat_main;
3948 int retval = clib_net_to_host_u32 (mp->retval);
3949 vl_api_one_adjacency_t *a;
3954 n = clib_net_to_host_u32 (mp->count);
3956 for (i = 0; i < n; i++)
3958 a = &mp->adjacencies[i];
3959 print (vam->ofp, "%U %40U",
3960 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3961 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3965 vam->retval = retval;
3966 vam->result_ready = 1;
3970 vl_api_one_adjacencies_get_reply_t_handler_json
3971 (vl_api_one_adjacencies_get_reply_t * mp)
3974 vat_main_t *vam = &vat_main;
3975 vat_json_node_t *e = 0, root;
3977 int retval = clib_net_to_host_u32 (mp->retval);
3978 vl_api_one_adjacency_t *a;
3983 n = clib_net_to_host_u32 (mp->count);
3984 vat_json_init_array (&root);
3986 for (i = 0; i < n; i++)
3988 e = vat_json_array_add (&root);
3989 a = &mp->adjacencies[i];
3991 vat_json_init_object (e);
3992 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3993 a->leid_prefix_len);
3995 vat_json_object_add_string_copy (e, "leid", s);
3998 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3999 a->reid_prefix_len);
4001 vat_json_object_add_string_copy (e, "reid", s);
4005 vat_json_print (vam->ofp, &root);
4006 vat_json_free (&root);
4009 vam->retval = retval;
4010 vam->result_ready = 1;
4014 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4016 vat_main_t *vam = &vat_main;
4018 print (vam->ofp, "%=20U",
4019 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4024 vl_api_one_map_server_details_t_handler_json
4025 (vl_api_one_map_server_details_t * mp)
4027 vat_main_t *vam = &vat_main;
4028 vat_json_node_t *node = NULL;
4029 struct in6_addr ip6;
4032 if (VAT_JSON_ARRAY != vam->json_tree.type)
4034 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4035 vat_json_init_array (&vam->json_tree);
4037 node = vat_json_array_add (&vam->json_tree);
4039 vat_json_init_object (node);
4042 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4043 vat_json_object_add_ip6 (node, "map-server", ip6);
4047 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4048 vat_json_object_add_ip4 (node, "map-server", ip4);
4053 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4056 vat_main_t *vam = &vat_main;
4058 print (vam->ofp, "%=20U",
4059 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4064 vl_api_one_map_resolver_details_t_handler_json
4065 (vl_api_one_map_resolver_details_t * mp)
4067 vat_main_t *vam = &vat_main;
4068 vat_json_node_t *node = NULL;
4069 struct in6_addr ip6;
4072 if (VAT_JSON_ARRAY != vam->json_tree.type)
4074 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4075 vat_json_init_array (&vam->json_tree);
4077 node = vat_json_array_add (&vam->json_tree);
4079 vat_json_init_object (node);
4082 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4083 vat_json_object_add_ip6 (node, "map resolver", ip6);
4087 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4088 vat_json_object_add_ip4 (node, "map resolver", ip4);
4093 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4095 vat_main_t *vam = &vat_main;
4096 i32 retval = ntohl (mp->retval);
4100 print (vam->ofp, "feature: %s\ngpe: %s",
4101 mp->feature_status ? "enabled" : "disabled",
4102 mp->gpe_status ? "enabled" : "disabled");
4105 vam->retval = retval;
4106 vam->result_ready = 1;
4110 vl_api_show_one_status_reply_t_handler_json
4111 (vl_api_show_one_status_reply_t * mp)
4113 vat_main_t *vam = &vat_main;
4114 vat_json_node_t node;
4115 u8 *gpe_status = NULL;
4116 u8 *feature_status = NULL;
4118 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4119 feature_status = format (0, "%s",
4120 mp->feature_status ? "enabled" : "disabled");
4121 vec_add1 (gpe_status, 0);
4122 vec_add1 (feature_status, 0);
4124 vat_json_init_object (&node);
4125 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4126 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4128 vec_free (gpe_status);
4129 vec_free (feature_status);
4131 vat_json_print (vam->ofp, &node);
4132 vat_json_free (&node);
4134 vam->retval = ntohl (mp->retval);
4135 vam->result_ready = 1;
4139 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4140 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4142 vat_main_t *vam = &vat_main;
4143 i32 retval = ntohl (mp->retval);
4147 print (vam->ofp, "%=20s", mp->locator_set_name);
4150 vam->retval = retval;
4151 vam->result_ready = 1;
4155 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4156 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4158 vat_main_t *vam = &vat_main;
4159 vat_json_node_t *node = NULL;
4161 if (VAT_JSON_ARRAY != vam->json_tree.type)
4163 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4164 vat_json_init_array (&vam->json_tree);
4166 node = vat_json_array_add (&vam->json_tree);
4168 vat_json_init_object (node);
4169 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4171 vat_json_print (vam->ofp, node);
4172 vat_json_free (node);
4174 vam->retval = ntohl (mp->retval);
4175 vam->result_ready = 1;
4179 format_lisp_map_request_mode (u8 * s, va_list * args)
4181 u32 mode = va_arg (*args, u32);
4186 return format (0, "dst-only");
4188 return format (0, "src-dst");
4194 vl_api_show_one_map_request_mode_reply_t_handler
4195 (vl_api_show_one_map_request_mode_reply_t * mp)
4197 vat_main_t *vam = &vat_main;
4198 i32 retval = ntohl (mp->retval);
4202 u32 mode = mp->mode;
4203 print (vam->ofp, "map_request_mode: %U",
4204 format_lisp_map_request_mode, mode);
4207 vam->retval = retval;
4208 vam->result_ready = 1;
4212 vl_api_show_one_map_request_mode_reply_t_handler_json
4213 (vl_api_show_one_map_request_mode_reply_t * mp)
4215 vat_main_t *vam = &vat_main;
4216 vat_json_node_t node;
4221 s = format (0, "%U", format_lisp_map_request_mode, mode);
4224 vat_json_init_object (&node);
4225 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4226 vat_json_print (vam->ofp, &node);
4227 vat_json_free (&node);
4230 vam->retval = ntohl (mp->retval);
4231 vam->result_ready = 1;
4235 vl_api_one_show_xtr_mode_reply_t_handler
4236 (vl_api_one_show_xtr_mode_reply_t * mp)
4238 vat_main_t *vam = &vat_main;
4239 i32 retval = ntohl (mp->retval);
4243 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4246 vam->retval = retval;
4247 vam->result_ready = 1;
4251 vl_api_one_show_xtr_mode_reply_t_handler_json
4252 (vl_api_one_show_xtr_mode_reply_t * mp)
4254 vat_main_t *vam = &vat_main;
4255 vat_json_node_t node;
4258 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4259 vec_add1 (status, 0);
4261 vat_json_init_object (&node);
4262 vat_json_object_add_string_copy (&node, "status", status);
4266 vat_json_print (vam->ofp, &node);
4267 vat_json_free (&node);
4269 vam->retval = ntohl (mp->retval);
4270 vam->result_ready = 1;
4274 vl_api_one_show_pitr_mode_reply_t_handler
4275 (vl_api_one_show_pitr_mode_reply_t * mp)
4277 vat_main_t *vam = &vat_main;
4278 i32 retval = ntohl (mp->retval);
4282 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4285 vam->retval = retval;
4286 vam->result_ready = 1;
4290 vl_api_one_show_pitr_mode_reply_t_handler_json
4291 (vl_api_one_show_pitr_mode_reply_t * mp)
4293 vat_main_t *vam = &vat_main;
4294 vat_json_node_t node;
4297 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4298 vec_add1 (status, 0);
4300 vat_json_init_object (&node);
4301 vat_json_object_add_string_copy (&node, "status", status);
4305 vat_json_print (vam->ofp, &node);
4306 vat_json_free (&node);
4308 vam->retval = ntohl (mp->retval);
4309 vam->result_ready = 1;
4313 vl_api_one_show_petr_mode_reply_t_handler
4314 (vl_api_one_show_petr_mode_reply_t * mp)
4316 vat_main_t *vam = &vat_main;
4317 i32 retval = ntohl (mp->retval);
4321 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4324 vam->retval = retval;
4325 vam->result_ready = 1;
4329 vl_api_one_show_petr_mode_reply_t_handler_json
4330 (vl_api_one_show_petr_mode_reply_t * mp)
4332 vat_main_t *vam = &vat_main;
4333 vat_json_node_t node;
4336 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4337 vec_add1 (status, 0);
4339 vat_json_init_object (&node);
4340 vat_json_object_add_string_copy (&node, "status", status);
4344 vat_json_print (vam->ofp, &node);
4345 vat_json_free (&node);
4347 vam->retval = ntohl (mp->retval);
4348 vam->result_ready = 1;
4352 vl_api_show_one_use_petr_reply_t_handler
4353 (vl_api_show_one_use_petr_reply_t * mp)
4355 vat_main_t *vam = &vat_main;
4356 i32 retval = ntohl (mp->retval);
4360 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4363 print (vam->ofp, "Proxy-ETR address; %U",
4364 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4369 vam->retval = retval;
4370 vam->result_ready = 1;
4374 vl_api_show_one_use_petr_reply_t_handler_json
4375 (vl_api_show_one_use_petr_reply_t * mp)
4377 vat_main_t *vam = &vat_main;
4378 vat_json_node_t node;
4381 struct in6_addr ip6;
4383 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4384 vec_add1 (status, 0);
4386 vat_json_init_object (&node);
4387 vat_json_object_add_string_copy (&node, "status", status);
4392 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4393 vat_json_object_add_ip6 (&node, "address", ip6);
4397 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4398 vat_json_object_add_ip4 (&node, "address", ip4);
4404 vat_json_print (vam->ofp, &node);
4405 vat_json_free (&node);
4407 vam->retval = ntohl (mp->retval);
4408 vam->result_ready = 1;
4412 vl_api_show_one_nsh_mapping_reply_t_handler
4413 (vl_api_show_one_nsh_mapping_reply_t * mp)
4415 vat_main_t *vam = &vat_main;
4416 i32 retval = ntohl (mp->retval);
4420 print (vam->ofp, "%-20s%-16s",
4421 mp->is_set ? "set" : "not-set",
4422 mp->is_set ? (char *) mp->locator_set_name : "");
4425 vam->retval = retval;
4426 vam->result_ready = 1;
4430 vl_api_show_one_nsh_mapping_reply_t_handler_json
4431 (vl_api_show_one_nsh_mapping_reply_t * mp)
4433 vat_main_t *vam = &vat_main;
4434 vat_json_node_t node;
4437 status = format (0, "%s", mp->is_set ? "yes" : "no");
4438 vec_add1 (status, 0);
4440 vat_json_init_object (&node);
4441 vat_json_object_add_string_copy (&node, "is_set", status);
4444 vat_json_object_add_string_copy (&node, "locator_set",
4445 mp->locator_set_name);
4450 vat_json_print (vam->ofp, &node);
4451 vat_json_free (&node);
4453 vam->retval = ntohl (mp->retval);
4454 vam->result_ready = 1;
4458 vl_api_show_one_map_register_ttl_reply_t_handler
4459 (vl_api_show_one_map_register_ttl_reply_t * mp)
4461 vat_main_t *vam = &vat_main;
4462 i32 retval = ntohl (mp->retval);
4464 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4468 print (vam->ofp, "ttl: %u", mp->ttl);
4471 vam->retval = retval;
4472 vam->result_ready = 1;
4476 vl_api_show_one_map_register_ttl_reply_t_handler_json
4477 (vl_api_show_one_map_register_ttl_reply_t * mp)
4479 vat_main_t *vam = &vat_main;
4480 vat_json_node_t node;
4482 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4483 vat_json_init_object (&node);
4484 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4486 vat_json_print (vam->ofp, &node);
4487 vat_json_free (&node);
4489 vam->retval = ntohl (mp->retval);
4490 vam->result_ready = 1;
4494 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4496 vat_main_t *vam = &vat_main;
4497 i32 retval = ntohl (mp->retval);
4501 print (vam->ofp, "%-20s%-16s",
4502 mp->status ? "enabled" : "disabled",
4503 mp->status ? (char *) mp->locator_set_name : "");
4506 vam->retval = retval;
4507 vam->result_ready = 1;
4511 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4513 vat_main_t *vam = &vat_main;
4514 vat_json_node_t node;
4517 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4518 vec_add1 (status, 0);
4520 vat_json_init_object (&node);
4521 vat_json_object_add_string_copy (&node, "status", status);
4524 vat_json_object_add_string_copy (&node, "locator_set",
4525 mp->locator_set_name);
4530 vat_json_print (vam->ofp, &node);
4531 vat_json_free (&node);
4533 vam->retval = ntohl (mp->retval);
4534 vam->result_ready = 1;
4538 format_policer_type (u8 * s, va_list * va)
4540 u32 i = va_arg (*va, u32);
4542 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4543 s = format (s, "1r2c");
4544 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4545 s = format (s, "1r3c");
4546 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4547 s = format (s, "2r3c-2698");
4548 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4549 s = format (s, "2r3c-4115");
4550 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4551 s = format (s, "2r3c-mef5cf1");
4553 s = format (s, "ILLEGAL");
4558 format_policer_rate_type (u8 * s, va_list * va)
4560 u32 i = va_arg (*va, u32);
4562 if (i == SSE2_QOS_RATE_KBPS)
4563 s = format (s, "kbps");
4564 else if (i == SSE2_QOS_RATE_PPS)
4565 s = format (s, "pps");
4567 s = format (s, "ILLEGAL");
4572 format_policer_round_type (u8 * s, va_list * va)
4574 u32 i = va_arg (*va, u32);
4576 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4577 s = format (s, "closest");
4578 else if (i == SSE2_QOS_ROUND_TO_UP)
4579 s = format (s, "up");
4580 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4581 s = format (s, "down");
4583 s = format (s, "ILLEGAL");
4588 format_policer_action_type (u8 * s, va_list * va)
4590 u32 i = va_arg (*va, u32);
4592 if (i == SSE2_QOS_ACTION_DROP)
4593 s = format (s, "drop");
4594 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4595 s = format (s, "transmit");
4596 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4597 s = format (s, "mark-and-transmit");
4599 s = format (s, "ILLEGAL");
4604 format_dscp (u8 * s, va_list * va)
4606 u32 i = va_arg (*va, u32);
4611 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4615 return format (s, "ILLEGAL");
4617 s = format (s, "%s", t);
4622 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4624 vat_main_t *vam = &vat_main;
4625 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4627 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4628 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4630 conform_dscp_str = format (0, "");
4632 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4633 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4635 exceed_dscp_str = format (0, "");
4637 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4638 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4640 violate_dscp_str = format (0, "");
4642 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4643 "rate type %U, round type %U, %s rate, %s color-aware, "
4644 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4645 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4646 "conform action %U%s, exceed action %U%s, violate action %U%s",
4648 format_policer_type, mp->type,
4651 clib_net_to_host_u64 (mp->cb),
4652 clib_net_to_host_u64 (mp->eb),
4653 format_policer_rate_type, mp->rate_type,
4654 format_policer_round_type, mp->round_type,
4655 mp->single_rate ? "single" : "dual",
4656 mp->color_aware ? "is" : "not",
4657 ntohl (mp->cir_tokens_per_period),
4658 ntohl (mp->pir_tokens_per_period),
4660 ntohl (mp->current_limit),
4661 ntohl (mp->current_bucket),
4662 ntohl (mp->extended_limit),
4663 ntohl (mp->extended_bucket),
4664 clib_net_to_host_u64 (mp->last_update_time),
4665 format_policer_action_type, mp->conform_action_type,
4667 format_policer_action_type, mp->exceed_action_type,
4669 format_policer_action_type, mp->violate_action_type,
4672 vec_free (conform_dscp_str);
4673 vec_free (exceed_dscp_str);
4674 vec_free (violate_dscp_str);
4677 static void vl_api_policer_details_t_handler_json
4678 (vl_api_policer_details_t * mp)
4680 vat_main_t *vam = &vat_main;
4681 vat_json_node_t *node;
4682 u8 *rate_type_str, *round_type_str, *type_str;
4683 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4685 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4687 format (0, "%U", format_policer_round_type, mp->round_type);
4688 type_str = format (0, "%U", format_policer_type, mp->type);
4689 conform_action_str = format (0, "%U", format_policer_action_type,
4690 mp->conform_action_type);
4691 exceed_action_str = format (0, "%U", format_policer_action_type,
4692 mp->exceed_action_type);
4693 violate_action_str = format (0, "%U", format_policer_action_type,
4694 mp->violate_action_type);
4696 if (VAT_JSON_ARRAY != vam->json_tree.type)
4698 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4699 vat_json_init_array (&vam->json_tree);
4701 node = vat_json_array_add (&vam->json_tree);
4703 vat_json_init_object (node);
4704 vat_json_object_add_string_copy (node, "name", mp->name);
4705 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4706 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4707 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4708 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4709 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4710 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4711 vat_json_object_add_string_copy (node, "type", type_str);
4712 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4713 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4714 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4715 vat_json_object_add_uint (node, "cir_tokens_per_period",
4716 ntohl (mp->cir_tokens_per_period));
4717 vat_json_object_add_uint (node, "eir_tokens_per_period",
4718 ntohl (mp->pir_tokens_per_period));
4719 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4720 vat_json_object_add_uint (node, "current_bucket",
4721 ntohl (mp->current_bucket));
4722 vat_json_object_add_uint (node, "extended_limit",
4723 ntohl (mp->extended_limit));
4724 vat_json_object_add_uint (node, "extended_bucket",
4725 ntohl (mp->extended_bucket));
4726 vat_json_object_add_uint (node, "last_update_time",
4727 ntohl (mp->last_update_time));
4728 vat_json_object_add_string_copy (node, "conform_action",
4729 conform_action_str);
4730 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4732 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4733 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4734 vec_free (dscp_str);
4736 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4737 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4739 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4740 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4741 vec_free (dscp_str);
4743 vat_json_object_add_string_copy (node, "violate_action",
4744 violate_action_str);
4745 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4747 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4748 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4749 vec_free (dscp_str);
4752 vec_free (rate_type_str);
4753 vec_free (round_type_str);
4754 vec_free (type_str);
4755 vec_free (conform_action_str);
4756 vec_free (exceed_action_str);
4757 vec_free (violate_action_str);
4761 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4764 vat_main_t *vam = &vat_main;
4765 int i, count = ntohl (mp->count);
4768 print (vam->ofp, "classify table ids (%d) : ", count);
4769 for (i = 0; i < count; i++)
4771 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4772 print (vam->ofp, (i < count - 1) ? "," : "");
4774 vam->retval = ntohl (mp->retval);
4775 vam->result_ready = 1;
4779 vl_api_classify_table_ids_reply_t_handler_json
4780 (vl_api_classify_table_ids_reply_t * mp)
4782 vat_main_t *vam = &vat_main;
4783 int i, count = ntohl (mp->count);
4787 vat_json_node_t node;
4789 vat_json_init_object (&node);
4790 for (i = 0; i < count; i++)
4792 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4794 vat_json_print (vam->ofp, &node);
4795 vat_json_free (&node);
4797 vam->retval = ntohl (mp->retval);
4798 vam->result_ready = 1;
4802 vl_api_classify_table_by_interface_reply_t_handler
4803 (vl_api_classify_table_by_interface_reply_t * mp)
4805 vat_main_t *vam = &vat_main;
4808 table_id = ntohl (mp->l2_table_id);
4810 print (vam->ofp, "l2 table id : %d", table_id);
4812 print (vam->ofp, "l2 table id : No input ACL tables configured");
4813 table_id = ntohl (mp->ip4_table_id);
4815 print (vam->ofp, "ip4 table id : %d", table_id);
4817 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4818 table_id = ntohl (mp->ip6_table_id);
4820 print (vam->ofp, "ip6 table id : %d", table_id);
4822 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4823 vam->retval = ntohl (mp->retval);
4824 vam->result_ready = 1;
4828 vl_api_classify_table_by_interface_reply_t_handler_json
4829 (vl_api_classify_table_by_interface_reply_t * mp)
4831 vat_main_t *vam = &vat_main;
4832 vat_json_node_t node;
4834 vat_json_init_object (&node);
4836 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4837 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4838 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4840 vat_json_print (vam->ofp, &node);
4841 vat_json_free (&node);
4843 vam->retval = ntohl (mp->retval);
4844 vam->result_ready = 1;
4847 static void vl_api_policer_add_del_reply_t_handler
4848 (vl_api_policer_add_del_reply_t * mp)
4850 vat_main_t *vam = &vat_main;
4851 i32 retval = ntohl (mp->retval);
4852 if (vam->async_mode)
4854 vam->async_errors += (retval < 0);
4858 vam->retval = retval;
4859 vam->result_ready = 1;
4860 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4862 * Note: this is just barely thread-safe, depends on
4863 * the main thread spinning waiting for an answer...
4865 errmsg ("policer index %d", ntohl (mp->policer_index));
4869 static void vl_api_policer_add_del_reply_t_handler_json
4870 (vl_api_policer_add_del_reply_t * mp)
4872 vat_main_t *vam = &vat_main;
4873 vat_json_node_t node;
4875 vat_json_init_object (&node);
4876 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4877 vat_json_object_add_uint (&node, "policer_index",
4878 ntohl (mp->policer_index));
4880 vat_json_print (vam->ofp, &node);
4881 vat_json_free (&node);
4883 vam->retval = ntohl (mp->retval);
4884 vam->result_ready = 1;
4887 /* Format hex dump. */
4889 format_hex_bytes (u8 * s, va_list * va)
4891 u8 *bytes = va_arg (*va, u8 *);
4892 int n_bytes = va_arg (*va, int);
4895 /* Print short or long form depending on byte count. */
4896 uword short_form = n_bytes <= 32;
4897 u32 indent = format_get_indent (s);
4902 for (i = 0; i < n_bytes; i++)
4904 if (!short_form && (i % 32) == 0)
4905 s = format (s, "%08x: ", i);
4906 s = format (s, "%02x", bytes[i]);
4907 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4908 s = format (s, "\n%U", format_white_space, indent);
4915 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4918 vat_main_t *vam = &vat_main;
4919 i32 retval = ntohl (mp->retval);
4922 print (vam->ofp, "classify table info :");
4923 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4924 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4925 ntohl (mp->miss_next_index));
4926 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4927 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4928 ntohl (mp->match_n_vectors));
4929 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4930 ntohl (mp->mask_length));
4932 vam->retval = retval;
4933 vam->result_ready = 1;
4937 vl_api_classify_table_info_reply_t_handler_json
4938 (vl_api_classify_table_info_reply_t * mp)
4940 vat_main_t *vam = &vat_main;
4941 vat_json_node_t node;
4943 i32 retval = ntohl (mp->retval);
4946 vat_json_init_object (&node);
4948 vat_json_object_add_int (&node, "sessions",
4949 ntohl (mp->active_sessions));
4950 vat_json_object_add_int (&node, "nexttbl",
4951 ntohl (mp->next_table_index));
4952 vat_json_object_add_int (&node, "nextnode",
4953 ntohl (mp->miss_next_index));
4954 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4955 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4956 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4957 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4958 ntohl (mp->mask_length), 0);
4959 vat_json_object_add_string_copy (&node, "mask", s);
4961 vat_json_print (vam->ofp, &node);
4962 vat_json_free (&node);
4964 vam->retval = ntohl (mp->retval);
4965 vam->result_ready = 1;
4969 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4972 vat_main_t *vam = &vat_main;
4974 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4975 ntohl (mp->hit_next_index), ntohl (mp->advance),
4976 ntohl (mp->opaque_index));
4977 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4978 ntohl (mp->match_length));
4982 vl_api_classify_session_details_t_handler_json
4983 (vl_api_classify_session_details_t * mp)
4985 vat_main_t *vam = &vat_main;
4986 vat_json_node_t *node = NULL;
4988 if (VAT_JSON_ARRAY != vam->json_tree.type)
4990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4991 vat_json_init_array (&vam->json_tree);
4993 node = vat_json_array_add (&vam->json_tree);
4995 vat_json_init_object (node);
4996 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4997 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4998 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
5000 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
5002 vat_json_object_add_string_copy (node, "match", s);
5005 static void vl_api_pg_create_interface_reply_t_handler
5006 (vl_api_pg_create_interface_reply_t * mp)
5008 vat_main_t *vam = &vat_main;
5010 vam->retval = ntohl (mp->retval);
5011 vam->result_ready = 1;
5014 static void vl_api_pg_create_interface_reply_t_handler_json
5015 (vl_api_pg_create_interface_reply_t * mp)
5017 vat_main_t *vam = &vat_main;
5018 vat_json_node_t node;
5020 i32 retval = ntohl (mp->retval);
5023 vat_json_init_object (&node);
5025 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5027 vat_json_print (vam->ofp, &node);
5028 vat_json_free (&node);
5030 vam->retval = ntohl (mp->retval);
5031 vam->result_ready = 1;
5034 static void vl_api_policer_classify_details_t_handler
5035 (vl_api_policer_classify_details_t * mp)
5037 vat_main_t *vam = &vat_main;
5039 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5040 ntohl (mp->table_index));
5043 static void vl_api_policer_classify_details_t_handler_json
5044 (vl_api_policer_classify_details_t * mp)
5046 vat_main_t *vam = &vat_main;
5047 vat_json_node_t *node;
5049 if (VAT_JSON_ARRAY != vam->json_tree.type)
5051 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5052 vat_json_init_array (&vam->json_tree);
5054 node = vat_json_array_add (&vam->json_tree);
5056 vat_json_init_object (node);
5057 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5058 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5061 static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler
5062 (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
5064 vat_main_t *vam = &vat_main;
5065 i32 retval = ntohl (mp->retval);
5066 if (vam->async_mode)
5068 vam->async_errors += (retval < 0);
5072 vam->retval = retval;
5073 vam->sw_if_index = ntohl (mp->sw_if_index);
5074 vam->result_ready = 1;
5076 vam->regenerate_interface_table = 1;
5079 static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler_json
5080 (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
5082 vat_main_t *vam = &vat_main;
5083 vat_json_node_t node;
5085 vat_json_init_object (&node);
5086 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5087 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5089 vat_json_print (vam->ofp, &node);
5090 vat_json_free (&node);
5092 vam->retval = ntohl (mp->retval);
5093 vam->result_ready = 1;
5096 static void vl_api_flow_classify_details_t_handler
5097 (vl_api_flow_classify_details_t * mp)
5099 vat_main_t *vam = &vat_main;
5101 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5102 ntohl (mp->table_index));
5105 static void vl_api_flow_classify_details_t_handler_json
5106 (vl_api_flow_classify_details_t * mp)
5108 vat_main_t *vam = &vat_main;
5109 vat_json_node_t *node;
5111 if (VAT_JSON_ARRAY != vam->json_tree.type)
5113 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5114 vat_json_init_array (&vam->json_tree);
5116 node = vat_json_array_add (&vam->json_tree);
5118 vat_json_init_object (node);
5119 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5120 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5123 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5124 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5125 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5126 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5127 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5128 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5129 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5130 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5131 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5132 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5135 * Generate boilerplate reply handlers, which
5136 * dig the return value out of the xxx_reply_t API message,
5137 * stick it into vam->retval, and set vam->result_ready
5139 * Could also do this by pointing N message decode slots at
5140 * a single function, but that could break in subtle ways.
5143 #define foreach_standard_reply_retval_handler \
5144 _(sw_interface_set_flags_reply) \
5145 _(sw_interface_add_del_address_reply) \
5146 _(sw_interface_set_rx_mode_reply) \
5147 _(sw_interface_set_rx_placement_reply) \
5148 _(sw_interface_set_table_reply) \
5149 _(sw_interface_set_mpls_enable_reply) \
5150 _(sw_interface_set_vpath_reply) \
5151 _(sw_interface_set_vxlan_bypass_reply) \
5152 _(sw_interface_set_geneve_bypass_reply) \
5153 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5154 _(sw_interface_set_l2_bridge_reply) \
5155 _(bridge_domain_add_del_reply) \
5156 _(sw_interface_set_l2_xconnect_reply) \
5157 _(l2fib_add_del_reply) \
5158 _(l2fib_flush_int_reply) \
5159 _(l2fib_flush_bd_reply) \
5160 _(ip_add_del_route_reply) \
5161 _(ip_table_add_del_reply) \
5162 _(ip_mroute_add_del_reply) \
5163 _(mpls_route_add_del_reply) \
5164 _(mpls_table_add_del_reply) \
5165 _(mpls_ip_bind_unbind_reply) \
5166 _(bier_route_add_del_reply) \
5167 _(bier_table_add_del_reply) \
5168 _(proxy_arp_add_del_reply) \
5169 _(proxy_arp_intfc_enable_disable_reply) \
5170 _(sw_interface_set_unnumbered_reply) \
5171 _(ip_neighbor_add_del_reply) \
5172 _(oam_add_del_reply) \
5173 _(reset_fib_reply) \
5174 _(dhcp_proxy_config_reply) \
5175 _(dhcp_proxy_set_vss_reply) \
5176 _(dhcp_client_config_reply) \
5177 _(set_ip_flow_hash_reply) \
5178 _(sw_interface_ip6_enable_disable_reply) \
5179 _(ip6nd_proxy_add_del_reply) \
5180 _(sw_interface_ip6nd_ra_prefix_reply) \
5181 _(sw_interface_ip6nd_ra_config_reply) \
5182 _(set_arp_neighbor_limit_reply) \
5183 _(l2_patch_add_del_reply) \
5184 _(sr_mpls_policy_add_reply) \
5185 _(sr_mpls_policy_mod_reply) \
5186 _(sr_mpls_policy_del_reply) \
5187 _(sr_policy_add_reply) \
5188 _(sr_policy_mod_reply) \
5189 _(sr_policy_del_reply) \
5190 _(sr_localsid_add_del_reply) \
5191 _(sr_steering_add_del_reply) \
5192 _(classify_add_del_session_reply) \
5193 _(classify_set_interface_ip_table_reply) \
5194 _(classify_set_interface_l2_tables_reply) \
5195 _(l2tpv3_set_tunnel_cookies_reply) \
5196 _(l2tpv3_interface_enable_disable_reply) \
5197 _(l2tpv3_set_lookup_key_reply) \
5198 _(l2_fib_clear_table_reply) \
5199 _(l2_interface_efp_filter_reply) \
5200 _(l2_interface_vlan_tag_rewrite_reply) \
5201 _(modify_vhost_user_if_reply) \
5202 _(delete_vhost_user_if_reply) \
5203 _(ip_probe_neighbor_reply) \
5204 _(ip_scan_neighbor_enable_disable_reply) \
5205 _(want_ip4_arp_events_reply) \
5206 _(want_ip6_nd_events_reply) \
5207 _(want_l2_macs_events_reply) \
5208 _(input_acl_set_interface_reply) \
5209 _(ipsec_spd_add_del_reply) \
5210 _(ipsec_interface_add_del_spd_reply) \
5211 _(ipsec_spd_entry_add_del_reply) \
5212 _(ipsec_sad_entry_add_del_reply) \
5213 _(ipsec_sa_set_key_reply) \
5214 _(ipsec_tunnel_if_add_del_reply) \
5215 _(ipsec_tunnel_if_set_key_reply) \
5216 _(ipsec_tunnel_if_set_sa_reply) \
5217 _(delete_loopback_reply) \
5218 _(bd_ip_mac_add_del_reply) \
5219 _(bd_ip_mac_flush_reply) \
5220 _(want_interface_events_reply) \
5221 _(cop_interface_enable_disable_reply) \
5222 _(cop_whitelist_enable_disable_reply) \
5223 _(sw_interface_clear_stats_reply) \
5224 _(ioam_enable_reply) \
5225 _(ioam_disable_reply) \
5226 _(one_add_del_locator_reply) \
5227 _(one_add_del_local_eid_reply) \
5228 _(one_add_del_remote_mapping_reply) \
5229 _(one_add_del_adjacency_reply) \
5230 _(one_add_del_map_resolver_reply) \
5231 _(one_add_del_map_server_reply) \
5232 _(one_enable_disable_reply) \
5233 _(one_rloc_probe_enable_disable_reply) \
5234 _(one_map_register_enable_disable_reply) \
5235 _(one_map_register_set_ttl_reply) \
5236 _(one_set_transport_protocol_reply) \
5237 _(one_map_register_fallback_threshold_reply) \
5238 _(one_pitr_set_locator_set_reply) \
5239 _(one_map_request_mode_reply) \
5240 _(one_add_del_map_request_itr_rlocs_reply) \
5241 _(one_eid_table_add_del_map_reply) \
5242 _(one_use_petr_reply) \
5243 _(one_stats_enable_disable_reply) \
5244 _(one_add_del_l2_arp_entry_reply) \
5245 _(one_add_del_ndp_entry_reply) \
5246 _(one_stats_flush_reply) \
5247 _(one_enable_disable_xtr_mode_reply) \
5248 _(one_enable_disable_pitr_mode_reply) \
5249 _(one_enable_disable_petr_mode_reply) \
5250 _(gpe_enable_disable_reply) \
5251 _(gpe_set_encap_mode_reply) \
5252 _(gpe_add_del_iface_reply) \
5253 _(gpe_add_del_native_fwd_rpath_reply) \
5254 _(af_packet_delete_reply) \
5255 _(policer_classify_set_interface_reply) \
5256 _(netmap_create_reply) \
5257 _(netmap_delete_reply) \
5258 _(set_ipfix_exporter_reply) \
5259 _(set_ipfix_classify_stream_reply) \
5260 _(ipfix_classify_table_add_del_reply) \
5261 _(flow_classify_set_interface_reply) \
5262 _(sw_interface_span_enable_disable_reply) \
5263 _(pg_capture_reply) \
5264 _(pg_enable_disable_reply) \
5265 _(ip_source_and_port_range_check_add_del_reply) \
5266 _(ip_source_and_port_range_check_interface_add_del_reply)\
5267 _(delete_subif_reply) \
5268 _(l2_interface_pbb_tag_rewrite_reply) \
5270 _(feature_enable_disable_reply) \
5271 _(sw_interface_tag_add_del_reply) \
5272 _(hw_interface_set_mtu_reply) \
5273 _(p2p_ethernet_add_reply) \
5274 _(p2p_ethernet_del_reply) \
5275 _(lldp_config_reply) \
5276 _(sw_interface_set_lldp_reply) \
5277 _(tcp_configure_src_addresses_reply) \
5278 _(dns_enable_disable_reply) \
5279 _(dns_name_server_add_del_reply) \
5280 _(session_rule_add_del_reply) \
5281 _(ip_container_proxy_add_del_reply) \
5282 _(output_acl_set_interface_reply) \
5283 _(qos_record_enable_disable_reply)
5286 static void vl_api_##n##_t_handler \
5287 (vl_api_##n##_t * mp) \
5289 vat_main_t * vam = &vat_main; \
5290 i32 retval = ntohl(mp->retval); \
5291 if (vam->async_mode) { \
5292 vam->async_errors += (retval < 0); \
5294 vam->retval = retval; \
5295 vam->result_ready = 1; \
5298 foreach_standard_reply_retval_handler;
5302 static void vl_api_##n##_t_handler_json \
5303 (vl_api_##n##_t * mp) \
5305 vat_main_t * vam = &vat_main; \
5306 vat_json_node_t node; \
5307 vat_json_init_object(&node); \
5308 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5309 vat_json_print(vam->ofp, &node); \
5310 vam->retval = ntohl(mp->retval); \
5311 vam->result_ready = 1; \
5313 foreach_standard_reply_retval_handler;
5317 * Table of message reply handlers, must include boilerplate handlers
5321 #define foreach_vpe_api_reply_msg \
5322 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5323 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5324 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5325 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5326 _(CONTROL_PING_REPLY, control_ping_reply) \
5327 _(CLI_REPLY, cli_reply) \
5328 _(CLI_INBAND_REPLY, cli_inband_reply) \
5329 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5330 sw_interface_add_del_address_reply) \
5331 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5332 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5333 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5334 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5335 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5336 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5337 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5338 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5339 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5340 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5341 sw_interface_set_l2_xconnect_reply) \
5342 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5343 sw_interface_set_l2_bridge_reply) \
5344 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5345 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5346 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5347 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5348 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5349 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5350 _(L2_FLAGS_REPLY, l2_flags_reply) \
5351 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5352 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5353 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5354 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5355 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5356 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5357 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5358 _(BOND_CREATE_REPLY, bond_create_reply) \
5359 _(BOND_DELETE_REPLY, bond_delete_reply) \
5360 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5361 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5362 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5363 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5364 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5365 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5366 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5367 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5368 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5369 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5370 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5371 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5372 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5373 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5374 proxy_arp_intfc_enable_disable_reply) \
5375 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5376 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5377 sw_interface_set_unnumbered_reply) \
5378 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5379 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5380 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5381 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5382 _(RESET_FIB_REPLY, reset_fib_reply) \
5383 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5384 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5385 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5386 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5387 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5388 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5389 sw_interface_ip6_enable_disable_reply) \
5390 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5391 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5392 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5393 sw_interface_ip6nd_ra_prefix_reply) \
5394 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5395 sw_interface_ip6nd_ra_config_reply) \
5396 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5397 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5398 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5399 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5400 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5401 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5402 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5403 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5404 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5405 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5406 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5407 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5408 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5409 classify_set_interface_ip_table_reply) \
5410 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5411 classify_set_interface_l2_tables_reply) \
5412 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5413 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5414 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5415 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5416 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5417 l2tpv3_interface_enable_disable_reply) \
5418 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5419 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5420 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5421 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5422 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5423 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5424 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5425 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5426 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5427 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5428 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5429 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5430 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5431 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5432 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5433 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5434 _(SHOW_VERSION_REPLY, show_version_reply) \
5435 _(SHOW_THREADS_REPLY, show_threads_reply) \
5436 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5437 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5438 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5439 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5440 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5441 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5442 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5443 _(IP4_ARP_EVENT, ip4_arp_event) \
5444 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5445 _(IP6_ND_EVENT, ip6_nd_event) \
5446 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5447 _(L2_MACS_EVENT, l2_macs_event) \
5448 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5449 _(IP_ADDRESS_DETAILS, ip_address_details) \
5450 _(IP_DETAILS, ip_details) \
5451 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5452 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5453 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5454 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5455 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5456 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5457 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5458 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5459 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5460 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5461 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5462 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5463 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5464 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5465 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5466 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5467 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5468 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5469 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5470 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5471 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5472 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5473 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5474 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5475 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5476 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5477 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5478 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5479 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5480 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5481 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5482 one_map_register_enable_disable_reply) \
5483 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5484 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5485 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5486 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5487 one_map_register_fallback_threshold_reply) \
5488 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5489 one_rloc_probe_enable_disable_reply) \
5490 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5491 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5492 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5493 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5494 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5495 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5496 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5497 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5498 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5499 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5500 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5501 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5502 _(ONE_STATS_DETAILS, one_stats_details) \
5503 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5504 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5505 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5506 show_one_stats_enable_disable_reply) \
5507 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5508 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5509 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5510 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5511 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5512 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5513 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5514 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5515 one_enable_disable_pitr_mode_reply) \
5516 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5517 one_enable_disable_petr_mode_reply) \
5518 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5519 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5520 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5521 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5522 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5523 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5524 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5525 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5526 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5527 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5528 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5529 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5530 gpe_add_del_native_fwd_rpath_reply) \
5531 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5532 gpe_fwd_entry_path_details) \
5533 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5534 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5535 one_add_del_map_request_itr_rlocs_reply) \
5536 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5537 one_get_map_request_itr_rlocs_reply) \
5538 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5539 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5540 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5541 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5542 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5543 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5544 show_one_map_register_state_reply) \
5545 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5546 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5547 show_one_map_register_fallback_threshold_reply) \
5548 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5549 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5550 _(AF_PACKET_DETAILS, af_packet_details) \
5551 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5552 _(POLICER_DETAILS, policer_details) \
5553 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5554 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5555 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5556 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5557 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5558 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5559 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5560 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5561 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5562 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5563 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5564 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5565 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5566 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5567 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5568 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5569 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5570 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5571 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5572 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5573 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5574 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5575 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5576 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5577 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5578 ip_source_and_port_range_check_add_del_reply) \
5579 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5580 ip_source_and_port_range_check_interface_add_del_reply) \
5581 _(IPSEC_GRE_TUNNEL_ADD_DEL_REPLY, ipsec_gre_tunnel_add_del_reply) \
5582 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5583 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5584 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5585 _(SET_PUNT_REPLY, set_punt_reply) \
5586 _(IP_FIB_DETAILS, ip_fib_details) \
5587 _(IP6_FIB_DETAILS, ip6_fib_details) \
5588 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5589 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5590 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5591 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5592 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5593 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5594 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5595 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5596 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5597 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5598 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5599 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5600 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5601 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5602 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5603 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5604 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5605 _(SESSION_RULES_DETAILS, session_rules_details) \
5606 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5607 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5608 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5610 #define foreach_standalone_reply_msg \
5611 _(SW_INTERFACE_EVENT, sw_interface_event)
5619 #define STR_VTR_OP_CASE(op) \
5620 case L2_VTR_ ## op: \
5624 str_vtr_op (u32 vtr_op)
5628 STR_VTR_OP_CASE (DISABLED);
5629 STR_VTR_OP_CASE (PUSH_1);
5630 STR_VTR_OP_CASE (PUSH_2);
5631 STR_VTR_OP_CASE (POP_1);
5632 STR_VTR_OP_CASE (POP_2);
5633 STR_VTR_OP_CASE (TRANSLATE_1_1);
5634 STR_VTR_OP_CASE (TRANSLATE_1_2);
5635 STR_VTR_OP_CASE (TRANSLATE_2_1);
5636 STR_VTR_OP_CASE (TRANSLATE_2_2);
5643 dump_sub_interface_table (vat_main_t * vam)
5645 const sw_interface_subif_t *sub = NULL;
5647 if (vam->json_output)
5650 ("JSON output supported only for VPE API calls and dump_stats_table");
5655 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5656 "Interface", "sw_if_index",
5657 "sub id", "dot1ad", "tags", "outer id",
5658 "inner id", "exact", "default", "outer any", "inner any");
5660 vec_foreach (sub, vam->sw_if_subif_table)
5663 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5664 sub->interface_name,
5666 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5667 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5668 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5669 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5670 if (sub->vtr_op != L2_VTR_DISABLED)
5673 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5674 "tag1: %d tag2: %d ]",
5675 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5676 sub->vtr_tag1, sub->vtr_tag2);
5684 name_sort_cmp (void *a1, void *a2)
5686 name_sort_t *n1 = a1;
5687 name_sort_t *n2 = a2;
5689 return strcmp ((char *) n1->name, (char *) n2->name);
5693 dump_interface_table (vat_main_t * vam)
5696 name_sort_t *nses = 0, *ns;
5698 if (vam->json_output)
5701 ("JSON output supported only for VPE API calls and dump_stats_table");
5706 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5708 vec_add2 (nses, ns, 1);
5709 ns->name = (u8 *)(p->key);
5710 ns->value = (u32) p->value[0];
5714 vec_sort_with_function (nses, name_sort_cmp);
5716 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5717 vec_foreach (ns, nses)
5719 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5726 dump_ip_table (vat_main_t * vam, int is_ipv6)
5728 const ip_details_t *det = NULL;
5729 const ip_address_details_t *address = NULL;
5732 print (vam->ofp, "%-12s", "sw_if_index");
5734 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5741 print (vam->ofp, "%-12d", i);
5742 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5747 vec_foreach (address, det->addr)
5751 is_ipv6 ? format_ip6_address : format_ip4_address,
5752 address->ip, address->prefix_length);
5760 dump_ipv4_table (vat_main_t * vam)
5762 if (vam->json_output)
5765 ("JSON output supported only for VPE API calls and dump_stats_table");
5769 return dump_ip_table (vam, 0);
5773 dump_ipv6_table (vat_main_t * vam)
5775 if (vam->json_output)
5778 ("JSON output supported only for VPE API calls and dump_stats_table");
5782 return dump_ip_table (vam, 1);
5786 * Pass CLI buffers directly in the CLI_INBAND API message,
5787 * instead of an additional shared memory area.
5790 exec_inband (vat_main_t * vam)
5792 vl_api_cli_inband_t *mp;
5793 unformat_input_t *i = vam->input;
5796 if (vec_len (i->buffer) == 0)
5799 if (vam->exec_mode == 0 && unformat (i, "mode"))
5804 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5811 * In order for the CLI command to work, it
5812 * must be a vector ending in \n, not a C-string ending
5815 u32 len = vec_len (vam->input->buffer);
5816 M2 (CLI_INBAND, mp, len);
5817 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5821 /* json responses may or may not include a useful reply... */
5822 if (vec_len (vam->cmd_reply))
5823 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5828 exec (vat_main_t * vam)
5830 return exec_inband (vam);
5834 api_create_loopback (vat_main_t * vam)
5836 unformat_input_t *i = vam->input;
5837 vl_api_create_loopback_t *mp;
5838 vl_api_create_loopback_instance_t *mp_lbi;
5841 u8 is_specified = 0;
5842 u32 user_instance = 0;
5845 clib_memset (mac_address, 0, sizeof (mac_address));
5847 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5849 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5851 if (unformat (i, "instance %d", &user_instance))
5859 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5860 mp_lbi->is_specified = is_specified;
5862 mp_lbi->user_instance = htonl (user_instance);
5864 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5869 /* Construct the API message */
5870 M (CREATE_LOOPBACK, mp);
5872 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5881 api_delete_loopback (vat_main_t * vam)
5883 unformat_input_t *i = vam->input;
5884 vl_api_delete_loopback_t *mp;
5885 u32 sw_if_index = ~0;
5888 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5890 if (unformat (i, "sw_if_index %d", &sw_if_index))
5896 if (sw_if_index == ~0)
5898 errmsg ("missing sw_if_index");
5902 /* Construct the API message */
5903 M (DELETE_LOOPBACK, mp);
5904 mp->sw_if_index = ntohl (sw_if_index);
5912 api_want_interface_events (vat_main_t * vam)
5914 unformat_input_t *i = vam->input;
5915 vl_api_want_interface_events_t *mp;
5919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5921 if (unformat (i, "enable"))
5923 else if (unformat (i, "disable"))
5931 errmsg ("missing enable|disable");
5935 M (WANT_INTERFACE_EVENTS, mp);
5936 mp->enable_disable = enable;
5938 vam->interface_event_display = enable;
5946 /* Note: non-static, called once to set up the initial intfc table */
5948 api_sw_interface_dump (vat_main_t * vam)
5950 vl_api_sw_interface_dump_t *mp;
5951 vl_api_control_ping_t *mp_ping;
5953 name_sort_t *nses = 0, *ns;
5954 sw_interface_subif_t *sub = NULL;
5957 /* Toss the old name table */
5959 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5961 vec_add2 (nses, ns, 1);
5962 ns->name = (u8 *)(p->key);
5963 ns->value = (u32) p->value[0];
5967 hash_free (vam->sw_if_index_by_interface_name);
5969 vec_foreach (ns, nses) vec_free (ns->name);
5973 vec_foreach (sub, vam->sw_if_subif_table)
5975 vec_free (sub->interface_name);
5977 vec_free (vam->sw_if_subif_table);
5979 /* recreate the interface name hash table */
5980 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5983 * Ask for all interface names. Otherwise, the epic catalog of
5984 * name filters becomes ridiculously long, and vat ends up needing
5985 * to be taught about new interface types.
5987 M (SW_INTERFACE_DUMP, mp);
5990 /* Use a control ping for synchronization */
5991 MPING (CONTROL_PING, mp_ping);
5999 api_sw_interface_set_flags (vat_main_t * vam)
6001 unformat_input_t *i = vam->input;
6002 vl_api_sw_interface_set_flags_t *mp;
6004 u8 sw_if_index_set = 0;
6008 /* Parse args required to build the message */
6009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6011 if (unformat (i, "admin-up"))
6013 else if (unformat (i, "admin-down"))
6016 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6017 sw_if_index_set = 1;
6018 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6019 sw_if_index_set = 1;
6024 if (sw_if_index_set == 0)
6026 errmsg ("missing interface name or sw_if_index");
6030 /* Construct the API message */
6031 M (SW_INTERFACE_SET_FLAGS, mp);
6032 mp->sw_if_index = ntohl (sw_if_index);
6033 mp->admin_up_down = admin_up;
6038 /* Wait for a reply, return the good/bad news... */
6044 api_sw_interface_set_rx_mode (vat_main_t * vam)
6046 unformat_input_t *i = vam->input;
6047 vl_api_sw_interface_set_rx_mode_t *mp;
6049 u8 sw_if_index_set = 0;
6051 u8 queue_id_valid = 0;
6053 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6055 /* Parse args required to build the message */
6056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6058 if (unformat (i, "queue %d", &queue_id))
6060 else if (unformat (i, "polling"))
6061 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6062 else if (unformat (i, "interrupt"))
6063 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6064 else if (unformat (i, "adaptive"))
6065 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6067 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6068 sw_if_index_set = 1;
6069 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6070 sw_if_index_set = 1;
6075 if (sw_if_index_set == 0)
6077 errmsg ("missing interface name or sw_if_index");
6080 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6082 errmsg ("missing rx-mode");
6086 /* Construct the API message */
6087 M (SW_INTERFACE_SET_RX_MODE, mp);
6088 mp->sw_if_index = ntohl (sw_if_index);
6090 mp->queue_id_valid = queue_id_valid;
6091 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6096 /* Wait for a reply, return the good/bad news... */
6102 api_sw_interface_set_rx_placement (vat_main_t * vam)
6104 unformat_input_t *i = vam->input;
6105 vl_api_sw_interface_set_rx_placement_t *mp;
6107 u8 sw_if_index_set = 0;
6110 u32 queue_id, thread_index;
6112 /* Parse args required to build the message */
6113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6115 if (unformat (i, "queue %d", &queue_id))
6117 else if (unformat (i, "main"))
6119 else if (unformat (i, "worker %d", &thread_index))
6122 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6123 sw_if_index_set = 1;
6124 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6125 sw_if_index_set = 1;
6130 if (sw_if_index_set == 0)
6132 errmsg ("missing interface name or sw_if_index");
6138 /* Construct the API message */
6139 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6140 mp->sw_if_index = ntohl (sw_if_index);
6141 mp->worker_id = ntohl (thread_index);
6142 mp->queue_id = ntohl (queue_id);
6143 mp->is_main = is_main;
6147 /* Wait for a reply, return the good/bad news... */
6152 static void vl_api_sw_interface_rx_placement_details_t_handler
6153 (vl_api_sw_interface_rx_placement_details_t * mp)
6155 vat_main_t *vam = &vat_main;
6156 u32 worker_id = ntohl (mp->worker_id);
6159 "\n%-11d %-11s %-6d %-5d %-9s",
6160 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6161 worker_id, ntohl (mp->queue_id),
6163 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6166 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6167 (vl_api_sw_interface_rx_placement_details_t * mp)
6169 vat_main_t *vam = &vat_main;
6170 vat_json_node_t *node = NULL;
6172 if (VAT_JSON_ARRAY != vam->json_tree.type)
6174 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6175 vat_json_init_array (&vam->json_tree);
6177 node = vat_json_array_add (&vam->json_tree);
6179 vat_json_init_object (node);
6180 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6181 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6182 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6183 vat_json_object_add_uint (node, "mode", mp->mode);
6187 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6189 unformat_input_t *i = vam->input;
6190 vl_api_sw_interface_rx_placement_dump_t *mp;
6191 vl_api_control_ping_t *mp_ping;
6194 u8 sw_if_index_set = 0;
6196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6198 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6200 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6207 "\n%-11s %-11s %-6s %-5s %-4s",
6208 "sw_if_index", "main/worker", "thread", "queue", "mode");
6210 /* Dump Interface rx placement */
6211 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6213 if (sw_if_index_set)
6214 mp->sw_if_index = htonl (sw_if_index);
6216 mp->sw_if_index = ~0;
6220 /* Use a control ping for synchronization */
6221 MPING (CONTROL_PING, mp_ping);
6229 api_sw_interface_clear_stats (vat_main_t * vam)
6231 unformat_input_t *i = vam->input;
6232 vl_api_sw_interface_clear_stats_t *mp;
6234 u8 sw_if_index_set = 0;
6237 /* Parse args required to build the message */
6238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6240 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6241 sw_if_index_set = 1;
6242 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6243 sw_if_index_set = 1;
6248 /* Construct the API message */
6249 M (SW_INTERFACE_CLEAR_STATS, mp);
6251 if (sw_if_index_set == 1)
6252 mp->sw_if_index = ntohl (sw_if_index);
6254 mp->sw_if_index = ~0;
6259 /* Wait for a reply, return the good/bad news... */
6265 api_sw_interface_add_del_address (vat_main_t * vam)
6267 unformat_input_t *i = vam->input;
6268 vl_api_sw_interface_add_del_address_t *mp;
6270 u8 sw_if_index_set = 0;
6271 u8 is_add = 1, del_all = 0;
6272 u32 address_length = 0;
6273 u8 v4_address_set = 0;
6274 u8 v6_address_set = 0;
6275 ip4_address_t v4address;
6276 ip6_address_t v6address;
6279 /* Parse args required to build the message */
6280 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6282 if (unformat (i, "del-all"))
6284 else if (unformat (i, "del"))
6287 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6288 sw_if_index_set = 1;
6289 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6290 sw_if_index_set = 1;
6291 else if (unformat (i, "%U/%d",
6292 unformat_ip4_address, &v4address, &address_length))
6294 else if (unformat (i, "%U/%d",
6295 unformat_ip6_address, &v6address, &address_length))
6301 if (sw_if_index_set == 0)
6303 errmsg ("missing interface name or sw_if_index");
6306 if (v4_address_set && v6_address_set)
6308 errmsg ("both v4 and v6 addresses set");
6311 if (!v4_address_set && !v6_address_set && !del_all)
6313 errmsg ("no addresses set");
6317 /* Construct the API message */
6318 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6320 mp->sw_if_index = ntohl (sw_if_index);
6321 mp->is_add = is_add;
6322 mp->del_all = del_all;
6326 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6330 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6332 mp->address_length = address_length;
6337 /* Wait for a reply, return good/bad news */
6343 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6345 unformat_input_t *i = vam->input;
6346 vl_api_sw_interface_set_mpls_enable_t *mp;
6348 u8 sw_if_index_set = 0;
6352 /* Parse args required to build the message */
6353 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6355 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6356 sw_if_index_set = 1;
6357 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6358 sw_if_index_set = 1;
6359 else if (unformat (i, "disable"))
6361 else if (unformat (i, "dis"))
6367 if (sw_if_index_set == 0)
6369 errmsg ("missing interface name or sw_if_index");
6373 /* Construct the API message */
6374 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6376 mp->sw_if_index = ntohl (sw_if_index);
6377 mp->enable = enable;
6382 /* Wait for a reply... */
6388 api_sw_interface_set_table (vat_main_t * vam)
6390 unformat_input_t *i = vam->input;
6391 vl_api_sw_interface_set_table_t *mp;
6392 u32 sw_if_index, vrf_id = 0;
6393 u8 sw_if_index_set = 0;
6397 /* Parse args required to build the message */
6398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6400 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6401 sw_if_index_set = 1;
6402 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6403 sw_if_index_set = 1;
6404 else if (unformat (i, "vrf %d", &vrf_id))
6406 else if (unformat (i, "ipv6"))
6412 if (sw_if_index_set == 0)
6414 errmsg ("missing interface name or sw_if_index");
6418 /* Construct the API message */
6419 M (SW_INTERFACE_SET_TABLE, mp);
6421 mp->sw_if_index = ntohl (sw_if_index);
6422 mp->is_ipv6 = is_ipv6;
6423 mp->vrf_id = ntohl (vrf_id);
6428 /* Wait for a reply... */
6433 static void vl_api_sw_interface_get_table_reply_t_handler
6434 (vl_api_sw_interface_get_table_reply_t * mp)
6436 vat_main_t *vam = &vat_main;
6438 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6440 vam->retval = ntohl (mp->retval);
6441 vam->result_ready = 1;
6445 static void vl_api_sw_interface_get_table_reply_t_handler_json
6446 (vl_api_sw_interface_get_table_reply_t * mp)
6448 vat_main_t *vam = &vat_main;
6449 vat_json_node_t node;
6451 vat_json_init_object (&node);
6452 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6453 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6455 vat_json_print (vam->ofp, &node);
6456 vat_json_free (&node);
6458 vam->retval = ntohl (mp->retval);
6459 vam->result_ready = 1;
6463 api_sw_interface_get_table (vat_main_t * vam)
6465 unformat_input_t *i = vam->input;
6466 vl_api_sw_interface_get_table_t *mp;
6468 u8 sw_if_index_set = 0;
6472 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6474 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6475 sw_if_index_set = 1;
6476 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6477 sw_if_index_set = 1;
6478 else if (unformat (i, "ipv6"))
6484 if (sw_if_index_set == 0)
6486 errmsg ("missing interface name or sw_if_index");
6490 M (SW_INTERFACE_GET_TABLE, mp);
6491 mp->sw_if_index = htonl (sw_if_index);
6492 mp->is_ipv6 = is_ipv6;
6500 api_sw_interface_set_vpath (vat_main_t * vam)
6502 unformat_input_t *i = vam->input;
6503 vl_api_sw_interface_set_vpath_t *mp;
6504 u32 sw_if_index = 0;
6505 u8 sw_if_index_set = 0;
6509 /* Parse args required to build the message */
6510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6512 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6513 sw_if_index_set = 1;
6514 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6515 sw_if_index_set = 1;
6516 else if (unformat (i, "enable"))
6518 else if (unformat (i, "disable"))
6524 if (sw_if_index_set == 0)
6526 errmsg ("missing interface name or sw_if_index");
6530 /* Construct the API message */
6531 M (SW_INTERFACE_SET_VPATH, mp);
6533 mp->sw_if_index = ntohl (sw_if_index);
6534 mp->enable = is_enable;
6539 /* Wait for a reply... */
6545 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6547 unformat_input_t *i = vam->input;
6548 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6549 u32 sw_if_index = 0;
6550 u8 sw_if_index_set = 0;
6555 /* Parse args required to build the message */
6556 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6558 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6559 sw_if_index_set = 1;
6560 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6561 sw_if_index_set = 1;
6562 else if (unformat (i, "enable"))
6564 else if (unformat (i, "disable"))
6566 else if (unformat (i, "ip4"))
6568 else if (unformat (i, "ip6"))
6574 if (sw_if_index_set == 0)
6576 errmsg ("missing interface name or sw_if_index");
6580 /* Construct the API message */
6581 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6583 mp->sw_if_index = ntohl (sw_if_index);
6584 mp->enable = is_enable;
6585 mp->is_ipv6 = is_ipv6;
6590 /* Wait for a reply... */
6596 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6598 unformat_input_t *i = vam->input;
6599 vl_api_sw_interface_set_geneve_bypass_t *mp;
6600 u32 sw_if_index = 0;
6601 u8 sw_if_index_set = 0;
6606 /* Parse args required to build the message */
6607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6609 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6610 sw_if_index_set = 1;
6611 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6612 sw_if_index_set = 1;
6613 else if (unformat (i, "enable"))
6615 else if (unformat (i, "disable"))
6617 else if (unformat (i, "ip4"))
6619 else if (unformat (i, "ip6"))
6625 if (sw_if_index_set == 0)
6627 errmsg ("missing interface name or sw_if_index");
6631 /* Construct the API message */
6632 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6634 mp->sw_if_index = ntohl (sw_if_index);
6635 mp->enable = is_enable;
6636 mp->is_ipv6 = is_ipv6;
6641 /* Wait for a reply... */
6647 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6649 unformat_input_t *i = vam->input;
6650 vl_api_sw_interface_set_l2_xconnect_t *mp;
6652 u8 rx_sw_if_index_set = 0;
6654 u8 tx_sw_if_index_set = 0;
6658 /* Parse args required to build the message */
6659 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6661 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6662 rx_sw_if_index_set = 1;
6663 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6664 tx_sw_if_index_set = 1;
6665 else if (unformat (i, "rx"))
6667 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6669 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6671 rx_sw_if_index_set = 1;
6676 else if (unformat (i, "tx"))
6678 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6680 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6682 tx_sw_if_index_set = 1;
6687 else if (unformat (i, "enable"))
6689 else if (unformat (i, "disable"))
6695 if (rx_sw_if_index_set == 0)
6697 errmsg ("missing rx interface name or rx_sw_if_index");
6701 if (enable && (tx_sw_if_index_set == 0))
6703 errmsg ("missing tx interface name or tx_sw_if_index");
6707 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6709 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6710 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6711 mp->enable = enable;
6719 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6721 unformat_input_t *i = vam->input;
6722 vl_api_sw_interface_set_l2_bridge_t *mp;
6723 vl_api_l2_port_type_t port_type;
6725 u8 rx_sw_if_index_set = 0;
6732 port_type = L2_API_PORT_TYPE_NORMAL;
6734 /* Parse args required to build the message */
6735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6737 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6738 rx_sw_if_index_set = 1;
6739 else if (unformat (i, "bd_id %d", &bd_id))
6743 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6744 rx_sw_if_index_set = 1;
6745 else if (unformat (i, "shg %d", &shg))
6747 else if (unformat (i, "bvi"))
6748 port_type = L2_API_PORT_TYPE_BVI;
6749 else if (unformat (i, "uu-fwd"))
6750 port_type = L2_API_PORT_TYPE_UU_FWD;
6751 else if (unformat (i, "enable"))
6753 else if (unformat (i, "disable"))
6759 if (rx_sw_if_index_set == 0)
6761 errmsg ("missing rx interface name or sw_if_index");
6765 if (enable && (bd_id_set == 0))
6767 errmsg ("missing bridge domain");
6771 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6773 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6774 mp->bd_id = ntohl (bd_id);
6776 mp->port_type = ntohl (port_type);
6777 mp->enable = enable;
6785 api_bridge_domain_dump (vat_main_t * vam)
6787 unformat_input_t *i = vam->input;
6788 vl_api_bridge_domain_dump_t *mp;
6789 vl_api_control_ping_t *mp_ping;
6793 /* Parse args required to build the message */
6794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6796 if (unformat (i, "bd_id %d", &bd_id))
6802 M (BRIDGE_DOMAIN_DUMP, mp);
6803 mp->bd_id = ntohl (bd_id);
6806 /* Use a control ping for synchronization */
6807 MPING (CONTROL_PING, mp_ping);
6815 api_bridge_domain_add_del (vat_main_t * vam)
6817 unformat_input_t *i = vam->input;
6818 vl_api_bridge_domain_add_del_t *mp;
6821 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6826 /* Parse args required to build the message */
6827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6829 if (unformat (i, "bd_id %d", &bd_id))
6831 else if (unformat (i, "flood %d", &flood))
6833 else if (unformat (i, "uu-flood %d", &uu_flood))
6835 else if (unformat (i, "forward %d", &forward))
6837 else if (unformat (i, "learn %d", &learn))
6839 else if (unformat (i, "arp-term %d", &arp_term))
6841 else if (unformat (i, "mac-age %d", &mac_age))
6843 else if (unformat (i, "bd-tag %s", &bd_tag))
6845 else if (unformat (i, "del"))
6848 flood = uu_flood = forward = learn = 0;
6856 errmsg ("missing bridge domain");
6863 errmsg ("mac age must be less than 256 ");
6868 if ((bd_tag) && (vec_len (bd_tag) > 63))
6870 errmsg ("bd-tag cannot be longer than 63");
6875 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6877 mp->bd_id = ntohl (bd_id);
6879 mp->uu_flood = uu_flood;
6880 mp->forward = forward;
6882 mp->arp_term = arp_term;
6883 mp->is_add = is_add;
6884 mp->mac_age = (u8) mac_age;
6887 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6888 mp->bd_tag[vec_len (bd_tag)] = 0;
6899 api_l2fib_flush_bd (vat_main_t * vam)
6901 unformat_input_t *i = vam->input;
6902 vl_api_l2fib_flush_bd_t *mp;
6906 /* Parse args required to build the message */
6907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6909 if (unformat (i, "bd_id %d", &bd_id));
6916 errmsg ("missing bridge domain");
6920 M (L2FIB_FLUSH_BD, mp);
6922 mp->bd_id = htonl (bd_id);
6930 api_l2fib_flush_int (vat_main_t * vam)
6932 unformat_input_t *i = vam->input;
6933 vl_api_l2fib_flush_int_t *mp;
6934 u32 sw_if_index = ~0;
6937 /* Parse args required to build the message */
6938 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6940 if (unformat (i, "sw_if_index %d", &sw_if_index));
6942 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6947 if (sw_if_index == ~0)
6949 errmsg ("missing interface name or sw_if_index");
6953 M (L2FIB_FLUSH_INT, mp);
6955 mp->sw_if_index = ntohl (sw_if_index);
6963 api_l2fib_add_del (vat_main_t * vam)
6965 unformat_input_t *i = vam->input;
6966 vl_api_l2fib_add_del_t *mp;
6972 u32 sw_if_index = 0;
6973 u8 sw_if_index_set = 0;
6982 /* Parse args required to build the message */
6983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6985 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6987 else if (unformat (i, "bd_id %d", &bd_id))
6989 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6990 sw_if_index_set = 1;
6991 else if (unformat (i, "sw_if"))
6993 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6996 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6997 sw_if_index_set = 1;
7002 else if (unformat (i, "static"))
7004 else if (unformat (i, "filter"))
7009 else if (unformat (i, "bvi"))
7014 else if (unformat (i, "del"))
7016 else if (unformat (i, "count %d", &count))
7024 errmsg ("missing mac address");
7030 errmsg ("missing bridge domain");
7034 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7036 errmsg ("missing interface name or sw_if_index");
7042 /* Turn on async mode */
7043 vam->async_mode = 1;
7044 vam->async_errors = 0;
7045 before = vat_time_now (vam);
7048 for (j = 0; j < count; j++)
7050 M (L2FIB_ADD_DEL, mp);
7052 clib_memcpy (mp->mac, mac, 6);
7053 mp->bd_id = ntohl (bd_id);
7054 mp->is_add = is_add;
7055 mp->sw_if_index = ntohl (sw_if_index);
7059 mp->static_mac = static_mac;
7060 mp->filter_mac = filter_mac;
7061 mp->bvi_mac = bvi_mac;
7063 increment_mac_address (mac);
7070 vl_api_control_ping_t *mp_ping;
7073 /* Shut off async mode */
7074 vam->async_mode = 0;
7076 MPING (CONTROL_PING, mp_ping);
7079 timeout = vat_time_now (vam) + 1.0;
7080 while (vat_time_now (vam) < timeout)
7081 if (vam->result_ready == 1)
7086 if (vam->retval == -99)
7089 if (vam->async_errors > 0)
7091 errmsg ("%d asynchronous errors", vam->async_errors);
7094 vam->async_errors = 0;
7095 after = vat_time_now (vam);
7097 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7098 count, after - before, count / (after - before));
7104 /* Wait for a reply... */
7108 /* Return the good/bad news */
7109 return (vam->retval);
7113 api_bridge_domain_set_mac_age (vat_main_t * vam)
7115 unformat_input_t *i = vam->input;
7116 vl_api_bridge_domain_set_mac_age_t *mp;
7121 /* Parse args required to build the message */
7122 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7124 if (unformat (i, "bd_id %d", &bd_id));
7125 else if (unformat (i, "mac-age %d", &mac_age));
7132 errmsg ("missing bridge domain");
7138 errmsg ("mac age must be less than 256 ");
7142 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7144 mp->bd_id = htonl (bd_id);
7145 mp->mac_age = (u8) mac_age;
7153 api_l2_flags (vat_main_t * vam)
7155 unformat_input_t *i = vam->input;
7156 vl_api_l2_flags_t *mp;
7159 u8 sw_if_index_set = 0;
7163 /* Parse args required to build the message */
7164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7166 if (unformat (i, "sw_if_index %d", &sw_if_index))
7167 sw_if_index_set = 1;
7168 else if (unformat (i, "sw_if"))
7170 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7173 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7174 sw_if_index_set = 1;
7179 else if (unformat (i, "learn"))
7181 else if (unformat (i, "forward"))
7183 else if (unformat (i, "flood"))
7185 else if (unformat (i, "uu-flood"))
7186 flags |= L2_UU_FLOOD;
7187 else if (unformat (i, "arp-term"))
7188 flags |= L2_ARP_TERM;
7189 else if (unformat (i, "off"))
7191 else if (unformat (i, "disable"))
7197 if (sw_if_index_set == 0)
7199 errmsg ("missing interface name or sw_if_index");
7205 mp->sw_if_index = ntohl (sw_if_index);
7206 mp->feature_bitmap = ntohl (flags);
7207 mp->is_set = is_set;
7215 api_bridge_flags (vat_main_t * vam)
7217 unformat_input_t *i = vam->input;
7218 vl_api_bridge_flags_t *mp;
7222 bd_flags_t flags = 0;
7225 /* Parse args required to build the message */
7226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7228 if (unformat (i, "bd_id %d", &bd_id))
7230 else if (unformat (i, "learn"))
7231 flags |= BRIDGE_API_FLAG_LEARN;
7232 else if (unformat (i, "forward"))
7233 flags |= BRIDGE_API_FLAG_FWD;
7234 else if (unformat (i, "flood"))
7235 flags |= BRIDGE_API_FLAG_FLOOD;
7236 else if (unformat (i, "uu-flood"))
7237 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7238 else if (unformat (i, "arp-term"))
7239 flags |= BRIDGE_API_FLAG_ARP_TERM;
7240 else if (unformat (i, "off"))
7242 else if (unformat (i, "disable"))
7250 errmsg ("missing bridge domain");
7254 M (BRIDGE_FLAGS, mp);
7256 mp->bd_id = ntohl (bd_id);
7257 mp->flags = ntohl (flags);
7258 mp->is_set = is_set;
7266 api_bd_ip_mac_add_del (vat_main_t * vam)
7268 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7269 vl_api_mac_address_t mac = { 0 };
7270 unformat_input_t *i = vam->input;
7271 vl_api_bd_ip_mac_add_del_t *mp;
7283 /* Parse args required to build the message */
7284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7286 if (unformat (i, "bd_id %d", &bd_id))
7290 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7294 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7298 else if (unformat (i, "del"))
7306 errmsg ("missing bridge domain");
7309 else if (ip_set == 0)
7311 errmsg ("missing IP address");
7314 else if (mac_set == 0)
7316 errmsg ("missing MAC address");
7320 M (BD_IP_MAC_ADD_DEL, mp);
7322 mp->bd_id = ntohl (bd_id);
7323 mp->is_add = is_add;
7325 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7326 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7334 api_bd_ip_mac_flush (vat_main_t * vam)
7336 unformat_input_t *i = vam->input;
7337 vl_api_bd_ip_mac_flush_t *mp;
7342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7344 if (unformat (i, "bd_id %d", &bd_id))
7354 errmsg ("missing bridge domain");
7358 M (BD_IP_MAC_FLUSH, mp);
7360 mp->bd_id = ntohl (bd_id);
7367 static void vl_api_bd_ip_mac_details_t_handler
7368 (vl_api_bd_ip_mac_details_t * mp)
7370 vat_main_t *vam = &vat_main;
7375 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7378 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7381 "\n%-5d %-7s %-20U %-30s",
7382 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7383 format_ethernet_address, mp->mac_address, ip);
7388 static void vl_api_bd_ip_mac_details_t_handler_json
7389 (vl_api_bd_ip_mac_details_t * mp)
7391 vat_main_t *vam = &vat_main;
7392 vat_json_node_t *node = NULL;
7394 if (VAT_JSON_ARRAY != vam->json_tree.type)
7396 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7397 vat_json_init_array (&vam->json_tree);
7399 node = vat_json_array_add (&vam->json_tree);
7401 vat_json_init_object (node);
7402 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7403 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7404 vat_json_object_add_string_copy (node, "mac_address",
7405 format (0, "%U", format_ethernet_address,
7411 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7414 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7415 vat_json_object_add_string_copy (node, "ip_address", ip);
7420 api_bd_ip_mac_dump (vat_main_t * vam)
7422 unformat_input_t *i = vam->input;
7423 vl_api_bd_ip_mac_dump_t *mp;
7424 vl_api_control_ping_t *mp_ping;
7429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7431 if (unformat (i, "bd_id %d", &bd_id))
7440 "\n%-5s %-7s %-20s %-30s",
7441 "bd_id", "is_ipv6", "mac_address", "ip_address");
7443 /* Dump Bridge Domain Ip to Mac entries */
7444 M (BD_IP_MAC_DUMP, mp);
7447 mp->bd_id = htonl (bd_id);
7453 /* Use a control ping for synchronization */
7454 MPING (CONTROL_PING, mp_ping);
7462 api_tap_create_v2 (vat_main_t * vam)
7464 unformat_input_t *i = vam->input;
7465 vl_api_tap_create_v2_t *mp;
7469 u8 *host_if_name = 0;
7471 u8 host_mac_addr[6];
7472 u8 host_mac_addr_set = 0;
7473 u8 *host_bridge = 0;
7474 ip4_address_t host_ip4_addr;
7475 ip4_address_t host_ip4_gw;
7476 u8 host_ip4_gw_set = 0;
7477 u32 host_ip4_prefix_len = 0;
7478 ip6_address_t host_ip6_addr;
7479 ip6_address_t host_ip6_gw;
7480 u8 host_ip6_gw_set = 0;
7481 u32 host_ip6_prefix_len = 0;
7483 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7485 clib_memset (mac_address, 0, sizeof (mac_address));
7487 /* Parse args required to build the message */
7488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7490 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7494 else if (unformat (i, "id %u", &id))
7496 else if (unformat (i, "host-if-name %s", &host_if_name))
7498 else if (unformat (i, "host-ns %s", &host_ns))
7500 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7502 host_mac_addr_set = 1;
7503 else if (unformat (i, "host-bridge %s", &host_bridge))
7505 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7506 &host_ip4_addr, &host_ip4_prefix_len))
7508 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7509 &host_ip6_addr, &host_ip6_prefix_len))
7511 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7513 host_ip4_gw_set = 1;
7514 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7516 host_ip6_gw_set = 1;
7517 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7519 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7525 if (vec_len (host_if_name) > 63)
7527 errmsg ("tap name too long. ");
7530 if (vec_len (host_ns) > 63)
7532 errmsg ("host name space too long. ");
7535 if (vec_len (host_bridge) > 63)
7537 errmsg ("host bridge name too long. ");
7540 if (host_ip4_prefix_len > 32)
7542 errmsg ("host ip4 prefix length not valid. ");
7545 if (host_ip6_prefix_len > 128)
7547 errmsg ("host ip6 prefix length not valid. ");
7550 if (!is_pow2 (rx_ring_sz))
7552 errmsg ("rx ring size must be power of 2. ");
7555 if (rx_ring_sz > 32768)
7557 errmsg ("rx ring size must be 32768 or lower. ");
7560 if (!is_pow2 (tx_ring_sz))
7562 errmsg ("tx ring size must be power of 2. ");
7565 if (tx_ring_sz > 32768)
7567 errmsg ("tx ring size must be 32768 or lower. ");
7571 /* Construct the API message */
7572 M (TAP_CREATE_V2, mp);
7574 mp->use_random_mac = random_mac;
7576 mp->id = ntohl (id);
7577 mp->host_namespace_set = host_ns != 0;
7578 mp->host_bridge_set = host_bridge != 0;
7579 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7580 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7581 mp->rx_ring_sz = ntohs (rx_ring_sz);
7582 mp->tx_ring_sz = ntohs (tx_ring_sz);
7584 if (random_mac == 0)
7585 clib_memcpy (mp->mac_address, mac_address, 6);
7586 if (host_mac_addr_set)
7587 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7589 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7591 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7593 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7594 if (host_ip4_prefix_len)
7595 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7596 if (host_ip6_prefix_len)
7597 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7598 if (host_ip4_gw_set)
7599 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7600 if (host_ip6_gw_set)
7601 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7604 vec_free (host_if_name);
7605 vec_free (host_bridge);
7610 /* Wait for a reply... */
7616 api_tap_delete_v2 (vat_main_t * vam)
7618 unformat_input_t *i = vam->input;
7619 vl_api_tap_delete_v2_t *mp;
7620 u32 sw_if_index = ~0;
7621 u8 sw_if_index_set = 0;
7624 /* Parse args required to build the message */
7625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7627 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7628 sw_if_index_set = 1;
7629 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7630 sw_if_index_set = 1;
7635 if (sw_if_index_set == 0)
7637 errmsg ("missing vpp interface name. ");
7641 /* Construct the API message */
7642 M (TAP_DELETE_V2, mp);
7644 mp->sw_if_index = ntohl (sw_if_index);
7649 /* Wait for a reply... */
7655 unformat_pci_addr (unformat_input_t * input, va_list * args)
7664 addr = va_arg (*args, struct pci_addr_t *);
7667 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7670 addr->domain = x[0];
7673 addr->function = x[3];
7679 api_virtio_pci_create (vat_main_t * vam)
7681 unformat_input_t *i = vam->input;
7682 vl_api_virtio_pci_create_t *mp;
7686 u64 features = (u64) ~ (0ULL);
7687 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7690 clib_memset (mac_address, 0, sizeof (mac_address));
7692 /* Parse args required to build the message */
7693 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7695 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7699 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7701 else if (unformat (i, "features 0x%llx", &features))
7703 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7705 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7713 errmsg ("pci address must be non zero. ");
7716 if (!is_pow2 (rx_ring_sz))
7718 errmsg ("rx ring size must be power of 2. ");
7721 if (rx_ring_sz > 32768)
7723 errmsg ("rx ring size must be 32768 or lower. ");
7726 if (!is_pow2 (tx_ring_sz))
7728 errmsg ("tx ring size must be power of 2. ");
7731 if (tx_ring_sz > 32768)
7733 errmsg ("tx ring size must be 32768 or lower. ");
7737 /* Construct the API message */
7738 M (VIRTIO_PCI_CREATE, mp);
7740 mp->use_random_mac = random_mac;
7742 mp->pci_addr = htonl (pci_addr);
7743 mp->features = clib_host_to_net_u64 (features);
7745 if (random_mac == 0)
7746 clib_memcpy (mp->mac_address, mac_address, 6);
7751 /* Wait for a reply... */
7757 api_virtio_pci_delete (vat_main_t * vam)
7759 unformat_input_t *i = vam->input;
7760 vl_api_virtio_pci_delete_t *mp;
7761 u32 sw_if_index = ~0;
7762 u8 sw_if_index_set = 0;
7765 /* Parse args required to build the message */
7766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7769 sw_if_index_set = 1;
7770 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7771 sw_if_index_set = 1;
7776 if (sw_if_index_set == 0)
7778 errmsg ("missing vpp interface name. ");
7782 /* Construct the API message */
7783 M (VIRTIO_PCI_DELETE, mp);
7785 mp->sw_if_index = htonl (sw_if_index);
7790 /* Wait for a reply... */
7796 api_bond_create (vat_main_t * vam)
7798 unformat_input_t *i = vam->input;
7799 vl_api_bond_create_t *mp;
7808 clib_memset (mac_address, 0, sizeof (mac_address));
7811 /* Parse args required to build the message */
7812 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7814 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7816 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7817 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7819 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7822 else if (unformat (i, "id %u", &id))
7828 if (mode_is_set == 0)
7830 errmsg ("Missing bond mode. ");
7834 /* Construct the API message */
7835 M (BOND_CREATE, mp);
7837 mp->use_custom_mac = custom_mac;
7841 mp->id = htonl (id);
7844 clib_memcpy (mp->mac_address, mac_address, 6);
7849 /* Wait for a reply... */
7855 api_bond_delete (vat_main_t * vam)
7857 unformat_input_t *i = vam->input;
7858 vl_api_bond_delete_t *mp;
7859 u32 sw_if_index = ~0;
7860 u8 sw_if_index_set = 0;
7863 /* Parse args required to build the message */
7864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7866 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7867 sw_if_index_set = 1;
7868 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7869 sw_if_index_set = 1;
7874 if (sw_if_index_set == 0)
7876 errmsg ("missing vpp interface name. ");
7880 /* Construct the API message */
7881 M (BOND_DELETE, mp);
7883 mp->sw_if_index = ntohl (sw_if_index);
7888 /* Wait for a reply... */
7894 api_bond_enslave (vat_main_t * vam)
7896 unformat_input_t *i = vam->input;
7897 vl_api_bond_enslave_t *mp;
7898 u32 bond_sw_if_index;
7902 u32 bond_sw_if_index_is_set = 0;
7904 u8 sw_if_index_is_set = 0;
7906 /* Parse args required to build the message */
7907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7909 if (unformat (i, "sw_if_index %d", &sw_if_index))
7910 sw_if_index_is_set = 1;
7911 else if (unformat (i, "bond %u", &bond_sw_if_index))
7912 bond_sw_if_index_is_set = 1;
7913 else if (unformat (i, "passive %d", &is_passive))
7915 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7921 if (bond_sw_if_index_is_set == 0)
7923 errmsg ("Missing bond sw_if_index. ");
7926 if (sw_if_index_is_set == 0)
7928 errmsg ("Missing slave sw_if_index. ");
7932 /* Construct the API message */
7933 M (BOND_ENSLAVE, mp);
7935 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7936 mp->sw_if_index = ntohl (sw_if_index);
7937 mp->is_long_timeout = is_long_timeout;
7938 mp->is_passive = is_passive;
7943 /* Wait for a reply... */
7949 api_bond_detach_slave (vat_main_t * vam)
7951 unformat_input_t *i = vam->input;
7952 vl_api_bond_detach_slave_t *mp;
7953 u32 sw_if_index = ~0;
7954 u8 sw_if_index_set = 0;
7957 /* Parse args required to build the message */
7958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7961 sw_if_index_set = 1;
7962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7963 sw_if_index_set = 1;
7968 if (sw_if_index_set == 0)
7970 errmsg ("missing vpp interface name. ");
7974 /* Construct the API message */
7975 M (BOND_DETACH_SLAVE, mp);
7977 mp->sw_if_index = ntohl (sw_if_index);
7982 /* Wait for a reply... */
7988 api_ip_table_add_del (vat_main_t * vam)
7990 unformat_input_t *i = vam->input;
7991 vl_api_ip_table_add_del_t *mp;
7997 /* Parse args required to build the message */
7998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8000 if (unformat (i, "ipv6"))
8002 else if (unformat (i, "del"))
8004 else if (unformat (i, "add"))
8006 else if (unformat (i, "table %d", &table_id))
8010 clib_warning ("parse error '%U'", format_unformat_error, i);
8017 errmsg ("missing table-ID");
8021 /* Construct the API message */
8022 M (IP_TABLE_ADD_DEL, mp);
8024 mp->table_id = ntohl (table_id);
8025 mp->is_ipv6 = is_ipv6;
8026 mp->is_add = is_add;
8031 /* Wait for a reply... */
8038 api_ip_add_del_route (vat_main_t * vam)
8040 unformat_input_t *i = vam->input;
8041 vl_api_ip_add_del_route_t *mp;
8042 u32 sw_if_index = ~0, vrf_id = 0;
8044 u8 is_local = 0, is_drop = 0;
8045 u8 is_unreach = 0, is_prohibit = 0;
8047 u32 next_hop_weight = 1;
8048 u8 is_multipath = 0;
8050 u8 address_length_set = 0;
8051 u32 next_hop_table_id = 0;
8052 u32 resolve_attempts = 0;
8053 u32 dst_address_length = 0;
8054 u8 next_hop_set = 0;
8055 ip4_address_t v4_dst_address, v4_next_hop_address;
8056 ip6_address_t v6_dst_address, v6_next_hop_address;
8060 u32 random_add_del = 0;
8061 u32 *random_vector = 0;
8063 u32 random_seed = 0xdeaddabe;
8064 u32 classify_table_index = ~0;
8066 u8 resolve_host = 0, resolve_attached = 0;
8067 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8068 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8069 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8071 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8072 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8073 /* Parse args required to build the message */
8074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8076 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8078 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8080 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8085 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8090 else if (unformat (i, "/%d", &dst_address_length))
8092 address_length_set = 1;
8095 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8096 &v4_next_hop_address))
8100 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8101 &v6_next_hop_address))
8107 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8111 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8115 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8117 else if (unformat (i, "weight %d", &next_hop_weight))
8119 else if (unformat (i, "drop"))
8123 else if (unformat (i, "null-send-unreach"))
8127 else if (unformat (i, "null-send-prohibit"))
8131 else if (unformat (i, "local"))
8135 else if (unformat (i, "classify %d", &classify_table_index))
8139 else if (unformat (i, "del"))
8141 else if (unformat (i, "add"))
8143 else if (unformat (i, "resolve-via-host"))
8145 else if (unformat (i, "resolve-via-attached"))
8146 resolve_attached = 1;
8147 else if (unformat (i, "multipath"))
8149 else if (unformat (i, "vrf %d", &vrf_id))
8151 else if (unformat (i, "count %d", &count))
8153 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8155 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8157 else if (unformat (i, "out-label %d", &next_hop_out_label))
8159 vl_api_fib_mpls_label_t fib_label = {
8160 .label = ntohl (next_hop_out_label),
8164 vec_add1 (next_hop_out_label_stack, fib_label);
8166 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8168 else if (unformat (i, "random"))
8170 else if (unformat (i, "seed %d", &random_seed))
8174 clib_warning ("parse error '%U'", format_unformat_error, i);
8179 if (!next_hop_set && !is_drop && !is_local &&
8180 !is_classify && !is_unreach && !is_prohibit &&
8181 MPLS_LABEL_INVALID == next_hop_via_label)
8184 ("next hop / local / drop / unreach / prohibit / classify not set");
8188 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8190 errmsg ("next hop and next-hop via label set");
8193 if (address_set == 0)
8195 errmsg ("missing addresses");
8199 if (address_length_set == 0)
8201 errmsg ("missing address length");
8205 /* Generate a pile of unique, random routes */
8208 u32 this_random_address;
8209 random_hash = hash_create (count, sizeof (uword));
8211 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8212 for (j = 0; j <= count; j++)
8216 this_random_address = random_u32 (&random_seed);
8217 this_random_address =
8218 clib_host_to_net_u32 (this_random_address);
8220 while (hash_get (random_hash, this_random_address));
8221 vec_add1 (random_vector, this_random_address);
8222 hash_set (random_hash, this_random_address, 1);
8224 hash_free (random_hash);
8225 v4_dst_address.as_u32 = random_vector[0];
8230 /* Turn on async mode */
8231 vam->async_mode = 1;
8232 vam->async_errors = 0;
8233 before = vat_time_now (vam);
8236 for (j = 0; j < count; j++)
8238 /* Construct the API message */
8239 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8240 vec_len (next_hop_out_label_stack));
8242 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8243 mp->table_id = ntohl (vrf_id);
8245 mp->is_add = is_add;
8246 mp->is_drop = is_drop;
8247 mp->is_unreach = is_unreach;
8248 mp->is_prohibit = is_prohibit;
8249 mp->is_ipv6 = is_ipv6;
8250 mp->is_local = is_local;
8251 mp->is_classify = is_classify;
8252 mp->is_multipath = is_multipath;
8253 mp->is_resolve_host = resolve_host;
8254 mp->is_resolve_attached = resolve_attached;
8255 mp->next_hop_weight = next_hop_weight;
8256 mp->next_hop_preference = 0;
8257 mp->dst_address_length = dst_address_length;
8258 mp->next_hop_table_id = ntohl (next_hop_table_id);
8259 mp->classify_table_index = ntohl (classify_table_index);
8260 mp->next_hop_via_label = ntohl (next_hop_via_label);
8261 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8262 if (0 != mp->next_hop_n_out_labels)
8264 memcpy (mp->next_hop_out_label_stack,
8265 next_hop_out_label_stack,
8266 (vec_len (next_hop_out_label_stack) *
8267 sizeof (vl_api_fib_mpls_label_t)));
8268 vec_free (next_hop_out_label_stack);
8273 clib_memcpy (mp->dst_address, &v6_dst_address,
8274 sizeof (v6_dst_address));
8276 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8277 sizeof (v6_next_hop_address));
8278 increment_v6_address (&v6_dst_address);
8282 clib_memcpy (mp->dst_address, &v4_dst_address,
8283 sizeof (v4_dst_address));
8285 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8286 sizeof (v4_next_hop_address));
8288 v4_dst_address.as_u32 = random_vector[j + 1];
8290 increment_v4_address (&v4_dst_address);
8294 /* If we receive SIGTERM, stop now... */
8299 /* When testing multiple add/del ops, use a control-ping to sync */
8302 vl_api_control_ping_t *mp_ping;
8306 /* Shut off async mode */
8307 vam->async_mode = 0;
8309 MPING (CONTROL_PING, mp_ping);
8312 timeout = vat_time_now (vam) + 1.0;
8313 while (vat_time_now (vam) < timeout)
8314 if (vam->result_ready == 1)
8319 if (vam->retval == -99)
8322 if (vam->async_errors > 0)
8324 errmsg ("%d asynchronous errors", vam->async_errors);
8327 vam->async_errors = 0;
8328 after = vat_time_now (vam);
8330 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8334 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8335 count, after - before, count / (after - before));
8341 /* Wait for a reply... */
8346 /* Return the good/bad news */
8347 return (vam->retval);
8351 api_ip_mroute_add_del (vat_main_t * vam)
8353 unformat_input_t *i = vam->input;
8354 vl_api_ip_mroute_add_del_t *mp;
8355 u32 sw_if_index = ~0, vrf_id = 0;
8360 u32 grp_address_length = 0;
8361 ip4_address_t v4_grp_address, v4_src_address;
8362 ip6_address_t v6_grp_address, v6_src_address;
8363 mfib_itf_flags_t iflags = 0;
8364 mfib_entry_flags_t eflags = 0;
8367 /* Parse args required to build the message */
8368 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8370 if (unformat (i, "sw_if_index %d", &sw_if_index))
8372 else if (unformat (i, "%U %U",
8373 unformat_ip4_address, &v4_src_address,
8374 unformat_ip4_address, &v4_grp_address))
8376 grp_address_length = 64;
8380 else if (unformat (i, "%U %U",
8381 unformat_ip6_address, &v6_src_address,
8382 unformat_ip6_address, &v6_grp_address))
8384 grp_address_length = 256;
8388 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8390 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8391 grp_address_length = 32;
8395 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8397 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8398 grp_address_length = 128;
8402 else if (unformat (i, "/%d", &grp_address_length))
8404 else if (unformat (i, "local"))
8408 else if (unformat (i, "del"))
8410 else if (unformat (i, "add"))
8412 else if (unformat (i, "vrf %d", &vrf_id))
8414 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8416 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8420 clib_warning ("parse error '%U'", format_unformat_error, i);
8425 if (address_set == 0)
8427 errmsg ("missing addresses\n");
8431 /* Construct the API message */
8432 M (IP_MROUTE_ADD_DEL, mp);
8434 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8435 mp->table_id = ntohl (vrf_id);
8437 mp->is_add = is_add;
8438 mp->is_ipv6 = is_ipv6;
8439 mp->is_local = is_local;
8440 mp->itf_flags = ntohl (iflags);
8441 mp->entry_flags = ntohl (eflags);
8442 mp->grp_address_length = grp_address_length;
8443 mp->grp_address_length = ntohs (mp->grp_address_length);
8447 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8448 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8452 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8453 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8459 /* Wait for a reply... */
8465 api_mpls_table_add_del (vat_main_t * vam)
8467 unformat_input_t *i = vam->input;
8468 vl_api_mpls_table_add_del_t *mp;
8473 /* Parse args required to build the message */
8474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8476 if (unformat (i, "table %d", &table_id))
8478 else if (unformat (i, "del"))
8480 else if (unformat (i, "add"))
8484 clib_warning ("parse error '%U'", format_unformat_error, i);
8491 errmsg ("missing table-ID");
8495 /* Construct the API message */
8496 M (MPLS_TABLE_ADD_DEL, mp);
8498 mp->mt_table_id = ntohl (table_id);
8499 mp->mt_is_add = is_add;
8504 /* Wait for a reply... */
8511 api_mpls_route_add_del (vat_main_t * vam)
8513 unformat_input_t *i = vam->input;
8514 vl_api_mpls_route_add_del_t *mp;
8515 u32 sw_if_index = ~0, table_id = 0;
8517 u32 next_hop_weight = 1;
8518 u8 is_multipath = 0;
8519 u32 next_hop_table_id = 0;
8520 u8 next_hop_set = 0;
8521 ip4_address_t v4_next_hop_address = {
8524 ip6_address_t v6_next_hop_address = { {0} };
8528 u32 classify_table_index = ~0;
8530 u8 resolve_host = 0, resolve_attached = 0;
8531 u8 is_interface_rx = 0;
8532 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8533 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8534 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8535 mpls_label_t local_label = MPLS_LABEL_INVALID;
8537 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8539 /* Parse args required to build the message */
8540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8546 else if (unformat (i, "%d", &local_label))
8548 else if (unformat (i, "eos"))
8550 else if (unformat (i, "non-eos"))
8552 else if (unformat (i, "via %U", unformat_ip4_address,
8553 &v4_next_hop_address))
8556 next_hop_proto = DPO_PROTO_IP4;
8558 else if (unformat (i, "via %U", unformat_ip6_address,
8559 &v6_next_hop_address))
8562 next_hop_proto = DPO_PROTO_IP6;
8564 else if (unformat (i, "weight %d", &next_hop_weight))
8566 else if (unformat (i, "classify %d", &classify_table_index))
8570 else if (unformat (i, "del"))
8572 else if (unformat (i, "add"))
8574 else if (unformat (i, "resolve-via-host"))
8576 else if (unformat (i, "resolve-via-attached"))
8577 resolve_attached = 1;
8578 else if (unformat (i, "multipath"))
8580 else if (unformat (i, "count %d", &count))
8582 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8585 next_hop_proto = DPO_PROTO_IP4;
8587 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8590 next_hop_proto = DPO_PROTO_IP6;
8594 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8598 next_hop_proto = DPO_PROTO_ETHERNET;
8599 is_interface_rx = 1;
8601 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8604 next_hop_proto = DPO_PROTO_ETHERNET;
8605 is_interface_rx = 1;
8607 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8609 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8611 else if (unformat (i, "out-label %d", &next_hop_out_label))
8613 vl_api_fib_mpls_label_t fib_label = {
8614 .label = ntohl (next_hop_out_label),
8618 vec_add1 (next_hop_out_label_stack, fib_label);
8622 clib_warning ("parse error '%U'", format_unformat_error, i);
8627 if (!next_hop_set && !is_classify)
8629 errmsg ("next hop / classify not set");
8633 if (MPLS_LABEL_INVALID == local_label)
8635 errmsg ("missing label");
8641 /* Turn on async mode */
8642 vam->async_mode = 1;
8643 vam->async_errors = 0;
8644 before = vat_time_now (vam);
8647 for (j = 0; j < count; j++)
8649 /* Construct the API message */
8650 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8651 vec_len (next_hop_out_label_stack));
8653 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8654 mp->mr_table_id = ntohl (table_id);
8656 mp->mr_is_add = is_add;
8657 mp->mr_next_hop_proto = next_hop_proto;
8658 mp->mr_is_classify = is_classify;
8659 mp->mr_is_multipath = is_multipath;
8660 mp->mr_is_resolve_host = resolve_host;
8661 mp->mr_is_resolve_attached = resolve_attached;
8662 mp->mr_is_interface_rx = is_interface_rx;
8663 mp->mr_next_hop_weight = next_hop_weight;
8664 mp->mr_next_hop_preference = 0;
8665 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8666 mp->mr_classify_table_index = ntohl (classify_table_index);
8667 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8668 mp->mr_label = ntohl (local_label);
8669 mp->mr_eos = is_eos;
8671 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8672 if (0 != mp->mr_next_hop_n_out_labels)
8674 memcpy (mp->mr_next_hop_out_label_stack,
8675 next_hop_out_label_stack,
8676 vec_len (next_hop_out_label_stack) *
8677 sizeof (vl_api_fib_mpls_label_t));
8678 vec_free (next_hop_out_label_stack);
8683 if (DPO_PROTO_IP4 == next_hop_proto)
8685 clib_memcpy (mp->mr_next_hop,
8686 &v4_next_hop_address,
8687 sizeof (v4_next_hop_address));
8689 else if (DPO_PROTO_IP6 == next_hop_proto)
8692 clib_memcpy (mp->mr_next_hop,
8693 &v6_next_hop_address,
8694 sizeof (v6_next_hop_address));
8701 /* If we receive SIGTERM, stop now... */
8706 /* When testing multiple add/del ops, use a control-ping to sync */
8709 vl_api_control_ping_t *mp_ping;
8713 /* Shut off async mode */
8714 vam->async_mode = 0;
8716 MPING (CONTROL_PING, mp_ping);
8719 timeout = vat_time_now (vam) + 1.0;
8720 while (vat_time_now (vam) < timeout)
8721 if (vam->result_ready == 1)
8726 if (vam->retval == -99)
8729 if (vam->async_errors > 0)
8731 errmsg ("%d asynchronous errors", vam->async_errors);
8734 vam->async_errors = 0;
8735 after = vat_time_now (vam);
8737 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8741 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8742 count, after - before, count / (after - before));
8748 /* Wait for a reply... */
8753 /* Return the good/bad news */
8754 return (vam->retval);
8758 api_mpls_ip_bind_unbind (vat_main_t * vam)
8760 unformat_input_t *i = vam->input;
8761 vl_api_mpls_ip_bind_unbind_t *mp;
8762 u32 ip_table_id = 0;
8765 ip4_address_t v4_address;
8766 ip6_address_t v6_address;
8769 mpls_label_t local_label = MPLS_LABEL_INVALID;
8772 /* Parse args required to build the message */
8773 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8775 if (unformat (i, "%U/%d", unformat_ip4_address,
8776 &v4_address, &address_length))
8781 else if (unformat (i, "%U/%d", unformat_ip6_address,
8782 &v6_address, &address_length))
8787 else if (unformat (i, "%d", &local_label))
8789 else if (unformat (i, "table-id %d", &ip_table_id))
8791 else if (unformat (i, "unbind"))
8793 else if (unformat (i, "bind"))
8797 clib_warning ("parse error '%U'", format_unformat_error, i);
8804 errmsg ("IP address not set");
8808 if (MPLS_LABEL_INVALID == local_label)
8810 errmsg ("missing label");
8814 /* Construct the API message */
8815 M (MPLS_IP_BIND_UNBIND, mp);
8817 mp->mb_is_bind = is_bind;
8818 mp->mb_is_ip4 = is_ip4;
8819 mp->mb_ip_table_id = ntohl (ip_table_id);
8820 mp->mb_mpls_table_id = 0;
8821 mp->mb_label = ntohl (local_label);
8822 mp->mb_address_length = address_length;
8825 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8827 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8832 /* Wait for a reply... */
8838 api_sr_mpls_policy_add (vat_main_t * vam)
8840 unformat_input_t *i = vam->input;
8841 vl_api_sr_mpls_policy_add_t *mp;
8847 u32 *segments = NULL;
8850 /* Parse args required to build the message */
8851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8853 if (unformat (i, "bsid %d", &bsid))
8855 else if (unformat (i, "weight %d", &weight))
8857 else if (unformat (i, "spray"))
8859 else if (unformat (i, "next %d", &sid))
8862 vec_add1 (segments, htonl (sid));
8866 clib_warning ("parse error '%U'", format_unformat_error, i);
8873 errmsg ("bsid not set");
8877 if (n_segments == 0)
8879 errmsg ("no sid in segment stack");
8883 /* Construct the API message */
8884 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8886 mp->bsid = htonl (bsid);
8887 mp->weight = htonl (weight);
8889 mp->n_segments = n_segments;
8890 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8891 vec_free (segments);
8896 /* Wait for a reply... */
8902 api_sr_mpls_policy_del (vat_main_t * vam)
8904 unformat_input_t *i = vam->input;
8905 vl_api_sr_mpls_policy_del_t *mp;
8909 /* Parse args required to build the message */
8910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8912 if (unformat (i, "bsid %d", &bsid))
8916 clib_warning ("parse error '%U'", format_unformat_error, i);
8923 errmsg ("bsid not set");
8927 /* Construct the API message */
8928 M (SR_MPLS_POLICY_DEL, mp);
8930 mp->bsid = htonl (bsid);
8935 /* Wait for a reply... */
8941 api_bier_table_add_del (vat_main_t * vam)
8943 unformat_input_t *i = vam->input;
8944 vl_api_bier_table_add_del_t *mp;
8946 u32 set = 0, sub_domain = 0, hdr_len = 3;
8947 mpls_label_t local_label = MPLS_LABEL_INVALID;
8950 /* Parse args required to build the message */
8951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8953 if (unformat (i, "sub-domain %d", &sub_domain))
8955 else if (unformat (i, "set %d", &set))
8957 else if (unformat (i, "label %d", &local_label))
8959 else if (unformat (i, "hdr-len %d", &hdr_len))
8961 else if (unformat (i, "add"))
8963 else if (unformat (i, "del"))
8967 clib_warning ("parse error '%U'", format_unformat_error, i);
8972 if (MPLS_LABEL_INVALID == local_label)
8974 errmsg ("missing label\n");
8978 /* Construct the API message */
8979 M (BIER_TABLE_ADD_DEL, mp);
8981 mp->bt_is_add = is_add;
8982 mp->bt_label = ntohl (local_label);
8983 mp->bt_tbl_id.bt_set = set;
8984 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8985 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8990 /* Wait for a reply... */
8997 api_bier_route_add_del (vat_main_t * vam)
8999 unformat_input_t *i = vam->input;
9000 vl_api_bier_route_add_del_t *mp;
9002 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
9003 ip4_address_t v4_next_hop_address;
9004 ip6_address_t v6_next_hop_address;
9005 u8 next_hop_set = 0;
9006 u8 next_hop_proto_is_ip4 = 1;
9007 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9010 /* Parse args required to build the message */
9011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9013 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9015 next_hop_proto_is_ip4 = 1;
9018 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9020 next_hop_proto_is_ip4 = 0;
9023 if (unformat (i, "sub-domain %d", &sub_domain))
9025 else if (unformat (i, "set %d", &set))
9027 else if (unformat (i, "hdr-len %d", &hdr_len))
9029 else if (unformat (i, "bp %d", &bp))
9031 else if (unformat (i, "add"))
9033 else if (unformat (i, "del"))
9035 else if (unformat (i, "out-label %d", &next_hop_out_label))
9039 clib_warning ("parse error '%U'", format_unformat_error, i);
9044 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9046 errmsg ("next hop / label set\n");
9051 errmsg ("bit=position not set\n");
9055 /* Construct the API message */
9056 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9058 mp->br_is_add = is_add;
9059 mp->br_tbl_id.bt_set = set;
9060 mp->br_tbl_id.bt_sub_domain = sub_domain;
9061 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9062 mp->br_bp = ntohs (bp);
9064 mp->br_paths[0].n_labels = 1;
9065 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9066 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9068 if (next_hop_proto_is_ip4)
9070 clib_memcpy (mp->br_paths[0].next_hop,
9071 &v4_next_hop_address, sizeof (v4_next_hop_address));
9075 clib_memcpy (mp->br_paths[0].next_hop,
9076 &v6_next_hop_address, sizeof (v6_next_hop_address));
9082 /* Wait for a reply... */
9089 api_proxy_arp_add_del (vat_main_t * vam)
9091 unformat_input_t *i = vam->input;
9092 vl_api_proxy_arp_add_del_t *mp;
9095 vl_api_ip4_address_t lo, hi;
9099 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9101 if (unformat (i, "vrf %d", &vrf_id))
9103 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
9104 unformat_vl_api_ip4_address, &hi))
9106 else if (unformat (i, "del"))
9110 clib_warning ("parse error '%U'", format_unformat_error, i);
9117 errmsg ("address range not set");
9121 M (PROXY_ARP_ADD_DEL, mp);
9123 mp->proxy.table_id = ntohl (vrf_id);
9124 mp->is_add = is_add;
9125 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
9126 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
9134 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9136 unformat_input_t *i = vam->input;
9137 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9140 u8 sw_if_index_set = 0;
9143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9146 sw_if_index_set = 1;
9147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9148 sw_if_index_set = 1;
9149 else if (unformat (i, "enable"))
9151 else if (unformat (i, "disable"))
9155 clib_warning ("parse error '%U'", format_unformat_error, i);
9160 if (sw_if_index_set == 0)
9162 errmsg ("missing interface name or sw_if_index");
9166 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9168 mp->sw_if_index = ntohl (sw_if_index);
9169 mp->enable_disable = enable;
9177 api_mpls_tunnel_add_del (vat_main_t * vam)
9179 unformat_input_t *i = vam->input;
9180 vl_api_mpls_tunnel_add_del_t *mp;
9184 u32 sw_if_index = ~0;
9185 u32 next_hop_sw_if_index = ~0;
9186 u32 next_hop_proto_is_ip4 = 1;
9188 u32 next_hop_table_id = 0;
9189 ip4_address_t v4_next_hop_address = {
9192 ip6_address_t v6_next_hop_address = { {0} };
9193 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9194 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9195 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9198 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9200 if (unformat (i, "add"))
9204 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9206 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9208 else if (unformat (i, "via %U",
9209 unformat_ip4_address, &v4_next_hop_address))
9211 next_hop_proto_is_ip4 = 1;
9213 else if (unformat (i, "via %U",
9214 unformat_ip6_address, &v6_next_hop_address))
9216 next_hop_proto_is_ip4 = 0;
9218 else if (unformat (i, "via-label %d", &next_hop_via_label))
9222 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9224 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9226 else if (unformat (i, "l2-only"))
9228 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9230 else if (unformat (i, "out-label %d", &next_hop_out_label))
9232 vl_api_fib_mpls_label_t fib_label = {
9233 .label = ntohl (next_hop_out_label),
9237 vec_add1 (next_hop_out_label_stack, fib_label);
9241 clib_warning ("parse error '%U'", format_unformat_error, i);
9246 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9247 vec_len (next_hop_out_label_stack));
9249 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9250 mp->mt_sw_if_index = ntohl (sw_if_index);
9251 mp->mt_is_add = is_add;
9252 mp->mt_l2_only = l2_only;
9253 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9254 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9255 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9256 mp->mt_next_hop_weight = 1;
9257 mp->mt_next_hop_preference = 0;
9259 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9261 if (0 != mp->mt_next_hop_n_out_labels)
9263 clib_memcpy (mp->mt_next_hop_out_label_stack,
9264 next_hop_out_label_stack,
9265 (vec_len (next_hop_out_label_stack) *
9266 sizeof (vl_api_fib_mpls_label_t)));
9267 vec_free (next_hop_out_label_stack);
9270 if (next_hop_proto_is_ip4)
9272 clib_memcpy (mp->mt_next_hop,
9273 &v4_next_hop_address, sizeof (v4_next_hop_address));
9277 clib_memcpy (mp->mt_next_hop,
9278 &v6_next_hop_address, sizeof (v6_next_hop_address));
9287 api_sw_interface_set_unnumbered (vat_main_t * vam)
9289 unformat_input_t *i = vam->input;
9290 vl_api_sw_interface_set_unnumbered_t *mp;
9292 u32 unnum_sw_index = ~0;
9294 u8 sw_if_index_set = 0;
9297 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9300 sw_if_index_set = 1;
9301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9302 sw_if_index_set = 1;
9303 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9305 else if (unformat (i, "del"))
9309 clib_warning ("parse error '%U'", format_unformat_error, i);
9314 if (sw_if_index_set == 0)
9316 errmsg ("missing interface name or sw_if_index");
9320 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9322 mp->sw_if_index = ntohl (sw_if_index);
9323 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9324 mp->is_add = is_add;
9332 api_ip_neighbor_add_del (vat_main_t * vam)
9334 vl_api_mac_address_t mac_address;
9335 unformat_input_t *i = vam->input;
9336 vl_api_ip_neighbor_add_del_t *mp;
9337 vl_api_address_t ip_address;
9339 u8 sw_if_index_set = 0;
9344 ip_neighbor_flags_t flags;
9346 flags = IP_NEIGHBOR_FLAG_NONE;
9347 clib_memset (&ip_address, 0, sizeof (ip_address));
9348 clib_memset (&mac_address, 0, sizeof (mac_address));
9349 /* Parse args required to build the message */
9350 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9352 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9356 else if (unformat (i, "del"))
9359 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9360 sw_if_index_set = 1;
9361 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9362 sw_if_index_set = 1;
9363 else if (unformat (i, "static"))
9364 flags |= IP_NEIGHBOR_FLAG_STATIC;
9365 else if (unformat (i, "no-fib-entry"))
9366 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9367 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9371 clib_warning ("parse error '%U'", format_unformat_error, i);
9376 if (sw_if_index_set == 0)
9378 errmsg ("missing interface name or sw_if_index");
9383 errmsg ("no address set");
9387 /* Construct the API message */
9388 M (IP_NEIGHBOR_ADD_DEL, mp);
9390 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9391 mp->is_add = is_add;
9392 mp->neighbor.flags = htonl (flags);
9394 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9395 sizeof (mac_address));
9397 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9402 /* Wait for a reply, return good/bad news */
9408 api_create_vlan_subif (vat_main_t * vam)
9410 unformat_input_t *i = vam->input;
9411 vl_api_create_vlan_subif_t *mp;
9413 u8 sw_if_index_set = 0;
9418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9420 if (unformat (i, "sw_if_index %d", &sw_if_index))
9421 sw_if_index_set = 1;
9423 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9424 sw_if_index_set = 1;
9425 else if (unformat (i, "vlan %d", &vlan_id))
9429 clib_warning ("parse error '%U'", format_unformat_error, i);
9434 if (sw_if_index_set == 0)
9436 errmsg ("missing interface name or sw_if_index");
9440 if (vlan_id_set == 0)
9442 errmsg ("missing vlan_id");
9445 M (CREATE_VLAN_SUBIF, mp);
9447 mp->sw_if_index = ntohl (sw_if_index);
9448 mp->vlan_id = ntohl (vlan_id);
9455 #define foreach_create_subif_bit \
9462 _(outer_vlan_id_any) \
9463 _(inner_vlan_id_any)
9466 api_create_subif (vat_main_t * vam)
9468 unformat_input_t *i = vam->input;
9469 vl_api_create_subif_t *mp;
9471 u8 sw_if_index_set = 0;
9478 u32 exact_match = 0;
9479 u32 default_sub = 0;
9480 u32 outer_vlan_id_any = 0;
9481 u32 inner_vlan_id_any = 0;
9483 u16 outer_vlan_id = 0;
9484 u16 inner_vlan_id = 0;
9487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9489 if (unformat (i, "sw_if_index %d", &sw_if_index))
9490 sw_if_index_set = 1;
9492 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9493 sw_if_index_set = 1;
9494 else if (unformat (i, "sub_id %d", &sub_id))
9496 else if (unformat (i, "outer_vlan_id %d", &tmp))
9497 outer_vlan_id = tmp;
9498 else if (unformat (i, "inner_vlan_id %d", &tmp))
9499 inner_vlan_id = tmp;
9501 #define _(a) else if (unformat (i, #a)) a = 1 ;
9502 foreach_create_subif_bit
9506 clib_warning ("parse error '%U'", format_unformat_error, i);
9511 if (sw_if_index_set == 0)
9513 errmsg ("missing interface name or sw_if_index");
9517 if (sub_id_set == 0)
9519 errmsg ("missing sub_id");
9522 M (CREATE_SUBIF, mp);
9524 mp->sw_if_index = ntohl (sw_if_index);
9525 mp->sub_id = ntohl (sub_id);
9527 #define _(a) mp->a = a;
9528 foreach_create_subif_bit;
9531 mp->outer_vlan_id = ntohs (outer_vlan_id);
9532 mp->inner_vlan_id = ntohs (inner_vlan_id);
9540 api_oam_add_del (vat_main_t * vam)
9542 unformat_input_t *i = vam->input;
9543 vl_api_oam_add_del_t *mp;
9546 ip4_address_t src, dst;
9551 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9553 if (unformat (i, "vrf %d", &vrf_id))
9555 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9557 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9559 else if (unformat (i, "del"))
9563 clib_warning ("parse error '%U'", format_unformat_error, i);
9570 errmsg ("missing src addr");
9576 errmsg ("missing dst addr");
9580 M (OAM_ADD_DEL, mp);
9582 mp->vrf_id = ntohl (vrf_id);
9583 mp->is_add = is_add;
9584 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9585 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9593 api_reset_fib (vat_main_t * vam)
9595 unformat_input_t *i = vam->input;
9596 vl_api_reset_fib_t *mp;
9602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9604 if (unformat (i, "vrf %d", &vrf_id))
9606 else if (unformat (i, "ipv6"))
9610 clib_warning ("parse error '%U'", format_unformat_error, i);
9615 if (vrf_id_set == 0)
9617 errmsg ("missing vrf id");
9623 mp->vrf_id = ntohl (vrf_id);
9624 mp->is_ipv6 = is_ipv6;
9632 api_dhcp_proxy_config (vat_main_t * vam)
9634 unformat_input_t *i = vam->input;
9635 vl_api_dhcp_proxy_config_t *mp;
9637 u32 server_vrf_id = 0;
9639 u8 v4_address_set = 0;
9640 u8 v6_address_set = 0;
9641 ip4_address_t v4address;
9642 ip6_address_t v6address;
9643 u8 v4_src_address_set = 0;
9644 u8 v6_src_address_set = 0;
9645 ip4_address_t v4srcaddress;
9646 ip6_address_t v6srcaddress;
9649 /* Parse args required to build the message */
9650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9652 if (unformat (i, "del"))
9654 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9656 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9658 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9660 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9662 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9663 v4_src_address_set = 1;
9664 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9665 v6_src_address_set = 1;
9670 if (v4_address_set && v6_address_set)
9672 errmsg ("both v4 and v6 server addresses set");
9675 if (!v4_address_set && !v6_address_set)
9677 errmsg ("no server addresses set");
9681 if (v4_src_address_set && v6_src_address_set)
9683 errmsg ("both v4 and v6 src addresses set");
9686 if (!v4_src_address_set && !v6_src_address_set)
9688 errmsg ("no src addresses set");
9692 if (!(v4_src_address_set && v4_address_set) &&
9693 !(v6_src_address_set && v6_address_set))
9695 errmsg ("no matching server and src addresses set");
9699 /* Construct the API message */
9700 M (DHCP_PROXY_CONFIG, mp);
9702 mp->is_add = is_add;
9703 mp->rx_vrf_id = ntohl (rx_vrf_id);
9704 mp->server_vrf_id = ntohl (server_vrf_id);
9708 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9709 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9713 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9714 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9720 /* Wait for a reply, return good/bad news */
9725 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9726 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9729 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9731 vat_main_t *vam = &vat_main;
9732 u32 i, count = mp->count;
9733 vl_api_dhcp_server_t *s;
9737 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9738 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9739 ntohl (mp->rx_vrf_id),
9740 format_ip6_address, mp->dhcp_src_address,
9741 mp->vss_type, mp->vss_vpn_ascii_id,
9742 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9745 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9746 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9747 ntohl (mp->rx_vrf_id),
9748 format_ip4_address, mp->dhcp_src_address,
9749 mp->vss_type, mp->vss_vpn_ascii_id,
9750 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9752 for (i = 0; i < count; i++)
9754 s = &mp->servers[i];
9758 " Server Table-ID %d, Server Address %U",
9759 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9762 " Server Table-ID %d, Server Address %U",
9763 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9767 static void vl_api_dhcp_proxy_details_t_handler_json
9768 (vl_api_dhcp_proxy_details_t * mp)
9770 vat_main_t *vam = &vat_main;
9771 vat_json_node_t *node = NULL;
9772 u32 i, count = mp->count;
9774 struct in6_addr ip6;
9775 vl_api_dhcp_server_t *s;
9777 if (VAT_JSON_ARRAY != vam->json_tree.type)
9779 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9780 vat_json_init_array (&vam->json_tree);
9782 node = vat_json_array_add (&vam->json_tree);
9784 vat_json_init_object (node);
9785 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9786 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9787 sizeof (mp->vss_type));
9788 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9789 mp->vss_vpn_ascii_id);
9790 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9791 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9795 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9796 vat_json_object_add_ip6 (node, "src_address", ip6);
9800 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9801 vat_json_object_add_ip4 (node, "src_address", ip4);
9804 for (i = 0; i < count; i++)
9806 s = &mp->servers[i];
9808 vat_json_object_add_uint (node, "server-table-id",
9809 ntohl (s->server_vrf_id));
9813 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9814 vat_json_object_add_ip4 (node, "src_address", ip4);
9818 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9819 vat_json_object_add_ip6 (node, "server_address", ip6);
9825 api_dhcp_proxy_dump (vat_main_t * vam)
9827 unformat_input_t *i = vam->input;
9828 vl_api_control_ping_t *mp_ping;
9829 vl_api_dhcp_proxy_dump_t *mp;
9833 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9835 if (unformat (i, "ipv6"))
9839 clib_warning ("parse error '%U'", format_unformat_error, i);
9844 M (DHCP_PROXY_DUMP, mp);
9846 mp->is_ip6 = is_ipv6;
9849 /* Use a control ping for synchronization */
9850 MPING (CONTROL_PING, mp_ping);
9858 api_dhcp_proxy_set_vss (vat_main_t * vam)
9860 unformat_input_t *i = vam->input;
9861 vl_api_dhcp_proxy_set_vss_t *mp;
9865 u8 vss_type = VSS_TYPE_DEFAULT;
9866 u8 *vpn_ascii_id = 0;
9871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9873 if (unformat (i, "tbl_id %d", &tbl_id))
9875 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9876 vss_type = VSS_TYPE_ASCII;
9877 else if (unformat (i, "fib_id %d", &fib_id))
9878 vss_type = VSS_TYPE_VPN_ID;
9879 else if (unformat (i, "oui %d", &oui))
9880 vss_type = VSS_TYPE_VPN_ID;
9881 else if (unformat (i, "ipv6"))
9883 else if (unformat (i, "del"))
9891 errmsg ("missing tbl_id ");
9892 vec_free (vpn_ascii_id);
9896 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9898 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9899 vec_free (vpn_ascii_id);
9903 M (DHCP_PROXY_SET_VSS, mp);
9904 mp->tbl_id = ntohl (tbl_id);
9905 mp->vss_type = vss_type;
9908 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9909 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9911 mp->vpn_index = ntohl (fib_id);
9912 mp->oui = ntohl (oui);
9913 mp->is_ipv6 = is_ipv6;
9914 mp->is_add = is_add;
9919 vec_free (vpn_ascii_id);
9924 api_dhcp_client_config (vat_main_t * vam)
9926 unformat_input_t *i = vam->input;
9927 vl_api_dhcp_client_config_t *mp;
9929 u8 sw_if_index_set = 0;
9932 u8 disable_event = 0;
9935 /* Parse args required to build the message */
9936 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9938 if (unformat (i, "del"))
9941 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9942 sw_if_index_set = 1;
9943 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9944 sw_if_index_set = 1;
9945 else if (unformat (i, "hostname %s", &hostname))
9947 else if (unformat (i, "disable_event"))
9953 if (sw_if_index_set == 0)
9955 errmsg ("missing interface name or sw_if_index");
9959 if (vec_len (hostname) > 63)
9961 errmsg ("hostname too long");
9963 vec_add1 (hostname, 0);
9965 /* Construct the API message */
9966 M (DHCP_CLIENT_CONFIG, mp);
9968 mp->is_add = is_add;
9969 mp->client.sw_if_index = htonl (sw_if_index);
9970 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9971 vec_free (hostname);
9972 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9973 mp->client.pid = htonl (getpid ());
9978 /* Wait for a reply, return good/bad news */
9984 api_set_ip_flow_hash (vat_main_t * vam)
9986 unformat_input_t *i = vam->input;
9987 vl_api_set_ip_flow_hash_t *mp;
9999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10001 if (unformat (i, "vrf %d", &vrf_id))
10003 else if (unformat (i, "ipv6"))
10005 else if (unformat (i, "src"))
10007 else if (unformat (i, "dst"))
10009 else if (unformat (i, "sport"))
10011 else if (unformat (i, "dport"))
10013 else if (unformat (i, "proto"))
10015 else if (unformat (i, "reverse"))
10020 clib_warning ("parse error '%U'", format_unformat_error, i);
10025 if (vrf_id_set == 0)
10027 errmsg ("missing vrf id");
10031 M (SET_IP_FLOW_HASH, mp);
10037 mp->reverse = reverse;
10038 mp->vrf_id = ntohl (vrf_id);
10039 mp->is_ipv6 = is_ipv6;
10047 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10049 unformat_input_t *i = vam->input;
10050 vl_api_sw_interface_ip6_enable_disable_t *mp;
10052 u8 sw_if_index_set = 0;
10056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10058 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10059 sw_if_index_set = 1;
10060 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10061 sw_if_index_set = 1;
10062 else if (unformat (i, "enable"))
10064 else if (unformat (i, "disable"))
10068 clib_warning ("parse error '%U'", format_unformat_error, i);
10073 if (sw_if_index_set == 0)
10075 errmsg ("missing interface name or sw_if_index");
10079 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10081 mp->sw_if_index = ntohl (sw_if_index);
10082 mp->enable = enable;
10090 api_ip6nd_proxy_add_del (vat_main_t * vam)
10092 unformat_input_t *i = vam->input;
10093 vl_api_ip6nd_proxy_add_del_t *mp;
10094 u32 sw_if_index = ~0;
10095 u8 v6_address_set = 0;
10096 vl_api_ip6_address_t v6address;
10100 /* Parse args required to build the message */
10101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10103 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10105 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10107 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
10108 v6_address_set = 1;
10109 if (unformat (i, "del"))
10113 clib_warning ("parse error '%U'", format_unformat_error, i);
10118 if (sw_if_index == ~0)
10120 errmsg ("missing interface name or sw_if_index");
10123 if (!v6_address_set)
10125 errmsg ("no address set");
10129 /* Construct the API message */
10130 M (IP6ND_PROXY_ADD_DEL, mp);
10132 mp->is_del = is_del;
10133 mp->sw_if_index = ntohl (sw_if_index);
10134 clib_memcpy (mp->ip, v6address, sizeof (v6address));
10139 /* Wait for a reply, return good/bad news */
10145 api_ip6nd_proxy_dump (vat_main_t * vam)
10147 vl_api_ip6nd_proxy_dump_t *mp;
10148 vl_api_control_ping_t *mp_ping;
10151 M (IP6ND_PROXY_DUMP, mp);
10155 /* Use a control ping for synchronization */
10156 MPING (CONTROL_PING, mp_ping);
10163 static void vl_api_ip6nd_proxy_details_t_handler
10164 (vl_api_ip6nd_proxy_details_t * mp)
10166 vat_main_t *vam = &vat_main;
10168 print (vam->ofp, "host %U sw_if_index %d",
10169 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
10172 static void vl_api_ip6nd_proxy_details_t_handler_json
10173 (vl_api_ip6nd_proxy_details_t * mp)
10175 vat_main_t *vam = &vat_main;
10176 struct in6_addr ip6;
10177 vat_json_node_t *node = NULL;
10179 if (VAT_JSON_ARRAY != vam->json_tree.type)
10181 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10182 vat_json_init_array (&vam->json_tree);
10184 node = vat_json_array_add (&vam->json_tree);
10186 vat_json_init_object (node);
10187 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10189 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
10190 vat_json_object_add_ip6 (node, "host", ip6);
10194 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10196 unformat_input_t *i = vam->input;
10197 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10199 u8 sw_if_index_set = 0;
10200 u32 address_length = 0;
10201 u8 v6_address_set = 0;
10202 vl_api_prefix_t pfx;
10203 u8 use_default = 0;
10204 u8 no_advertise = 0;
10206 u8 no_autoconfig = 0;
10209 u32 val_lifetime = 0;
10210 u32 pref_lifetime = 0;
10213 /* Parse args required to build the message */
10214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10217 sw_if_index_set = 1;
10218 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10219 sw_if_index_set = 1;
10220 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
10221 v6_address_set = 1;
10222 else if (unformat (i, "val_life %d", &val_lifetime))
10224 else if (unformat (i, "pref_life %d", &pref_lifetime))
10226 else if (unformat (i, "def"))
10228 else if (unformat (i, "noadv"))
10230 else if (unformat (i, "offl"))
10232 else if (unformat (i, "noauto"))
10234 else if (unformat (i, "nolink"))
10236 else if (unformat (i, "isno"))
10240 clib_warning ("parse error '%U'", format_unformat_error, i);
10245 if (sw_if_index_set == 0)
10247 errmsg ("missing interface name or sw_if_index");
10250 if (!v6_address_set)
10252 errmsg ("no address set");
10256 /* Construct the API message */
10257 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10259 mp->sw_if_index = ntohl (sw_if_index);
10260 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
10261 mp->use_default = use_default;
10262 mp->no_advertise = no_advertise;
10263 mp->off_link = off_link;
10264 mp->no_autoconfig = no_autoconfig;
10265 mp->no_onlink = no_onlink;
10267 mp->val_lifetime = ntohl (val_lifetime);
10268 mp->pref_lifetime = ntohl (pref_lifetime);
10273 /* Wait for a reply, return good/bad news */
10279 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10281 unformat_input_t *i = vam->input;
10282 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10284 u8 sw_if_index_set = 0;
10289 u8 send_unicast = 0;
10292 u8 default_router = 0;
10293 u32 max_interval = 0;
10294 u32 min_interval = 0;
10296 u32 initial_count = 0;
10297 u32 initial_interval = 0;
10301 /* Parse args required to build the message */
10302 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10304 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10305 sw_if_index_set = 1;
10306 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10307 sw_if_index_set = 1;
10308 else if (unformat (i, "maxint %d", &max_interval))
10310 else if (unformat (i, "minint %d", &min_interval))
10312 else if (unformat (i, "life %d", &lifetime))
10314 else if (unformat (i, "count %d", &initial_count))
10316 else if (unformat (i, "interval %d", &initial_interval))
10318 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10320 else if (unformat (i, "managed"))
10322 else if (unformat (i, "other"))
10324 else if (unformat (i, "ll"))
10326 else if (unformat (i, "send"))
10328 else if (unformat (i, "cease"))
10330 else if (unformat (i, "isno"))
10332 else if (unformat (i, "def"))
10333 default_router = 1;
10336 clib_warning ("parse error '%U'", format_unformat_error, i);
10341 if (sw_if_index_set == 0)
10343 errmsg ("missing interface name or sw_if_index");
10347 /* Construct the API message */
10348 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10350 mp->sw_if_index = ntohl (sw_if_index);
10351 mp->max_interval = ntohl (max_interval);
10352 mp->min_interval = ntohl (min_interval);
10353 mp->lifetime = ntohl (lifetime);
10354 mp->initial_count = ntohl (initial_count);
10355 mp->initial_interval = ntohl (initial_interval);
10356 mp->suppress = suppress;
10357 mp->managed = managed;
10359 mp->ll_option = ll_option;
10360 mp->send_unicast = send_unicast;
10363 mp->default_router = default_router;
10368 /* Wait for a reply, return good/bad news */
10374 api_set_arp_neighbor_limit (vat_main_t * vam)
10376 unformat_input_t *i = vam->input;
10377 vl_api_set_arp_neighbor_limit_t *mp;
10383 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10385 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10387 else if (unformat (i, "ipv6"))
10391 clib_warning ("parse error '%U'", format_unformat_error, i);
10396 if (limit_set == 0)
10398 errmsg ("missing limit value");
10402 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10404 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10405 mp->is_ipv6 = is_ipv6;
10413 api_l2_patch_add_del (vat_main_t * vam)
10415 unformat_input_t *i = vam->input;
10416 vl_api_l2_patch_add_del_t *mp;
10417 u32 rx_sw_if_index;
10418 u8 rx_sw_if_index_set = 0;
10419 u32 tx_sw_if_index;
10420 u8 tx_sw_if_index_set = 0;
10424 /* Parse args required to build the message */
10425 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10427 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10428 rx_sw_if_index_set = 1;
10429 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10430 tx_sw_if_index_set = 1;
10431 else if (unformat (i, "rx"))
10433 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10435 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10437 rx_sw_if_index_set = 1;
10442 else if (unformat (i, "tx"))
10444 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10446 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10448 tx_sw_if_index_set = 1;
10453 else if (unformat (i, "del"))
10459 if (rx_sw_if_index_set == 0)
10461 errmsg ("missing rx interface name or rx_sw_if_index");
10465 if (tx_sw_if_index_set == 0)
10467 errmsg ("missing tx interface name or tx_sw_if_index");
10471 M (L2_PATCH_ADD_DEL, mp);
10473 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10474 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10475 mp->is_add = is_add;
10483 u8 localsid_addr[16];
10492 api_sr_localsid_add_del (vat_main_t * vam)
10494 unformat_input_t *i = vam->input;
10495 vl_api_sr_localsid_add_del_t *mp;
10498 ip6_address_t localsid;
10502 u32 fib_table = ~(u32) 0;
10503 ip6_address_t nh_addr6;
10504 ip4_address_t nh_addr4;
10505 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10506 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10508 bool nexthop_set = 0;
10512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10514 if (unformat (i, "del"))
10516 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10517 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10519 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10521 else if (unformat (i, "behavior %u", &behavior));
10522 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10523 else if (unformat (i, "fib-table %u", &fib_table));
10524 else if (unformat (i, "end.psp %u", &behavior));
10529 M (SR_LOCALSID_ADD_DEL, mp);
10531 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10534 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10535 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10537 mp->behavior = behavior;
10538 mp->sw_if_index = ntohl (sw_if_index);
10539 mp->fib_table = ntohl (fib_table);
10540 mp->end_psp = end_psp;
10541 mp->is_del = is_del;
10549 api_ioam_enable (vat_main_t * vam)
10551 unformat_input_t *input = vam->input;
10552 vl_api_ioam_enable_t *mp;
10554 int has_trace_option = 0;
10555 int has_pot_option = 0;
10556 int has_seqno_option = 0;
10557 int has_analyse_option = 0;
10560 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10562 if (unformat (input, "trace"))
10563 has_trace_option = 1;
10564 else if (unformat (input, "pot"))
10565 has_pot_option = 1;
10566 else if (unformat (input, "seqno"))
10567 has_seqno_option = 1;
10568 else if (unformat (input, "analyse"))
10569 has_analyse_option = 1;
10573 M (IOAM_ENABLE, mp);
10574 mp->id = htons (id);
10575 mp->seqno = has_seqno_option;
10576 mp->analyse = has_analyse_option;
10577 mp->pot_enable = has_pot_option;
10578 mp->trace_enable = has_trace_option;
10587 api_ioam_disable (vat_main_t * vam)
10589 vl_api_ioam_disable_t *mp;
10592 M (IOAM_DISABLE, mp);
10598 #define foreach_tcp_proto_field \
10602 #define foreach_udp_proto_field \
10606 #define foreach_ip4_proto_field \
10618 u16 src_port, dst_port;
10621 #if VPP_API_TEST_BUILTIN == 0
10623 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10625 u8 **maskp = va_arg (*args, u8 **);
10627 u8 found_something = 0;
10630 #define _(a) u8 a=0;
10631 foreach_tcp_proto_field;
10634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10637 #define _(a) else if (unformat (input, #a)) a=1;
10638 foreach_tcp_proto_field
10644 #define _(a) found_something += a;
10645 foreach_tcp_proto_field;
10648 if (found_something == 0)
10651 vec_validate (mask, sizeof (*tcp) - 1);
10653 tcp = (tcp_header_t *) mask;
10655 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10656 foreach_tcp_proto_field;
10664 unformat_udp_mask (unformat_input_t * input, va_list * args)
10666 u8 **maskp = va_arg (*args, u8 **);
10668 u8 found_something = 0;
10671 #define _(a) u8 a=0;
10672 foreach_udp_proto_field;
10675 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10678 #define _(a) else if (unformat (input, #a)) a=1;
10679 foreach_udp_proto_field
10685 #define _(a) found_something += a;
10686 foreach_udp_proto_field;
10689 if (found_something == 0)
10692 vec_validate (mask, sizeof (*udp) - 1);
10694 udp = (udp_header_t *) mask;
10696 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10697 foreach_udp_proto_field;
10705 unformat_l4_mask (unformat_input_t * input, va_list * args)
10707 u8 **maskp = va_arg (*args, u8 **);
10708 u16 src_port = 0, dst_port = 0;
10709 tcpudp_header_t *tcpudp;
10711 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10713 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10715 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10717 else if (unformat (input, "src_port"))
10719 else if (unformat (input, "dst_port"))
10725 if (!src_port && !dst_port)
10729 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10731 tcpudp = (tcpudp_header_t *) mask;
10732 tcpudp->src_port = src_port;
10733 tcpudp->dst_port = dst_port;
10741 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10743 u8 **maskp = va_arg (*args, u8 **);
10745 u8 found_something = 0;
10748 #define _(a) u8 a=0;
10749 foreach_ip4_proto_field;
10755 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10757 if (unformat (input, "version"))
10759 else if (unformat (input, "hdr_length"))
10761 else if (unformat (input, "src"))
10763 else if (unformat (input, "dst"))
10765 else if (unformat (input, "proto"))
10768 #define _(a) else if (unformat (input, #a)) a=1;
10769 foreach_ip4_proto_field
10775 #define _(a) found_something += a;
10776 foreach_ip4_proto_field;
10779 if (found_something == 0)
10782 vec_validate (mask, sizeof (*ip) - 1);
10784 ip = (ip4_header_t *) mask;
10786 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10787 foreach_ip4_proto_field;
10790 ip->ip_version_and_header_length = 0;
10793 ip->ip_version_and_header_length |= 0xF0;
10796 ip->ip_version_and_header_length |= 0x0F;
10802 #define foreach_ip6_proto_field \
10805 _(payload_length) \
10810 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10812 u8 **maskp = va_arg (*args, u8 **);
10814 u8 found_something = 0;
10816 u32 ip_version_traffic_class_and_flow_label;
10818 #define _(a) u8 a=0;
10819 foreach_ip6_proto_field;
10822 u8 traffic_class = 0;
10825 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10827 if (unformat (input, "version"))
10829 else if (unformat (input, "traffic-class"))
10831 else if (unformat (input, "flow-label"))
10833 else if (unformat (input, "src"))
10835 else if (unformat (input, "dst"))
10837 else if (unformat (input, "proto"))
10840 #define _(a) else if (unformat (input, #a)) a=1;
10841 foreach_ip6_proto_field
10847 #define _(a) found_something += a;
10848 foreach_ip6_proto_field;
10851 if (found_something == 0)
10854 vec_validate (mask, sizeof (*ip) - 1);
10856 ip = (ip6_header_t *) mask;
10858 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10859 foreach_ip6_proto_field;
10862 ip_version_traffic_class_and_flow_label = 0;
10865 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10868 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10871 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10873 ip->ip_version_traffic_class_and_flow_label =
10874 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10881 unformat_l3_mask (unformat_input_t * input, va_list * args)
10883 u8 **maskp = va_arg (*args, u8 **);
10885 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10887 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10889 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10898 unformat_l2_mask (unformat_input_t * input, va_list * args)
10900 u8 **maskp = va_arg (*args, u8 **);
10907 u8 ignore_tag1 = 0;
10908 u8 ignore_tag2 = 0;
10915 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10917 if (unformat (input, "src"))
10919 else if (unformat (input, "dst"))
10921 else if (unformat (input, "proto"))
10923 else if (unformat (input, "tag1"))
10925 else if (unformat (input, "tag2"))
10927 else if (unformat (input, "ignore-tag1"))
10929 else if (unformat (input, "ignore-tag2"))
10931 else if (unformat (input, "cos1"))
10933 else if (unformat (input, "cos2"))
10935 else if (unformat (input, "dot1q"))
10937 else if (unformat (input, "dot1ad"))
10942 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10943 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10946 if (tag1 || ignore_tag1 || cos1 || dot1q)
10948 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10951 vec_validate (mask, len - 1);
10954 clib_memset (mask, 0xff, 6);
10957 clib_memset (mask + 6, 0xff, 6);
10959 if (tag2 || dot1ad)
10961 /* inner vlan tag */
10970 mask[21] = mask[20] = 0xff;
10991 mask[16] = mask[17] = 0xff;
11001 mask[12] = mask[13] = 0xff;
11008 unformat_classify_mask (unformat_input_t * input, va_list * args)
11010 u8 **maskp = va_arg (*args, u8 **);
11011 u32 *skipp = va_arg (*args, u32 *);
11012 u32 *matchp = va_arg (*args, u32 *);
11020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11022 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11024 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11026 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11028 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11042 if (mask || l2 || l3 || l4)
11044 if (l2 || l3 || l4)
11046 /* "With a free Ethernet header in every package" */
11048 vec_validate (l2, 13);
11052 vec_append (mask, l3);
11057 vec_append (mask, l4);
11062 /* Scan forward looking for the first significant mask octet */
11063 for (i = 0; i < vec_len (mask); i++)
11067 /* compute (skip, match) params */
11068 *skipp = i / sizeof (u32x4);
11069 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11071 /* Pad mask to an even multiple of the vector size */
11072 while (vec_len (mask) % sizeof (u32x4))
11073 vec_add1 (mask, 0);
11075 match = vec_len (mask) / sizeof (u32x4);
11077 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11079 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11080 if (*tmp || *(tmp + 1))
11085 clib_warning ("BUG: match 0");
11087 _vec_len (mask) = match * sizeof (u32x4);
11097 #endif /* VPP_API_TEST_BUILTIN */
11099 #define foreach_l2_next \
11101 _(ethernet, ETHERNET_INPUT) \
11102 _(ip4, IP4_INPUT) \
11106 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11108 u32 *miss_next_indexp = va_arg (*args, u32 *);
11109 u32 next_index = 0;
11113 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11117 if (unformat (input, "%d", &tmp))
11126 *miss_next_indexp = next_index;
11130 #define foreach_ip_next \
11133 _(rewrite, REWRITE)
11136 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11138 u32 *miss_next_indexp = va_arg (*args, u32 *);
11139 u32 next_index = 0;
11143 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11147 if (unformat (input, "%d", &tmp))
11156 *miss_next_indexp = next_index;
11160 #define foreach_acl_next \
11164 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11166 u32 *miss_next_indexp = va_arg (*args, u32 *);
11167 u32 next_index = 0;
11171 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11175 if (unformat (input, "permit"))
11180 else if (unformat (input, "%d", &tmp))
11189 *miss_next_indexp = next_index;
11194 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11196 u32 *r = va_arg (*args, u32 *);
11198 if (unformat (input, "conform-color"))
11199 *r = POLICE_CONFORM;
11200 else if (unformat (input, "exceed-color"))
11201 *r = POLICE_EXCEED;
11209 api_classify_add_del_table (vat_main_t * vam)
11211 unformat_input_t *i = vam->input;
11212 vl_api_classify_add_del_table_t *mp;
11219 u32 table_index = ~0;
11220 u32 next_table_index = ~0;
11221 u32 miss_next_index = ~0;
11222 u32 memory_size = 32 << 20;
11224 u32 current_data_flag = 0;
11225 int current_data_offset = 0;
11228 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11230 if (unformat (i, "del"))
11232 else if (unformat (i, "del-chain"))
11237 else if (unformat (i, "buckets %d", &nbuckets))
11239 else if (unformat (i, "memory_size %d", &memory_size))
11241 else if (unformat (i, "skip %d", &skip))
11243 else if (unformat (i, "match %d", &match))
11245 else if (unformat (i, "table %d", &table_index))
11247 else if (unformat (i, "mask %U", unformat_classify_mask,
11248 &mask, &skip, &match))
11250 else if (unformat (i, "next-table %d", &next_table_index))
11252 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11255 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11258 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11261 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11263 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11269 if (is_add && mask == 0)
11271 errmsg ("Mask required");
11275 if (is_add && skip == ~0)
11277 errmsg ("skip count required");
11281 if (is_add && match == ~0)
11283 errmsg ("match count required");
11287 if (!is_add && table_index == ~0)
11289 errmsg ("table index required for delete");
11293 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11295 mp->is_add = is_add;
11296 mp->del_chain = del_chain;
11297 mp->table_index = ntohl (table_index);
11298 mp->nbuckets = ntohl (nbuckets);
11299 mp->memory_size = ntohl (memory_size);
11300 mp->skip_n_vectors = ntohl (skip);
11301 mp->match_n_vectors = ntohl (match);
11302 mp->next_table_index = ntohl (next_table_index);
11303 mp->miss_next_index = ntohl (miss_next_index);
11304 mp->current_data_flag = ntohl (current_data_flag);
11305 mp->current_data_offset = ntohl (current_data_offset);
11306 mp->mask_len = ntohl (vec_len (mask));
11307 clib_memcpy (mp->mask, mask, vec_len (mask));
11316 #if VPP_API_TEST_BUILTIN == 0
11318 unformat_l4_match (unformat_input_t * input, va_list * args)
11320 u8 **matchp = va_arg (*args, u8 **);
11322 u8 *proto_header = 0;
11328 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11330 if (unformat (input, "src_port %d", &src_port))
11332 else if (unformat (input, "dst_port %d", &dst_port))
11338 h.src_port = clib_host_to_net_u16 (src_port);
11339 h.dst_port = clib_host_to_net_u16 (dst_port);
11340 vec_validate (proto_header, sizeof (h) - 1);
11341 memcpy (proto_header, &h, sizeof (h));
11343 *matchp = proto_header;
11349 unformat_ip4_match (unformat_input_t * input, va_list * args)
11351 u8 **matchp = va_arg (*args, u8 **);
11356 int hdr_length = 0;
11357 u32 hdr_length_val;
11358 int src = 0, dst = 0;
11359 ip4_address_t src_val, dst_val;
11366 int fragment_id = 0;
11367 u32 fragment_id_val;
11373 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11375 if (unformat (input, "version %d", &version_val))
11377 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11379 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11381 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11383 else if (unformat (input, "proto %d", &proto_val))
11385 else if (unformat (input, "tos %d", &tos_val))
11387 else if (unformat (input, "length %d", &length_val))
11389 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11391 else if (unformat (input, "ttl %d", &ttl_val))
11393 else if (unformat (input, "checksum %d", &checksum_val))
11399 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11400 + ttl + checksum == 0)
11404 * Aligned because we use the real comparison functions
11406 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11408 ip = (ip4_header_t *) match;
11410 /* These are realistically matched in practice */
11412 ip->src_address.as_u32 = src_val.as_u32;
11415 ip->dst_address.as_u32 = dst_val.as_u32;
11418 ip->protocol = proto_val;
11421 /* These are not, but they're included for completeness */
11423 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11426 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11432 ip->length = clib_host_to_net_u16 (length_val);
11438 ip->checksum = clib_host_to_net_u16 (checksum_val);
11445 unformat_ip6_match (unformat_input_t * input, va_list * args)
11447 u8 **matchp = va_arg (*args, u8 **);
11452 u8 traffic_class = 0;
11453 u32 traffic_class_val = 0;
11456 int src = 0, dst = 0;
11457 ip6_address_t src_val, dst_val;
11460 int payload_length = 0;
11461 u32 payload_length_val;
11464 u32 ip_version_traffic_class_and_flow_label;
11466 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11468 if (unformat (input, "version %d", &version_val))
11470 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11472 else if (unformat (input, "flow_label %d", &flow_label_val))
11474 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11476 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11478 else if (unformat (input, "proto %d", &proto_val))
11480 else if (unformat (input, "payload_length %d", &payload_length_val))
11481 payload_length = 1;
11482 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11488 if (version + traffic_class + flow_label + src + dst + proto +
11489 payload_length + hop_limit == 0)
11493 * Aligned because we use the real comparison functions
11495 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11497 ip = (ip6_header_t *) match;
11500 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11503 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11506 ip->protocol = proto_val;
11508 ip_version_traffic_class_and_flow_label = 0;
11511 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11514 ip_version_traffic_class_and_flow_label |=
11515 (traffic_class_val & 0xFF) << 20;
11518 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11520 ip->ip_version_traffic_class_and_flow_label =
11521 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11523 if (payload_length)
11524 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11527 ip->hop_limit = hop_limit_val;
11534 unformat_l3_match (unformat_input_t * input, va_list * args)
11536 u8 **matchp = va_arg (*args, u8 **);
11538 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11540 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11542 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11551 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11553 u8 *tagp = va_arg (*args, u8 *);
11556 if (unformat (input, "%d", &tag))
11558 tagp[0] = (tag >> 8) & 0x0F;
11559 tagp[1] = tag & 0xFF;
11567 unformat_l2_match (unformat_input_t * input, va_list * args)
11569 u8 **matchp = va_arg (*args, u8 **);
11582 u8 ignore_tag1 = 0;
11583 u8 ignore_tag2 = 0;
11589 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11591 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11594 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11596 else if (unformat (input, "proto %U",
11597 unformat_ethernet_type_host_byte_order, &proto_val))
11599 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11601 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11603 else if (unformat (input, "ignore-tag1"))
11605 else if (unformat (input, "ignore-tag2"))
11607 else if (unformat (input, "cos1 %d", &cos1_val))
11609 else if (unformat (input, "cos2 %d", &cos2_val))
11614 if ((src + dst + proto + tag1 + tag2 +
11615 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11618 if (tag1 || ignore_tag1 || cos1)
11620 if (tag2 || ignore_tag2 || cos2)
11623 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11626 clib_memcpy (match, dst_val, 6);
11629 clib_memcpy (match + 6, src_val, 6);
11633 /* inner vlan tag */
11634 match[19] = tag2_val[1];
11635 match[18] = tag2_val[0];
11637 match[18] |= (cos2_val & 0x7) << 5;
11640 match[21] = proto_val & 0xff;
11641 match[20] = proto_val >> 8;
11645 match[15] = tag1_val[1];
11646 match[14] = tag1_val[0];
11649 match[14] |= (cos1_val & 0x7) << 5;
11655 match[15] = tag1_val[1];
11656 match[14] = tag1_val[0];
11659 match[17] = proto_val & 0xff;
11660 match[16] = proto_val >> 8;
11663 match[14] |= (cos1_val & 0x7) << 5;
11669 match[18] |= (cos2_val & 0x7) << 5;
11671 match[14] |= (cos1_val & 0x7) << 5;
11674 match[13] = proto_val & 0xff;
11675 match[12] = proto_val >> 8;
11683 unformat_qos_source (unformat_input_t * input, va_list * args)
11685 int *qs = va_arg (*args, int *);
11687 if (unformat (input, "ip"))
11688 *qs = QOS_SOURCE_IP;
11689 else if (unformat (input, "mpls"))
11690 *qs = QOS_SOURCE_MPLS;
11691 else if (unformat (input, "ext"))
11692 *qs = QOS_SOURCE_EXT;
11693 else if (unformat (input, "vlan"))
11694 *qs = QOS_SOURCE_VLAN;
11703 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11705 u8 **matchp = va_arg (*args, u8 **);
11706 u32 skip_n_vectors = va_arg (*args, u32);
11707 u32 match_n_vectors = va_arg (*args, u32);
11714 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11716 if (unformat (input, "hex %U", unformat_hex_string, &match))
11718 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11720 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11722 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11736 if (match || l2 || l3 || l4)
11738 if (l2 || l3 || l4)
11740 /* "Win a free Ethernet header in every packet" */
11742 vec_validate_aligned (l2, 13, sizeof (u32x4));
11746 vec_append_aligned (match, l3, sizeof (u32x4));
11751 vec_append_aligned (match, l4, sizeof (u32x4));
11756 /* Make sure the vector is big enough even if key is all 0's */
11757 vec_validate_aligned
11758 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11761 /* Set size, include skipped vectors */
11762 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11773 api_classify_add_del_session (vat_main_t * vam)
11775 unformat_input_t *i = vam->input;
11776 vl_api_classify_add_del_session_t *mp;
11778 u32 table_index = ~0;
11779 u32 hit_next_index = ~0;
11780 u32 opaque_index = ~0;
11783 u32 skip_n_vectors = 0;
11784 u32 match_n_vectors = 0;
11790 * Warning: you have to supply skip_n and match_n
11791 * because the API client cant simply look at the classify
11795 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11797 if (unformat (i, "del"))
11799 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11802 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11805 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11808 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11810 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11812 else if (unformat (i, "opaque-index %d", &opaque_index))
11814 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11816 else if (unformat (i, "match_n %d", &match_n_vectors))
11818 else if (unformat (i, "match %U", api_unformat_classify_match,
11819 &match, skip_n_vectors, match_n_vectors))
11821 else if (unformat (i, "advance %d", &advance))
11823 else if (unformat (i, "table-index %d", &table_index))
11825 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11827 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11829 else if (unformat (i, "action %d", &action))
11831 else if (unformat (i, "metadata %d", &metadata))
11837 if (table_index == ~0)
11839 errmsg ("Table index required");
11843 if (is_add && match == 0)
11845 errmsg ("Match value required");
11849 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11851 mp->is_add = is_add;
11852 mp->table_index = ntohl (table_index);
11853 mp->hit_next_index = ntohl (hit_next_index);
11854 mp->opaque_index = ntohl (opaque_index);
11855 mp->advance = ntohl (advance);
11856 mp->action = action;
11857 mp->metadata = ntohl (metadata);
11858 mp->match_len = ntohl (vec_len (match));
11859 clib_memcpy (mp->match, match, vec_len (match));
11868 api_classify_set_interface_ip_table (vat_main_t * vam)
11870 unformat_input_t *i = vam->input;
11871 vl_api_classify_set_interface_ip_table_t *mp;
11873 int sw_if_index_set;
11874 u32 table_index = ~0;
11878 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11880 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11881 sw_if_index_set = 1;
11882 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11883 sw_if_index_set = 1;
11884 else if (unformat (i, "table %d", &table_index))
11888 clib_warning ("parse error '%U'", format_unformat_error, i);
11893 if (sw_if_index_set == 0)
11895 errmsg ("missing interface name or sw_if_index");
11900 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11902 mp->sw_if_index = ntohl (sw_if_index);
11903 mp->table_index = ntohl (table_index);
11904 mp->is_ipv6 = is_ipv6;
11912 api_classify_set_interface_l2_tables (vat_main_t * vam)
11914 unformat_input_t *i = vam->input;
11915 vl_api_classify_set_interface_l2_tables_t *mp;
11917 int sw_if_index_set;
11918 u32 ip4_table_index = ~0;
11919 u32 ip6_table_index = ~0;
11920 u32 other_table_index = ~0;
11924 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11926 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11927 sw_if_index_set = 1;
11928 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11929 sw_if_index_set = 1;
11930 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11932 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11934 else if (unformat (i, "other-table %d", &other_table_index))
11936 else if (unformat (i, "is-input %d", &is_input))
11940 clib_warning ("parse error '%U'", format_unformat_error, i);
11945 if (sw_if_index_set == 0)
11947 errmsg ("missing interface name or sw_if_index");
11952 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11954 mp->sw_if_index = ntohl (sw_if_index);
11955 mp->ip4_table_index = ntohl (ip4_table_index);
11956 mp->ip6_table_index = ntohl (ip6_table_index);
11957 mp->other_table_index = ntohl (other_table_index);
11958 mp->is_input = (u8) is_input;
11966 api_set_ipfix_exporter (vat_main_t * vam)
11968 unformat_input_t *i = vam->input;
11969 vl_api_set_ipfix_exporter_t *mp;
11970 ip4_address_t collector_address;
11971 u8 collector_address_set = 0;
11972 u32 collector_port = ~0;
11973 ip4_address_t src_address;
11974 u8 src_address_set = 0;
11977 u32 template_interval = ~0;
11978 u8 udp_checksum = 0;
11981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11983 if (unformat (i, "collector_address %U", unformat_ip4_address,
11984 &collector_address))
11985 collector_address_set = 1;
11986 else if (unformat (i, "collector_port %d", &collector_port))
11988 else if (unformat (i, "src_address %U", unformat_ip4_address,
11990 src_address_set = 1;
11991 else if (unformat (i, "vrf_id %d", &vrf_id))
11993 else if (unformat (i, "path_mtu %d", &path_mtu))
11995 else if (unformat (i, "template_interval %d", &template_interval))
11997 else if (unformat (i, "udp_checksum"))
12003 if (collector_address_set == 0)
12005 errmsg ("collector_address required");
12009 if (src_address_set == 0)
12011 errmsg ("src_address required");
12015 M (SET_IPFIX_EXPORTER, mp);
12017 memcpy (mp->collector_address, collector_address.data,
12018 sizeof (collector_address.data));
12019 mp->collector_port = htons ((u16) collector_port);
12020 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12021 mp->vrf_id = htonl (vrf_id);
12022 mp->path_mtu = htonl (path_mtu);
12023 mp->template_interval = htonl (template_interval);
12024 mp->udp_checksum = udp_checksum;
12032 api_set_ipfix_classify_stream (vat_main_t * vam)
12034 unformat_input_t *i = vam->input;
12035 vl_api_set_ipfix_classify_stream_t *mp;
12037 u32 src_port = UDP_DST_PORT_ipfix;
12040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12042 if (unformat (i, "domain %d", &domain_id))
12044 else if (unformat (i, "src_port %d", &src_port))
12048 errmsg ("unknown input `%U'", format_unformat_error, i);
12053 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12055 mp->domain_id = htonl (domain_id);
12056 mp->src_port = htons ((u16) src_port);
12064 api_ipfix_classify_table_add_del (vat_main_t * vam)
12066 unformat_input_t *i = vam->input;
12067 vl_api_ipfix_classify_table_add_del_t *mp;
12069 u32 classify_table_index = ~0;
12071 u8 transport_protocol = 255;
12074 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12076 if (unformat (i, "add"))
12078 else if (unformat (i, "del"))
12080 else if (unformat (i, "table %d", &classify_table_index))
12082 else if (unformat (i, "ip4"))
12084 else if (unformat (i, "ip6"))
12086 else if (unformat (i, "tcp"))
12087 transport_protocol = 6;
12088 else if (unformat (i, "udp"))
12089 transport_protocol = 17;
12092 errmsg ("unknown input `%U'", format_unformat_error, i);
12099 errmsg ("expecting: add|del");
12102 if (classify_table_index == ~0)
12104 errmsg ("classifier table not specified");
12107 if (ip_version == 0)
12109 errmsg ("IP version not specified");
12113 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12115 mp->is_add = is_add;
12116 mp->table_id = htonl (classify_table_index);
12117 mp->ip_version = ip_version;
12118 mp->transport_protocol = transport_protocol;
12126 api_get_node_index (vat_main_t * vam)
12128 unformat_input_t *i = vam->input;
12129 vl_api_get_node_index_t *mp;
12133 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12135 if (unformat (i, "node %s", &name))
12142 errmsg ("node name required");
12145 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12147 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12151 M (GET_NODE_INDEX, mp);
12152 clib_memcpy (mp->node_name, name, vec_len (name));
12161 api_get_next_index (vat_main_t * vam)
12163 unformat_input_t *i = vam->input;
12164 vl_api_get_next_index_t *mp;
12165 u8 *node_name = 0, *next_node_name = 0;
12168 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12170 if (unformat (i, "node-name %s", &node_name))
12172 else if (unformat (i, "next-node-name %s", &next_node_name))
12176 if (node_name == 0)
12178 errmsg ("node name required");
12181 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12183 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12187 if (next_node_name == 0)
12189 errmsg ("next node name required");
12192 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12194 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12198 M (GET_NEXT_INDEX, mp);
12199 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12200 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12201 vec_free (node_name);
12202 vec_free (next_node_name);
12210 api_add_node_next (vat_main_t * vam)
12212 unformat_input_t *i = vam->input;
12213 vl_api_add_node_next_t *mp;
12218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12220 if (unformat (i, "node %s", &name))
12222 else if (unformat (i, "next %s", &next))
12229 errmsg ("node name required");
12232 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12234 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12239 errmsg ("next node required");
12242 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12244 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12248 M (ADD_NODE_NEXT, mp);
12249 clib_memcpy (mp->node_name, name, vec_len (name));
12250 clib_memcpy (mp->next_name, next, vec_len (next));
12260 api_l2tpv3_create_tunnel (vat_main_t * vam)
12262 unformat_input_t *i = vam->input;
12263 ip6_address_t client_address, our_address;
12264 int client_address_set = 0;
12265 int our_address_set = 0;
12266 u32 local_session_id = 0;
12267 u32 remote_session_id = 0;
12268 u64 local_cookie = 0;
12269 u64 remote_cookie = 0;
12270 u8 l2_sublayer_present = 0;
12271 vl_api_l2tpv3_create_tunnel_t *mp;
12274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12276 if (unformat (i, "client_address %U", unformat_ip6_address,
12278 client_address_set = 1;
12279 else if (unformat (i, "our_address %U", unformat_ip6_address,
12281 our_address_set = 1;
12282 else if (unformat (i, "local_session_id %d", &local_session_id))
12284 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12286 else if (unformat (i, "local_cookie %lld", &local_cookie))
12288 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12290 else if (unformat (i, "l2-sublayer-present"))
12291 l2_sublayer_present = 1;
12296 if (client_address_set == 0)
12298 errmsg ("client_address required");
12302 if (our_address_set == 0)
12304 errmsg ("our_address required");
12308 M (L2TPV3_CREATE_TUNNEL, mp);
12310 clib_memcpy (mp->client_address, client_address.as_u8,
12311 sizeof (mp->client_address));
12313 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12315 mp->local_session_id = ntohl (local_session_id);
12316 mp->remote_session_id = ntohl (remote_session_id);
12317 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12318 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12319 mp->l2_sublayer_present = l2_sublayer_present;
12328 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12330 unformat_input_t *i = vam->input;
12332 u8 sw_if_index_set = 0;
12333 u64 new_local_cookie = 0;
12334 u64 new_remote_cookie = 0;
12335 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12340 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12341 sw_if_index_set = 1;
12342 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12343 sw_if_index_set = 1;
12344 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12346 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12352 if (sw_if_index_set == 0)
12354 errmsg ("missing interface name or sw_if_index");
12358 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12360 mp->sw_if_index = ntohl (sw_if_index);
12361 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12362 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12370 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12372 unformat_input_t *i = vam->input;
12373 vl_api_l2tpv3_interface_enable_disable_t *mp;
12375 u8 sw_if_index_set = 0;
12376 u8 enable_disable = 1;
12379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12381 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12382 sw_if_index_set = 1;
12383 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12384 sw_if_index_set = 1;
12385 else if (unformat (i, "enable"))
12386 enable_disable = 1;
12387 else if (unformat (i, "disable"))
12388 enable_disable = 0;
12393 if (sw_if_index_set == 0)
12395 errmsg ("missing interface name or sw_if_index");
12399 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12401 mp->sw_if_index = ntohl (sw_if_index);
12402 mp->enable_disable = enable_disable;
12410 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12412 unformat_input_t *i = vam->input;
12413 vl_api_l2tpv3_set_lookup_key_t *mp;
12417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12419 if (unformat (i, "lookup_v6_src"))
12420 key = L2T_LOOKUP_SRC_ADDRESS;
12421 else if (unformat (i, "lookup_v6_dst"))
12422 key = L2T_LOOKUP_DST_ADDRESS;
12423 else if (unformat (i, "lookup_session_id"))
12424 key = L2T_LOOKUP_SESSION_ID;
12429 if (key == (u8) ~ 0)
12431 errmsg ("l2tp session lookup key unset");
12435 M (L2TPV3_SET_LOOKUP_KEY, mp);
12444 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12445 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12447 vat_main_t *vam = &vat_main;
12449 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12450 format_ip6_address, mp->our_address,
12451 format_ip6_address, mp->client_address,
12452 clib_net_to_host_u32 (mp->sw_if_index));
12455 " local cookies %016llx %016llx remote cookie %016llx",
12456 clib_net_to_host_u64 (mp->local_cookie[0]),
12457 clib_net_to_host_u64 (mp->local_cookie[1]),
12458 clib_net_to_host_u64 (mp->remote_cookie));
12460 print (vam->ofp, " local session-id %d remote session-id %d",
12461 clib_net_to_host_u32 (mp->local_session_id),
12462 clib_net_to_host_u32 (mp->remote_session_id));
12464 print (vam->ofp, " l2 specific sublayer %s\n",
12465 mp->l2_sublayer_present ? "preset" : "absent");
12469 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12470 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12472 vat_main_t *vam = &vat_main;
12473 vat_json_node_t *node = NULL;
12474 struct in6_addr addr;
12476 if (VAT_JSON_ARRAY != vam->json_tree.type)
12478 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12479 vat_json_init_array (&vam->json_tree);
12481 node = vat_json_array_add (&vam->json_tree);
12483 vat_json_init_object (node);
12485 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12486 vat_json_object_add_ip6 (node, "our_address", addr);
12487 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12488 vat_json_object_add_ip6 (node, "client_address", addr);
12490 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12491 vat_json_init_array (lc);
12492 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12493 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12494 vat_json_object_add_uint (node, "remote_cookie",
12495 clib_net_to_host_u64 (mp->remote_cookie));
12497 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12498 vat_json_object_add_uint (node, "local_session_id",
12499 clib_net_to_host_u32 (mp->local_session_id));
12500 vat_json_object_add_uint (node, "remote_session_id",
12501 clib_net_to_host_u32 (mp->remote_session_id));
12502 vat_json_object_add_string_copy (node, "l2_sublayer",
12503 mp->l2_sublayer_present ? (u8 *) "present"
12504 : (u8 *) "absent");
12508 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12510 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12511 vl_api_control_ping_t *mp_ping;
12514 /* Get list of l2tpv3-tunnel interfaces */
12515 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12518 /* Use a control ping for synchronization */
12519 MPING (CONTROL_PING, mp_ping);
12527 static void vl_api_sw_interface_tap_v2_details_t_handler
12528 (vl_api_sw_interface_tap_v2_details_t * mp)
12530 vat_main_t *vam = &vat_main;
12532 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12533 mp->host_ip4_prefix_len);
12534 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12535 mp->host_ip6_prefix_len);
12538 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12539 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12540 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12541 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12542 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12548 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12549 (vl_api_sw_interface_tap_v2_details_t * mp)
12551 vat_main_t *vam = &vat_main;
12552 vat_json_node_t *node = NULL;
12554 if (VAT_JSON_ARRAY != vam->json_tree.type)
12556 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12557 vat_json_init_array (&vam->json_tree);
12559 node = vat_json_array_add (&vam->json_tree);
12561 vat_json_init_object (node);
12562 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12563 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12564 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12565 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12566 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12567 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12568 vat_json_object_add_string_copy (node, "host_mac_addr",
12569 format (0, "%U", format_ethernet_address,
12570 &mp->host_mac_addr));
12571 vat_json_object_add_string_copy (node, "host_namespace",
12572 mp->host_namespace);
12573 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12574 vat_json_object_add_string_copy (node, "host_ip4_addr",
12575 format (0, "%U/%d", format_ip4_address,
12577 mp->host_ip4_prefix_len));
12578 vat_json_object_add_string_copy (node, "host_ip6_addr",
12579 format (0, "%U/%d", format_ip6_address,
12581 mp->host_ip6_prefix_len));
12586 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12588 vl_api_sw_interface_tap_v2_dump_t *mp;
12589 vl_api_control_ping_t *mp_ping;
12593 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12594 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12595 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12598 /* Get list of tap interfaces */
12599 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12602 /* Use a control ping for synchronization */
12603 MPING (CONTROL_PING, mp_ping);
12610 static void vl_api_sw_interface_virtio_pci_details_t_handler
12611 (vl_api_sw_interface_virtio_pci_details_t * mp)
12613 vat_main_t *vam = &vat_main;
12627 addr.as_u32 = ntohl (mp->pci_addr);
12628 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12629 addr.slot, addr.function);
12632 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12633 pci_addr, ntohl (mp->sw_if_index),
12634 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12635 format_ethernet_address, mp->mac_addr,
12636 clib_net_to_host_u64 (mp->features));
12637 vec_free (pci_addr);
12640 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12641 (vl_api_sw_interface_virtio_pci_details_t * mp)
12643 vat_main_t *vam = &vat_main;
12644 vat_json_node_t *node = NULL;
12646 if (VAT_JSON_ARRAY != vam->json_tree.type)
12648 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12649 vat_json_init_array (&vam->json_tree);
12651 node = vat_json_array_add (&vam->json_tree);
12653 vat_json_init_object (node);
12654 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12655 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12656 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12657 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12658 vat_json_object_add_uint (node, "features",
12659 clib_net_to_host_u64 (mp->features));
12660 vat_json_object_add_string_copy (node, "mac_addr",
12661 format (0, "%U", format_ethernet_address,
12666 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12668 vl_api_sw_interface_virtio_pci_dump_t *mp;
12669 vl_api_control_ping_t *mp_ping;
12673 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12674 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12675 "mac_addr", "features");
12677 /* Get list of tap interfaces */
12678 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12681 /* Use a control ping for synchronization */
12682 MPING (CONTROL_PING, mp_ping);
12690 api_vxlan_offload_rx (vat_main_t * vam)
12692 unformat_input_t *line_input = vam->input;
12693 vl_api_vxlan_offload_rx_t *mp;
12694 u32 hw_if_index = ~0, rx_if_index = ~0;
12698 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12700 if (unformat (line_input, "del"))
12702 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12705 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12707 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12710 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12714 errmsg ("parse error '%U'", format_unformat_error, line_input);
12719 if (hw_if_index == ~0)
12721 errmsg ("no hw interface");
12725 if (rx_if_index == ~0)
12727 errmsg ("no rx tunnel");
12731 M (VXLAN_OFFLOAD_RX, mp);
12733 mp->hw_if_index = ntohl (hw_if_index);
12734 mp->sw_if_index = ntohl (rx_if_index);
12735 mp->enable = is_add;
12742 static uword unformat_vxlan_decap_next
12743 (unformat_input_t * input, va_list * args)
12745 u32 *result = va_arg (*args, u32 *);
12748 if (unformat (input, "l2"))
12749 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12750 else if (unformat (input, "%d", &tmp))
12758 api_vxlan_add_del_tunnel (vat_main_t * vam)
12760 unformat_input_t *line_input = vam->input;
12761 vl_api_vxlan_add_del_tunnel_t *mp;
12762 ip46_address_t src, dst;
12764 u8 ipv4_set = 0, ipv6_set = 0;
12769 u32 mcast_sw_if_index = ~0;
12770 u32 encap_vrf_id = 0;
12771 u32 decap_next_index = ~0;
12775 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12776 clib_memset (&src, 0, sizeof src);
12777 clib_memset (&dst, 0, sizeof dst);
12779 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12781 if (unformat (line_input, "del"))
12783 else if (unformat (line_input, "instance %d", &instance))
12786 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12792 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12798 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12804 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12809 else if (unformat (line_input, "group %U %U",
12810 unformat_ip4_address, &dst.ip4,
12811 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12813 grp_set = dst_set = 1;
12816 else if (unformat (line_input, "group %U",
12817 unformat_ip4_address, &dst.ip4))
12819 grp_set = dst_set = 1;
12822 else if (unformat (line_input, "group %U %U",
12823 unformat_ip6_address, &dst.ip6,
12824 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12826 grp_set = dst_set = 1;
12829 else if (unformat (line_input, "group %U",
12830 unformat_ip6_address, &dst.ip6))
12832 grp_set = dst_set = 1;
12836 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12838 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12840 else if (unformat (line_input, "decap-next %U",
12841 unformat_vxlan_decap_next, &decap_next_index))
12843 else if (unformat (line_input, "vni %d", &vni))
12847 errmsg ("parse error '%U'", format_unformat_error, line_input);
12854 errmsg ("tunnel src address not specified");
12859 errmsg ("tunnel dst address not specified");
12863 if (grp_set && !ip46_address_is_multicast (&dst))
12865 errmsg ("tunnel group address not multicast");
12868 if (grp_set && mcast_sw_if_index == ~0)
12870 errmsg ("tunnel nonexistent multicast device");
12873 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12875 errmsg ("tunnel dst address must be unicast");
12880 if (ipv4_set && ipv6_set)
12882 errmsg ("both IPv4 and IPv6 addresses specified");
12886 if ((vni == 0) || (vni >> 24))
12888 errmsg ("vni not specified or out of range");
12892 M (VXLAN_ADD_DEL_TUNNEL, mp);
12896 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12897 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12901 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12902 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12905 mp->instance = htonl (instance);
12906 mp->encap_vrf_id = ntohl (encap_vrf_id);
12907 mp->decap_next_index = ntohl (decap_next_index);
12908 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12909 mp->vni = ntohl (vni);
12910 mp->is_add = is_add;
12911 mp->is_ipv6 = ipv6_set;
12918 static void vl_api_vxlan_tunnel_details_t_handler
12919 (vl_api_vxlan_tunnel_details_t * mp)
12921 vat_main_t *vam = &vat_main;
12922 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12923 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12925 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12926 ntohl (mp->sw_if_index),
12927 ntohl (mp->instance),
12928 format_ip46_address, &src, IP46_TYPE_ANY,
12929 format_ip46_address, &dst, IP46_TYPE_ANY,
12930 ntohl (mp->encap_vrf_id),
12931 ntohl (mp->decap_next_index), ntohl (mp->vni),
12932 ntohl (mp->mcast_sw_if_index));
12935 static void vl_api_vxlan_tunnel_details_t_handler_json
12936 (vl_api_vxlan_tunnel_details_t * mp)
12938 vat_main_t *vam = &vat_main;
12939 vat_json_node_t *node = NULL;
12941 if (VAT_JSON_ARRAY != vam->json_tree.type)
12943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12944 vat_json_init_array (&vam->json_tree);
12946 node = vat_json_array_add (&vam->json_tree);
12948 vat_json_init_object (node);
12949 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12951 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12955 struct in6_addr ip6;
12957 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12958 vat_json_object_add_ip6 (node, "src_address", ip6);
12959 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12960 vat_json_object_add_ip6 (node, "dst_address", ip6);
12964 struct in_addr ip4;
12966 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12967 vat_json_object_add_ip4 (node, "src_address", ip4);
12968 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12969 vat_json_object_add_ip4 (node, "dst_address", ip4);
12971 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12972 vat_json_object_add_uint (node, "decap_next_index",
12973 ntohl (mp->decap_next_index));
12974 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12975 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12976 vat_json_object_add_uint (node, "mcast_sw_if_index",
12977 ntohl (mp->mcast_sw_if_index));
12981 api_vxlan_tunnel_dump (vat_main_t * vam)
12983 unformat_input_t *i = vam->input;
12984 vl_api_vxlan_tunnel_dump_t *mp;
12985 vl_api_control_ping_t *mp_ping;
12987 u8 sw_if_index_set = 0;
12990 /* Parse args required to build the message */
12991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12993 if (unformat (i, "sw_if_index %d", &sw_if_index))
12994 sw_if_index_set = 1;
12999 if (sw_if_index_set == 0)
13004 if (!vam->json_output)
13006 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13007 "sw_if_index", "instance", "src_address", "dst_address",
13008 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13011 /* Get list of vxlan-tunnel interfaces */
13012 M (VXLAN_TUNNEL_DUMP, mp);
13014 mp->sw_if_index = htonl (sw_if_index);
13018 /* Use a control ping for synchronization */
13019 MPING (CONTROL_PING, mp_ping);
13026 static uword unformat_geneve_decap_next
13027 (unformat_input_t * input, va_list * args)
13029 u32 *result = va_arg (*args, u32 *);
13032 if (unformat (input, "l2"))
13033 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13034 else if (unformat (input, "%d", &tmp))
13042 api_geneve_add_del_tunnel (vat_main_t * vam)
13044 unformat_input_t *line_input = vam->input;
13045 vl_api_geneve_add_del_tunnel_t *mp;
13046 ip46_address_t src, dst;
13048 u8 ipv4_set = 0, ipv6_set = 0;
13052 u32 mcast_sw_if_index = ~0;
13053 u32 encap_vrf_id = 0;
13054 u32 decap_next_index = ~0;
13058 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13059 clib_memset (&src, 0, sizeof src);
13060 clib_memset (&dst, 0, sizeof dst);
13062 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13064 if (unformat (line_input, "del"))
13067 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13073 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13079 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13085 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13090 else if (unformat (line_input, "group %U %U",
13091 unformat_ip4_address, &dst.ip4,
13092 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13094 grp_set = dst_set = 1;
13097 else if (unformat (line_input, "group %U",
13098 unformat_ip4_address, &dst.ip4))
13100 grp_set = dst_set = 1;
13103 else if (unformat (line_input, "group %U %U",
13104 unformat_ip6_address, &dst.ip6,
13105 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13107 grp_set = dst_set = 1;
13110 else if (unformat (line_input, "group %U",
13111 unformat_ip6_address, &dst.ip6))
13113 grp_set = dst_set = 1;
13117 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13119 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13121 else if (unformat (line_input, "decap-next %U",
13122 unformat_geneve_decap_next, &decap_next_index))
13124 else if (unformat (line_input, "vni %d", &vni))
13128 errmsg ("parse error '%U'", format_unformat_error, line_input);
13135 errmsg ("tunnel src address not specified");
13140 errmsg ("tunnel dst address not specified");
13144 if (grp_set && !ip46_address_is_multicast (&dst))
13146 errmsg ("tunnel group address not multicast");
13149 if (grp_set && mcast_sw_if_index == ~0)
13151 errmsg ("tunnel nonexistent multicast device");
13154 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13156 errmsg ("tunnel dst address must be unicast");
13161 if (ipv4_set && ipv6_set)
13163 errmsg ("both IPv4 and IPv6 addresses specified");
13167 if ((vni == 0) || (vni >> 24))
13169 errmsg ("vni not specified or out of range");
13173 M (GENEVE_ADD_DEL_TUNNEL, mp);
13177 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13178 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13182 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13183 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13185 mp->encap_vrf_id = ntohl (encap_vrf_id);
13186 mp->decap_next_index = ntohl (decap_next_index);
13187 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13188 mp->vni = ntohl (vni);
13189 mp->is_add = is_add;
13190 mp->is_ipv6 = ipv6_set;
13197 static void vl_api_geneve_tunnel_details_t_handler
13198 (vl_api_geneve_tunnel_details_t * mp)
13200 vat_main_t *vam = &vat_main;
13201 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13202 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13204 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13205 ntohl (mp->sw_if_index),
13206 format_ip46_address, &src, IP46_TYPE_ANY,
13207 format_ip46_address, &dst, IP46_TYPE_ANY,
13208 ntohl (mp->encap_vrf_id),
13209 ntohl (mp->decap_next_index), ntohl (mp->vni),
13210 ntohl (mp->mcast_sw_if_index));
13213 static void vl_api_geneve_tunnel_details_t_handler_json
13214 (vl_api_geneve_tunnel_details_t * mp)
13216 vat_main_t *vam = &vat_main;
13217 vat_json_node_t *node = NULL;
13219 if (VAT_JSON_ARRAY != vam->json_tree.type)
13221 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13222 vat_json_init_array (&vam->json_tree);
13224 node = vat_json_array_add (&vam->json_tree);
13226 vat_json_init_object (node);
13227 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13230 struct in6_addr ip6;
13232 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13233 vat_json_object_add_ip6 (node, "src_address", ip6);
13234 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13235 vat_json_object_add_ip6 (node, "dst_address", ip6);
13239 struct in_addr ip4;
13241 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13242 vat_json_object_add_ip4 (node, "src_address", ip4);
13243 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13244 vat_json_object_add_ip4 (node, "dst_address", ip4);
13246 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13247 vat_json_object_add_uint (node, "decap_next_index",
13248 ntohl (mp->decap_next_index));
13249 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13250 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13251 vat_json_object_add_uint (node, "mcast_sw_if_index",
13252 ntohl (mp->mcast_sw_if_index));
13256 api_geneve_tunnel_dump (vat_main_t * vam)
13258 unformat_input_t *i = vam->input;
13259 vl_api_geneve_tunnel_dump_t *mp;
13260 vl_api_control_ping_t *mp_ping;
13262 u8 sw_if_index_set = 0;
13265 /* Parse args required to build the message */
13266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13268 if (unformat (i, "sw_if_index %d", &sw_if_index))
13269 sw_if_index_set = 1;
13274 if (sw_if_index_set == 0)
13279 if (!vam->json_output)
13281 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13282 "sw_if_index", "local_address", "remote_address",
13283 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13286 /* Get list of geneve-tunnel interfaces */
13287 M (GENEVE_TUNNEL_DUMP, mp);
13289 mp->sw_if_index = htonl (sw_if_index);
13293 /* Use a control ping for synchronization */
13294 M (CONTROL_PING, mp_ping);
13302 api_gre_tunnel_add_del (vat_main_t * vam)
13304 unformat_input_t *line_input = vam->input;
13305 vl_api_address_t src = { }, dst =
13308 vl_api_gre_tunnel_add_del_t *mp;
13309 vl_api_gre_tunnel_type_t t_type;
13315 u32 outer_fib_id = 0;
13316 u32 session_id = 0;
13320 t_type = GRE_API_TUNNEL_TYPE_L3;
13322 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13324 if (unformat (line_input, "del"))
13326 else if (unformat (line_input, "instance %d", &instance))
13328 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13332 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13336 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13338 else if (unformat (line_input, "teb"))
13339 t_type = GRE_API_TUNNEL_TYPE_TEB;
13340 else if (unformat (line_input, "erspan %d", &session_id))
13341 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13344 errmsg ("parse error '%U'", format_unformat_error, line_input);
13351 errmsg ("tunnel src address not specified");
13356 errmsg ("tunnel dst address not specified");
13360 M (GRE_TUNNEL_ADD_DEL, mp);
13362 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13363 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13365 mp->tunnel.instance = htonl (instance);
13366 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13367 mp->is_add = is_add;
13368 mp->tunnel.session_id = htons ((u16) session_id);
13369 mp->tunnel.type = htonl (t_type);
13376 static void vl_api_gre_tunnel_details_t_handler
13377 (vl_api_gre_tunnel_details_t * mp)
13379 vat_main_t *vam = &vat_main;
13381 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13382 ntohl (mp->tunnel.sw_if_index),
13383 ntohl (mp->tunnel.instance),
13384 format_vl_api_address, &mp->tunnel.src,
13385 format_vl_api_address, &mp->tunnel.dst,
13386 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13387 ntohl (mp->tunnel.session_id));
13391 vat_json_object_add_address (vat_json_node_t * node,
13392 const char *str, const vl_api_address_t * addr)
13394 if (ADDRESS_IP6 == addr->af)
13396 struct in6_addr ip6;
13398 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
13399 vat_json_object_add_ip6 (node, str, ip6);
13403 struct in_addr ip4;
13405 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
13406 vat_json_object_add_ip4 (node, str, ip4);
13410 static void vl_api_gre_tunnel_details_t_handler_json
13411 (vl_api_gre_tunnel_details_t * mp)
13413 vat_main_t *vam = &vat_main;
13414 vat_json_node_t *node = NULL;
13415 struct in_addr ip4;
13416 struct in6_addr ip6;
13418 if (VAT_JSON_ARRAY != vam->json_tree.type)
13420 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13421 vat_json_init_array (&vam->json_tree);
13423 node = vat_json_array_add (&vam->json_tree);
13425 vat_json_init_object (node);
13426 vat_json_object_add_uint (node, "sw_if_index",
13427 ntohl (mp->tunnel.sw_if_index));
13428 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13430 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13431 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13432 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13433 vat_json_object_add_uint (node, "outer_fib_id",
13434 ntohl (mp->tunnel.outer_fib_id));
13435 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13439 api_gre_tunnel_dump (vat_main_t * vam)
13441 unformat_input_t *i = vam->input;
13442 vl_api_gre_tunnel_dump_t *mp;
13443 vl_api_control_ping_t *mp_ping;
13445 u8 sw_if_index_set = 0;
13448 /* Parse args required to build the message */
13449 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13451 if (unformat (i, "sw_if_index %d", &sw_if_index))
13452 sw_if_index_set = 1;
13457 if (sw_if_index_set == 0)
13462 if (!vam->json_output)
13464 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13465 "sw_if_index", "instance", "src_address", "dst_address",
13466 "tunnel_type", "outer_fib_id", "session_id");
13469 /* Get list of gre-tunnel interfaces */
13470 M (GRE_TUNNEL_DUMP, mp);
13472 mp->sw_if_index = htonl (sw_if_index);
13476 /* Use a control ping for synchronization */
13477 MPING (CONTROL_PING, mp_ping);
13485 api_l2_fib_clear_table (vat_main_t * vam)
13487 // unformat_input_t * i = vam->input;
13488 vl_api_l2_fib_clear_table_t *mp;
13491 M (L2_FIB_CLEAR_TABLE, mp);
13499 api_l2_interface_efp_filter (vat_main_t * vam)
13501 unformat_input_t *i = vam->input;
13502 vl_api_l2_interface_efp_filter_t *mp;
13505 u8 sw_if_index_set = 0;
13508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13510 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13511 sw_if_index_set = 1;
13512 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13513 sw_if_index_set = 1;
13514 else if (unformat (i, "enable"))
13516 else if (unformat (i, "disable"))
13520 clib_warning ("parse error '%U'", format_unformat_error, i);
13525 if (sw_if_index_set == 0)
13527 errmsg ("missing sw_if_index");
13531 M (L2_INTERFACE_EFP_FILTER, mp);
13533 mp->sw_if_index = ntohl (sw_if_index);
13534 mp->enable_disable = enable;
13541 #define foreach_vtr_op \
13542 _("disable", L2_VTR_DISABLED) \
13543 _("push-1", L2_VTR_PUSH_1) \
13544 _("push-2", L2_VTR_PUSH_2) \
13545 _("pop-1", L2_VTR_POP_1) \
13546 _("pop-2", L2_VTR_POP_2) \
13547 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13548 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13549 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13550 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13553 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13555 unformat_input_t *i = vam->input;
13556 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13558 u8 sw_if_index_set = 0;
13561 u32 push_dot1q = 1;
13566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13568 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13569 sw_if_index_set = 1;
13570 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13571 sw_if_index_set = 1;
13572 else if (unformat (i, "vtr_op %d", &vtr_op))
13574 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13577 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13579 else if (unformat (i, "tag1 %d", &tag1))
13581 else if (unformat (i, "tag2 %d", &tag2))
13585 clib_warning ("parse error '%U'", format_unformat_error, i);
13590 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13592 errmsg ("missing vtr operation or sw_if_index");
13596 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13597 mp->sw_if_index = ntohl (sw_if_index);
13598 mp->vtr_op = ntohl (vtr_op);
13599 mp->push_dot1q = ntohl (push_dot1q);
13600 mp->tag1 = ntohl (tag1);
13601 mp->tag2 = ntohl (tag2);
13609 api_create_vhost_user_if (vat_main_t * vam)
13611 unformat_input_t *i = vam->input;
13612 vl_api_create_vhost_user_if_t *mp;
13615 u8 file_name_set = 0;
13616 u32 custom_dev_instance = ~0;
13618 u8 use_custom_mac = 0;
13619 u8 disable_mrg_rxbuf = 0;
13620 u8 disable_indirect_desc = 0;
13624 /* Shut up coverity */
13625 clib_memset (hwaddr, 0, sizeof (hwaddr));
13627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13629 if (unformat (i, "socket %s", &file_name))
13633 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13635 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13636 use_custom_mac = 1;
13637 else if (unformat (i, "server"))
13639 else if (unformat (i, "disable_mrg_rxbuf"))
13640 disable_mrg_rxbuf = 1;
13641 else if (unformat (i, "disable_indirect_desc"))
13642 disable_indirect_desc = 1;
13643 else if (unformat (i, "tag %s", &tag))
13649 if (file_name_set == 0)
13651 errmsg ("missing socket file name");
13655 if (vec_len (file_name) > 255)
13657 errmsg ("socket file name too long");
13660 vec_add1 (file_name, 0);
13662 M (CREATE_VHOST_USER_IF, mp);
13664 mp->is_server = is_server;
13665 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13666 mp->disable_indirect_desc = disable_indirect_desc;
13667 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13668 vec_free (file_name);
13669 if (custom_dev_instance != ~0)
13672 mp->custom_dev_instance = ntohl (custom_dev_instance);
13675 mp->use_custom_mac = use_custom_mac;
13676 clib_memcpy (mp->mac_address, hwaddr, 6);
13678 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13687 api_modify_vhost_user_if (vat_main_t * vam)
13689 unformat_input_t *i = vam->input;
13690 vl_api_modify_vhost_user_if_t *mp;
13693 u8 file_name_set = 0;
13694 u32 custom_dev_instance = ~0;
13695 u8 sw_if_index_set = 0;
13696 u32 sw_if_index = (u32) ~ 0;
13699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13701 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13702 sw_if_index_set = 1;
13703 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13704 sw_if_index_set = 1;
13705 else if (unformat (i, "socket %s", &file_name))
13709 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13711 else if (unformat (i, "server"))
13717 if (sw_if_index_set == 0)
13719 errmsg ("missing sw_if_index or interface name");
13723 if (file_name_set == 0)
13725 errmsg ("missing socket file name");
13729 if (vec_len (file_name) > 255)
13731 errmsg ("socket file name too long");
13734 vec_add1 (file_name, 0);
13736 M (MODIFY_VHOST_USER_IF, mp);
13738 mp->sw_if_index = ntohl (sw_if_index);
13739 mp->is_server = is_server;
13740 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13741 vec_free (file_name);
13742 if (custom_dev_instance != ~0)
13745 mp->custom_dev_instance = ntohl (custom_dev_instance);
13754 api_delete_vhost_user_if (vat_main_t * vam)
13756 unformat_input_t *i = vam->input;
13757 vl_api_delete_vhost_user_if_t *mp;
13758 u32 sw_if_index = ~0;
13759 u8 sw_if_index_set = 0;
13762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13764 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13765 sw_if_index_set = 1;
13766 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13767 sw_if_index_set = 1;
13772 if (sw_if_index_set == 0)
13774 errmsg ("missing sw_if_index or interface name");
13779 M (DELETE_VHOST_USER_IF, mp);
13781 mp->sw_if_index = ntohl (sw_if_index);
13788 static void vl_api_sw_interface_vhost_user_details_t_handler
13789 (vl_api_sw_interface_vhost_user_details_t * mp)
13791 vat_main_t *vam = &vat_main;
13793 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13794 (char *) mp->interface_name,
13795 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13796 clib_net_to_host_u64 (mp->features), mp->is_server,
13797 ntohl (mp->num_regions), (char *) mp->sock_filename);
13798 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13801 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13802 (vl_api_sw_interface_vhost_user_details_t * mp)
13804 vat_main_t *vam = &vat_main;
13805 vat_json_node_t *node = NULL;
13807 if (VAT_JSON_ARRAY != vam->json_tree.type)
13809 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13810 vat_json_init_array (&vam->json_tree);
13812 node = vat_json_array_add (&vam->json_tree);
13814 vat_json_init_object (node);
13815 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13816 vat_json_object_add_string_copy (node, "interface_name",
13817 mp->interface_name);
13818 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13819 ntohl (mp->virtio_net_hdr_sz));
13820 vat_json_object_add_uint (node, "features",
13821 clib_net_to_host_u64 (mp->features));
13822 vat_json_object_add_uint (node, "is_server", mp->is_server);
13823 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13824 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13825 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13829 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13831 vl_api_sw_interface_vhost_user_dump_t *mp;
13832 vl_api_control_ping_t *mp_ping;
13835 "Interface name idx hdr_sz features server regions filename");
13837 /* Get list of vhost-user interfaces */
13838 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13841 /* Use a control ping for synchronization */
13842 MPING (CONTROL_PING, mp_ping);
13850 api_show_version (vat_main_t * vam)
13852 vl_api_show_version_t *mp;
13855 M (SHOW_VERSION, mp);
13864 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13866 unformat_input_t *line_input = vam->input;
13867 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13868 ip4_address_t local4, remote4;
13869 ip6_address_t local6, remote6;
13871 u8 ipv4_set = 0, ipv6_set = 0;
13875 u32 mcast_sw_if_index = ~0;
13876 u32 encap_vrf_id = 0;
13877 u32 decap_vrf_id = 0;
13883 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13884 clib_memset (&local4, 0, sizeof local4);
13885 clib_memset (&remote4, 0, sizeof remote4);
13886 clib_memset (&local6, 0, sizeof local6);
13887 clib_memset (&remote6, 0, sizeof remote6);
13889 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13891 if (unformat (line_input, "del"))
13893 else if (unformat (line_input, "local %U",
13894 unformat_ip4_address, &local4))
13899 else if (unformat (line_input, "remote %U",
13900 unformat_ip4_address, &remote4))
13905 else if (unformat (line_input, "local %U",
13906 unformat_ip6_address, &local6))
13911 else if (unformat (line_input, "remote %U",
13912 unformat_ip6_address, &remote6))
13917 else if (unformat (line_input, "group %U %U",
13918 unformat_ip4_address, &remote4,
13919 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13921 grp_set = remote_set = 1;
13924 else if (unformat (line_input, "group %U",
13925 unformat_ip4_address, &remote4))
13927 grp_set = remote_set = 1;
13930 else if (unformat (line_input, "group %U %U",
13931 unformat_ip6_address, &remote6,
13932 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13934 grp_set = remote_set = 1;
13937 else if (unformat (line_input, "group %U",
13938 unformat_ip6_address, &remote6))
13940 grp_set = remote_set = 1;
13944 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13946 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13948 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13950 else if (unformat (line_input, "vni %d", &vni))
13952 else if (unformat (line_input, "next-ip4"))
13954 else if (unformat (line_input, "next-ip6"))
13956 else if (unformat (line_input, "next-ethernet"))
13958 else if (unformat (line_input, "next-nsh"))
13962 errmsg ("parse error '%U'", format_unformat_error, line_input);
13967 if (local_set == 0)
13969 errmsg ("tunnel local address not specified");
13972 if (remote_set == 0)
13974 errmsg ("tunnel remote address not specified");
13977 if (grp_set && mcast_sw_if_index == ~0)
13979 errmsg ("tunnel nonexistent multicast device");
13982 if (ipv4_set && ipv6_set)
13984 errmsg ("both IPv4 and IPv6 addresses specified");
13990 errmsg ("vni not specified");
13994 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13999 clib_memcpy (&mp->local, &local6, sizeof (local6));
14000 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
14004 clib_memcpy (&mp->local, &local4, sizeof (local4));
14005 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14008 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14009 mp->encap_vrf_id = ntohl (encap_vrf_id);
14010 mp->decap_vrf_id = ntohl (decap_vrf_id);
14011 mp->protocol = protocol;
14012 mp->vni = ntohl (vni);
14013 mp->is_add = is_add;
14014 mp->is_ipv6 = ipv6_set;
14021 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14022 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14024 vat_main_t *vam = &vat_main;
14025 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14026 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14028 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14029 ntohl (mp->sw_if_index),
14030 format_ip46_address, &local, IP46_TYPE_ANY,
14031 format_ip46_address, &remote, IP46_TYPE_ANY,
14032 ntohl (mp->vni), mp->protocol,
14033 ntohl (mp->mcast_sw_if_index),
14034 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14038 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14039 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14041 vat_main_t *vam = &vat_main;
14042 vat_json_node_t *node = NULL;
14043 struct in_addr ip4;
14044 struct in6_addr ip6;
14046 if (VAT_JSON_ARRAY != vam->json_tree.type)
14048 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14049 vat_json_init_array (&vam->json_tree);
14051 node = vat_json_array_add (&vam->json_tree);
14053 vat_json_init_object (node);
14054 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14057 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14058 vat_json_object_add_ip6 (node, "local", ip6);
14059 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14060 vat_json_object_add_ip6 (node, "remote", ip6);
14064 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14065 vat_json_object_add_ip4 (node, "local", ip4);
14066 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14067 vat_json_object_add_ip4 (node, "remote", ip4);
14069 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14070 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14071 vat_json_object_add_uint (node, "mcast_sw_if_index",
14072 ntohl (mp->mcast_sw_if_index));
14073 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14074 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14075 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14079 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14081 unformat_input_t *i = vam->input;
14082 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14083 vl_api_control_ping_t *mp_ping;
14085 u8 sw_if_index_set = 0;
14088 /* Parse args required to build the message */
14089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14091 if (unformat (i, "sw_if_index %d", &sw_if_index))
14092 sw_if_index_set = 1;
14097 if (sw_if_index_set == 0)
14102 if (!vam->json_output)
14104 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14105 "sw_if_index", "local", "remote", "vni",
14106 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14109 /* Get list of vxlan-tunnel interfaces */
14110 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14112 mp->sw_if_index = htonl (sw_if_index);
14116 /* Use a control ping for synchronization */
14117 MPING (CONTROL_PING, mp_ping);
14124 static void vl_api_l2_fib_table_details_t_handler
14125 (vl_api_l2_fib_table_details_t * mp)
14127 vat_main_t *vam = &vat_main;
14129 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14131 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14132 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14136 static void vl_api_l2_fib_table_details_t_handler_json
14137 (vl_api_l2_fib_table_details_t * mp)
14139 vat_main_t *vam = &vat_main;
14140 vat_json_node_t *node = NULL;
14142 if (VAT_JSON_ARRAY != vam->json_tree.type)
14144 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14145 vat_json_init_array (&vam->json_tree);
14147 node = vat_json_array_add (&vam->json_tree);
14149 vat_json_init_object (node);
14150 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14151 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14152 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14153 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14154 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14155 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14159 api_l2_fib_table_dump (vat_main_t * vam)
14161 unformat_input_t *i = vam->input;
14162 vl_api_l2_fib_table_dump_t *mp;
14163 vl_api_control_ping_t *mp_ping;
14168 /* Parse args required to build the message */
14169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14171 if (unformat (i, "bd_id %d", &bd_id))
14177 if (bd_id_set == 0)
14179 errmsg ("missing bridge domain");
14183 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14185 /* Get list of l2 fib entries */
14186 M (L2_FIB_TABLE_DUMP, mp);
14188 mp->bd_id = ntohl (bd_id);
14191 /* Use a control ping for synchronization */
14192 MPING (CONTROL_PING, mp_ping);
14201 api_interface_name_renumber (vat_main_t * vam)
14203 unformat_input_t *line_input = vam->input;
14204 vl_api_interface_name_renumber_t *mp;
14205 u32 sw_if_index = ~0;
14206 u32 new_show_dev_instance = ~0;
14209 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14211 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14214 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14216 else if (unformat (line_input, "new_show_dev_instance %d",
14217 &new_show_dev_instance))
14223 if (sw_if_index == ~0)
14225 errmsg ("missing interface name or sw_if_index");
14229 if (new_show_dev_instance == ~0)
14231 errmsg ("missing new_show_dev_instance");
14235 M (INTERFACE_NAME_RENUMBER, mp);
14237 mp->sw_if_index = ntohl (sw_if_index);
14238 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14246 api_ip_probe_neighbor (vat_main_t * vam)
14248 unformat_input_t *i = vam->input;
14249 vl_api_ip_probe_neighbor_t *mp;
14250 vl_api_address_t dst_adr;
14256 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14258 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14260 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14262 else if (unformat (i, "address %U", unformat_vl_api_address, dst_adr))
14270 errmsg ("missing interface");
14276 errmsg ("missing addresses");
14280 M (IP_PROBE_NEIGHBOR, mp);
14282 mp->sw_if_index = ntohl (sw_if_index);
14283 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
14291 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14293 unformat_input_t *i = vam->input;
14294 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14295 u8 mode = IP_SCAN_V46_NEIGHBORS;
14296 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14299 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14301 if (unformat (i, "ip4"))
14302 mode = IP_SCAN_V4_NEIGHBORS;
14303 else if (unformat (i, "ip6"))
14304 mode = IP_SCAN_V6_NEIGHBORS;
14305 if (unformat (i, "both"))
14306 mode = IP_SCAN_V46_NEIGHBORS;
14307 else if (unformat (i, "disable"))
14308 mode = IP_SCAN_DISABLED;
14309 else if (unformat (i, "interval %d", &interval))
14311 else if (unformat (i, "max-time %d", &time))
14313 else if (unformat (i, "max-update %d", &update))
14315 else if (unformat (i, "delay %d", &delay))
14317 else if (unformat (i, "stale %d", &stale))
14323 if (interval > 255)
14325 errmsg ("interval cannot exceed 255 minutes.");
14330 errmsg ("max-time cannot exceed 255 usec.");
14335 errmsg ("max-update cannot exceed 255.");
14340 errmsg ("delay cannot exceed 255 msec.");
14345 errmsg ("stale cannot exceed 255 minutes.");
14349 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14351 mp->scan_interval = interval;
14352 mp->max_proc_time = time;
14353 mp->max_update = update;
14354 mp->scan_int_delay = delay;
14355 mp->stale_threshold = stale;
14363 api_want_ip4_arp_events (vat_main_t * vam)
14365 unformat_input_t *line_input = vam->input;
14366 vl_api_want_ip4_arp_events_t *mp;
14367 ip4_address_t address;
14368 int address_set = 0;
14369 u32 enable_disable = 1;
14372 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14374 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14376 else if (unformat (line_input, "del"))
14377 enable_disable = 0;
14382 if (address_set == 0)
14384 errmsg ("missing addresses");
14388 M (WANT_IP4_ARP_EVENTS, mp);
14389 mp->enable_disable = enable_disable;
14390 mp->pid = htonl (getpid ());
14391 clib_memcpy (mp->ip, &address, sizeof (address));
14399 api_want_ip6_nd_events (vat_main_t * vam)
14401 unformat_input_t *line_input = vam->input;
14402 vl_api_want_ip6_nd_events_t *mp;
14403 vl_api_ip6_address_t address;
14404 int address_set = 0;
14405 u32 enable_disable = 1;
14408 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14411 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14413 else if (unformat (line_input, "del"))
14414 enable_disable = 0;
14419 if (address_set == 0)
14421 errmsg ("missing addresses");
14425 M (WANT_IP6_ND_EVENTS, mp);
14426 mp->enable_disable = enable_disable;
14427 mp->pid = htonl (getpid ());
14428 clib_memcpy (&mp->ip, &address, sizeof (address));
14436 api_want_l2_macs_events (vat_main_t * vam)
14438 unformat_input_t *line_input = vam->input;
14439 vl_api_want_l2_macs_events_t *mp;
14440 u8 enable_disable = 1;
14441 u32 scan_delay = 0;
14442 u32 max_macs_in_event = 0;
14443 u32 learn_limit = 0;
14446 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14448 if (unformat (line_input, "learn-limit %d", &learn_limit))
14450 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14452 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14454 else if (unformat (line_input, "disable"))
14455 enable_disable = 0;
14460 M (WANT_L2_MACS_EVENTS, mp);
14461 mp->enable_disable = enable_disable;
14462 mp->pid = htonl (getpid ());
14463 mp->learn_limit = htonl (learn_limit);
14464 mp->scan_delay = (u8) scan_delay;
14465 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14472 api_input_acl_set_interface (vat_main_t * vam)
14474 unformat_input_t *i = vam->input;
14475 vl_api_input_acl_set_interface_t *mp;
14477 int sw_if_index_set;
14478 u32 ip4_table_index = ~0;
14479 u32 ip6_table_index = ~0;
14480 u32 l2_table_index = ~0;
14484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14487 sw_if_index_set = 1;
14488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14489 sw_if_index_set = 1;
14490 else if (unformat (i, "del"))
14492 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14494 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14496 else if (unformat (i, "l2-table %d", &l2_table_index))
14500 clib_warning ("parse error '%U'", format_unformat_error, i);
14505 if (sw_if_index_set == 0)
14507 errmsg ("missing interface name or sw_if_index");
14511 M (INPUT_ACL_SET_INTERFACE, mp);
14513 mp->sw_if_index = ntohl (sw_if_index);
14514 mp->ip4_table_index = ntohl (ip4_table_index);
14515 mp->ip6_table_index = ntohl (ip6_table_index);
14516 mp->l2_table_index = ntohl (l2_table_index);
14517 mp->is_add = is_add;
14525 api_output_acl_set_interface (vat_main_t * vam)
14527 unformat_input_t *i = vam->input;
14528 vl_api_output_acl_set_interface_t *mp;
14530 int sw_if_index_set;
14531 u32 ip4_table_index = ~0;
14532 u32 ip6_table_index = ~0;
14533 u32 l2_table_index = ~0;
14537 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14539 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14540 sw_if_index_set = 1;
14541 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14542 sw_if_index_set = 1;
14543 else if (unformat (i, "del"))
14545 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14547 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14549 else if (unformat (i, "l2-table %d", &l2_table_index))
14553 clib_warning ("parse error '%U'", format_unformat_error, i);
14558 if (sw_if_index_set == 0)
14560 errmsg ("missing interface name or sw_if_index");
14564 M (OUTPUT_ACL_SET_INTERFACE, mp);
14566 mp->sw_if_index = ntohl (sw_if_index);
14567 mp->ip4_table_index = ntohl (ip4_table_index);
14568 mp->ip6_table_index = ntohl (ip6_table_index);
14569 mp->l2_table_index = ntohl (l2_table_index);
14570 mp->is_add = is_add;
14578 api_ip_address_dump (vat_main_t * vam)
14580 unformat_input_t *i = vam->input;
14581 vl_api_ip_address_dump_t *mp;
14582 vl_api_control_ping_t *mp_ping;
14583 u32 sw_if_index = ~0;
14584 u8 sw_if_index_set = 0;
14589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14591 if (unformat (i, "sw_if_index %d", &sw_if_index))
14592 sw_if_index_set = 1;
14594 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14595 sw_if_index_set = 1;
14596 else if (unformat (i, "ipv4"))
14598 else if (unformat (i, "ipv6"))
14604 if (ipv4_set && ipv6_set)
14606 errmsg ("ipv4 and ipv6 flags cannot be both set");
14610 if ((!ipv4_set) && (!ipv6_set))
14612 errmsg ("no ipv4 nor ipv6 flag set");
14616 if (sw_if_index_set == 0)
14618 errmsg ("missing interface name or sw_if_index");
14622 vam->current_sw_if_index = sw_if_index;
14623 vam->is_ipv6 = ipv6_set;
14625 M (IP_ADDRESS_DUMP, mp);
14626 mp->sw_if_index = ntohl (sw_if_index);
14627 mp->is_ipv6 = ipv6_set;
14630 /* Use a control ping for synchronization */
14631 MPING (CONTROL_PING, mp_ping);
14639 api_ip_dump (vat_main_t * vam)
14641 vl_api_ip_dump_t *mp;
14642 vl_api_control_ping_t *mp_ping;
14643 unformat_input_t *in = vam->input;
14650 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14652 if (unformat (in, "ipv4"))
14654 else if (unformat (in, "ipv6"))
14660 if (ipv4_set && ipv6_set)
14662 errmsg ("ipv4 and ipv6 flags cannot be both set");
14666 if ((!ipv4_set) && (!ipv6_set))
14668 errmsg ("no ipv4 nor ipv6 flag set");
14672 is_ipv6 = ipv6_set;
14673 vam->is_ipv6 = is_ipv6;
14675 /* free old data */
14676 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14678 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14680 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14683 mp->is_ipv6 = ipv6_set;
14686 /* Use a control ping for synchronization */
14687 MPING (CONTROL_PING, mp_ping);
14695 api_ipsec_spd_add_del (vat_main_t * vam)
14697 unformat_input_t *i = vam->input;
14698 vl_api_ipsec_spd_add_del_t *mp;
14703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14705 if (unformat (i, "spd_id %d", &spd_id))
14707 else if (unformat (i, "del"))
14711 clib_warning ("parse error '%U'", format_unformat_error, i);
14717 errmsg ("spd_id must be set");
14721 M (IPSEC_SPD_ADD_DEL, mp);
14723 mp->spd_id = ntohl (spd_id);
14724 mp->is_add = is_add;
14732 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14734 unformat_input_t *i = vam->input;
14735 vl_api_ipsec_interface_add_del_spd_t *mp;
14737 u8 sw_if_index_set = 0;
14738 u32 spd_id = (u32) ~ 0;
14742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14744 if (unformat (i, "del"))
14746 else if (unformat (i, "spd_id %d", &spd_id))
14749 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14750 sw_if_index_set = 1;
14751 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14752 sw_if_index_set = 1;
14755 clib_warning ("parse error '%U'", format_unformat_error, i);
14761 if (spd_id == (u32) ~ 0)
14763 errmsg ("spd_id must be set");
14767 if (sw_if_index_set == 0)
14769 errmsg ("missing interface name or sw_if_index");
14773 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14775 mp->spd_id = ntohl (spd_id);
14776 mp->sw_if_index = ntohl (sw_if_index);
14777 mp->is_add = is_add;
14785 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14787 unformat_input_t *i = vam->input;
14788 vl_api_ipsec_spd_entry_add_del_t *mp;
14789 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14790 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14792 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14793 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14794 vl_api_address_t laddr_start = { }, laddr_stop =
14803 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14805 if (unformat (i, "del"))
14807 if (unformat (i, "outbound"))
14809 if (unformat (i, "inbound"))
14811 else if (unformat (i, "spd_id %d", &spd_id))
14813 else if (unformat (i, "sa_id %d", &sa_id))
14815 else if (unformat (i, "priority %d", &priority))
14817 else if (unformat (i, "protocol %d", &protocol))
14819 else if (unformat (i, "lport_start %d", &lport_start))
14821 else if (unformat (i, "lport_stop %d", &lport_stop))
14823 else if (unformat (i, "rport_start %d", &rport_start))
14825 else if (unformat (i, "rport_stop %d", &rport_stop))
14827 else if (unformat (i, "laddr_start %U",
14828 unformat_vl_api_address, &laddr_start))
14830 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14833 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14836 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14840 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14842 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14844 clib_warning ("unsupported action: 'resolve'");
14850 clib_warning ("parse error '%U'", format_unformat_error, i);
14856 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14858 mp->is_add = is_add;
14860 mp->entry.spd_id = ntohl (spd_id);
14861 mp->entry.priority = ntohl (priority);
14862 mp->entry.is_outbound = is_outbound;
14864 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14865 sizeof (vl_api_address_t));
14866 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14867 sizeof (vl_api_address_t));
14868 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14869 sizeof (vl_api_address_t));
14870 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14871 sizeof (vl_api_address_t));
14873 mp->entry.protocol = (u8) protocol;
14874 mp->entry.local_port_start = ntohs ((u16) lport_start);
14875 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14876 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14877 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14878 mp->entry.policy = (u8) policy;
14879 mp->entry.sa_id = ntohl (sa_id);
14887 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14889 unformat_input_t *i = vam->input;
14890 vl_api_ipsec_sad_entry_add_del_t *mp;
14891 u32 sad_id = 0, spi = 0;
14892 u8 *ck = 0, *ik = 0;
14895 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14896 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14897 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14898 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14899 vl_api_address_t tun_src, tun_dst;
14902 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14904 if (unformat (i, "del"))
14906 else if (unformat (i, "sad_id %d", &sad_id))
14908 else if (unformat (i, "spi %d", &spi))
14910 else if (unformat (i, "esp"))
14911 protocol = IPSEC_API_PROTO_ESP;
14913 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14915 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14916 if (ADDRESS_IP6 == tun_src.af)
14917 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14920 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14922 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14923 if (ADDRESS_IP6 == tun_src.af)
14924 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14927 if (unformat (i, "crypto_alg %U",
14928 unformat_ipsec_api_crypto_alg, &crypto_alg))
14930 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14932 else if (unformat (i, "integ_alg %U",
14933 unformat_ipsec_api_integ_alg, &integ_alg))
14935 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14939 clib_warning ("parse error '%U'", format_unformat_error, i);
14945 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14947 mp->is_add = is_add;
14948 mp->entry.sad_id = ntohl (sad_id);
14949 mp->entry.protocol = protocol;
14950 mp->entry.spi = ntohl (spi);
14951 mp->entry.flags = flags;
14953 mp->entry.crypto_algorithm = crypto_alg;
14954 mp->entry.integrity_algorithm = integ_alg;
14955 mp->entry.crypto_key.length = vec_len (ck);
14956 mp->entry.integrity_key.length = vec_len (ik);
14958 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14959 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14961 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14962 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14965 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14967 clib_memcpy (mp->entry.integrity_key.data, ik,
14968 mp->entry.integrity_key.length);
14970 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14972 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14973 sizeof (mp->entry.tunnel_src));
14974 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14975 sizeof (mp->entry.tunnel_dst));
14984 api_ipsec_sa_set_key (vat_main_t * vam)
14986 unformat_input_t *i = vam->input;
14987 vl_api_ipsec_sa_set_key_t *mp;
14989 u8 *ck = 0, *ik = 0;
14992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14994 if (unformat (i, "sa_id %d", &sa_id))
14996 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14998 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
15002 clib_warning ("parse error '%U'", format_unformat_error, i);
15007 M (IPSEC_SA_SET_KEY, mp);
15009 mp->sa_id = ntohl (sa_id);
15010 mp->crypto_key.length = vec_len (ck);
15011 mp->integrity_key.length = vec_len (ik);
15013 if (mp->crypto_key.length > sizeof (mp->crypto_key.data))
15014 mp->crypto_key.length = sizeof (mp->crypto_key.data);
15016 if (mp->integrity_key.length > sizeof (mp->integrity_key.data))
15017 mp->integrity_key.length = sizeof (mp->integrity_key.data);
15020 clib_memcpy (mp->crypto_key.data, ck, mp->crypto_key.length);
15022 clib_memcpy (mp->integrity_key.data, ik, mp->integrity_key.length);
15030 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15032 unformat_input_t *i = vam->input;
15033 vl_api_ipsec_tunnel_if_add_del_t *mp;
15034 u32 local_spi = 0, remote_spi = 0;
15035 u32 crypto_alg = 0, integ_alg = 0;
15036 u8 *lck = NULL, *rck = NULL;
15037 u8 *lik = NULL, *rik = NULL;
15038 vl_api_address_t local_ip = { 0 };
15039 vl_api_address_t remote_ip = { 0 };
15043 u8 anti_replay = 0;
15049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15051 if (unformat (i, "del"))
15053 else if (unformat (i, "esn"))
15055 else if (unformat (i, "anti-replay"))
15057 else if (unformat (i, "count %d", &count))
15059 else if (unformat (i, "local_spi %d", &local_spi))
15061 else if (unformat (i, "remote_spi %d", &remote_spi))
15064 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
15067 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
15069 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15072 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15074 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15076 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15080 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
15082 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15084 errmsg ("unsupported crypto-alg: '%U'\n",
15085 format_ipsec_crypto_alg, crypto_alg);
15091 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
15093 if (integ_alg >= IPSEC_INTEG_N_ALG)
15095 errmsg ("unsupported integ-alg: '%U'\n",
15096 format_ipsec_integ_alg, integ_alg);
15100 else if (unformat (i, "instance %u", &instance))
15104 errmsg ("parse error '%U'\n", format_unformat_error, i);
15111 /* Turn on async mode */
15112 vam->async_mode = 1;
15113 vam->async_errors = 0;
15114 before = vat_time_now (vam);
15117 for (jj = 0; jj < count; jj++)
15119 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15121 mp->is_add = is_add;
15123 mp->anti_replay = anti_replay;
15126 increment_vl_address (&remote_ip);
15128 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
15129 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
15131 mp->local_spi = htonl (local_spi + jj);
15132 mp->remote_spi = htonl (remote_spi + jj);
15133 mp->crypto_alg = (u8) crypto_alg;
15135 mp->local_crypto_key_len = 0;
15138 mp->local_crypto_key_len = vec_len (lck);
15139 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15140 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15141 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15144 mp->remote_crypto_key_len = 0;
15147 mp->remote_crypto_key_len = vec_len (rck);
15148 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15149 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15150 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15153 mp->integ_alg = (u8) integ_alg;
15155 mp->local_integ_key_len = 0;
15158 mp->local_integ_key_len = vec_len (lik);
15159 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15160 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15161 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15164 mp->remote_integ_key_len = 0;
15167 mp->remote_integ_key_len = vec_len (rik);
15168 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15169 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15170 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15175 mp->renumber = renumber;
15176 mp->show_instance = ntohl (instance);
15181 /* When testing multiple add/del ops, use a control-ping to sync */
15184 vl_api_control_ping_t *mp_ping;
15188 /* Shut off async mode */
15189 vam->async_mode = 0;
15191 MPING (CONTROL_PING, mp_ping);
15194 timeout = vat_time_now (vam) + 1.0;
15195 while (vat_time_now (vam) < timeout)
15196 if (vam->result_ready == 1)
15201 if (vam->retval == -99)
15202 errmsg ("timeout");
15204 if (vam->async_errors > 0)
15206 errmsg ("%d asynchronous errors", vam->async_errors);
15209 vam->async_errors = 0;
15210 after = vat_time_now (vam);
15212 /* slim chance, but we might have eaten SIGTERM on the first iteration */
15216 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
15217 count, after - before, count / (after - before));
15221 /* Wait for a reply... */
15230 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15232 vat_main_t *vam = &vat_main;
15234 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15235 "crypto_key %U integ_alg %u integ_key %U flags %x "
15236 "tunnel_src_addr %U tunnel_dst_addr %U "
15237 "salt %u seq_outbound %lu last_seq_inbound %lu "
15238 "replay_window %lu\n",
15239 ntohl (mp->entry.sad_id),
15240 ntohl (mp->sw_if_index),
15241 ntohl (mp->entry.spi),
15242 ntohl (mp->entry.protocol),
15243 ntohl (mp->entry.crypto_algorithm),
15244 format_hex_bytes, mp->entry.crypto_key.data,
15245 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
15246 format_hex_bytes, mp->entry.integrity_key.data,
15247 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
15248 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
15249 &mp->entry.tunnel_dst, ntohl (mp->salt),
15250 clib_net_to_host_u64 (mp->seq_outbound),
15251 clib_net_to_host_u64 (mp->last_seq_inbound),
15252 clib_net_to_host_u64 (mp->replay_window));
15255 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15256 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15258 static void vl_api_ipsec_sa_details_t_handler_json
15259 (vl_api_ipsec_sa_details_t * mp)
15261 vat_main_t *vam = &vat_main;
15262 vat_json_node_t *node = NULL;
15263 vl_api_ipsec_sad_flags_t flags;
15265 if (VAT_JSON_ARRAY != vam->json_tree.type)
15267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15268 vat_json_init_array (&vam->json_tree);
15270 node = vat_json_array_add (&vam->json_tree);
15272 vat_json_init_object (node);
15273 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
15274 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15275 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
15276 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
15277 vat_json_object_add_uint (node, "crypto_alg",
15278 ntohl (mp->entry.crypto_algorithm));
15279 vat_json_object_add_uint (node, "integ_alg",
15280 ntohl (mp->entry.integrity_algorithm));
15281 flags = ntohl (mp->entry.flags);
15282 vat_json_object_add_uint (node, "use_esn",
15283 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
15284 vat_json_object_add_uint (node, "use_anti_replay",
15285 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
15286 vat_json_object_add_uint (node, "is_tunnel",
15287 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
15288 vat_json_object_add_uint (node, "is_tunnel_ip6",
15289 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
15290 vat_json_object_add_uint (node, "udp_encap",
15291 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
15292 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
15293 mp->entry.crypto_key.length);
15294 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
15295 mp->entry.integrity_key.length);
15296 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
15297 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
15298 vat_json_object_add_uint (node, "replay_window",
15299 clib_net_to_host_u64 (mp->replay_window));
15303 api_ipsec_sa_dump (vat_main_t * vam)
15305 unformat_input_t *i = vam->input;
15306 vl_api_ipsec_sa_dump_t *mp;
15307 vl_api_control_ping_t *mp_ping;
15311 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15313 if (unformat (i, "sa_id %d", &sa_id))
15317 clib_warning ("parse error '%U'", format_unformat_error, i);
15322 M (IPSEC_SA_DUMP, mp);
15324 mp->sa_id = ntohl (sa_id);
15328 /* Use a control ping for synchronization */
15329 M (CONTROL_PING, mp_ping);
15337 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15339 unformat_input_t *i = vam->input;
15340 vl_api_ipsec_tunnel_if_set_key_t *mp;
15341 u32 sw_if_index = ~0;
15342 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15347 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15349 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15353 (i, "local crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15354 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15357 (i, "remote crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15358 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15361 (i, "local integ %U", unformat_ipsec_api_integ_alg, &alg))
15362 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15365 (i, "remote integ %U", unformat_ipsec_api_integ_alg, &alg))
15366 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15367 else if (unformat (i, "%U", unformat_hex_string, &key))
15371 clib_warning ("parse error '%U'", format_unformat_error, i);
15376 if (sw_if_index == ~0)
15378 errmsg ("interface must be specified");
15382 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15384 errmsg ("key type must be specified");
15390 errmsg ("algorithm must be specified");
15394 if (vec_len (key) == 0)
15396 errmsg ("key must be specified");
15400 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15402 mp->sw_if_index = htonl (sw_if_index);
15404 mp->key_type = key_type;
15405 mp->key_len = vec_len (key);
15406 clib_memcpy (mp->key, key, vec_len (key));
15415 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15417 unformat_input_t *i = vam->input;
15418 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15419 u32 sw_if_index = ~0;
15421 u8 is_outbound = (u8) ~ 0;
15424 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15426 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15428 else if (unformat (i, "sa_id %d", &sa_id))
15430 else if (unformat (i, "outbound"))
15432 else if (unformat (i, "inbound"))
15436 clib_warning ("parse error '%U'", format_unformat_error, i);
15441 if (sw_if_index == ~0)
15443 errmsg ("interface must be specified");
15449 errmsg ("SA ID must be specified");
15453 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15455 mp->sw_if_index = htonl (sw_if_index);
15456 mp->sa_id = htonl (sa_id);
15457 mp->is_outbound = is_outbound;
15466 api_get_first_msg_id (vat_main_t * vam)
15468 vl_api_get_first_msg_id_t *mp;
15469 unformat_input_t *i = vam->input;
15474 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15476 if (unformat (i, "client %s", &name))
15484 errmsg ("missing client name");
15487 vec_add1 (name, 0);
15489 if (vec_len (name) > 63)
15491 errmsg ("client name too long");
15495 M (GET_FIRST_MSG_ID, mp);
15496 clib_memcpy (mp->name, name, vec_len (name));
15503 api_cop_interface_enable_disable (vat_main_t * vam)
15505 unformat_input_t *line_input = vam->input;
15506 vl_api_cop_interface_enable_disable_t *mp;
15507 u32 sw_if_index = ~0;
15508 u8 enable_disable = 1;
15511 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15513 if (unformat (line_input, "disable"))
15514 enable_disable = 0;
15515 if (unformat (line_input, "enable"))
15516 enable_disable = 1;
15517 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15518 vam, &sw_if_index))
15520 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15526 if (sw_if_index == ~0)
15528 errmsg ("missing interface name or sw_if_index");
15532 /* Construct the API message */
15533 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15534 mp->sw_if_index = ntohl (sw_if_index);
15535 mp->enable_disable = enable_disable;
15539 /* Wait for the reply */
15545 api_cop_whitelist_enable_disable (vat_main_t * vam)
15547 unformat_input_t *line_input = vam->input;
15548 vl_api_cop_whitelist_enable_disable_t *mp;
15549 u32 sw_if_index = ~0;
15550 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15554 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15556 if (unformat (line_input, "ip4"))
15558 else if (unformat (line_input, "ip6"))
15560 else if (unformat (line_input, "default"))
15562 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15563 vam, &sw_if_index))
15565 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15567 else if (unformat (line_input, "fib-id %d", &fib_id))
15573 if (sw_if_index == ~0)
15575 errmsg ("missing interface name or sw_if_index");
15579 /* Construct the API message */
15580 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15581 mp->sw_if_index = ntohl (sw_if_index);
15582 mp->fib_id = ntohl (fib_id);
15585 mp->default_cop = default_cop;
15589 /* Wait for the reply */
15595 api_get_node_graph (vat_main_t * vam)
15597 vl_api_get_node_graph_t *mp;
15600 M (GET_NODE_GRAPH, mp);
15604 /* Wait for the reply */
15610 /** Used for parsing LISP eids */
15611 typedef CLIB_PACKED(struct{
15612 u8 addr[16]; /**< eid address */
15613 u32 len; /**< prefix length if IP */
15614 u8 type; /**< type of eid */
15619 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15621 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15623 clib_memset (a, 0, sizeof (a[0]));
15625 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15627 a->type = 0; /* ipv4 type */
15629 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15631 a->type = 1; /* ipv6 type */
15633 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15635 a->type = 2; /* mac type */
15637 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15639 a->type = 3; /* NSH type */
15640 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15641 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15648 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15657 lisp_eid_size_vat (u8 type)
15674 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15676 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15680 api_one_add_del_locator_set (vat_main_t * vam)
15682 unformat_input_t *input = vam->input;
15683 vl_api_one_add_del_locator_set_t *mp;
15685 u8 *locator_set_name = NULL;
15686 u8 locator_set_name_set = 0;
15687 vl_api_local_locator_t locator, *locators = 0;
15688 u32 sw_if_index, priority, weight;
15692 /* Parse args required to build the message */
15693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15695 if (unformat (input, "del"))
15699 else if (unformat (input, "locator-set %s", &locator_set_name))
15701 locator_set_name_set = 1;
15703 else if (unformat (input, "sw_if_index %u p %u w %u",
15704 &sw_if_index, &priority, &weight))
15706 locator.sw_if_index = htonl (sw_if_index);
15707 locator.priority = priority;
15708 locator.weight = weight;
15709 vec_add1 (locators, locator);
15713 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15714 &sw_if_index, &priority, &weight))
15716 locator.sw_if_index = htonl (sw_if_index);
15717 locator.priority = priority;
15718 locator.weight = weight;
15719 vec_add1 (locators, locator);
15725 if (locator_set_name_set == 0)
15727 errmsg ("missing locator-set name");
15728 vec_free (locators);
15732 if (vec_len (locator_set_name) > 64)
15734 errmsg ("locator-set name too long");
15735 vec_free (locator_set_name);
15736 vec_free (locators);
15739 vec_add1 (locator_set_name, 0);
15741 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15743 /* Construct the API message */
15744 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15746 mp->is_add = is_add;
15747 clib_memcpy (mp->locator_set_name, locator_set_name,
15748 vec_len (locator_set_name));
15749 vec_free (locator_set_name);
15751 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15753 clib_memcpy (mp->locators, locators, data_len);
15754 vec_free (locators);
15759 /* Wait for a reply... */
15764 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15767 api_one_add_del_locator (vat_main_t * vam)
15769 unformat_input_t *input = vam->input;
15770 vl_api_one_add_del_locator_t *mp;
15771 u32 tmp_if_index = ~0;
15772 u32 sw_if_index = ~0;
15773 u8 sw_if_index_set = 0;
15774 u8 sw_if_index_if_name_set = 0;
15776 u8 priority_set = 0;
15780 u8 *locator_set_name = NULL;
15781 u8 locator_set_name_set = 0;
15784 /* Parse args required to build the message */
15785 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15787 if (unformat (input, "del"))
15791 else if (unformat (input, "locator-set %s", &locator_set_name))
15793 locator_set_name_set = 1;
15795 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15798 sw_if_index_if_name_set = 1;
15799 sw_if_index = tmp_if_index;
15801 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15803 sw_if_index_set = 1;
15804 sw_if_index = tmp_if_index;
15806 else if (unformat (input, "p %d", &priority))
15810 else if (unformat (input, "w %d", &weight))
15818 if (locator_set_name_set == 0)
15820 errmsg ("missing locator-set name");
15824 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15826 errmsg ("missing sw_if_index");
15827 vec_free (locator_set_name);
15831 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15833 errmsg ("cannot use both params interface name and sw_if_index");
15834 vec_free (locator_set_name);
15838 if (priority_set == 0)
15840 errmsg ("missing locator-set priority");
15841 vec_free (locator_set_name);
15845 if (weight_set == 0)
15847 errmsg ("missing locator-set weight");
15848 vec_free (locator_set_name);
15852 if (vec_len (locator_set_name) > 64)
15854 errmsg ("locator-set name too long");
15855 vec_free (locator_set_name);
15858 vec_add1 (locator_set_name, 0);
15860 /* Construct the API message */
15861 M (ONE_ADD_DEL_LOCATOR, mp);
15863 mp->is_add = is_add;
15864 mp->sw_if_index = ntohl (sw_if_index);
15865 mp->priority = priority;
15866 mp->weight = weight;
15867 clib_memcpy (mp->locator_set_name, locator_set_name,
15868 vec_len (locator_set_name));
15869 vec_free (locator_set_name);
15874 /* Wait for a reply... */
15879 #define api_lisp_add_del_locator api_one_add_del_locator
15882 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15884 u32 *key_id = va_arg (*args, u32 *);
15887 if (unformat (input, "%s", &s))
15889 if (!strcmp ((char *) s, "sha1"))
15890 key_id[0] = HMAC_SHA_1_96;
15891 else if (!strcmp ((char *) s, "sha256"))
15892 key_id[0] = HMAC_SHA_256_128;
15895 clib_warning ("invalid key_id: '%s'", s);
15896 key_id[0] = HMAC_NO_KEY;
15907 api_one_add_del_local_eid (vat_main_t * vam)
15909 unformat_input_t *input = vam->input;
15910 vl_api_one_add_del_local_eid_t *mp;
15913 lisp_eid_vat_t _eid, *eid = &_eid;
15914 u8 *locator_set_name = 0;
15915 u8 locator_set_name_set = 0;
15921 /* Parse args required to build the message */
15922 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15924 if (unformat (input, "del"))
15928 else if (unformat (input, "vni %d", &vni))
15932 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15936 else if (unformat (input, "locator-set %s", &locator_set_name))
15938 locator_set_name_set = 1;
15940 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15942 else if (unformat (input, "secret-key %_%v%_", &key))
15948 if (locator_set_name_set == 0)
15950 errmsg ("missing locator-set name");
15956 errmsg ("EID address not set!");
15957 vec_free (locator_set_name);
15961 if (key && (0 == key_id))
15963 errmsg ("invalid key_id!");
15967 if (vec_len (key) > 64)
15969 errmsg ("key too long");
15974 if (vec_len (locator_set_name) > 64)
15976 errmsg ("locator-set name too long");
15977 vec_free (locator_set_name);
15980 vec_add1 (locator_set_name, 0);
15982 /* Construct the API message */
15983 M (ONE_ADD_DEL_LOCAL_EID, mp);
15985 mp->is_add = is_add;
15986 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15987 mp->eid_type = eid->type;
15988 mp->prefix_len = eid->len;
15989 mp->vni = clib_host_to_net_u32 (vni);
15990 mp->key_id = clib_host_to_net_u16 (key_id);
15991 clib_memcpy (mp->locator_set_name, locator_set_name,
15992 vec_len (locator_set_name));
15993 clib_memcpy (mp->key, key, vec_len (key));
15995 vec_free (locator_set_name);
16001 /* Wait for a reply... */
16006 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16009 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16011 u32 dp_table = 0, vni = 0;;
16012 unformat_input_t *input = vam->input;
16013 vl_api_gpe_add_del_fwd_entry_t *mp;
16015 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16016 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16017 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16018 u32 action = ~0, w;
16019 ip4_address_t rmt_rloc4, lcl_rloc4;
16020 ip6_address_t rmt_rloc6, lcl_rloc6;
16021 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16024 clib_memset (&rloc, 0, sizeof (rloc));
16026 /* Parse args required to build the message */
16027 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16029 if (unformat (input, "del"))
16031 else if (unformat (input, "add"))
16033 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16037 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16041 else if (unformat (input, "vrf %d", &dp_table))
16043 else if (unformat (input, "bd %d", &dp_table))
16045 else if (unformat (input, "vni %d", &vni))
16047 else if (unformat (input, "w %d", &w))
16051 errmsg ("No RLOC configured for setting priority/weight!");
16054 curr_rloc->weight = w;
16056 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16057 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16061 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16063 vec_add1 (lcl_locs, rloc);
16065 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16066 vec_add1 (rmt_locs, rloc);
16067 /* weight saved in rmt loc */
16068 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16070 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16071 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16074 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16076 vec_add1 (lcl_locs, rloc);
16078 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16079 vec_add1 (rmt_locs, rloc);
16080 /* weight saved in rmt loc */
16081 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16083 else if (unformat (input, "action %d", &action))
16089 clib_warning ("parse error '%U'", format_unformat_error, input);
16096 errmsg ("remote eid addresses not set");
16100 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16102 errmsg ("eid types don't match");
16106 if (0 == rmt_locs && (u32) ~ 0 == action)
16108 errmsg ("action not set for negative mapping");
16112 /* Construct the API message */
16113 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16114 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16116 mp->is_add = is_add;
16117 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16118 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16119 mp->eid_type = rmt_eid->type;
16120 mp->dp_table = clib_host_to_net_u32 (dp_table);
16121 mp->vni = clib_host_to_net_u32 (vni);
16122 mp->rmt_len = rmt_eid->len;
16123 mp->lcl_len = lcl_eid->len;
16124 mp->action = action;
16126 if (0 != rmt_locs && 0 != lcl_locs)
16128 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16129 clib_memcpy (mp->locs, lcl_locs,
16130 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16132 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16133 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16134 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16136 vec_free (lcl_locs);
16137 vec_free (rmt_locs);
16142 /* Wait for a reply... */
16148 api_one_add_del_map_server (vat_main_t * vam)
16150 unformat_input_t *input = vam->input;
16151 vl_api_one_add_del_map_server_t *mp;
16155 ip4_address_t ipv4;
16156 ip6_address_t ipv6;
16159 /* Parse args required to build the message */
16160 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16162 if (unformat (input, "del"))
16166 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16170 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16178 if (ipv4_set && ipv6_set)
16180 errmsg ("both eid v4 and v6 addresses set");
16184 if (!ipv4_set && !ipv6_set)
16186 errmsg ("eid addresses not set");
16190 /* Construct the API message */
16191 M (ONE_ADD_DEL_MAP_SERVER, mp);
16193 mp->is_add = is_add;
16197 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16202 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16208 /* Wait for a reply... */
16213 #define api_lisp_add_del_map_server api_one_add_del_map_server
16216 api_one_add_del_map_resolver (vat_main_t * vam)
16218 unformat_input_t *input = vam->input;
16219 vl_api_one_add_del_map_resolver_t *mp;
16223 ip4_address_t ipv4;
16224 ip6_address_t ipv6;
16227 /* Parse args required to build the message */
16228 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16230 if (unformat (input, "del"))
16234 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16238 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16246 if (ipv4_set && ipv6_set)
16248 errmsg ("both eid v4 and v6 addresses set");
16252 if (!ipv4_set && !ipv6_set)
16254 errmsg ("eid addresses not set");
16258 /* Construct the API message */
16259 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16261 mp->is_add = is_add;
16265 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16270 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16276 /* Wait for a reply... */
16281 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16284 api_lisp_gpe_enable_disable (vat_main_t * vam)
16286 unformat_input_t *input = vam->input;
16287 vl_api_gpe_enable_disable_t *mp;
16292 /* Parse args required to build the message */
16293 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16295 if (unformat (input, "enable"))
16300 else if (unformat (input, "disable"))
16311 errmsg ("Value not set");
16315 /* Construct the API message */
16316 M (GPE_ENABLE_DISABLE, mp);
16323 /* Wait for a reply... */
16329 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16331 unformat_input_t *input = vam->input;
16332 vl_api_one_rloc_probe_enable_disable_t *mp;
16337 /* Parse args required to build the message */
16338 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16340 if (unformat (input, "enable"))
16345 else if (unformat (input, "disable"))
16353 errmsg ("Value not set");
16357 /* Construct the API message */
16358 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16360 mp->is_enabled = is_en;
16365 /* Wait for a reply... */
16370 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16373 api_one_map_register_enable_disable (vat_main_t * vam)
16375 unformat_input_t *input = vam->input;
16376 vl_api_one_map_register_enable_disable_t *mp;
16381 /* Parse args required to build the message */
16382 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16384 if (unformat (input, "enable"))
16389 else if (unformat (input, "disable"))
16397 errmsg ("Value not set");
16401 /* Construct the API message */
16402 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16404 mp->is_enabled = is_en;
16409 /* Wait for a reply... */
16414 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16417 api_one_enable_disable (vat_main_t * vam)
16419 unformat_input_t *input = vam->input;
16420 vl_api_one_enable_disable_t *mp;
16425 /* Parse args required to build the message */
16426 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16428 if (unformat (input, "enable"))
16433 else if (unformat (input, "disable"))
16443 errmsg ("Value not set");
16447 /* Construct the API message */
16448 M (ONE_ENABLE_DISABLE, mp);
16455 /* Wait for a reply... */
16460 #define api_lisp_enable_disable api_one_enable_disable
16463 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16465 unformat_input_t *input = vam->input;
16466 vl_api_one_enable_disable_xtr_mode_t *mp;
16471 /* Parse args required to build the message */
16472 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16474 if (unformat (input, "enable"))
16479 else if (unformat (input, "disable"))
16489 errmsg ("Value not set");
16493 /* Construct the API message */
16494 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16501 /* Wait for a reply... */
16507 api_one_show_xtr_mode (vat_main_t * vam)
16509 vl_api_one_show_xtr_mode_t *mp;
16512 /* Construct the API message */
16513 M (ONE_SHOW_XTR_MODE, mp);
16518 /* Wait for a reply... */
16524 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16526 unformat_input_t *input = vam->input;
16527 vl_api_one_enable_disable_pitr_mode_t *mp;
16532 /* Parse args required to build the message */
16533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16535 if (unformat (input, "enable"))
16540 else if (unformat (input, "disable"))
16550 errmsg ("Value not set");
16554 /* Construct the API message */
16555 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16562 /* Wait for a reply... */
16568 api_one_show_pitr_mode (vat_main_t * vam)
16570 vl_api_one_show_pitr_mode_t *mp;
16573 /* Construct the API message */
16574 M (ONE_SHOW_PITR_MODE, mp);
16579 /* Wait for a reply... */
16585 api_one_enable_disable_petr_mode (vat_main_t * vam)
16587 unformat_input_t *input = vam->input;
16588 vl_api_one_enable_disable_petr_mode_t *mp;
16593 /* Parse args required to build the message */
16594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16596 if (unformat (input, "enable"))
16601 else if (unformat (input, "disable"))
16611 errmsg ("Value not set");
16615 /* Construct the API message */
16616 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16623 /* Wait for a reply... */
16629 api_one_show_petr_mode (vat_main_t * vam)
16631 vl_api_one_show_petr_mode_t *mp;
16634 /* Construct the API message */
16635 M (ONE_SHOW_PETR_MODE, mp);
16640 /* Wait for a reply... */
16646 api_show_one_map_register_state (vat_main_t * vam)
16648 vl_api_show_one_map_register_state_t *mp;
16651 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16656 /* wait for reply */
16661 #define api_show_lisp_map_register_state api_show_one_map_register_state
16664 api_show_one_rloc_probe_state (vat_main_t * vam)
16666 vl_api_show_one_rloc_probe_state_t *mp;
16669 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16674 /* wait for reply */
16679 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16682 api_one_add_del_ndp_entry (vat_main_t * vam)
16684 vl_api_one_add_del_ndp_entry_t *mp;
16685 unformat_input_t *input = vam->input;
16690 u8 mac[6] = { 0, };
16691 u8 ip6[16] = { 0, };
16695 /* Parse args required to build the message */
16696 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16698 if (unformat (input, "del"))
16700 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16702 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16704 else if (unformat (input, "bd %d", &bd))
16708 errmsg ("parse error '%U'", format_unformat_error, input);
16713 if (!bd_set || !ip_set || (!mac_set && is_add))
16715 errmsg ("Missing BD, IP or MAC!");
16719 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16720 mp->is_add = is_add;
16721 clib_memcpy (mp->mac, mac, 6);
16722 mp->bd = clib_host_to_net_u32 (bd);
16723 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16728 /* wait for reply */
16734 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16736 vl_api_one_add_del_l2_arp_entry_t *mp;
16737 unformat_input_t *input = vam->input;
16742 u8 mac[6] = { 0, };
16743 u32 ip4 = 0, bd = ~0;
16746 /* Parse args required to build the message */
16747 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16749 if (unformat (input, "del"))
16751 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16753 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16755 else if (unformat (input, "bd %d", &bd))
16759 errmsg ("parse error '%U'", format_unformat_error, input);
16764 if (!bd_set || !ip_set || (!mac_set && is_add))
16766 errmsg ("Missing BD, IP or MAC!");
16770 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16771 mp->is_add = is_add;
16772 clib_memcpy (mp->mac, mac, 6);
16773 mp->bd = clib_host_to_net_u32 (bd);
16779 /* wait for reply */
16785 api_one_ndp_bd_get (vat_main_t * vam)
16787 vl_api_one_ndp_bd_get_t *mp;
16790 M (ONE_NDP_BD_GET, mp);
16795 /* wait for reply */
16801 api_one_ndp_entries_get (vat_main_t * vam)
16803 vl_api_one_ndp_entries_get_t *mp;
16804 unformat_input_t *input = vam->input;
16809 /* Parse args required to build the message */
16810 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16812 if (unformat (input, "bd %d", &bd))
16816 errmsg ("parse error '%U'", format_unformat_error, input);
16823 errmsg ("Expected bridge domain!");
16827 M (ONE_NDP_ENTRIES_GET, mp);
16828 mp->bd = clib_host_to_net_u32 (bd);
16833 /* wait for reply */
16839 api_one_l2_arp_bd_get (vat_main_t * vam)
16841 vl_api_one_l2_arp_bd_get_t *mp;
16844 M (ONE_L2_ARP_BD_GET, mp);
16849 /* wait for reply */
16855 api_one_l2_arp_entries_get (vat_main_t * vam)
16857 vl_api_one_l2_arp_entries_get_t *mp;
16858 unformat_input_t *input = vam->input;
16863 /* Parse args required to build the message */
16864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16866 if (unformat (input, "bd %d", &bd))
16870 errmsg ("parse error '%U'", format_unformat_error, input);
16877 errmsg ("Expected bridge domain!");
16881 M (ONE_L2_ARP_ENTRIES_GET, mp);
16882 mp->bd = clib_host_to_net_u32 (bd);
16887 /* wait for reply */
16893 api_one_stats_enable_disable (vat_main_t * vam)
16895 vl_api_one_stats_enable_disable_t *mp;
16896 unformat_input_t *input = vam->input;
16901 /* Parse args required to build the message */
16902 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16904 if (unformat (input, "enable"))
16909 else if (unformat (input, "disable"))
16919 errmsg ("Value not set");
16923 M (ONE_STATS_ENABLE_DISABLE, mp);
16929 /* wait for reply */
16935 api_show_one_stats_enable_disable (vat_main_t * vam)
16937 vl_api_show_one_stats_enable_disable_t *mp;
16940 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16945 /* wait for reply */
16951 api_show_one_map_request_mode (vat_main_t * vam)
16953 vl_api_show_one_map_request_mode_t *mp;
16956 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16961 /* wait for reply */
16966 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16969 api_one_map_request_mode (vat_main_t * vam)
16971 unformat_input_t *input = vam->input;
16972 vl_api_one_map_request_mode_t *mp;
16976 /* Parse args required to build the message */
16977 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16979 if (unformat (input, "dst-only"))
16981 else if (unformat (input, "src-dst"))
16985 errmsg ("parse error '%U'", format_unformat_error, input);
16990 M (ONE_MAP_REQUEST_MODE, mp);
16997 /* wait for reply */
17002 #define api_lisp_map_request_mode api_one_map_request_mode
17005 * Enable/disable ONE proxy ITR.
17007 * @param vam vpp API test context
17008 * @return return code
17011 api_one_pitr_set_locator_set (vat_main_t * vam)
17013 u8 ls_name_set = 0;
17014 unformat_input_t *input = vam->input;
17015 vl_api_one_pitr_set_locator_set_t *mp;
17020 /* Parse args required to build the message */
17021 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17023 if (unformat (input, "del"))
17025 else if (unformat (input, "locator-set %s", &ls_name))
17029 errmsg ("parse error '%U'", format_unformat_error, input);
17036 errmsg ("locator-set name not set!");
17040 M (ONE_PITR_SET_LOCATOR_SET, mp);
17042 mp->is_add = is_add;
17043 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17044 vec_free (ls_name);
17049 /* wait for reply */
17054 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17057 api_one_nsh_set_locator_set (vat_main_t * vam)
17059 u8 ls_name_set = 0;
17060 unformat_input_t *input = vam->input;
17061 vl_api_one_nsh_set_locator_set_t *mp;
17066 /* Parse args required to build the message */
17067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17069 if (unformat (input, "del"))
17071 else if (unformat (input, "ls %s", &ls_name))
17075 errmsg ("parse error '%U'", format_unformat_error, input);
17080 if (!ls_name_set && is_add)
17082 errmsg ("locator-set name not set!");
17086 M (ONE_NSH_SET_LOCATOR_SET, mp);
17088 mp->is_add = is_add;
17089 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17090 vec_free (ls_name);
17095 /* wait for reply */
17101 api_show_one_pitr (vat_main_t * vam)
17103 vl_api_show_one_pitr_t *mp;
17106 if (!vam->json_output)
17108 print (vam->ofp, "%=20s", "lisp status:");
17111 M (SHOW_ONE_PITR, mp);
17115 /* Wait for a reply... */
17120 #define api_show_lisp_pitr api_show_one_pitr
17123 api_one_use_petr (vat_main_t * vam)
17125 unformat_input_t *input = vam->input;
17126 vl_api_one_use_petr_t *mp;
17131 clib_memset (&ip, 0, sizeof (ip));
17133 /* Parse args required to build the message */
17134 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17136 if (unformat (input, "disable"))
17139 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17142 ip_addr_version (&ip) = IP4;
17145 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17148 ip_addr_version (&ip) = IP6;
17152 errmsg ("parse error '%U'", format_unformat_error, input);
17157 M (ONE_USE_PETR, mp);
17159 mp->is_add = is_add;
17162 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17164 clib_memcpy (mp->address, &ip, 4);
17166 clib_memcpy (mp->address, &ip, 16);
17172 /* wait for reply */
17177 #define api_lisp_use_petr api_one_use_petr
17180 api_show_one_nsh_mapping (vat_main_t * vam)
17182 vl_api_show_one_use_petr_t *mp;
17185 if (!vam->json_output)
17187 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17190 M (SHOW_ONE_NSH_MAPPING, mp);
17194 /* Wait for a reply... */
17200 api_show_one_use_petr (vat_main_t * vam)
17202 vl_api_show_one_use_petr_t *mp;
17205 if (!vam->json_output)
17207 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17210 M (SHOW_ONE_USE_PETR, mp);
17214 /* Wait for a reply... */
17219 #define api_show_lisp_use_petr api_show_one_use_petr
17222 * Add/delete mapping between vni and vrf
17225 api_one_eid_table_add_del_map (vat_main_t * vam)
17227 unformat_input_t *input = vam->input;
17228 vl_api_one_eid_table_add_del_map_t *mp;
17229 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17230 u32 vni, vrf, bd_index;
17233 /* Parse args required to build the message */
17234 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17236 if (unformat (input, "del"))
17238 else if (unformat (input, "vrf %d", &vrf))
17240 else if (unformat (input, "bd_index %d", &bd_index))
17242 else if (unformat (input, "vni %d", &vni))
17248 if (!vni_set || (!vrf_set && !bd_index_set))
17250 errmsg ("missing arguments!");
17254 if (vrf_set && bd_index_set)
17256 errmsg ("error: both vrf and bd entered!");
17260 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17262 mp->is_add = is_add;
17263 mp->vni = htonl (vni);
17264 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17265 mp->is_l2 = bd_index_set;
17270 /* wait for reply */
17275 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17278 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17280 u32 *action = va_arg (*args, u32 *);
17283 if (unformat (input, "%s", &s))
17285 if (!strcmp ((char *) s, "no-action"))
17287 else if (!strcmp ((char *) s, "natively-forward"))
17289 else if (!strcmp ((char *) s, "send-map-request"))
17291 else if (!strcmp ((char *) s, "drop"))
17295 clib_warning ("invalid action: '%s'", s);
17307 * Add/del remote mapping to/from ONE control plane
17309 * @param vam vpp API test context
17310 * @return return code
17313 api_one_add_del_remote_mapping (vat_main_t * vam)
17315 unformat_input_t *input = vam->input;
17316 vl_api_one_add_del_remote_mapping_t *mp;
17318 lisp_eid_vat_t _eid, *eid = &_eid;
17319 lisp_eid_vat_t _seid, *seid = &_seid;
17320 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17321 u32 action = ~0, p, w, data_len;
17322 ip4_address_t rloc4;
17323 ip6_address_t rloc6;
17324 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17327 clib_memset (&rloc, 0, sizeof (rloc));
17329 /* Parse args required to build the message */
17330 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17332 if (unformat (input, "del-all"))
17336 else if (unformat (input, "del"))
17340 else if (unformat (input, "add"))
17344 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17348 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17352 else if (unformat (input, "vni %d", &vni))
17356 else if (unformat (input, "p %d w %d", &p, &w))
17360 errmsg ("No RLOC configured for setting priority/weight!");
17363 curr_rloc->priority = p;
17364 curr_rloc->weight = w;
17366 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17369 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17370 vec_add1 (rlocs, rloc);
17371 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17373 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17376 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17377 vec_add1 (rlocs, rloc);
17378 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17380 else if (unformat (input, "action %U",
17381 unformat_negative_mapping_action, &action))
17387 clib_warning ("parse error '%U'", format_unformat_error, input);
17394 errmsg ("missing params!");
17398 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17400 errmsg ("no action set for negative map-reply!");
17404 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17406 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17407 mp->is_add = is_add;
17408 mp->vni = htonl (vni);
17409 mp->action = (u8) action;
17410 mp->is_src_dst = seid_set;
17411 mp->eid_len = eid->len;
17412 mp->seid_len = seid->len;
17413 mp->del_all = del_all;
17414 mp->eid_type = eid->type;
17415 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17416 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17418 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17419 clib_memcpy (mp->rlocs, rlocs, data_len);
17425 /* Wait for a reply... */
17430 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17433 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17434 * forwarding entries in data-plane accordingly.
17436 * @param vam vpp API test context
17437 * @return return code
17440 api_one_add_del_adjacency (vat_main_t * vam)
17442 unformat_input_t *input = vam->input;
17443 vl_api_one_add_del_adjacency_t *mp;
17445 ip4_address_t leid4, reid4;
17446 ip6_address_t leid6, reid6;
17447 u8 reid_mac[6] = { 0 };
17448 u8 leid_mac[6] = { 0 };
17449 u8 reid_type, leid_type;
17450 u32 leid_len = 0, reid_len = 0, len;
17454 leid_type = reid_type = (u8) ~ 0;
17456 /* Parse args required to build the message */
17457 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17459 if (unformat (input, "del"))
17463 else if (unformat (input, "add"))
17467 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17470 reid_type = 0; /* ipv4 */
17473 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17476 reid_type = 1; /* ipv6 */
17479 else if (unformat (input, "reid %U", unformat_ethernet_address,
17482 reid_type = 2; /* mac */
17484 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17487 leid_type = 0; /* ipv4 */
17490 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17493 leid_type = 1; /* ipv6 */
17496 else if (unformat (input, "leid %U", unformat_ethernet_address,
17499 leid_type = 2; /* mac */
17501 else if (unformat (input, "vni %d", &vni))
17507 errmsg ("parse error '%U'", format_unformat_error, input);
17512 if ((u8) ~ 0 == reid_type)
17514 errmsg ("missing params!");
17518 if (leid_type != reid_type)
17520 errmsg ("remote and local EIDs are of different types!");
17524 M (ONE_ADD_DEL_ADJACENCY, mp);
17525 mp->is_add = is_add;
17526 mp->vni = htonl (vni);
17527 mp->leid_len = leid_len;
17528 mp->reid_len = reid_len;
17529 mp->eid_type = reid_type;
17531 switch (mp->eid_type)
17534 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17535 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17538 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17539 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17542 clib_memcpy (mp->leid, leid_mac, 6);
17543 clib_memcpy (mp->reid, reid_mac, 6);
17546 errmsg ("unknown EID type %d!", mp->eid_type);
17553 /* Wait for a reply... */
17558 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17561 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17563 u32 *mode = va_arg (*args, u32 *);
17565 if (unformat (input, "lisp"))
17567 else if (unformat (input, "vxlan"))
17576 api_gpe_get_encap_mode (vat_main_t * vam)
17578 vl_api_gpe_get_encap_mode_t *mp;
17581 /* Construct the API message */
17582 M (GPE_GET_ENCAP_MODE, mp);
17587 /* Wait for a reply... */
17593 api_gpe_set_encap_mode (vat_main_t * vam)
17595 unformat_input_t *input = vam->input;
17596 vl_api_gpe_set_encap_mode_t *mp;
17600 /* Parse args required to build the message */
17601 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17603 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17609 /* Construct the API message */
17610 M (GPE_SET_ENCAP_MODE, mp);
17617 /* Wait for a reply... */
17623 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17625 unformat_input_t *input = vam->input;
17626 vl_api_gpe_add_del_iface_t *mp;
17627 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17628 u32 dp_table = 0, vni = 0;
17631 /* Parse args required to build the message */
17632 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17634 if (unformat (input, "up"))
17639 else if (unformat (input, "down"))
17644 else if (unformat (input, "table_id %d", &dp_table))
17648 else if (unformat (input, "bd_id %d", &dp_table))
17653 else if (unformat (input, "vni %d", &vni))
17661 if (action_set == 0)
17663 errmsg ("Action not set");
17666 if (dp_table_set == 0 || vni_set == 0)
17668 errmsg ("vni and dp_table must be set");
17672 /* Construct the API message */
17673 M (GPE_ADD_DEL_IFACE, mp);
17675 mp->is_add = is_add;
17676 mp->dp_table = clib_host_to_net_u32 (dp_table);
17678 mp->vni = clib_host_to_net_u32 (vni);
17683 /* Wait for a reply... */
17689 api_one_map_register_fallback_threshold (vat_main_t * vam)
17691 unformat_input_t *input = vam->input;
17692 vl_api_one_map_register_fallback_threshold_t *mp;
17697 /* Parse args required to build the message */
17698 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17700 if (unformat (input, "%u", &value))
17704 clib_warning ("parse error '%U'", format_unformat_error, input);
17711 errmsg ("fallback threshold value is missing!");
17715 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17716 mp->value = clib_host_to_net_u32 (value);
17721 /* Wait for a reply... */
17727 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17729 vl_api_show_one_map_register_fallback_threshold_t *mp;
17732 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17737 /* Wait for a reply... */
17743 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17745 u32 *proto = va_arg (*args, u32 *);
17747 if (unformat (input, "udp"))
17749 else if (unformat (input, "api"))
17758 api_one_set_transport_protocol (vat_main_t * vam)
17760 unformat_input_t *input = vam->input;
17761 vl_api_one_set_transport_protocol_t *mp;
17766 /* Parse args required to build the message */
17767 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17769 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17773 clib_warning ("parse error '%U'", format_unformat_error, input);
17780 errmsg ("Transport protocol missing!");
17784 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17785 mp->protocol = (u8) protocol;
17790 /* Wait for a reply... */
17796 api_one_get_transport_protocol (vat_main_t * vam)
17798 vl_api_one_get_transport_protocol_t *mp;
17801 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17806 /* Wait for a reply... */
17812 api_one_map_register_set_ttl (vat_main_t * vam)
17814 unformat_input_t *input = vam->input;
17815 vl_api_one_map_register_set_ttl_t *mp;
17820 /* Parse args required to build the message */
17821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17823 if (unformat (input, "%u", &ttl))
17827 clib_warning ("parse error '%U'", format_unformat_error, input);
17834 errmsg ("TTL value missing!");
17838 M (ONE_MAP_REGISTER_SET_TTL, mp);
17839 mp->ttl = clib_host_to_net_u32 (ttl);
17844 /* Wait for a reply... */
17850 api_show_one_map_register_ttl (vat_main_t * vam)
17852 vl_api_show_one_map_register_ttl_t *mp;
17855 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17860 /* Wait for a reply... */
17866 * Add/del map request itr rlocs from ONE control plane and updates
17868 * @param vam vpp API test context
17869 * @return return code
17872 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17874 unformat_input_t *input = vam->input;
17875 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17876 u8 *locator_set_name = 0;
17877 u8 locator_set_name_set = 0;
17881 /* Parse args required to build the message */
17882 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17884 if (unformat (input, "del"))
17888 else if (unformat (input, "%_%v%_", &locator_set_name))
17890 locator_set_name_set = 1;
17894 clib_warning ("parse error '%U'", format_unformat_error, input);
17899 if (is_add && !locator_set_name_set)
17901 errmsg ("itr-rloc is not set!");
17905 if (is_add && vec_len (locator_set_name) > 64)
17907 errmsg ("itr-rloc locator-set name too long");
17908 vec_free (locator_set_name);
17912 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17913 mp->is_add = is_add;
17916 clib_memcpy (mp->locator_set_name, locator_set_name,
17917 vec_len (locator_set_name));
17921 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17923 vec_free (locator_set_name);
17928 /* Wait for a reply... */
17933 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17936 api_one_locator_dump (vat_main_t * vam)
17938 unformat_input_t *input = vam->input;
17939 vl_api_one_locator_dump_t *mp;
17940 vl_api_control_ping_t *mp_ping;
17941 u8 is_index_set = 0, is_name_set = 0;
17946 /* Parse args required to build the message */
17947 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17949 if (unformat (input, "ls_name %_%v%_", &ls_name))
17953 else if (unformat (input, "ls_index %d", &ls_index))
17959 errmsg ("parse error '%U'", format_unformat_error, input);
17964 if (!is_index_set && !is_name_set)
17966 errmsg ("error: expected one of index or name!");
17970 if (is_index_set && is_name_set)
17972 errmsg ("error: only one param expected!");
17976 if (vec_len (ls_name) > 62)
17978 errmsg ("error: locator set name too long!");
17982 if (!vam->json_output)
17984 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17987 M (ONE_LOCATOR_DUMP, mp);
17988 mp->is_index_set = is_index_set;
17991 mp->ls_index = clib_host_to_net_u32 (ls_index);
17994 vec_add1 (ls_name, 0);
17995 strncpy ((char *) mp->ls_name, (char *) ls_name,
17996 sizeof (mp->ls_name) - 1);
18002 /* Use a control ping for synchronization */
18003 MPING (CONTROL_PING, mp_ping);
18006 /* Wait for a reply... */
18011 #define api_lisp_locator_dump api_one_locator_dump
18014 api_one_locator_set_dump (vat_main_t * vam)
18016 vl_api_one_locator_set_dump_t *mp;
18017 vl_api_control_ping_t *mp_ping;
18018 unformat_input_t *input = vam->input;
18022 /* Parse args required to build the message */
18023 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18025 if (unformat (input, "local"))
18029 else if (unformat (input, "remote"))
18035 errmsg ("parse error '%U'", format_unformat_error, input);
18040 if (!vam->json_output)
18042 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18045 M (ONE_LOCATOR_SET_DUMP, mp);
18047 mp->filter = filter;
18052 /* Use a control ping for synchronization */
18053 MPING (CONTROL_PING, mp_ping);
18056 /* Wait for a reply... */
18061 #define api_lisp_locator_set_dump api_one_locator_set_dump
18064 api_one_eid_table_map_dump (vat_main_t * vam)
18068 unformat_input_t *input = vam->input;
18069 vl_api_one_eid_table_map_dump_t *mp;
18070 vl_api_control_ping_t *mp_ping;
18073 /* Parse args required to build the message */
18074 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18076 if (unformat (input, "l2"))
18081 else if (unformat (input, "l3"))
18088 errmsg ("parse error '%U'", format_unformat_error, input);
18095 errmsg ("expected one of 'l2' or 'l3' parameter!");
18099 if (!vam->json_output)
18101 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18104 M (ONE_EID_TABLE_MAP_DUMP, mp);
18110 /* Use a control ping for synchronization */
18111 MPING (CONTROL_PING, mp_ping);
18114 /* Wait for a reply... */
18119 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18122 api_one_eid_table_vni_dump (vat_main_t * vam)
18124 vl_api_one_eid_table_vni_dump_t *mp;
18125 vl_api_control_ping_t *mp_ping;
18128 if (!vam->json_output)
18130 print (vam->ofp, "VNI");
18133 M (ONE_EID_TABLE_VNI_DUMP, mp);
18138 /* Use a control ping for synchronization */
18139 MPING (CONTROL_PING, mp_ping);
18142 /* Wait for a reply... */
18147 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18150 api_one_eid_table_dump (vat_main_t * vam)
18152 unformat_input_t *i = vam->input;
18153 vl_api_one_eid_table_dump_t *mp;
18154 vl_api_control_ping_t *mp_ping;
18155 struct in_addr ip4;
18156 struct in6_addr ip6;
18158 u8 eid_type = ~0, eid_set = 0;
18159 u32 prefix_length = ~0, t, vni = 0;
18162 lisp_nsh_api_t nsh;
18164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18166 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18172 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18178 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18183 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18188 else if (unformat (i, "vni %d", &t))
18192 else if (unformat (i, "local"))
18196 else if (unformat (i, "remote"))
18202 errmsg ("parse error '%U'", format_unformat_error, i);
18207 if (!vam->json_output)
18209 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18210 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18213 M (ONE_EID_TABLE_DUMP, mp);
18215 mp->filter = filter;
18219 mp->vni = htonl (vni);
18220 mp->eid_type = eid_type;
18224 mp->prefix_length = prefix_length;
18225 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18228 mp->prefix_length = prefix_length;
18229 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18232 clib_memcpy (mp->eid, mac, sizeof (mac));
18235 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18238 errmsg ("unknown EID type %d!", eid_type);
18246 /* Use a control ping for synchronization */
18247 MPING (CONTROL_PING, mp_ping);
18250 /* Wait for a reply... */
18255 #define api_lisp_eid_table_dump api_one_eid_table_dump
18258 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18260 unformat_input_t *i = vam->input;
18261 vl_api_gpe_fwd_entries_get_t *mp;
18266 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18268 if (unformat (i, "vni %d", &vni))
18274 errmsg ("parse error '%U'", format_unformat_error, i);
18281 errmsg ("vni not set!");
18285 if (!vam->json_output)
18287 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18291 M (GPE_FWD_ENTRIES_GET, mp);
18292 mp->vni = clib_host_to_net_u32 (vni);
18297 /* Wait for a reply... */
18302 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18303 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18304 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18305 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18306 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18307 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18308 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18309 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18312 api_one_adjacencies_get (vat_main_t * vam)
18314 unformat_input_t *i = vam->input;
18315 vl_api_one_adjacencies_get_t *mp;
18320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18322 if (unformat (i, "vni %d", &vni))
18328 errmsg ("parse error '%U'", format_unformat_error, i);
18335 errmsg ("vni not set!");
18339 if (!vam->json_output)
18341 print (vam->ofp, "%s %40s", "leid", "reid");
18344 M (ONE_ADJACENCIES_GET, mp);
18345 mp->vni = clib_host_to_net_u32 (vni);
18350 /* Wait for a reply... */
18355 #define api_lisp_adjacencies_get api_one_adjacencies_get
18358 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18360 unformat_input_t *i = vam->input;
18361 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18363 u8 ip_family_set = 0, is_ip4 = 1;
18365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18367 if (unformat (i, "ip4"))
18372 else if (unformat (i, "ip6"))
18379 errmsg ("parse error '%U'", format_unformat_error, i);
18384 if (!ip_family_set)
18386 errmsg ("ip family not set!");
18390 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18391 mp->is_ip4 = is_ip4;
18396 /* Wait for a reply... */
18402 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18404 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18407 if (!vam->json_output)
18409 print (vam->ofp, "VNIs");
18412 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18417 /* Wait for a reply... */
18423 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18425 unformat_input_t *i = vam->input;
18426 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18428 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18429 struct in_addr ip4;
18430 struct in6_addr ip6;
18431 u32 table_id = 0, nh_sw_if_index = ~0;
18433 clib_memset (&ip4, 0, sizeof (ip4));
18434 clib_memset (&ip6, 0, sizeof (ip6));
18436 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18438 if (unformat (i, "del"))
18440 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18441 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18446 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18447 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18452 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18456 nh_sw_if_index = ~0;
18458 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18462 nh_sw_if_index = ~0;
18464 else if (unformat (i, "table %d", &table_id))
18468 errmsg ("parse error '%U'", format_unformat_error, i);
18475 errmsg ("nh addr not set!");
18479 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18480 mp->is_add = is_add;
18481 mp->table_id = clib_host_to_net_u32 (table_id);
18482 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18483 mp->is_ip4 = is_ip4;
18485 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18487 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18492 /* Wait for a reply... */
18498 api_one_map_server_dump (vat_main_t * vam)
18500 vl_api_one_map_server_dump_t *mp;
18501 vl_api_control_ping_t *mp_ping;
18504 if (!vam->json_output)
18506 print (vam->ofp, "%=20s", "Map server");
18509 M (ONE_MAP_SERVER_DUMP, mp);
18513 /* Use a control ping for synchronization */
18514 MPING (CONTROL_PING, mp_ping);
18517 /* Wait for a reply... */
18522 #define api_lisp_map_server_dump api_one_map_server_dump
18525 api_one_map_resolver_dump (vat_main_t * vam)
18527 vl_api_one_map_resolver_dump_t *mp;
18528 vl_api_control_ping_t *mp_ping;
18531 if (!vam->json_output)
18533 print (vam->ofp, "%=20s", "Map resolver");
18536 M (ONE_MAP_RESOLVER_DUMP, mp);
18540 /* Use a control ping for synchronization */
18541 MPING (CONTROL_PING, mp_ping);
18544 /* Wait for a reply... */
18549 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18552 api_one_stats_flush (vat_main_t * vam)
18554 vl_api_one_stats_flush_t *mp;
18557 M (ONE_STATS_FLUSH, mp);
18564 api_one_stats_dump (vat_main_t * vam)
18566 vl_api_one_stats_dump_t *mp;
18567 vl_api_control_ping_t *mp_ping;
18570 M (ONE_STATS_DUMP, mp);
18574 /* Use a control ping for synchronization */
18575 MPING (CONTROL_PING, mp_ping);
18578 /* Wait for a reply... */
18584 api_show_one_status (vat_main_t * vam)
18586 vl_api_show_one_status_t *mp;
18589 if (!vam->json_output)
18591 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18594 M (SHOW_ONE_STATUS, mp);
18597 /* Wait for a reply... */
18602 #define api_show_lisp_status api_show_one_status
18605 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18607 vl_api_gpe_fwd_entry_path_dump_t *mp;
18608 vl_api_control_ping_t *mp_ping;
18609 unformat_input_t *i = vam->input;
18610 u32 fwd_entry_index = ~0;
18613 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18615 if (unformat (i, "index %d", &fwd_entry_index))
18621 if (~0 == fwd_entry_index)
18623 errmsg ("no index specified!");
18627 if (!vam->json_output)
18629 print (vam->ofp, "first line");
18632 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18636 /* Use a control ping for synchronization */
18637 MPING (CONTROL_PING, mp_ping);
18640 /* Wait for a reply... */
18646 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18648 vl_api_one_get_map_request_itr_rlocs_t *mp;
18651 if (!vam->json_output)
18653 print (vam->ofp, "%=20s", "itr-rlocs:");
18656 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18659 /* Wait for a reply... */
18664 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18667 api_af_packet_create (vat_main_t * vam)
18669 unformat_input_t *i = vam->input;
18670 vl_api_af_packet_create_t *mp;
18671 u8 *host_if_name = 0;
18673 u8 random_hw_addr = 1;
18676 clib_memset (hw_addr, 0, sizeof (hw_addr));
18678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18680 if (unformat (i, "name %s", &host_if_name))
18681 vec_add1 (host_if_name, 0);
18682 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18683 random_hw_addr = 0;
18688 if (!vec_len (host_if_name))
18690 errmsg ("host-interface name must be specified");
18694 if (vec_len (host_if_name) > 64)
18696 errmsg ("host-interface name too long");
18700 M (AF_PACKET_CREATE, mp);
18702 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18703 clib_memcpy (mp->hw_addr, hw_addr, 6);
18704 mp->use_random_hw_addr = random_hw_addr;
18705 vec_free (host_if_name);
18713 fprintf (vam->ofp ? vam->ofp : stderr,
18714 " new sw_if_index = %d\n", vam->sw_if_index);
18721 api_af_packet_delete (vat_main_t * vam)
18723 unformat_input_t *i = vam->input;
18724 vl_api_af_packet_delete_t *mp;
18725 u8 *host_if_name = 0;
18728 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18730 if (unformat (i, "name %s", &host_if_name))
18731 vec_add1 (host_if_name, 0);
18736 if (!vec_len (host_if_name))
18738 errmsg ("host-interface name must be specified");
18742 if (vec_len (host_if_name) > 64)
18744 errmsg ("host-interface name too long");
18748 M (AF_PACKET_DELETE, mp);
18750 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18751 vec_free (host_if_name);
18758 static void vl_api_af_packet_details_t_handler
18759 (vl_api_af_packet_details_t * mp)
18761 vat_main_t *vam = &vat_main;
18763 print (vam->ofp, "%-16s %d",
18764 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18767 static void vl_api_af_packet_details_t_handler_json
18768 (vl_api_af_packet_details_t * mp)
18770 vat_main_t *vam = &vat_main;
18771 vat_json_node_t *node = NULL;
18773 if (VAT_JSON_ARRAY != vam->json_tree.type)
18775 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18776 vat_json_init_array (&vam->json_tree);
18778 node = vat_json_array_add (&vam->json_tree);
18780 vat_json_init_object (node);
18781 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18782 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18786 api_af_packet_dump (vat_main_t * vam)
18788 vl_api_af_packet_dump_t *mp;
18789 vl_api_control_ping_t *mp_ping;
18792 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18793 /* Get list of tap interfaces */
18794 M (AF_PACKET_DUMP, mp);
18797 /* Use a control ping for synchronization */
18798 MPING (CONTROL_PING, mp_ping);
18806 api_policer_add_del (vat_main_t * vam)
18808 unformat_input_t *i = vam->input;
18809 vl_api_policer_add_del_t *mp;
18819 u8 color_aware = 0;
18820 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18823 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18824 conform_action.dscp = 0;
18825 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18826 exceed_action.dscp = 0;
18827 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18828 violate_action.dscp = 0;
18830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18832 if (unformat (i, "del"))
18834 else if (unformat (i, "name %s", &name))
18835 vec_add1 (name, 0);
18836 else if (unformat (i, "cir %u", &cir))
18838 else if (unformat (i, "eir %u", &eir))
18840 else if (unformat (i, "cb %u", &cb))
18842 else if (unformat (i, "eb %u", &eb))
18844 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18847 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18850 else if (unformat (i, "type %U", unformat_policer_type, &type))
18852 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18855 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18858 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18861 else if (unformat (i, "color-aware"))
18867 if (!vec_len (name))
18869 errmsg ("policer name must be specified");
18873 if (vec_len (name) > 64)
18875 errmsg ("policer name too long");
18879 M (POLICER_ADD_DEL, mp);
18881 clib_memcpy (mp->name, name, vec_len (name));
18883 mp->is_add = is_add;
18884 mp->cir = ntohl (cir);
18885 mp->eir = ntohl (eir);
18886 mp->cb = clib_net_to_host_u64 (cb);
18887 mp->eb = clib_net_to_host_u64 (eb);
18888 mp->rate_type = rate_type;
18889 mp->round_type = round_type;
18891 mp->conform_action_type = conform_action.action_type;
18892 mp->conform_dscp = conform_action.dscp;
18893 mp->exceed_action_type = exceed_action.action_type;
18894 mp->exceed_dscp = exceed_action.dscp;
18895 mp->violate_action_type = violate_action.action_type;
18896 mp->violate_dscp = violate_action.dscp;
18897 mp->color_aware = color_aware;
18905 api_policer_dump (vat_main_t * vam)
18907 unformat_input_t *i = vam->input;
18908 vl_api_policer_dump_t *mp;
18909 vl_api_control_ping_t *mp_ping;
18910 u8 *match_name = 0;
18911 u8 match_name_valid = 0;
18914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18916 if (unformat (i, "name %s", &match_name))
18918 vec_add1 (match_name, 0);
18919 match_name_valid = 1;
18925 M (POLICER_DUMP, mp);
18926 mp->match_name_valid = match_name_valid;
18927 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18928 vec_free (match_name);
18932 /* Use a control ping for synchronization */
18933 MPING (CONTROL_PING, mp_ping);
18936 /* Wait for a reply... */
18942 api_policer_classify_set_interface (vat_main_t * vam)
18944 unformat_input_t *i = vam->input;
18945 vl_api_policer_classify_set_interface_t *mp;
18947 int sw_if_index_set;
18948 u32 ip4_table_index = ~0;
18949 u32 ip6_table_index = ~0;
18950 u32 l2_table_index = ~0;
18954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18956 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18957 sw_if_index_set = 1;
18958 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18959 sw_if_index_set = 1;
18960 else if (unformat (i, "del"))
18962 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18964 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18966 else if (unformat (i, "l2-table %d", &l2_table_index))
18970 clib_warning ("parse error '%U'", format_unformat_error, i);
18975 if (sw_if_index_set == 0)
18977 errmsg ("missing interface name or sw_if_index");
18981 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18983 mp->sw_if_index = ntohl (sw_if_index);
18984 mp->ip4_table_index = ntohl (ip4_table_index);
18985 mp->ip6_table_index = ntohl (ip6_table_index);
18986 mp->l2_table_index = ntohl (l2_table_index);
18987 mp->is_add = is_add;
18995 api_policer_classify_dump (vat_main_t * vam)
18997 unformat_input_t *i = vam->input;
18998 vl_api_policer_classify_dump_t *mp;
18999 vl_api_control_ping_t *mp_ping;
19000 u8 type = POLICER_CLASSIFY_N_TABLES;
19003 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19007 errmsg ("classify table type must be specified");
19011 if (!vam->json_output)
19013 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19016 M (POLICER_CLASSIFY_DUMP, mp);
19021 /* Use a control ping for synchronization */
19022 MPING (CONTROL_PING, mp_ping);
19025 /* Wait for a reply... */
19031 api_netmap_create (vat_main_t * vam)
19033 unformat_input_t *i = vam->input;
19034 vl_api_netmap_create_t *mp;
19037 u8 random_hw_addr = 1;
19042 clib_memset (hw_addr, 0, sizeof (hw_addr));
19044 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19046 if (unformat (i, "name %s", &if_name))
19047 vec_add1 (if_name, 0);
19048 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19049 random_hw_addr = 0;
19050 else if (unformat (i, "pipe"))
19052 else if (unformat (i, "master"))
19054 else if (unformat (i, "slave"))
19060 if (!vec_len (if_name))
19062 errmsg ("interface name must be specified");
19066 if (vec_len (if_name) > 64)
19068 errmsg ("interface name too long");
19072 M (NETMAP_CREATE, mp);
19074 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19075 clib_memcpy (mp->hw_addr, hw_addr, 6);
19076 mp->use_random_hw_addr = random_hw_addr;
19077 mp->is_pipe = is_pipe;
19078 mp->is_master = is_master;
19079 vec_free (if_name);
19087 api_netmap_delete (vat_main_t * vam)
19089 unformat_input_t *i = vam->input;
19090 vl_api_netmap_delete_t *mp;
19094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19096 if (unformat (i, "name %s", &if_name))
19097 vec_add1 (if_name, 0);
19102 if (!vec_len (if_name))
19104 errmsg ("interface name must be specified");
19108 if (vec_len (if_name) > 64)
19110 errmsg ("interface name too long");
19114 M (NETMAP_DELETE, mp);
19116 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19117 vec_free (if_name);
19125 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19127 if (fp->afi == IP46_TYPE_IP6)
19129 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19130 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19131 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19132 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19133 format_ip6_address, fp->next_hop);
19134 else if (fp->afi == IP46_TYPE_IP4)
19136 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19137 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19138 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19139 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19140 format_ip4_address, fp->next_hop);
19144 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19145 vl_api_fib_path_t * fp)
19147 struct in_addr ip4;
19148 struct in6_addr ip6;
19150 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19151 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19152 vat_json_object_add_uint (node, "is_local", fp->is_local);
19153 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19154 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19155 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19156 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19157 if (fp->afi == IP46_TYPE_IP4)
19159 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19160 vat_json_object_add_ip4 (node, "next_hop", ip4);
19162 else if (fp->afi == IP46_TYPE_IP6)
19164 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19165 vat_json_object_add_ip6 (node, "next_hop", ip6);
19170 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19172 vat_main_t *vam = &vat_main;
19173 int count = ntohl (mp->mt_count);
19174 vl_api_fib_path_t *fp;
19177 print (vam->ofp, "[%d]: sw_if_index %d via:",
19178 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19180 for (i = 0; i < count; i++)
19182 vl_api_mpls_fib_path_print (vam, fp);
19186 print (vam->ofp, "");
19189 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19190 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19193 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19195 vat_main_t *vam = &vat_main;
19196 vat_json_node_t *node = NULL;
19197 int count = ntohl (mp->mt_count);
19198 vl_api_fib_path_t *fp;
19201 if (VAT_JSON_ARRAY != vam->json_tree.type)
19203 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19204 vat_json_init_array (&vam->json_tree);
19206 node = vat_json_array_add (&vam->json_tree);
19208 vat_json_init_object (node);
19209 vat_json_object_add_uint (node, "tunnel_index",
19210 ntohl (mp->mt_tunnel_index));
19211 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19213 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19216 for (i = 0; i < count; i++)
19218 vl_api_mpls_fib_path_json_print (node, fp);
19224 api_mpls_tunnel_dump (vat_main_t * vam)
19226 vl_api_mpls_tunnel_dump_t *mp;
19227 vl_api_control_ping_t *mp_ping;
19228 u32 sw_if_index = ~0;
19231 /* Parse args required to build the message */
19232 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19234 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19238 print (vam->ofp, " sw_if_index %d", sw_if_index);
19240 M (MPLS_TUNNEL_DUMP, mp);
19241 mp->sw_if_index = htonl (sw_if_index);
19244 /* Use a control ping for synchronization */
19245 MPING (CONTROL_PING, mp_ping);
19252 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19253 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19257 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19259 vat_main_t *vam = &vat_main;
19260 int count = ntohl (mp->count);
19261 vl_api_fib_path_t *fp;
19265 "table-id %d, label %u, ess_bit %u",
19266 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19268 for (i = 0; i < count; i++)
19270 vl_api_mpls_fib_path_print (vam, fp);
19275 static void vl_api_mpls_fib_details_t_handler_json
19276 (vl_api_mpls_fib_details_t * mp)
19278 vat_main_t *vam = &vat_main;
19279 int count = ntohl (mp->count);
19280 vat_json_node_t *node = NULL;
19281 vl_api_fib_path_t *fp;
19284 if (VAT_JSON_ARRAY != vam->json_tree.type)
19286 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19287 vat_json_init_array (&vam->json_tree);
19289 node = vat_json_array_add (&vam->json_tree);
19291 vat_json_init_object (node);
19292 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19293 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19294 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19295 vat_json_object_add_uint (node, "path_count", count);
19297 for (i = 0; i < count; i++)
19299 vl_api_mpls_fib_path_json_print (node, fp);
19305 api_mpls_fib_dump (vat_main_t * vam)
19307 vl_api_mpls_fib_dump_t *mp;
19308 vl_api_control_ping_t *mp_ping;
19311 M (MPLS_FIB_DUMP, mp);
19314 /* Use a control ping for synchronization */
19315 MPING (CONTROL_PING, mp_ping);
19322 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19323 #define vl_api_ip_fib_details_t_print vl_noop_handler
19326 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19328 vat_main_t *vam = &vat_main;
19329 int count = ntohl (mp->count);
19330 vl_api_fib_path_t *fp;
19334 "table-id %d, prefix %U/%d stats-index %d",
19335 ntohl (mp->table_id), format_ip4_address, mp->address,
19336 mp->address_length, ntohl (mp->stats_index));
19338 for (i = 0; i < count; i++)
19340 if (fp->afi == IP46_TYPE_IP6)
19342 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19343 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19344 "next_hop_table %d",
19345 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19346 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19347 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
19348 else if (fp->afi == IP46_TYPE_IP4)
19350 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19351 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19352 "next_hop_table %d",
19353 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19354 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19355 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
19360 static void vl_api_ip_fib_details_t_handler_json
19361 (vl_api_ip_fib_details_t * mp)
19363 vat_main_t *vam = &vat_main;
19364 int count = ntohl (mp->count);
19365 vat_json_node_t *node = NULL;
19366 struct in_addr ip4;
19367 struct in6_addr ip6;
19368 vl_api_fib_path_t *fp;
19371 if (VAT_JSON_ARRAY != vam->json_tree.type)
19373 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19374 vat_json_init_array (&vam->json_tree);
19376 node = vat_json_array_add (&vam->json_tree);
19378 vat_json_init_object (node);
19379 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19380 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19381 vat_json_object_add_ip4 (node, "prefix", ip4);
19382 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19383 vat_json_object_add_uint (node, "path_count", count);
19385 for (i = 0; i < count; i++)
19387 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19388 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19389 vat_json_object_add_uint (node, "is_local", fp->is_local);
19390 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19391 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19392 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19393 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19394 if (fp->afi == IP46_TYPE_IP4)
19396 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19397 vat_json_object_add_ip4 (node, "next_hop", ip4);
19399 else if (fp->afi == IP46_TYPE_IP6)
19401 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19402 vat_json_object_add_ip6 (node, "next_hop", ip6);
19408 api_ip_fib_dump (vat_main_t * vam)
19410 vl_api_ip_fib_dump_t *mp;
19411 vl_api_control_ping_t *mp_ping;
19414 M (IP_FIB_DUMP, mp);
19417 /* Use a control ping for synchronization */
19418 MPING (CONTROL_PING, mp_ping);
19426 api_ip_mfib_dump (vat_main_t * vam)
19428 vl_api_ip_mfib_dump_t *mp;
19429 vl_api_control_ping_t *mp_ping;
19432 M (IP_MFIB_DUMP, mp);
19435 /* Use a control ping for synchronization */
19436 MPING (CONTROL_PING, mp_ping);
19443 static void vl_api_ip_neighbor_details_t_handler
19444 (vl_api_ip_neighbor_details_t * mp)
19446 vat_main_t *vam = &vat_main;
19448 print (vam->ofp, "%c %U %U",
19449 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19450 format_vl_api_mac_address, &mp->neighbor.mac_address,
19451 format_vl_api_address, &mp->neighbor.ip_address);
19454 static void vl_api_ip_neighbor_details_t_handler_json
19455 (vl_api_ip_neighbor_details_t * mp)
19458 vat_main_t *vam = &vat_main;
19459 vat_json_node_t *node;
19461 if (VAT_JSON_ARRAY != vam->json_tree.type)
19463 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19464 vat_json_init_array (&vam->json_tree);
19466 node = vat_json_array_add (&vam->json_tree);
19468 vat_json_init_object (node);
19469 vat_json_object_add_string_copy
19471 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19472 (u8 *) "static" : (u8 *) "dynamic"));
19474 vat_json_object_add_string_copy (node, "link_layer",
19475 format (0, "%U", format_vl_api_mac_address,
19476 &mp->neighbor.mac_address));
19477 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19481 api_ip_neighbor_dump (vat_main_t * vam)
19483 unformat_input_t *i = vam->input;
19484 vl_api_ip_neighbor_dump_t *mp;
19485 vl_api_control_ping_t *mp_ping;
19487 u32 sw_if_index = ~0;
19490 /* Parse args required to build the message */
19491 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19493 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19495 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19497 else if (unformat (i, "ip6"))
19503 if (sw_if_index == ~0)
19505 errmsg ("missing interface name or sw_if_index");
19509 M (IP_NEIGHBOR_DUMP, mp);
19510 mp->is_ipv6 = (u8) is_ipv6;
19511 mp->sw_if_index = ntohl (sw_if_index);
19514 /* Use a control ping for synchronization */
19515 MPING (CONTROL_PING, mp_ping);
19522 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19523 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19526 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19528 vat_main_t *vam = &vat_main;
19529 int count = ntohl (mp->count);
19530 vl_api_fib_path_t *fp;
19534 "table-id %d, prefix %U/%d stats-index %d",
19535 ntohl (mp->table_id), format_ip6_address, mp->address,
19536 mp->address_length, ntohl (mp->stats_index));
19538 for (i = 0; i < count; i++)
19540 if (fp->afi == IP46_TYPE_IP6)
19542 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19543 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19544 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19545 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19546 format_ip6_address, fp->next_hop);
19547 else if (fp->afi == IP46_TYPE_IP4)
19549 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19550 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19551 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19552 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19553 format_ip4_address, fp->next_hop);
19558 static void vl_api_ip6_fib_details_t_handler_json
19559 (vl_api_ip6_fib_details_t * mp)
19561 vat_main_t *vam = &vat_main;
19562 int count = ntohl (mp->count);
19563 vat_json_node_t *node = NULL;
19564 struct in_addr ip4;
19565 struct in6_addr ip6;
19566 vl_api_fib_path_t *fp;
19569 if (VAT_JSON_ARRAY != vam->json_tree.type)
19571 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19572 vat_json_init_array (&vam->json_tree);
19574 node = vat_json_array_add (&vam->json_tree);
19576 vat_json_init_object (node);
19577 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19578 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19579 vat_json_object_add_ip6 (node, "prefix", ip6);
19580 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19581 vat_json_object_add_uint (node, "path_count", count);
19583 for (i = 0; i < count; i++)
19585 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19586 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19587 vat_json_object_add_uint (node, "is_local", fp->is_local);
19588 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19589 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19590 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19591 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19592 if (fp->afi == IP46_TYPE_IP4)
19594 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19595 vat_json_object_add_ip4 (node, "next_hop", ip4);
19597 else if (fp->afi == IP46_TYPE_IP6)
19599 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19600 vat_json_object_add_ip6 (node, "next_hop", ip6);
19606 api_ip6_fib_dump (vat_main_t * vam)
19608 vl_api_ip6_fib_dump_t *mp;
19609 vl_api_control_ping_t *mp_ping;
19612 M (IP6_FIB_DUMP, mp);
19615 /* Use a control ping for synchronization */
19616 MPING (CONTROL_PING, mp_ping);
19624 api_ip6_mfib_dump (vat_main_t * vam)
19626 vl_api_ip6_mfib_dump_t *mp;
19627 vl_api_control_ping_t *mp_ping;
19630 M (IP6_MFIB_DUMP, mp);
19633 /* Use a control ping for synchronization */
19634 MPING (CONTROL_PING, mp_ping);
19642 api_classify_table_ids (vat_main_t * vam)
19644 vl_api_classify_table_ids_t *mp;
19647 /* Construct the API message */
19648 M (CLASSIFY_TABLE_IDS, mp);
19657 api_classify_table_by_interface (vat_main_t * vam)
19659 unformat_input_t *input = vam->input;
19660 vl_api_classify_table_by_interface_t *mp;
19662 u32 sw_if_index = ~0;
19664 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19666 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19668 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19673 if (sw_if_index == ~0)
19675 errmsg ("missing interface name or sw_if_index");
19679 /* Construct the API message */
19680 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19682 mp->sw_if_index = ntohl (sw_if_index);
19690 api_classify_table_info (vat_main_t * vam)
19692 unformat_input_t *input = vam->input;
19693 vl_api_classify_table_info_t *mp;
19697 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19699 if (unformat (input, "table_id %d", &table_id))
19704 if (table_id == ~0)
19706 errmsg ("missing table id");
19710 /* Construct the API message */
19711 M (CLASSIFY_TABLE_INFO, mp);
19713 mp->table_id = ntohl (table_id);
19721 api_classify_session_dump (vat_main_t * vam)
19723 unformat_input_t *input = vam->input;
19724 vl_api_classify_session_dump_t *mp;
19725 vl_api_control_ping_t *mp_ping;
19729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19731 if (unformat (input, "table_id %d", &table_id))
19736 if (table_id == ~0)
19738 errmsg ("missing table id");
19742 /* Construct the API message */
19743 M (CLASSIFY_SESSION_DUMP, mp);
19745 mp->table_id = ntohl (table_id);
19748 /* Use a control ping for synchronization */
19749 MPING (CONTROL_PING, mp_ping);
19757 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19759 vat_main_t *vam = &vat_main;
19761 print (vam->ofp, "collector_address %U, collector_port %d, "
19762 "src_address %U, vrf_id %d, path_mtu %u, "
19763 "template_interval %u, udp_checksum %d",
19764 format_ip4_address, mp->collector_address,
19765 ntohs (mp->collector_port),
19766 format_ip4_address, mp->src_address,
19767 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19768 ntohl (mp->template_interval), mp->udp_checksum);
19771 vam->result_ready = 1;
19775 vl_api_ipfix_exporter_details_t_handler_json
19776 (vl_api_ipfix_exporter_details_t * mp)
19778 vat_main_t *vam = &vat_main;
19779 vat_json_node_t node;
19780 struct in_addr collector_address;
19781 struct in_addr src_address;
19783 vat_json_init_object (&node);
19784 clib_memcpy (&collector_address, &mp->collector_address,
19785 sizeof (collector_address));
19786 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19787 vat_json_object_add_uint (&node, "collector_port",
19788 ntohs (mp->collector_port));
19789 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19790 vat_json_object_add_ip4 (&node, "src_address", src_address);
19791 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19792 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19793 vat_json_object_add_uint (&node, "template_interval",
19794 ntohl (mp->template_interval));
19795 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19797 vat_json_print (vam->ofp, &node);
19798 vat_json_free (&node);
19800 vam->result_ready = 1;
19804 api_ipfix_exporter_dump (vat_main_t * vam)
19806 vl_api_ipfix_exporter_dump_t *mp;
19809 /* Construct the API message */
19810 M (IPFIX_EXPORTER_DUMP, mp);
19819 api_ipfix_classify_stream_dump (vat_main_t * vam)
19821 vl_api_ipfix_classify_stream_dump_t *mp;
19824 /* Construct the API message */
19825 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19836 vl_api_ipfix_classify_stream_details_t_handler
19837 (vl_api_ipfix_classify_stream_details_t * mp)
19839 vat_main_t *vam = &vat_main;
19840 print (vam->ofp, "domain_id %d, src_port %d",
19841 ntohl (mp->domain_id), ntohs (mp->src_port));
19843 vam->result_ready = 1;
19847 vl_api_ipfix_classify_stream_details_t_handler_json
19848 (vl_api_ipfix_classify_stream_details_t * mp)
19850 vat_main_t *vam = &vat_main;
19851 vat_json_node_t node;
19853 vat_json_init_object (&node);
19854 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19855 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19857 vat_json_print (vam->ofp, &node);
19858 vat_json_free (&node);
19860 vam->result_ready = 1;
19864 api_ipfix_classify_table_dump (vat_main_t * vam)
19866 vl_api_ipfix_classify_table_dump_t *mp;
19867 vl_api_control_ping_t *mp_ping;
19870 if (!vam->json_output)
19872 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19873 "transport_protocol");
19876 /* Construct the API message */
19877 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19882 /* Use a control ping for synchronization */
19883 MPING (CONTROL_PING, mp_ping);
19891 vl_api_ipfix_classify_table_details_t_handler
19892 (vl_api_ipfix_classify_table_details_t * mp)
19894 vat_main_t *vam = &vat_main;
19895 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19896 mp->transport_protocol);
19900 vl_api_ipfix_classify_table_details_t_handler_json
19901 (vl_api_ipfix_classify_table_details_t * mp)
19903 vat_json_node_t *node = NULL;
19904 vat_main_t *vam = &vat_main;
19906 if (VAT_JSON_ARRAY != vam->json_tree.type)
19908 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19909 vat_json_init_array (&vam->json_tree);
19912 node = vat_json_array_add (&vam->json_tree);
19913 vat_json_init_object (node);
19915 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19916 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19917 vat_json_object_add_uint (node, "transport_protocol",
19918 mp->transport_protocol);
19922 api_sw_interface_span_enable_disable (vat_main_t * vam)
19924 unformat_input_t *i = vam->input;
19925 vl_api_sw_interface_span_enable_disable_t *mp;
19926 u32 src_sw_if_index = ~0;
19927 u32 dst_sw_if_index = ~0;
19932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19935 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19937 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19941 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19943 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19945 else if (unformat (i, "disable"))
19947 else if (unformat (i, "rx"))
19949 else if (unformat (i, "tx"))
19951 else if (unformat (i, "both"))
19953 else if (unformat (i, "l2"))
19959 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19961 mp->sw_if_index_from = htonl (src_sw_if_index);
19962 mp->sw_if_index_to = htonl (dst_sw_if_index);
19972 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19975 vat_main_t *vam = &vat_main;
19976 u8 *sw_if_from_name = 0;
19977 u8 *sw_if_to_name = 0;
19978 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19979 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19980 char *states[] = { "none", "rx", "tx", "both" };
19984 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19986 if ((u32) p->value[0] == sw_if_index_from)
19988 sw_if_from_name = (u8 *)(p->key);
19992 if ((u32) p->value[0] == sw_if_index_to)
19994 sw_if_to_name = (u8 *)(p->key);
19995 if (sw_if_from_name)
20000 print (vam->ofp, "%20s => %20s (%s) %s",
20001 sw_if_from_name, sw_if_to_name, states[mp->state],
20002 mp->is_l2 ? "l2" : "device");
20006 vl_api_sw_interface_span_details_t_handler_json
20007 (vl_api_sw_interface_span_details_t * mp)
20009 vat_main_t *vam = &vat_main;
20010 vat_json_node_t *node = NULL;
20011 u8 *sw_if_from_name = 0;
20012 u8 *sw_if_to_name = 0;
20013 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20014 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20018 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20020 if ((u32) p->value[0] == sw_if_index_from)
20022 sw_if_from_name = (u8 *)(p->key);
20026 if ((u32) p->value[0] == sw_if_index_to)
20028 sw_if_to_name = (u8 *)(p->key);
20029 if (sw_if_from_name)
20035 if (VAT_JSON_ARRAY != vam->json_tree.type)
20037 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20038 vat_json_init_array (&vam->json_tree);
20040 node = vat_json_array_add (&vam->json_tree);
20042 vat_json_init_object (node);
20043 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20044 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20045 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20046 if (0 != sw_if_to_name)
20048 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20050 vat_json_object_add_uint (node, "state", mp->state);
20051 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20055 api_sw_interface_span_dump (vat_main_t * vam)
20057 unformat_input_t *input = vam->input;
20058 vl_api_sw_interface_span_dump_t *mp;
20059 vl_api_control_ping_t *mp_ping;
20063 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20065 if (unformat (input, "l2"))
20071 M (SW_INTERFACE_SPAN_DUMP, mp);
20075 /* Use a control ping for synchronization */
20076 MPING (CONTROL_PING, mp_ping);
20084 api_pg_create_interface (vat_main_t * vam)
20086 unformat_input_t *input = vam->input;
20087 vl_api_pg_create_interface_t *mp;
20091 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20093 if (unformat (input, "if_id %d", &if_id))
20100 errmsg ("missing pg interface index");
20104 /* Construct the API message */
20105 M (PG_CREATE_INTERFACE, mp);
20107 mp->interface_id = ntohl (if_id);
20115 api_pg_capture (vat_main_t * vam)
20117 unformat_input_t *input = vam->input;
20118 vl_api_pg_capture_t *mp;
20123 u8 pcap_file_set = 0;
20126 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20128 if (unformat (input, "if_id %d", &if_id))
20130 else if (unformat (input, "pcap %s", &pcap_file))
20132 else if (unformat (input, "count %d", &count))
20134 else if (unformat (input, "disable"))
20141 errmsg ("missing pg interface index");
20144 if (pcap_file_set > 0)
20146 if (vec_len (pcap_file) > 255)
20148 errmsg ("pcap file name is too long");
20153 u32 name_len = vec_len (pcap_file);
20154 /* Construct the API message */
20155 M (PG_CAPTURE, mp);
20157 mp->interface_id = ntohl (if_id);
20158 mp->is_enabled = enable;
20159 mp->count = ntohl (count);
20160 mp->pcap_name_length = ntohl (name_len);
20161 if (pcap_file_set != 0)
20163 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20165 vec_free (pcap_file);
20173 api_pg_enable_disable (vat_main_t * vam)
20175 unformat_input_t *input = vam->input;
20176 vl_api_pg_enable_disable_t *mp;
20179 u8 stream_name_set = 0;
20180 u8 *stream_name = 0;
20182 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20184 if (unformat (input, "stream %s", &stream_name))
20185 stream_name_set = 1;
20186 else if (unformat (input, "disable"))
20192 if (stream_name_set > 0)
20194 if (vec_len (stream_name) > 255)
20196 errmsg ("stream name too long");
20201 u32 name_len = vec_len (stream_name);
20202 /* Construct the API message */
20203 M (PG_ENABLE_DISABLE, mp);
20205 mp->is_enabled = enable;
20206 if (stream_name_set != 0)
20208 mp->stream_name_length = ntohl (name_len);
20209 clib_memcpy (mp->stream_name, stream_name, name_len);
20211 vec_free (stream_name);
20219 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20221 unformat_input_t *input = vam->input;
20222 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20224 u16 *low_ports = 0;
20225 u16 *high_ports = 0;
20228 vl_api_prefix_t prefix;
20236 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20238 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
20240 else if (unformat (input, "vrf %d", &vrf_id))
20242 else if (unformat (input, "del"))
20244 else if (unformat (input, "port %d", &tmp))
20246 if (tmp == 0 || tmp > 65535)
20248 errmsg ("port %d out of range", tmp);
20252 this_hi = this_low + 1;
20253 vec_add1 (low_ports, this_low);
20254 vec_add1 (high_ports, this_hi);
20256 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20258 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20260 errmsg ("incorrect range parameters");
20264 /* Note: in debug CLI +1 is added to high before
20265 passing to real fn that does "the work"
20266 (ip_source_and_port_range_check_add_del).
20267 This fn is a wrapper around the binary API fn a
20268 control plane will call, which expects this increment
20269 to have occurred. Hence letting the binary API control
20270 plane fn do the increment for consistency between VAT
20271 and other control planes.
20274 vec_add1 (low_ports, this_low);
20275 vec_add1 (high_ports, this_hi);
20281 if (prefix_set == 0)
20283 errmsg ("<address>/<mask> not specified");
20289 errmsg ("VRF ID required, not specified");
20296 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20300 if (vec_len (low_ports) == 0)
20302 errmsg ("At least one port or port range required");
20306 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20308 mp->is_add = is_add;
20310 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
20312 mp->number_of_ranges = vec_len (low_ports);
20314 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20315 vec_free (low_ports);
20317 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20318 vec_free (high_ports);
20320 mp->vrf_id = ntohl (vrf_id);
20328 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20330 unformat_input_t *input = vam->input;
20331 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20332 u32 sw_if_index = ~0;
20334 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20335 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20339 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20341 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20343 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20345 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20347 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20349 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20351 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20353 else if (unformat (input, "del"))
20359 if (sw_if_index == ~0)
20361 errmsg ("Interface required but not specified");
20367 errmsg ("VRF ID required but not specified");
20371 if (tcp_out_vrf_id == 0
20372 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20375 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20379 /* Construct the API message */
20380 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20382 mp->sw_if_index = ntohl (sw_if_index);
20383 mp->is_add = is_add;
20384 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20385 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20386 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20387 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20392 /* Wait for a reply... */
20398 api_ipsec_gre_tunnel_add_del (vat_main_t * vam)
20400 unformat_input_t *i = vam->input;
20401 vl_api_ipsec_gre_tunnel_add_del_t *mp;
20402 u32 local_sa_id = 0;
20403 u32 remote_sa_id = 0;
20404 vl_api_ip4_address_t src_address;
20405 vl_api_ip4_address_t dst_address;
20409 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20411 if (unformat (i, "local_sa %d", &local_sa_id))
20413 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20416 if (unformat (i, "src %U", unformat_vl_api_ip4_address, &src_address))
20419 if (unformat (i, "dst %U", unformat_vl_api_ip4_address, &dst_address))
20421 else if (unformat (i, "del"))
20425 clib_warning ("parse error '%U'", format_unformat_error, i);
20430 M (IPSEC_GRE_TUNNEL_ADD_DEL, mp);
20432 mp->tunnel.local_sa_id = ntohl (local_sa_id);
20433 mp->tunnel.remote_sa_id = ntohl (remote_sa_id);
20434 clib_memcpy (mp->tunnel.src, &src_address, sizeof (src_address));
20435 clib_memcpy (mp->tunnel.dst, &dst_address, sizeof (dst_address));
20436 mp->is_add = is_add;
20444 api_set_punt (vat_main_t * vam)
20446 unformat_input_t *i = vam->input;
20447 vl_api_set_punt_t *mp;
20454 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20456 if (unformat (i, "ip %d", &ipv))
20458 else if (unformat (i, "protocol %d", &protocol))
20460 else if (unformat (i, "port %d", &port))
20462 else if (unformat (i, "del"))
20466 clib_warning ("parse error '%U'", format_unformat_error, i);
20473 mp->is_add = (u8) is_add;
20474 mp->punt.ipv = (u8) ipv;
20475 mp->punt.l4_protocol = (u8) protocol;
20476 mp->punt.l4_port = htons ((u16) port);
20483 static void vl_api_ipsec_gre_tunnel_details_t_handler
20484 (vl_api_ipsec_gre_tunnel_details_t * mp)
20486 vat_main_t *vam = &vat_main;
20488 print (vam->ofp, "%11d%15U%15U%14d%14d",
20489 ntohl (mp->tunnel.sw_if_index),
20490 format_vl_api_ip4_address, mp->tunnel.src,
20491 format_vl_api_ip4_address, mp->tunnel.dst,
20492 ntohl (mp->tunnel.local_sa_id), ntohl (mp->tunnel.remote_sa_id));
20496 vat_json_object_add_vl_api_ip4 (vat_json_node_t * node,
20498 const vl_api_ip4_address_t addr)
20500 struct in_addr ip4;
20502 clib_memcpy (&ip4, addr, sizeof (ip4));
20503 vat_json_object_add_ip4 (node, name, ip4);
20506 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20507 (vl_api_ipsec_gre_tunnel_details_t * mp)
20509 vat_main_t *vam = &vat_main;
20510 vat_json_node_t *node = NULL;
20511 struct in_addr ip4;
20513 if (VAT_JSON_ARRAY != vam->json_tree.type)
20515 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20516 vat_json_init_array (&vam->json_tree);
20518 node = vat_json_array_add (&vam->json_tree);
20520 vat_json_init_object (node);
20521 vat_json_object_add_uint (node, "sw_if_index",
20522 ntohl (mp->tunnel.sw_if_index));
20523 vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.src);
20524 vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.dst);
20525 vat_json_object_add_uint (node, "local_sa_id",
20526 ntohl (mp->tunnel.local_sa_id));
20527 vat_json_object_add_uint (node, "remote_sa_id",
20528 ntohl (mp->tunnel.remote_sa_id));
20532 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20534 unformat_input_t *i = vam->input;
20535 vl_api_ipsec_gre_tunnel_dump_t *mp;
20536 vl_api_control_ping_t *mp_ping;
20538 u8 sw_if_index_set = 0;
20541 /* Parse args required to build the message */
20542 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20544 if (unformat (i, "sw_if_index %d", &sw_if_index))
20545 sw_if_index_set = 1;
20550 if (sw_if_index_set == 0)
20555 if (!vam->json_output)
20557 print (vam->ofp, "%11s%15s%15s%14s%14s",
20558 "sw_if_index", "src_address", "dst_address",
20559 "local_sa_id", "remote_sa_id");
20562 /* Get list of gre-tunnel interfaces */
20563 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20565 mp->sw_if_index = htonl (sw_if_index);
20569 /* Use a control ping for synchronization */
20570 MPING (CONTROL_PING, mp_ping);
20578 api_delete_subif (vat_main_t * vam)
20580 unformat_input_t *i = vam->input;
20581 vl_api_delete_subif_t *mp;
20582 u32 sw_if_index = ~0;
20585 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20589 if (unformat (i, "sw_if_index %d", &sw_if_index))
20595 if (sw_if_index == ~0)
20597 errmsg ("missing sw_if_index");
20601 /* Construct the API message */
20602 M (DELETE_SUBIF, mp);
20603 mp->sw_if_index = ntohl (sw_if_index);
20610 #define foreach_pbb_vtr_op \
20611 _("disable", L2_VTR_DISABLED) \
20612 _("pop", L2_VTR_POP_2) \
20613 _("push", L2_VTR_PUSH_2)
20616 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20618 unformat_input_t *i = vam->input;
20619 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20620 u32 sw_if_index = ~0, vtr_op = ~0;
20621 u16 outer_tag = ~0;
20622 u8 dmac[6], smac[6];
20623 u8 dmac_set = 0, smac_set = 0;
20629 /* Shut up coverity */
20630 clib_memset (dmac, 0, sizeof (dmac));
20631 clib_memset (smac, 0, sizeof (smac));
20633 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20635 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20637 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20639 else if (unformat (i, "vtr_op %d", &vtr_op))
20641 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20644 else if (unformat (i, "translate_pbb_stag"))
20646 if (unformat (i, "%d", &tmp))
20648 vtr_op = L2_VTR_TRANSLATE_2_1;
20654 ("translate_pbb_stag operation requires outer tag definition");
20658 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20660 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20662 else if (unformat (i, "sid %d", &sid))
20664 else if (unformat (i, "vlanid %d", &tmp))
20668 clib_warning ("parse error '%U'", format_unformat_error, i);
20673 if ((sw_if_index == ~0) || (vtr_op == ~0))
20675 errmsg ("missing sw_if_index or vtr operation");
20678 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20679 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20682 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20686 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20687 mp->sw_if_index = ntohl (sw_if_index);
20688 mp->vtr_op = ntohl (vtr_op);
20689 mp->outer_tag = ntohs (outer_tag);
20690 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20691 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20692 mp->b_vlanid = ntohs (vlanid);
20693 mp->i_sid = ntohl (sid);
20701 api_flow_classify_set_interface (vat_main_t * vam)
20703 unformat_input_t *i = vam->input;
20704 vl_api_flow_classify_set_interface_t *mp;
20706 int sw_if_index_set;
20707 u32 ip4_table_index = ~0;
20708 u32 ip6_table_index = ~0;
20712 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20714 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20715 sw_if_index_set = 1;
20716 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20717 sw_if_index_set = 1;
20718 else if (unformat (i, "del"))
20720 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20722 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20726 clib_warning ("parse error '%U'", format_unformat_error, i);
20731 if (sw_if_index_set == 0)
20733 errmsg ("missing interface name or sw_if_index");
20737 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20739 mp->sw_if_index = ntohl (sw_if_index);
20740 mp->ip4_table_index = ntohl (ip4_table_index);
20741 mp->ip6_table_index = ntohl (ip6_table_index);
20742 mp->is_add = is_add;
20750 api_flow_classify_dump (vat_main_t * vam)
20752 unformat_input_t *i = vam->input;
20753 vl_api_flow_classify_dump_t *mp;
20754 vl_api_control_ping_t *mp_ping;
20755 u8 type = FLOW_CLASSIFY_N_TABLES;
20758 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20762 errmsg ("classify table type must be specified");
20766 if (!vam->json_output)
20768 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20771 M (FLOW_CLASSIFY_DUMP, mp);
20776 /* Use a control ping for synchronization */
20777 MPING (CONTROL_PING, mp_ping);
20780 /* Wait for a reply... */
20786 api_feature_enable_disable (vat_main_t * vam)
20788 unformat_input_t *i = vam->input;
20789 vl_api_feature_enable_disable_t *mp;
20791 u8 *feature_name = 0;
20792 u32 sw_if_index = ~0;
20796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20798 if (unformat (i, "arc_name %s", &arc_name))
20800 else if (unformat (i, "feature_name %s", &feature_name))
20803 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20805 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20807 else if (unformat (i, "disable"))
20815 errmsg ("missing arc name");
20818 if (vec_len (arc_name) > 63)
20820 errmsg ("arc name too long");
20823 if (feature_name == 0)
20825 errmsg ("missing feature name");
20828 if (vec_len (feature_name) > 63)
20830 errmsg ("feature name too long");
20833 if (sw_if_index == ~0)
20835 errmsg ("missing interface name or sw_if_index");
20839 /* Construct the API message */
20840 M (FEATURE_ENABLE_DISABLE, mp);
20841 mp->sw_if_index = ntohl (sw_if_index);
20842 mp->enable = enable;
20843 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20844 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20845 vec_free (arc_name);
20846 vec_free (feature_name);
20854 api_sw_interface_tag_add_del (vat_main_t * vam)
20856 unformat_input_t *i = vam->input;
20857 vl_api_sw_interface_tag_add_del_t *mp;
20858 u32 sw_if_index = ~0;
20863 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20865 if (unformat (i, "tag %s", &tag))
20867 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20869 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20871 else if (unformat (i, "del"))
20877 if (sw_if_index == ~0)
20879 errmsg ("missing interface name or sw_if_index");
20883 if (enable && (tag == 0))
20885 errmsg ("no tag specified");
20889 /* Construct the API message */
20890 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20891 mp->sw_if_index = ntohl (sw_if_index);
20892 mp->is_add = enable;
20894 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20902 static void vl_api_l2_xconnect_details_t_handler
20903 (vl_api_l2_xconnect_details_t * mp)
20905 vat_main_t *vam = &vat_main;
20907 print (vam->ofp, "%15d%15d",
20908 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20911 static void vl_api_l2_xconnect_details_t_handler_json
20912 (vl_api_l2_xconnect_details_t * mp)
20914 vat_main_t *vam = &vat_main;
20915 vat_json_node_t *node = NULL;
20917 if (VAT_JSON_ARRAY != vam->json_tree.type)
20919 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20920 vat_json_init_array (&vam->json_tree);
20922 node = vat_json_array_add (&vam->json_tree);
20924 vat_json_init_object (node);
20925 vat_json_object_add_uint (node, "rx_sw_if_index",
20926 ntohl (mp->rx_sw_if_index));
20927 vat_json_object_add_uint (node, "tx_sw_if_index",
20928 ntohl (mp->tx_sw_if_index));
20932 api_l2_xconnect_dump (vat_main_t * vam)
20934 vl_api_l2_xconnect_dump_t *mp;
20935 vl_api_control_ping_t *mp_ping;
20938 if (!vam->json_output)
20940 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20943 M (L2_XCONNECT_DUMP, mp);
20947 /* Use a control ping for synchronization */
20948 MPING (CONTROL_PING, mp_ping);
20956 api_hw_interface_set_mtu (vat_main_t * vam)
20958 unformat_input_t *i = vam->input;
20959 vl_api_hw_interface_set_mtu_t *mp;
20960 u32 sw_if_index = ~0;
20964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20966 if (unformat (i, "mtu %d", &mtu))
20968 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20970 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20976 if (sw_if_index == ~0)
20978 errmsg ("missing interface name or sw_if_index");
20984 errmsg ("no mtu specified");
20988 /* Construct the API message */
20989 M (HW_INTERFACE_SET_MTU, mp);
20990 mp->sw_if_index = ntohl (sw_if_index);
20991 mp->mtu = ntohs ((u16) mtu);
20999 api_p2p_ethernet_add (vat_main_t * vam)
21001 unformat_input_t *i = vam->input;
21002 vl_api_p2p_ethernet_add_t *mp;
21003 u32 parent_if_index = ~0;
21009 clib_memset (remote_mac, 0, sizeof (remote_mac));
21010 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21012 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21014 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21018 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21020 else if (unformat (i, "sub_id %d", &sub_id))
21024 clib_warning ("parse error '%U'", format_unformat_error, i);
21029 if (parent_if_index == ~0)
21031 errmsg ("missing interface name or sw_if_index");
21036 errmsg ("missing remote mac address");
21041 errmsg ("missing sub-interface id");
21045 M (P2P_ETHERNET_ADD, mp);
21046 mp->parent_if_index = ntohl (parent_if_index);
21047 mp->subif_id = ntohl (sub_id);
21048 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21056 api_p2p_ethernet_del (vat_main_t * vam)
21058 unformat_input_t *i = vam->input;
21059 vl_api_p2p_ethernet_del_t *mp;
21060 u32 parent_if_index = ~0;
21065 clib_memset (remote_mac, 0, sizeof (remote_mac));
21066 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21068 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21070 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21074 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21078 clib_warning ("parse error '%U'", format_unformat_error, i);
21083 if (parent_if_index == ~0)
21085 errmsg ("missing interface name or sw_if_index");
21090 errmsg ("missing remote mac address");
21094 M (P2P_ETHERNET_DEL, mp);
21095 mp->parent_if_index = ntohl (parent_if_index);
21096 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21104 api_lldp_config (vat_main_t * vam)
21106 unformat_input_t *i = vam->input;
21107 vl_api_lldp_config_t *mp;
21109 int tx_interval = 0;
21110 u8 *sys_name = NULL;
21113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21115 if (unformat (i, "system-name %s", &sys_name))
21117 else if (unformat (i, "tx-hold %d", &tx_hold))
21119 else if (unformat (i, "tx-interval %d", &tx_interval))
21123 clib_warning ("parse error '%U'", format_unformat_error, i);
21128 vec_add1 (sys_name, 0);
21130 M (LLDP_CONFIG, mp);
21131 mp->tx_hold = htonl (tx_hold);
21132 mp->tx_interval = htonl (tx_interval);
21133 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21134 vec_free (sys_name);
21142 api_sw_interface_set_lldp (vat_main_t * vam)
21144 unformat_input_t *i = vam->input;
21145 vl_api_sw_interface_set_lldp_t *mp;
21146 u32 sw_if_index = ~0;
21148 u8 *port_desc = NULL, *mgmt_oid = NULL;
21149 ip4_address_t ip4_addr;
21150 ip6_address_t ip6_addr;
21153 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21154 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21158 if (unformat (i, "disable"))
21161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21165 else if (unformat (i, "port-desc %s", &port_desc))
21167 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21169 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21171 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21177 if (sw_if_index == ~0)
21179 errmsg ("missing interface name or sw_if_index");
21183 /* Construct the API message */
21184 vec_add1 (port_desc, 0);
21185 vec_add1 (mgmt_oid, 0);
21186 M (SW_INTERFACE_SET_LLDP, mp);
21187 mp->sw_if_index = ntohl (sw_if_index);
21188 mp->enable = enable;
21189 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21190 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21191 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21192 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21193 vec_free (port_desc);
21194 vec_free (mgmt_oid);
21202 api_tcp_configure_src_addresses (vat_main_t * vam)
21204 vl_api_tcp_configure_src_addresses_t *mp;
21205 unformat_input_t *i = vam->input;
21206 ip4_address_t v4first, v4last;
21207 ip6_address_t v6first, v6last;
21212 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21214 if (unformat (i, "%U - %U",
21215 unformat_ip4_address, &v4first,
21216 unformat_ip4_address, &v4last))
21220 errmsg ("one range per message (range already set)");
21225 else if (unformat (i, "%U - %U",
21226 unformat_ip6_address, &v6first,
21227 unformat_ip6_address, &v6last))
21231 errmsg ("one range per message (range already set)");
21236 else if (unformat (i, "vrf %d", &vrf_id))
21242 if (range_set == 0)
21244 errmsg ("address range not set");
21248 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21249 mp->vrf_id = ntohl (vrf_id);
21251 if (range_set == 2)
21254 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21255 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21260 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21261 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21268 static void vl_api_app_namespace_add_del_reply_t_handler
21269 (vl_api_app_namespace_add_del_reply_t * mp)
21271 vat_main_t *vam = &vat_main;
21272 i32 retval = ntohl (mp->retval);
21273 if (vam->async_mode)
21275 vam->async_errors += (retval < 0);
21279 vam->retval = retval;
21281 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21282 vam->result_ready = 1;
21286 static void vl_api_app_namespace_add_del_reply_t_handler_json
21287 (vl_api_app_namespace_add_del_reply_t * mp)
21289 vat_main_t *vam = &vat_main;
21290 vat_json_node_t node;
21292 vat_json_init_object (&node);
21293 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21294 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21296 vat_json_print (vam->ofp, &node);
21297 vat_json_free (&node);
21299 vam->retval = ntohl (mp->retval);
21300 vam->result_ready = 1;
21304 api_app_namespace_add_del (vat_main_t * vam)
21306 vl_api_app_namespace_add_del_t *mp;
21307 unformat_input_t *i = vam->input;
21308 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21309 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21315 if (unformat (i, "id %_%v%_", &ns_id))
21317 else if (unformat (i, "secret %lu", &secret))
21319 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21320 sw_if_index_set = 1;
21321 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21323 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21328 if (!ns_id || !secret_set || !sw_if_index_set)
21330 errmsg ("namespace id, secret and sw_if_index must be set");
21333 if (vec_len (ns_id) > 64)
21335 errmsg ("namespace id too long");
21338 M (APP_NAMESPACE_ADD_DEL, mp);
21340 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21341 mp->namespace_id_len = vec_len (ns_id);
21342 mp->secret = clib_host_to_net_u64 (secret);
21343 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21344 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21345 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21353 api_sock_init_shm (vat_main_t * vam)
21355 #if VPP_API_TEST_BUILTIN == 0
21356 unformat_input_t *i = vam->input;
21357 vl_api_shm_elem_config_t *config = 0;
21358 u64 size = 64 << 20;
21361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21363 if (unformat (i, "size %U", unformat_memory_size, &size))
21370 * Canned custom ring allocator config.
21371 * Should probably parse all of this
21373 vec_validate (config, 6);
21374 config[0].type = VL_API_VLIB_RING;
21375 config[0].size = 256;
21376 config[0].count = 32;
21378 config[1].type = VL_API_VLIB_RING;
21379 config[1].size = 1024;
21380 config[1].count = 16;
21382 config[2].type = VL_API_VLIB_RING;
21383 config[2].size = 4096;
21384 config[2].count = 2;
21386 config[3].type = VL_API_CLIENT_RING;
21387 config[3].size = 256;
21388 config[3].count = 32;
21390 config[4].type = VL_API_CLIENT_RING;
21391 config[4].size = 1024;
21392 config[4].count = 16;
21394 config[5].type = VL_API_CLIENT_RING;
21395 config[5].size = 4096;
21396 config[5].count = 2;
21398 config[6].type = VL_API_QUEUE;
21399 config[6].count = 128;
21400 config[6].size = sizeof (uword);
21402 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
21404 vam->client_index_invalid = 1;
21412 api_dns_enable_disable (vat_main_t * vam)
21414 unformat_input_t *line_input = vam->input;
21415 vl_api_dns_enable_disable_t *mp;
21416 u8 enable_disable = 1;
21419 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21421 if (unformat (line_input, "disable"))
21422 enable_disable = 0;
21423 if (unformat (line_input, "enable"))
21424 enable_disable = 1;
21429 /* Construct the API message */
21430 M (DNS_ENABLE_DISABLE, mp);
21431 mp->enable = enable_disable;
21435 /* Wait for the reply */
21441 api_dns_resolve_name (vat_main_t * vam)
21443 unformat_input_t *line_input = vam->input;
21444 vl_api_dns_resolve_name_t *mp;
21448 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21450 if (unformat (line_input, "%s", &name))
21456 if (vec_len (name) > 127)
21458 errmsg ("name too long");
21462 /* Construct the API message */
21463 M (DNS_RESOLVE_NAME, mp);
21464 memcpy (mp->name, name, vec_len (name));
21469 /* Wait for the reply */
21475 api_dns_resolve_ip (vat_main_t * vam)
21477 unformat_input_t *line_input = vam->input;
21478 vl_api_dns_resolve_ip_t *mp;
21480 ip4_address_t addr4;
21481 ip6_address_t addr6;
21484 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21486 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21488 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21496 errmsg ("missing address");
21500 /* Construct the API message */
21501 M (DNS_RESOLVE_IP, mp);
21502 mp->is_ip6 = is_ip6;
21504 memcpy (mp->address, &addr6, sizeof (addr6));
21506 memcpy (mp->address, &addr4, sizeof (addr4));
21510 /* Wait for the reply */
21516 api_dns_name_server_add_del (vat_main_t * vam)
21518 unformat_input_t *i = vam->input;
21519 vl_api_dns_name_server_add_del_t *mp;
21521 ip6_address_t ip6_server;
21522 ip4_address_t ip4_server;
21527 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21529 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21531 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21533 else if (unformat (i, "del"))
21537 clib_warning ("parse error '%U'", format_unformat_error, i);
21542 if (ip4_set && ip6_set)
21544 errmsg ("Only one server address allowed per message");
21547 if ((ip4_set + ip6_set) == 0)
21549 errmsg ("Server address required");
21553 /* Construct the API message */
21554 M (DNS_NAME_SERVER_ADD_DEL, mp);
21558 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21563 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21567 mp->is_add = is_add;
21572 /* Wait for a reply, return good/bad news */
21578 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21580 vat_main_t *vam = &vat_main;
21585 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21586 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21587 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21588 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21589 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21590 clib_net_to_host_u32 (mp->action_index), mp->tag);
21595 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21596 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21597 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21598 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21599 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21600 clib_net_to_host_u32 (mp->action_index), mp->tag);
21605 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21608 vat_main_t *vam = &vat_main;
21609 vat_json_node_t *node = NULL;
21610 struct in6_addr ip6;
21611 struct in_addr ip4;
21613 if (VAT_JSON_ARRAY != vam->json_tree.type)
21615 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21616 vat_json_init_array (&vam->json_tree);
21618 node = vat_json_array_add (&vam->json_tree);
21619 vat_json_init_object (node);
21621 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21622 vat_json_object_add_uint (node, "appns_index",
21623 clib_net_to_host_u32 (mp->appns_index));
21624 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21625 vat_json_object_add_uint (node, "scope", mp->scope);
21626 vat_json_object_add_uint (node, "action_index",
21627 clib_net_to_host_u32 (mp->action_index));
21628 vat_json_object_add_uint (node, "lcl_port",
21629 clib_net_to_host_u16 (mp->lcl_port));
21630 vat_json_object_add_uint (node, "rmt_port",
21631 clib_net_to_host_u16 (mp->rmt_port));
21632 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21633 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21634 vat_json_object_add_string_copy (node, "tag", mp->tag);
21637 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21638 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21639 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21640 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21644 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21645 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21646 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21647 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21652 api_session_rule_add_del (vat_main_t * vam)
21654 vl_api_session_rule_add_del_t *mp;
21655 unformat_input_t *i = vam->input;
21656 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21657 u32 appns_index = 0, scope = 0;
21658 ip4_address_t lcl_ip4, rmt_ip4;
21659 ip6_address_t lcl_ip6, rmt_ip6;
21660 u8 is_ip4 = 1, conn_set = 0;
21661 u8 is_add = 1, *tag = 0;
21664 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21666 if (unformat (i, "del"))
21668 else if (unformat (i, "add"))
21670 else if (unformat (i, "proto tcp"))
21672 else if (unformat (i, "proto udp"))
21674 else if (unformat (i, "appns %d", &appns_index))
21676 else if (unformat (i, "scope %d", &scope))
21678 else if (unformat (i, "tag %_%v%_", &tag))
21682 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21683 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21691 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21692 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21698 else if (unformat (i, "action %d", &action))
21703 if (proto == ~0 || !conn_set || action == ~0)
21705 errmsg ("transport proto, connection and action must be set");
21711 errmsg ("scope should be 0-3");
21715 M (SESSION_RULE_ADD_DEL, mp);
21717 mp->is_ip4 = is_ip4;
21718 mp->transport_proto = proto;
21719 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21720 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21721 mp->lcl_plen = lcl_plen;
21722 mp->rmt_plen = rmt_plen;
21723 mp->action_index = clib_host_to_net_u32 (action);
21724 mp->appns_index = clib_host_to_net_u32 (appns_index);
21726 mp->is_add = is_add;
21729 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21730 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21734 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21735 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21739 clib_memcpy (mp->tag, tag, vec_len (tag));
21749 api_session_rules_dump (vat_main_t * vam)
21751 vl_api_session_rules_dump_t *mp;
21752 vl_api_control_ping_t *mp_ping;
21755 if (!vam->json_output)
21757 print (vam->ofp, "%=20s", "Session Rules");
21760 M (SESSION_RULES_DUMP, mp);
21764 /* Use a control ping for synchronization */
21765 MPING (CONTROL_PING, mp_ping);
21768 /* Wait for a reply... */
21774 api_ip_container_proxy_add_del (vat_main_t * vam)
21776 vl_api_ip_container_proxy_add_del_t *mp;
21777 unformat_input_t *i = vam->input;
21778 u32 sw_if_index = ~0;
21779 vl_api_prefix_t pfx = { };
21783 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21785 if (unformat (i, "del"))
21787 else if (unformat (i, "add"))
21789 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21791 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21796 if (sw_if_index == ~0 || pfx.address_length == 0)
21798 errmsg ("address and sw_if_index must be set");
21802 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21804 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21805 mp->is_add = is_add;
21806 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21814 api_qos_record_enable_disable (vat_main_t * vam)
21816 unformat_input_t *i = vam->input;
21817 vl_api_qos_record_enable_disable_t *mp;
21818 u32 sw_if_index, qs = 0xff;
21819 u8 sw_if_index_set = 0;
21823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21825 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21826 sw_if_index_set = 1;
21827 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21828 sw_if_index_set = 1;
21829 else if (unformat (i, "%U", unformat_qos_source, &qs))
21831 else if (unformat (i, "disable"))
21835 clib_warning ("parse error '%U'", format_unformat_error, i);
21840 if (sw_if_index_set == 0)
21842 errmsg ("missing interface name or sw_if_index");
21847 errmsg ("input location must be specified");
21851 M (QOS_RECORD_ENABLE_DISABLE, mp);
21853 mp->sw_if_index = ntohl (sw_if_index);
21854 mp->input_source = qs;
21855 mp->enable = enable;
21864 q_or_quit (vat_main_t * vam)
21866 #if VPP_API_TEST_BUILTIN == 0
21867 longjmp (vam->jump_buf, 1);
21869 return 0; /* not so much */
21873 q (vat_main_t * vam)
21875 return q_or_quit (vam);
21879 quit (vat_main_t * vam)
21881 return q_or_quit (vam);
21885 comment (vat_main_t * vam)
21891 statseg (vat_main_t * vam)
21893 ssvm_private_t *ssvmp = &vam->stat_segment;
21894 ssvm_shared_header_t *shared_header = ssvmp->sh;
21895 vlib_counter_t **counters;
21896 u64 thread0_index1_packets;
21897 u64 thread0_index1_bytes;
21898 f64 vector_rate, input_rate;
21901 uword *counter_vector_by_name;
21902 if (vam->stat_segment_lockp == 0)
21904 errmsg ("Stat segment not mapped...");
21908 /* look up "/if/rx for sw_if_index 1 as a test */
21910 clib_spinlock_lock (vam->stat_segment_lockp);
21912 counter_vector_by_name = (uword *) shared_header->opaque[1];
21914 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21917 clib_spinlock_unlock (vam->stat_segment_lockp);
21918 errmsg ("/if/tx not found?");
21922 /* Fish per-thread vector of combined counters from shared memory */
21923 counters = (vlib_counter_t **) p[0];
21925 if (vec_len (counters[0]) < 2)
21927 clib_spinlock_unlock (vam->stat_segment_lockp);
21928 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21932 /* Read thread 0 sw_if_index 1 counter */
21933 thread0_index1_packets = counters[0][1].packets;
21934 thread0_index1_bytes = counters[0][1].bytes;
21936 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21939 clib_spinlock_unlock (vam->stat_segment_lockp);
21940 errmsg ("vector_rate not found?");
21944 vector_rate = *(f64 *) (p[0]);
21945 p = hash_get_mem (counter_vector_by_name, "input_rate");
21948 clib_spinlock_unlock (vam->stat_segment_lockp);
21949 errmsg ("input_rate not found?");
21952 input_rate = *(f64 *) (p[0]);
21954 clib_spinlock_unlock (vam->stat_segment_lockp);
21956 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21957 vector_rate, input_rate);
21958 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21959 thread0_index1_packets, thread0_index1_bytes);
21965 cmd_cmp (void *a1, void *a2)
21970 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21974 help (vat_main_t * vam)
21979 unformat_input_t *i = vam->input;
21982 if (unformat (i, "%s", &name))
21986 vec_add1 (name, 0);
21988 hs = hash_get_mem (vam->help_by_name, name);
21990 print (vam->ofp, "usage: %s %s", name, hs[0]);
21992 print (vam->ofp, "No such msg / command '%s'", name);
21997 print (vam->ofp, "Help is available for the following:");
22000 hash_foreach_pair (p, vam->function_by_name,
22002 vec_add1 (cmds, (u8 *)(p->key));
22006 vec_sort_with_function (cmds, cmd_cmp);
22008 for (j = 0; j < vec_len (cmds); j++)
22009 print (vam->ofp, "%s", cmds[j]);
22016 set (vat_main_t * vam)
22018 u8 *name = 0, *value = 0;
22019 unformat_input_t *i = vam->input;
22021 if (unformat (i, "%s", &name))
22023 /* The input buffer is a vector, not a string. */
22024 value = vec_dup (i->buffer);
22025 vec_delete (value, i->index, 0);
22026 /* Almost certainly has a trailing newline */
22027 if (value[vec_len (value) - 1] == '\n')
22028 value[vec_len (value) - 1] = 0;
22029 /* Make sure it's a proper string, one way or the other */
22030 vec_add1 (value, 0);
22031 (void) clib_macro_set_value (&vam->macro_main,
22032 (char *) name, (char *) value);
22035 errmsg ("usage: set <name> <value>");
22043 unset (vat_main_t * vam)
22047 if (unformat (vam->input, "%s", &name))
22048 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22049 errmsg ("unset: %s wasn't set", name);
22062 macro_sort_cmp (void *a1, void *a2)
22064 macro_sort_t *s1 = a1;
22065 macro_sort_t *s2 = a2;
22067 return strcmp ((char *) (s1->name), (char *) (s2->name));
22071 dump_macro_table (vat_main_t * vam)
22073 macro_sort_t *sort_me = 0, *sm;
22078 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22080 vec_add2 (sort_me, sm, 1);
22081 sm->name = (u8 *)(p->key);
22082 sm->value = (u8 *) (p->value[0]);
22086 vec_sort_with_function (sort_me, macro_sort_cmp);
22088 if (vec_len (sort_me))
22089 print (vam->ofp, "%-15s%s", "Name", "Value");
22091 print (vam->ofp, "The macro table is empty...");
22093 for (i = 0; i < vec_len (sort_me); i++)
22094 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22099 dump_node_table (vat_main_t * vam)
22102 vlib_node_t *node, *next_node;
22104 if (vec_len (vam->graph_nodes) == 0)
22106 print (vam->ofp, "Node table empty, issue get_node_graph...");
22110 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22112 node = vam->graph_nodes[0][i];
22113 print (vam->ofp, "[%d] %s", i, node->name);
22114 for (j = 0; j < vec_len (node->next_nodes); j++)
22116 if (node->next_nodes[j] != ~0)
22118 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22119 print (vam->ofp, " [%d] %s", j, next_node->name);
22127 value_sort_cmp (void *a1, void *a2)
22129 name_sort_t *n1 = a1;
22130 name_sort_t *n2 = a2;
22132 if (n1->value < n2->value)
22134 if (n1->value > n2->value)
22141 dump_msg_api_table (vat_main_t * vam)
22143 api_main_t *am = &api_main;
22144 name_sort_t *nses = 0, *ns;
22149 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22151 vec_add2 (nses, ns, 1);
22152 ns->name = (u8 *)(hp->key);
22153 ns->value = (u32) hp->value[0];
22157 vec_sort_with_function (nses, value_sort_cmp);
22159 for (i = 0; i < vec_len (nses); i++)
22160 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22166 get_msg_id (vat_main_t * vam)
22171 if (unformat (vam->input, "%s", &name_and_crc))
22173 message_index = vl_msg_api_get_msg_index (name_and_crc);
22174 if (message_index == ~0)
22176 print (vam->ofp, " '%s' not found", name_and_crc);
22179 print (vam->ofp, " '%s' has message index %d",
22180 name_and_crc, message_index);
22183 errmsg ("name_and_crc required...");
22188 search_node_table (vat_main_t * vam)
22190 unformat_input_t *line_input = vam->input;
22193 vlib_node_t *node, *next_node;
22196 if (vam->graph_node_index_by_name == 0)
22198 print (vam->ofp, "Node table empty, issue get_node_graph...");
22202 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22204 if (unformat (line_input, "%s", &node_to_find))
22206 vec_add1 (node_to_find, 0);
22207 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22210 print (vam->ofp, "%s not found...", node_to_find);
22213 node = vam->graph_nodes[0][p[0]];
22214 print (vam->ofp, "[%d] %s", p[0], node->name);
22215 for (j = 0; j < vec_len (node->next_nodes); j++)
22217 if (node->next_nodes[j] != ~0)
22219 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22220 print (vam->ofp, " [%d] %s", j, next_node->name);
22227 clib_warning ("parse error '%U'", format_unformat_error,
22233 vec_free (node_to_find);
22242 script (vat_main_t * vam)
22244 #if (VPP_API_TEST_BUILTIN==0)
22246 char *save_current_file;
22247 unformat_input_t save_input;
22248 jmp_buf save_jump_buf;
22249 u32 save_line_number;
22251 FILE *new_fp, *save_ifp;
22253 if (unformat (vam->input, "%s", &s))
22255 new_fp = fopen ((char *) s, "r");
22258 errmsg ("Couldn't open script file %s", s);
22265 errmsg ("Missing script name");
22269 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22270 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22271 save_ifp = vam->ifp;
22272 save_line_number = vam->input_line_number;
22273 save_current_file = (char *) vam->current_file;
22275 vam->input_line_number = 0;
22277 vam->current_file = s;
22280 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
22281 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22282 vam->ifp = save_ifp;
22283 vam->input_line_number = save_line_number;
22284 vam->current_file = (u8 *) save_current_file;
22289 clib_warning ("use the exec command...");
22295 echo (vat_main_t * vam)
22297 print (vam->ofp, "%v", vam->input->buffer);
22301 /* List of API message constructors, CLI names map to api_xxx */
22302 #define foreach_vpe_api_msg \
22303 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22304 _(sw_interface_dump,"") \
22305 _(sw_interface_set_flags, \
22306 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22307 _(sw_interface_add_del_address, \
22308 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22309 _(sw_interface_set_rx_mode, \
22310 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22311 _(sw_interface_set_rx_placement, \
22312 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
22313 _(sw_interface_rx_placement_dump, \
22314 "[<intfc> | sw_if_index <id>]") \
22315 _(sw_interface_set_table, \
22316 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22317 _(sw_interface_set_mpls_enable, \
22318 "<intfc> | sw_if_index [disable | dis]") \
22319 _(sw_interface_set_vpath, \
22320 "<intfc> | sw_if_index <id> enable | disable") \
22321 _(sw_interface_set_vxlan_bypass, \
22322 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22323 _(sw_interface_set_geneve_bypass, \
22324 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22325 _(sw_interface_set_l2_xconnect, \
22326 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22327 "enable | disable") \
22328 _(sw_interface_set_l2_bridge, \
22329 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22330 "[shg <split-horizon-group>] [bvi]\n" \
22331 "enable | disable") \
22332 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22333 _(bridge_domain_add_del, \
22334 "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") \
22335 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22337 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22338 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22339 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22341 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22343 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22345 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22347 "<vpp-if-name> | sw_if_index <id>") \
22348 _(sw_interface_tap_v2_dump, "") \
22349 _(virtio_pci_create, \
22350 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
22351 _(virtio_pci_delete, \
22352 "<vpp-if-name> | sw_if_index <id>") \
22353 _(sw_interface_virtio_pci_dump, "") \
22355 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
22356 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
22359 "<vpp-if-name> | sw_if_index <id>") \
22361 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
22362 _(bond_detach_slave, \
22363 "sw_if_index <n>") \
22364 _(sw_interface_bond_dump, "") \
22365 _(sw_interface_slave_dump, \
22366 "<vpp-if-name> | sw_if_index <id>") \
22367 _(ip_table_add_del, \
22368 "table <n> [ipv6] [add | del]\n") \
22369 _(ip_add_del_route, \
22370 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
22371 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
22372 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
22373 "[multipath] [count <n>] [del]") \
22374 _(ip_mroute_add_del, \
22375 "<src> <grp>/<mask> [table-id <n>]\n" \
22376 "[<intfc> | sw_if_index <id>] [local] [del]") \
22377 _(mpls_table_add_del, \
22378 "table <n> [add | del]\n") \
22379 _(mpls_route_add_del, \
22380 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
22381 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
22382 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
22383 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
22384 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
22385 "[count <n>] [del]") \
22386 _(mpls_ip_bind_unbind, \
22387 "<label> <addr/len>") \
22388 _(mpls_tunnel_add_del, \
22389 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22390 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22391 "[l2-only] [out-label <n>]") \
22392 _(sr_mpls_policy_add, \
22393 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22394 _(sr_mpls_policy_del, \
22396 _(bier_table_add_del, \
22397 "<label> <sub-domain> <set> <bsl> [del]") \
22398 _(bier_route_add_del, \
22399 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22400 "[<intfc> | sw_if_index <id>]" \
22401 "[weight <n>] [del] [multipath]") \
22402 _(proxy_arp_add_del, \
22403 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22404 _(proxy_arp_intfc_enable_disable, \
22405 "<intfc> | sw_if_index <id> enable | disable") \
22406 _(sw_interface_set_unnumbered, \
22407 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22408 _(ip_neighbor_add_del, \
22409 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22410 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22411 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22412 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22413 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22414 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22415 "[outer_vlan_id_any][inner_vlan_id_any]") \
22416 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22417 _(reset_fib, "vrf <n> [ipv6]") \
22418 _(dhcp_proxy_config, \
22419 "svr <v46-address> src <v46-address>\n" \
22420 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22421 _(dhcp_proxy_set_vss, \
22422 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22423 _(dhcp_proxy_dump, "ip6") \
22424 _(dhcp_client_config, \
22425 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22426 _(set_ip_flow_hash, \
22427 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22428 _(sw_interface_ip6_enable_disable, \
22429 "<intfc> | sw_if_index <id> enable | disable") \
22430 _(ip6nd_proxy_add_del, \
22431 "<intfc> | sw_if_index <id> <ip6-address>") \
22432 _(ip6nd_proxy_dump, "") \
22433 _(sw_interface_ip6nd_ra_prefix, \
22434 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22435 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22436 "[nolink] [isno]") \
22437 _(sw_interface_ip6nd_ra_config, \
22438 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22439 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22440 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22441 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22442 _(l2_patch_add_del, \
22443 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22444 "enable | disable") \
22445 _(sr_localsid_add_del, \
22446 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22447 "fib-table <num> (end.psp) sw_if_index <num>") \
22448 _(classify_add_del_table, \
22449 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22450 " [del] [del-chain] mask <mask-value>\n" \
22451 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22452 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22453 _(classify_add_del_session, \
22454 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22455 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22456 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22457 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22458 _(classify_set_interface_ip_table, \
22459 "<intfc> | sw_if_index <nn> table <nn>") \
22460 _(classify_set_interface_l2_tables, \
22461 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22462 " [other-table <nn>]") \
22463 _(get_node_index, "node <node-name") \
22464 _(add_node_next, "node <node-name> next <next-node-name>") \
22465 _(l2tpv3_create_tunnel, \
22466 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22467 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22468 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22469 _(l2tpv3_set_tunnel_cookies, \
22470 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22471 "[new_remote_cookie <nn>]\n") \
22472 _(l2tpv3_interface_enable_disable, \
22473 "<intfc> | sw_if_index <nn> enable | disable") \
22474 _(l2tpv3_set_lookup_key, \
22475 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22476 _(sw_if_l2tpv3_tunnel_dump, "") \
22477 _(vxlan_offload_rx, \
22478 "hw { <interface name> | hw_if_index <nn>} " \
22479 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22480 _(vxlan_add_del_tunnel, \
22481 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22482 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22483 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22484 _(geneve_add_del_tunnel, \
22485 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22486 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22487 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22488 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22489 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22490 _(gre_tunnel_add_del, \
22491 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22492 "[teb | erspan <session-id>] [del]") \
22493 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22494 _(l2_fib_clear_table, "") \
22495 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22496 _(l2_interface_vlan_tag_rewrite, \
22497 "<intfc> | sw_if_index <nn> \n" \
22498 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22499 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22500 _(create_vhost_user_if, \
22501 "socket <filename> [server] [renumber <dev_instance>] " \
22502 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22503 "[mac <mac_address>]") \
22504 _(modify_vhost_user_if, \
22505 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22506 "[server] [renumber <dev_instance>]") \
22507 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22508 _(sw_interface_vhost_user_dump, "") \
22509 _(show_version, "") \
22510 _(show_threads, "") \
22511 _(vxlan_gpe_add_del_tunnel, \
22512 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22513 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22514 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22515 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22516 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22517 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22518 _(interface_name_renumber, \
22519 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22520 _(input_acl_set_interface, \
22521 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22522 " [l2-table <nn>] [del]") \
22523 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22524 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22525 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22526 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22527 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22528 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22529 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22530 _(ip_dump, "ipv4 | ipv6") \
22531 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22532 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22534 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22535 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22536 " integ_alg <alg> integ_key <hex>") \
22537 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22538 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22539 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22540 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22541 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22542 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22543 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22544 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22545 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22546 " [instance <n>]") \
22547 _(ipsec_sa_dump, "[sa_id <n>]") \
22548 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22549 " <alg> <hex>\n") \
22550 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22551 _(delete_loopback,"sw_if_index <nn>") \
22552 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22553 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22554 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22555 _(want_interface_events, "enable|disable") \
22556 _(get_first_msg_id, "client <name>") \
22557 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22558 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22559 "fib-id <nn> [ip4][ip6][default]") \
22560 _(get_node_graph, " ") \
22561 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22562 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22563 _(ioam_disable, "") \
22564 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22565 " sw_if_index <sw_if_index> p <priority> " \
22566 "w <weight>] [del]") \
22567 _(one_add_del_locator, "locator-set <locator_name> " \
22568 "iface <intf> | sw_if_index <sw_if_index> " \
22569 "p <priority> w <weight> [del]") \
22570 _(one_add_del_local_eid,"vni <vni> eid " \
22571 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22572 "locator-set <locator_name> [del]" \
22573 "[key-id sha1|sha256 secret-key <secret-key>]")\
22574 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22575 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22576 _(one_enable_disable, "enable|disable") \
22577 _(one_map_register_enable_disable, "enable|disable") \
22578 _(one_map_register_fallback_threshold, "<value>") \
22579 _(one_rloc_probe_enable_disable, "enable|disable") \
22580 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22582 "rloc <locator> p <prio> " \
22583 "w <weight> [rloc <loc> ... ] " \
22584 "action <action> [del-all]") \
22585 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22587 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22588 _(one_use_petr, "ip-address> | disable") \
22589 _(one_map_request_mode, "src-dst|dst-only") \
22590 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22591 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22592 _(one_locator_set_dump, "[local | remote]") \
22593 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22594 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22595 "[local] | [remote]") \
22596 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22597 _(one_ndp_bd_get, "") \
22598 _(one_ndp_entries_get, "bd <bridge-domain>") \
22599 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22600 _(one_l2_arp_bd_get, "") \
22601 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22602 _(one_stats_enable_disable, "enable|disable") \
22603 _(show_one_stats_enable_disable, "") \
22604 _(one_eid_table_vni_dump, "") \
22605 _(one_eid_table_map_dump, "l2|l3") \
22606 _(one_map_resolver_dump, "") \
22607 _(one_map_server_dump, "") \
22608 _(one_adjacencies_get, "vni <vni>") \
22609 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22610 _(show_one_rloc_probe_state, "") \
22611 _(show_one_map_register_state, "") \
22612 _(show_one_status, "") \
22613 _(one_stats_dump, "") \
22614 _(one_stats_flush, "") \
22615 _(one_get_map_request_itr_rlocs, "") \
22616 _(one_map_register_set_ttl, "<ttl>") \
22617 _(one_set_transport_protocol, "udp|api") \
22618 _(one_get_transport_protocol, "") \
22619 _(one_enable_disable_xtr_mode, "enable|disable") \
22620 _(one_show_xtr_mode, "") \
22621 _(one_enable_disable_pitr_mode, "enable|disable") \
22622 _(one_show_pitr_mode, "") \
22623 _(one_enable_disable_petr_mode, "enable|disable") \
22624 _(one_show_petr_mode, "") \
22625 _(show_one_nsh_mapping, "") \
22626 _(show_one_pitr, "") \
22627 _(show_one_use_petr, "") \
22628 _(show_one_map_request_mode, "") \
22629 _(show_one_map_register_ttl, "") \
22630 _(show_one_map_register_fallback_threshold, "") \
22631 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22632 " sw_if_index <sw_if_index> p <priority> " \
22633 "w <weight>] [del]") \
22634 _(lisp_add_del_locator, "locator-set <locator_name> " \
22635 "iface <intf> | sw_if_index <sw_if_index> " \
22636 "p <priority> w <weight> [del]") \
22637 _(lisp_add_del_local_eid,"vni <vni> eid " \
22638 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22639 "locator-set <locator_name> [del]" \
22640 "[key-id sha1|sha256 secret-key <secret-key>]") \
22641 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22642 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22643 _(lisp_enable_disable, "enable|disable") \
22644 _(lisp_map_register_enable_disable, "enable|disable") \
22645 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22646 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22648 "rloc <locator> p <prio> " \
22649 "w <weight> [rloc <loc> ... ] " \
22650 "action <action> [del-all]") \
22651 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22653 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22654 _(lisp_use_petr, "<ip-address> | disable") \
22655 _(lisp_map_request_mode, "src-dst|dst-only") \
22656 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22657 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22658 _(lisp_locator_set_dump, "[local | remote]") \
22659 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22660 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22661 "[local] | [remote]") \
22662 _(lisp_eid_table_vni_dump, "") \
22663 _(lisp_eid_table_map_dump, "l2|l3") \
22664 _(lisp_map_resolver_dump, "") \
22665 _(lisp_map_server_dump, "") \
22666 _(lisp_adjacencies_get, "vni <vni>") \
22667 _(gpe_fwd_entry_vnis_get, "") \
22668 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22669 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22670 "[table <table-id>]") \
22671 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22672 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22673 _(gpe_set_encap_mode, "lisp|vxlan") \
22674 _(gpe_get_encap_mode, "") \
22675 _(lisp_gpe_add_del_iface, "up|down") \
22676 _(lisp_gpe_enable_disable, "enable|disable") \
22677 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22678 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22679 _(show_lisp_rloc_probe_state, "") \
22680 _(show_lisp_map_register_state, "") \
22681 _(show_lisp_status, "") \
22682 _(lisp_get_map_request_itr_rlocs, "") \
22683 _(show_lisp_pitr, "") \
22684 _(show_lisp_use_petr, "") \
22685 _(show_lisp_map_request_mode, "") \
22686 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22687 _(af_packet_delete, "name <host interface name>") \
22688 _(af_packet_dump, "") \
22689 _(policer_add_del, "name <policer name> <params> [del]") \
22690 _(policer_dump, "[name <policer name>]") \
22691 _(policer_classify_set_interface, \
22692 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22693 " [l2-table <nn>] [del]") \
22694 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22695 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22696 "[master|slave]") \
22697 _(netmap_delete, "name <interface name>") \
22698 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22699 _(mpls_fib_dump, "") \
22700 _(classify_table_ids, "") \
22701 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22702 _(classify_table_info, "table_id <nn>") \
22703 _(classify_session_dump, "table_id <nn>") \
22704 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22705 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22706 "[template_interval <nn>] [udp_checksum]") \
22707 _(ipfix_exporter_dump, "") \
22708 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22709 _(ipfix_classify_stream_dump, "") \
22710 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22711 _(ipfix_classify_table_dump, "") \
22712 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22713 _(sw_interface_span_dump, "[l2]") \
22714 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22715 _(pg_create_interface, "if_id <nn>") \
22716 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22717 _(pg_enable_disable, "[stream <id>] disable") \
22718 _(ip_source_and_port_range_check_add_del, \
22719 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22720 _(ip_source_and_port_range_check_interface_add_del, \
22721 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22722 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22723 _(ipsec_gre_tunnel_add_del, \
22724 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22725 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22726 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22727 _(l2_interface_pbb_tag_rewrite, \
22728 "<intfc> | sw_if_index <nn> \n" \
22729 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22730 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22731 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22732 _(flow_classify_set_interface, \
22733 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22734 _(flow_classify_dump, "type [ip4|ip6]") \
22735 _(ip_fib_dump, "") \
22736 _(ip_mfib_dump, "") \
22737 _(ip6_fib_dump, "") \
22738 _(ip6_mfib_dump, "") \
22739 _(feature_enable_disable, "arc_name <arc_name> " \
22740 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22741 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22743 _(l2_xconnect_dump, "") \
22744 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22745 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22746 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22747 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22748 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22749 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22750 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22751 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22752 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22753 _(sock_init_shm, "size <nnn>") \
22754 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22755 _(dns_enable_disable, "[enable][disable]") \
22756 _(dns_name_server_add_del, "<ip-address> [del]") \
22757 _(dns_resolve_name, "<hostname>") \
22758 _(dns_resolve_ip, "<ip4|ip6>") \
22759 _(dns_name_server_add_del, "<ip-address> [del]") \
22760 _(dns_resolve_name, "<hostname>") \
22761 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22762 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22763 _(session_rules_dump, "") \
22764 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22765 _(output_acl_set_interface, \
22766 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22767 " [l2-table <nn>] [del]") \
22768 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22770 /* List of command functions, CLI names map directly to functions */
22771 #define foreach_cli_function \
22772 _(comment, "usage: comment <ignore-rest-of-line>") \
22773 _(dump_interface_table, "usage: dump_interface_table") \
22774 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22775 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22776 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22777 _(dump_macro_table, "usage: dump_macro_table ") \
22778 _(dump_node_table, "usage: dump_node_table") \
22779 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22780 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22781 _(echo, "usage: echo <message>") \
22782 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22783 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22784 _(help, "usage: help") \
22785 _(q, "usage: quit") \
22786 _(quit, "usage: quit") \
22787 _(search_node_table, "usage: search_node_table <name>...") \
22788 _(set, "usage: set <variable-name> <value>") \
22789 _(script, "usage: script <file-name>") \
22790 _(statseg, "usage: statseg"); \
22791 _(unset, "usage: unset <variable-name>")
22794 static void vl_api_##n##_t_handler_uni \
22795 (vl_api_##n##_t * mp) \
22797 vat_main_t * vam = &vat_main; \
22798 if (vam->json_output) { \
22799 vl_api_##n##_t_handler_json(mp); \
22801 vl_api_##n##_t_handler(mp); \
22804 foreach_vpe_api_reply_msg;
22805 #if VPP_API_TEST_BUILTIN == 0
22806 foreach_standalone_reply_msg;
22811 vat_api_hookup (vat_main_t * vam)
22814 vl_msg_api_set_handlers(VL_API_##N, #n, \
22815 vl_api_##n##_t_handler_uni, \
22817 vl_api_##n##_t_endian, \
22818 vl_api_##n##_t_print, \
22819 sizeof(vl_api_##n##_t), 1);
22820 foreach_vpe_api_reply_msg;
22821 #if VPP_API_TEST_BUILTIN == 0
22822 foreach_standalone_reply_msg;
22826 #if (VPP_API_TEST_BUILTIN==0)
22827 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22829 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22831 vam->function_by_name = hash_create_string (0, sizeof (uword));
22833 vam->help_by_name = hash_create_string (0, sizeof (uword));
22836 /* API messages we can send */
22837 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22838 foreach_vpe_api_msg;
22842 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22843 foreach_vpe_api_msg;
22846 /* CLI functions */
22847 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22848 foreach_cli_function;
22852 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22853 foreach_cli_function;
22857 #if VPP_API_TEST_BUILTIN
22858 static clib_error_t *
22859 vat_api_hookup_shim (vlib_main_t * vm)
22861 vat_api_hookup (&vat_main);
22865 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22869 * fd.io coding-style-patch-verification: ON
22872 * eval: (c-set-style "gnu")