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)
2700 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2701 "router_addr %U host_mac %U",
2702 ntohl (mp->pid), mp->lease.is_ipv6 ? "ipv6" : "ipv4",
2704 format_ip4_address, &mp->lease.host_address,
2705 format_ip4_address, &mp->lease.router_address,
2706 format_ethernet_address, mp->lease.host_mac);
2709 static void vl_api_dhcp_compl_event_t_handler_json
2710 (vl_api_dhcp_compl_event_t * mp)
2712 /* JSON output not supported */
2715 static void vl_api_get_first_msg_id_reply_t_handler
2716 (vl_api_get_first_msg_id_reply_t * mp)
2718 vat_main_t *vam = &vat_main;
2719 i32 retval = ntohl (mp->retval);
2721 if (vam->async_mode)
2723 vam->async_errors += (retval < 0);
2727 vam->retval = retval;
2728 vam->result_ready = 1;
2732 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2736 static void vl_api_get_first_msg_id_reply_t_handler_json
2737 (vl_api_get_first_msg_id_reply_t * mp)
2739 vat_main_t *vam = &vat_main;
2740 vat_json_node_t node;
2742 vat_json_init_object (&node);
2743 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2744 vat_json_object_add_uint (&node, "first_msg_id",
2745 (uint) ntohs (mp->first_msg_id));
2747 vat_json_print (vam->ofp, &node);
2748 vat_json_free (&node);
2750 vam->retval = ntohl (mp->retval);
2751 vam->result_ready = 1;
2754 static void vl_api_get_node_graph_reply_t_handler
2755 (vl_api_get_node_graph_reply_t * mp)
2757 vat_main_t *vam = &vat_main;
2758 api_main_t *am = &api_main;
2759 i32 retval = ntohl (mp->retval);
2760 u8 *pvt_copy, *reply;
2765 if (vam->async_mode)
2767 vam->async_errors += (retval < 0);
2771 vam->retval = retval;
2772 vam->result_ready = 1;
2775 /* "Should never happen..." */
2779 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2780 pvt_copy = vec_dup (reply);
2782 /* Toss the shared-memory original... */
2783 pthread_mutex_lock (&am->vlib_rp->mutex);
2784 oldheap = svm_push_data_heap (am->vlib_rp);
2788 svm_pop_heap (oldheap);
2789 pthread_mutex_unlock (&am->vlib_rp->mutex);
2791 if (vam->graph_nodes)
2793 hash_free (vam->graph_node_index_by_name);
2795 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2797 node = vam->graph_nodes[0][i];
2798 vec_free (node->name);
2799 vec_free (node->next_nodes);
2802 vec_free (vam->graph_nodes[0]);
2803 vec_free (vam->graph_nodes);
2806 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2807 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2808 vec_free (pvt_copy);
2810 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
2812 node = vam->graph_nodes[0][i];
2813 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2817 static void vl_api_get_node_graph_reply_t_handler_json
2818 (vl_api_get_node_graph_reply_t * mp)
2820 vat_main_t *vam = &vat_main;
2821 api_main_t *am = &api_main;
2823 vat_json_node_t node;
2826 /* $$$$ make this real? */
2827 vat_json_init_object (&node);
2828 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2829 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2831 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2833 /* Toss the shared-memory original... */
2834 pthread_mutex_lock (&am->vlib_rp->mutex);
2835 oldheap = svm_push_data_heap (am->vlib_rp);
2839 svm_pop_heap (oldheap);
2840 pthread_mutex_unlock (&am->vlib_rp->mutex);
2842 vat_json_print (vam->ofp, &node);
2843 vat_json_free (&node);
2845 vam->retval = ntohl (mp->retval);
2846 vam->result_ready = 1;
2850 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2852 vat_main_t *vam = &vat_main;
2857 s = format (s, "%=16d%=16d%=16d",
2858 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2862 s = format (s, "%=16U%=16d%=16d",
2863 mp->is_ipv6 ? format_ip6_address :
2865 mp->ip_address, mp->priority, mp->weight);
2868 print (vam->ofp, "%v", s);
2873 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2875 vat_main_t *vam = &vat_main;
2876 vat_json_node_t *node = NULL;
2877 struct in6_addr ip6;
2880 if (VAT_JSON_ARRAY != vam->json_tree.type)
2882 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2883 vat_json_init_array (&vam->json_tree);
2885 node = vat_json_array_add (&vam->json_tree);
2886 vat_json_init_object (node);
2888 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2889 vat_json_object_add_uint (node, "priority", mp->priority);
2890 vat_json_object_add_uint (node, "weight", mp->weight);
2893 vat_json_object_add_uint (node, "sw_if_index",
2894 clib_net_to_host_u32 (mp->sw_if_index));
2899 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2900 vat_json_object_add_ip6 (node, "address", ip6);
2904 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2905 vat_json_object_add_ip4 (node, "address", ip4);
2911 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2914 vat_main_t *vam = &vat_main;
2917 ls_name = format (0, "%s", mp->ls_name);
2919 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2925 vl_api_one_locator_set_details_t_handler_json
2926 (vl_api_one_locator_set_details_t * mp)
2928 vat_main_t *vam = &vat_main;
2929 vat_json_node_t *node = 0;
2932 ls_name = format (0, "%s", mp->ls_name);
2933 vec_add1 (ls_name, 0);
2935 if (VAT_JSON_ARRAY != vam->json_tree.type)
2937 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2938 vat_json_init_array (&vam->json_tree);
2940 node = vat_json_array_add (&vam->json_tree);
2942 vat_json_init_object (node);
2943 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2944 vat_json_object_add_uint (node, "ls_index",
2945 clib_net_to_host_u32 (mp->ls_index));
2953 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2956 unformat_nsh_address (unformat_input_t * input, va_list * args)
2958 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2959 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2963 format_nsh_address_vat (u8 * s, va_list * args)
2965 nsh_t *a = va_arg (*args, nsh_t *);
2966 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2970 format_lisp_flat_eid (u8 * s, va_list * args)
2972 u32 type = va_arg (*args, u32);
2973 u8 *eid = va_arg (*args, u8 *);
2974 u32 eid_len = va_arg (*args, u32);
2979 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2981 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2983 return format (s, "%U", format_ethernet_address, eid);
2985 return format (s, "%U", format_nsh_address_vat, eid);
2991 format_lisp_eid_vat (u8 * s, va_list * args)
2993 u32 type = va_arg (*args, u32);
2994 u8 *eid = va_arg (*args, u8 *);
2995 u32 eid_len = va_arg (*args, u32);
2996 u8 *seid = va_arg (*args, u8 *);
2997 u32 seid_len = va_arg (*args, u32);
2998 u32 is_src_dst = va_arg (*args, u32);
3001 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
3003 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
3009 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
3011 vat_main_t *vam = &vat_main;
3012 u8 *s = 0, *eid = 0;
3014 if (~0 == mp->locator_set_index)
3015 s = format (0, "action: %d", mp->action);
3017 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
3019 eid = format (0, "%U", format_lisp_eid_vat,
3023 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3026 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
3027 clib_net_to_host_u32 (mp->vni),
3029 mp->is_local ? "local" : "remote",
3030 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
3031 clib_net_to_host_u16 (mp->key_id), mp->key);
3038 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
3041 vat_main_t *vam = &vat_main;
3042 vat_json_node_t *node = 0;
3045 if (VAT_JSON_ARRAY != vam->json_tree.type)
3047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3048 vat_json_init_array (&vam->json_tree);
3050 node = vat_json_array_add (&vam->json_tree);
3052 vat_json_init_object (node);
3053 if (~0 == mp->locator_set_index)
3054 vat_json_object_add_uint (node, "action", mp->action);
3056 vat_json_object_add_uint (node, "locator_set_index",
3057 clib_net_to_host_u32 (mp->locator_set_index));
3059 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
3060 if (mp->eid_type == 3)
3062 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
3063 vat_json_init_object (nsh_json);
3064 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
3065 vat_json_object_add_uint (nsh_json, "spi",
3066 clib_net_to_host_u32 (nsh->spi));
3067 vat_json_object_add_uint (nsh_json, "si", nsh->si);
3071 eid = format (0, "%U", format_lisp_eid_vat,
3075 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
3077 vat_json_object_add_string_copy (node, "eid", eid);
3080 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3081 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
3082 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
3086 vat_json_object_add_uint (node, "key_id",
3087 clib_net_to_host_u16 (mp->key_id));
3088 vat_json_object_add_string_copy (node, "key", mp->key);
3093 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
3095 vat_main_t *vam = &vat_main;
3096 u8 *seid = 0, *deid = 0;
3097 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3099 deid = format (0, "%U", format_lisp_eid_vat,
3100 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3102 seid = format (0, "%U", format_lisp_eid_vat,
3103 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3109 format_ip_address_fcn = format_ip4_address;
3111 format_ip_address_fcn = format_ip6_address;
3114 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
3115 clib_net_to_host_u32 (mp->vni),
3117 format_ip_address_fcn, mp->lloc,
3118 format_ip_address_fcn, mp->rloc,
3119 clib_net_to_host_u32 (mp->pkt_count),
3120 clib_net_to_host_u32 (mp->bytes));
3127 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
3129 struct in6_addr ip6;
3131 vat_main_t *vam = &vat_main;
3132 vat_json_node_t *node = 0;
3133 u8 *deid = 0, *seid = 0;
3135 if (VAT_JSON_ARRAY != vam->json_tree.type)
3137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3138 vat_json_init_array (&vam->json_tree);
3140 node = vat_json_array_add (&vam->json_tree);
3142 vat_json_init_object (node);
3143 deid = format (0, "%U", format_lisp_eid_vat,
3144 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
3146 seid = format (0, "%U", format_lisp_eid_vat,
3147 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
3152 vat_json_object_add_string_copy (node, "seid", seid);
3153 vat_json_object_add_string_copy (node, "deid", deid);
3154 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3158 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
3159 vat_json_object_add_ip4 (node, "lloc", ip4);
3160 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
3161 vat_json_object_add_ip4 (node, "rloc", ip4);
3165 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
3166 vat_json_object_add_ip6 (node, "lloc", ip6);
3167 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
3168 vat_json_object_add_ip6 (node, "rloc", ip6);
3170 vat_json_object_add_uint (node, "pkt_count",
3171 clib_net_to_host_u32 (mp->pkt_count));
3172 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
3179 vl_api_one_eid_table_map_details_t_handler
3180 (vl_api_one_eid_table_map_details_t * mp)
3182 vat_main_t *vam = &vat_main;
3184 u8 *line = format (0, "%=10d%=10d",
3185 clib_net_to_host_u32 (mp->vni),
3186 clib_net_to_host_u32 (mp->dp_table));
3187 print (vam->ofp, "%v", line);
3192 vl_api_one_eid_table_map_details_t_handler_json
3193 (vl_api_one_eid_table_map_details_t * mp)
3195 vat_main_t *vam = &vat_main;
3196 vat_json_node_t *node = NULL;
3198 if (VAT_JSON_ARRAY != vam->json_tree.type)
3200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3201 vat_json_init_array (&vam->json_tree);
3203 node = vat_json_array_add (&vam->json_tree);
3204 vat_json_init_object (node);
3205 vat_json_object_add_uint (node, "dp_table",
3206 clib_net_to_host_u32 (mp->dp_table));
3207 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3211 vl_api_one_eid_table_vni_details_t_handler
3212 (vl_api_one_eid_table_vni_details_t * mp)
3214 vat_main_t *vam = &vat_main;
3216 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
3217 print (vam->ofp, "%v", line);
3222 vl_api_one_eid_table_vni_details_t_handler_json
3223 (vl_api_one_eid_table_vni_details_t * mp)
3225 vat_main_t *vam = &vat_main;
3226 vat_json_node_t *node = NULL;
3228 if (VAT_JSON_ARRAY != vam->json_tree.type)
3230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3231 vat_json_init_array (&vam->json_tree);
3233 node = vat_json_array_add (&vam->json_tree);
3234 vat_json_init_object (node);
3235 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
3239 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
3240 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3242 vat_main_t *vam = &vat_main;
3243 int retval = clib_net_to_host_u32 (mp->retval);
3245 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3246 print (vam->ofp, "fallback threshold value: %d", mp->value);
3248 vam->retval = retval;
3249 vam->result_ready = 1;
3253 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
3254 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
3256 vat_main_t *vam = &vat_main;
3257 vat_json_node_t _node, *node = &_node;
3258 int retval = clib_net_to_host_u32 (mp->retval);
3260 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
3261 vat_json_init_object (node);
3262 vat_json_object_add_uint (node, "value", mp->value);
3264 vat_json_print (vam->ofp, node);
3265 vat_json_free (node);
3267 vam->retval = retval;
3268 vam->result_ready = 1;
3272 vl_api_show_one_map_register_state_reply_t_handler
3273 (vl_api_show_one_map_register_state_reply_t * mp)
3275 vat_main_t *vam = &vat_main;
3276 int retval = clib_net_to_host_u32 (mp->retval);
3278 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3280 vam->retval = retval;
3281 vam->result_ready = 1;
3285 vl_api_show_one_map_register_state_reply_t_handler_json
3286 (vl_api_show_one_map_register_state_reply_t * mp)
3288 vat_main_t *vam = &vat_main;
3289 vat_json_node_t _node, *node = &_node;
3290 int retval = clib_net_to_host_u32 (mp->retval);
3292 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3294 vat_json_init_object (node);
3295 vat_json_object_add_string_copy (node, "state", s);
3297 vat_json_print (vam->ofp, node);
3298 vat_json_free (node);
3300 vam->retval = retval;
3301 vam->result_ready = 1;
3306 vl_api_show_one_rloc_probe_state_reply_t_handler
3307 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3309 vat_main_t *vam = &vat_main;
3310 int retval = clib_net_to_host_u32 (mp->retval);
3315 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3317 vam->retval = retval;
3318 vam->result_ready = 1;
3322 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3323 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3325 vat_main_t *vam = &vat_main;
3326 vat_json_node_t _node, *node = &_node;
3327 int retval = clib_net_to_host_u32 (mp->retval);
3329 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3330 vat_json_init_object (node);
3331 vat_json_object_add_string_copy (node, "state", s);
3333 vat_json_print (vam->ofp, node);
3334 vat_json_free (node);
3336 vam->retval = retval;
3337 vam->result_ready = 1;
3342 vl_api_show_one_stats_enable_disable_reply_t_handler
3343 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3345 vat_main_t *vam = &vat_main;
3346 int retval = clib_net_to_host_u32 (mp->retval);
3351 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3353 vam->retval = retval;
3354 vam->result_ready = 1;
3358 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3359 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3361 vat_main_t *vam = &vat_main;
3362 vat_json_node_t _node, *node = &_node;
3363 int retval = clib_net_to_host_u32 (mp->retval);
3365 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3366 vat_json_init_object (node);
3367 vat_json_object_add_string_copy (node, "state", s);
3369 vat_json_print (vam->ofp, node);
3370 vat_json_free (node);
3372 vam->retval = retval;
3373 vam->result_ready = 1;
3378 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3380 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3381 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3382 e->vni = clib_net_to_host_u32 (e->vni);
3386 gpe_fwd_entries_get_reply_t_net_to_host
3387 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3391 mp->count = clib_net_to_host_u32 (mp->count);
3392 for (i = 0; i < mp->count; i++)
3394 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3399 format_gpe_encap_mode (u8 * s, va_list * args)
3401 u32 mode = va_arg (*args, u32);
3406 return format (s, "lisp");
3408 return format (s, "vxlan");
3414 vl_api_gpe_get_encap_mode_reply_t_handler
3415 (vl_api_gpe_get_encap_mode_reply_t * mp)
3417 vat_main_t *vam = &vat_main;
3419 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3420 vam->retval = ntohl (mp->retval);
3421 vam->result_ready = 1;
3425 vl_api_gpe_get_encap_mode_reply_t_handler_json
3426 (vl_api_gpe_get_encap_mode_reply_t * mp)
3428 vat_main_t *vam = &vat_main;
3429 vat_json_node_t node;
3431 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3432 vec_add1 (encap_mode, 0);
3434 vat_json_init_object (&node);
3435 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3437 vec_free (encap_mode);
3438 vat_json_print (vam->ofp, &node);
3439 vat_json_free (&node);
3441 vam->retval = ntohl (mp->retval);
3442 vam->result_ready = 1;
3446 vl_api_gpe_fwd_entry_path_details_t_handler
3447 (vl_api_gpe_fwd_entry_path_details_t * mp)
3449 vat_main_t *vam = &vat_main;
3450 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3452 if (mp->lcl_loc.is_ip4)
3453 format_ip_address_fcn = format_ip4_address;
3455 format_ip_address_fcn = format_ip6_address;
3457 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3458 format_ip_address_fcn, &mp->lcl_loc,
3459 format_ip_address_fcn, &mp->rmt_loc);
3463 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3465 struct in6_addr ip6;
3470 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3471 vat_json_object_add_ip4 (n, "address", ip4);
3475 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3476 vat_json_object_add_ip6 (n, "address", ip6);
3478 vat_json_object_add_uint (n, "weight", loc->weight);
3482 vl_api_gpe_fwd_entry_path_details_t_handler_json
3483 (vl_api_gpe_fwd_entry_path_details_t * mp)
3485 vat_main_t *vam = &vat_main;
3486 vat_json_node_t *node = NULL;
3487 vat_json_node_t *loc_node;
3489 if (VAT_JSON_ARRAY != vam->json_tree.type)
3491 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3492 vat_json_init_array (&vam->json_tree);
3494 node = vat_json_array_add (&vam->json_tree);
3495 vat_json_init_object (node);
3497 loc_node = vat_json_object_add (node, "local_locator");
3498 vat_json_init_object (loc_node);
3499 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3501 loc_node = vat_json_object_add (node, "remote_locator");
3502 vat_json_init_object (loc_node);
3503 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3507 vl_api_gpe_fwd_entries_get_reply_t_handler
3508 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3510 vat_main_t *vam = &vat_main;
3512 int retval = clib_net_to_host_u32 (mp->retval);
3513 vl_api_gpe_fwd_entry_t *e;
3518 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3520 for (i = 0; i < mp->count; i++)
3522 e = &mp->entries[i];
3523 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3524 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3525 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3529 vam->retval = retval;
3530 vam->result_ready = 1;
3534 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3535 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3538 vat_main_t *vam = &vat_main;
3539 vat_json_node_t *e = 0, root;
3541 int retval = clib_net_to_host_u32 (mp->retval);
3542 vl_api_gpe_fwd_entry_t *fwd;
3547 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3548 vat_json_init_array (&root);
3550 for (i = 0; i < mp->count; i++)
3552 e = vat_json_array_add (&root);
3553 fwd = &mp->entries[i];
3555 vat_json_init_object (e);
3556 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3557 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3558 vat_json_object_add_int (e, "vni", fwd->vni);
3559 vat_json_object_add_int (e, "action", fwd->action);
3561 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3562 fwd->leid_prefix_len);
3564 vat_json_object_add_string_copy (e, "leid", s);
3567 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3568 fwd->reid_prefix_len);
3570 vat_json_object_add_string_copy (e, "reid", s);
3574 vat_json_print (vam->ofp, &root);
3575 vat_json_free (&root);
3578 vam->retval = retval;
3579 vam->result_ready = 1;
3583 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3584 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3586 vat_main_t *vam = &vat_main;
3588 int retval = clib_net_to_host_u32 (mp->retval);
3589 vl_api_gpe_native_fwd_rpath_t *r;
3594 n = clib_net_to_host_u32 (mp->count);
3596 for (i = 0; i < n; i++)
3598 r = &mp->entries[i];
3599 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3600 clib_net_to_host_u32 (r->fib_index),
3601 clib_net_to_host_u32 (r->nh_sw_if_index),
3602 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3606 vam->retval = retval;
3607 vam->result_ready = 1;
3611 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3612 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3614 vat_main_t *vam = &vat_main;
3615 vat_json_node_t root, *e;
3617 int retval = clib_net_to_host_u32 (mp->retval);
3618 vl_api_gpe_native_fwd_rpath_t *r;
3624 n = clib_net_to_host_u32 (mp->count);
3625 vat_json_init_array (&root);
3627 for (i = 0; i < n; i++)
3629 e = vat_json_array_add (&root);
3630 vat_json_init_object (e);
3631 r = &mp->entries[i];
3633 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3636 vat_json_object_add_string_copy (e, "ip4", s);
3639 vat_json_object_add_uint (e, "fib_index",
3640 clib_net_to_host_u32 (r->fib_index));
3641 vat_json_object_add_uint (e, "nh_sw_if_index",
3642 clib_net_to_host_u32 (r->nh_sw_if_index));
3645 vat_json_print (vam->ofp, &root);
3646 vat_json_free (&root);
3649 vam->retval = retval;
3650 vam->result_ready = 1;
3654 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3655 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3657 vat_main_t *vam = &vat_main;
3659 int retval = clib_net_to_host_u32 (mp->retval);
3664 n = clib_net_to_host_u32 (mp->count);
3666 for (i = 0; i < n; i++)
3667 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3670 vam->retval = retval;
3671 vam->result_ready = 1;
3675 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3676 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3678 vat_main_t *vam = &vat_main;
3679 vat_json_node_t root;
3681 int retval = clib_net_to_host_u32 (mp->retval);
3686 n = clib_net_to_host_u32 (mp->count);
3687 vat_json_init_array (&root);
3689 for (i = 0; i < n; i++)
3690 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3692 vat_json_print (vam->ofp, &root);
3693 vat_json_free (&root);
3696 vam->retval = retval;
3697 vam->result_ready = 1;
3701 vl_api_one_ndp_entries_get_reply_t_handler
3702 (vl_api_one_ndp_entries_get_reply_t * mp)
3704 vat_main_t *vam = &vat_main;
3706 int retval = clib_net_to_host_u32 (mp->retval);
3711 n = clib_net_to_host_u32 (mp->count);
3713 for (i = 0; i < n; i++)
3714 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3715 format_ethernet_address, mp->entries[i].mac);
3718 vam->retval = retval;
3719 vam->result_ready = 1;
3723 vl_api_one_ndp_entries_get_reply_t_handler_json
3724 (vl_api_one_ndp_entries_get_reply_t * mp)
3727 vat_main_t *vam = &vat_main;
3728 vat_json_node_t *e = 0, root;
3730 int retval = clib_net_to_host_u32 (mp->retval);
3731 vl_api_one_ndp_entry_t *arp_entry;
3736 n = clib_net_to_host_u32 (mp->count);
3737 vat_json_init_array (&root);
3739 for (i = 0; i < n; i++)
3741 e = vat_json_array_add (&root);
3742 arp_entry = &mp->entries[i];
3744 vat_json_init_object (e);
3745 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3748 vat_json_object_add_string_copy (e, "mac", s);
3751 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3753 vat_json_object_add_string_copy (e, "ip6", s);
3757 vat_json_print (vam->ofp, &root);
3758 vat_json_free (&root);
3761 vam->retval = retval;
3762 vam->result_ready = 1;
3766 vl_api_one_l2_arp_entries_get_reply_t_handler
3767 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3769 vat_main_t *vam = &vat_main;
3771 int retval = clib_net_to_host_u32 (mp->retval);
3776 n = clib_net_to_host_u32 (mp->count);
3778 for (i = 0; i < n; i++)
3779 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3780 format_ethernet_address, mp->entries[i].mac);
3783 vam->retval = retval;
3784 vam->result_ready = 1;
3788 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3789 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3792 vat_main_t *vam = &vat_main;
3793 vat_json_node_t *e = 0, root;
3795 int retval = clib_net_to_host_u32 (mp->retval);
3796 vl_api_one_l2_arp_entry_t *arp_entry;
3801 n = clib_net_to_host_u32 (mp->count);
3802 vat_json_init_array (&root);
3804 for (i = 0; i < n; i++)
3806 e = vat_json_array_add (&root);
3807 arp_entry = &mp->entries[i];
3809 vat_json_init_object (e);
3810 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3813 vat_json_object_add_string_copy (e, "mac", s);
3816 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3818 vat_json_object_add_string_copy (e, "ip4", s);
3822 vat_json_print (vam->ofp, &root);
3823 vat_json_free (&root);
3826 vam->retval = retval;
3827 vam->result_ready = 1;
3831 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3833 vat_main_t *vam = &vat_main;
3835 int retval = clib_net_to_host_u32 (mp->retval);
3840 n = clib_net_to_host_u32 (mp->count);
3842 for (i = 0; i < n; i++)
3844 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3848 vam->retval = retval;
3849 vam->result_ready = 1;
3853 vl_api_one_ndp_bd_get_reply_t_handler_json
3854 (vl_api_one_ndp_bd_get_reply_t * mp)
3856 vat_main_t *vam = &vat_main;
3857 vat_json_node_t root;
3859 int retval = clib_net_to_host_u32 (mp->retval);
3864 n = clib_net_to_host_u32 (mp->count);
3865 vat_json_init_array (&root);
3867 for (i = 0; i < n; i++)
3869 vat_json_array_add_uint (&root,
3870 clib_net_to_host_u32 (mp->bridge_domains[i]));
3873 vat_json_print (vam->ofp, &root);
3874 vat_json_free (&root);
3877 vam->retval = retval;
3878 vam->result_ready = 1;
3882 vl_api_one_l2_arp_bd_get_reply_t_handler
3883 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3885 vat_main_t *vam = &vat_main;
3887 int retval = clib_net_to_host_u32 (mp->retval);
3892 n = clib_net_to_host_u32 (mp->count);
3894 for (i = 0; i < n; i++)
3896 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3900 vam->retval = retval;
3901 vam->result_ready = 1;
3905 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3906 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3908 vat_main_t *vam = &vat_main;
3909 vat_json_node_t root;
3911 int retval = clib_net_to_host_u32 (mp->retval);
3916 n = clib_net_to_host_u32 (mp->count);
3917 vat_json_init_array (&root);
3919 for (i = 0; i < n; i++)
3921 vat_json_array_add_uint (&root,
3922 clib_net_to_host_u32 (mp->bridge_domains[i]));
3925 vat_json_print (vam->ofp, &root);
3926 vat_json_free (&root);
3929 vam->retval = retval;
3930 vam->result_ready = 1;
3934 vl_api_one_adjacencies_get_reply_t_handler
3935 (vl_api_one_adjacencies_get_reply_t * mp)
3937 vat_main_t *vam = &vat_main;
3939 int retval = clib_net_to_host_u32 (mp->retval);
3940 vl_api_one_adjacency_t *a;
3945 n = clib_net_to_host_u32 (mp->count);
3947 for (i = 0; i < n; i++)
3949 a = &mp->adjacencies[i];
3950 print (vam->ofp, "%U %40U",
3951 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3952 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3956 vam->retval = retval;
3957 vam->result_ready = 1;
3961 vl_api_one_adjacencies_get_reply_t_handler_json
3962 (vl_api_one_adjacencies_get_reply_t * mp)
3965 vat_main_t *vam = &vat_main;
3966 vat_json_node_t *e = 0, root;
3968 int retval = clib_net_to_host_u32 (mp->retval);
3969 vl_api_one_adjacency_t *a;
3974 n = clib_net_to_host_u32 (mp->count);
3975 vat_json_init_array (&root);
3977 for (i = 0; i < n; i++)
3979 e = vat_json_array_add (&root);
3980 a = &mp->adjacencies[i];
3982 vat_json_init_object (e);
3983 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3984 a->leid_prefix_len);
3986 vat_json_object_add_string_copy (e, "leid", s);
3989 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3990 a->reid_prefix_len);
3992 vat_json_object_add_string_copy (e, "reid", s);
3996 vat_json_print (vam->ofp, &root);
3997 vat_json_free (&root);
4000 vam->retval = retval;
4001 vam->result_ready = 1;
4005 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
4007 vat_main_t *vam = &vat_main;
4009 print (vam->ofp, "%=20U",
4010 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4015 vl_api_one_map_server_details_t_handler_json
4016 (vl_api_one_map_server_details_t * mp)
4018 vat_main_t *vam = &vat_main;
4019 vat_json_node_t *node = NULL;
4020 struct in6_addr ip6;
4023 if (VAT_JSON_ARRAY != vam->json_tree.type)
4025 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4026 vat_json_init_array (&vam->json_tree);
4028 node = vat_json_array_add (&vam->json_tree);
4030 vat_json_init_object (node);
4033 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4034 vat_json_object_add_ip6 (node, "map-server", ip6);
4038 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4039 vat_json_object_add_ip4 (node, "map-server", ip4);
4044 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
4047 vat_main_t *vam = &vat_main;
4049 print (vam->ofp, "%=20U",
4050 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
4055 vl_api_one_map_resolver_details_t_handler_json
4056 (vl_api_one_map_resolver_details_t * mp)
4058 vat_main_t *vam = &vat_main;
4059 vat_json_node_t *node = NULL;
4060 struct in6_addr ip6;
4063 if (VAT_JSON_ARRAY != vam->json_tree.type)
4065 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4066 vat_json_init_array (&vam->json_tree);
4068 node = vat_json_array_add (&vam->json_tree);
4070 vat_json_init_object (node);
4073 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
4074 vat_json_object_add_ip6 (node, "map resolver", ip6);
4078 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
4079 vat_json_object_add_ip4 (node, "map resolver", ip4);
4084 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
4086 vat_main_t *vam = &vat_main;
4087 i32 retval = ntohl (mp->retval);
4091 print (vam->ofp, "feature: %s\ngpe: %s",
4092 mp->feature_status ? "enabled" : "disabled",
4093 mp->gpe_status ? "enabled" : "disabled");
4096 vam->retval = retval;
4097 vam->result_ready = 1;
4101 vl_api_show_one_status_reply_t_handler_json
4102 (vl_api_show_one_status_reply_t * mp)
4104 vat_main_t *vam = &vat_main;
4105 vat_json_node_t node;
4106 u8 *gpe_status = NULL;
4107 u8 *feature_status = NULL;
4109 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
4110 feature_status = format (0, "%s",
4111 mp->feature_status ? "enabled" : "disabled");
4112 vec_add1 (gpe_status, 0);
4113 vec_add1 (feature_status, 0);
4115 vat_json_init_object (&node);
4116 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
4117 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
4119 vec_free (gpe_status);
4120 vec_free (feature_status);
4122 vat_json_print (vam->ofp, &node);
4123 vat_json_free (&node);
4125 vam->retval = ntohl (mp->retval);
4126 vam->result_ready = 1;
4130 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
4131 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4133 vat_main_t *vam = &vat_main;
4134 i32 retval = ntohl (mp->retval);
4138 print (vam->ofp, "%=20s", mp->locator_set_name);
4141 vam->retval = retval;
4142 vam->result_ready = 1;
4146 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
4147 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
4149 vat_main_t *vam = &vat_main;
4150 vat_json_node_t *node = NULL;
4152 if (VAT_JSON_ARRAY != vam->json_tree.type)
4154 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4155 vat_json_init_array (&vam->json_tree);
4157 node = vat_json_array_add (&vam->json_tree);
4159 vat_json_init_object (node);
4160 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
4162 vat_json_print (vam->ofp, node);
4163 vat_json_free (node);
4165 vam->retval = ntohl (mp->retval);
4166 vam->result_ready = 1;
4170 format_lisp_map_request_mode (u8 * s, va_list * args)
4172 u32 mode = va_arg (*args, u32);
4177 return format (0, "dst-only");
4179 return format (0, "src-dst");
4185 vl_api_show_one_map_request_mode_reply_t_handler
4186 (vl_api_show_one_map_request_mode_reply_t * mp)
4188 vat_main_t *vam = &vat_main;
4189 i32 retval = ntohl (mp->retval);
4193 u32 mode = mp->mode;
4194 print (vam->ofp, "map_request_mode: %U",
4195 format_lisp_map_request_mode, mode);
4198 vam->retval = retval;
4199 vam->result_ready = 1;
4203 vl_api_show_one_map_request_mode_reply_t_handler_json
4204 (vl_api_show_one_map_request_mode_reply_t * mp)
4206 vat_main_t *vam = &vat_main;
4207 vat_json_node_t node;
4212 s = format (0, "%U", format_lisp_map_request_mode, mode);
4215 vat_json_init_object (&node);
4216 vat_json_object_add_string_copy (&node, "map_request_mode", s);
4217 vat_json_print (vam->ofp, &node);
4218 vat_json_free (&node);
4221 vam->retval = ntohl (mp->retval);
4222 vam->result_ready = 1;
4226 vl_api_one_show_xtr_mode_reply_t_handler
4227 (vl_api_one_show_xtr_mode_reply_t * mp)
4229 vat_main_t *vam = &vat_main;
4230 i32 retval = ntohl (mp->retval);
4234 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4237 vam->retval = retval;
4238 vam->result_ready = 1;
4242 vl_api_one_show_xtr_mode_reply_t_handler_json
4243 (vl_api_one_show_xtr_mode_reply_t * mp)
4245 vat_main_t *vam = &vat_main;
4246 vat_json_node_t node;
4249 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4250 vec_add1 (status, 0);
4252 vat_json_init_object (&node);
4253 vat_json_object_add_string_copy (&node, "status", status);
4257 vat_json_print (vam->ofp, &node);
4258 vat_json_free (&node);
4260 vam->retval = ntohl (mp->retval);
4261 vam->result_ready = 1;
4265 vl_api_one_show_pitr_mode_reply_t_handler
4266 (vl_api_one_show_pitr_mode_reply_t * mp)
4268 vat_main_t *vam = &vat_main;
4269 i32 retval = ntohl (mp->retval);
4273 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4276 vam->retval = retval;
4277 vam->result_ready = 1;
4281 vl_api_one_show_pitr_mode_reply_t_handler_json
4282 (vl_api_one_show_pitr_mode_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 vat_json_node_t node;
4288 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4289 vec_add1 (status, 0);
4291 vat_json_init_object (&node);
4292 vat_json_object_add_string_copy (&node, "status", status);
4296 vat_json_print (vam->ofp, &node);
4297 vat_json_free (&node);
4299 vam->retval = ntohl (mp->retval);
4300 vam->result_ready = 1;
4304 vl_api_one_show_petr_mode_reply_t_handler
4305 (vl_api_one_show_petr_mode_reply_t * mp)
4307 vat_main_t *vam = &vat_main;
4308 i32 retval = ntohl (mp->retval);
4312 print (vam->ofp, "%s\n", mp->is_en ? "enabled" : "disabled");
4315 vam->retval = retval;
4316 vam->result_ready = 1;
4320 vl_api_one_show_petr_mode_reply_t_handler_json
4321 (vl_api_one_show_petr_mode_reply_t * mp)
4323 vat_main_t *vam = &vat_main;
4324 vat_json_node_t node;
4327 status = format (0, "%s", mp->is_en ? "enabled" : "disabled");
4328 vec_add1 (status, 0);
4330 vat_json_init_object (&node);
4331 vat_json_object_add_string_copy (&node, "status", status);
4335 vat_json_print (vam->ofp, &node);
4336 vat_json_free (&node);
4338 vam->retval = ntohl (mp->retval);
4339 vam->result_ready = 1;
4343 vl_api_show_one_use_petr_reply_t_handler
4344 (vl_api_show_one_use_petr_reply_t * mp)
4346 vat_main_t *vam = &vat_main;
4347 i32 retval = ntohl (mp->retval);
4351 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
4354 print (vam->ofp, "Proxy-ETR address; %U",
4355 mp->is_ip4 ? format_ip4_address : format_ip6_address,
4360 vam->retval = retval;
4361 vam->result_ready = 1;
4365 vl_api_show_one_use_petr_reply_t_handler_json
4366 (vl_api_show_one_use_petr_reply_t * mp)
4368 vat_main_t *vam = &vat_main;
4369 vat_json_node_t node;
4372 struct in6_addr ip6;
4374 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4375 vec_add1 (status, 0);
4377 vat_json_init_object (&node);
4378 vat_json_object_add_string_copy (&node, "status", status);
4383 clib_memcpy (&ip6, mp->address, sizeof (ip6));
4384 vat_json_object_add_ip6 (&node, "address", ip6);
4388 clib_memcpy (&ip4, mp->address, sizeof (ip4));
4389 vat_json_object_add_ip4 (&node, "address", ip4);
4395 vat_json_print (vam->ofp, &node);
4396 vat_json_free (&node);
4398 vam->retval = ntohl (mp->retval);
4399 vam->result_ready = 1;
4403 vl_api_show_one_nsh_mapping_reply_t_handler
4404 (vl_api_show_one_nsh_mapping_reply_t * mp)
4406 vat_main_t *vam = &vat_main;
4407 i32 retval = ntohl (mp->retval);
4411 print (vam->ofp, "%-20s%-16s",
4412 mp->is_set ? "set" : "not-set",
4413 mp->is_set ? (char *) mp->locator_set_name : "");
4416 vam->retval = retval;
4417 vam->result_ready = 1;
4421 vl_api_show_one_nsh_mapping_reply_t_handler_json
4422 (vl_api_show_one_nsh_mapping_reply_t * mp)
4424 vat_main_t *vam = &vat_main;
4425 vat_json_node_t node;
4428 status = format (0, "%s", mp->is_set ? "yes" : "no");
4429 vec_add1 (status, 0);
4431 vat_json_init_object (&node);
4432 vat_json_object_add_string_copy (&node, "is_set", status);
4435 vat_json_object_add_string_copy (&node, "locator_set",
4436 mp->locator_set_name);
4441 vat_json_print (vam->ofp, &node);
4442 vat_json_free (&node);
4444 vam->retval = ntohl (mp->retval);
4445 vam->result_ready = 1;
4449 vl_api_show_one_map_register_ttl_reply_t_handler
4450 (vl_api_show_one_map_register_ttl_reply_t * mp)
4452 vat_main_t *vam = &vat_main;
4453 i32 retval = ntohl (mp->retval);
4455 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4459 print (vam->ofp, "ttl: %u", mp->ttl);
4462 vam->retval = retval;
4463 vam->result_ready = 1;
4467 vl_api_show_one_map_register_ttl_reply_t_handler_json
4468 (vl_api_show_one_map_register_ttl_reply_t * mp)
4470 vat_main_t *vam = &vat_main;
4471 vat_json_node_t node;
4473 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4474 vat_json_init_object (&node);
4475 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4477 vat_json_print (vam->ofp, &node);
4478 vat_json_free (&node);
4480 vam->retval = ntohl (mp->retval);
4481 vam->result_ready = 1;
4485 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4487 vat_main_t *vam = &vat_main;
4488 i32 retval = ntohl (mp->retval);
4492 print (vam->ofp, "%-20s%-16s",
4493 mp->status ? "enabled" : "disabled",
4494 mp->status ? (char *) mp->locator_set_name : "");
4497 vam->retval = retval;
4498 vam->result_ready = 1;
4502 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4504 vat_main_t *vam = &vat_main;
4505 vat_json_node_t node;
4508 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4509 vec_add1 (status, 0);
4511 vat_json_init_object (&node);
4512 vat_json_object_add_string_copy (&node, "status", status);
4515 vat_json_object_add_string_copy (&node, "locator_set",
4516 mp->locator_set_name);
4521 vat_json_print (vam->ofp, &node);
4522 vat_json_free (&node);
4524 vam->retval = ntohl (mp->retval);
4525 vam->result_ready = 1;
4529 format_policer_type (u8 * s, va_list * va)
4531 u32 i = va_arg (*va, u32);
4533 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4534 s = format (s, "1r2c");
4535 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4536 s = format (s, "1r3c");
4537 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4538 s = format (s, "2r3c-2698");
4539 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4540 s = format (s, "2r3c-4115");
4541 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4542 s = format (s, "2r3c-mef5cf1");
4544 s = format (s, "ILLEGAL");
4549 format_policer_rate_type (u8 * s, va_list * va)
4551 u32 i = va_arg (*va, u32);
4553 if (i == SSE2_QOS_RATE_KBPS)
4554 s = format (s, "kbps");
4555 else if (i == SSE2_QOS_RATE_PPS)
4556 s = format (s, "pps");
4558 s = format (s, "ILLEGAL");
4563 format_policer_round_type (u8 * s, va_list * va)
4565 u32 i = va_arg (*va, u32);
4567 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4568 s = format (s, "closest");
4569 else if (i == SSE2_QOS_ROUND_TO_UP)
4570 s = format (s, "up");
4571 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4572 s = format (s, "down");
4574 s = format (s, "ILLEGAL");
4579 format_policer_action_type (u8 * s, va_list * va)
4581 u32 i = va_arg (*va, u32);
4583 if (i == SSE2_QOS_ACTION_DROP)
4584 s = format (s, "drop");
4585 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4586 s = format (s, "transmit");
4587 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4588 s = format (s, "mark-and-transmit");
4590 s = format (s, "ILLEGAL");
4595 format_dscp (u8 * s, va_list * va)
4597 u32 i = va_arg (*va, u32);
4602 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4606 return format (s, "ILLEGAL");
4608 s = format (s, "%s", t);
4613 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4615 vat_main_t *vam = &vat_main;
4616 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4618 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4619 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4621 conform_dscp_str = format (0, "");
4623 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4624 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4626 exceed_dscp_str = format (0, "");
4628 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4629 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4631 violate_dscp_str = format (0, "");
4633 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4634 "rate type %U, round type %U, %s rate, %s color-aware, "
4635 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4636 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4637 "conform action %U%s, exceed action %U%s, violate action %U%s",
4639 format_policer_type, mp->type,
4642 clib_net_to_host_u64 (mp->cb),
4643 clib_net_to_host_u64 (mp->eb),
4644 format_policer_rate_type, mp->rate_type,
4645 format_policer_round_type, mp->round_type,
4646 mp->single_rate ? "single" : "dual",
4647 mp->color_aware ? "is" : "not",
4648 ntohl (mp->cir_tokens_per_period),
4649 ntohl (mp->pir_tokens_per_period),
4651 ntohl (mp->current_limit),
4652 ntohl (mp->current_bucket),
4653 ntohl (mp->extended_limit),
4654 ntohl (mp->extended_bucket),
4655 clib_net_to_host_u64 (mp->last_update_time),
4656 format_policer_action_type, mp->conform_action_type,
4658 format_policer_action_type, mp->exceed_action_type,
4660 format_policer_action_type, mp->violate_action_type,
4663 vec_free (conform_dscp_str);
4664 vec_free (exceed_dscp_str);
4665 vec_free (violate_dscp_str);
4668 static void vl_api_policer_details_t_handler_json
4669 (vl_api_policer_details_t * mp)
4671 vat_main_t *vam = &vat_main;
4672 vat_json_node_t *node;
4673 u8 *rate_type_str, *round_type_str, *type_str;
4674 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4676 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4678 format (0, "%U", format_policer_round_type, mp->round_type);
4679 type_str = format (0, "%U", format_policer_type, mp->type);
4680 conform_action_str = format (0, "%U", format_policer_action_type,
4681 mp->conform_action_type);
4682 exceed_action_str = format (0, "%U", format_policer_action_type,
4683 mp->exceed_action_type);
4684 violate_action_str = format (0, "%U", format_policer_action_type,
4685 mp->violate_action_type);
4687 if (VAT_JSON_ARRAY != vam->json_tree.type)
4689 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4690 vat_json_init_array (&vam->json_tree);
4692 node = vat_json_array_add (&vam->json_tree);
4694 vat_json_init_object (node);
4695 vat_json_object_add_string_copy (node, "name", mp->name);
4696 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4697 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4698 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4699 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4700 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4701 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4702 vat_json_object_add_string_copy (node, "type", type_str);
4703 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4704 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4705 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4706 vat_json_object_add_uint (node, "cir_tokens_per_period",
4707 ntohl (mp->cir_tokens_per_period));
4708 vat_json_object_add_uint (node, "eir_tokens_per_period",
4709 ntohl (mp->pir_tokens_per_period));
4710 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4711 vat_json_object_add_uint (node, "current_bucket",
4712 ntohl (mp->current_bucket));
4713 vat_json_object_add_uint (node, "extended_limit",
4714 ntohl (mp->extended_limit));
4715 vat_json_object_add_uint (node, "extended_bucket",
4716 ntohl (mp->extended_bucket));
4717 vat_json_object_add_uint (node, "last_update_time",
4718 ntohl (mp->last_update_time));
4719 vat_json_object_add_string_copy (node, "conform_action",
4720 conform_action_str);
4721 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4723 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4724 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4725 vec_free (dscp_str);
4727 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4728 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4730 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4731 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4732 vec_free (dscp_str);
4734 vat_json_object_add_string_copy (node, "violate_action",
4735 violate_action_str);
4736 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4738 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4739 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4740 vec_free (dscp_str);
4743 vec_free (rate_type_str);
4744 vec_free (round_type_str);
4745 vec_free (type_str);
4746 vec_free (conform_action_str);
4747 vec_free (exceed_action_str);
4748 vec_free (violate_action_str);
4752 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4755 vat_main_t *vam = &vat_main;
4756 int i, count = ntohl (mp->count);
4759 print (vam->ofp, "classify table ids (%d) : ", count);
4760 for (i = 0; i < count; i++)
4762 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4763 print (vam->ofp, (i < count - 1) ? "," : "");
4765 vam->retval = ntohl (mp->retval);
4766 vam->result_ready = 1;
4770 vl_api_classify_table_ids_reply_t_handler_json
4771 (vl_api_classify_table_ids_reply_t * mp)
4773 vat_main_t *vam = &vat_main;
4774 int i, count = ntohl (mp->count);
4778 vat_json_node_t node;
4780 vat_json_init_object (&node);
4781 for (i = 0; i < count; i++)
4783 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4785 vat_json_print (vam->ofp, &node);
4786 vat_json_free (&node);
4788 vam->retval = ntohl (mp->retval);
4789 vam->result_ready = 1;
4793 vl_api_classify_table_by_interface_reply_t_handler
4794 (vl_api_classify_table_by_interface_reply_t * mp)
4796 vat_main_t *vam = &vat_main;
4799 table_id = ntohl (mp->l2_table_id);
4801 print (vam->ofp, "l2 table id : %d", table_id);
4803 print (vam->ofp, "l2 table id : No input ACL tables configured");
4804 table_id = ntohl (mp->ip4_table_id);
4806 print (vam->ofp, "ip4 table id : %d", table_id);
4808 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4809 table_id = ntohl (mp->ip6_table_id);
4811 print (vam->ofp, "ip6 table id : %d", table_id);
4813 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4814 vam->retval = ntohl (mp->retval);
4815 vam->result_ready = 1;
4819 vl_api_classify_table_by_interface_reply_t_handler_json
4820 (vl_api_classify_table_by_interface_reply_t * mp)
4822 vat_main_t *vam = &vat_main;
4823 vat_json_node_t node;
4825 vat_json_init_object (&node);
4827 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4828 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4829 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4831 vat_json_print (vam->ofp, &node);
4832 vat_json_free (&node);
4834 vam->retval = ntohl (mp->retval);
4835 vam->result_ready = 1;
4838 static void vl_api_policer_add_del_reply_t_handler
4839 (vl_api_policer_add_del_reply_t * mp)
4841 vat_main_t *vam = &vat_main;
4842 i32 retval = ntohl (mp->retval);
4843 if (vam->async_mode)
4845 vam->async_errors += (retval < 0);
4849 vam->retval = retval;
4850 vam->result_ready = 1;
4851 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4853 * Note: this is just barely thread-safe, depends on
4854 * the main thread spinning waiting for an answer...
4856 errmsg ("policer index %d", ntohl (mp->policer_index));
4860 static void vl_api_policer_add_del_reply_t_handler_json
4861 (vl_api_policer_add_del_reply_t * mp)
4863 vat_main_t *vam = &vat_main;
4864 vat_json_node_t node;
4866 vat_json_init_object (&node);
4867 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4868 vat_json_object_add_uint (&node, "policer_index",
4869 ntohl (mp->policer_index));
4871 vat_json_print (vam->ofp, &node);
4872 vat_json_free (&node);
4874 vam->retval = ntohl (mp->retval);
4875 vam->result_ready = 1;
4878 /* Format hex dump. */
4880 format_hex_bytes (u8 * s, va_list * va)
4882 u8 *bytes = va_arg (*va, u8 *);
4883 int n_bytes = va_arg (*va, int);
4886 /* Print short or long form depending on byte count. */
4887 uword short_form = n_bytes <= 32;
4888 u32 indent = format_get_indent (s);
4893 for (i = 0; i < n_bytes; i++)
4895 if (!short_form && (i % 32) == 0)
4896 s = format (s, "%08x: ", i);
4897 s = format (s, "%02x", bytes[i]);
4898 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4899 s = format (s, "\n%U", format_white_space, indent);
4906 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4909 vat_main_t *vam = &vat_main;
4910 i32 retval = ntohl (mp->retval);
4913 print (vam->ofp, "classify table info :");
4914 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4915 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4916 ntohl (mp->miss_next_index));
4917 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4918 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4919 ntohl (mp->match_n_vectors));
4920 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4921 ntohl (mp->mask_length));
4923 vam->retval = retval;
4924 vam->result_ready = 1;
4928 vl_api_classify_table_info_reply_t_handler_json
4929 (vl_api_classify_table_info_reply_t * mp)
4931 vat_main_t *vam = &vat_main;
4932 vat_json_node_t node;
4934 i32 retval = ntohl (mp->retval);
4937 vat_json_init_object (&node);
4939 vat_json_object_add_int (&node, "sessions",
4940 ntohl (mp->active_sessions));
4941 vat_json_object_add_int (&node, "nexttbl",
4942 ntohl (mp->next_table_index));
4943 vat_json_object_add_int (&node, "nextnode",
4944 ntohl (mp->miss_next_index));
4945 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4946 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4947 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4948 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4949 ntohl (mp->mask_length), 0);
4950 vat_json_object_add_string_copy (&node, "mask", s);
4952 vat_json_print (vam->ofp, &node);
4953 vat_json_free (&node);
4955 vam->retval = ntohl (mp->retval);
4956 vam->result_ready = 1;
4960 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4963 vat_main_t *vam = &vat_main;
4965 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4966 ntohl (mp->hit_next_index), ntohl (mp->advance),
4967 ntohl (mp->opaque_index));
4968 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4969 ntohl (mp->match_length));
4973 vl_api_classify_session_details_t_handler_json
4974 (vl_api_classify_session_details_t * mp)
4976 vat_main_t *vam = &vat_main;
4977 vat_json_node_t *node = NULL;
4979 if (VAT_JSON_ARRAY != vam->json_tree.type)
4981 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4982 vat_json_init_array (&vam->json_tree);
4984 node = vat_json_array_add (&vam->json_tree);
4986 vat_json_init_object (node);
4987 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4988 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4989 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4991 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4993 vat_json_object_add_string_copy (node, "match", s);
4996 static void vl_api_pg_create_interface_reply_t_handler
4997 (vl_api_pg_create_interface_reply_t * mp)
4999 vat_main_t *vam = &vat_main;
5001 vam->retval = ntohl (mp->retval);
5002 vam->result_ready = 1;
5005 static void vl_api_pg_create_interface_reply_t_handler_json
5006 (vl_api_pg_create_interface_reply_t * mp)
5008 vat_main_t *vam = &vat_main;
5009 vat_json_node_t node;
5011 i32 retval = ntohl (mp->retval);
5014 vat_json_init_object (&node);
5016 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
5018 vat_json_print (vam->ofp, &node);
5019 vat_json_free (&node);
5021 vam->retval = ntohl (mp->retval);
5022 vam->result_ready = 1;
5025 static void vl_api_policer_classify_details_t_handler
5026 (vl_api_policer_classify_details_t * mp)
5028 vat_main_t *vam = &vat_main;
5030 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5031 ntohl (mp->table_index));
5034 static void vl_api_policer_classify_details_t_handler_json
5035 (vl_api_policer_classify_details_t * mp)
5037 vat_main_t *vam = &vat_main;
5038 vat_json_node_t *node;
5040 if (VAT_JSON_ARRAY != vam->json_tree.type)
5042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5043 vat_json_init_array (&vam->json_tree);
5045 node = vat_json_array_add (&vam->json_tree);
5047 vat_json_init_object (node);
5048 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5049 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5052 static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler
5053 (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
5055 vat_main_t *vam = &vat_main;
5056 i32 retval = ntohl (mp->retval);
5057 if (vam->async_mode)
5059 vam->async_errors += (retval < 0);
5063 vam->retval = retval;
5064 vam->sw_if_index = ntohl (mp->sw_if_index);
5065 vam->result_ready = 1;
5067 vam->regenerate_interface_table = 1;
5070 static void vl_api_ipsec_gre_tunnel_add_del_reply_t_handler_json
5071 (vl_api_ipsec_gre_tunnel_add_del_reply_t * mp)
5073 vat_main_t *vam = &vat_main;
5074 vat_json_node_t node;
5076 vat_json_init_object (&node);
5077 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5078 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
5080 vat_json_print (vam->ofp, &node);
5081 vat_json_free (&node);
5083 vam->retval = ntohl (mp->retval);
5084 vam->result_ready = 1;
5087 static void vl_api_flow_classify_details_t_handler
5088 (vl_api_flow_classify_details_t * mp)
5090 vat_main_t *vam = &vat_main;
5092 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
5093 ntohl (mp->table_index));
5096 static void vl_api_flow_classify_details_t_handler_json
5097 (vl_api_flow_classify_details_t * mp)
5099 vat_main_t *vam = &vat_main;
5100 vat_json_node_t *node;
5102 if (VAT_JSON_ARRAY != vam->json_tree.type)
5104 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
5105 vat_json_init_array (&vam->json_tree);
5107 node = vat_json_array_add (&vam->json_tree);
5109 vat_json_init_object (node);
5110 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
5111 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
5114 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
5115 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
5116 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
5117 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
5118 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
5119 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
5120 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
5121 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
5122 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
5123 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
5126 * Generate boilerplate reply handlers, which
5127 * dig the return value out of the xxx_reply_t API message,
5128 * stick it into vam->retval, and set vam->result_ready
5130 * Could also do this by pointing N message decode slots at
5131 * a single function, but that could break in subtle ways.
5134 #define foreach_standard_reply_retval_handler \
5135 _(sw_interface_set_flags_reply) \
5136 _(sw_interface_add_del_address_reply) \
5137 _(sw_interface_set_rx_mode_reply) \
5138 _(sw_interface_set_rx_placement_reply) \
5139 _(sw_interface_set_table_reply) \
5140 _(sw_interface_set_mpls_enable_reply) \
5141 _(sw_interface_set_vpath_reply) \
5142 _(sw_interface_set_vxlan_bypass_reply) \
5143 _(sw_interface_set_geneve_bypass_reply) \
5144 _(sw_interface_set_vxlan_gpe_bypass_reply) \
5145 _(sw_interface_set_l2_bridge_reply) \
5146 _(bridge_domain_add_del_reply) \
5147 _(sw_interface_set_l2_xconnect_reply) \
5148 _(l2fib_add_del_reply) \
5149 _(l2fib_flush_int_reply) \
5150 _(l2fib_flush_bd_reply) \
5151 _(ip_add_del_route_reply) \
5152 _(ip_table_add_del_reply) \
5153 _(ip_mroute_add_del_reply) \
5154 _(mpls_route_add_del_reply) \
5155 _(mpls_table_add_del_reply) \
5156 _(mpls_ip_bind_unbind_reply) \
5157 _(bier_route_add_del_reply) \
5158 _(bier_table_add_del_reply) \
5159 _(proxy_arp_add_del_reply) \
5160 _(proxy_arp_intfc_enable_disable_reply) \
5161 _(sw_interface_set_unnumbered_reply) \
5162 _(ip_neighbor_add_del_reply) \
5163 _(oam_add_del_reply) \
5164 _(reset_fib_reply) \
5165 _(dhcp_proxy_config_reply) \
5166 _(dhcp_proxy_set_vss_reply) \
5167 _(dhcp_client_config_reply) \
5168 _(set_ip_flow_hash_reply) \
5169 _(sw_interface_ip6_enable_disable_reply) \
5170 _(ip6nd_proxy_add_del_reply) \
5171 _(sw_interface_ip6nd_ra_prefix_reply) \
5172 _(sw_interface_ip6nd_ra_config_reply) \
5173 _(set_arp_neighbor_limit_reply) \
5174 _(l2_patch_add_del_reply) \
5175 _(sr_mpls_policy_add_reply) \
5176 _(sr_mpls_policy_mod_reply) \
5177 _(sr_mpls_policy_del_reply) \
5178 _(sr_policy_add_reply) \
5179 _(sr_policy_mod_reply) \
5180 _(sr_policy_del_reply) \
5181 _(sr_localsid_add_del_reply) \
5182 _(sr_steering_add_del_reply) \
5183 _(classify_add_del_session_reply) \
5184 _(classify_set_interface_ip_table_reply) \
5185 _(classify_set_interface_l2_tables_reply) \
5186 _(l2tpv3_set_tunnel_cookies_reply) \
5187 _(l2tpv3_interface_enable_disable_reply) \
5188 _(l2tpv3_set_lookup_key_reply) \
5189 _(l2_fib_clear_table_reply) \
5190 _(l2_interface_efp_filter_reply) \
5191 _(l2_interface_vlan_tag_rewrite_reply) \
5192 _(modify_vhost_user_if_reply) \
5193 _(delete_vhost_user_if_reply) \
5194 _(ip_probe_neighbor_reply) \
5195 _(ip_scan_neighbor_enable_disable_reply) \
5196 _(want_ip4_arp_events_reply) \
5197 _(want_ip6_nd_events_reply) \
5198 _(want_l2_macs_events_reply) \
5199 _(input_acl_set_interface_reply) \
5200 _(ipsec_spd_add_del_reply) \
5201 _(ipsec_interface_add_del_spd_reply) \
5202 _(ipsec_spd_entry_add_del_reply) \
5203 _(ipsec_sad_entry_add_del_reply) \
5204 _(ipsec_sa_set_key_reply) \
5205 _(ipsec_tunnel_if_add_del_reply) \
5206 _(ipsec_tunnel_if_set_key_reply) \
5207 _(ipsec_tunnel_if_set_sa_reply) \
5208 _(delete_loopback_reply) \
5209 _(bd_ip_mac_add_del_reply) \
5210 _(bd_ip_mac_flush_reply) \
5211 _(want_interface_events_reply) \
5212 _(cop_interface_enable_disable_reply) \
5213 _(cop_whitelist_enable_disable_reply) \
5214 _(sw_interface_clear_stats_reply) \
5215 _(ioam_enable_reply) \
5216 _(ioam_disable_reply) \
5217 _(one_add_del_locator_reply) \
5218 _(one_add_del_local_eid_reply) \
5219 _(one_add_del_remote_mapping_reply) \
5220 _(one_add_del_adjacency_reply) \
5221 _(one_add_del_map_resolver_reply) \
5222 _(one_add_del_map_server_reply) \
5223 _(one_enable_disable_reply) \
5224 _(one_rloc_probe_enable_disable_reply) \
5225 _(one_map_register_enable_disable_reply) \
5226 _(one_map_register_set_ttl_reply) \
5227 _(one_set_transport_protocol_reply) \
5228 _(one_map_register_fallback_threshold_reply) \
5229 _(one_pitr_set_locator_set_reply) \
5230 _(one_map_request_mode_reply) \
5231 _(one_add_del_map_request_itr_rlocs_reply) \
5232 _(one_eid_table_add_del_map_reply) \
5233 _(one_use_petr_reply) \
5234 _(one_stats_enable_disable_reply) \
5235 _(one_add_del_l2_arp_entry_reply) \
5236 _(one_add_del_ndp_entry_reply) \
5237 _(one_stats_flush_reply) \
5238 _(one_enable_disable_xtr_mode_reply) \
5239 _(one_enable_disable_pitr_mode_reply) \
5240 _(one_enable_disable_petr_mode_reply) \
5241 _(gpe_enable_disable_reply) \
5242 _(gpe_set_encap_mode_reply) \
5243 _(gpe_add_del_iface_reply) \
5244 _(gpe_add_del_native_fwd_rpath_reply) \
5245 _(af_packet_delete_reply) \
5246 _(policer_classify_set_interface_reply) \
5247 _(netmap_create_reply) \
5248 _(netmap_delete_reply) \
5249 _(set_ipfix_exporter_reply) \
5250 _(set_ipfix_classify_stream_reply) \
5251 _(ipfix_classify_table_add_del_reply) \
5252 _(flow_classify_set_interface_reply) \
5253 _(sw_interface_span_enable_disable_reply) \
5254 _(pg_capture_reply) \
5255 _(pg_enable_disable_reply) \
5256 _(ip_source_and_port_range_check_add_del_reply) \
5257 _(ip_source_and_port_range_check_interface_add_del_reply)\
5258 _(delete_subif_reply) \
5259 _(l2_interface_pbb_tag_rewrite_reply) \
5261 _(feature_enable_disable_reply) \
5262 _(sw_interface_tag_add_del_reply) \
5263 _(hw_interface_set_mtu_reply) \
5264 _(p2p_ethernet_add_reply) \
5265 _(p2p_ethernet_del_reply) \
5266 _(lldp_config_reply) \
5267 _(sw_interface_set_lldp_reply) \
5268 _(tcp_configure_src_addresses_reply) \
5269 _(dns_enable_disable_reply) \
5270 _(dns_name_server_add_del_reply) \
5271 _(session_rule_add_del_reply) \
5272 _(ip_container_proxy_add_del_reply) \
5273 _(output_acl_set_interface_reply) \
5274 _(qos_record_enable_disable_reply)
5277 static void vl_api_##n##_t_handler \
5278 (vl_api_##n##_t * mp) \
5280 vat_main_t * vam = &vat_main; \
5281 i32 retval = ntohl(mp->retval); \
5282 if (vam->async_mode) { \
5283 vam->async_errors += (retval < 0); \
5285 vam->retval = retval; \
5286 vam->result_ready = 1; \
5289 foreach_standard_reply_retval_handler;
5293 static void vl_api_##n##_t_handler_json \
5294 (vl_api_##n##_t * mp) \
5296 vat_main_t * vam = &vat_main; \
5297 vat_json_node_t node; \
5298 vat_json_init_object(&node); \
5299 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
5300 vat_json_print(vam->ofp, &node); \
5301 vam->retval = ntohl(mp->retval); \
5302 vam->result_ready = 1; \
5304 foreach_standard_reply_retval_handler;
5308 * Table of message reply handlers, must include boilerplate handlers
5312 #define foreach_vpe_api_reply_msg \
5313 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
5314 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
5315 _(SW_INTERFACE_DETAILS, sw_interface_details) \
5316 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
5317 _(CONTROL_PING_REPLY, control_ping_reply) \
5318 _(CLI_REPLY, cli_reply) \
5319 _(CLI_INBAND_REPLY, cli_inband_reply) \
5320 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
5321 sw_interface_add_del_address_reply) \
5322 _(SW_INTERFACE_SET_RX_MODE_REPLY, sw_interface_set_rx_mode_reply) \
5323 _(SW_INTERFACE_SET_RX_PLACEMENT_REPLY, sw_interface_set_rx_placement_reply) \
5324 _(SW_INTERFACE_RX_PLACEMENT_DETAILS, sw_interface_rx_placement_details) \
5325 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
5326 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
5327 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
5328 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
5329 _(SW_INTERFACE_SET_GENEVE_BYPASS_REPLY, sw_interface_set_geneve_bypass_reply) \
5330 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
5331 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
5332 sw_interface_set_l2_xconnect_reply) \
5333 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
5334 sw_interface_set_l2_bridge_reply) \
5335 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
5336 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
5337 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
5338 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
5339 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
5340 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
5341 _(L2_FLAGS_REPLY, l2_flags_reply) \
5342 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
5343 _(TAP_CREATE_V2_REPLY, tap_create_v2_reply) \
5344 _(TAP_DELETE_V2_REPLY, tap_delete_v2_reply) \
5345 _(SW_INTERFACE_TAP_V2_DETAILS, sw_interface_tap_v2_details) \
5346 _(VIRTIO_PCI_CREATE_REPLY, virtio_pci_create_reply) \
5347 _(VIRTIO_PCI_DELETE_REPLY, virtio_pci_delete_reply) \
5348 _(SW_INTERFACE_VIRTIO_PCI_DETAILS, sw_interface_virtio_pci_details) \
5349 _(BOND_CREATE_REPLY, bond_create_reply) \
5350 _(BOND_DELETE_REPLY, bond_delete_reply) \
5351 _(BOND_ENSLAVE_REPLY, bond_enslave_reply) \
5352 _(BOND_DETACH_SLAVE_REPLY, bond_detach_slave_reply) \
5353 _(SW_INTERFACE_BOND_DETAILS, sw_interface_bond_details) \
5354 _(SW_INTERFACE_SLAVE_DETAILS, sw_interface_slave_details) \
5355 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
5356 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
5357 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
5358 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
5359 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
5360 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
5361 _(BIER_ROUTE_ADD_DEL_REPLY, bier_route_add_del_reply) \
5362 _(BIER_TABLE_ADD_DEL_REPLY, bier_table_add_del_reply) \
5363 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
5364 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
5365 proxy_arp_intfc_enable_disable_reply) \
5366 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
5367 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
5368 sw_interface_set_unnumbered_reply) \
5369 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
5370 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
5371 _(CREATE_SUBIF_REPLY, create_subif_reply) \
5372 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
5373 _(RESET_FIB_REPLY, reset_fib_reply) \
5374 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
5375 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
5376 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
5377 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
5378 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
5379 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
5380 sw_interface_ip6_enable_disable_reply) \
5381 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
5382 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
5383 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
5384 sw_interface_ip6nd_ra_prefix_reply) \
5385 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
5386 sw_interface_ip6nd_ra_config_reply) \
5387 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
5388 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
5389 _(SR_MPLS_POLICY_ADD_REPLY, sr_mpls_policy_add_reply) \
5390 _(SR_MPLS_POLICY_MOD_REPLY, sr_mpls_policy_mod_reply) \
5391 _(SR_MPLS_POLICY_DEL_REPLY, sr_mpls_policy_del_reply) \
5392 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
5393 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
5394 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
5395 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
5396 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
5397 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
5398 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
5399 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
5400 classify_set_interface_ip_table_reply) \
5401 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
5402 classify_set_interface_l2_tables_reply) \
5403 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
5404 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
5405 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
5406 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
5407 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
5408 l2tpv3_interface_enable_disable_reply) \
5409 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
5410 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
5411 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
5412 _(VXLAN_OFFLOAD_RX_REPLY, vxlan_offload_rx_reply) \
5413 _(GENEVE_ADD_DEL_TUNNEL_REPLY, geneve_add_del_tunnel_reply) \
5414 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
5415 _(GENEVE_TUNNEL_DETAILS, geneve_tunnel_details) \
5416 _(GRE_TUNNEL_ADD_DEL_REPLY, gre_tunnel_add_del_reply) \
5417 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
5418 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
5419 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
5420 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
5421 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
5422 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
5423 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
5424 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
5425 _(SHOW_VERSION_REPLY, show_version_reply) \
5426 _(SHOW_THREADS_REPLY, show_threads_reply) \
5427 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
5428 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
5429 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
5430 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
5431 _(IP_PROBE_NEIGHBOR_REPLY, ip_probe_neighbor_reply) \
5432 _(IP_SCAN_NEIGHBOR_ENABLE_DISABLE_REPLY, ip_scan_neighbor_enable_disable_reply) \
5433 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
5434 _(IP4_ARP_EVENT, ip4_arp_event) \
5435 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5436 _(IP6_ND_EVENT, ip6_nd_event) \
5437 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5438 _(L2_MACS_EVENT, l2_macs_event) \
5439 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5440 _(IP_ADDRESS_DETAILS, ip_address_details) \
5441 _(IP_DETAILS, ip_details) \
5442 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5443 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5444 _(IPSEC_SPD_ENTRY_ADD_DEL_REPLY, ipsec_spd_entry_add_del_reply) \
5445 _(IPSEC_SAD_ENTRY_ADD_DEL_REPLY, ipsec_sad_entry_add_del_reply) \
5446 _(IPSEC_SA_DETAILS, ipsec_sa_details) \
5447 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5448 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5449 _(IPSEC_TUNNEL_IF_SET_KEY_REPLY, ipsec_tunnel_if_set_key_reply) \
5450 _(IPSEC_TUNNEL_IF_SET_SA_REPLY, ipsec_tunnel_if_set_sa_reply) \
5451 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5452 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5453 _(BD_IP_MAC_FLUSH_REPLY, bd_ip_mac_flush_reply) \
5454 _(BD_IP_MAC_DETAILS, bd_ip_mac_details) \
5455 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5456 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5457 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5458 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5459 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5460 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5461 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5462 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5463 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5464 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5465 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5466 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5467 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5468 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5469 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5470 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5471 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5472 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5473 one_map_register_enable_disable_reply) \
5474 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5475 _(ONE_SET_TRANSPORT_PROTOCOL_REPLY, one_set_transport_protocol_reply) \
5476 _(ONE_GET_TRANSPORT_PROTOCOL_REPLY, one_get_transport_protocol_reply) \
5477 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5478 one_map_register_fallback_threshold_reply) \
5479 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5480 one_rloc_probe_enable_disable_reply) \
5481 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5482 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5483 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5484 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5485 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5486 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5487 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5488 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5489 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5490 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5491 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5492 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5493 _(ONE_STATS_DETAILS, one_stats_details) \
5494 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5495 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5496 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5497 show_one_stats_enable_disable_reply) \
5498 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5499 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5500 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5501 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5502 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5503 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5504 _(ONE_ENABLE_DISABLE_XTR_MODE_REPLY, one_enable_disable_xtr_mode_reply) \
5505 _(ONE_ENABLE_DISABLE_PITR_MODE_REPLY, \
5506 one_enable_disable_pitr_mode_reply) \
5507 _(ONE_ENABLE_DISABLE_PETR_MODE_REPLY, \
5508 one_enable_disable_petr_mode_reply) \
5509 _(ONE_SHOW_XTR_MODE_REPLY, one_show_xtr_mode_reply) \
5510 _(ONE_SHOW_PITR_MODE_REPLY, one_show_pitr_mode_reply) \
5511 _(ONE_SHOW_PETR_MODE_REPLY, one_show_petr_mode_reply) \
5512 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5513 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5514 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5515 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5516 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5517 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5518 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5519 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5520 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5521 gpe_add_del_native_fwd_rpath_reply) \
5522 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5523 gpe_fwd_entry_path_details) \
5524 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5525 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5526 one_add_del_map_request_itr_rlocs_reply) \
5527 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5528 one_get_map_request_itr_rlocs_reply) \
5529 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5530 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5531 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5532 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5533 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5534 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5535 show_one_map_register_state_reply) \
5536 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5537 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5538 show_one_map_register_fallback_threshold_reply) \
5539 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5540 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5541 _(AF_PACKET_DETAILS, af_packet_details) \
5542 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5543 _(POLICER_DETAILS, policer_details) \
5544 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5545 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5546 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5547 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5548 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5549 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5550 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5551 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5552 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5553 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5554 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5555 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5556 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5557 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5558 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5559 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5560 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5561 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5562 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5563 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5564 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5565 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5566 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5567 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5568 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5569 ip_source_and_port_range_check_add_del_reply) \
5570 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5571 ip_source_and_port_range_check_interface_add_del_reply) \
5572 _(IPSEC_GRE_TUNNEL_ADD_DEL_REPLY, ipsec_gre_tunnel_add_del_reply) \
5573 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5574 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5575 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5576 _(SET_PUNT_REPLY, set_punt_reply) \
5577 _(IP_FIB_DETAILS, ip_fib_details) \
5578 _(IP6_FIB_DETAILS, ip6_fib_details) \
5579 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5580 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5581 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5582 _(HW_INTERFACE_SET_MTU_REPLY, hw_interface_set_mtu_reply) \
5583 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5584 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5585 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5586 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5587 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5588 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5589 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply) \
5590 _(APP_NAMESPACE_ADD_DEL_REPLY, app_namespace_add_del_reply) \
5591 _(DNS_ENABLE_DISABLE_REPLY, dns_enable_disable_reply) \
5592 _(DNS_NAME_SERVER_ADD_DEL_REPLY, dns_name_server_add_del_reply) \
5593 _(DNS_RESOLVE_NAME_REPLY, dns_resolve_name_reply) \
5594 _(DNS_RESOLVE_IP_REPLY, dns_resolve_ip_reply) \
5595 _(SESSION_RULE_ADD_DEL_REPLY, session_rule_add_del_reply) \
5596 _(SESSION_RULES_DETAILS, session_rules_details) \
5597 _(IP_CONTAINER_PROXY_ADD_DEL_REPLY, ip_container_proxy_add_del_reply) \
5598 _(OUTPUT_ACL_SET_INTERFACE_REPLY, output_acl_set_interface_reply) \
5599 _(QOS_RECORD_ENABLE_DISABLE_REPLY, qos_record_enable_disable_reply)
5601 #define foreach_standalone_reply_msg \
5602 _(SW_INTERFACE_EVENT, sw_interface_event)
5610 #define STR_VTR_OP_CASE(op) \
5611 case L2_VTR_ ## op: \
5615 str_vtr_op (u32 vtr_op)
5619 STR_VTR_OP_CASE (DISABLED);
5620 STR_VTR_OP_CASE (PUSH_1);
5621 STR_VTR_OP_CASE (PUSH_2);
5622 STR_VTR_OP_CASE (POP_1);
5623 STR_VTR_OP_CASE (POP_2);
5624 STR_VTR_OP_CASE (TRANSLATE_1_1);
5625 STR_VTR_OP_CASE (TRANSLATE_1_2);
5626 STR_VTR_OP_CASE (TRANSLATE_2_1);
5627 STR_VTR_OP_CASE (TRANSLATE_2_2);
5634 dump_sub_interface_table (vat_main_t * vam)
5636 const sw_interface_subif_t *sub = NULL;
5638 if (vam->json_output)
5641 ("JSON output supported only for VPE API calls and dump_stats_table");
5646 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5647 "Interface", "sw_if_index",
5648 "sub id", "dot1ad", "tags", "outer id",
5649 "inner id", "exact", "default", "outer any", "inner any");
5651 vec_foreach (sub, vam->sw_if_subif_table)
5654 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5655 sub->interface_name,
5657 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5658 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5659 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5660 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5661 if (sub->vtr_op != L2_VTR_DISABLED)
5664 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5665 "tag1: %d tag2: %d ]",
5666 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5667 sub->vtr_tag1, sub->vtr_tag2);
5675 name_sort_cmp (void *a1, void *a2)
5677 name_sort_t *n1 = a1;
5678 name_sort_t *n2 = a2;
5680 return strcmp ((char *) n1->name, (char *) n2->name);
5684 dump_interface_table (vat_main_t * vam)
5687 name_sort_t *nses = 0, *ns;
5689 if (vam->json_output)
5692 ("JSON output supported only for VPE API calls and dump_stats_table");
5697 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5699 vec_add2 (nses, ns, 1);
5700 ns->name = (u8 *)(p->key);
5701 ns->value = (u32) p->value[0];
5705 vec_sort_with_function (nses, name_sort_cmp);
5707 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5708 vec_foreach (ns, nses)
5710 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5717 dump_ip_table (vat_main_t * vam, int is_ipv6)
5719 const ip_details_t *det = NULL;
5720 const ip_address_details_t *address = NULL;
5723 print (vam->ofp, "%-12s", "sw_if_index");
5725 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5732 print (vam->ofp, "%-12d", i);
5733 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5738 vec_foreach (address, det->addr)
5742 is_ipv6 ? format_ip6_address : format_ip4_address,
5743 address->ip, address->prefix_length);
5751 dump_ipv4_table (vat_main_t * vam)
5753 if (vam->json_output)
5756 ("JSON output supported only for VPE API calls and dump_stats_table");
5760 return dump_ip_table (vam, 0);
5764 dump_ipv6_table (vat_main_t * vam)
5766 if (vam->json_output)
5769 ("JSON output supported only for VPE API calls and dump_stats_table");
5773 return dump_ip_table (vam, 1);
5777 * Pass CLI buffers directly in the CLI_INBAND API message,
5778 * instead of an additional shared memory area.
5781 exec_inband (vat_main_t * vam)
5783 vl_api_cli_inband_t *mp;
5784 unformat_input_t *i = vam->input;
5787 if (vec_len (i->buffer) == 0)
5790 if (vam->exec_mode == 0 && unformat (i, "mode"))
5795 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5802 * In order for the CLI command to work, it
5803 * must be a vector ending in \n, not a C-string ending
5806 u32 len = vec_len (vam->input->buffer);
5807 M2 (CLI_INBAND, mp, len);
5808 vl_api_to_api_string (len - 1, (const char *) vam->input->buffer, &mp->cmd);
5812 /* json responses may or may not include a useful reply... */
5813 if (vec_len (vam->cmd_reply))
5814 print (vam->ofp, "%v", (char *) (vam->cmd_reply));
5819 exec (vat_main_t * vam)
5821 return exec_inband (vam);
5825 api_create_loopback (vat_main_t * vam)
5827 unformat_input_t *i = vam->input;
5828 vl_api_create_loopback_t *mp;
5829 vl_api_create_loopback_instance_t *mp_lbi;
5832 u8 is_specified = 0;
5833 u32 user_instance = 0;
5836 clib_memset (mac_address, 0, sizeof (mac_address));
5838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5840 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5842 if (unformat (i, "instance %d", &user_instance))
5850 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5851 mp_lbi->is_specified = is_specified;
5853 mp_lbi->user_instance = htonl (user_instance);
5855 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5860 /* Construct the API message */
5861 M (CREATE_LOOPBACK, mp);
5863 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5872 api_delete_loopback (vat_main_t * vam)
5874 unformat_input_t *i = vam->input;
5875 vl_api_delete_loopback_t *mp;
5876 u32 sw_if_index = ~0;
5879 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5881 if (unformat (i, "sw_if_index %d", &sw_if_index))
5887 if (sw_if_index == ~0)
5889 errmsg ("missing sw_if_index");
5893 /* Construct the API message */
5894 M (DELETE_LOOPBACK, mp);
5895 mp->sw_if_index = ntohl (sw_if_index);
5903 api_want_interface_events (vat_main_t * vam)
5905 unformat_input_t *i = vam->input;
5906 vl_api_want_interface_events_t *mp;
5910 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5912 if (unformat (i, "enable"))
5914 else if (unformat (i, "disable"))
5922 errmsg ("missing enable|disable");
5926 M (WANT_INTERFACE_EVENTS, mp);
5927 mp->enable_disable = enable;
5929 vam->interface_event_display = enable;
5937 /* Note: non-static, called once to set up the initial intfc table */
5939 api_sw_interface_dump (vat_main_t * vam)
5941 vl_api_sw_interface_dump_t *mp;
5942 vl_api_control_ping_t *mp_ping;
5944 name_sort_t *nses = 0, *ns;
5945 sw_interface_subif_t *sub = NULL;
5948 /* Toss the old name table */
5950 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5952 vec_add2 (nses, ns, 1);
5953 ns->name = (u8 *)(p->key);
5954 ns->value = (u32) p->value[0];
5958 hash_free (vam->sw_if_index_by_interface_name);
5960 vec_foreach (ns, nses) vec_free (ns->name);
5964 vec_foreach (sub, vam->sw_if_subif_table)
5966 vec_free (sub->interface_name);
5968 vec_free (vam->sw_if_subif_table);
5970 /* recreate the interface name hash table */
5971 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5974 * Ask for all interface names. Otherwise, the epic catalog of
5975 * name filters becomes ridiculously long, and vat ends up needing
5976 * to be taught about new interface types.
5978 M (SW_INTERFACE_DUMP, mp);
5981 /* Use a control ping for synchronization */
5982 MPING (CONTROL_PING, mp_ping);
5990 api_sw_interface_set_flags (vat_main_t * vam)
5992 unformat_input_t *i = vam->input;
5993 vl_api_sw_interface_set_flags_t *mp;
5995 u8 sw_if_index_set = 0;
5999 /* Parse args required to build the message */
6000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6002 if (unformat (i, "admin-up"))
6004 else if (unformat (i, "admin-down"))
6007 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6008 sw_if_index_set = 1;
6009 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6010 sw_if_index_set = 1;
6015 if (sw_if_index_set == 0)
6017 errmsg ("missing interface name or sw_if_index");
6021 /* Construct the API message */
6022 M (SW_INTERFACE_SET_FLAGS, mp);
6023 mp->sw_if_index = ntohl (sw_if_index);
6024 mp->admin_up_down = admin_up;
6029 /* Wait for a reply, return the good/bad news... */
6035 api_sw_interface_set_rx_mode (vat_main_t * vam)
6037 unformat_input_t *i = vam->input;
6038 vl_api_sw_interface_set_rx_mode_t *mp;
6040 u8 sw_if_index_set = 0;
6042 u8 queue_id_valid = 0;
6044 vnet_hw_interface_rx_mode mode = VNET_HW_INTERFACE_RX_MODE_UNKNOWN;
6046 /* Parse args required to build the message */
6047 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6049 if (unformat (i, "queue %d", &queue_id))
6051 else if (unformat (i, "polling"))
6052 mode = VNET_HW_INTERFACE_RX_MODE_POLLING;
6053 else if (unformat (i, "interrupt"))
6054 mode = VNET_HW_INTERFACE_RX_MODE_INTERRUPT;
6055 else if (unformat (i, "adaptive"))
6056 mode = VNET_HW_INTERFACE_RX_MODE_ADAPTIVE;
6058 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6059 sw_if_index_set = 1;
6060 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6061 sw_if_index_set = 1;
6066 if (sw_if_index_set == 0)
6068 errmsg ("missing interface name or sw_if_index");
6071 if (mode == VNET_HW_INTERFACE_RX_MODE_UNKNOWN)
6073 errmsg ("missing rx-mode");
6077 /* Construct the API message */
6078 M (SW_INTERFACE_SET_RX_MODE, mp);
6079 mp->sw_if_index = ntohl (sw_if_index);
6081 mp->queue_id_valid = queue_id_valid;
6082 mp->queue_id = queue_id_valid ? ntohl (queue_id) : ~0;
6087 /* Wait for a reply, return the good/bad news... */
6093 api_sw_interface_set_rx_placement (vat_main_t * vam)
6095 unformat_input_t *i = vam->input;
6096 vl_api_sw_interface_set_rx_placement_t *mp;
6098 u8 sw_if_index_set = 0;
6101 u32 queue_id, thread_index;
6103 /* Parse args required to build the message */
6104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6106 if (unformat (i, "queue %d", &queue_id))
6108 else if (unformat (i, "main"))
6110 else if (unformat (i, "worker %d", &thread_index))
6113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6114 sw_if_index_set = 1;
6115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6116 sw_if_index_set = 1;
6121 if (sw_if_index_set == 0)
6123 errmsg ("missing interface name or sw_if_index");
6129 /* Construct the API message */
6130 M (SW_INTERFACE_SET_RX_PLACEMENT, mp);
6131 mp->sw_if_index = ntohl (sw_if_index);
6132 mp->worker_id = ntohl (thread_index);
6133 mp->queue_id = ntohl (queue_id);
6134 mp->is_main = is_main;
6138 /* Wait for a reply, return the good/bad news... */
6143 static void vl_api_sw_interface_rx_placement_details_t_handler
6144 (vl_api_sw_interface_rx_placement_details_t * mp)
6146 vat_main_t *vam = &vat_main;
6147 u32 worker_id = ntohl (mp->worker_id);
6150 "\n%-11d %-11s %-6d %-5d %-9s",
6151 ntohl (mp->sw_if_index), (worker_id == 0) ? "main" : "worker",
6152 worker_id, ntohl (mp->queue_id),
6154 1) ? "polling" : ((mp->mode == 2) ? "interrupt" : "adaptive"));
6157 static void vl_api_sw_interface_rx_placement_details_t_handler_json
6158 (vl_api_sw_interface_rx_placement_details_t * mp)
6160 vat_main_t *vam = &vat_main;
6161 vat_json_node_t *node = NULL;
6163 if (VAT_JSON_ARRAY != vam->json_tree.type)
6165 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
6166 vat_json_init_array (&vam->json_tree);
6168 node = vat_json_array_add (&vam->json_tree);
6170 vat_json_init_object (node);
6171 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
6172 vat_json_object_add_uint (node, "worker_id", ntohl (mp->worker_id));
6173 vat_json_object_add_uint (node, "queue_id", ntohl (mp->queue_id));
6174 vat_json_object_add_uint (node, "mode", mp->mode);
6178 api_sw_interface_rx_placement_dump (vat_main_t * vam)
6180 unformat_input_t *i = vam->input;
6181 vl_api_sw_interface_rx_placement_dump_t *mp;
6182 vl_api_control_ping_t *mp_ping;
6185 u8 sw_if_index_set = 0;
6187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6189 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6191 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6198 "\n%-11s %-11s %-6s %-5s %-4s",
6199 "sw_if_index", "main/worker", "thread", "queue", "mode");
6201 /* Dump Interface rx placement */
6202 M (SW_INTERFACE_RX_PLACEMENT_DUMP, mp);
6204 if (sw_if_index_set)
6205 mp->sw_if_index = htonl (sw_if_index);
6207 mp->sw_if_index = ~0;
6211 /* Use a control ping for synchronization */
6212 MPING (CONTROL_PING, mp_ping);
6220 api_sw_interface_clear_stats (vat_main_t * vam)
6222 unformat_input_t *i = vam->input;
6223 vl_api_sw_interface_clear_stats_t *mp;
6225 u8 sw_if_index_set = 0;
6228 /* Parse args required to build the message */
6229 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6231 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6232 sw_if_index_set = 1;
6233 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6234 sw_if_index_set = 1;
6239 /* Construct the API message */
6240 M (SW_INTERFACE_CLEAR_STATS, mp);
6242 if (sw_if_index_set == 1)
6243 mp->sw_if_index = ntohl (sw_if_index);
6245 mp->sw_if_index = ~0;
6250 /* Wait for a reply, return the good/bad news... */
6256 api_sw_interface_add_del_address (vat_main_t * vam)
6258 unformat_input_t *i = vam->input;
6259 vl_api_sw_interface_add_del_address_t *mp;
6261 u8 sw_if_index_set = 0;
6262 u8 is_add = 1, del_all = 0;
6263 u32 address_length = 0;
6264 u8 v4_address_set = 0;
6265 u8 v6_address_set = 0;
6266 ip4_address_t v4address;
6267 ip6_address_t v6address;
6270 /* Parse args required to build the message */
6271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6273 if (unformat (i, "del-all"))
6275 else if (unformat (i, "del"))
6278 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6279 sw_if_index_set = 1;
6280 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6281 sw_if_index_set = 1;
6282 else if (unformat (i, "%U/%d",
6283 unformat_ip4_address, &v4address, &address_length))
6285 else if (unformat (i, "%U/%d",
6286 unformat_ip6_address, &v6address, &address_length))
6292 if (sw_if_index_set == 0)
6294 errmsg ("missing interface name or sw_if_index");
6297 if (v4_address_set && v6_address_set)
6299 errmsg ("both v4 and v6 addresses set");
6302 if (!v4_address_set && !v6_address_set && !del_all)
6304 errmsg ("no addresses set");
6308 /* Construct the API message */
6309 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6311 mp->sw_if_index = ntohl (sw_if_index);
6312 mp->is_add = is_add;
6313 mp->del_all = del_all;
6317 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6321 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6323 mp->address_length = address_length;
6328 /* Wait for a reply, return good/bad news */
6334 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6336 unformat_input_t *i = vam->input;
6337 vl_api_sw_interface_set_mpls_enable_t *mp;
6339 u8 sw_if_index_set = 0;
6343 /* Parse args required to build the message */
6344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6346 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6347 sw_if_index_set = 1;
6348 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6349 sw_if_index_set = 1;
6350 else if (unformat (i, "disable"))
6352 else if (unformat (i, "dis"))
6358 if (sw_if_index_set == 0)
6360 errmsg ("missing interface name or sw_if_index");
6364 /* Construct the API message */
6365 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6367 mp->sw_if_index = ntohl (sw_if_index);
6368 mp->enable = enable;
6373 /* Wait for a reply... */
6379 api_sw_interface_set_table (vat_main_t * vam)
6381 unformat_input_t *i = vam->input;
6382 vl_api_sw_interface_set_table_t *mp;
6383 u32 sw_if_index, vrf_id = 0;
6384 u8 sw_if_index_set = 0;
6388 /* Parse args required to build the message */
6389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6391 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6392 sw_if_index_set = 1;
6393 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6394 sw_if_index_set = 1;
6395 else if (unformat (i, "vrf %d", &vrf_id))
6397 else if (unformat (i, "ipv6"))
6403 if (sw_if_index_set == 0)
6405 errmsg ("missing interface name or sw_if_index");
6409 /* Construct the API message */
6410 M (SW_INTERFACE_SET_TABLE, mp);
6412 mp->sw_if_index = ntohl (sw_if_index);
6413 mp->is_ipv6 = is_ipv6;
6414 mp->vrf_id = ntohl (vrf_id);
6419 /* Wait for a reply... */
6424 static void vl_api_sw_interface_get_table_reply_t_handler
6425 (vl_api_sw_interface_get_table_reply_t * mp)
6427 vat_main_t *vam = &vat_main;
6429 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6431 vam->retval = ntohl (mp->retval);
6432 vam->result_ready = 1;
6436 static void vl_api_sw_interface_get_table_reply_t_handler_json
6437 (vl_api_sw_interface_get_table_reply_t * mp)
6439 vat_main_t *vam = &vat_main;
6440 vat_json_node_t node;
6442 vat_json_init_object (&node);
6443 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6444 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6446 vat_json_print (vam->ofp, &node);
6447 vat_json_free (&node);
6449 vam->retval = ntohl (mp->retval);
6450 vam->result_ready = 1;
6454 api_sw_interface_get_table (vat_main_t * vam)
6456 unformat_input_t *i = vam->input;
6457 vl_api_sw_interface_get_table_t *mp;
6459 u8 sw_if_index_set = 0;
6463 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6465 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6466 sw_if_index_set = 1;
6467 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6468 sw_if_index_set = 1;
6469 else if (unformat (i, "ipv6"))
6475 if (sw_if_index_set == 0)
6477 errmsg ("missing interface name or sw_if_index");
6481 M (SW_INTERFACE_GET_TABLE, mp);
6482 mp->sw_if_index = htonl (sw_if_index);
6483 mp->is_ipv6 = is_ipv6;
6491 api_sw_interface_set_vpath (vat_main_t * vam)
6493 unformat_input_t *i = vam->input;
6494 vl_api_sw_interface_set_vpath_t *mp;
6495 u32 sw_if_index = 0;
6496 u8 sw_if_index_set = 0;
6500 /* Parse args required to build the message */
6501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6504 sw_if_index_set = 1;
6505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6506 sw_if_index_set = 1;
6507 else if (unformat (i, "enable"))
6509 else if (unformat (i, "disable"))
6515 if (sw_if_index_set == 0)
6517 errmsg ("missing interface name or sw_if_index");
6521 /* Construct the API message */
6522 M (SW_INTERFACE_SET_VPATH, mp);
6524 mp->sw_if_index = ntohl (sw_if_index);
6525 mp->enable = is_enable;
6530 /* Wait for a reply... */
6536 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6538 unformat_input_t *i = vam->input;
6539 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6540 u32 sw_if_index = 0;
6541 u8 sw_if_index_set = 0;
6546 /* Parse args required to build the message */
6547 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6549 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6550 sw_if_index_set = 1;
6551 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6552 sw_if_index_set = 1;
6553 else if (unformat (i, "enable"))
6555 else if (unformat (i, "disable"))
6557 else if (unformat (i, "ip4"))
6559 else if (unformat (i, "ip6"))
6565 if (sw_if_index_set == 0)
6567 errmsg ("missing interface name or sw_if_index");
6571 /* Construct the API message */
6572 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6574 mp->sw_if_index = ntohl (sw_if_index);
6575 mp->enable = is_enable;
6576 mp->is_ipv6 = is_ipv6;
6581 /* Wait for a reply... */
6587 api_sw_interface_set_geneve_bypass (vat_main_t * vam)
6589 unformat_input_t *i = vam->input;
6590 vl_api_sw_interface_set_geneve_bypass_t *mp;
6591 u32 sw_if_index = 0;
6592 u8 sw_if_index_set = 0;
6597 /* Parse args required to build the message */
6598 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6600 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6601 sw_if_index_set = 1;
6602 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6603 sw_if_index_set = 1;
6604 else if (unformat (i, "enable"))
6606 else if (unformat (i, "disable"))
6608 else if (unformat (i, "ip4"))
6610 else if (unformat (i, "ip6"))
6616 if (sw_if_index_set == 0)
6618 errmsg ("missing interface name or sw_if_index");
6622 /* Construct the API message */
6623 M (SW_INTERFACE_SET_GENEVE_BYPASS, mp);
6625 mp->sw_if_index = ntohl (sw_if_index);
6626 mp->enable = is_enable;
6627 mp->is_ipv6 = is_ipv6;
6632 /* Wait for a reply... */
6638 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6640 unformat_input_t *i = vam->input;
6641 vl_api_sw_interface_set_l2_xconnect_t *mp;
6643 u8 rx_sw_if_index_set = 0;
6645 u8 tx_sw_if_index_set = 0;
6649 /* Parse args required to build the message */
6650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6652 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6653 rx_sw_if_index_set = 1;
6654 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6655 tx_sw_if_index_set = 1;
6656 else if (unformat (i, "rx"))
6658 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6660 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6662 rx_sw_if_index_set = 1;
6667 else if (unformat (i, "tx"))
6669 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6671 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6673 tx_sw_if_index_set = 1;
6678 else if (unformat (i, "enable"))
6680 else if (unformat (i, "disable"))
6686 if (rx_sw_if_index_set == 0)
6688 errmsg ("missing rx interface name or rx_sw_if_index");
6692 if (enable && (tx_sw_if_index_set == 0))
6694 errmsg ("missing tx interface name or tx_sw_if_index");
6698 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6700 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6701 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6702 mp->enable = enable;
6710 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6712 unformat_input_t *i = vam->input;
6713 vl_api_sw_interface_set_l2_bridge_t *mp;
6714 vl_api_l2_port_type_t port_type;
6716 u8 rx_sw_if_index_set = 0;
6723 port_type = L2_API_PORT_TYPE_NORMAL;
6725 /* Parse args required to build the message */
6726 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6728 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6729 rx_sw_if_index_set = 1;
6730 else if (unformat (i, "bd_id %d", &bd_id))
6734 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6735 rx_sw_if_index_set = 1;
6736 else if (unformat (i, "shg %d", &shg))
6738 else if (unformat (i, "bvi"))
6739 port_type = L2_API_PORT_TYPE_BVI;
6740 else if (unformat (i, "uu-fwd"))
6741 port_type = L2_API_PORT_TYPE_UU_FWD;
6742 else if (unformat (i, "enable"))
6744 else if (unformat (i, "disable"))
6750 if (rx_sw_if_index_set == 0)
6752 errmsg ("missing rx interface name or sw_if_index");
6756 if (enable && (bd_id_set == 0))
6758 errmsg ("missing bridge domain");
6762 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6764 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6765 mp->bd_id = ntohl (bd_id);
6767 mp->port_type = ntohl (port_type);
6768 mp->enable = enable;
6776 api_bridge_domain_dump (vat_main_t * vam)
6778 unformat_input_t *i = vam->input;
6779 vl_api_bridge_domain_dump_t *mp;
6780 vl_api_control_ping_t *mp_ping;
6784 /* Parse args required to build the message */
6785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6787 if (unformat (i, "bd_id %d", &bd_id))
6793 M (BRIDGE_DOMAIN_DUMP, mp);
6794 mp->bd_id = ntohl (bd_id);
6797 /* Use a control ping for synchronization */
6798 MPING (CONTROL_PING, mp_ping);
6806 api_bridge_domain_add_del (vat_main_t * vam)
6808 unformat_input_t *i = vam->input;
6809 vl_api_bridge_domain_add_del_t *mp;
6812 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6817 /* Parse args required to build the message */
6818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6820 if (unformat (i, "bd_id %d", &bd_id))
6822 else if (unformat (i, "flood %d", &flood))
6824 else if (unformat (i, "uu-flood %d", &uu_flood))
6826 else if (unformat (i, "forward %d", &forward))
6828 else if (unformat (i, "learn %d", &learn))
6830 else if (unformat (i, "arp-term %d", &arp_term))
6832 else if (unformat (i, "mac-age %d", &mac_age))
6834 else if (unformat (i, "bd-tag %s", &bd_tag))
6836 else if (unformat (i, "del"))
6839 flood = uu_flood = forward = learn = 0;
6847 errmsg ("missing bridge domain");
6854 errmsg ("mac age must be less than 256 ");
6859 if ((bd_tag) && (vec_len (bd_tag) > 63))
6861 errmsg ("bd-tag cannot be longer than 63");
6866 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6868 mp->bd_id = ntohl (bd_id);
6870 mp->uu_flood = uu_flood;
6871 mp->forward = forward;
6873 mp->arp_term = arp_term;
6874 mp->is_add = is_add;
6875 mp->mac_age = (u8) mac_age;
6878 clib_memcpy (mp->bd_tag, bd_tag, vec_len (bd_tag));
6879 mp->bd_tag[vec_len (bd_tag)] = 0;
6890 api_l2fib_flush_bd (vat_main_t * vam)
6892 unformat_input_t *i = vam->input;
6893 vl_api_l2fib_flush_bd_t *mp;
6897 /* Parse args required to build the message */
6898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6900 if (unformat (i, "bd_id %d", &bd_id));
6907 errmsg ("missing bridge domain");
6911 M (L2FIB_FLUSH_BD, mp);
6913 mp->bd_id = htonl (bd_id);
6921 api_l2fib_flush_int (vat_main_t * vam)
6923 unformat_input_t *i = vam->input;
6924 vl_api_l2fib_flush_int_t *mp;
6925 u32 sw_if_index = ~0;
6928 /* Parse args required to build the message */
6929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6931 if (unformat (i, "sw_if_index %d", &sw_if_index));
6933 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6938 if (sw_if_index == ~0)
6940 errmsg ("missing interface name or sw_if_index");
6944 M (L2FIB_FLUSH_INT, mp);
6946 mp->sw_if_index = ntohl (sw_if_index);
6954 api_l2fib_add_del (vat_main_t * vam)
6956 unformat_input_t *i = vam->input;
6957 vl_api_l2fib_add_del_t *mp;
6963 u32 sw_if_index = 0;
6964 u8 sw_if_index_set = 0;
6973 /* Parse args required to build the message */
6974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6976 if (unformat (i, "mac %U", unformat_ethernet_address, mac))
6978 else if (unformat (i, "bd_id %d", &bd_id))
6980 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6981 sw_if_index_set = 1;
6982 else if (unformat (i, "sw_if"))
6984 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6987 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6988 sw_if_index_set = 1;
6993 else if (unformat (i, "static"))
6995 else if (unformat (i, "filter"))
7000 else if (unformat (i, "bvi"))
7005 else if (unformat (i, "del"))
7007 else if (unformat (i, "count %d", &count))
7015 errmsg ("missing mac address");
7021 errmsg ("missing bridge domain");
7025 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
7027 errmsg ("missing interface name or sw_if_index");
7033 /* Turn on async mode */
7034 vam->async_mode = 1;
7035 vam->async_errors = 0;
7036 before = vat_time_now (vam);
7039 for (j = 0; j < count; j++)
7041 M (L2FIB_ADD_DEL, mp);
7043 clib_memcpy (mp->mac, mac, 6);
7044 mp->bd_id = ntohl (bd_id);
7045 mp->is_add = is_add;
7046 mp->sw_if_index = ntohl (sw_if_index);
7050 mp->static_mac = static_mac;
7051 mp->filter_mac = filter_mac;
7052 mp->bvi_mac = bvi_mac;
7054 increment_mac_address (mac);
7061 vl_api_control_ping_t *mp_ping;
7064 /* Shut off async mode */
7065 vam->async_mode = 0;
7067 MPING (CONTROL_PING, mp_ping);
7070 timeout = vat_time_now (vam) + 1.0;
7071 while (vat_time_now (vam) < timeout)
7072 if (vam->result_ready == 1)
7077 if (vam->retval == -99)
7080 if (vam->async_errors > 0)
7082 errmsg ("%d asynchronous errors", vam->async_errors);
7085 vam->async_errors = 0;
7086 after = vat_time_now (vam);
7088 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7089 count, after - before, count / (after - before));
7095 /* Wait for a reply... */
7099 /* Return the good/bad news */
7100 return (vam->retval);
7104 api_bridge_domain_set_mac_age (vat_main_t * vam)
7106 unformat_input_t *i = vam->input;
7107 vl_api_bridge_domain_set_mac_age_t *mp;
7112 /* Parse args required to build the message */
7113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7115 if (unformat (i, "bd_id %d", &bd_id));
7116 else if (unformat (i, "mac-age %d", &mac_age));
7123 errmsg ("missing bridge domain");
7129 errmsg ("mac age must be less than 256 ");
7133 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
7135 mp->bd_id = htonl (bd_id);
7136 mp->mac_age = (u8) mac_age;
7144 api_l2_flags (vat_main_t * vam)
7146 unformat_input_t *i = vam->input;
7147 vl_api_l2_flags_t *mp;
7150 u8 sw_if_index_set = 0;
7154 /* Parse args required to build the message */
7155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7157 if (unformat (i, "sw_if_index %d", &sw_if_index))
7158 sw_if_index_set = 1;
7159 else if (unformat (i, "sw_if"))
7161 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7164 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7165 sw_if_index_set = 1;
7170 else if (unformat (i, "learn"))
7172 else if (unformat (i, "forward"))
7174 else if (unformat (i, "flood"))
7176 else if (unformat (i, "uu-flood"))
7177 flags |= L2_UU_FLOOD;
7178 else if (unformat (i, "arp-term"))
7179 flags |= L2_ARP_TERM;
7180 else if (unformat (i, "off"))
7182 else if (unformat (i, "disable"))
7188 if (sw_if_index_set == 0)
7190 errmsg ("missing interface name or sw_if_index");
7196 mp->sw_if_index = ntohl (sw_if_index);
7197 mp->feature_bitmap = ntohl (flags);
7198 mp->is_set = is_set;
7206 api_bridge_flags (vat_main_t * vam)
7208 unformat_input_t *i = vam->input;
7209 vl_api_bridge_flags_t *mp;
7213 bd_flags_t flags = 0;
7216 /* Parse args required to build the message */
7217 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7219 if (unformat (i, "bd_id %d", &bd_id))
7221 else if (unformat (i, "learn"))
7222 flags |= BRIDGE_API_FLAG_LEARN;
7223 else if (unformat (i, "forward"))
7224 flags |= BRIDGE_API_FLAG_FWD;
7225 else if (unformat (i, "flood"))
7226 flags |= BRIDGE_API_FLAG_FLOOD;
7227 else if (unformat (i, "uu-flood"))
7228 flags |= BRIDGE_API_FLAG_UU_FLOOD;
7229 else if (unformat (i, "arp-term"))
7230 flags |= BRIDGE_API_FLAG_ARP_TERM;
7231 else if (unformat (i, "off"))
7233 else if (unformat (i, "disable"))
7241 errmsg ("missing bridge domain");
7245 M (BRIDGE_FLAGS, mp);
7247 mp->bd_id = ntohl (bd_id);
7248 mp->flags = ntohl (flags);
7249 mp->is_set = is_set;
7257 api_bd_ip_mac_add_del (vat_main_t * vam)
7259 vl_api_address_t ip = VL_API_ZERO_ADDRESS;
7260 vl_api_mac_address_t mac = { 0 };
7261 unformat_input_t *i = vam->input;
7262 vl_api_bd_ip_mac_add_del_t *mp;
7274 /* Parse args required to build the message */
7275 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7277 if (unformat (i, "bd_id %d", &bd_id))
7281 else if (unformat (i, "%U", unformat_vl_api_address, &ip))
7285 else if (unformat (i, "%U", unformat_vl_api_mac_address, &mac))
7289 else if (unformat (i, "del"))
7297 errmsg ("missing bridge domain");
7300 else if (ip_set == 0)
7302 errmsg ("missing IP address");
7305 else if (mac_set == 0)
7307 errmsg ("missing MAC address");
7311 M (BD_IP_MAC_ADD_DEL, mp);
7313 mp->bd_id = ntohl (bd_id);
7314 mp->is_add = is_add;
7316 clib_memcpy (&mp->ip, &ip, sizeof (ip));
7317 clib_memcpy (&mp->mac, &mac, sizeof (mac));
7325 api_bd_ip_mac_flush (vat_main_t * vam)
7327 unformat_input_t *i = vam->input;
7328 vl_api_bd_ip_mac_flush_t *mp;
7333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7335 if (unformat (i, "bd_id %d", &bd_id))
7345 errmsg ("missing bridge domain");
7349 M (BD_IP_MAC_FLUSH, mp);
7351 mp->bd_id = ntohl (bd_id);
7358 static void vl_api_bd_ip_mac_details_t_handler
7359 (vl_api_bd_ip_mac_details_t * mp)
7361 vat_main_t *vam = &vat_main;
7366 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7369 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7372 "\n%-5d %-7s %-20U %-30s",
7373 ntohl (mp->bd_id), mp->is_ipv6 ? "ip6" : "ip4",
7374 format_ethernet_address, mp->mac_address, ip);
7379 static void vl_api_bd_ip_mac_details_t_handler_json
7380 (vl_api_bd_ip_mac_details_t * mp)
7382 vat_main_t *vam = &vat_main;
7383 vat_json_node_t *node = NULL;
7385 if (VAT_JSON_ARRAY != vam->json_tree.type)
7387 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7388 vat_json_init_array (&vam->json_tree);
7390 node = vat_json_array_add (&vam->json_tree);
7392 vat_json_init_object (node);
7393 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
7394 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
7395 vat_json_object_add_string_copy (node, "mac_address",
7396 format (0, "%U", format_ethernet_address,
7402 format (0, "%U", format_ip4_address, (ip4_address_t *) mp->ip_address);
7405 format (0, "%U", format_ip6_address, (ip6_address_t *) mp->ip_address);
7406 vat_json_object_add_string_copy (node, "ip_address", ip);
7411 api_bd_ip_mac_dump (vat_main_t * vam)
7413 unformat_input_t *i = vam->input;
7414 vl_api_bd_ip_mac_dump_t *mp;
7415 vl_api_control_ping_t *mp_ping;
7420 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7422 if (unformat (i, "bd_id %d", &bd_id))
7431 "\n%-5s %-7s %-20s %-30s",
7432 "bd_id", "is_ipv6", "mac_address", "ip_address");
7434 /* Dump Bridge Domain Ip to Mac entries */
7435 M (BD_IP_MAC_DUMP, mp);
7438 mp->bd_id = htonl (bd_id);
7444 /* Use a control ping for synchronization */
7445 MPING (CONTROL_PING, mp_ping);
7453 api_tap_create_v2 (vat_main_t * vam)
7455 unformat_input_t *i = vam->input;
7456 vl_api_tap_create_v2_t *mp;
7460 u8 *host_if_name = 0;
7462 u8 host_mac_addr[6];
7463 u8 host_mac_addr_set = 0;
7464 u8 *host_bridge = 0;
7465 ip4_address_t host_ip4_addr;
7466 ip4_address_t host_ip4_gw;
7467 u8 host_ip4_gw_set = 0;
7468 u32 host_ip4_prefix_len = 0;
7469 ip6_address_t host_ip6_addr;
7470 ip6_address_t host_ip6_gw;
7471 u8 host_ip6_gw_set = 0;
7472 u32 host_ip6_prefix_len = 0;
7474 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7476 clib_memset (mac_address, 0, sizeof (mac_address));
7478 /* Parse args required to build the message */
7479 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7481 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7485 else if (unformat (i, "id %u", &id))
7487 else if (unformat (i, "host-if-name %s", &host_if_name))
7489 else if (unformat (i, "host-ns %s", &host_ns))
7491 else if (unformat (i, "host-mac-addr %U", unformat_ethernet_address,
7493 host_mac_addr_set = 1;
7494 else if (unformat (i, "host-bridge %s", &host_bridge))
7496 else if (unformat (i, "host-ip4-addr %U/%d", unformat_ip4_address,
7497 &host_ip4_addr, &host_ip4_prefix_len))
7499 else if (unformat (i, "host-ip6-addr %U/%d", unformat_ip6_address,
7500 &host_ip6_addr, &host_ip6_prefix_len))
7502 else if (unformat (i, "host-ip4-gw %U", unformat_ip4_address,
7504 host_ip4_gw_set = 1;
7505 else if (unformat (i, "host-ip6-gw %U", unformat_ip6_address,
7507 host_ip6_gw_set = 1;
7508 else if (unformat (i, "rx-ring-size %d", &rx_ring_sz))
7510 else if (unformat (i, "tx-ring-size %d", &tx_ring_sz))
7516 if (vec_len (host_if_name) > 63)
7518 errmsg ("tap name too long. ");
7521 if (vec_len (host_ns) > 63)
7523 errmsg ("host name space too long. ");
7526 if (vec_len (host_bridge) > 63)
7528 errmsg ("host bridge name too long. ");
7531 if (host_ip4_prefix_len > 32)
7533 errmsg ("host ip4 prefix length not valid. ");
7536 if (host_ip6_prefix_len > 128)
7538 errmsg ("host ip6 prefix length not valid. ");
7541 if (!is_pow2 (rx_ring_sz))
7543 errmsg ("rx ring size must be power of 2. ");
7546 if (rx_ring_sz > 32768)
7548 errmsg ("rx ring size must be 32768 or lower. ");
7551 if (!is_pow2 (tx_ring_sz))
7553 errmsg ("tx ring size must be power of 2. ");
7556 if (tx_ring_sz > 32768)
7558 errmsg ("tx ring size must be 32768 or lower. ");
7562 /* Construct the API message */
7563 M (TAP_CREATE_V2, mp);
7565 mp->use_random_mac = random_mac;
7567 mp->id = ntohl (id);
7568 mp->host_namespace_set = host_ns != 0;
7569 mp->host_bridge_set = host_bridge != 0;
7570 mp->host_ip4_addr_set = host_ip4_prefix_len != 0;
7571 mp->host_ip6_addr_set = host_ip6_prefix_len != 0;
7572 mp->rx_ring_sz = ntohs (rx_ring_sz);
7573 mp->tx_ring_sz = ntohs (tx_ring_sz);
7575 if (random_mac == 0)
7576 clib_memcpy (mp->mac_address, mac_address, 6);
7577 if (host_mac_addr_set)
7578 clib_memcpy (mp->host_mac_addr, host_mac_addr, 6);
7580 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
7582 clib_memcpy (mp->host_namespace, host_ns, vec_len (host_ns));
7584 clib_memcpy (mp->host_bridge, host_bridge, vec_len (host_bridge));
7585 if (host_ip4_prefix_len)
7586 clib_memcpy (mp->host_ip4_addr, &host_ip4_addr, 4);
7587 if (host_ip6_prefix_len)
7588 clib_memcpy (mp->host_ip6_addr, &host_ip6_addr, 16);
7589 if (host_ip4_gw_set)
7590 clib_memcpy (mp->host_ip4_gw, &host_ip4_gw, 4);
7591 if (host_ip6_gw_set)
7592 clib_memcpy (mp->host_ip6_gw, &host_ip6_gw, 16);
7595 vec_free (host_if_name);
7596 vec_free (host_bridge);
7601 /* Wait for a reply... */
7607 api_tap_delete_v2 (vat_main_t * vam)
7609 unformat_input_t *i = vam->input;
7610 vl_api_tap_delete_v2_t *mp;
7611 u32 sw_if_index = ~0;
7612 u8 sw_if_index_set = 0;
7615 /* Parse args required to build the message */
7616 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7618 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7619 sw_if_index_set = 1;
7620 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7621 sw_if_index_set = 1;
7626 if (sw_if_index_set == 0)
7628 errmsg ("missing vpp interface name. ");
7632 /* Construct the API message */
7633 M (TAP_DELETE_V2, mp);
7635 mp->sw_if_index = ntohl (sw_if_index);
7640 /* Wait for a reply... */
7646 unformat_pci_addr (unformat_input_t * input, va_list * args)
7655 addr = va_arg (*args, struct pci_addr_t *);
7658 if (!unformat (input, "%x:%x:%x.%x", &x[0], &x[1], &x[2], &x[3]))
7661 addr->domain = x[0];
7664 addr->function = x[3];
7670 api_virtio_pci_create (vat_main_t * vam)
7672 unformat_input_t *i = vam->input;
7673 vl_api_virtio_pci_create_t *mp;
7677 u64 features = (u64) ~ (0ULL);
7678 u32 rx_ring_sz = 0, tx_ring_sz = 0;
7681 clib_memset (mac_address, 0, sizeof (mac_address));
7683 /* Parse args required to build the message */
7684 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7686 if (unformat (i, "hw-addr %U", unformat_ethernet_address, mac_address))
7690 else if (unformat (i, "pci-addr %U", unformat_pci_addr, &pci_addr))
7692 else if (unformat (i, "features 0x%llx", &features))
7694 else if (unformat (i, "rx-ring-size %u", &rx_ring_sz))
7696 else if (unformat (i, "tx-ring-size %u", &tx_ring_sz))
7704 errmsg ("pci address must be non zero. ");
7707 if (!is_pow2 (rx_ring_sz))
7709 errmsg ("rx ring size must be power of 2. ");
7712 if (rx_ring_sz > 32768)
7714 errmsg ("rx ring size must be 32768 or lower. ");
7717 if (!is_pow2 (tx_ring_sz))
7719 errmsg ("tx ring size must be power of 2. ");
7722 if (tx_ring_sz > 32768)
7724 errmsg ("tx ring size must be 32768 or lower. ");
7728 /* Construct the API message */
7729 M (VIRTIO_PCI_CREATE, mp);
7731 mp->use_random_mac = random_mac;
7733 mp->pci_addr = htonl (pci_addr);
7734 mp->features = clib_host_to_net_u64 (features);
7735 mp->rx_ring_sz = htons (rx_ring_sz);
7736 mp->tx_ring_sz = htons (tx_ring_sz);
7738 if (random_mac == 0)
7739 clib_memcpy (mp->mac_address, mac_address, 6);
7744 /* Wait for a reply... */
7750 api_virtio_pci_delete (vat_main_t * vam)
7752 unformat_input_t *i = vam->input;
7753 vl_api_virtio_pci_delete_t *mp;
7754 u32 sw_if_index = ~0;
7755 u8 sw_if_index_set = 0;
7758 /* Parse args required to build the message */
7759 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7761 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7762 sw_if_index_set = 1;
7763 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7764 sw_if_index_set = 1;
7769 if (sw_if_index_set == 0)
7771 errmsg ("missing vpp interface name. ");
7775 /* Construct the API message */
7776 M (VIRTIO_PCI_DELETE, mp);
7778 mp->sw_if_index = htonl (sw_if_index);
7783 /* Wait for a reply... */
7789 api_bond_create (vat_main_t * vam)
7791 unformat_input_t *i = vam->input;
7792 vl_api_bond_create_t *mp;
7801 clib_memset (mac_address, 0, sizeof (mac_address));
7804 /* Parse args required to build the message */
7805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7807 if (unformat (i, "mode %U", unformat_bond_mode, &mode))
7809 else if (((mode == BOND_MODE_LACP) || (mode == BOND_MODE_XOR))
7810 && unformat (i, "lb %U", unformat_bond_load_balance, &lb))
7812 else if (unformat (i, "hw-addr %U", unformat_ethernet_address,
7815 else if (unformat (i, "id %u", &id))
7821 if (mode_is_set == 0)
7823 errmsg ("Missing bond mode. ");
7827 /* Construct the API message */
7828 M (BOND_CREATE, mp);
7830 mp->use_custom_mac = custom_mac;
7834 mp->id = htonl (id);
7837 clib_memcpy (mp->mac_address, mac_address, 6);
7842 /* Wait for a reply... */
7848 api_bond_delete (vat_main_t * vam)
7850 unformat_input_t *i = vam->input;
7851 vl_api_bond_delete_t *mp;
7852 u32 sw_if_index = ~0;
7853 u8 sw_if_index_set = 0;
7856 /* Parse args required to build the message */
7857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7859 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7860 sw_if_index_set = 1;
7861 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7862 sw_if_index_set = 1;
7867 if (sw_if_index_set == 0)
7869 errmsg ("missing vpp interface name. ");
7873 /* Construct the API message */
7874 M (BOND_DELETE, mp);
7876 mp->sw_if_index = ntohl (sw_if_index);
7881 /* Wait for a reply... */
7887 api_bond_enslave (vat_main_t * vam)
7889 unformat_input_t *i = vam->input;
7890 vl_api_bond_enslave_t *mp;
7891 u32 bond_sw_if_index;
7895 u32 bond_sw_if_index_is_set = 0;
7897 u8 sw_if_index_is_set = 0;
7899 /* Parse args required to build the message */
7900 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7902 if (unformat (i, "sw_if_index %d", &sw_if_index))
7903 sw_if_index_is_set = 1;
7904 else if (unformat (i, "bond %u", &bond_sw_if_index))
7905 bond_sw_if_index_is_set = 1;
7906 else if (unformat (i, "passive %d", &is_passive))
7908 else if (unformat (i, "long-timeout %d", &is_long_timeout))
7914 if (bond_sw_if_index_is_set == 0)
7916 errmsg ("Missing bond sw_if_index. ");
7919 if (sw_if_index_is_set == 0)
7921 errmsg ("Missing slave sw_if_index. ");
7925 /* Construct the API message */
7926 M (BOND_ENSLAVE, mp);
7928 mp->bond_sw_if_index = ntohl (bond_sw_if_index);
7929 mp->sw_if_index = ntohl (sw_if_index);
7930 mp->is_long_timeout = is_long_timeout;
7931 mp->is_passive = is_passive;
7936 /* Wait for a reply... */
7942 api_bond_detach_slave (vat_main_t * vam)
7944 unformat_input_t *i = vam->input;
7945 vl_api_bond_detach_slave_t *mp;
7946 u32 sw_if_index = ~0;
7947 u8 sw_if_index_set = 0;
7950 /* Parse args required to build the message */
7951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7953 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7954 sw_if_index_set = 1;
7955 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7956 sw_if_index_set = 1;
7961 if (sw_if_index_set == 0)
7963 errmsg ("missing vpp interface name. ");
7967 /* Construct the API message */
7968 M (BOND_DETACH_SLAVE, mp);
7970 mp->sw_if_index = ntohl (sw_if_index);
7975 /* Wait for a reply... */
7981 api_ip_table_add_del (vat_main_t * vam)
7983 unformat_input_t *i = vam->input;
7984 vl_api_ip_table_add_del_t *mp;
7990 /* Parse args required to build the message */
7991 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7993 if (unformat (i, "ipv6"))
7995 else if (unformat (i, "del"))
7997 else if (unformat (i, "add"))
7999 else if (unformat (i, "table %d", &table_id))
8003 clib_warning ("parse error '%U'", format_unformat_error, i);
8010 errmsg ("missing table-ID");
8014 /* Construct the API message */
8015 M (IP_TABLE_ADD_DEL, mp);
8017 mp->table_id = ntohl (table_id);
8018 mp->is_ipv6 = is_ipv6;
8019 mp->is_add = is_add;
8024 /* Wait for a reply... */
8031 api_ip_add_del_route (vat_main_t * vam)
8033 unformat_input_t *i = vam->input;
8034 vl_api_ip_add_del_route_t *mp;
8035 u32 sw_if_index = ~0, vrf_id = 0;
8037 u8 is_local = 0, is_drop = 0;
8038 u8 is_unreach = 0, is_prohibit = 0;
8040 u32 next_hop_weight = 1;
8041 u8 is_multipath = 0;
8043 u8 address_length_set = 0;
8044 u32 next_hop_table_id = 0;
8045 u32 resolve_attempts = 0;
8046 u32 dst_address_length = 0;
8047 u8 next_hop_set = 0;
8048 ip4_address_t v4_dst_address, v4_next_hop_address;
8049 ip6_address_t v6_dst_address, v6_next_hop_address;
8053 u32 random_add_del = 0;
8054 u32 *random_vector = 0;
8056 u32 random_seed = 0xdeaddabe;
8057 u32 classify_table_index = ~0;
8059 u8 resolve_host = 0, resolve_attached = 0;
8060 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8061 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8062 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8064 clib_memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
8065 clib_memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
8066 /* Parse args required to build the message */
8067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8069 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8071 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8073 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
8078 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
8083 else if (unformat (i, "/%d", &dst_address_length))
8085 address_length_set = 1;
8088 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
8089 &v4_next_hop_address))
8093 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
8094 &v6_next_hop_address))
8100 (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
8104 else if (unformat (i, "via sw_if_index %d", &sw_if_index))
8108 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
8110 else if (unformat (i, "weight %d", &next_hop_weight))
8112 else if (unformat (i, "drop"))
8116 else if (unformat (i, "null-send-unreach"))
8120 else if (unformat (i, "null-send-prohibit"))
8124 else if (unformat (i, "local"))
8128 else if (unformat (i, "classify %d", &classify_table_index))
8132 else if (unformat (i, "del"))
8134 else if (unformat (i, "add"))
8136 else if (unformat (i, "resolve-via-host"))
8138 else if (unformat (i, "resolve-via-attached"))
8139 resolve_attached = 1;
8140 else if (unformat (i, "multipath"))
8142 else if (unformat (i, "vrf %d", &vrf_id))
8144 else if (unformat (i, "count %d", &count))
8146 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
8148 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8150 else if (unformat (i, "out-label %d", &next_hop_out_label))
8152 vl_api_fib_mpls_label_t fib_label = {
8153 .label = ntohl (next_hop_out_label),
8157 vec_add1 (next_hop_out_label_stack, fib_label);
8159 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8161 else if (unformat (i, "random"))
8163 else if (unformat (i, "seed %d", &random_seed))
8167 clib_warning ("parse error '%U'", format_unformat_error, i);
8172 if (!next_hop_set && !is_drop && !is_local &&
8173 !is_classify && !is_unreach && !is_prohibit &&
8174 MPLS_LABEL_INVALID == next_hop_via_label)
8177 ("next hop / local / drop / unreach / prohibit / classify not set");
8181 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
8183 errmsg ("next hop and next-hop via label set");
8186 if (address_set == 0)
8188 errmsg ("missing addresses");
8192 if (address_length_set == 0)
8194 errmsg ("missing address length");
8198 /* Generate a pile of unique, random routes */
8201 u32 this_random_address;
8202 random_hash = hash_create (count, sizeof (uword));
8204 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
8205 for (j = 0; j <= count; j++)
8209 this_random_address = random_u32 (&random_seed);
8210 this_random_address =
8211 clib_host_to_net_u32 (this_random_address);
8213 while (hash_get (random_hash, this_random_address));
8214 vec_add1 (random_vector, this_random_address);
8215 hash_set (random_hash, this_random_address, 1);
8217 hash_free (random_hash);
8218 v4_dst_address.as_u32 = random_vector[0];
8223 /* Turn on async mode */
8224 vam->async_mode = 1;
8225 vam->async_errors = 0;
8226 before = vat_time_now (vam);
8229 for (j = 0; j < count; j++)
8231 /* Construct the API message */
8232 M2 (IP_ADD_DEL_ROUTE, mp, sizeof (vl_api_fib_mpls_label_t) *
8233 vec_len (next_hop_out_label_stack));
8235 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8236 mp->table_id = ntohl (vrf_id);
8238 mp->is_add = is_add;
8239 mp->is_drop = is_drop;
8240 mp->is_unreach = is_unreach;
8241 mp->is_prohibit = is_prohibit;
8242 mp->is_ipv6 = is_ipv6;
8243 mp->is_local = is_local;
8244 mp->is_classify = is_classify;
8245 mp->is_multipath = is_multipath;
8246 mp->is_resolve_host = resolve_host;
8247 mp->is_resolve_attached = resolve_attached;
8248 mp->next_hop_weight = next_hop_weight;
8249 mp->next_hop_preference = 0;
8250 mp->dst_address_length = dst_address_length;
8251 mp->next_hop_table_id = ntohl (next_hop_table_id);
8252 mp->classify_table_index = ntohl (classify_table_index);
8253 mp->next_hop_via_label = ntohl (next_hop_via_label);
8254 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8255 if (0 != mp->next_hop_n_out_labels)
8257 memcpy (mp->next_hop_out_label_stack,
8258 next_hop_out_label_stack,
8259 (vec_len (next_hop_out_label_stack) *
8260 sizeof (vl_api_fib_mpls_label_t)));
8261 vec_free (next_hop_out_label_stack);
8266 clib_memcpy (mp->dst_address, &v6_dst_address,
8267 sizeof (v6_dst_address));
8269 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
8270 sizeof (v6_next_hop_address));
8271 increment_v6_address (&v6_dst_address);
8275 clib_memcpy (mp->dst_address, &v4_dst_address,
8276 sizeof (v4_dst_address));
8278 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
8279 sizeof (v4_next_hop_address));
8281 v4_dst_address.as_u32 = random_vector[j + 1];
8283 increment_v4_address (&v4_dst_address);
8287 /* If we receive SIGTERM, stop now... */
8292 /* When testing multiple add/del ops, use a control-ping to sync */
8295 vl_api_control_ping_t *mp_ping;
8299 /* Shut off async mode */
8300 vam->async_mode = 0;
8302 MPING (CONTROL_PING, mp_ping);
8305 timeout = vat_time_now (vam) + 1.0;
8306 while (vat_time_now (vam) < timeout)
8307 if (vam->result_ready == 1)
8312 if (vam->retval == -99)
8315 if (vam->async_errors > 0)
8317 errmsg ("%d asynchronous errors", vam->async_errors);
8320 vam->async_errors = 0;
8321 after = vat_time_now (vam);
8323 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8327 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8328 count, after - before, count / (after - before));
8334 /* Wait for a reply... */
8339 /* Return the good/bad news */
8340 return (vam->retval);
8344 api_ip_mroute_add_del (vat_main_t * vam)
8346 unformat_input_t *i = vam->input;
8347 vl_api_ip_mroute_add_del_t *mp;
8348 u32 sw_if_index = ~0, vrf_id = 0;
8353 u32 grp_address_length = 0;
8354 ip4_address_t v4_grp_address, v4_src_address;
8355 ip6_address_t v6_grp_address, v6_src_address;
8356 mfib_itf_flags_t iflags = 0;
8357 mfib_entry_flags_t eflags = 0;
8360 /* Parse args required to build the message */
8361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8363 if (unformat (i, "sw_if_index %d", &sw_if_index))
8365 else if (unformat (i, "%U %U",
8366 unformat_ip4_address, &v4_src_address,
8367 unformat_ip4_address, &v4_grp_address))
8369 grp_address_length = 64;
8373 else if (unformat (i, "%U %U",
8374 unformat_ip6_address, &v6_src_address,
8375 unformat_ip6_address, &v6_grp_address))
8377 grp_address_length = 256;
8381 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
8383 clib_memset (&v4_src_address, 0, sizeof (v4_src_address));
8384 grp_address_length = 32;
8388 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
8390 clib_memset (&v6_src_address, 0, sizeof (v6_src_address));
8391 grp_address_length = 128;
8395 else if (unformat (i, "/%d", &grp_address_length))
8397 else if (unformat (i, "local"))
8401 else if (unformat (i, "del"))
8403 else if (unformat (i, "add"))
8405 else if (unformat (i, "vrf %d", &vrf_id))
8407 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
8409 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
8413 clib_warning ("parse error '%U'", format_unformat_error, i);
8418 if (address_set == 0)
8420 errmsg ("missing addresses\n");
8424 /* Construct the API message */
8425 M (IP_MROUTE_ADD_DEL, mp);
8427 mp->next_hop_sw_if_index = ntohl (sw_if_index);
8428 mp->table_id = ntohl (vrf_id);
8430 mp->is_add = is_add;
8431 mp->is_ipv6 = is_ipv6;
8432 mp->is_local = is_local;
8433 mp->itf_flags = ntohl (iflags);
8434 mp->entry_flags = ntohl (eflags);
8435 mp->grp_address_length = grp_address_length;
8436 mp->grp_address_length = ntohs (mp->grp_address_length);
8440 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
8441 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
8445 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
8446 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
8452 /* Wait for a reply... */
8458 api_mpls_table_add_del (vat_main_t * vam)
8460 unformat_input_t *i = vam->input;
8461 vl_api_mpls_table_add_del_t *mp;
8466 /* Parse args required to build the message */
8467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8469 if (unformat (i, "table %d", &table_id))
8471 else if (unformat (i, "del"))
8473 else if (unformat (i, "add"))
8477 clib_warning ("parse error '%U'", format_unformat_error, i);
8484 errmsg ("missing table-ID");
8488 /* Construct the API message */
8489 M (MPLS_TABLE_ADD_DEL, mp);
8491 mp->mt_table_id = ntohl (table_id);
8492 mp->mt_is_add = is_add;
8497 /* Wait for a reply... */
8504 api_mpls_route_add_del (vat_main_t * vam)
8506 unformat_input_t *i = vam->input;
8507 vl_api_mpls_route_add_del_t *mp;
8508 u32 sw_if_index = ~0, table_id = 0;
8510 u32 next_hop_weight = 1;
8511 u8 is_multipath = 0;
8512 u32 next_hop_table_id = 0;
8513 u8 next_hop_set = 0;
8514 ip4_address_t v4_next_hop_address = {
8517 ip6_address_t v6_next_hop_address = { {0} };
8521 u32 classify_table_index = ~0;
8523 u8 resolve_host = 0, resolve_attached = 0;
8524 u8 is_interface_rx = 0;
8525 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
8526 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
8527 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
8528 mpls_label_t local_label = MPLS_LABEL_INVALID;
8530 dpo_proto_t next_hop_proto = DPO_PROTO_MPLS;
8532 /* Parse args required to build the message */
8533 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8535 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8537 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8539 else if (unformat (i, "%d", &local_label))
8541 else if (unformat (i, "eos"))
8543 else if (unformat (i, "non-eos"))
8545 else if (unformat (i, "via %U", unformat_ip4_address,
8546 &v4_next_hop_address))
8549 next_hop_proto = DPO_PROTO_IP4;
8551 else if (unformat (i, "via %U", unformat_ip6_address,
8552 &v6_next_hop_address))
8555 next_hop_proto = DPO_PROTO_IP6;
8557 else if (unformat (i, "weight %d", &next_hop_weight))
8559 else if (unformat (i, "classify %d", &classify_table_index))
8563 else if (unformat (i, "del"))
8565 else if (unformat (i, "add"))
8567 else if (unformat (i, "resolve-via-host"))
8569 else if (unformat (i, "resolve-via-attached"))
8570 resolve_attached = 1;
8571 else if (unformat (i, "multipath"))
8573 else if (unformat (i, "count %d", &count))
8575 else if (unformat (i, "via lookup-in-ip4-table %d", &next_hop_table_id))
8578 next_hop_proto = DPO_PROTO_IP4;
8580 else if (unformat (i, "via lookup-in-ip6-table %d", &next_hop_table_id))
8583 next_hop_proto = DPO_PROTO_IP6;
8587 (i, "via l2-input-on %U", api_unformat_sw_if_index, vam,
8591 next_hop_proto = DPO_PROTO_ETHERNET;
8592 is_interface_rx = 1;
8594 else if (unformat (i, "via l2-input-on sw_if_index %d", &sw_if_index))
8597 next_hop_proto = DPO_PROTO_ETHERNET;
8598 is_interface_rx = 1;
8600 else if (unformat (i, "via next-hop-table %d", &next_hop_table_id))
8602 else if (unformat (i, "via via-label %d", &next_hop_via_label))
8604 else if (unformat (i, "out-label %d", &next_hop_out_label))
8606 vl_api_fib_mpls_label_t fib_label = {
8607 .label = ntohl (next_hop_out_label),
8611 vec_add1 (next_hop_out_label_stack, fib_label);
8615 clib_warning ("parse error '%U'", format_unformat_error, i);
8620 if (!next_hop_set && !is_classify)
8622 errmsg ("next hop / classify not set");
8626 if (MPLS_LABEL_INVALID == local_label)
8628 errmsg ("missing label");
8634 /* Turn on async mode */
8635 vam->async_mode = 1;
8636 vam->async_errors = 0;
8637 before = vat_time_now (vam);
8640 for (j = 0; j < count; j++)
8642 /* Construct the API message */
8643 M2 (MPLS_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
8644 vec_len (next_hop_out_label_stack));
8646 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
8647 mp->mr_table_id = ntohl (table_id);
8649 mp->mr_is_add = is_add;
8650 mp->mr_next_hop_proto = next_hop_proto;
8651 mp->mr_is_classify = is_classify;
8652 mp->mr_is_multipath = is_multipath;
8653 mp->mr_is_resolve_host = resolve_host;
8654 mp->mr_is_resolve_attached = resolve_attached;
8655 mp->mr_is_interface_rx = is_interface_rx;
8656 mp->mr_next_hop_weight = next_hop_weight;
8657 mp->mr_next_hop_preference = 0;
8658 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
8659 mp->mr_classify_table_index = ntohl (classify_table_index);
8660 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
8661 mp->mr_label = ntohl (local_label);
8662 mp->mr_eos = is_eos;
8664 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
8665 if (0 != mp->mr_next_hop_n_out_labels)
8667 memcpy (mp->mr_next_hop_out_label_stack,
8668 next_hop_out_label_stack,
8669 vec_len (next_hop_out_label_stack) *
8670 sizeof (vl_api_fib_mpls_label_t));
8671 vec_free (next_hop_out_label_stack);
8676 if (DPO_PROTO_IP4 == next_hop_proto)
8678 clib_memcpy (mp->mr_next_hop,
8679 &v4_next_hop_address,
8680 sizeof (v4_next_hop_address));
8682 else if (DPO_PROTO_IP6 == next_hop_proto)
8685 clib_memcpy (mp->mr_next_hop,
8686 &v6_next_hop_address,
8687 sizeof (v6_next_hop_address));
8694 /* If we receive SIGTERM, stop now... */
8699 /* When testing multiple add/del ops, use a control-ping to sync */
8702 vl_api_control_ping_t *mp_ping;
8706 /* Shut off async mode */
8707 vam->async_mode = 0;
8709 MPING (CONTROL_PING, mp_ping);
8712 timeout = vat_time_now (vam) + 1.0;
8713 while (vat_time_now (vam) < timeout)
8714 if (vam->result_ready == 1)
8719 if (vam->retval == -99)
8722 if (vam->async_errors > 0)
8724 errmsg ("%d asynchronous errors", vam->async_errors);
8727 vam->async_errors = 0;
8728 after = vat_time_now (vam);
8730 /* slim chance, but we might have eaten SIGTERM on the first iteration */
8734 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
8735 count, after - before, count / (after - before));
8741 /* Wait for a reply... */
8746 /* Return the good/bad news */
8747 return (vam->retval);
8751 api_mpls_ip_bind_unbind (vat_main_t * vam)
8753 unformat_input_t *i = vam->input;
8754 vl_api_mpls_ip_bind_unbind_t *mp;
8755 u32 ip_table_id = 0;
8758 ip4_address_t v4_address;
8759 ip6_address_t v6_address;
8762 mpls_label_t local_label = MPLS_LABEL_INVALID;
8765 /* Parse args required to build the message */
8766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8768 if (unformat (i, "%U/%d", unformat_ip4_address,
8769 &v4_address, &address_length))
8774 else if (unformat (i, "%U/%d", unformat_ip6_address,
8775 &v6_address, &address_length))
8780 else if (unformat (i, "%d", &local_label))
8782 else if (unformat (i, "table-id %d", &ip_table_id))
8784 else if (unformat (i, "unbind"))
8786 else if (unformat (i, "bind"))
8790 clib_warning ("parse error '%U'", format_unformat_error, i);
8797 errmsg ("IP address not set");
8801 if (MPLS_LABEL_INVALID == local_label)
8803 errmsg ("missing label");
8807 /* Construct the API message */
8808 M (MPLS_IP_BIND_UNBIND, mp);
8810 mp->mb_is_bind = is_bind;
8811 mp->mb_is_ip4 = is_ip4;
8812 mp->mb_ip_table_id = ntohl (ip_table_id);
8813 mp->mb_mpls_table_id = 0;
8814 mp->mb_label = ntohl (local_label);
8815 mp->mb_address_length = address_length;
8818 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8820 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8825 /* Wait for a reply... */
8831 api_sr_mpls_policy_add (vat_main_t * vam)
8833 unformat_input_t *i = vam->input;
8834 vl_api_sr_mpls_policy_add_t *mp;
8840 u32 *segments = NULL;
8843 /* Parse args required to build the message */
8844 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8846 if (unformat (i, "bsid %d", &bsid))
8848 else if (unformat (i, "weight %d", &weight))
8850 else if (unformat (i, "spray"))
8852 else if (unformat (i, "next %d", &sid))
8855 vec_add1 (segments, htonl (sid));
8859 clib_warning ("parse error '%U'", format_unformat_error, i);
8866 errmsg ("bsid not set");
8870 if (n_segments == 0)
8872 errmsg ("no sid in segment stack");
8876 /* Construct the API message */
8877 M2 (SR_MPLS_POLICY_ADD, mp, sizeof (u32) * n_segments);
8879 mp->bsid = htonl (bsid);
8880 mp->weight = htonl (weight);
8882 mp->n_segments = n_segments;
8883 memcpy (mp->segments, segments, sizeof (u32) * n_segments);
8884 vec_free (segments);
8889 /* Wait for a reply... */
8895 api_sr_mpls_policy_del (vat_main_t * vam)
8897 unformat_input_t *i = vam->input;
8898 vl_api_sr_mpls_policy_del_t *mp;
8902 /* Parse args required to build the message */
8903 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8905 if (unformat (i, "bsid %d", &bsid))
8909 clib_warning ("parse error '%U'", format_unformat_error, i);
8916 errmsg ("bsid not set");
8920 /* Construct the API message */
8921 M (SR_MPLS_POLICY_DEL, mp);
8923 mp->bsid = htonl (bsid);
8928 /* Wait for a reply... */
8934 api_bier_table_add_del (vat_main_t * vam)
8936 unformat_input_t *i = vam->input;
8937 vl_api_bier_table_add_del_t *mp;
8939 u32 set = 0, sub_domain = 0, hdr_len = 3;
8940 mpls_label_t local_label = MPLS_LABEL_INVALID;
8943 /* Parse args required to build the message */
8944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8946 if (unformat (i, "sub-domain %d", &sub_domain))
8948 else if (unformat (i, "set %d", &set))
8950 else if (unformat (i, "label %d", &local_label))
8952 else if (unformat (i, "hdr-len %d", &hdr_len))
8954 else if (unformat (i, "add"))
8956 else if (unformat (i, "del"))
8960 clib_warning ("parse error '%U'", format_unformat_error, i);
8965 if (MPLS_LABEL_INVALID == local_label)
8967 errmsg ("missing label\n");
8971 /* Construct the API message */
8972 M (BIER_TABLE_ADD_DEL, mp);
8974 mp->bt_is_add = is_add;
8975 mp->bt_label = ntohl (local_label);
8976 mp->bt_tbl_id.bt_set = set;
8977 mp->bt_tbl_id.bt_sub_domain = sub_domain;
8978 mp->bt_tbl_id.bt_hdr_len_id = hdr_len;
8983 /* Wait for a reply... */
8990 api_bier_route_add_del (vat_main_t * vam)
8992 unformat_input_t *i = vam->input;
8993 vl_api_bier_route_add_del_t *mp;
8995 u32 set = 0, sub_domain = 0, hdr_len = 3, bp = 0;
8996 ip4_address_t v4_next_hop_address;
8997 ip6_address_t v6_next_hop_address;
8998 u8 next_hop_set = 0;
8999 u8 next_hop_proto_is_ip4 = 1;
9000 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9003 /* Parse args required to build the message */
9004 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9006 if (unformat (i, "%U", unformat_ip4_address, &v4_next_hop_address))
9008 next_hop_proto_is_ip4 = 1;
9011 else if (unformat (i, "%U", unformat_ip6_address, &v6_next_hop_address))
9013 next_hop_proto_is_ip4 = 0;
9016 if (unformat (i, "sub-domain %d", &sub_domain))
9018 else if (unformat (i, "set %d", &set))
9020 else if (unformat (i, "hdr-len %d", &hdr_len))
9022 else if (unformat (i, "bp %d", &bp))
9024 else if (unformat (i, "add"))
9026 else if (unformat (i, "del"))
9028 else if (unformat (i, "out-label %d", &next_hop_out_label))
9032 clib_warning ("parse error '%U'", format_unformat_error, i);
9037 if (!next_hop_set || (MPLS_LABEL_INVALID == next_hop_out_label))
9039 errmsg ("next hop / label set\n");
9044 errmsg ("bit=position not set\n");
9048 /* Construct the API message */
9049 M2 (BIER_ROUTE_ADD_DEL, mp, sizeof (vl_api_fib_path_t));
9051 mp->br_is_add = is_add;
9052 mp->br_tbl_id.bt_set = set;
9053 mp->br_tbl_id.bt_sub_domain = sub_domain;
9054 mp->br_tbl_id.bt_hdr_len_id = hdr_len;
9055 mp->br_bp = ntohs (bp);
9057 mp->br_paths[0].n_labels = 1;
9058 mp->br_paths[0].label_stack[0].label = ntohl (next_hop_out_label);
9059 mp->br_paths[0].afi = (next_hop_proto_is_ip4 ? 0 : 1);
9061 if (next_hop_proto_is_ip4)
9063 clib_memcpy (mp->br_paths[0].next_hop,
9064 &v4_next_hop_address, sizeof (v4_next_hop_address));
9068 clib_memcpy (mp->br_paths[0].next_hop,
9069 &v6_next_hop_address, sizeof (v6_next_hop_address));
9075 /* Wait for a reply... */
9082 api_proxy_arp_add_del (vat_main_t * vam)
9084 unformat_input_t *i = vam->input;
9085 vl_api_proxy_arp_add_del_t *mp;
9088 vl_api_ip4_address_t lo, hi;
9092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9094 if (unformat (i, "vrf %d", &vrf_id))
9096 else if (unformat (i, "%U - %U", unformat_vl_api_ip4_address, &lo,
9097 unformat_vl_api_ip4_address, &hi))
9099 else if (unformat (i, "del"))
9103 clib_warning ("parse error '%U'", format_unformat_error, i);
9110 errmsg ("address range not set");
9114 M (PROXY_ARP_ADD_DEL, mp);
9116 mp->proxy.table_id = ntohl (vrf_id);
9117 mp->is_add = is_add;
9118 clib_memcpy (mp->proxy.low, &lo, sizeof (lo));
9119 clib_memcpy (mp->proxy.hi, &hi, sizeof (hi));
9127 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
9129 unformat_input_t *i = vam->input;
9130 vl_api_proxy_arp_intfc_enable_disable_t *mp;
9133 u8 sw_if_index_set = 0;
9136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9138 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9139 sw_if_index_set = 1;
9140 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9141 sw_if_index_set = 1;
9142 else if (unformat (i, "enable"))
9144 else if (unformat (i, "disable"))
9148 clib_warning ("parse error '%U'", format_unformat_error, i);
9153 if (sw_if_index_set == 0)
9155 errmsg ("missing interface name or sw_if_index");
9159 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
9161 mp->sw_if_index = ntohl (sw_if_index);
9162 mp->enable_disable = enable;
9170 api_mpls_tunnel_add_del (vat_main_t * vam)
9172 unformat_input_t *i = vam->input;
9173 vl_api_mpls_tunnel_add_del_t *mp;
9177 u32 sw_if_index = ~0;
9178 u32 next_hop_sw_if_index = ~0;
9179 u32 next_hop_proto_is_ip4 = 1;
9181 u32 next_hop_table_id = 0;
9182 ip4_address_t v4_next_hop_address = {
9185 ip6_address_t v6_next_hop_address = { {0} };
9186 vl_api_fib_mpls_label_t *next_hop_out_label_stack = NULL;
9187 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
9188 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
9191 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9193 if (unformat (i, "add"))
9197 (i, "del %U", api_unformat_sw_if_index, vam, &sw_if_index))
9199 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
9201 else if (unformat (i, "via %U",
9202 unformat_ip4_address, &v4_next_hop_address))
9204 next_hop_proto_is_ip4 = 1;
9206 else if (unformat (i, "via %U",
9207 unformat_ip6_address, &v6_next_hop_address))
9209 next_hop_proto_is_ip4 = 0;
9211 else if (unformat (i, "via-label %d", &next_hop_via_label))
9215 (i, "%U", api_unformat_sw_if_index, vam, &next_hop_sw_if_index))
9217 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
9219 else if (unformat (i, "l2-only"))
9221 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
9223 else if (unformat (i, "out-label %d", &next_hop_out_label))
9225 vl_api_fib_mpls_label_t fib_label = {
9226 .label = ntohl (next_hop_out_label),
9230 vec_add1 (next_hop_out_label_stack, fib_label);
9234 clib_warning ("parse error '%U'", format_unformat_error, i);
9239 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (vl_api_fib_mpls_label_t) *
9240 vec_len (next_hop_out_label_stack));
9242 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
9243 mp->mt_sw_if_index = ntohl (sw_if_index);
9244 mp->mt_is_add = is_add;
9245 mp->mt_l2_only = l2_only;
9246 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
9247 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
9248 mp->mt_next_hop_via_label = ntohl (next_hop_via_label);
9249 mp->mt_next_hop_weight = 1;
9250 mp->mt_next_hop_preference = 0;
9252 mp->mt_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
9254 if (0 != mp->mt_next_hop_n_out_labels)
9256 clib_memcpy (mp->mt_next_hop_out_label_stack,
9257 next_hop_out_label_stack,
9258 (vec_len (next_hop_out_label_stack) *
9259 sizeof (vl_api_fib_mpls_label_t)));
9260 vec_free (next_hop_out_label_stack);
9263 if (next_hop_proto_is_ip4)
9265 clib_memcpy (mp->mt_next_hop,
9266 &v4_next_hop_address, sizeof (v4_next_hop_address));
9270 clib_memcpy (mp->mt_next_hop,
9271 &v6_next_hop_address, sizeof (v6_next_hop_address));
9280 api_sw_interface_set_unnumbered (vat_main_t * vam)
9282 unformat_input_t *i = vam->input;
9283 vl_api_sw_interface_set_unnumbered_t *mp;
9285 u32 unnum_sw_index = ~0;
9287 u8 sw_if_index_set = 0;
9290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9292 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9293 sw_if_index_set = 1;
9294 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9295 sw_if_index_set = 1;
9296 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
9298 else if (unformat (i, "del"))
9302 clib_warning ("parse error '%U'", format_unformat_error, i);
9307 if (sw_if_index_set == 0)
9309 errmsg ("missing interface name or sw_if_index");
9313 M (SW_INTERFACE_SET_UNNUMBERED, mp);
9315 mp->sw_if_index = ntohl (sw_if_index);
9316 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
9317 mp->is_add = is_add;
9325 api_ip_neighbor_add_del (vat_main_t * vam)
9327 vl_api_mac_address_t mac_address;
9328 unformat_input_t *i = vam->input;
9329 vl_api_ip_neighbor_add_del_t *mp;
9330 vl_api_address_t ip_address;
9332 u8 sw_if_index_set = 0;
9337 ip_neighbor_flags_t flags;
9339 flags = IP_NEIGHBOR_FLAG_NONE;
9340 clib_memset (&ip_address, 0, sizeof (ip_address));
9341 clib_memset (&mac_address, 0, sizeof (mac_address));
9342 /* Parse args required to build the message */
9343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9345 if (unformat (i, "mac %U", unformat_vl_api_mac_address, &mac_address))
9349 else if (unformat (i, "del"))
9352 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9353 sw_if_index_set = 1;
9354 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9355 sw_if_index_set = 1;
9356 else if (unformat (i, "static"))
9357 flags |= IP_NEIGHBOR_FLAG_STATIC;
9358 else if (unformat (i, "no-fib-entry"))
9359 flags |= IP_NEIGHBOR_FLAG_NO_FIB_ENTRY;
9360 else if (unformat (i, "dst %U", unformat_vl_api_address, &ip_address))
9364 clib_warning ("parse error '%U'", format_unformat_error, i);
9369 if (sw_if_index_set == 0)
9371 errmsg ("missing interface name or sw_if_index");
9376 errmsg ("no address set");
9380 /* Construct the API message */
9381 M (IP_NEIGHBOR_ADD_DEL, mp);
9383 mp->neighbor.sw_if_index = ntohl (sw_if_index);
9384 mp->is_add = is_add;
9385 mp->neighbor.flags = htonl (flags);
9387 clib_memcpy (&mp->neighbor.mac_address, &mac_address,
9388 sizeof (mac_address));
9390 clib_memcpy (&mp->neighbor.ip_address, &ip_address, sizeof (ip_address));
9395 /* Wait for a reply, return good/bad news */
9401 api_create_vlan_subif (vat_main_t * vam)
9403 unformat_input_t *i = vam->input;
9404 vl_api_create_vlan_subif_t *mp;
9406 u8 sw_if_index_set = 0;
9411 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9413 if (unformat (i, "sw_if_index %d", &sw_if_index))
9414 sw_if_index_set = 1;
9416 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9417 sw_if_index_set = 1;
9418 else if (unformat (i, "vlan %d", &vlan_id))
9422 clib_warning ("parse error '%U'", format_unformat_error, i);
9427 if (sw_if_index_set == 0)
9429 errmsg ("missing interface name or sw_if_index");
9433 if (vlan_id_set == 0)
9435 errmsg ("missing vlan_id");
9438 M (CREATE_VLAN_SUBIF, mp);
9440 mp->sw_if_index = ntohl (sw_if_index);
9441 mp->vlan_id = ntohl (vlan_id);
9448 #define foreach_create_subif_bit \
9455 _(outer_vlan_id_any) \
9456 _(inner_vlan_id_any)
9459 api_create_subif (vat_main_t * vam)
9461 unformat_input_t *i = vam->input;
9462 vl_api_create_subif_t *mp;
9464 u8 sw_if_index_set = 0;
9471 u32 exact_match = 0;
9472 u32 default_sub = 0;
9473 u32 outer_vlan_id_any = 0;
9474 u32 inner_vlan_id_any = 0;
9476 u16 outer_vlan_id = 0;
9477 u16 inner_vlan_id = 0;
9480 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9482 if (unformat (i, "sw_if_index %d", &sw_if_index))
9483 sw_if_index_set = 1;
9485 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9486 sw_if_index_set = 1;
9487 else if (unformat (i, "sub_id %d", &sub_id))
9489 else if (unformat (i, "outer_vlan_id %d", &tmp))
9490 outer_vlan_id = tmp;
9491 else if (unformat (i, "inner_vlan_id %d", &tmp))
9492 inner_vlan_id = tmp;
9494 #define _(a) else if (unformat (i, #a)) a = 1 ;
9495 foreach_create_subif_bit
9499 clib_warning ("parse error '%U'", format_unformat_error, i);
9504 if (sw_if_index_set == 0)
9506 errmsg ("missing interface name or sw_if_index");
9510 if (sub_id_set == 0)
9512 errmsg ("missing sub_id");
9515 M (CREATE_SUBIF, mp);
9517 mp->sw_if_index = ntohl (sw_if_index);
9518 mp->sub_id = ntohl (sub_id);
9520 #define _(a) mp->a = a;
9521 foreach_create_subif_bit;
9524 mp->outer_vlan_id = ntohs (outer_vlan_id);
9525 mp->inner_vlan_id = ntohs (inner_vlan_id);
9533 api_oam_add_del (vat_main_t * vam)
9535 unformat_input_t *i = vam->input;
9536 vl_api_oam_add_del_t *mp;
9539 ip4_address_t src, dst;
9544 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9546 if (unformat (i, "vrf %d", &vrf_id))
9548 else if (unformat (i, "src %U", unformat_ip4_address, &src))
9550 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
9552 else if (unformat (i, "del"))
9556 clib_warning ("parse error '%U'", format_unformat_error, i);
9563 errmsg ("missing src addr");
9569 errmsg ("missing dst addr");
9573 M (OAM_ADD_DEL, mp);
9575 mp->vrf_id = ntohl (vrf_id);
9576 mp->is_add = is_add;
9577 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
9578 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
9586 api_reset_fib (vat_main_t * vam)
9588 unformat_input_t *i = vam->input;
9589 vl_api_reset_fib_t *mp;
9595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9597 if (unformat (i, "vrf %d", &vrf_id))
9599 else if (unformat (i, "ipv6"))
9603 clib_warning ("parse error '%U'", format_unformat_error, i);
9608 if (vrf_id_set == 0)
9610 errmsg ("missing vrf id");
9616 mp->vrf_id = ntohl (vrf_id);
9617 mp->is_ipv6 = is_ipv6;
9625 api_dhcp_proxy_config (vat_main_t * vam)
9627 unformat_input_t *i = vam->input;
9628 vl_api_dhcp_proxy_config_t *mp;
9630 u32 server_vrf_id = 0;
9632 u8 v4_address_set = 0;
9633 u8 v6_address_set = 0;
9634 ip4_address_t v4address;
9635 ip6_address_t v6address;
9636 u8 v4_src_address_set = 0;
9637 u8 v6_src_address_set = 0;
9638 ip4_address_t v4srcaddress;
9639 ip6_address_t v6srcaddress;
9642 /* Parse args required to build the message */
9643 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9645 if (unformat (i, "del"))
9647 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
9649 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
9651 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
9653 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
9655 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
9656 v4_src_address_set = 1;
9657 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
9658 v6_src_address_set = 1;
9663 if (v4_address_set && v6_address_set)
9665 errmsg ("both v4 and v6 server addresses set");
9668 if (!v4_address_set && !v6_address_set)
9670 errmsg ("no server addresses set");
9674 if (v4_src_address_set && v6_src_address_set)
9676 errmsg ("both v4 and v6 src addresses set");
9679 if (!v4_src_address_set && !v6_src_address_set)
9681 errmsg ("no src addresses set");
9685 if (!(v4_src_address_set && v4_address_set) &&
9686 !(v6_src_address_set && v6_address_set))
9688 errmsg ("no matching server and src addresses set");
9692 /* Construct the API message */
9693 M (DHCP_PROXY_CONFIG, mp);
9695 mp->is_add = is_add;
9696 mp->rx_vrf_id = ntohl (rx_vrf_id);
9697 mp->server_vrf_id = ntohl (server_vrf_id);
9701 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
9702 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
9706 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
9707 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
9713 /* Wait for a reply, return good/bad news */
9718 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
9719 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
9722 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
9724 vat_main_t *vam = &vat_main;
9725 u32 i, count = mp->count;
9726 vl_api_dhcp_server_t *s;
9730 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9731 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9732 ntohl (mp->rx_vrf_id),
9733 format_ip6_address, mp->dhcp_src_address,
9734 mp->vss_type, mp->vss_vpn_ascii_id,
9735 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9738 "RX Table-ID %d, Source Address %U, VSS Type %d, "
9739 "VSS ASCII VPN-ID '%s', VSS RFC2685 VPN-ID (oui:id) %d:%d",
9740 ntohl (mp->rx_vrf_id),
9741 format_ip4_address, mp->dhcp_src_address,
9742 mp->vss_type, mp->vss_vpn_ascii_id,
9743 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
9745 for (i = 0; i < count; i++)
9747 s = &mp->servers[i];
9751 " Server Table-ID %d, Server Address %U",
9752 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
9755 " Server Table-ID %d, Server Address %U",
9756 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
9760 static void vl_api_dhcp_proxy_details_t_handler_json
9761 (vl_api_dhcp_proxy_details_t * mp)
9763 vat_main_t *vam = &vat_main;
9764 vat_json_node_t *node = NULL;
9765 u32 i, count = mp->count;
9767 struct in6_addr ip6;
9768 vl_api_dhcp_server_t *s;
9770 if (VAT_JSON_ARRAY != vam->json_tree.type)
9772 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9773 vat_json_init_array (&vam->json_tree);
9775 node = vat_json_array_add (&vam->json_tree);
9777 vat_json_init_object (node);
9778 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
9779 vat_json_object_add_bytes (node, "vss-type", &mp->vss_type,
9780 sizeof (mp->vss_type));
9781 vat_json_object_add_string_copy (node, "vss-vpn-ascii-id",
9782 mp->vss_vpn_ascii_id);
9783 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
9784 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
9788 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
9789 vat_json_object_add_ip6 (node, "src_address", ip6);
9793 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
9794 vat_json_object_add_ip4 (node, "src_address", ip4);
9797 for (i = 0; i < count; i++)
9799 s = &mp->servers[i];
9801 vat_json_object_add_uint (node, "server-table-id",
9802 ntohl (s->server_vrf_id));
9806 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
9807 vat_json_object_add_ip4 (node, "src_address", ip4);
9811 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
9812 vat_json_object_add_ip6 (node, "server_address", ip6);
9818 api_dhcp_proxy_dump (vat_main_t * vam)
9820 unformat_input_t *i = vam->input;
9821 vl_api_control_ping_t *mp_ping;
9822 vl_api_dhcp_proxy_dump_t *mp;
9826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9828 if (unformat (i, "ipv6"))
9832 clib_warning ("parse error '%U'", format_unformat_error, i);
9837 M (DHCP_PROXY_DUMP, mp);
9839 mp->is_ip6 = is_ipv6;
9842 /* Use a control ping for synchronization */
9843 MPING (CONTROL_PING, mp_ping);
9851 api_dhcp_proxy_set_vss (vat_main_t * vam)
9853 unformat_input_t *i = vam->input;
9854 vl_api_dhcp_proxy_set_vss_t *mp;
9858 u8 vss_type = VSS_TYPE_DEFAULT;
9859 u8 *vpn_ascii_id = 0;
9864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9866 if (unformat (i, "tbl_id %d", &tbl_id))
9868 else if (unformat (i, "vpn_ascii_id %s", &vpn_ascii_id))
9869 vss_type = VSS_TYPE_ASCII;
9870 else if (unformat (i, "fib_id %d", &fib_id))
9871 vss_type = VSS_TYPE_VPN_ID;
9872 else if (unformat (i, "oui %d", &oui))
9873 vss_type = VSS_TYPE_VPN_ID;
9874 else if (unformat (i, "ipv6"))
9876 else if (unformat (i, "del"))
9884 errmsg ("missing tbl_id ");
9885 vec_free (vpn_ascii_id);
9889 if ((vpn_ascii_id) && (vec_len (vpn_ascii_id) > 128))
9891 errmsg ("vpn_ascii_id cannot be longer than 128 ");
9892 vec_free (vpn_ascii_id);
9896 M (DHCP_PROXY_SET_VSS, mp);
9897 mp->tbl_id = ntohl (tbl_id);
9898 mp->vss_type = vss_type;
9901 clib_memcpy (mp->vpn_ascii_id, vpn_ascii_id, vec_len (vpn_ascii_id));
9902 mp->vpn_ascii_id[vec_len (vpn_ascii_id)] = 0;
9904 mp->vpn_index = ntohl (fib_id);
9905 mp->oui = ntohl (oui);
9906 mp->is_ipv6 = is_ipv6;
9907 mp->is_add = is_add;
9912 vec_free (vpn_ascii_id);
9917 api_dhcp_client_config (vat_main_t * vam)
9919 unformat_input_t *i = vam->input;
9920 vl_api_dhcp_client_config_t *mp;
9922 u8 sw_if_index_set = 0;
9925 u8 disable_event = 0;
9928 /* Parse args required to build the message */
9929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9931 if (unformat (i, "del"))
9934 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9935 sw_if_index_set = 1;
9936 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9937 sw_if_index_set = 1;
9938 else if (unformat (i, "hostname %s", &hostname))
9940 else if (unformat (i, "disable_event"))
9946 if (sw_if_index_set == 0)
9948 errmsg ("missing interface name or sw_if_index");
9952 if (vec_len (hostname) > 63)
9954 errmsg ("hostname too long");
9956 vec_add1 (hostname, 0);
9958 /* Construct the API message */
9959 M (DHCP_CLIENT_CONFIG, mp);
9961 mp->is_add = is_add;
9962 mp->client.sw_if_index = htonl (sw_if_index);
9963 clib_memcpy (mp->client.hostname, hostname, vec_len (hostname));
9964 vec_free (hostname);
9965 mp->client.want_dhcp_event = disable_event ? 0 : 1;
9966 mp->client.pid = htonl (getpid ());
9971 /* Wait for a reply, return good/bad news */
9977 api_set_ip_flow_hash (vat_main_t * vam)
9979 unformat_input_t *i = vam->input;
9980 vl_api_set_ip_flow_hash_t *mp;
9992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9994 if (unformat (i, "vrf %d", &vrf_id))
9996 else if (unformat (i, "ipv6"))
9998 else if (unformat (i, "src"))
10000 else if (unformat (i, "dst"))
10002 else if (unformat (i, "sport"))
10004 else if (unformat (i, "dport"))
10006 else if (unformat (i, "proto"))
10008 else if (unformat (i, "reverse"))
10013 clib_warning ("parse error '%U'", format_unformat_error, i);
10018 if (vrf_id_set == 0)
10020 errmsg ("missing vrf id");
10024 M (SET_IP_FLOW_HASH, mp);
10030 mp->reverse = reverse;
10031 mp->vrf_id = ntohl (vrf_id);
10032 mp->is_ipv6 = is_ipv6;
10040 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
10042 unformat_input_t *i = vam->input;
10043 vl_api_sw_interface_ip6_enable_disable_t *mp;
10045 u8 sw_if_index_set = 0;
10049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10051 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10052 sw_if_index_set = 1;
10053 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10054 sw_if_index_set = 1;
10055 else if (unformat (i, "enable"))
10057 else if (unformat (i, "disable"))
10061 clib_warning ("parse error '%U'", format_unformat_error, i);
10066 if (sw_if_index_set == 0)
10068 errmsg ("missing interface name or sw_if_index");
10072 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
10074 mp->sw_if_index = ntohl (sw_if_index);
10075 mp->enable = enable;
10083 api_ip6nd_proxy_add_del (vat_main_t * vam)
10085 unformat_input_t *i = vam->input;
10086 vl_api_ip6nd_proxy_add_del_t *mp;
10087 u32 sw_if_index = ~0;
10088 u8 v6_address_set = 0;
10089 vl_api_ip6_address_t v6address;
10093 /* Parse args required to build the message */
10094 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10096 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10098 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10100 else if (unformat (i, "%U", unformat_vl_api_ip6_address, &v6address))
10101 v6_address_set = 1;
10102 if (unformat (i, "del"))
10106 clib_warning ("parse error '%U'", format_unformat_error, i);
10111 if (sw_if_index == ~0)
10113 errmsg ("missing interface name or sw_if_index");
10116 if (!v6_address_set)
10118 errmsg ("no address set");
10122 /* Construct the API message */
10123 M (IP6ND_PROXY_ADD_DEL, mp);
10125 mp->is_del = is_del;
10126 mp->sw_if_index = ntohl (sw_if_index);
10127 clib_memcpy (mp->ip, v6address, sizeof (v6address));
10132 /* Wait for a reply, return good/bad news */
10138 api_ip6nd_proxy_dump (vat_main_t * vam)
10140 vl_api_ip6nd_proxy_dump_t *mp;
10141 vl_api_control_ping_t *mp_ping;
10144 M (IP6ND_PROXY_DUMP, mp);
10148 /* Use a control ping for synchronization */
10149 MPING (CONTROL_PING, mp_ping);
10156 static void vl_api_ip6nd_proxy_details_t_handler
10157 (vl_api_ip6nd_proxy_details_t * mp)
10159 vat_main_t *vam = &vat_main;
10161 print (vam->ofp, "host %U sw_if_index %d",
10162 format_vl_api_ip6_address, mp->ip, ntohl (mp->sw_if_index));
10165 static void vl_api_ip6nd_proxy_details_t_handler_json
10166 (vl_api_ip6nd_proxy_details_t * mp)
10168 vat_main_t *vam = &vat_main;
10169 struct in6_addr ip6;
10170 vat_json_node_t *node = NULL;
10172 if (VAT_JSON_ARRAY != vam->json_tree.type)
10174 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10175 vat_json_init_array (&vam->json_tree);
10177 node = vat_json_array_add (&vam->json_tree);
10179 vat_json_init_object (node);
10180 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10182 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
10183 vat_json_object_add_ip6 (node, "host", ip6);
10187 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
10189 unformat_input_t *i = vam->input;
10190 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
10192 u8 sw_if_index_set = 0;
10193 u32 address_length = 0;
10194 u8 v6_address_set = 0;
10195 vl_api_prefix_t pfx;
10196 u8 use_default = 0;
10197 u8 no_advertise = 0;
10199 u8 no_autoconfig = 0;
10202 u32 val_lifetime = 0;
10203 u32 pref_lifetime = 0;
10206 /* Parse args required to build the message */
10207 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10209 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10210 sw_if_index_set = 1;
10211 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10212 sw_if_index_set = 1;
10213 else if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
10214 v6_address_set = 1;
10215 else if (unformat (i, "val_life %d", &val_lifetime))
10217 else if (unformat (i, "pref_life %d", &pref_lifetime))
10219 else if (unformat (i, "def"))
10221 else if (unformat (i, "noadv"))
10223 else if (unformat (i, "offl"))
10225 else if (unformat (i, "noauto"))
10227 else if (unformat (i, "nolink"))
10229 else if (unformat (i, "isno"))
10233 clib_warning ("parse error '%U'", format_unformat_error, i);
10238 if (sw_if_index_set == 0)
10240 errmsg ("missing interface name or sw_if_index");
10243 if (!v6_address_set)
10245 errmsg ("no address set");
10249 /* Construct the API message */
10250 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
10252 mp->sw_if_index = ntohl (sw_if_index);
10253 clib_memcpy (&mp->prefix, &pfx, sizeof (pfx));
10254 mp->use_default = use_default;
10255 mp->no_advertise = no_advertise;
10256 mp->off_link = off_link;
10257 mp->no_autoconfig = no_autoconfig;
10258 mp->no_onlink = no_onlink;
10260 mp->val_lifetime = ntohl (val_lifetime);
10261 mp->pref_lifetime = ntohl (pref_lifetime);
10266 /* Wait for a reply, return good/bad news */
10272 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
10274 unformat_input_t *i = vam->input;
10275 vl_api_sw_interface_ip6nd_ra_config_t *mp;
10277 u8 sw_if_index_set = 0;
10282 u8 send_unicast = 0;
10285 u8 default_router = 0;
10286 u32 max_interval = 0;
10287 u32 min_interval = 0;
10289 u32 initial_count = 0;
10290 u32 initial_interval = 0;
10294 /* Parse args required to build the message */
10295 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10297 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10298 sw_if_index_set = 1;
10299 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10300 sw_if_index_set = 1;
10301 else if (unformat (i, "maxint %d", &max_interval))
10303 else if (unformat (i, "minint %d", &min_interval))
10305 else if (unformat (i, "life %d", &lifetime))
10307 else if (unformat (i, "count %d", &initial_count))
10309 else if (unformat (i, "interval %d", &initial_interval))
10311 else if (unformat (i, "suppress") || unformat (i, "surpress"))
10313 else if (unformat (i, "managed"))
10315 else if (unformat (i, "other"))
10317 else if (unformat (i, "ll"))
10319 else if (unformat (i, "send"))
10321 else if (unformat (i, "cease"))
10323 else if (unformat (i, "isno"))
10325 else if (unformat (i, "def"))
10326 default_router = 1;
10329 clib_warning ("parse error '%U'", format_unformat_error, i);
10334 if (sw_if_index_set == 0)
10336 errmsg ("missing interface name or sw_if_index");
10340 /* Construct the API message */
10341 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
10343 mp->sw_if_index = ntohl (sw_if_index);
10344 mp->max_interval = ntohl (max_interval);
10345 mp->min_interval = ntohl (min_interval);
10346 mp->lifetime = ntohl (lifetime);
10347 mp->initial_count = ntohl (initial_count);
10348 mp->initial_interval = ntohl (initial_interval);
10349 mp->suppress = suppress;
10350 mp->managed = managed;
10352 mp->ll_option = ll_option;
10353 mp->send_unicast = send_unicast;
10356 mp->default_router = default_router;
10361 /* Wait for a reply, return good/bad news */
10367 api_set_arp_neighbor_limit (vat_main_t * vam)
10369 unformat_input_t *i = vam->input;
10370 vl_api_set_arp_neighbor_limit_t *mp;
10376 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10378 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
10380 else if (unformat (i, "ipv6"))
10384 clib_warning ("parse error '%U'", format_unformat_error, i);
10389 if (limit_set == 0)
10391 errmsg ("missing limit value");
10395 M (SET_ARP_NEIGHBOR_LIMIT, mp);
10397 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
10398 mp->is_ipv6 = is_ipv6;
10406 api_l2_patch_add_del (vat_main_t * vam)
10408 unformat_input_t *i = vam->input;
10409 vl_api_l2_patch_add_del_t *mp;
10410 u32 rx_sw_if_index;
10411 u8 rx_sw_if_index_set = 0;
10412 u32 tx_sw_if_index;
10413 u8 tx_sw_if_index_set = 0;
10417 /* Parse args required to build the message */
10418 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10420 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
10421 rx_sw_if_index_set = 1;
10422 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
10423 tx_sw_if_index_set = 1;
10424 else if (unformat (i, "rx"))
10426 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10428 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10430 rx_sw_if_index_set = 1;
10435 else if (unformat (i, "tx"))
10437 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10439 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
10441 tx_sw_if_index_set = 1;
10446 else if (unformat (i, "del"))
10452 if (rx_sw_if_index_set == 0)
10454 errmsg ("missing rx interface name or rx_sw_if_index");
10458 if (tx_sw_if_index_set == 0)
10460 errmsg ("missing tx interface name or tx_sw_if_index");
10464 M (L2_PATCH_ADD_DEL, mp);
10466 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
10467 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
10468 mp->is_add = is_add;
10476 u8 localsid_addr[16];
10485 api_sr_localsid_add_del (vat_main_t * vam)
10487 unformat_input_t *i = vam->input;
10488 vl_api_sr_localsid_add_del_t *mp;
10491 ip6_address_t localsid;
10495 u32 fib_table = ~(u32) 0;
10496 ip6_address_t nh_addr6;
10497 ip4_address_t nh_addr4;
10498 clib_memset (&nh_addr6, 0, sizeof (ip6_address_t));
10499 clib_memset (&nh_addr4, 0, sizeof (ip4_address_t));
10501 bool nexthop_set = 0;
10505 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10507 if (unformat (i, "del"))
10509 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
10510 else if (unformat (i, "next-hop %U", unformat_ip4_address, &nh_addr4))
10512 else if (unformat (i, "next-hop %U", unformat_ip6_address, &nh_addr6))
10514 else if (unformat (i, "behavior %u", &behavior));
10515 else if (unformat (i, "sw_if_index %u", &sw_if_index));
10516 else if (unformat (i, "fib-table %u", &fib_table));
10517 else if (unformat (i, "end.psp %u", &behavior));
10522 M (SR_LOCALSID_ADD_DEL, mp);
10524 clib_memcpy (mp->localsid.addr, &localsid, sizeof (mp->localsid));
10527 clib_memcpy (mp->nh_addr6, &nh_addr6, sizeof (mp->nh_addr6));
10528 clib_memcpy (mp->nh_addr4, &nh_addr4, sizeof (mp->nh_addr4));
10530 mp->behavior = behavior;
10531 mp->sw_if_index = ntohl (sw_if_index);
10532 mp->fib_table = ntohl (fib_table);
10533 mp->end_psp = end_psp;
10534 mp->is_del = is_del;
10542 api_ioam_enable (vat_main_t * vam)
10544 unformat_input_t *input = vam->input;
10545 vl_api_ioam_enable_t *mp;
10547 int has_trace_option = 0;
10548 int has_pot_option = 0;
10549 int has_seqno_option = 0;
10550 int has_analyse_option = 0;
10553 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10555 if (unformat (input, "trace"))
10556 has_trace_option = 1;
10557 else if (unformat (input, "pot"))
10558 has_pot_option = 1;
10559 else if (unformat (input, "seqno"))
10560 has_seqno_option = 1;
10561 else if (unformat (input, "analyse"))
10562 has_analyse_option = 1;
10566 M (IOAM_ENABLE, mp);
10567 mp->id = htons (id);
10568 mp->seqno = has_seqno_option;
10569 mp->analyse = has_analyse_option;
10570 mp->pot_enable = has_pot_option;
10571 mp->trace_enable = has_trace_option;
10580 api_ioam_disable (vat_main_t * vam)
10582 vl_api_ioam_disable_t *mp;
10585 M (IOAM_DISABLE, mp);
10591 #define foreach_tcp_proto_field \
10595 #define foreach_udp_proto_field \
10599 #define foreach_ip4_proto_field \
10611 u16 src_port, dst_port;
10614 #if VPP_API_TEST_BUILTIN == 0
10616 unformat_tcp_mask (unformat_input_t * input, va_list * args)
10618 u8 **maskp = va_arg (*args, u8 **);
10620 u8 found_something = 0;
10623 #define _(a) u8 a=0;
10624 foreach_tcp_proto_field;
10627 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10630 #define _(a) else if (unformat (input, #a)) a=1;
10631 foreach_tcp_proto_field
10637 #define _(a) found_something += a;
10638 foreach_tcp_proto_field;
10641 if (found_something == 0)
10644 vec_validate (mask, sizeof (*tcp) - 1);
10646 tcp = (tcp_header_t *) mask;
10648 #define _(a) if (a) clib_memset (&tcp->a, 0xff, sizeof (tcp->a));
10649 foreach_tcp_proto_field;
10657 unformat_udp_mask (unformat_input_t * input, va_list * args)
10659 u8 **maskp = va_arg (*args, u8 **);
10661 u8 found_something = 0;
10664 #define _(a) u8 a=0;
10665 foreach_udp_proto_field;
10668 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10671 #define _(a) else if (unformat (input, #a)) a=1;
10672 foreach_udp_proto_field
10678 #define _(a) found_something += a;
10679 foreach_udp_proto_field;
10682 if (found_something == 0)
10685 vec_validate (mask, sizeof (*udp) - 1);
10687 udp = (udp_header_t *) mask;
10689 #define _(a) if (a) clib_memset (&udp->a, 0xff, sizeof (udp->a));
10690 foreach_udp_proto_field;
10698 unformat_l4_mask (unformat_input_t * input, va_list * args)
10700 u8 **maskp = va_arg (*args, u8 **);
10701 u16 src_port = 0, dst_port = 0;
10702 tcpudp_header_t *tcpudp;
10704 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10706 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
10708 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
10710 else if (unformat (input, "src_port"))
10712 else if (unformat (input, "dst_port"))
10718 if (!src_port && !dst_port)
10722 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
10724 tcpudp = (tcpudp_header_t *) mask;
10725 tcpudp->src_port = src_port;
10726 tcpudp->dst_port = dst_port;
10734 unformat_ip4_mask (unformat_input_t * input, va_list * args)
10736 u8 **maskp = va_arg (*args, u8 **);
10738 u8 found_something = 0;
10741 #define _(a) u8 a=0;
10742 foreach_ip4_proto_field;
10748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10750 if (unformat (input, "version"))
10752 else if (unformat (input, "hdr_length"))
10754 else if (unformat (input, "src"))
10756 else if (unformat (input, "dst"))
10758 else if (unformat (input, "proto"))
10761 #define _(a) else if (unformat (input, #a)) a=1;
10762 foreach_ip4_proto_field
10768 #define _(a) found_something += a;
10769 foreach_ip4_proto_field;
10772 if (found_something == 0)
10775 vec_validate (mask, sizeof (*ip) - 1);
10777 ip = (ip4_header_t *) mask;
10779 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10780 foreach_ip4_proto_field;
10783 ip->ip_version_and_header_length = 0;
10786 ip->ip_version_and_header_length |= 0xF0;
10789 ip->ip_version_and_header_length |= 0x0F;
10795 #define foreach_ip6_proto_field \
10798 _(payload_length) \
10803 unformat_ip6_mask (unformat_input_t * input, va_list * args)
10805 u8 **maskp = va_arg (*args, u8 **);
10807 u8 found_something = 0;
10809 u32 ip_version_traffic_class_and_flow_label;
10811 #define _(a) u8 a=0;
10812 foreach_ip6_proto_field;
10815 u8 traffic_class = 0;
10818 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10820 if (unformat (input, "version"))
10822 else if (unformat (input, "traffic-class"))
10824 else if (unformat (input, "flow-label"))
10826 else if (unformat (input, "src"))
10828 else if (unformat (input, "dst"))
10830 else if (unformat (input, "proto"))
10833 #define _(a) else if (unformat (input, #a)) a=1;
10834 foreach_ip6_proto_field
10840 #define _(a) found_something += a;
10841 foreach_ip6_proto_field;
10844 if (found_something == 0)
10847 vec_validate (mask, sizeof (*ip) - 1);
10849 ip = (ip6_header_t *) mask;
10851 #define _(a) if (a) clib_memset (&ip->a, 0xff, sizeof (ip->a));
10852 foreach_ip6_proto_field;
10855 ip_version_traffic_class_and_flow_label = 0;
10858 ip_version_traffic_class_and_flow_label |= 0xF0000000;
10861 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
10864 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
10866 ip->ip_version_traffic_class_and_flow_label =
10867 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10874 unformat_l3_mask (unformat_input_t * input, va_list * args)
10876 u8 **maskp = va_arg (*args, u8 **);
10878 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10880 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
10882 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
10891 unformat_l2_mask (unformat_input_t * input, va_list * args)
10893 u8 **maskp = va_arg (*args, u8 **);
10900 u8 ignore_tag1 = 0;
10901 u8 ignore_tag2 = 0;
10908 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10910 if (unformat (input, "src"))
10912 else if (unformat (input, "dst"))
10914 else if (unformat (input, "proto"))
10916 else if (unformat (input, "tag1"))
10918 else if (unformat (input, "tag2"))
10920 else if (unformat (input, "ignore-tag1"))
10922 else if (unformat (input, "ignore-tag2"))
10924 else if (unformat (input, "cos1"))
10926 else if (unformat (input, "cos2"))
10928 else if (unformat (input, "dot1q"))
10930 else if (unformat (input, "dot1ad"))
10935 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
10936 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10939 if (tag1 || ignore_tag1 || cos1 || dot1q)
10941 if (tag2 || ignore_tag2 || cos2 || dot1ad)
10944 vec_validate (mask, len - 1);
10947 clib_memset (mask, 0xff, 6);
10950 clib_memset (mask + 6, 0xff, 6);
10952 if (tag2 || dot1ad)
10954 /* inner vlan tag */
10963 mask[21] = mask[20] = 0xff;
10984 mask[16] = mask[17] = 0xff;
10994 mask[12] = mask[13] = 0xff;
11001 unformat_classify_mask (unformat_input_t * input, va_list * args)
11003 u8 **maskp = va_arg (*args, u8 **);
11004 u32 *skipp = va_arg (*args, u32 *);
11005 u32 *matchp = va_arg (*args, u32 *);
11013 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11015 if (unformat (input, "hex %U", unformat_hex_string, &mask))
11017 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
11019 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
11021 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
11035 if (mask || l2 || l3 || l4)
11037 if (l2 || l3 || l4)
11039 /* "With a free Ethernet header in every package" */
11041 vec_validate (l2, 13);
11045 vec_append (mask, l3);
11050 vec_append (mask, l4);
11055 /* Scan forward looking for the first significant mask octet */
11056 for (i = 0; i < vec_len (mask); i++)
11060 /* compute (skip, match) params */
11061 *skipp = i / sizeof (u32x4);
11062 vec_delete (mask, *skipp * sizeof (u32x4), 0);
11064 /* Pad mask to an even multiple of the vector size */
11065 while (vec_len (mask) % sizeof (u32x4))
11066 vec_add1 (mask, 0);
11068 match = vec_len (mask) / sizeof (u32x4);
11070 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
11072 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
11073 if (*tmp || *(tmp + 1))
11078 clib_warning ("BUG: match 0");
11080 _vec_len (mask) = match * sizeof (u32x4);
11090 #endif /* VPP_API_TEST_BUILTIN */
11092 #define foreach_l2_next \
11094 _(ethernet, ETHERNET_INPUT) \
11095 _(ip4, IP4_INPUT) \
11099 unformat_l2_next_index (unformat_input_t * input, va_list * args)
11101 u32 *miss_next_indexp = va_arg (*args, u32 *);
11102 u32 next_index = 0;
11106 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
11110 if (unformat (input, "%d", &tmp))
11119 *miss_next_indexp = next_index;
11123 #define foreach_ip_next \
11126 _(rewrite, REWRITE)
11129 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
11131 u32 *miss_next_indexp = va_arg (*args, u32 *);
11132 u32 next_index = 0;
11136 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
11140 if (unformat (input, "%d", &tmp))
11149 *miss_next_indexp = next_index;
11153 #define foreach_acl_next \
11157 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
11159 u32 *miss_next_indexp = va_arg (*args, u32 *);
11160 u32 next_index = 0;
11164 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
11168 if (unformat (input, "permit"))
11173 else if (unformat (input, "%d", &tmp))
11182 *miss_next_indexp = next_index;
11187 unformat_policer_precolor (unformat_input_t * input, va_list * args)
11189 u32 *r = va_arg (*args, u32 *);
11191 if (unformat (input, "conform-color"))
11192 *r = POLICE_CONFORM;
11193 else if (unformat (input, "exceed-color"))
11194 *r = POLICE_EXCEED;
11202 api_classify_add_del_table (vat_main_t * vam)
11204 unformat_input_t *i = vam->input;
11205 vl_api_classify_add_del_table_t *mp;
11212 u32 table_index = ~0;
11213 u32 next_table_index = ~0;
11214 u32 miss_next_index = ~0;
11215 u32 memory_size = 32 << 20;
11217 u32 current_data_flag = 0;
11218 int current_data_offset = 0;
11221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11223 if (unformat (i, "del"))
11225 else if (unformat (i, "del-chain"))
11230 else if (unformat (i, "buckets %d", &nbuckets))
11232 else if (unformat (i, "memory_size %d", &memory_size))
11234 else if (unformat (i, "skip %d", &skip))
11236 else if (unformat (i, "match %d", &match))
11238 else if (unformat (i, "table %d", &table_index))
11240 else if (unformat (i, "mask %U", unformat_classify_mask,
11241 &mask, &skip, &match))
11243 else if (unformat (i, "next-table %d", &next_table_index))
11245 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
11248 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
11251 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
11254 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
11256 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
11262 if (is_add && mask == 0)
11264 errmsg ("Mask required");
11268 if (is_add && skip == ~0)
11270 errmsg ("skip count required");
11274 if (is_add && match == ~0)
11276 errmsg ("match count required");
11280 if (!is_add && table_index == ~0)
11282 errmsg ("table index required for delete");
11286 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
11288 mp->is_add = is_add;
11289 mp->del_chain = del_chain;
11290 mp->table_index = ntohl (table_index);
11291 mp->nbuckets = ntohl (nbuckets);
11292 mp->memory_size = ntohl (memory_size);
11293 mp->skip_n_vectors = ntohl (skip);
11294 mp->match_n_vectors = ntohl (match);
11295 mp->next_table_index = ntohl (next_table_index);
11296 mp->miss_next_index = ntohl (miss_next_index);
11297 mp->current_data_flag = ntohl (current_data_flag);
11298 mp->current_data_offset = ntohl (current_data_offset);
11299 mp->mask_len = ntohl (vec_len (mask));
11300 clib_memcpy (mp->mask, mask, vec_len (mask));
11309 #if VPP_API_TEST_BUILTIN == 0
11311 unformat_l4_match (unformat_input_t * input, va_list * args)
11313 u8 **matchp = va_arg (*args, u8 **);
11315 u8 *proto_header = 0;
11321 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11323 if (unformat (input, "src_port %d", &src_port))
11325 else if (unformat (input, "dst_port %d", &dst_port))
11331 h.src_port = clib_host_to_net_u16 (src_port);
11332 h.dst_port = clib_host_to_net_u16 (dst_port);
11333 vec_validate (proto_header, sizeof (h) - 1);
11334 memcpy (proto_header, &h, sizeof (h));
11336 *matchp = proto_header;
11342 unformat_ip4_match (unformat_input_t * input, va_list * args)
11344 u8 **matchp = va_arg (*args, u8 **);
11349 int hdr_length = 0;
11350 u32 hdr_length_val;
11351 int src = 0, dst = 0;
11352 ip4_address_t src_val, dst_val;
11359 int fragment_id = 0;
11360 u32 fragment_id_val;
11366 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11368 if (unformat (input, "version %d", &version_val))
11370 else if (unformat (input, "hdr_length %d", &hdr_length_val))
11372 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
11374 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
11376 else if (unformat (input, "proto %d", &proto_val))
11378 else if (unformat (input, "tos %d", &tos_val))
11380 else if (unformat (input, "length %d", &length_val))
11382 else if (unformat (input, "fragment_id %d", &fragment_id_val))
11384 else if (unformat (input, "ttl %d", &ttl_val))
11386 else if (unformat (input, "checksum %d", &checksum_val))
11392 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
11393 + ttl + checksum == 0)
11397 * Aligned because we use the real comparison functions
11399 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11401 ip = (ip4_header_t *) match;
11403 /* These are realistically matched in practice */
11405 ip->src_address.as_u32 = src_val.as_u32;
11408 ip->dst_address.as_u32 = dst_val.as_u32;
11411 ip->protocol = proto_val;
11414 /* These are not, but they're included for completeness */
11416 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
11419 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
11425 ip->length = clib_host_to_net_u16 (length_val);
11431 ip->checksum = clib_host_to_net_u16 (checksum_val);
11438 unformat_ip6_match (unformat_input_t * input, va_list * args)
11440 u8 **matchp = va_arg (*args, u8 **);
11445 u8 traffic_class = 0;
11446 u32 traffic_class_val = 0;
11449 int src = 0, dst = 0;
11450 ip6_address_t src_val, dst_val;
11453 int payload_length = 0;
11454 u32 payload_length_val;
11457 u32 ip_version_traffic_class_and_flow_label;
11459 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11461 if (unformat (input, "version %d", &version_val))
11463 else if (unformat (input, "traffic_class %d", &traffic_class_val))
11465 else if (unformat (input, "flow_label %d", &flow_label_val))
11467 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
11469 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
11471 else if (unformat (input, "proto %d", &proto_val))
11473 else if (unformat (input, "payload_length %d", &payload_length_val))
11474 payload_length = 1;
11475 else if (unformat (input, "hop_limit %d", &hop_limit_val))
11481 if (version + traffic_class + flow_label + src + dst + proto +
11482 payload_length + hop_limit == 0)
11486 * Aligned because we use the real comparison functions
11488 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
11490 ip = (ip6_header_t *) match;
11493 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
11496 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
11499 ip->protocol = proto_val;
11501 ip_version_traffic_class_and_flow_label = 0;
11504 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
11507 ip_version_traffic_class_and_flow_label |=
11508 (traffic_class_val & 0xFF) << 20;
11511 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
11513 ip->ip_version_traffic_class_and_flow_label =
11514 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
11516 if (payload_length)
11517 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
11520 ip->hop_limit = hop_limit_val;
11527 unformat_l3_match (unformat_input_t * input, va_list * args)
11529 u8 **matchp = va_arg (*args, u8 **);
11531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11533 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
11535 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
11544 unformat_vlan_tag (unformat_input_t * input, va_list * args)
11546 u8 *tagp = va_arg (*args, u8 *);
11549 if (unformat (input, "%d", &tag))
11551 tagp[0] = (tag >> 8) & 0x0F;
11552 tagp[1] = tag & 0xFF;
11560 unformat_l2_match (unformat_input_t * input, va_list * args)
11562 u8 **matchp = va_arg (*args, u8 **);
11575 u8 ignore_tag1 = 0;
11576 u8 ignore_tag2 = 0;
11582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11584 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
11587 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
11589 else if (unformat (input, "proto %U",
11590 unformat_ethernet_type_host_byte_order, &proto_val))
11592 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
11594 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
11596 else if (unformat (input, "ignore-tag1"))
11598 else if (unformat (input, "ignore-tag2"))
11600 else if (unformat (input, "cos1 %d", &cos1_val))
11602 else if (unformat (input, "cos2 %d", &cos2_val))
11607 if ((src + dst + proto + tag1 + tag2 +
11608 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
11611 if (tag1 || ignore_tag1 || cos1)
11613 if (tag2 || ignore_tag2 || cos2)
11616 vec_validate_aligned (match, len - 1, sizeof (u32x4));
11619 clib_memcpy (match, dst_val, 6);
11622 clib_memcpy (match + 6, src_val, 6);
11626 /* inner vlan tag */
11627 match[19] = tag2_val[1];
11628 match[18] = tag2_val[0];
11630 match[18] |= (cos2_val & 0x7) << 5;
11633 match[21] = proto_val & 0xff;
11634 match[20] = proto_val >> 8;
11638 match[15] = tag1_val[1];
11639 match[14] = tag1_val[0];
11642 match[14] |= (cos1_val & 0x7) << 5;
11648 match[15] = tag1_val[1];
11649 match[14] = tag1_val[0];
11652 match[17] = proto_val & 0xff;
11653 match[16] = proto_val >> 8;
11656 match[14] |= (cos1_val & 0x7) << 5;
11662 match[18] |= (cos2_val & 0x7) << 5;
11664 match[14] |= (cos1_val & 0x7) << 5;
11667 match[13] = proto_val & 0xff;
11668 match[12] = proto_val >> 8;
11676 unformat_qos_source (unformat_input_t * input, va_list * args)
11678 int *qs = va_arg (*args, int *);
11680 if (unformat (input, "ip"))
11681 *qs = QOS_SOURCE_IP;
11682 else if (unformat (input, "mpls"))
11683 *qs = QOS_SOURCE_MPLS;
11684 else if (unformat (input, "ext"))
11685 *qs = QOS_SOURCE_EXT;
11686 else if (unformat (input, "vlan"))
11687 *qs = QOS_SOURCE_VLAN;
11696 api_unformat_classify_match (unformat_input_t * input, va_list * args)
11698 u8 **matchp = va_arg (*args, u8 **);
11699 u32 skip_n_vectors = va_arg (*args, u32);
11700 u32 match_n_vectors = va_arg (*args, u32);
11707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
11709 if (unformat (input, "hex %U", unformat_hex_string, &match))
11711 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
11713 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
11715 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
11729 if (match || l2 || l3 || l4)
11731 if (l2 || l3 || l4)
11733 /* "Win a free Ethernet header in every packet" */
11735 vec_validate_aligned (l2, 13, sizeof (u32x4));
11739 vec_append_aligned (match, l3, sizeof (u32x4));
11744 vec_append_aligned (match, l4, sizeof (u32x4));
11749 /* Make sure the vector is big enough even if key is all 0's */
11750 vec_validate_aligned
11751 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
11754 /* Set size, include skipped vectors */
11755 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
11766 api_classify_add_del_session (vat_main_t * vam)
11768 unformat_input_t *i = vam->input;
11769 vl_api_classify_add_del_session_t *mp;
11771 u32 table_index = ~0;
11772 u32 hit_next_index = ~0;
11773 u32 opaque_index = ~0;
11776 u32 skip_n_vectors = 0;
11777 u32 match_n_vectors = 0;
11783 * Warning: you have to supply skip_n and match_n
11784 * because the API client cant simply look at the classify
11788 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11790 if (unformat (i, "del"))
11792 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
11795 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
11798 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
11801 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
11803 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
11805 else if (unformat (i, "opaque-index %d", &opaque_index))
11807 else if (unformat (i, "skip_n %d", &skip_n_vectors))
11809 else if (unformat (i, "match_n %d", &match_n_vectors))
11811 else if (unformat (i, "match %U", api_unformat_classify_match,
11812 &match, skip_n_vectors, match_n_vectors))
11814 else if (unformat (i, "advance %d", &advance))
11816 else if (unformat (i, "table-index %d", &table_index))
11818 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
11820 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
11822 else if (unformat (i, "action %d", &action))
11824 else if (unformat (i, "metadata %d", &metadata))
11830 if (table_index == ~0)
11832 errmsg ("Table index required");
11836 if (is_add && match == 0)
11838 errmsg ("Match value required");
11842 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
11844 mp->is_add = is_add;
11845 mp->table_index = ntohl (table_index);
11846 mp->hit_next_index = ntohl (hit_next_index);
11847 mp->opaque_index = ntohl (opaque_index);
11848 mp->advance = ntohl (advance);
11849 mp->action = action;
11850 mp->metadata = ntohl (metadata);
11851 mp->match_len = ntohl (vec_len (match));
11852 clib_memcpy (mp->match, match, vec_len (match));
11861 api_classify_set_interface_ip_table (vat_main_t * vam)
11863 unformat_input_t *i = vam->input;
11864 vl_api_classify_set_interface_ip_table_t *mp;
11866 int sw_if_index_set;
11867 u32 table_index = ~0;
11871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11873 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11874 sw_if_index_set = 1;
11875 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11876 sw_if_index_set = 1;
11877 else if (unformat (i, "table %d", &table_index))
11881 clib_warning ("parse error '%U'", format_unformat_error, i);
11886 if (sw_if_index_set == 0)
11888 errmsg ("missing interface name or sw_if_index");
11893 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
11895 mp->sw_if_index = ntohl (sw_if_index);
11896 mp->table_index = ntohl (table_index);
11897 mp->is_ipv6 = is_ipv6;
11905 api_classify_set_interface_l2_tables (vat_main_t * vam)
11907 unformat_input_t *i = vam->input;
11908 vl_api_classify_set_interface_l2_tables_t *mp;
11910 int sw_if_index_set;
11911 u32 ip4_table_index = ~0;
11912 u32 ip6_table_index = ~0;
11913 u32 other_table_index = ~0;
11917 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11919 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11920 sw_if_index_set = 1;
11921 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11922 sw_if_index_set = 1;
11923 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11925 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11927 else if (unformat (i, "other-table %d", &other_table_index))
11929 else if (unformat (i, "is-input %d", &is_input))
11933 clib_warning ("parse error '%U'", format_unformat_error, i);
11938 if (sw_if_index_set == 0)
11940 errmsg ("missing interface name or sw_if_index");
11945 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
11947 mp->sw_if_index = ntohl (sw_if_index);
11948 mp->ip4_table_index = ntohl (ip4_table_index);
11949 mp->ip6_table_index = ntohl (ip6_table_index);
11950 mp->other_table_index = ntohl (other_table_index);
11951 mp->is_input = (u8) is_input;
11959 api_set_ipfix_exporter (vat_main_t * vam)
11961 unformat_input_t *i = vam->input;
11962 vl_api_set_ipfix_exporter_t *mp;
11963 ip4_address_t collector_address;
11964 u8 collector_address_set = 0;
11965 u32 collector_port = ~0;
11966 ip4_address_t src_address;
11967 u8 src_address_set = 0;
11970 u32 template_interval = ~0;
11971 u8 udp_checksum = 0;
11974 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11976 if (unformat (i, "collector_address %U", unformat_ip4_address,
11977 &collector_address))
11978 collector_address_set = 1;
11979 else if (unformat (i, "collector_port %d", &collector_port))
11981 else if (unformat (i, "src_address %U", unformat_ip4_address,
11983 src_address_set = 1;
11984 else if (unformat (i, "vrf_id %d", &vrf_id))
11986 else if (unformat (i, "path_mtu %d", &path_mtu))
11988 else if (unformat (i, "template_interval %d", &template_interval))
11990 else if (unformat (i, "udp_checksum"))
11996 if (collector_address_set == 0)
11998 errmsg ("collector_address required");
12002 if (src_address_set == 0)
12004 errmsg ("src_address required");
12008 M (SET_IPFIX_EXPORTER, mp);
12010 memcpy (mp->collector_address, collector_address.data,
12011 sizeof (collector_address.data));
12012 mp->collector_port = htons ((u16) collector_port);
12013 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
12014 mp->vrf_id = htonl (vrf_id);
12015 mp->path_mtu = htonl (path_mtu);
12016 mp->template_interval = htonl (template_interval);
12017 mp->udp_checksum = udp_checksum;
12025 api_set_ipfix_classify_stream (vat_main_t * vam)
12027 unformat_input_t *i = vam->input;
12028 vl_api_set_ipfix_classify_stream_t *mp;
12030 u32 src_port = UDP_DST_PORT_ipfix;
12033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12035 if (unformat (i, "domain %d", &domain_id))
12037 else if (unformat (i, "src_port %d", &src_port))
12041 errmsg ("unknown input `%U'", format_unformat_error, i);
12046 M (SET_IPFIX_CLASSIFY_STREAM, mp);
12048 mp->domain_id = htonl (domain_id);
12049 mp->src_port = htons ((u16) src_port);
12057 api_ipfix_classify_table_add_del (vat_main_t * vam)
12059 unformat_input_t *i = vam->input;
12060 vl_api_ipfix_classify_table_add_del_t *mp;
12062 u32 classify_table_index = ~0;
12064 u8 transport_protocol = 255;
12067 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12069 if (unformat (i, "add"))
12071 else if (unformat (i, "del"))
12073 else if (unformat (i, "table %d", &classify_table_index))
12075 else if (unformat (i, "ip4"))
12077 else if (unformat (i, "ip6"))
12079 else if (unformat (i, "tcp"))
12080 transport_protocol = 6;
12081 else if (unformat (i, "udp"))
12082 transport_protocol = 17;
12085 errmsg ("unknown input `%U'", format_unformat_error, i);
12092 errmsg ("expecting: add|del");
12095 if (classify_table_index == ~0)
12097 errmsg ("classifier table not specified");
12100 if (ip_version == 0)
12102 errmsg ("IP version not specified");
12106 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
12108 mp->is_add = is_add;
12109 mp->table_id = htonl (classify_table_index);
12110 mp->ip_version = ip_version;
12111 mp->transport_protocol = transport_protocol;
12119 api_get_node_index (vat_main_t * vam)
12121 unformat_input_t *i = vam->input;
12122 vl_api_get_node_index_t *mp;
12126 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12128 if (unformat (i, "node %s", &name))
12135 errmsg ("node name required");
12138 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12140 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12144 M (GET_NODE_INDEX, mp);
12145 clib_memcpy (mp->node_name, name, vec_len (name));
12154 api_get_next_index (vat_main_t * vam)
12156 unformat_input_t *i = vam->input;
12157 vl_api_get_next_index_t *mp;
12158 u8 *node_name = 0, *next_node_name = 0;
12161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12163 if (unformat (i, "node-name %s", &node_name))
12165 else if (unformat (i, "next-node-name %s", &next_node_name))
12169 if (node_name == 0)
12171 errmsg ("node name required");
12174 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
12176 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12180 if (next_node_name == 0)
12182 errmsg ("next node name required");
12185 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
12187 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
12191 M (GET_NEXT_INDEX, mp);
12192 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
12193 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
12194 vec_free (node_name);
12195 vec_free (next_node_name);
12203 api_add_node_next (vat_main_t * vam)
12205 unformat_input_t *i = vam->input;
12206 vl_api_add_node_next_t *mp;
12211 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12213 if (unformat (i, "node %s", &name))
12215 else if (unformat (i, "next %s", &next))
12222 errmsg ("node name required");
12225 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
12227 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
12232 errmsg ("next node required");
12235 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
12237 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
12241 M (ADD_NODE_NEXT, mp);
12242 clib_memcpy (mp->node_name, name, vec_len (name));
12243 clib_memcpy (mp->next_name, next, vec_len (next));
12253 api_l2tpv3_create_tunnel (vat_main_t * vam)
12255 unformat_input_t *i = vam->input;
12256 ip6_address_t client_address, our_address;
12257 int client_address_set = 0;
12258 int our_address_set = 0;
12259 u32 local_session_id = 0;
12260 u32 remote_session_id = 0;
12261 u64 local_cookie = 0;
12262 u64 remote_cookie = 0;
12263 u8 l2_sublayer_present = 0;
12264 vl_api_l2tpv3_create_tunnel_t *mp;
12267 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12269 if (unformat (i, "client_address %U", unformat_ip6_address,
12271 client_address_set = 1;
12272 else if (unformat (i, "our_address %U", unformat_ip6_address,
12274 our_address_set = 1;
12275 else if (unformat (i, "local_session_id %d", &local_session_id))
12277 else if (unformat (i, "remote_session_id %d", &remote_session_id))
12279 else if (unformat (i, "local_cookie %lld", &local_cookie))
12281 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
12283 else if (unformat (i, "l2-sublayer-present"))
12284 l2_sublayer_present = 1;
12289 if (client_address_set == 0)
12291 errmsg ("client_address required");
12295 if (our_address_set == 0)
12297 errmsg ("our_address required");
12301 M (L2TPV3_CREATE_TUNNEL, mp);
12303 clib_memcpy (mp->client_address, client_address.as_u8,
12304 sizeof (mp->client_address));
12306 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
12308 mp->local_session_id = ntohl (local_session_id);
12309 mp->remote_session_id = ntohl (remote_session_id);
12310 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
12311 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
12312 mp->l2_sublayer_present = l2_sublayer_present;
12321 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
12323 unformat_input_t *i = vam->input;
12325 u8 sw_if_index_set = 0;
12326 u64 new_local_cookie = 0;
12327 u64 new_remote_cookie = 0;
12328 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
12331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12333 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12334 sw_if_index_set = 1;
12335 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12336 sw_if_index_set = 1;
12337 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
12339 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
12345 if (sw_if_index_set == 0)
12347 errmsg ("missing interface name or sw_if_index");
12351 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
12353 mp->sw_if_index = ntohl (sw_if_index);
12354 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
12355 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
12363 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
12365 unformat_input_t *i = vam->input;
12366 vl_api_l2tpv3_interface_enable_disable_t *mp;
12368 u8 sw_if_index_set = 0;
12369 u8 enable_disable = 1;
12372 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12374 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12375 sw_if_index_set = 1;
12376 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12377 sw_if_index_set = 1;
12378 else if (unformat (i, "enable"))
12379 enable_disable = 1;
12380 else if (unformat (i, "disable"))
12381 enable_disable = 0;
12386 if (sw_if_index_set == 0)
12388 errmsg ("missing interface name or sw_if_index");
12392 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
12394 mp->sw_if_index = ntohl (sw_if_index);
12395 mp->enable_disable = enable_disable;
12403 api_l2tpv3_set_lookup_key (vat_main_t * vam)
12405 unformat_input_t *i = vam->input;
12406 vl_api_l2tpv3_set_lookup_key_t *mp;
12410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12412 if (unformat (i, "lookup_v6_src"))
12413 key = L2T_LOOKUP_SRC_ADDRESS;
12414 else if (unformat (i, "lookup_v6_dst"))
12415 key = L2T_LOOKUP_DST_ADDRESS;
12416 else if (unformat (i, "lookup_session_id"))
12417 key = L2T_LOOKUP_SESSION_ID;
12422 if (key == (u8) ~ 0)
12424 errmsg ("l2tp session lookup key unset");
12428 M (L2TPV3_SET_LOOKUP_KEY, mp);
12437 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
12438 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12440 vat_main_t *vam = &vat_main;
12442 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
12443 format_ip6_address, mp->our_address,
12444 format_ip6_address, mp->client_address,
12445 clib_net_to_host_u32 (mp->sw_if_index));
12448 " local cookies %016llx %016llx remote cookie %016llx",
12449 clib_net_to_host_u64 (mp->local_cookie[0]),
12450 clib_net_to_host_u64 (mp->local_cookie[1]),
12451 clib_net_to_host_u64 (mp->remote_cookie));
12453 print (vam->ofp, " local session-id %d remote session-id %d",
12454 clib_net_to_host_u32 (mp->local_session_id),
12455 clib_net_to_host_u32 (mp->remote_session_id));
12457 print (vam->ofp, " l2 specific sublayer %s\n",
12458 mp->l2_sublayer_present ? "preset" : "absent");
12462 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
12463 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
12465 vat_main_t *vam = &vat_main;
12466 vat_json_node_t *node = NULL;
12467 struct in6_addr addr;
12469 if (VAT_JSON_ARRAY != vam->json_tree.type)
12471 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12472 vat_json_init_array (&vam->json_tree);
12474 node = vat_json_array_add (&vam->json_tree);
12476 vat_json_init_object (node);
12478 clib_memcpy (&addr, mp->our_address, sizeof (addr));
12479 vat_json_object_add_ip6 (node, "our_address", addr);
12480 clib_memcpy (&addr, mp->client_address, sizeof (addr));
12481 vat_json_object_add_ip6 (node, "client_address", addr);
12483 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
12484 vat_json_init_array (lc);
12485 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
12486 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
12487 vat_json_object_add_uint (node, "remote_cookie",
12488 clib_net_to_host_u64 (mp->remote_cookie));
12490 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
12491 vat_json_object_add_uint (node, "local_session_id",
12492 clib_net_to_host_u32 (mp->local_session_id));
12493 vat_json_object_add_uint (node, "remote_session_id",
12494 clib_net_to_host_u32 (mp->remote_session_id));
12495 vat_json_object_add_string_copy (node, "l2_sublayer",
12496 mp->l2_sublayer_present ? (u8 *) "present"
12497 : (u8 *) "absent");
12501 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
12503 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
12504 vl_api_control_ping_t *mp_ping;
12507 /* Get list of l2tpv3-tunnel interfaces */
12508 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
12511 /* Use a control ping for synchronization */
12512 MPING (CONTROL_PING, mp_ping);
12520 static void vl_api_sw_interface_tap_v2_details_t_handler
12521 (vl_api_sw_interface_tap_v2_details_t * mp)
12523 vat_main_t *vam = &vat_main;
12525 u8 *ip4 = format (0, "%U/%d", format_ip4_address, mp->host_ip4_addr,
12526 mp->host_ip4_prefix_len);
12527 u8 *ip6 = format (0, "%U/%d", format_ip6_address, mp->host_ip6_addr,
12528 mp->host_ip6_prefix_len);
12531 "\n%-16s %-12d %-5d %-12d %-12d %-14U %-30s %-20s %-20s %-30s 0x%-08x",
12532 mp->dev_name, ntohl (mp->sw_if_index), ntohl (mp->id),
12533 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12534 format_ethernet_address, mp->host_mac_addr, mp->host_namespace,
12535 mp->host_bridge, ip4, ip6, ntohl (mp->tap_flags));
12541 static void vl_api_sw_interface_tap_v2_details_t_handler_json
12542 (vl_api_sw_interface_tap_v2_details_t * mp)
12544 vat_main_t *vam = &vat_main;
12545 vat_json_node_t *node = NULL;
12547 if (VAT_JSON_ARRAY != vam->json_tree.type)
12549 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12550 vat_json_init_array (&vam->json_tree);
12552 node = vat_json_array_add (&vam->json_tree);
12554 vat_json_init_object (node);
12555 vat_json_object_add_uint (node, "id", ntohl (mp->id));
12556 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12557 vat_json_object_add_uint (node, "tap_flags", ntohl (mp->tap_flags));
12558 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
12559 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12560 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12561 vat_json_object_add_string_copy (node, "host_mac_addr",
12562 format (0, "%U", format_ethernet_address,
12563 &mp->host_mac_addr));
12564 vat_json_object_add_string_copy (node, "host_namespace",
12565 mp->host_namespace);
12566 vat_json_object_add_string_copy (node, "host_bridge", mp->host_bridge);
12567 vat_json_object_add_string_copy (node, "host_ip4_addr",
12568 format (0, "%U/%d", format_ip4_address,
12570 mp->host_ip4_prefix_len));
12571 vat_json_object_add_string_copy (node, "host_ip6_addr",
12572 format (0, "%U/%d", format_ip6_address,
12574 mp->host_ip6_prefix_len));
12579 api_sw_interface_tap_v2_dump (vat_main_t * vam)
12581 vl_api_sw_interface_tap_v2_dump_t *mp;
12582 vl_api_control_ping_t *mp_ping;
12586 "\n%-16s %-12s %-5s %-12s %-12s %-14s %-30s %-20s %-20s %-30s",
12587 "dev_name", "sw_if_index", "id", "rx_ring_sz", "tx_ring_sz",
12588 "host_mac_addr", "host_namespace", "host_bridge", "host_ip4_addr",
12591 /* Get list of tap interfaces */
12592 M (SW_INTERFACE_TAP_V2_DUMP, mp);
12595 /* Use a control ping for synchronization */
12596 MPING (CONTROL_PING, mp_ping);
12603 static void vl_api_sw_interface_virtio_pci_details_t_handler
12604 (vl_api_sw_interface_virtio_pci_details_t * mp)
12606 vat_main_t *vam = &vat_main;
12620 addr.as_u32 = ntohl (mp->pci_addr);
12621 u8 *pci_addr = format (0, "%04x:%02x:%02x.%x", addr.domain, addr.bus,
12622 addr.slot, addr.function);
12625 "\n%-12s %-12d %-12d %-12d %-17U 0x%-08llx",
12626 pci_addr, ntohl (mp->sw_if_index),
12627 ntohs (mp->rx_ring_sz), ntohs (mp->tx_ring_sz),
12628 format_ethernet_address, mp->mac_addr,
12629 clib_net_to_host_u64 (mp->features));
12630 vec_free (pci_addr);
12633 static void vl_api_sw_interface_virtio_pci_details_t_handler_json
12634 (vl_api_sw_interface_virtio_pci_details_t * mp)
12636 vat_main_t *vam = &vat_main;
12637 vat_json_node_t *node = NULL;
12639 if (VAT_JSON_ARRAY != vam->json_tree.type)
12641 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12642 vat_json_init_array (&vam->json_tree);
12644 node = vat_json_array_add (&vam->json_tree);
12646 vat_json_init_object (node);
12647 vat_json_object_add_uint (node, "pci-addr", ntohl (mp->pci_addr));
12648 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12649 vat_json_object_add_uint (node, "rx_ring_sz", ntohs (mp->rx_ring_sz));
12650 vat_json_object_add_uint (node, "tx_ring_sz", ntohs (mp->tx_ring_sz));
12651 vat_json_object_add_uint (node, "features",
12652 clib_net_to_host_u64 (mp->features));
12653 vat_json_object_add_string_copy (node, "mac_addr",
12654 format (0, "%U", format_ethernet_address,
12659 api_sw_interface_virtio_pci_dump (vat_main_t * vam)
12661 vl_api_sw_interface_virtio_pci_dump_t *mp;
12662 vl_api_control_ping_t *mp_ping;
12666 "\n%-12s %-12s %-12s %-12s %-17s %-08s",
12667 "pci_addr", "sw_if_index", "rx_ring_sz", "tx_ring_sz",
12668 "mac_addr", "features");
12670 /* Get list of tap interfaces */
12671 M (SW_INTERFACE_VIRTIO_PCI_DUMP, mp);
12674 /* Use a control ping for synchronization */
12675 MPING (CONTROL_PING, mp_ping);
12683 api_vxlan_offload_rx (vat_main_t * vam)
12685 unformat_input_t *line_input = vam->input;
12686 vl_api_vxlan_offload_rx_t *mp;
12687 u32 hw_if_index = ~0, rx_if_index = ~0;
12691 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12693 if (unformat (line_input, "del"))
12695 else if (unformat (line_input, "hw %U", api_unformat_hw_if_index, vam,
12698 else if (unformat (line_input, "hw hw_if_index %u", &hw_if_index))
12700 else if (unformat (line_input, "rx %U", api_unformat_sw_if_index, vam,
12703 else if (unformat (line_input, "rx sw_if_index %u", &rx_if_index))
12707 errmsg ("parse error '%U'", format_unformat_error, line_input);
12712 if (hw_if_index == ~0)
12714 errmsg ("no hw interface");
12718 if (rx_if_index == ~0)
12720 errmsg ("no rx tunnel");
12724 M (VXLAN_OFFLOAD_RX, mp);
12726 mp->hw_if_index = ntohl (hw_if_index);
12727 mp->sw_if_index = ntohl (rx_if_index);
12728 mp->enable = is_add;
12735 static uword unformat_vxlan_decap_next
12736 (unformat_input_t * input, va_list * args)
12738 u32 *result = va_arg (*args, u32 *);
12741 if (unformat (input, "l2"))
12742 *result = VXLAN_INPUT_NEXT_L2_INPUT;
12743 else if (unformat (input, "%d", &tmp))
12751 api_vxlan_add_del_tunnel (vat_main_t * vam)
12753 unformat_input_t *line_input = vam->input;
12754 vl_api_vxlan_add_del_tunnel_t *mp;
12755 ip46_address_t src, dst;
12757 u8 ipv4_set = 0, ipv6_set = 0;
12762 u32 mcast_sw_if_index = ~0;
12763 u32 encap_vrf_id = 0;
12764 u32 decap_next_index = ~0;
12768 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12769 clib_memset (&src, 0, sizeof src);
12770 clib_memset (&dst, 0, sizeof dst);
12772 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12774 if (unformat (line_input, "del"))
12776 else if (unformat (line_input, "instance %d", &instance))
12779 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
12785 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
12791 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
12797 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
12802 else if (unformat (line_input, "group %U %U",
12803 unformat_ip4_address, &dst.ip4,
12804 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12806 grp_set = dst_set = 1;
12809 else if (unformat (line_input, "group %U",
12810 unformat_ip4_address, &dst.ip4))
12812 grp_set = dst_set = 1;
12815 else if (unformat (line_input, "group %U %U",
12816 unformat_ip6_address, &dst.ip6,
12817 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12819 grp_set = dst_set = 1;
12822 else if (unformat (line_input, "group %U",
12823 unformat_ip6_address, &dst.ip6))
12825 grp_set = dst_set = 1;
12829 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12831 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12833 else if (unformat (line_input, "decap-next %U",
12834 unformat_vxlan_decap_next, &decap_next_index))
12836 else if (unformat (line_input, "vni %d", &vni))
12840 errmsg ("parse error '%U'", format_unformat_error, line_input);
12847 errmsg ("tunnel src address not specified");
12852 errmsg ("tunnel dst address not specified");
12856 if (grp_set && !ip46_address_is_multicast (&dst))
12858 errmsg ("tunnel group address not multicast");
12861 if (grp_set && mcast_sw_if_index == ~0)
12863 errmsg ("tunnel nonexistent multicast device");
12866 if (grp_set == 0 && ip46_address_is_multicast (&dst))
12868 errmsg ("tunnel dst address must be unicast");
12873 if (ipv4_set && ipv6_set)
12875 errmsg ("both IPv4 and IPv6 addresses specified");
12879 if ((vni == 0) || (vni >> 24))
12881 errmsg ("vni not specified or out of range");
12885 M (VXLAN_ADD_DEL_TUNNEL, mp);
12889 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
12890 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
12894 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
12895 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
12898 mp->instance = htonl (instance);
12899 mp->encap_vrf_id = ntohl (encap_vrf_id);
12900 mp->decap_next_index = ntohl (decap_next_index);
12901 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12902 mp->vni = ntohl (vni);
12903 mp->is_add = is_add;
12904 mp->is_ipv6 = ipv6_set;
12911 static void vl_api_vxlan_tunnel_details_t_handler
12912 (vl_api_vxlan_tunnel_details_t * mp)
12914 vat_main_t *vam = &vat_main;
12915 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
12916 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
12918 print (vam->ofp, "%11d%11d%24U%24U%14d%18d%13d%19d",
12919 ntohl (mp->sw_if_index),
12920 ntohl (mp->instance),
12921 format_ip46_address, &src, IP46_TYPE_ANY,
12922 format_ip46_address, &dst, IP46_TYPE_ANY,
12923 ntohl (mp->encap_vrf_id),
12924 ntohl (mp->decap_next_index), ntohl (mp->vni),
12925 ntohl (mp->mcast_sw_if_index));
12928 static void vl_api_vxlan_tunnel_details_t_handler_json
12929 (vl_api_vxlan_tunnel_details_t * mp)
12931 vat_main_t *vam = &vat_main;
12932 vat_json_node_t *node = NULL;
12934 if (VAT_JSON_ARRAY != vam->json_tree.type)
12936 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12937 vat_json_init_array (&vam->json_tree);
12939 node = vat_json_array_add (&vam->json_tree);
12941 vat_json_init_object (node);
12942 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12944 vat_json_object_add_uint (node, "instance", ntohl (mp->instance));
12948 struct in6_addr ip6;
12950 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
12951 vat_json_object_add_ip6 (node, "src_address", ip6);
12952 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
12953 vat_json_object_add_ip6 (node, "dst_address", ip6);
12957 struct in_addr ip4;
12959 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
12960 vat_json_object_add_ip4 (node, "src_address", ip4);
12961 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
12962 vat_json_object_add_ip4 (node, "dst_address", ip4);
12964 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12965 vat_json_object_add_uint (node, "decap_next_index",
12966 ntohl (mp->decap_next_index));
12967 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12968 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12969 vat_json_object_add_uint (node, "mcast_sw_if_index",
12970 ntohl (mp->mcast_sw_if_index));
12974 api_vxlan_tunnel_dump (vat_main_t * vam)
12976 unformat_input_t *i = vam->input;
12977 vl_api_vxlan_tunnel_dump_t *mp;
12978 vl_api_control_ping_t *mp_ping;
12980 u8 sw_if_index_set = 0;
12983 /* Parse args required to build the message */
12984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12986 if (unformat (i, "sw_if_index %d", &sw_if_index))
12987 sw_if_index_set = 1;
12992 if (sw_if_index_set == 0)
12997 if (!vam->json_output)
12999 print (vam->ofp, "%11s%11s%24s%24s%14s%18s%13s%19s",
13000 "sw_if_index", "instance", "src_address", "dst_address",
13001 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13004 /* Get list of vxlan-tunnel interfaces */
13005 M (VXLAN_TUNNEL_DUMP, mp);
13007 mp->sw_if_index = htonl (sw_if_index);
13011 /* Use a control ping for synchronization */
13012 MPING (CONTROL_PING, mp_ping);
13019 static uword unformat_geneve_decap_next
13020 (unformat_input_t * input, va_list * args)
13022 u32 *result = va_arg (*args, u32 *);
13025 if (unformat (input, "l2"))
13026 *result = GENEVE_INPUT_NEXT_L2_INPUT;
13027 else if (unformat (input, "%d", &tmp))
13035 api_geneve_add_del_tunnel (vat_main_t * vam)
13037 unformat_input_t *line_input = vam->input;
13038 vl_api_geneve_add_del_tunnel_t *mp;
13039 ip46_address_t src, dst;
13041 u8 ipv4_set = 0, ipv6_set = 0;
13045 u32 mcast_sw_if_index = ~0;
13046 u32 encap_vrf_id = 0;
13047 u32 decap_next_index = ~0;
13051 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13052 clib_memset (&src, 0, sizeof src);
13053 clib_memset (&dst, 0, sizeof dst);
13055 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13057 if (unformat (line_input, "del"))
13060 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
13066 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
13072 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
13078 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
13083 else if (unformat (line_input, "group %U %U",
13084 unformat_ip4_address, &dst.ip4,
13085 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13087 grp_set = dst_set = 1;
13090 else if (unformat (line_input, "group %U",
13091 unformat_ip4_address, &dst.ip4))
13093 grp_set = dst_set = 1;
13096 else if (unformat (line_input, "group %U %U",
13097 unformat_ip6_address, &dst.ip6,
13098 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13100 grp_set = dst_set = 1;
13103 else if (unformat (line_input, "group %U",
13104 unformat_ip6_address, &dst.ip6))
13106 grp_set = dst_set = 1;
13110 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13112 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13114 else if (unformat (line_input, "decap-next %U",
13115 unformat_geneve_decap_next, &decap_next_index))
13117 else if (unformat (line_input, "vni %d", &vni))
13121 errmsg ("parse error '%U'", format_unformat_error, line_input);
13128 errmsg ("tunnel src address not specified");
13133 errmsg ("tunnel dst address not specified");
13137 if (grp_set && !ip46_address_is_multicast (&dst))
13139 errmsg ("tunnel group address not multicast");
13142 if (grp_set && mcast_sw_if_index == ~0)
13144 errmsg ("tunnel nonexistent multicast device");
13147 if (grp_set == 0 && ip46_address_is_multicast (&dst))
13149 errmsg ("tunnel dst address must be unicast");
13154 if (ipv4_set && ipv6_set)
13156 errmsg ("both IPv4 and IPv6 addresses specified");
13160 if ((vni == 0) || (vni >> 24))
13162 errmsg ("vni not specified or out of range");
13166 M (GENEVE_ADD_DEL_TUNNEL, mp);
13170 clib_memcpy (mp->local_address, &src.ip6, sizeof (src.ip6));
13171 clib_memcpy (mp->remote_address, &dst.ip6, sizeof (dst.ip6));
13175 clib_memcpy (mp->local_address, &src.ip4, sizeof (src.ip4));
13176 clib_memcpy (mp->remote_address, &dst.ip4, sizeof (dst.ip4));
13178 mp->encap_vrf_id = ntohl (encap_vrf_id);
13179 mp->decap_next_index = ntohl (decap_next_index);
13180 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
13181 mp->vni = ntohl (vni);
13182 mp->is_add = is_add;
13183 mp->is_ipv6 = ipv6_set;
13190 static void vl_api_geneve_tunnel_details_t_handler
13191 (vl_api_geneve_tunnel_details_t * mp)
13193 vat_main_t *vam = &vat_main;
13194 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
13195 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
13197 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
13198 ntohl (mp->sw_if_index),
13199 format_ip46_address, &src, IP46_TYPE_ANY,
13200 format_ip46_address, &dst, IP46_TYPE_ANY,
13201 ntohl (mp->encap_vrf_id),
13202 ntohl (mp->decap_next_index), ntohl (mp->vni),
13203 ntohl (mp->mcast_sw_if_index));
13206 static void vl_api_geneve_tunnel_details_t_handler_json
13207 (vl_api_geneve_tunnel_details_t * mp)
13209 vat_main_t *vam = &vat_main;
13210 vat_json_node_t *node = NULL;
13212 if (VAT_JSON_ARRAY != vam->json_tree.type)
13214 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13215 vat_json_init_array (&vam->json_tree);
13217 node = vat_json_array_add (&vam->json_tree);
13219 vat_json_init_object (node);
13220 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13223 struct in6_addr ip6;
13225 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
13226 vat_json_object_add_ip6 (node, "src_address", ip6);
13227 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
13228 vat_json_object_add_ip6 (node, "dst_address", ip6);
13232 struct in_addr ip4;
13234 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
13235 vat_json_object_add_ip4 (node, "src_address", ip4);
13236 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
13237 vat_json_object_add_ip4 (node, "dst_address", ip4);
13239 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
13240 vat_json_object_add_uint (node, "decap_next_index",
13241 ntohl (mp->decap_next_index));
13242 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
13243 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
13244 vat_json_object_add_uint (node, "mcast_sw_if_index",
13245 ntohl (mp->mcast_sw_if_index));
13249 api_geneve_tunnel_dump (vat_main_t * vam)
13251 unformat_input_t *i = vam->input;
13252 vl_api_geneve_tunnel_dump_t *mp;
13253 vl_api_control_ping_t *mp_ping;
13255 u8 sw_if_index_set = 0;
13258 /* Parse args required to build the message */
13259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13261 if (unformat (i, "sw_if_index %d", &sw_if_index))
13262 sw_if_index_set = 1;
13267 if (sw_if_index_set == 0)
13272 if (!vam->json_output)
13274 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
13275 "sw_if_index", "local_address", "remote_address",
13276 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
13279 /* Get list of geneve-tunnel interfaces */
13280 M (GENEVE_TUNNEL_DUMP, mp);
13282 mp->sw_if_index = htonl (sw_if_index);
13286 /* Use a control ping for synchronization */
13287 M (CONTROL_PING, mp_ping);
13295 api_gre_tunnel_add_del (vat_main_t * vam)
13297 unformat_input_t *line_input = vam->input;
13298 vl_api_address_t src = { }, dst =
13301 vl_api_gre_tunnel_add_del_t *mp;
13302 vl_api_gre_tunnel_type_t t_type;
13308 u32 outer_fib_id = 0;
13309 u32 session_id = 0;
13313 t_type = GRE_API_TUNNEL_TYPE_L3;
13315 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13317 if (unformat (line_input, "del"))
13319 else if (unformat (line_input, "instance %d", &instance))
13321 else if (unformat (line_input, "src %U", unformat_vl_api_address, &src))
13325 else if (unformat (line_input, "dst %U", unformat_vl_api_address, &dst))
13329 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
13331 else if (unformat (line_input, "teb"))
13332 t_type = GRE_API_TUNNEL_TYPE_TEB;
13333 else if (unformat (line_input, "erspan %d", &session_id))
13334 t_type = GRE_API_TUNNEL_TYPE_ERSPAN;
13337 errmsg ("parse error '%U'", format_unformat_error, line_input);
13344 errmsg ("tunnel src address not specified");
13349 errmsg ("tunnel dst address not specified");
13353 M (GRE_TUNNEL_ADD_DEL, mp);
13355 clib_memcpy (&mp->tunnel.src, &src, sizeof (mp->tunnel.src));
13356 clib_memcpy (&mp->tunnel.dst, &dst, sizeof (mp->tunnel.dst));
13358 mp->tunnel.instance = htonl (instance);
13359 mp->tunnel.outer_fib_id = htonl (outer_fib_id);
13360 mp->is_add = is_add;
13361 mp->tunnel.session_id = htons ((u16) session_id);
13362 mp->tunnel.type = htonl (t_type);
13369 static void vl_api_gre_tunnel_details_t_handler
13370 (vl_api_gre_tunnel_details_t * mp)
13372 vat_main_t *vam = &vat_main;
13374 print (vam->ofp, "%11d%11d%24U%24U%13d%14d%12d",
13375 ntohl (mp->tunnel.sw_if_index),
13376 ntohl (mp->tunnel.instance),
13377 format_vl_api_address, &mp->tunnel.src,
13378 format_vl_api_address, &mp->tunnel.dst,
13379 mp->tunnel.type, ntohl (mp->tunnel.outer_fib_id),
13380 ntohl (mp->tunnel.session_id));
13384 vat_json_object_add_address (vat_json_node_t * node,
13385 const char *str, const vl_api_address_t * addr)
13387 if (ADDRESS_IP6 == addr->af)
13389 struct in6_addr ip6;
13391 clib_memcpy (&ip6, &addr->un.ip6, sizeof (ip6));
13392 vat_json_object_add_ip6 (node, str, ip6);
13396 struct in_addr ip4;
13398 clib_memcpy (&ip4, &addr->un.ip4, sizeof (ip4));
13399 vat_json_object_add_ip4 (node, str, ip4);
13403 static void vl_api_gre_tunnel_details_t_handler_json
13404 (vl_api_gre_tunnel_details_t * mp)
13406 vat_main_t *vam = &vat_main;
13407 vat_json_node_t *node = NULL;
13408 struct in_addr ip4;
13409 struct in6_addr ip6;
13411 if (VAT_JSON_ARRAY != vam->json_tree.type)
13413 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13414 vat_json_init_array (&vam->json_tree);
13416 node = vat_json_array_add (&vam->json_tree);
13418 vat_json_init_object (node);
13419 vat_json_object_add_uint (node, "sw_if_index",
13420 ntohl (mp->tunnel.sw_if_index));
13421 vat_json_object_add_uint (node, "instance", ntohl (mp->tunnel.instance));
13423 vat_json_object_add_address (node, "src", &mp->tunnel.src);
13424 vat_json_object_add_address (node, "dst", &mp->tunnel.dst);
13425 vat_json_object_add_uint (node, "tunnel_type", mp->tunnel.type);
13426 vat_json_object_add_uint (node, "outer_fib_id",
13427 ntohl (mp->tunnel.outer_fib_id));
13428 vat_json_object_add_uint (node, "session_id", mp->tunnel.session_id);
13432 api_gre_tunnel_dump (vat_main_t * vam)
13434 unformat_input_t *i = vam->input;
13435 vl_api_gre_tunnel_dump_t *mp;
13436 vl_api_control_ping_t *mp_ping;
13438 u8 sw_if_index_set = 0;
13441 /* Parse args required to build the message */
13442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13444 if (unformat (i, "sw_if_index %d", &sw_if_index))
13445 sw_if_index_set = 1;
13450 if (sw_if_index_set == 0)
13455 if (!vam->json_output)
13457 print (vam->ofp, "%11s%11s%24s%24s%13s%14s%12s",
13458 "sw_if_index", "instance", "src_address", "dst_address",
13459 "tunnel_type", "outer_fib_id", "session_id");
13462 /* Get list of gre-tunnel interfaces */
13463 M (GRE_TUNNEL_DUMP, mp);
13465 mp->sw_if_index = htonl (sw_if_index);
13469 /* Use a control ping for synchronization */
13470 MPING (CONTROL_PING, mp_ping);
13478 api_l2_fib_clear_table (vat_main_t * vam)
13480 // unformat_input_t * i = vam->input;
13481 vl_api_l2_fib_clear_table_t *mp;
13484 M (L2_FIB_CLEAR_TABLE, mp);
13492 api_l2_interface_efp_filter (vat_main_t * vam)
13494 unformat_input_t *i = vam->input;
13495 vl_api_l2_interface_efp_filter_t *mp;
13498 u8 sw_if_index_set = 0;
13501 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13503 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13504 sw_if_index_set = 1;
13505 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13506 sw_if_index_set = 1;
13507 else if (unformat (i, "enable"))
13509 else if (unformat (i, "disable"))
13513 clib_warning ("parse error '%U'", format_unformat_error, i);
13518 if (sw_if_index_set == 0)
13520 errmsg ("missing sw_if_index");
13524 M (L2_INTERFACE_EFP_FILTER, mp);
13526 mp->sw_if_index = ntohl (sw_if_index);
13527 mp->enable_disable = enable;
13534 #define foreach_vtr_op \
13535 _("disable", L2_VTR_DISABLED) \
13536 _("push-1", L2_VTR_PUSH_1) \
13537 _("push-2", L2_VTR_PUSH_2) \
13538 _("pop-1", L2_VTR_POP_1) \
13539 _("pop-2", L2_VTR_POP_2) \
13540 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
13541 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
13542 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
13543 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
13546 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
13548 unformat_input_t *i = vam->input;
13549 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
13551 u8 sw_if_index_set = 0;
13554 u32 push_dot1q = 1;
13559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13561 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13562 sw_if_index_set = 1;
13563 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13564 sw_if_index_set = 1;
13565 else if (unformat (i, "vtr_op %d", &vtr_op))
13567 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
13570 else if (unformat (i, "push_dot1q %d", &push_dot1q))
13572 else if (unformat (i, "tag1 %d", &tag1))
13574 else if (unformat (i, "tag2 %d", &tag2))
13578 clib_warning ("parse error '%U'", format_unformat_error, i);
13583 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
13585 errmsg ("missing vtr operation or sw_if_index");
13589 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
13590 mp->sw_if_index = ntohl (sw_if_index);
13591 mp->vtr_op = ntohl (vtr_op);
13592 mp->push_dot1q = ntohl (push_dot1q);
13593 mp->tag1 = ntohl (tag1);
13594 mp->tag2 = ntohl (tag2);
13602 api_create_vhost_user_if (vat_main_t * vam)
13604 unformat_input_t *i = vam->input;
13605 vl_api_create_vhost_user_if_t *mp;
13608 u8 file_name_set = 0;
13609 u32 custom_dev_instance = ~0;
13611 u8 use_custom_mac = 0;
13612 u8 disable_mrg_rxbuf = 0;
13613 u8 disable_indirect_desc = 0;
13617 /* Shut up coverity */
13618 clib_memset (hwaddr, 0, sizeof (hwaddr));
13620 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13622 if (unformat (i, "socket %s", &file_name))
13626 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13628 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
13629 use_custom_mac = 1;
13630 else if (unformat (i, "server"))
13632 else if (unformat (i, "disable_mrg_rxbuf"))
13633 disable_mrg_rxbuf = 1;
13634 else if (unformat (i, "disable_indirect_desc"))
13635 disable_indirect_desc = 1;
13636 else if (unformat (i, "tag %s", &tag))
13642 if (file_name_set == 0)
13644 errmsg ("missing socket file name");
13648 if (vec_len (file_name) > 255)
13650 errmsg ("socket file name too long");
13653 vec_add1 (file_name, 0);
13655 M (CREATE_VHOST_USER_IF, mp);
13657 mp->is_server = is_server;
13658 mp->disable_mrg_rxbuf = disable_mrg_rxbuf;
13659 mp->disable_indirect_desc = disable_indirect_desc;
13660 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13661 vec_free (file_name);
13662 if (custom_dev_instance != ~0)
13665 mp->custom_dev_instance = ntohl (custom_dev_instance);
13668 mp->use_custom_mac = use_custom_mac;
13669 clib_memcpy (mp->mac_address, hwaddr, 6);
13671 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
13680 api_modify_vhost_user_if (vat_main_t * vam)
13682 unformat_input_t *i = vam->input;
13683 vl_api_modify_vhost_user_if_t *mp;
13686 u8 file_name_set = 0;
13687 u32 custom_dev_instance = ~0;
13688 u8 sw_if_index_set = 0;
13689 u32 sw_if_index = (u32) ~ 0;
13692 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13694 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13695 sw_if_index_set = 1;
13696 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13697 sw_if_index_set = 1;
13698 else if (unformat (i, "socket %s", &file_name))
13702 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
13704 else if (unformat (i, "server"))
13710 if (sw_if_index_set == 0)
13712 errmsg ("missing sw_if_index or interface name");
13716 if (file_name_set == 0)
13718 errmsg ("missing socket file name");
13722 if (vec_len (file_name) > 255)
13724 errmsg ("socket file name too long");
13727 vec_add1 (file_name, 0);
13729 M (MODIFY_VHOST_USER_IF, mp);
13731 mp->sw_if_index = ntohl (sw_if_index);
13732 mp->is_server = is_server;
13733 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
13734 vec_free (file_name);
13735 if (custom_dev_instance != ~0)
13738 mp->custom_dev_instance = ntohl (custom_dev_instance);
13747 api_delete_vhost_user_if (vat_main_t * vam)
13749 unformat_input_t *i = vam->input;
13750 vl_api_delete_vhost_user_if_t *mp;
13751 u32 sw_if_index = ~0;
13752 u8 sw_if_index_set = 0;
13755 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13757 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13758 sw_if_index_set = 1;
13759 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13760 sw_if_index_set = 1;
13765 if (sw_if_index_set == 0)
13767 errmsg ("missing sw_if_index or interface name");
13772 M (DELETE_VHOST_USER_IF, mp);
13774 mp->sw_if_index = ntohl (sw_if_index);
13781 static void vl_api_sw_interface_vhost_user_details_t_handler
13782 (vl_api_sw_interface_vhost_user_details_t * mp)
13784 vat_main_t *vam = &vat_main;
13786 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
13787 (char *) mp->interface_name,
13788 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
13789 clib_net_to_host_u64 (mp->features), mp->is_server,
13790 ntohl (mp->num_regions), (char *) mp->sock_filename);
13791 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
13794 static void vl_api_sw_interface_vhost_user_details_t_handler_json
13795 (vl_api_sw_interface_vhost_user_details_t * mp)
13797 vat_main_t *vam = &vat_main;
13798 vat_json_node_t *node = NULL;
13800 if (VAT_JSON_ARRAY != vam->json_tree.type)
13802 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
13803 vat_json_init_array (&vam->json_tree);
13805 node = vat_json_array_add (&vam->json_tree);
13807 vat_json_init_object (node);
13808 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
13809 vat_json_object_add_string_copy (node, "interface_name",
13810 mp->interface_name);
13811 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
13812 ntohl (mp->virtio_net_hdr_sz));
13813 vat_json_object_add_uint (node, "features",
13814 clib_net_to_host_u64 (mp->features));
13815 vat_json_object_add_uint (node, "is_server", mp->is_server);
13816 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
13817 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
13818 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
13822 api_sw_interface_vhost_user_dump (vat_main_t * vam)
13824 vl_api_sw_interface_vhost_user_dump_t *mp;
13825 vl_api_control_ping_t *mp_ping;
13828 "Interface name idx hdr_sz features server regions filename");
13830 /* Get list of vhost-user interfaces */
13831 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
13834 /* Use a control ping for synchronization */
13835 MPING (CONTROL_PING, mp_ping);
13843 api_show_version (vat_main_t * vam)
13845 vl_api_show_version_t *mp;
13848 M (SHOW_VERSION, mp);
13857 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
13859 unformat_input_t *line_input = vam->input;
13860 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
13861 ip4_address_t local4, remote4;
13862 ip6_address_t local6, remote6;
13864 u8 ipv4_set = 0, ipv6_set = 0;
13868 u32 mcast_sw_if_index = ~0;
13869 u32 encap_vrf_id = 0;
13870 u32 decap_vrf_id = 0;
13876 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
13877 clib_memset (&local4, 0, sizeof local4);
13878 clib_memset (&remote4, 0, sizeof remote4);
13879 clib_memset (&local6, 0, sizeof local6);
13880 clib_memset (&remote6, 0, sizeof remote6);
13882 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13884 if (unformat (line_input, "del"))
13886 else if (unformat (line_input, "local %U",
13887 unformat_ip4_address, &local4))
13892 else if (unformat (line_input, "remote %U",
13893 unformat_ip4_address, &remote4))
13898 else if (unformat (line_input, "local %U",
13899 unformat_ip6_address, &local6))
13904 else if (unformat (line_input, "remote %U",
13905 unformat_ip6_address, &remote6))
13910 else if (unformat (line_input, "group %U %U",
13911 unformat_ip4_address, &remote4,
13912 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13914 grp_set = remote_set = 1;
13917 else if (unformat (line_input, "group %U",
13918 unformat_ip4_address, &remote4))
13920 grp_set = remote_set = 1;
13923 else if (unformat (line_input, "group %U %U",
13924 unformat_ip6_address, &remote6,
13925 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
13927 grp_set = remote_set = 1;
13930 else if (unformat (line_input, "group %U",
13931 unformat_ip6_address, &remote6))
13933 grp_set = remote_set = 1;
13937 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
13939 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
13941 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
13943 else if (unformat (line_input, "vni %d", &vni))
13945 else if (unformat (line_input, "next-ip4"))
13947 else if (unformat (line_input, "next-ip6"))
13949 else if (unformat (line_input, "next-ethernet"))
13951 else if (unformat (line_input, "next-nsh"))
13955 errmsg ("parse error '%U'", format_unformat_error, line_input);
13960 if (local_set == 0)
13962 errmsg ("tunnel local address not specified");
13965 if (remote_set == 0)
13967 errmsg ("tunnel remote address not specified");
13970 if (grp_set && mcast_sw_if_index == ~0)
13972 errmsg ("tunnel nonexistent multicast device");
13975 if (ipv4_set && ipv6_set)
13977 errmsg ("both IPv4 and IPv6 addresses specified");
13983 errmsg ("vni not specified");
13987 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
13992 clib_memcpy (&mp->local, &local6, sizeof (local6));
13993 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
13997 clib_memcpy (&mp->local, &local4, sizeof (local4));
13998 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
14001 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
14002 mp->encap_vrf_id = ntohl (encap_vrf_id);
14003 mp->decap_vrf_id = ntohl (decap_vrf_id);
14004 mp->protocol = protocol;
14005 mp->vni = ntohl (vni);
14006 mp->is_add = is_add;
14007 mp->is_ipv6 = ipv6_set;
14014 static void vl_api_vxlan_gpe_tunnel_details_t_handler
14015 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14017 vat_main_t *vam = &vat_main;
14018 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
14019 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
14021 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
14022 ntohl (mp->sw_if_index),
14023 format_ip46_address, &local, IP46_TYPE_ANY,
14024 format_ip46_address, &remote, IP46_TYPE_ANY,
14025 ntohl (mp->vni), mp->protocol,
14026 ntohl (mp->mcast_sw_if_index),
14027 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
14031 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
14032 (vl_api_vxlan_gpe_tunnel_details_t * mp)
14034 vat_main_t *vam = &vat_main;
14035 vat_json_node_t *node = NULL;
14036 struct in_addr ip4;
14037 struct in6_addr ip6;
14039 if (VAT_JSON_ARRAY != vam->json_tree.type)
14041 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14042 vat_json_init_array (&vam->json_tree);
14044 node = vat_json_array_add (&vam->json_tree);
14046 vat_json_init_object (node);
14047 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14050 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
14051 vat_json_object_add_ip6 (node, "local", ip6);
14052 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
14053 vat_json_object_add_ip6 (node, "remote", ip6);
14057 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
14058 vat_json_object_add_ip4 (node, "local", ip4);
14059 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
14060 vat_json_object_add_ip4 (node, "remote", ip4);
14062 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
14063 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
14064 vat_json_object_add_uint (node, "mcast_sw_if_index",
14065 ntohl (mp->mcast_sw_if_index));
14066 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
14067 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
14068 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
14072 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
14074 unformat_input_t *i = vam->input;
14075 vl_api_vxlan_gpe_tunnel_dump_t *mp;
14076 vl_api_control_ping_t *mp_ping;
14078 u8 sw_if_index_set = 0;
14081 /* Parse args required to build the message */
14082 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14084 if (unformat (i, "sw_if_index %d", &sw_if_index))
14085 sw_if_index_set = 1;
14090 if (sw_if_index_set == 0)
14095 if (!vam->json_output)
14097 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
14098 "sw_if_index", "local", "remote", "vni",
14099 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
14102 /* Get list of vxlan-tunnel interfaces */
14103 M (VXLAN_GPE_TUNNEL_DUMP, mp);
14105 mp->sw_if_index = htonl (sw_if_index);
14109 /* Use a control ping for synchronization */
14110 MPING (CONTROL_PING, mp_ping);
14117 static void vl_api_l2_fib_table_details_t_handler
14118 (vl_api_l2_fib_table_details_t * mp)
14120 vat_main_t *vam = &vat_main;
14122 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
14124 ntohl (mp->bd_id), format_ethernet_address, mp->mac,
14125 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
14129 static void vl_api_l2_fib_table_details_t_handler_json
14130 (vl_api_l2_fib_table_details_t * mp)
14132 vat_main_t *vam = &vat_main;
14133 vat_json_node_t *node = NULL;
14135 if (VAT_JSON_ARRAY != vam->json_tree.type)
14137 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
14138 vat_json_init_array (&vam->json_tree);
14140 node = vat_json_array_add (&vam->json_tree);
14142 vat_json_init_object (node);
14143 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
14144 vat_json_object_add_bytes (node, "mac", mp->mac, 6);
14145 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
14146 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
14147 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
14148 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
14152 api_l2_fib_table_dump (vat_main_t * vam)
14154 unformat_input_t *i = vam->input;
14155 vl_api_l2_fib_table_dump_t *mp;
14156 vl_api_control_ping_t *mp_ping;
14161 /* Parse args required to build the message */
14162 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14164 if (unformat (i, "bd_id %d", &bd_id))
14170 if (bd_id_set == 0)
14172 errmsg ("missing bridge domain");
14176 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
14178 /* Get list of l2 fib entries */
14179 M (L2_FIB_TABLE_DUMP, mp);
14181 mp->bd_id = ntohl (bd_id);
14184 /* Use a control ping for synchronization */
14185 MPING (CONTROL_PING, mp_ping);
14194 api_interface_name_renumber (vat_main_t * vam)
14196 unformat_input_t *line_input = vam->input;
14197 vl_api_interface_name_renumber_t *mp;
14198 u32 sw_if_index = ~0;
14199 u32 new_show_dev_instance = ~0;
14202 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14204 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
14207 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14209 else if (unformat (line_input, "new_show_dev_instance %d",
14210 &new_show_dev_instance))
14216 if (sw_if_index == ~0)
14218 errmsg ("missing interface name or sw_if_index");
14222 if (new_show_dev_instance == ~0)
14224 errmsg ("missing new_show_dev_instance");
14228 M (INTERFACE_NAME_RENUMBER, mp);
14230 mp->sw_if_index = ntohl (sw_if_index);
14231 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
14239 api_ip_probe_neighbor (vat_main_t * vam)
14241 unformat_input_t *i = vam->input;
14242 vl_api_ip_probe_neighbor_t *mp;
14243 vl_api_address_t dst_adr;
14249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14251 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14253 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14255 else if (unformat (i, "address %U", unformat_vl_api_address, dst_adr))
14263 errmsg ("missing interface");
14269 errmsg ("missing addresses");
14273 M (IP_PROBE_NEIGHBOR, mp);
14275 mp->sw_if_index = ntohl (sw_if_index);
14276 clib_memcpy (&mp->dst, &dst_adr, sizeof (dst_adr));
14284 api_ip_scan_neighbor_enable_disable (vat_main_t * vam)
14286 unformat_input_t *i = vam->input;
14287 vl_api_ip_scan_neighbor_enable_disable_t *mp;
14288 u8 mode = IP_SCAN_V46_NEIGHBORS;
14289 u32 interval = 0, time = 0, update = 0, delay = 0, stale = 0;
14292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14294 if (unformat (i, "ip4"))
14295 mode = IP_SCAN_V4_NEIGHBORS;
14296 else if (unformat (i, "ip6"))
14297 mode = IP_SCAN_V6_NEIGHBORS;
14298 if (unformat (i, "both"))
14299 mode = IP_SCAN_V46_NEIGHBORS;
14300 else if (unformat (i, "disable"))
14301 mode = IP_SCAN_DISABLED;
14302 else if (unformat (i, "interval %d", &interval))
14304 else if (unformat (i, "max-time %d", &time))
14306 else if (unformat (i, "max-update %d", &update))
14308 else if (unformat (i, "delay %d", &delay))
14310 else if (unformat (i, "stale %d", &stale))
14316 if (interval > 255)
14318 errmsg ("interval cannot exceed 255 minutes.");
14323 errmsg ("max-time cannot exceed 255 usec.");
14328 errmsg ("max-update cannot exceed 255.");
14333 errmsg ("delay cannot exceed 255 msec.");
14338 errmsg ("stale cannot exceed 255 minutes.");
14342 M (IP_SCAN_NEIGHBOR_ENABLE_DISABLE, mp);
14344 mp->scan_interval = interval;
14345 mp->max_proc_time = time;
14346 mp->max_update = update;
14347 mp->scan_int_delay = delay;
14348 mp->stale_threshold = stale;
14356 api_want_ip4_arp_events (vat_main_t * vam)
14358 unformat_input_t *line_input = vam->input;
14359 vl_api_want_ip4_arp_events_t *mp;
14360 ip4_address_t address;
14361 int address_set = 0;
14362 u32 enable_disable = 1;
14365 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14367 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
14369 else if (unformat (line_input, "del"))
14370 enable_disable = 0;
14375 if (address_set == 0)
14377 errmsg ("missing addresses");
14381 M (WANT_IP4_ARP_EVENTS, mp);
14382 mp->enable_disable = enable_disable;
14383 mp->pid = htonl (getpid ());
14384 clib_memcpy (mp->ip, &address, sizeof (address));
14392 api_want_ip6_nd_events (vat_main_t * vam)
14394 unformat_input_t *line_input = vam->input;
14395 vl_api_want_ip6_nd_events_t *mp;
14396 vl_api_ip6_address_t address;
14397 int address_set = 0;
14398 u32 enable_disable = 1;
14401 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14404 (line_input, "address %U", unformat_vl_api_ip6_address, &address))
14406 else if (unformat (line_input, "del"))
14407 enable_disable = 0;
14412 if (address_set == 0)
14414 errmsg ("missing addresses");
14418 M (WANT_IP6_ND_EVENTS, mp);
14419 mp->enable_disable = enable_disable;
14420 mp->pid = htonl (getpid ());
14421 clib_memcpy (&mp->ip, &address, sizeof (address));
14429 api_want_l2_macs_events (vat_main_t * vam)
14431 unformat_input_t *line_input = vam->input;
14432 vl_api_want_l2_macs_events_t *mp;
14433 u8 enable_disable = 1;
14434 u32 scan_delay = 0;
14435 u32 max_macs_in_event = 0;
14436 u32 learn_limit = 0;
14439 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14441 if (unformat (line_input, "learn-limit %d", &learn_limit))
14443 else if (unformat (line_input, "scan-delay %d", &scan_delay))
14445 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
14447 else if (unformat (line_input, "disable"))
14448 enable_disable = 0;
14453 M (WANT_L2_MACS_EVENTS, mp);
14454 mp->enable_disable = enable_disable;
14455 mp->pid = htonl (getpid ());
14456 mp->learn_limit = htonl (learn_limit);
14457 mp->scan_delay = (u8) scan_delay;
14458 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
14465 api_input_acl_set_interface (vat_main_t * vam)
14467 unformat_input_t *i = vam->input;
14468 vl_api_input_acl_set_interface_t *mp;
14470 int sw_if_index_set;
14471 u32 ip4_table_index = ~0;
14472 u32 ip6_table_index = ~0;
14473 u32 l2_table_index = ~0;
14477 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14479 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14480 sw_if_index_set = 1;
14481 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14482 sw_if_index_set = 1;
14483 else if (unformat (i, "del"))
14485 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14487 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14489 else if (unformat (i, "l2-table %d", &l2_table_index))
14493 clib_warning ("parse error '%U'", format_unformat_error, i);
14498 if (sw_if_index_set == 0)
14500 errmsg ("missing interface name or sw_if_index");
14504 M (INPUT_ACL_SET_INTERFACE, mp);
14506 mp->sw_if_index = ntohl (sw_if_index);
14507 mp->ip4_table_index = ntohl (ip4_table_index);
14508 mp->ip6_table_index = ntohl (ip6_table_index);
14509 mp->l2_table_index = ntohl (l2_table_index);
14510 mp->is_add = is_add;
14518 api_output_acl_set_interface (vat_main_t * vam)
14520 unformat_input_t *i = vam->input;
14521 vl_api_output_acl_set_interface_t *mp;
14523 int sw_if_index_set;
14524 u32 ip4_table_index = ~0;
14525 u32 ip6_table_index = ~0;
14526 u32 l2_table_index = ~0;
14530 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14532 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14533 sw_if_index_set = 1;
14534 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14535 sw_if_index_set = 1;
14536 else if (unformat (i, "del"))
14538 else if (unformat (i, "ip4-table %d", &ip4_table_index))
14540 else if (unformat (i, "ip6-table %d", &ip6_table_index))
14542 else if (unformat (i, "l2-table %d", &l2_table_index))
14546 clib_warning ("parse error '%U'", format_unformat_error, i);
14551 if (sw_if_index_set == 0)
14553 errmsg ("missing interface name or sw_if_index");
14557 M (OUTPUT_ACL_SET_INTERFACE, mp);
14559 mp->sw_if_index = ntohl (sw_if_index);
14560 mp->ip4_table_index = ntohl (ip4_table_index);
14561 mp->ip6_table_index = ntohl (ip6_table_index);
14562 mp->l2_table_index = ntohl (l2_table_index);
14563 mp->is_add = is_add;
14571 api_ip_address_dump (vat_main_t * vam)
14573 unformat_input_t *i = vam->input;
14574 vl_api_ip_address_dump_t *mp;
14575 vl_api_control_ping_t *mp_ping;
14576 u32 sw_if_index = ~0;
14577 u8 sw_if_index_set = 0;
14582 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14584 if (unformat (i, "sw_if_index %d", &sw_if_index))
14585 sw_if_index_set = 1;
14587 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14588 sw_if_index_set = 1;
14589 else if (unformat (i, "ipv4"))
14591 else if (unformat (i, "ipv6"))
14597 if (ipv4_set && ipv6_set)
14599 errmsg ("ipv4 and ipv6 flags cannot be both set");
14603 if ((!ipv4_set) && (!ipv6_set))
14605 errmsg ("no ipv4 nor ipv6 flag set");
14609 if (sw_if_index_set == 0)
14611 errmsg ("missing interface name or sw_if_index");
14615 vam->current_sw_if_index = sw_if_index;
14616 vam->is_ipv6 = ipv6_set;
14618 M (IP_ADDRESS_DUMP, mp);
14619 mp->sw_if_index = ntohl (sw_if_index);
14620 mp->is_ipv6 = ipv6_set;
14623 /* Use a control ping for synchronization */
14624 MPING (CONTROL_PING, mp_ping);
14632 api_ip_dump (vat_main_t * vam)
14634 vl_api_ip_dump_t *mp;
14635 vl_api_control_ping_t *mp_ping;
14636 unformat_input_t *in = vam->input;
14643 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
14645 if (unformat (in, "ipv4"))
14647 else if (unformat (in, "ipv6"))
14653 if (ipv4_set && ipv6_set)
14655 errmsg ("ipv4 and ipv6 flags cannot be both set");
14659 if ((!ipv4_set) && (!ipv6_set))
14661 errmsg ("no ipv4 nor ipv6 flag set");
14665 is_ipv6 = ipv6_set;
14666 vam->is_ipv6 = is_ipv6;
14668 /* free old data */
14669 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
14671 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
14673 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
14676 mp->is_ipv6 = ipv6_set;
14679 /* Use a control ping for synchronization */
14680 MPING (CONTROL_PING, mp_ping);
14688 api_ipsec_spd_add_del (vat_main_t * vam)
14690 unformat_input_t *i = vam->input;
14691 vl_api_ipsec_spd_add_del_t *mp;
14696 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14698 if (unformat (i, "spd_id %d", &spd_id))
14700 else if (unformat (i, "del"))
14704 clib_warning ("parse error '%U'", format_unformat_error, i);
14710 errmsg ("spd_id must be set");
14714 M (IPSEC_SPD_ADD_DEL, mp);
14716 mp->spd_id = ntohl (spd_id);
14717 mp->is_add = is_add;
14725 api_ipsec_interface_add_del_spd (vat_main_t * vam)
14727 unformat_input_t *i = vam->input;
14728 vl_api_ipsec_interface_add_del_spd_t *mp;
14730 u8 sw_if_index_set = 0;
14731 u32 spd_id = (u32) ~ 0;
14735 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14737 if (unformat (i, "del"))
14739 else if (unformat (i, "spd_id %d", &spd_id))
14742 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
14743 sw_if_index_set = 1;
14744 else if (unformat (i, "sw_if_index %d", &sw_if_index))
14745 sw_if_index_set = 1;
14748 clib_warning ("parse error '%U'", format_unformat_error, i);
14754 if (spd_id == (u32) ~ 0)
14756 errmsg ("spd_id must be set");
14760 if (sw_if_index_set == 0)
14762 errmsg ("missing interface name or sw_if_index");
14766 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
14768 mp->spd_id = ntohl (spd_id);
14769 mp->sw_if_index = ntohl (sw_if_index);
14770 mp->is_add = is_add;
14778 api_ipsec_spd_entry_add_del (vat_main_t * vam)
14780 unformat_input_t *i = vam->input;
14781 vl_api_ipsec_spd_entry_add_del_t *mp;
14782 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
14783 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
14785 u32 rport_start = 0, rport_stop = (u32) ~ 0;
14786 u32 lport_start = 0, lport_stop = (u32) ~ 0;
14787 vl_api_address_t laddr_start = { }, laddr_stop =
14796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14798 if (unformat (i, "del"))
14800 if (unformat (i, "outbound"))
14802 if (unformat (i, "inbound"))
14804 else if (unformat (i, "spd_id %d", &spd_id))
14806 else if (unformat (i, "sa_id %d", &sa_id))
14808 else if (unformat (i, "priority %d", &priority))
14810 else if (unformat (i, "protocol %d", &protocol))
14812 else if (unformat (i, "lport_start %d", &lport_start))
14814 else if (unformat (i, "lport_stop %d", &lport_stop))
14816 else if (unformat (i, "rport_start %d", &rport_start))
14818 else if (unformat (i, "rport_stop %d", &rport_stop))
14820 else if (unformat (i, "laddr_start %U",
14821 unformat_vl_api_address, &laddr_start))
14823 else if (unformat (i, "laddr_stop %U", unformat_vl_api_address,
14826 else if (unformat (i, "raddr_start %U", unformat_vl_api_address,
14829 else if (unformat (i, "raddr_stop %U", unformat_vl_api_address,
14833 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
14835 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
14837 clib_warning ("unsupported action: 'resolve'");
14843 clib_warning ("parse error '%U'", format_unformat_error, i);
14849 M (IPSEC_SPD_ENTRY_ADD_DEL, mp);
14851 mp->is_add = is_add;
14853 mp->entry.spd_id = ntohl (spd_id);
14854 mp->entry.priority = ntohl (priority);
14855 mp->entry.is_outbound = is_outbound;
14857 clib_memcpy (&mp->entry.remote_address_start, &raddr_start,
14858 sizeof (vl_api_address_t));
14859 clib_memcpy (&mp->entry.remote_address_stop, &raddr_stop,
14860 sizeof (vl_api_address_t));
14861 clib_memcpy (&mp->entry.local_address_start, &laddr_start,
14862 sizeof (vl_api_address_t));
14863 clib_memcpy (&mp->entry.local_address_stop, &laddr_stop,
14864 sizeof (vl_api_address_t));
14866 mp->entry.protocol = (u8) protocol;
14867 mp->entry.local_port_start = ntohs ((u16) lport_start);
14868 mp->entry.local_port_stop = ntohs ((u16) lport_stop);
14869 mp->entry.remote_port_start = ntohs ((u16) rport_start);
14870 mp->entry.remote_port_stop = ntohs ((u16) rport_stop);
14871 mp->entry.policy = (u8) policy;
14872 mp->entry.sa_id = ntohl (sa_id);
14880 api_ipsec_sad_entry_add_del (vat_main_t * vam)
14882 unformat_input_t *i = vam->input;
14883 vl_api_ipsec_sad_entry_add_del_t *mp;
14884 u32 sad_id = 0, spi = 0;
14885 u8 *ck = 0, *ik = 0;
14888 vl_api_ipsec_crypto_alg_t crypto_alg = IPSEC_API_CRYPTO_ALG_NONE;
14889 vl_api_ipsec_integ_alg_t integ_alg = IPSEC_API_INTEG_ALG_NONE;
14890 vl_api_ipsec_sad_flags_t flags = IPSEC_API_SAD_FLAG_NONE;
14891 vl_api_ipsec_proto_t protocol = IPSEC_API_PROTO_AH;
14892 vl_api_address_t tun_src, tun_dst;
14895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14897 if (unformat (i, "del"))
14899 else if (unformat (i, "sad_id %d", &sad_id))
14901 else if (unformat (i, "spi %d", &spi))
14903 else if (unformat (i, "esp"))
14904 protocol = IPSEC_API_PROTO_ESP;
14906 if (unformat (i, "tunnel_src %U", unformat_vl_api_address, &tun_src))
14908 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14909 if (ADDRESS_IP6 == tun_src.af)
14910 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14913 if (unformat (i, "tunnel_dst %U", unformat_vl_api_address, &tun_dst))
14915 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL;
14916 if (ADDRESS_IP6 == tun_src.af)
14917 flags |= IPSEC_API_SAD_FLAG_IS_TUNNEL_V6;
14920 if (unformat (i, "crypto_alg %U",
14921 unformat_ipsec_api_crypto_alg, &crypto_alg))
14923 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14925 else if (unformat (i, "integ_alg %U",
14926 unformat_ipsec_api_integ_alg, &integ_alg))
14928 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14932 clib_warning ("parse error '%U'", format_unformat_error, i);
14938 M (IPSEC_SAD_ENTRY_ADD_DEL, mp);
14940 mp->is_add = is_add;
14941 mp->entry.sad_id = ntohl (sad_id);
14942 mp->entry.protocol = protocol;
14943 mp->entry.spi = ntohl (spi);
14944 mp->entry.flags = flags;
14946 mp->entry.crypto_algorithm = crypto_alg;
14947 mp->entry.integrity_algorithm = integ_alg;
14948 mp->entry.crypto_key.length = vec_len (ck);
14949 mp->entry.integrity_key.length = vec_len (ik);
14951 if (mp->entry.crypto_key.length > sizeof (mp->entry.crypto_key.data))
14952 mp->entry.crypto_key.length = sizeof (mp->entry.crypto_key.data);
14954 if (mp->entry.integrity_key.length > sizeof (mp->entry.integrity_key.data))
14955 mp->entry.integrity_key.length = sizeof (mp->entry.integrity_key.data);
14958 clib_memcpy (mp->entry.crypto_key.data, ck, mp->entry.crypto_key.length);
14960 clib_memcpy (mp->entry.integrity_key.data, ik,
14961 mp->entry.integrity_key.length);
14963 if (flags & IPSEC_API_SAD_FLAG_IS_TUNNEL)
14965 clib_memcpy (&mp->entry.tunnel_src, &tun_src,
14966 sizeof (mp->entry.tunnel_src));
14967 clib_memcpy (&mp->entry.tunnel_dst, &tun_dst,
14968 sizeof (mp->entry.tunnel_dst));
14977 api_ipsec_sa_set_key (vat_main_t * vam)
14979 unformat_input_t *i = vam->input;
14980 vl_api_ipsec_sa_set_key_t *mp;
14982 u8 *ck = 0, *ik = 0;
14985 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14987 if (unformat (i, "sa_id %d", &sa_id))
14989 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
14991 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
14995 clib_warning ("parse error '%U'", format_unformat_error, i);
15000 M (IPSEC_SA_SET_KEY, mp);
15002 mp->sa_id = ntohl (sa_id);
15003 mp->crypto_key.length = vec_len (ck);
15004 mp->integrity_key.length = vec_len (ik);
15006 if (mp->crypto_key.length > sizeof (mp->crypto_key.data))
15007 mp->crypto_key.length = sizeof (mp->crypto_key.data);
15009 if (mp->integrity_key.length > sizeof (mp->integrity_key.data))
15010 mp->integrity_key.length = sizeof (mp->integrity_key.data);
15013 clib_memcpy (mp->crypto_key.data, ck, mp->crypto_key.length);
15015 clib_memcpy (mp->integrity_key.data, ik, mp->integrity_key.length);
15023 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
15025 unformat_input_t *i = vam->input;
15026 vl_api_ipsec_tunnel_if_add_del_t *mp;
15027 u32 local_spi = 0, remote_spi = 0;
15028 u32 crypto_alg = 0, integ_alg = 0;
15029 u8 *lck = NULL, *rck = NULL;
15030 u8 *lik = NULL, *rik = NULL;
15031 vl_api_address_t local_ip = { 0 };
15032 vl_api_address_t remote_ip = { 0 };
15036 u8 anti_replay = 0;
15042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15044 if (unformat (i, "del"))
15046 else if (unformat (i, "esn"))
15048 else if (unformat (i, "anti-replay"))
15050 else if (unformat (i, "count %d", &count))
15052 else if (unformat (i, "local_spi %d", &local_spi))
15054 else if (unformat (i, "remote_spi %d", &remote_spi))
15057 if (unformat (i, "local_ip %U", unformat_vl_api_address, &local_ip))
15060 if (unformat (i, "remote_ip %U", unformat_vl_api_address, &remote_ip))
15062 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
15065 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
15067 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
15069 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
15073 (i, "crypto_alg %U", unformat_ipsec_api_crypto_alg, &crypto_alg))
15075 if (crypto_alg >= IPSEC_CRYPTO_N_ALG)
15077 errmsg ("unsupported crypto-alg: '%U'\n",
15078 format_ipsec_crypto_alg, crypto_alg);
15084 (i, "integ_alg %U", unformat_ipsec_api_integ_alg, &integ_alg))
15086 if (integ_alg >= IPSEC_INTEG_N_ALG)
15088 errmsg ("unsupported integ-alg: '%U'\n",
15089 format_ipsec_integ_alg, integ_alg);
15093 else if (unformat (i, "instance %u", &instance))
15097 errmsg ("parse error '%U'\n", format_unformat_error, i);
15104 /* Turn on async mode */
15105 vam->async_mode = 1;
15106 vam->async_errors = 0;
15107 before = vat_time_now (vam);
15110 for (jj = 0; jj < count; jj++)
15112 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
15114 mp->is_add = is_add;
15116 mp->anti_replay = anti_replay;
15119 increment_vl_address (&remote_ip);
15121 clib_memcpy (&mp->local_ip, &local_ip, sizeof (local_ip));
15122 clib_memcpy (&mp->remote_ip, &remote_ip, sizeof (remote_ip));
15124 mp->local_spi = htonl (local_spi + jj);
15125 mp->remote_spi = htonl (remote_spi + jj);
15126 mp->crypto_alg = (u8) crypto_alg;
15128 mp->local_crypto_key_len = 0;
15131 mp->local_crypto_key_len = vec_len (lck);
15132 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
15133 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
15134 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
15137 mp->remote_crypto_key_len = 0;
15140 mp->remote_crypto_key_len = vec_len (rck);
15141 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
15142 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
15143 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
15146 mp->integ_alg = (u8) integ_alg;
15148 mp->local_integ_key_len = 0;
15151 mp->local_integ_key_len = vec_len (lik);
15152 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
15153 mp->local_integ_key_len = sizeof (mp->local_integ_key);
15154 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
15157 mp->remote_integ_key_len = 0;
15160 mp->remote_integ_key_len = vec_len (rik);
15161 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
15162 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
15163 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
15168 mp->renumber = renumber;
15169 mp->show_instance = ntohl (instance);
15174 /* When testing multiple add/del ops, use a control-ping to sync */
15177 vl_api_control_ping_t *mp_ping;
15181 /* Shut off async mode */
15182 vam->async_mode = 0;
15184 MPING (CONTROL_PING, mp_ping);
15187 timeout = vat_time_now (vam) + 1.0;
15188 while (vat_time_now (vam) < timeout)
15189 if (vam->result_ready == 1)
15194 if (vam->retval == -99)
15195 errmsg ("timeout");
15197 if (vam->async_errors > 0)
15199 errmsg ("%d asynchronous errors", vam->async_errors);
15202 vam->async_errors = 0;
15203 after = vat_time_now (vam);
15205 /* slim chance, but we might have eaten SIGTERM on the first iteration */
15209 print (vam->ofp, "%d tunnels in %.6f secs, %.2f tunnels/sec",
15210 count, after - before, count / (after - before));
15214 /* Wait for a reply... */
15223 vl_api_ipsec_sa_details_t_handler (vl_api_ipsec_sa_details_t * mp)
15225 vat_main_t *vam = &vat_main;
15227 print (vam->ofp, "sa_id %u sw_if_index %u spi %u proto %u crypto_alg %u "
15228 "crypto_key %U integ_alg %u integ_key %U flags %x "
15229 "tunnel_src_addr %U tunnel_dst_addr %U "
15230 "salt %u seq_outbound %lu last_seq_inbound %lu "
15231 "replay_window %lu\n",
15232 ntohl (mp->entry.sad_id),
15233 ntohl (mp->sw_if_index),
15234 ntohl (mp->entry.spi),
15235 ntohl (mp->entry.protocol),
15236 ntohl (mp->entry.crypto_algorithm),
15237 format_hex_bytes, mp->entry.crypto_key.data,
15238 mp->entry.crypto_key.length, ntohl (mp->entry.integrity_algorithm),
15239 format_hex_bytes, mp->entry.integrity_key.data,
15240 mp->entry.integrity_key.length, ntohl (mp->entry.flags),
15241 format_vl_api_address, &mp->entry.tunnel_src, format_vl_api_address,
15242 &mp->entry.tunnel_dst, ntohl (mp->salt),
15243 clib_net_to_host_u64 (mp->seq_outbound),
15244 clib_net_to_host_u64 (mp->last_seq_inbound),
15245 clib_net_to_host_u64 (mp->replay_window));
15248 #define vl_api_ipsec_sa_details_t_endian vl_noop_handler
15249 #define vl_api_ipsec_sa_details_t_print vl_noop_handler
15251 static void vl_api_ipsec_sa_details_t_handler_json
15252 (vl_api_ipsec_sa_details_t * mp)
15254 vat_main_t *vam = &vat_main;
15255 vat_json_node_t *node = NULL;
15256 vl_api_ipsec_sad_flags_t flags;
15258 if (VAT_JSON_ARRAY != vam->json_tree.type)
15260 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15261 vat_json_init_array (&vam->json_tree);
15263 node = vat_json_array_add (&vam->json_tree);
15265 vat_json_init_object (node);
15266 vat_json_object_add_uint (node, "sa_id", ntohl (mp->entry.sad_id));
15267 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
15268 vat_json_object_add_uint (node, "spi", ntohl (mp->entry.spi));
15269 vat_json_object_add_uint (node, "proto", ntohl (mp->entry.protocol));
15270 vat_json_object_add_uint (node, "crypto_alg",
15271 ntohl (mp->entry.crypto_algorithm));
15272 vat_json_object_add_uint (node, "integ_alg",
15273 ntohl (mp->entry.integrity_algorithm));
15274 flags = ntohl (mp->entry.flags);
15275 vat_json_object_add_uint (node, "use_esn",
15276 ! !(flags & IPSEC_API_SAD_FLAG_USE_ESN));
15277 vat_json_object_add_uint (node, "use_anti_replay",
15278 ! !(flags & IPSEC_API_SAD_FLAG_USE_ANTI_REPLAY));
15279 vat_json_object_add_uint (node, "is_tunnel",
15280 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL));
15281 vat_json_object_add_uint (node, "is_tunnel_ip6",
15282 ! !(flags & IPSEC_API_SAD_FLAG_IS_TUNNEL_V6));
15283 vat_json_object_add_uint (node, "udp_encap",
15284 ! !(flags & IPSEC_API_SAD_FLAG_UDP_ENCAP));
15285 vat_json_object_add_bytes (node, "crypto_key", mp->entry.crypto_key.data,
15286 mp->entry.crypto_key.length);
15287 vat_json_object_add_bytes (node, "integ_key", mp->entry.integrity_key.data,
15288 mp->entry.integrity_key.length);
15289 vat_json_object_add_address (node, "src", &mp->entry.tunnel_src);
15290 vat_json_object_add_address (node, "dst", &mp->entry.tunnel_dst);
15291 vat_json_object_add_uint (node, "replay_window",
15292 clib_net_to_host_u64 (mp->replay_window));
15296 api_ipsec_sa_dump (vat_main_t * vam)
15298 unformat_input_t *i = vam->input;
15299 vl_api_ipsec_sa_dump_t *mp;
15300 vl_api_control_ping_t *mp_ping;
15304 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15306 if (unformat (i, "sa_id %d", &sa_id))
15310 clib_warning ("parse error '%U'", format_unformat_error, i);
15315 M (IPSEC_SA_DUMP, mp);
15317 mp->sa_id = ntohl (sa_id);
15321 /* Use a control ping for synchronization */
15322 M (CONTROL_PING, mp_ping);
15330 api_ipsec_tunnel_if_set_key (vat_main_t * vam)
15332 unformat_input_t *i = vam->input;
15333 vl_api_ipsec_tunnel_if_set_key_t *mp;
15334 u32 sw_if_index = ~0;
15335 u8 key_type = IPSEC_IF_SET_KEY_TYPE_NONE;
15340 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15342 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15346 (i, "local crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15347 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_CRYPTO;
15350 (i, "remote crypto %U", unformat_ipsec_api_crypto_alg, &alg))
15351 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_CRYPTO;
15354 (i, "local integ %U", unformat_ipsec_api_integ_alg, &alg))
15355 key_type = IPSEC_IF_SET_KEY_TYPE_LOCAL_INTEG;
15358 (i, "remote integ %U", unformat_ipsec_api_integ_alg, &alg))
15359 key_type = IPSEC_IF_SET_KEY_TYPE_REMOTE_INTEG;
15360 else if (unformat (i, "%U", unformat_hex_string, &key))
15364 clib_warning ("parse error '%U'", format_unformat_error, i);
15369 if (sw_if_index == ~0)
15371 errmsg ("interface must be specified");
15375 if (key_type == IPSEC_IF_SET_KEY_TYPE_NONE)
15377 errmsg ("key type must be specified");
15383 errmsg ("algorithm must be specified");
15387 if (vec_len (key) == 0)
15389 errmsg ("key must be specified");
15393 M (IPSEC_TUNNEL_IF_SET_KEY, mp);
15395 mp->sw_if_index = htonl (sw_if_index);
15397 mp->key_type = key_type;
15398 mp->key_len = vec_len (key);
15399 clib_memcpy (mp->key, key, vec_len (key));
15408 api_ipsec_tunnel_if_set_sa (vat_main_t * vam)
15410 unformat_input_t *i = vam->input;
15411 vl_api_ipsec_tunnel_if_set_sa_t *mp;
15412 u32 sw_if_index = ~0;
15414 u8 is_outbound = (u8) ~ 0;
15417 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15419 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15421 else if (unformat (i, "sa_id %d", &sa_id))
15423 else if (unformat (i, "outbound"))
15425 else if (unformat (i, "inbound"))
15429 clib_warning ("parse error '%U'", format_unformat_error, i);
15434 if (sw_if_index == ~0)
15436 errmsg ("interface must be specified");
15442 errmsg ("SA ID must be specified");
15446 M (IPSEC_TUNNEL_IF_SET_SA, mp);
15448 mp->sw_if_index = htonl (sw_if_index);
15449 mp->sa_id = htonl (sa_id);
15450 mp->is_outbound = is_outbound;
15459 api_get_first_msg_id (vat_main_t * vam)
15461 vl_api_get_first_msg_id_t *mp;
15462 unformat_input_t *i = vam->input;
15467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15469 if (unformat (i, "client %s", &name))
15477 errmsg ("missing client name");
15480 vec_add1 (name, 0);
15482 if (vec_len (name) > 63)
15484 errmsg ("client name too long");
15488 M (GET_FIRST_MSG_ID, mp);
15489 clib_memcpy (mp->name, name, vec_len (name));
15496 api_cop_interface_enable_disable (vat_main_t * vam)
15498 unformat_input_t *line_input = vam->input;
15499 vl_api_cop_interface_enable_disable_t *mp;
15500 u32 sw_if_index = ~0;
15501 u8 enable_disable = 1;
15504 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15506 if (unformat (line_input, "disable"))
15507 enable_disable = 0;
15508 if (unformat (line_input, "enable"))
15509 enable_disable = 1;
15510 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15511 vam, &sw_if_index))
15513 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15519 if (sw_if_index == ~0)
15521 errmsg ("missing interface name or sw_if_index");
15525 /* Construct the API message */
15526 M (COP_INTERFACE_ENABLE_DISABLE, mp);
15527 mp->sw_if_index = ntohl (sw_if_index);
15528 mp->enable_disable = enable_disable;
15532 /* Wait for the reply */
15538 api_cop_whitelist_enable_disable (vat_main_t * vam)
15540 unformat_input_t *line_input = vam->input;
15541 vl_api_cop_whitelist_enable_disable_t *mp;
15542 u32 sw_if_index = ~0;
15543 u8 ip4 = 0, ip6 = 0, default_cop = 0;
15547 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
15549 if (unformat (line_input, "ip4"))
15551 else if (unformat (line_input, "ip6"))
15553 else if (unformat (line_input, "default"))
15555 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
15556 vam, &sw_if_index))
15558 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
15560 else if (unformat (line_input, "fib-id %d", &fib_id))
15566 if (sw_if_index == ~0)
15568 errmsg ("missing interface name or sw_if_index");
15572 /* Construct the API message */
15573 M (COP_WHITELIST_ENABLE_DISABLE, mp);
15574 mp->sw_if_index = ntohl (sw_if_index);
15575 mp->fib_id = ntohl (fib_id);
15578 mp->default_cop = default_cop;
15582 /* Wait for the reply */
15588 api_get_node_graph (vat_main_t * vam)
15590 vl_api_get_node_graph_t *mp;
15593 M (GET_NODE_GRAPH, mp);
15597 /* Wait for the reply */
15603 /** Used for parsing LISP eids */
15604 typedef CLIB_PACKED(struct{
15605 u8 addr[16]; /**< eid address */
15606 u32 len; /**< prefix length if IP */
15607 u8 type; /**< type of eid */
15612 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
15614 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
15616 clib_memset (a, 0, sizeof (a[0]));
15618 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
15620 a->type = 0; /* ipv4 type */
15622 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
15624 a->type = 1; /* ipv6 type */
15626 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
15628 a->type = 2; /* mac type */
15630 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
15632 a->type = 3; /* NSH type */
15633 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
15634 nsh->spi = clib_host_to_net_u32 (nsh->spi);
15641 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
15650 lisp_eid_size_vat (u8 type)
15667 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
15669 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
15673 api_one_add_del_locator_set (vat_main_t * vam)
15675 unformat_input_t *input = vam->input;
15676 vl_api_one_add_del_locator_set_t *mp;
15678 u8 *locator_set_name = NULL;
15679 u8 locator_set_name_set = 0;
15680 vl_api_local_locator_t locator, *locators = 0;
15681 u32 sw_if_index, priority, weight;
15685 /* Parse args required to build the message */
15686 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15688 if (unformat (input, "del"))
15692 else if (unformat (input, "locator-set %s", &locator_set_name))
15694 locator_set_name_set = 1;
15696 else if (unformat (input, "sw_if_index %u p %u w %u",
15697 &sw_if_index, &priority, &weight))
15699 locator.sw_if_index = htonl (sw_if_index);
15700 locator.priority = priority;
15701 locator.weight = weight;
15702 vec_add1 (locators, locator);
15706 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
15707 &sw_if_index, &priority, &weight))
15709 locator.sw_if_index = htonl (sw_if_index);
15710 locator.priority = priority;
15711 locator.weight = weight;
15712 vec_add1 (locators, locator);
15718 if (locator_set_name_set == 0)
15720 errmsg ("missing locator-set name");
15721 vec_free (locators);
15725 if (vec_len (locator_set_name) > 64)
15727 errmsg ("locator-set name too long");
15728 vec_free (locator_set_name);
15729 vec_free (locators);
15732 vec_add1 (locator_set_name, 0);
15734 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
15736 /* Construct the API message */
15737 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
15739 mp->is_add = is_add;
15740 clib_memcpy (mp->locator_set_name, locator_set_name,
15741 vec_len (locator_set_name));
15742 vec_free (locator_set_name);
15744 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
15746 clib_memcpy (mp->locators, locators, data_len);
15747 vec_free (locators);
15752 /* Wait for a reply... */
15757 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
15760 api_one_add_del_locator (vat_main_t * vam)
15762 unformat_input_t *input = vam->input;
15763 vl_api_one_add_del_locator_t *mp;
15764 u32 tmp_if_index = ~0;
15765 u32 sw_if_index = ~0;
15766 u8 sw_if_index_set = 0;
15767 u8 sw_if_index_if_name_set = 0;
15769 u8 priority_set = 0;
15773 u8 *locator_set_name = NULL;
15774 u8 locator_set_name_set = 0;
15777 /* Parse args required to build the message */
15778 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15780 if (unformat (input, "del"))
15784 else if (unformat (input, "locator-set %s", &locator_set_name))
15786 locator_set_name_set = 1;
15788 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
15791 sw_if_index_if_name_set = 1;
15792 sw_if_index = tmp_if_index;
15794 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
15796 sw_if_index_set = 1;
15797 sw_if_index = tmp_if_index;
15799 else if (unformat (input, "p %d", &priority))
15803 else if (unformat (input, "w %d", &weight))
15811 if (locator_set_name_set == 0)
15813 errmsg ("missing locator-set name");
15817 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
15819 errmsg ("missing sw_if_index");
15820 vec_free (locator_set_name);
15824 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
15826 errmsg ("cannot use both params interface name and sw_if_index");
15827 vec_free (locator_set_name);
15831 if (priority_set == 0)
15833 errmsg ("missing locator-set priority");
15834 vec_free (locator_set_name);
15838 if (weight_set == 0)
15840 errmsg ("missing locator-set weight");
15841 vec_free (locator_set_name);
15845 if (vec_len (locator_set_name) > 64)
15847 errmsg ("locator-set name too long");
15848 vec_free (locator_set_name);
15851 vec_add1 (locator_set_name, 0);
15853 /* Construct the API message */
15854 M (ONE_ADD_DEL_LOCATOR, mp);
15856 mp->is_add = is_add;
15857 mp->sw_if_index = ntohl (sw_if_index);
15858 mp->priority = priority;
15859 mp->weight = weight;
15860 clib_memcpy (mp->locator_set_name, locator_set_name,
15861 vec_len (locator_set_name));
15862 vec_free (locator_set_name);
15867 /* Wait for a reply... */
15872 #define api_lisp_add_del_locator api_one_add_del_locator
15875 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
15877 u32 *key_id = va_arg (*args, u32 *);
15880 if (unformat (input, "%s", &s))
15882 if (!strcmp ((char *) s, "sha1"))
15883 key_id[0] = HMAC_SHA_1_96;
15884 else if (!strcmp ((char *) s, "sha256"))
15885 key_id[0] = HMAC_SHA_256_128;
15888 clib_warning ("invalid key_id: '%s'", s);
15889 key_id[0] = HMAC_NO_KEY;
15900 api_one_add_del_local_eid (vat_main_t * vam)
15902 unformat_input_t *input = vam->input;
15903 vl_api_one_add_del_local_eid_t *mp;
15906 lisp_eid_vat_t _eid, *eid = &_eid;
15907 u8 *locator_set_name = 0;
15908 u8 locator_set_name_set = 0;
15914 /* Parse args required to build the message */
15915 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15917 if (unformat (input, "del"))
15921 else if (unformat (input, "vni %d", &vni))
15925 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15929 else if (unformat (input, "locator-set %s", &locator_set_name))
15931 locator_set_name_set = 1;
15933 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
15935 else if (unformat (input, "secret-key %_%v%_", &key))
15941 if (locator_set_name_set == 0)
15943 errmsg ("missing locator-set name");
15949 errmsg ("EID address not set!");
15950 vec_free (locator_set_name);
15954 if (key && (0 == key_id))
15956 errmsg ("invalid key_id!");
15960 if (vec_len (key) > 64)
15962 errmsg ("key too long");
15967 if (vec_len (locator_set_name) > 64)
15969 errmsg ("locator-set name too long");
15970 vec_free (locator_set_name);
15973 vec_add1 (locator_set_name, 0);
15975 /* Construct the API message */
15976 M (ONE_ADD_DEL_LOCAL_EID, mp);
15978 mp->is_add = is_add;
15979 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15980 mp->eid_type = eid->type;
15981 mp->prefix_len = eid->len;
15982 mp->vni = clib_host_to_net_u32 (vni);
15983 mp->key_id = clib_host_to_net_u16 (key_id);
15984 clib_memcpy (mp->locator_set_name, locator_set_name,
15985 vec_len (locator_set_name));
15986 clib_memcpy (mp->key, key, vec_len (key));
15988 vec_free (locator_set_name);
15994 /* Wait for a reply... */
15999 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
16002 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
16004 u32 dp_table = 0, vni = 0;;
16005 unformat_input_t *input = vam->input;
16006 vl_api_gpe_add_del_fwd_entry_t *mp;
16008 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
16009 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
16010 u8 rmt_eid_set = 0, lcl_eid_set = 0;
16011 u32 action = ~0, w;
16012 ip4_address_t rmt_rloc4, lcl_rloc4;
16013 ip6_address_t rmt_rloc6, lcl_rloc6;
16014 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
16017 clib_memset (&rloc, 0, sizeof (rloc));
16019 /* Parse args required to build the message */
16020 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16022 if (unformat (input, "del"))
16024 else if (unformat (input, "add"))
16026 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
16030 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
16034 else if (unformat (input, "vrf %d", &dp_table))
16036 else if (unformat (input, "bd %d", &dp_table))
16038 else if (unformat (input, "vni %d", &vni))
16040 else if (unformat (input, "w %d", &w))
16044 errmsg ("No RLOC configured for setting priority/weight!");
16047 curr_rloc->weight = w;
16049 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
16050 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
16054 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
16056 vec_add1 (lcl_locs, rloc);
16058 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
16059 vec_add1 (rmt_locs, rloc);
16060 /* weight saved in rmt loc */
16061 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16063 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
16064 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
16067 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
16069 vec_add1 (lcl_locs, rloc);
16071 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
16072 vec_add1 (rmt_locs, rloc);
16073 /* weight saved in rmt loc */
16074 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
16076 else if (unformat (input, "action %d", &action))
16082 clib_warning ("parse error '%U'", format_unformat_error, input);
16089 errmsg ("remote eid addresses not set");
16093 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
16095 errmsg ("eid types don't match");
16099 if (0 == rmt_locs && (u32) ~ 0 == action)
16101 errmsg ("action not set for negative mapping");
16105 /* Construct the API message */
16106 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
16107 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
16109 mp->is_add = is_add;
16110 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
16111 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
16112 mp->eid_type = rmt_eid->type;
16113 mp->dp_table = clib_host_to_net_u32 (dp_table);
16114 mp->vni = clib_host_to_net_u32 (vni);
16115 mp->rmt_len = rmt_eid->len;
16116 mp->lcl_len = lcl_eid->len;
16117 mp->action = action;
16119 if (0 != rmt_locs && 0 != lcl_locs)
16121 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
16122 clib_memcpy (mp->locs, lcl_locs,
16123 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
16125 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
16126 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
16127 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
16129 vec_free (lcl_locs);
16130 vec_free (rmt_locs);
16135 /* Wait for a reply... */
16141 api_one_add_del_map_server (vat_main_t * vam)
16143 unformat_input_t *input = vam->input;
16144 vl_api_one_add_del_map_server_t *mp;
16148 ip4_address_t ipv4;
16149 ip6_address_t ipv6;
16152 /* Parse args required to build the message */
16153 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16155 if (unformat (input, "del"))
16159 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16163 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16171 if (ipv4_set && ipv6_set)
16173 errmsg ("both eid v4 and v6 addresses set");
16177 if (!ipv4_set && !ipv6_set)
16179 errmsg ("eid addresses not set");
16183 /* Construct the API message */
16184 M (ONE_ADD_DEL_MAP_SERVER, mp);
16186 mp->is_add = is_add;
16190 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16195 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16201 /* Wait for a reply... */
16206 #define api_lisp_add_del_map_server api_one_add_del_map_server
16209 api_one_add_del_map_resolver (vat_main_t * vam)
16211 unformat_input_t *input = vam->input;
16212 vl_api_one_add_del_map_resolver_t *mp;
16216 ip4_address_t ipv4;
16217 ip6_address_t ipv6;
16220 /* Parse args required to build the message */
16221 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16223 if (unformat (input, "del"))
16227 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
16231 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
16239 if (ipv4_set && ipv6_set)
16241 errmsg ("both eid v4 and v6 addresses set");
16245 if (!ipv4_set && !ipv6_set)
16247 errmsg ("eid addresses not set");
16251 /* Construct the API message */
16252 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
16254 mp->is_add = is_add;
16258 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
16263 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
16269 /* Wait for a reply... */
16274 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
16277 api_lisp_gpe_enable_disable (vat_main_t * vam)
16279 unformat_input_t *input = vam->input;
16280 vl_api_gpe_enable_disable_t *mp;
16285 /* Parse args required to build the message */
16286 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16288 if (unformat (input, "enable"))
16293 else if (unformat (input, "disable"))
16304 errmsg ("Value not set");
16308 /* Construct the API message */
16309 M (GPE_ENABLE_DISABLE, mp);
16316 /* Wait for a reply... */
16322 api_one_rloc_probe_enable_disable (vat_main_t * vam)
16324 unformat_input_t *input = vam->input;
16325 vl_api_one_rloc_probe_enable_disable_t *mp;
16330 /* Parse args required to build the message */
16331 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16333 if (unformat (input, "enable"))
16338 else if (unformat (input, "disable"))
16346 errmsg ("Value not set");
16350 /* Construct the API message */
16351 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
16353 mp->is_enabled = is_en;
16358 /* Wait for a reply... */
16363 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
16366 api_one_map_register_enable_disable (vat_main_t * vam)
16368 unformat_input_t *input = vam->input;
16369 vl_api_one_map_register_enable_disable_t *mp;
16374 /* Parse args required to build the message */
16375 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16377 if (unformat (input, "enable"))
16382 else if (unformat (input, "disable"))
16390 errmsg ("Value not set");
16394 /* Construct the API message */
16395 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
16397 mp->is_enabled = is_en;
16402 /* Wait for a reply... */
16407 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
16410 api_one_enable_disable (vat_main_t * vam)
16412 unformat_input_t *input = vam->input;
16413 vl_api_one_enable_disable_t *mp;
16418 /* Parse args required to build the message */
16419 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16421 if (unformat (input, "enable"))
16426 else if (unformat (input, "disable"))
16436 errmsg ("Value not set");
16440 /* Construct the API message */
16441 M (ONE_ENABLE_DISABLE, mp);
16448 /* Wait for a reply... */
16453 #define api_lisp_enable_disable api_one_enable_disable
16456 api_one_enable_disable_xtr_mode (vat_main_t * vam)
16458 unformat_input_t *input = vam->input;
16459 vl_api_one_enable_disable_xtr_mode_t *mp;
16464 /* Parse args required to build the message */
16465 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16467 if (unformat (input, "enable"))
16472 else if (unformat (input, "disable"))
16482 errmsg ("Value not set");
16486 /* Construct the API message */
16487 M (ONE_ENABLE_DISABLE_XTR_MODE, mp);
16494 /* Wait for a reply... */
16500 api_one_show_xtr_mode (vat_main_t * vam)
16502 vl_api_one_show_xtr_mode_t *mp;
16505 /* Construct the API message */
16506 M (ONE_SHOW_XTR_MODE, mp);
16511 /* Wait for a reply... */
16517 api_one_enable_disable_pitr_mode (vat_main_t * vam)
16519 unformat_input_t *input = vam->input;
16520 vl_api_one_enable_disable_pitr_mode_t *mp;
16525 /* Parse args required to build the message */
16526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16528 if (unformat (input, "enable"))
16533 else if (unformat (input, "disable"))
16543 errmsg ("Value not set");
16547 /* Construct the API message */
16548 M (ONE_ENABLE_DISABLE_PITR_MODE, mp);
16555 /* Wait for a reply... */
16561 api_one_show_pitr_mode (vat_main_t * vam)
16563 vl_api_one_show_pitr_mode_t *mp;
16566 /* Construct the API message */
16567 M (ONE_SHOW_PITR_MODE, mp);
16572 /* Wait for a reply... */
16578 api_one_enable_disable_petr_mode (vat_main_t * vam)
16580 unformat_input_t *input = vam->input;
16581 vl_api_one_enable_disable_petr_mode_t *mp;
16586 /* Parse args required to build the message */
16587 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16589 if (unformat (input, "enable"))
16594 else if (unformat (input, "disable"))
16604 errmsg ("Value not set");
16608 /* Construct the API message */
16609 M (ONE_ENABLE_DISABLE_PETR_MODE, mp);
16616 /* Wait for a reply... */
16622 api_one_show_petr_mode (vat_main_t * vam)
16624 vl_api_one_show_petr_mode_t *mp;
16627 /* Construct the API message */
16628 M (ONE_SHOW_PETR_MODE, mp);
16633 /* Wait for a reply... */
16639 api_show_one_map_register_state (vat_main_t * vam)
16641 vl_api_show_one_map_register_state_t *mp;
16644 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
16649 /* wait for reply */
16654 #define api_show_lisp_map_register_state api_show_one_map_register_state
16657 api_show_one_rloc_probe_state (vat_main_t * vam)
16659 vl_api_show_one_rloc_probe_state_t *mp;
16662 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
16667 /* wait for reply */
16672 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
16675 api_one_add_del_ndp_entry (vat_main_t * vam)
16677 vl_api_one_add_del_ndp_entry_t *mp;
16678 unformat_input_t *input = vam->input;
16683 u8 mac[6] = { 0, };
16684 u8 ip6[16] = { 0, };
16688 /* Parse args required to build the message */
16689 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16691 if (unformat (input, "del"))
16693 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16695 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
16697 else if (unformat (input, "bd %d", &bd))
16701 errmsg ("parse error '%U'", format_unformat_error, input);
16706 if (!bd_set || !ip_set || (!mac_set && is_add))
16708 errmsg ("Missing BD, IP or MAC!");
16712 M (ONE_ADD_DEL_NDP_ENTRY, mp);
16713 mp->is_add = is_add;
16714 clib_memcpy (mp->mac, mac, 6);
16715 mp->bd = clib_host_to_net_u32 (bd);
16716 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
16721 /* wait for reply */
16727 api_one_add_del_l2_arp_entry (vat_main_t * vam)
16729 vl_api_one_add_del_l2_arp_entry_t *mp;
16730 unformat_input_t *input = vam->input;
16735 u8 mac[6] = { 0, };
16736 u32 ip4 = 0, bd = ~0;
16739 /* Parse args required to build the message */
16740 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16742 if (unformat (input, "del"))
16744 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
16746 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
16748 else if (unformat (input, "bd %d", &bd))
16752 errmsg ("parse error '%U'", format_unformat_error, input);
16757 if (!bd_set || !ip_set || (!mac_set && is_add))
16759 errmsg ("Missing BD, IP or MAC!");
16763 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
16764 mp->is_add = is_add;
16765 clib_memcpy (mp->mac, mac, 6);
16766 mp->bd = clib_host_to_net_u32 (bd);
16772 /* wait for reply */
16778 api_one_ndp_bd_get (vat_main_t * vam)
16780 vl_api_one_ndp_bd_get_t *mp;
16783 M (ONE_NDP_BD_GET, mp);
16788 /* wait for reply */
16794 api_one_ndp_entries_get (vat_main_t * vam)
16796 vl_api_one_ndp_entries_get_t *mp;
16797 unformat_input_t *input = vam->input;
16802 /* Parse args required to build the message */
16803 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16805 if (unformat (input, "bd %d", &bd))
16809 errmsg ("parse error '%U'", format_unformat_error, input);
16816 errmsg ("Expected bridge domain!");
16820 M (ONE_NDP_ENTRIES_GET, mp);
16821 mp->bd = clib_host_to_net_u32 (bd);
16826 /* wait for reply */
16832 api_one_l2_arp_bd_get (vat_main_t * vam)
16834 vl_api_one_l2_arp_bd_get_t *mp;
16837 M (ONE_L2_ARP_BD_GET, mp);
16842 /* wait for reply */
16848 api_one_l2_arp_entries_get (vat_main_t * vam)
16850 vl_api_one_l2_arp_entries_get_t *mp;
16851 unformat_input_t *input = vam->input;
16856 /* Parse args required to build the message */
16857 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16859 if (unformat (input, "bd %d", &bd))
16863 errmsg ("parse error '%U'", format_unformat_error, input);
16870 errmsg ("Expected bridge domain!");
16874 M (ONE_L2_ARP_ENTRIES_GET, mp);
16875 mp->bd = clib_host_to_net_u32 (bd);
16880 /* wait for reply */
16886 api_one_stats_enable_disable (vat_main_t * vam)
16888 vl_api_one_stats_enable_disable_t *mp;
16889 unformat_input_t *input = vam->input;
16894 /* Parse args required to build the message */
16895 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16897 if (unformat (input, "enable"))
16902 else if (unformat (input, "disable"))
16912 errmsg ("Value not set");
16916 M (ONE_STATS_ENABLE_DISABLE, mp);
16922 /* wait for reply */
16928 api_show_one_stats_enable_disable (vat_main_t * vam)
16930 vl_api_show_one_stats_enable_disable_t *mp;
16933 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
16938 /* wait for reply */
16944 api_show_one_map_request_mode (vat_main_t * vam)
16946 vl_api_show_one_map_request_mode_t *mp;
16949 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
16954 /* wait for reply */
16959 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
16962 api_one_map_request_mode (vat_main_t * vam)
16964 unformat_input_t *input = vam->input;
16965 vl_api_one_map_request_mode_t *mp;
16969 /* Parse args required to build the message */
16970 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16972 if (unformat (input, "dst-only"))
16974 else if (unformat (input, "src-dst"))
16978 errmsg ("parse error '%U'", format_unformat_error, input);
16983 M (ONE_MAP_REQUEST_MODE, mp);
16990 /* wait for reply */
16995 #define api_lisp_map_request_mode api_one_map_request_mode
16998 * Enable/disable ONE proxy ITR.
17000 * @param vam vpp API test context
17001 * @return return code
17004 api_one_pitr_set_locator_set (vat_main_t * vam)
17006 u8 ls_name_set = 0;
17007 unformat_input_t *input = vam->input;
17008 vl_api_one_pitr_set_locator_set_t *mp;
17013 /* Parse args required to build the message */
17014 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17016 if (unformat (input, "del"))
17018 else if (unformat (input, "locator-set %s", &ls_name))
17022 errmsg ("parse error '%U'", format_unformat_error, input);
17029 errmsg ("locator-set name not set!");
17033 M (ONE_PITR_SET_LOCATOR_SET, mp);
17035 mp->is_add = is_add;
17036 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17037 vec_free (ls_name);
17042 /* wait for reply */
17047 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
17050 api_one_nsh_set_locator_set (vat_main_t * vam)
17052 u8 ls_name_set = 0;
17053 unformat_input_t *input = vam->input;
17054 vl_api_one_nsh_set_locator_set_t *mp;
17059 /* Parse args required to build the message */
17060 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17062 if (unformat (input, "del"))
17064 else if (unformat (input, "ls %s", &ls_name))
17068 errmsg ("parse error '%U'", format_unformat_error, input);
17073 if (!ls_name_set && is_add)
17075 errmsg ("locator-set name not set!");
17079 M (ONE_NSH_SET_LOCATOR_SET, mp);
17081 mp->is_add = is_add;
17082 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
17083 vec_free (ls_name);
17088 /* wait for reply */
17094 api_show_one_pitr (vat_main_t * vam)
17096 vl_api_show_one_pitr_t *mp;
17099 if (!vam->json_output)
17101 print (vam->ofp, "%=20s", "lisp status:");
17104 M (SHOW_ONE_PITR, mp);
17108 /* Wait for a reply... */
17113 #define api_show_lisp_pitr api_show_one_pitr
17116 api_one_use_petr (vat_main_t * vam)
17118 unformat_input_t *input = vam->input;
17119 vl_api_one_use_petr_t *mp;
17124 clib_memset (&ip, 0, sizeof (ip));
17126 /* Parse args required to build the message */
17127 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17129 if (unformat (input, "disable"))
17132 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
17135 ip_addr_version (&ip) = IP4;
17138 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
17141 ip_addr_version (&ip) = IP6;
17145 errmsg ("parse error '%U'", format_unformat_error, input);
17150 M (ONE_USE_PETR, mp);
17152 mp->is_add = is_add;
17155 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
17157 clib_memcpy (mp->address, &ip, 4);
17159 clib_memcpy (mp->address, &ip, 16);
17165 /* wait for reply */
17170 #define api_lisp_use_petr api_one_use_petr
17173 api_show_one_nsh_mapping (vat_main_t * vam)
17175 vl_api_show_one_use_petr_t *mp;
17178 if (!vam->json_output)
17180 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
17183 M (SHOW_ONE_NSH_MAPPING, mp);
17187 /* Wait for a reply... */
17193 api_show_one_use_petr (vat_main_t * vam)
17195 vl_api_show_one_use_petr_t *mp;
17198 if (!vam->json_output)
17200 print (vam->ofp, "%=20s", "Proxy-ETR status:");
17203 M (SHOW_ONE_USE_PETR, mp);
17207 /* Wait for a reply... */
17212 #define api_show_lisp_use_petr api_show_one_use_petr
17215 * Add/delete mapping between vni and vrf
17218 api_one_eid_table_add_del_map (vat_main_t * vam)
17220 unformat_input_t *input = vam->input;
17221 vl_api_one_eid_table_add_del_map_t *mp;
17222 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
17223 u32 vni, vrf, bd_index;
17226 /* Parse args required to build the message */
17227 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17229 if (unformat (input, "del"))
17231 else if (unformat (input, "vrf %d", &vrf))
17233 else if (unformat (input, "bd_index %d", &bd_index))
17235 else if (unformat (input, "vni %d", &vni))
17241 if (!vni_set || (!vrf_set && !bd_index_set))
17243 errmsg ("missing arguments!");
17247 if (vrf_set && bd_index_set)
17249 errmsg ("error: both vrf and bd entered!");
17253 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
17255 mp->is_add = is_add;
17256 mp->vni = htonl (vni);
17257 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
17258 mp->is_l2 = bd_index_set;
17263 /* wait for reply */
17268 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
17271 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
17273 u32 *action = va_arg (*args, u32 *);
17276 if (unformat (input, "%s", &s))
17278 if (!strcmp ((char *) s, "no-action"))
17280 else if (!strcmp ((char *) s, "natively-forward"))
17282 else if (!strcmp ((char *) s, "send-map-request"))
17284 else if (!strcmp ((char *) s, "drop"))
17288 clib_warning ("invalid action: '%s'", s);
17300 * Add/del remote mapping to/from ONE control plane
17302 * @param vam vpp API test context
17303 * @return return code
17306 api_one_add_del_remote_mapping (vat_main_t * vam)
17308 unformat_input_t *input = vam->input;
17309 vl_api_one_add_del_remote_mapping_t *mp;
17311 lisp_eid_vat_t _eid, *eid = &_eid;
17312 lisp_eid_vat_t _seid, *seid = &_seid;
17313 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
17314 u32 action = ~0, p, w, data_len;
17315 ip4_address_t rloc4;
17316 ip6_address_t rloc6;
17317 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
17320 clib_memset (&rloc, 0, sizeof (rloc));
17322 /* Parse args required to build the message */
17323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17325 if (unformat (input, "del-all"))
17329 else if (unformat (input, "del"))
17333 else if (unformat (input, "add"))
17337 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
17341 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
17345 else if (unformat (input, "vni %d", &vni))
17349 else if (unformat (input, "p %d w %d", &p, &w))
17353 errmsg ("No RLOC configured for setting priority/weight!");
17356 curr_rloc->priority = p;
17357 curr_rloc->weight = w;
17359 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
17362 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
17363 vec_add1 (rlocs, rloc);
17364 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17366 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
17369 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
17370 vec_add1 (rlocs, rloc);
17371 curr_rloc = &rlocs[vec_len (rlocs) - 1];
17373 else if (unformat (input, "action %U",
17374 unformat_negative_mapping_action, &action))
17380 clib_warning ("parse error '%U'", format_unformat_error, input);
17387 errmsg ("missing params!");
17391 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
17393 errmsg ("no action set for negative map-reply!");
17397 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
17399 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
17400 mp->is_add = is_add;
17401 mp->vni = htonl (vni);
17402 mp->action = (u8) action;
17403 mp->is_src_dst = seid_set;
17404 mp->eid_len = eid->len;
17405 mp->seid_len = seid->len;
17406 mp->del_all = del_all;
17407 mp->eid_type = eid->type;
17408 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
17409 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
17411 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
17412 clib_memcpy (mp->rlocs, rlocs, data_len);
17418 /* Wait for a reply... */
17423 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
17426 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
17427 * forwarding entries in data-plane accordingly.
17429 * @param vam vpp API test context
17430 * @return return code
17433 api_one_add_del_adjacency (vat_main_t * vam)
17435 unformat_input_t *input = vam->input;
17436 vl_api_one_add_del_adjacency_t *mp;
17438 ip4_address_t leid4, reid4;
17439 ip6_address_t leid6, reid6;
17440 u8 reid_mac[6] = { 0 };
17441 u8 leid_mac[6] = { 0 };
17442 u8 reid_type, leid_type;
17443 u32 leid_len = 0, reid_len = 0, len;
17447 leid_type = reid_type = (u8) ~ 0;
17449 /* Parse args required to build the message */
17450 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17452 if (unformat (input, "del"))
17456 else if (unformat (input, "add"))
17460 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
17463 reid_type = 0; /* ipv4 */
17466 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
17469 reid_type = 1; /* ipv6 */
17472 else if (unformat (input, "reid %U", unformat_ethernet_address,
17475 reid_type = 2; /* mac */
17477 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
17480 leid_type = 0; /* ipv4 */
17483 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
17486 leid_type = 1; /* ipv6 */
17489 else if (unformat (input, "leid %U", unformat_ethernet_address,
17492 leid_type = 2; /* mac */
17494 else if (unformat (input, "vni %d", &vni))
17500 errmsg ("parse error '%U'", format_unformat_error, input);
17505 if ((u8) ~ 0 == reid_type)
17507 errmsg ("missing params!");
17511 if (leid_type != reid_type)
17513 errmsg ("remote and local EIDs are of different types!");
17517 M (ONE_ADD_DEL_ADJACENCY, mp);
17518 mp->is_add = is_add;
17519 mp->vni = htonl (vni);
17520 mp->leid_len = leid_len;
17521 mp->reid_len = reid_len;
17522 mp->eid_type = reid_type;
17524 switch (mp->eid_type)
17527 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
17528 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
17531 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
17532 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
17535 clib_memcpy (mp->leid, leid_mac, 6);
17536 clib_memcpy (mp->reid, reid_mac, 6);
17539 errmsg ("unknown EID type %d!", mp->eid_type);
17546 /* Wait for a reply... */
17551 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
17554 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
17556 u32 *mode = va_arg (*args, u32 *);
17558 if (unformat (input, "lisp"))
17560 else if (unformat (input, "vxlan"))
17569 api_gpe_get_encap_mode (vat_main_t * vam)
17571 vl_api_gpe_get_encap_mode_t *mp;
17574 /* Construct the API message */
17575 M (GPE_GET_ENCAP_MODE, mp);
17580 /* Wait for a reply... */
17586 api_gpe_set_encap_mode (vat_main_t * vam)
17588 unformat_input_t *input = vam->input;
17589 vl_api_gpe_set_encap_mode_t *mp;
17593 /* Parse args required to build the message */
17594 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17596 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
17602 /* Construct the API message */
17603 M (GPE_SET_ENCAP_MODE, mp);
17610 /* Wait for a reply... */
17616 api_lisp_gpe_add_del_iface (vat_main_t * vam)
17618 unformat_input_t *input = vam->input;
17619 vl_api_gpe_add_del_iface_t *mp;
17620 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
17621 u32 dp_table = 0, vni = 0;
17624 /* Parse args required to build the message */
17625 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17627 if (unformat (input, "up"))
17632 else if (unformat (input, "down"))
17637 else if (unformat (input, "table_id %d", &dp_table))
17641 else if (unformat (input, "bd_id %d", &dp_table))
17646 else if (unformat (input, "vni %d", &vni))
17654 if (action_set == 0)
17656 errmsg ("Action not set");
17659 if (dp_table_set == 0 || vni_set == 0)
17661 errmsg ("vni and dp_table must be set");
17665 /* Construct the API message */
17666 M (GPE_ADD_DEL_IFACE, mp);
17668 mp->is_add = is_add;
17669 mp->dp_table = clib_host_to_net_u32 (dp_table);
17671 mp->vni = clib_host_to_net_u32 (vni);
17676 /* Wait for a reply... */
17682 api_one_map_register_fallback_threshold (vat_main_t * vam)
17684 unformat_input_t *input = vam->input;
17685 vl_api_one_map_register_fallback_threshold_t *mp;
17690 /* Parse args required to build the message */
17691 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17693 if (unformat (input, "%u", &value))
17697 clib_warning ("parse error '%U'", format_unformat_error, input);
17704 errmsg ("fallback threshold value is missing!");
17708 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17709 mp->value = clib_host_to_net_u32 (value);
17714 /* Wait for a reply... */
17720 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
17722 vl_api_show_one_map_register_fallback_threshold_t *mp;
17725 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
17730 /* Wait for a reply... */
17736 unformat_lisp_transport_protocol (unformat_input_t * input, va_list * args)
17738 u32 *proto = va_arg (*args, u32 *);
17740 if (unformat (input, "udp"))
17742 else if (unformat (input, "api"))
17751 api_one_set_transport_protocol (vat_main_t * vam)
17753 unformat_input_t *input = vam->input;
17754 vl_api_one_set_transport_protocol_t *mp;
17759 /* Parse args required to build the message */
17760 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17762 if (unformat (input, "%U", unformat_lisp_transport_protocol, &protocol))
17766 clib_warning ("parse error '%U'", format_unformat_error, input);
17773 errmsg ("Transport protocol missing!");
17777 M (ONE_SET_TRANSPORT_PROTOCOL, mp);
17778 mp->protocol = (u8) protocol;
17783 /* Wait for a reply... */
17789 api_one_get_transport_protocol (vat_main_t * vam)
17791 vl_api_one_get_transport_protocol_t *mp;
17794 M (ONE_GET_TRANSPORT_PROTOCOL, mp);
17799 /* Wait for a reply... */
17805 api_one_map_register_set_ttl (vat_main_t * vam)
17807 unformat_input_t *input = vam->input;
17808 vl_api_one_map_register_set_ttl_t *mp;
17813 /* Parse args required to build the message */
17814 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17816 if (unformat (input, "%u", &ttl))
17820 clib_warning ("parse error '%U'", format_unformat_error, input);
17827 errmsg ("TTL value missing!");
17831 M (ONE_MAP_REGISTER_SET_TTL, mp);
17832 mp->ttl = clib_host_to_net_u32 (ttl);
17837 /* Wait for a reply... */
17843 api_show_one_map_register_ttl (vat_main_t * vam)
17845 vl_api_show_one_map_register_ttl_t *mp;
17848 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
17853 /* Wait for a reply... */
17859 * Add/del map request itr rlocs from ONE control plane and updates
17861 * @param vam vpp API test context
17862 * @return return code
17865 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
17867 unformat_input_t *input = vam->input;
17868 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
17869 u8 *locator_set_name = 0;
17870 u8 locator_set_name_set = 0;
17874 /* Parse args required to build the message */
17875 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17877 if (unformat (input, "del"))
17881 else if (unformat (input, "%_%v%_", &locator_set_name))
17883 locator_set_name_set = 1;
17887 clib_warning ("parse error '%U'", format_unformat_error, input);
17892 if (is_add && !locator_set_name_set)
17894 errmsg ("itr-rloc is not set!");
17898 if (is_add && vec_len (locator_set_name) > 64)
17900 errmsg ("itr-rloc locator-set name too long");
17901 vec_free (locator_set_name);
17905 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
17906 mp->is_add = is_add;
17909 clib_memcpy (mp->locator_set_name, locator_set_name,
17910 vec_len (locator_set_name));
17914 clib_memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
17916 vec_free (locator_set_name);
17921 /* Wait for a reply... */
17926 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
17929 api_one_locator_dump (vat_main_t * vam)
17931 unformat_input_t *input = vam->input;
17932 vl_api_one_locator_dump_t *mp;
17933 vl_api_control_ping_t *mp_ping;
17934 u8 is_index_set = 0, is_name_set = 0;
17939 /* Parse args required to build the message */
17940 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
17942 if (unformat (input, "ls_name %_%v%_", &ls_name))
17946 else if (unformat (input, "ls_index %d", &ls_index))
17952 errmsg ("parse error '%U'", format_unformat_error, input);
17957 if (!is_index_set && !is_name_set)
17959 errmsg ("error: expected one of index or name!");
17963 if (is_index_set && is_name_set)
17965 errmsg ("error: only one param expected!");
17969 if (vec_len (ls_name) > 62)
17971 errmsg ("error: locator set name too long!");
17975 if (!vam->json_output)
17977 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
17980 M (ONE_LOCATOR_DUMP, mp);
17981 mp->is_index_set = is_index_set;
17984 mp->ls_index = clib_host_to_net_u32 (ls_index);
17987 vec_add1 (ls_name, 0);
17988 strncpy ((char *) mp->ls_name, (char *) ls_name,
17989 sizeof (mp->ls_name) - 1);
17995 /* Use a control ping for synchronization */
17996 MPING (CONTROL_PING, mp_ping);
17999 /* Wait for a reply... */
18004 #define api_lisp_locator_dump api_one_locator_dump
18007 api_one_locator_set_dump (vat_main_t * vam)
18009 vl_api_one_locator_set_dump_t *mp;
18010 vl_api_control_ping_t *mp_ping;
18011 unformat_input_t *input = vam->input;
18015 /* Parse args required to build the message */
18016 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18018 if (unformat (input, "local"))
18022 else if (unformat (input, "remote"))
18028 errmsg ("parse error '%U'", format_unformat_error, input);
18033 if (!vam->json_output)
18035 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
18038 M (ONE_LOCATOR_SET_DUMP, mp);
18040 mp->filter = filter;
18045 /* Use a control ping for synchronization */
18046 MPING (CONTROL_PING, mp_ping);
18049 /* Wait for a reply... */
18054 #define api_lisp_locator_set_dump api_one_locator_set_dump
18057 api_one_eid_table_map_dump (vat_main_t * vam)
18061 unformat_input_t *input = vam->input;
18062 vl_api_one_eid_table_map_dump_t *mp;
18063 vl_api_control_ping_t *mp_ping;
18066 /* Parse args required to build the message */
18067 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18069 if (unformat (input, "l2"))
18074 else if (unformat (input, "l3"))
18081 errmsg ("parse error '%U'", format_unformat_error, input);
18088 errmsg ("expected one of 'l2' or 'l3' parameter!");
18092 if (!vam->json_output)
18094 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
18097 M (ONE_EID_TABLE_MAP_DUMP, mp);
18103 /* Use a control ping for synchronization */
18104 MPING (CONTROL_PING, mp_ping);
18107 /* Wait for a reply... */
18112 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
18115 api_one_eid_table_vni_dump (vat_main_t * vam)
18117 vl_api_one_eid_table_vni_dump_t *mp;
18118 vl_api_control_ping_t *mp_ping;
18121 if (!vam->json_output)
18123 print (vam->ofp, "VNI");
18126 M (ONE_EID_TABLE_VNI_DUMP, mp);
18131 /* Use a control ping for synchronization */
18132 MPING (CONTROL_PING, mp_ping);
18135 /* Wait for a reply... */
18140 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
18143 api_one_eid_table_dump (vat_main_t * vam)
18145 unformat_input_t *i = vam->input;
18146 vl_api_one_eid_table_dump_t *mp;
18147 vl_api_control_ping_t *mp_ping;
18148 struct in_addr ip4;
18149 struct in6_addr ip6;
18151 u8 eid_type = ~0, eid_set = 0;
18152 u32 prefix_length = ~0, t, vni = 0;
18155 lisp_nsh_api_t nsh;
18157 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18159 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
18165 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
18171 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
18176 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
18181 else if (unformat (i, "vni %d", &t))
18185 else if (unformat (i, "local"))
18189 else if (unformat (i, "remote"))
18195 errmsg ("parse error '%U'", format_unformat_error, i);
18200 if (!vam->json_output)
18202 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
18203 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
18206 M (ONE_EID_TABLE_DUMP, mp);
18208 mp->filter = filter;
18212 mp->vni = htonl (vni);
18213 mp->eid_type = eid_type;
18217 mp->prefix_length = prefix_length;
18218 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
18221 mp->prefix_length = prefix_length;
18222 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
18225 clib_memcpy (mp->eid, mac, sizeof (mac));
18228 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
18231 errmsg ("unknown EID type %d!", eid_type);
18239 /* Use a control ping for synchronization */
18240 MPING (CONTROL_PING, mp_ping);
18243 /* Wait for a reply... */
18248 #define api_lisp_eid_table_dump api_one_eid_table_dump
18251 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
18253 unformat_input_t *i = vam->input;
18254 vl_api_gpe_fwd_entries_get_t *mp;
18259 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18261 if (unformat (i, "vni %d", &vni))
18267 errmsg ("parse error '%U'", format_unformat_error, i);
18274 errmsg ("vni not set!");
18278 if (!vam->json_output)
18280 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
18284 M (GPE_FWD_ENTRIES_GET, mp);
18285 mp->vni = clib_host_to_net_u32 (vni);
18290 /* Wait for a reply... */
18295 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
18296 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
18297 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
18298 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
18299 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
18300 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
18301 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
18302 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
18305 api_one_adjacencies_get (vat_main_t * vam)
18307 unformat_input_t *i = vam->input;
18308 vl_api_one_adjacencies_get_t *mp;
18313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18315 if (unformat (i, "vni %d", &vni))
18321 errmsg ("parse error '%U'", format_unformat_error, i);
18328 errmsg ("vni not set!");
18332 if (!vam->json_output)
18334 print (vam->ofp, "%s %40s", "leid", "reid");
18337 M (ONE_ADJACENCIES_GET, mp);
18338 mp->vni = clib_host_to_net_u32 (vni);
18343 /* Wait for a reply... */
18348 #define api_lisp_adjacencies_get api_one_adjacencies_get
18351 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
18353 unformat_input_t *i = vam->input;
18354 vl_api_gpe_native_fwd_rpaths_get_t *mp;
18356 u8 ip_family_set = 0, is_ip4 = 1;
18358 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18360 if (unformat (i, "ip4"))
18365 else if (unformat (i, "ip6"))
18372 errmsg ("parse error '%U'", format_unformat_error, i);
18377 if (!ip_family_set)
18379 errmsg ("ip family not set!");
18383 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
18384 mp->is_ip4 = is_ip4;
18389 /* Wait for a reply... */
18395 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
18397 vl_api_gpe_fwd_entry_vnis_get_t *mp;
18400 if (!vam->json_output)
18402 print (vam->ofp, "VNIs");
18405 M (GPE_FWD_ENTRY_VNIS_GET, mp);
18410 /* Wait for a reply... */
18416 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
18418 unformat_input_t *i = vam->input;
18419 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
18421 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
18422 struct in_addr ip4;
18423 struct in6_addr ip6;
18424 u32 table_id = 0, nh_sw_if_index = ~0;
18426 clib_memset (&ip4, 0, sizeof (ip4));
18427 clib_memset (&ip6, 0, sizeof (ip6));
18429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18431 if (unformat (i, "del"))
18433 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
18434 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18439 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
18440 api_unformat_sw_if_index, vam, &nh_sw_if_index))
18445 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
18449 nh_sw_if_index = ~0;
18451 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
18455 nh_sw_if_index = ~0;
18457 else if (unformat (i, "table %d", &table_id))
18461 errmsg ("parse error '%U'", format_unformat_error, i);
18468 errmsg ("nh addr not set!");
18472 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
18473 mp->is_add = is_add;
18474 mp->table_id = clib_host_to_net_u32 (table_id);
18475 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
18476 mp->is_ip4 = is_ip4;
18478 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
18480 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
18485 /* Wait for a reply... */
18491 api_one_map_server_dump (vat_main_t * vam)
18493 vl_api_one_map_server_dump_t *mp;
18494 vl_api_control_ping_t *mp_ping;
18497 if (!vam->json_output)
18499 print (vam->ofp, "%=20s", "Map server");
18502 M (ONE_MAP_SERVER_DUMP, mp);
18506 /* Use a control ping for synchronization */
18507 MPING (CONTROL_PING, mp_ping);
18510 /* Wait for a reply... */
18515 #define api_lisp_map_server_dump api_one_map_server_dump
18518 api_one_map_resolver_dump (vat_main_t * vam)
18520 vl_api_one_map_resolver_dump_t *mp;
18521 vl_api_control_ping_t *mp_ping;
18524 if (!vam->json_output)
18526 print (vam->ofp, "%=20s", "Map resolver");
18529 M (ONE_MAP_RESOLVER_DUMP, mp);
18533 /* Use a control ping for synchronization */
18534 MPING (CONTROL_PING, mp_ping);
18537 /* Wait for a reply... */
18542 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
18545 api_one_stats_flush (vat_main_t * vam)
18547 vl_api_one_stats_flush_t *mp;
18550 M (ONE_STATS_FLUSH, mp);
18557 api_one_stats_dump (vat_main_t * vam)
18559 vl_api_one_stats_dump_t *mp;
18560 vl_api_control_ping_t *mp_ping;
18563 M (ONE_STATS_DUMP, mp);
18567 /* Use a control ping for synchronization */
18568 MPING (CONTROL_PING, mp_ping);
18571 /* Wait for a reply... */
18577 api_show_one_status (vat_main_t * vam)
18579 vl_api_show_one_status_t *mp;
18582 if (!vam->json_output)
18584 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
18587 M (SHOW_ONE_STATUS, mp);
18590 /* Wait for a reply... */
18595 #define api_show_lisp_status api_show_one_status
18598 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
18600 vl_api_gpe_fwd_entry_path_dump_t *mp;
18601 vl_api_control_ping_t *mp_ping;
18602 unformat_input_t *i = vam->input;
18603 u32 fwd_entry_index = ~0;
18606 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18608 if (unformat (i, "index %d", &fwd_entry_index))
18614 if (~0 == fwd_entry_index)
18616 errmsg ("no index specified!");
18620 if (!vam->json_output)
18622 print (vam->ofp, "first line");
18625 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
18629 /* Use a control ping for synchronization */
18630 MPING (CONTROL_PING, mp_ping);
18633 /* Wait for a reply... */
18639 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
18641 vl_api_one_get_map_request_itr_rlocs_t *mp;
18644 if (!vam->json_output)
18646 print (vam->ofp, "%=20s", "itr-rlocs:");
18649 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
18652 /* Wait for a reply... */
18657 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
18660 api_af_packet_create (vat_main_t * vam)
18662 unformat_input_t *i = vam->input;
18663 vl_api_af_packet_create_t *mp;
18664 u8 *host_if_name = 0;
18666 u8 random_hw_addr = 1;
18669 clib_memset (hw_addr, 0, sizeof (hw_addr));
18671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18673 if (unformat (i, "name %s", &host_if_name))
18674 vec_add1 (host_if_name, 0);
18675 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
18676 random_hw_addr = 0;
18681 if (!vec_len (host_if_name))
18683 errmsg ("host-interface name must be specified");
18687 if (vec_len (host_if_name) > 64)
18689 errmsg ("host-interface name too long");
18693 M (AF_PACKET_CREATE, mp);
18695 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18696 clib_memcpy (mp->hw_addr, hw_addr, 6);
18697 mp->use_random_hw_addr = random_hw_addr;
18698 vec_free (host_if_name);
18706 fprintf (vam->ofp ? vam->ofp : stderr,
18707 " new sw_if_index = %d\n", vam->sw_if_index);
18714 api_af_packet_delete (vat_main_t * vam)
18716 unformat_input_t *i = vam->input;
18717 vl_api_af_packet_delete_t *mp;
18718 u8 *host_if_name = 0;
18721 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18723 if (unformat (i, "name %s", &host_if_name))
18724 vec_add1 (host_if_name, 0);
18729 if (!vec_len (host_if_name))
18731 errmsg ("host-interface name must be specified");
18735 if (vec_len (host_if_name) > 64)
18737 errmsg ("host-interface name too long");
18741 M (AF_PACKET_DELETE, mp);
18743 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
18744 vec_free (host_if_name);
18751 static void vl_api_af_packet_details_t_handler
18752 (vl_api_af_packet_details_t * mp)
18754 vat_main_t *vam = &vat_main;
18756 print (vam->ofp, "%-16s %d",
18757 mp->host_if_name, clib_net_to_host_u32 (mp->sw_if_index));
18760 static void vl_api_af_packet_details_t_handler_json
18761 (vl_api_af_packet_details_t * mp)
18763 vat_main_t *vam = &vat_main;
18764 vat_json_node_t *node = NULL;
18766 if (VAT_JSON_ARRAY != vam->json_tree.type)
18768 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18769 vat_json_init_array (&vam->json_tree);
18771 node = vat_json_array_add (&vam->json_tree);
18773 vat_json_init_object (node);
18774 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
18775 vat_json_object_add_string_copy (node, "dev_name", mp->host_if_name);
18779 api_af_packet_dump (vat_main_t * vam)
18781 vl_api_af_packet_dump_t *mp;
18782 vl_api_control_ping_t *mp_ping;
18785 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
18786 /* Get list of tap interfaces */
18787 M (AF_PACKET_DUMP, mp);
18790 /* Use a control ping for synchronization */
18791 MPING (CONTROL_PING, mp_ping);
18799 api_policer_add_del (vat_main_t * vam)
18801 unformat_input_t *i = vam->input;
18802 vl_api_policer_add_del_t *mp;
18812 u8 color_aware = 0;
18813 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
18816 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
18817 conform_action.dscp = 0;
18818 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
18819 exceed_action.dscp = 0;
18820 violate_action.action_type = SSE2_QOS_ACTION_DROP;
18821 violate_action.dscp = 0;
18823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18825 if (unformat (i, "del"))
18827 else if (unformat (i, "name %s", &name))
18828 vec_add1 (name, 0);
18829 else if (unformat (i, "cir %u", &cir))
18831 else if (unformat (i, "eir %u", &eir))
18833 else if (unformat (i, "cb %u", &cb))
18835 else if (unformat (i, "eb %u", &eb))
18837 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
18840 else if (unformat (i, "round_type %U", unformat_policer_round_type,
18843 else if (unformat (i, "type %U", unformat_policer_type, &type))
18845 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
18848 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
18851 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
18854 else if (unformat (i, "color-aware"))
18860 if (!vec_len (name))
18862 errmsg ("policer name must be specified");
18866 if (vec_len (name) > 64)
18868 errmsg ("policer name too long");
18872 M (POLICER_ADD_DEL, mp);
18874 clib_memcpy (mp->name, name, vec_len (name));
18876 mp->is_add = is_add;
18877 mp->cir = ntohl (cir);
18878 mp->eir = ntohl (eir);
18879 mp->cb = clib_net_to_host_u64 (cb);
18880 mp->eb = clib_net_to_host_u64 (eb);
18881 mp->rate_type = rate_type;
18882 mp->round_type = round_type;
18884 mp->conform_action_type = conform_action.action_type;
18885 mp->conform_dscp = conform_action.dscp;
18886 mp->exceed_action_type = exceed_action.action_type;
18887 mp->exceed_dscp = exceed_action.dscp;
18888 mp->violate_action_type = violate_action.action_type;
18889 mp->violate_dscp = violate_action.dscp;
18890 mp->color_aware = color_aware;
18898 api_policer_dump (vat_main_t * vam)
18900 unformat_input_t *i = vam->input;
18901 vl_api_policer_dump_t *mp;
18902 vl_api_control_ping_t *mp_ping;
18903 u8 *match_name = 0;
18904 u8 match_name_valid = 0;
18907 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18909 if (unformat (i, "name %s", &match_name))
18911 vec_add1 (match_name, 0);
18912 match_name_valid = 1;
18918 M (POLICER_DUMP, mp);
18919 mp->match_name_valid = match_name_valid;
18920 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
18921 vec_free (match_name);
18925 /* Use a control ping for synchronization */
18926 MPING (CONTROL_PING, mp_ping);
18929 /* Wait for a reply... */
18935 api_policer_classify_set_interface (vat_main_t * vam)
18937 unformat_input_t *i = vam->input;
18938 vl_api_policer_classify_set_interface_t *mp;
18940 int sw_if_index_set;
18941 u32 ip4_table_index = ~0;
18942 u32 ip6_table_index = ~0;
18943 u32 l2_table_index = ~0;
18947 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18949 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18950 sw_if_index_set = 1;
18951 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18952 sw_if_index_set = 1;
18953 else if (unformat (i, "del"))
18955 else if (unformat (i, "ip4-table %d", &ip4_table_index))
18957 else if (unformat (i, "ip6-table %d", &ip6_table_index))
18959 else if (unformat (i, "l2-table %d", &l2_table_index))
18963 clib_warning ("parse error '%U'", format_unformat_error, i);
18968 if (sw_if_index_set == 0)
18970 errmsg ("missing interface name or sw_if_index");
18974 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
18976 mp->sw_if_index = ntohl (sw_if_index);
18977 mp->ip4_table_index = ntohl (ip4_table_index);
18978 mp->ip6_table_index = ntohl (ip6_table_index);
18979 mp->l2_table_index = ntohl (l2_table_index);
18980 mp->is_add = is_add;
18988 api_policer_classify_dump (vat_main_t * vam)
18990 unformat_input_t *i = vam->input;
18991 vl_api_policer_classify_dump_t *mp;
18992 vl_api_control_ping_t *mp_ping;
18993 u8 type = POLICER_CLASSIFY_N_TABLES;
18996 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
19000 errmsg ("classify table type must be specified");
19004 if (!vam->json_output)
19006 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19009 M (POLICER_CLASSIFY_DUMP, mp);
19014 /* Use a control ping for synchronization */
19015 MPING (CONTROL_PING, mp_ping);
19018 /* Wait for a reply... */
19024 api_netmap_create (vat_main_t * vam)
19026 unformat_input_t *i = vam->input;
19027 vl_api_netmap_create_t *mp;
19030 u8 random_hw_addr = 1;
19035 clib_memset (hw_addr, 0, sizeof (hw_addr));
19037 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19039 if (unformat (i, "name %s", &if_name))
19040 vec_add1 (if_name, 0);
19041 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
19042 random_hw_addr = 0;
19043 else if (unformat (i, "pipe"))
19045 else if (unformat (i, "master"))
19047 else if (unformat (i, "slave"))
19053 if (!vec_len (if_name))
19055 errmsg ("interface name must be specified");
19059 if (vec_len (if_name) > 64)
19061 errmsg ("interface name too long");
19065 M (NETMAP_CREATE, mp);
19067 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19068 clib_memcpy (mp->hw_addr, hw_addr, 6);
19069 mp->use_random_hw_addr = random_hw_addr;
19070 mp->is_pipe = is_pipe;
19071 mp->is_master = is_master;
19072 vec_free (if_name);
19080 api_netmap_delete (vat_main_t * vam)
19082 unformat_input_t *i = vam->input;
19083 vl_api_netmap_delete_t *mp;
19087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19089 if (unformat (i, "name %s", &if_name))
19090 vec_add1 (if_name, 0);
19095 if (!vec_len (if_name))
19097 errmsg ("interface name must be specified");
19101 if (vec_len (if_name) > 64)
19103 errmsg ("interface name too long");
19107 M (NETMAP_DELETE, mp);
19109 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
19110 vec_free (if_name);
19118 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path_t * fp)
19120 if (fp->afi == IP46_TYPE_IP6)
19122 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19123 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19124 fp->weight, ntohl (fp->sw_if_index), fp->is_local,
19125 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19126 format_ip6_address, fp->next_hop);
19127 else if (fp->afi == IP46_TYPE_IP4)
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_ip4_address, fp->next_hop);
19137 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
19138 vl_api_fib_path_t * fp)
19140 struct in_addr ip4;
19141 struct in6_addr ip6;
19143 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19144 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19145 vat_json_object_add_uint (node, "is_local", fp->is_local);
19146 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19147 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19148 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19149 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19150 if (fp->afi == IP46_TYPE_IP4)
19152 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19153 vat_json_object_add_ip4 (node, "next_hop", ip4);
19155 else if (fp->afi == IP46_TYPE_IP6)
19157 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19158 vat_json_object_add_ip6 (node, "next_hop", ip6);
19163 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
19165 vat_main_t *vam = &vat_main;
19166 int count = ntohl (mp->mt_count);
19167 vl_api_fib_path_t *fp;
19170 print (vam->ofp, "[%d]: sw_if_index %d via:",
19171 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
19173 for (i = 0; i < count; i++)
19175 vl_api_mpls_fib_path_print (vam, fp);
19179 print (vam->ofp, "");
19182 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
19183 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
19186 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
19188 vat_main_t *vam = &vat_main;
19189 vat_json_node_t *node = NULL;
19190 int count = ntohl (mp->mt_count);
19191 vl_api_fib_path_t *fp;
19194 if (VAT_JSON_ARRAY != vam->json_tree.type)
19196 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19197 vat_json_init_array (&vam->json_tree);
19199 node = vat_json_array_add (&vam->json_tree);
19201 vat_json_init_object (node);
19202 vat_json_object_add_uint (node, "tunnel_index",
19203 ntohl (mp->mt_tunnel_index));
19204 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
19206 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
19209 for (i = 0; i < count; i++)
19211 vl_api_mpls_fib_path_json_print (node, fp);
19217 api_mpls_tunnel_dump (vat_main_t * vam)
19219 vl_api_mpls_tunnel_dump_t *mp;
19220 vl_api_control_ping_t *mp_ping;
19221 u32 sw_if_index = ~0;
19224 /* Parse args required to build the message */
19225 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
19227 if (unformat (vam->input, "sw_if_index %d", &sw_if_index))
19231 print (vam->ofp, " sw_if_index %d", sw_if_index);
19233 M (MPLS_TUNNEL_DUMP, mp);
19234 mp->sw_if_index = htonl (sw_if_index);
19237 /* Use a control ping for synchronization */
19238 MPING (CONTROL_PING, mp_ping);
19245 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
19246 #define vl_api_mpls_fib_details_t_print vl_noop_handler
19250 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
19252 vat_main_t *vam = &vat_main;
19253 int count = ntohl (mp->count);
19254 vl_api_fib_path_t *fp;
19258 "table-id %d, label %u, ess_bit %u",
19259 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
19261 for (i = 0; i < count; i++)
19263 vl_api_mpls_fib_path_print (vam, fp);
19268 static void vl_api_mpls_fib_details_t_handler_json
19269 (vl_api_mpls_fib_details_t * mp)
19271 vat_main_t *vam = &vat_main;
19272 int count = ntohl (mp->count);
19273 vat_json_node_t *node = NULL;
19274 vl_api_fib_path_t *fp;
19277 if (VAT_JSON_ARRAY != vam->json_tree.type)
19279 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19280 vat_json_init_array (&vam->json_tree);
19282 node = vat_json_array_add (&vam->json_tree);
19284 vat_json_init_object (node);
19285 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19286 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
19287 vat_json_object_add_uint (node, "label", ntohl (mp->label));
19288 vat_json_object_add_uint (node, "path_count", count);
19290 for (i = 0; i < count; i++)
19292 vl_api_mpls_fib_path_json_print (node, fp);
19298 api_mpls_fib_dump (vat_main_t * vam)
19300 vl_api_mpls_fib_dump_t *mp;
19301 vl_api_control_ping_t *mp_ping;
19304 M (MPLS_FIB_DUMP, mp);
19307 /* Use a control ping for synchronization */
19308 MPING (CONTROL_PING, mp_ping);
19315 #define vl_api_ip_fib_details_t_endian vl_noop_handler
19316 #define vl_api_ip_fib_details_t_print vl_noop_handler
19319 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
19321 vat_main_t *vam = &vat_main;
19322 int count = ntohl (mp->count);
19323 vl_api_fib_path_t *fp;
19327 "table-id %d, prefix %U/%d stats-index %d",
19328 ntohl (mp->table_id), format_ip4_address, mp->address,
19329 mp->address_length, ntohl (mp->stats_index));
19331 for (i = 0; i < count; i++)
19333 if (fp->afi == IP46_TYPE_IP6)
19335 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19336 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19337 "next_hop_table %d",
19338 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19339 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19340 format_ip6_address, fp->next_hop, ntohl (fp->table_id));
19341 else if (fp->afi == IP46_TYPE_IP4)
19343 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19344 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U, "
19345 "next_hop_table %d",
19346 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19347 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19348 format_ip4_address, fp->next_hop, ntohl (fp->table_id));
19353 static void vl_api_ip_fib_details_t_handler_json
19354 (vl_api_ip_fib_details_t * mp)
19356 vat_main_t *vam = &vat_main;
19357 int count = ntohl (mp->count);
19358 vat_json_node_t *node = NULL;
19359 struct in_addr ip4;
19360 struct in6_addr ip6;
19361 vl_api_fib_path_t *fp;
19364 if (VAT_JSON_ARRAY != vam->json_tree.type)
19366 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19367 vat_json_init_array (&vam->json_tree);
19369 node = vat_json_array_add (&vam->json_tree);
19371 vat_json_init_object (node);
19372 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19373 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
19374 vat_json_object_add_ip4 (node, "prefix", ip4);
19375 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19376 vat_json_object_add_uint (node, "path_count", count);
19378 for (i = 0; i < count; i++)
19380 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19381 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19382 vat_json_object_add_uint (node, "is_local", fp->is_local);
19383 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19384 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19385 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19386 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19387 if (fp->afi == IP46_TYPE_IP4)
19389 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19390 vat_json_object_add_ip4 (node, "next_hop", ip4);
19392 else if (fp->afi == IP46_TYPE_IP6)
19394 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19395 vat_json_object_add_ip6 (node, "next_hop", ip6);
19401 api_ip_fib_dump (vat_main_t * vam)
19403 vl_api_ip_fib_dump_t *mp;
19404 vl_api_control_ping_t *mp_ping;
19407 M (IP_FIB_DUMP, mp);
19410 /* Use a control ping for synchronization */
19411 MPING (CONTROL_PING, mp_ping);
19419 api_ip_mfib_dump (vat_main_t * vam)
19421 vl_api_ip_mfib_dump_t *mp;
19422 vl_api_control_ping_t *mp_ping;
19425 M (IP_MFIB_DUMP, mp);
19428 /* Use a control ping for synchronization */
19429 MPING (CONTROL_PING, mp_ping);
19436 static void vl_api_ip_neighbor_details_t_handler
19437 (vl_api_ip_neighbor_details_t * mp)
19439 vat_main_t *vam = &vat_main;
19441 print (vam->ofp, "%c %U %U",
19442 (ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ? 'S' : 'D',
19443 format_vl_api_mac_address, &mp->neighbor.mac_address,
19444 format_vl_api_address, &mp->neighbor.ip_address);
19447 static void vl_api_ip_neighbor_details_t_handler_json
19448 (vl_api_ip_neighbor_details_t * mp)
19451 vat_main_t *vam = &vat_main;
19452 vat_json_node_t *node;
19454 if (VAT_JSON_ARRAY != vam->json_tree.type)
19456 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19457 vat_json_init_array (&vam->json_tree);
19459 node = vat_json_array_add (&vam->json_tree);
19461 vat_json_init_object (node);
19462 vat_json_object_add_string_copy
19464 ((ntohl (mp->neighbor.flags) & IP_NEIGHBOR_FLAG_STATIC) ?
19465 (u8 *) "static" : (u8 *) "dynamic"));
19467 vat_json_object_add_string_copy (node, "link_layer",
19468 format (0, "%U", format_vl_api_mac_address,
19469 &mp->neighbor.mac_address));
19470 vat_json_object_add_address (node, "ip", &mp->neighbor.ip_address);
19474 api_ip_neighbor_dump (vat_main_t * vam)
19476 unformat_input_t *i = vam->input;
19477 vl_api_ip_neighbor_dump_t *mp;
19478 vl_api_control_ping_t *mp_ping;
19480 u32 sw_if_index = ~0;
19483 /* Parse args required to build the message */
19484 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19486 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19488 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19490 else if (unformat (i, "ip6"))
19496 if (sw_if_index == ~0)
19498 errmsg ("missing interface name or sw_if_index");
19502 M (IP_NEIGHBOR_DUMP, mp);
19503 mp->is_ipv6 = (u8) is_ipv6;
19504 mp->sw_if_index = ntohl (sw_if_index);
19507 /* Use a control ping for synchronization */
19508 MPING (CONTROL_PING, mp_ping);
19515 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
19516 #define vl_api_ip6_fib_details_t_print vl_noop_handler
19519 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
19521 vat_main_t *vam = &vat_main;
19522 int count = ntohl (mp->count);
19523 vl_api_fib_path_t *fp;
19527 "table-id %d, prefix %U/%d stats-index %d",
19528 ntohl (mp->table_id), format_ip6_address, mp->address,
19529 mp->address_length, ntohl (mp->stats_index));
19531 for (i = 0; i < count; i++)
19533 if (fp->afi == IP46_TYPE_IP6)
19535 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
19536 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
19537 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
19538 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
19539 format_ip6_address, fp->next_hop);
19540 else if (fp->afi == IP46_TYPE_IP4)
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_ip4_address, fp->next_hop);
19551 static void vl_api_ip6_fib_details_t_handler_json
19552 (vl_api_ip6_fib_details_t * mp)
19554 vat_main_t *vam = &vat_main;
19555 int count = ntohl (mp->count);
19556 vat_json_node_t *node = NULL;
19557 struct in_addr ip4;
19558 struct in6_addr ip6;
19559 vl_api_fib_path_t *fp;
19562 if (VAT_JSON_ARRAY != vam->json_tree.type)
19564 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19565 vat_json_init_array (&vam->json_tree);
19567 node = vat_json_array_add (&vam->json_tree);
19569 vat_json_init_object (node);
19570 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
19571 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
19572 vat_json_object_add_ip6 (node, "prefix", ip6);
19573 vat_json_object_add_uint (node, "mask_length", mp->address_length);
19574 vat_json_object_add_uint (node, "path_count", count);
19576 for (i = 0; i < count; i++)
19578 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
19579 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
19580 vat_json_object_add_uint (node, "is_local", fp->is_local);
19581 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
19582 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
19583 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
19584 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
19585 if (fp->afi == IP46_TYPE_IP4)
19587 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
19588 vat_json_object_add_ip4 (node, "next_hop", ip4);
19590 else if (fp->afi == IP46_TYPE_IP6)
19592 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
19593 vat_json_object_add_ip6 (node, "next_hop", ip6);
19599 api_ip6_fib_dump (vat_main_t * vam)
19601 vl_api_ip6_fib_dump_t *mp;
19602 vl_api_control_ping_t *mp_ping;
19605 M (IP6_FIB_DUMP, mp);
19608 /* Use a control ping for synchronization */
19609 MPING (CONTROL_PING, mp_ping);
19617 api_ip6_mfib_dump (vat_main_t * vam)
19619 vl_api_ip6_mfib_dump_t *mp;
19620 vl_api_control_ping_t *mp_ping;
19623 M (IP6_MFIB_DUMP, mp);
19626 /* Use a control ping for synchronization */
19627 MPING (CONTROL_PING, mp_ping);
19635 api_classify_table_ids (vat_main_t * vam)
19637 vl_api_classify_table_ids_t *mp;
19640 /* Construct the API message */
19641 M (CLASSIFY_TABLE_IDS, mp);
19650 api_classify_table_by_interface (vat_main_t * vam)
19652 unformat_input_t *input = vam->input;
19653 vl_api_classify_table_by_interface_t *mp;
19655 u32 sw_if_index = ~0;
19657 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19659 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19661 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19666 if (sw_if_index == ~0)
19668 errmsg ("missing interface name or sw_if_index");
19672 /* Construct the API message */
19673 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
19675 mp->sw_if_index = ntohl (sw_if_index);
19683 api_classify_table_info (vat_main_t * vam)
19685 unformat_input_t *input = vam->input;
19686 vl_api_classify_table_info_t *mp;
19690 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19692 if (unformat (input, "table_id %d", &table_id))
19697 if (table_id == ~0)
19699 errmsg ("missing table id");
19703 /* Construct the API message */
19704 M (CLASSIFY_TABLE_INFO, mp);
19706 mp->table_id = ntohl (table_id);
19714 api_classify_session_dump (vat_main_t * vam)
19716 unformat_input_t *input = vam->input;
19717 vl_api_classify_session_dump_t *mp;
19718 vl_api_control_ping_t *mp_ping;
19722 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19724 if (unformat (input, "table_id %d", &table_id))
19729 if (table_id == ~0)
19731 errmsg ("missing table id");
19735 /* Construct the API message */
19736 M (CLASSIFY_SESSION_DUMP, mp);
19738 mp->table_id = ntohl (table_id);
19741 /* Use a control ping for synchronization */
19742 MPING (CONTROL_PING, mp_ping);
19750 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
19752 vat_main_t *vam = &vat_main;
19754 print (vam->ofp, "collector_address %U, collector_port %d, "
19755 "src_address %U, vrf_id %d, path_mtu %u, "
19756 "template_interval %u, udp_checksum %d",
19757 format_ip4_address, mp->collector_address,
19758 ntohs (mp->collector_port),
19759 format_ip4_address, mp->src_address,
19760 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
19761 ntohl (mp->template_interval), mp->udp_checksum);
19764 vam->result_ready = 1;
19768 vl_api_ipfix_exporter_details_t_handler_json
19769 (vl_api_ipfix_exporter_details_t * mp)
19771 vat_main_t *vam = &vat_main;
19772 vat_json_node_t node;
19773 struct in_addr collector_address;
19774 struct in_addr src_address;
19776 vat_json_init_object (&node);
19777 clib_memcpy (&collector_address, &mp->collector_address,
19778 sizeof (collector_address));
19779 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
19780 vat_json_object_add_uint (&node, "collector_port",
19781 ntohs (mp->collector_port));
19782 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
19783 vat_json_object_add_ip4 (&node, "src_address", src_address);
19784 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
19785 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
19786 vat_json_object_add_uint (&node, "template_interval",
19787 ntohl (mp->template_interval));
19788 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
19790 vat_json_print (vam->ofp, &node);
19791 vat_json_free (&node);
19793 vam->result_ready = 1;
19797 api_ipfix_exporter_dump (vat_main_t * vam)
19799 vl_api_ipfix_exporter_dump_t *mp;
19802 /* Construct the API message */
19803 M (IPFIX_EXPORTER_DUMP, mp);
19812 api_ipfix_classify_stream_dump (vat_main_t * vam)
19814 vl_api_ipfix_classify_stream_dump_t *mp;
19817 /* Construct the API message */
19818 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
19829 vl_api_ipfix_classify_stream_details_t_handler
19830 (vl_api_ipfix_classify_stream_details_t * mp)
19832 vat_main_t *vam = &vat_main;
19833 print (vam->ofp, "domain_id %d, src_port %d",
19834 ntohl (mp->domain_id), ntohs (mp->src_port));
19836 vam->result_ready = 1;
19840 vl_api_ipfix_classify_stream_details_t_handler_json
19841 (vl_api_ipfix_classify_stream_details_t * mp)
19843 vat_main_t *vam = &vat_main;
19844 vat_json_node_t node;
19846 vat_json_init_object (&node);
19847 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
19848 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
19850 vat_json_print (vam->ofp, &node);
19851 vat_json_free (&node);
19853 vam->result_ready = 1;
19857 api_ipfix_classify_table_dump (vat_main_t * vam)
19859 vl_api_ipfix_classify_table_dump_t *mp;
19860 vl_api_control_ping_t *mp_ping;
19863 if (!vam->json_output)
19865 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
19866 "transport_protocol");
19869 /* Construct the API message */
19870 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
19875 /* Use a control ping for synchronization */
19876 MPING (CONTROL_PING, mp_ping);
19884 vl_api_ipfix_classify_table_details_t_handler
19885 (vl_api_ipfix_classify_table_details_t * mp)
19887 vat_main_t *vam = &vat_main;
19888 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
19889 mp->transport_protocol);
19893 vl_api_ipfix_classify_table_details_t_handler_json
19894 (vl_api_ipfix_classify_table_details_t * mp)
19896 vat_json_node_t *node = NULL;
19897 vat_main_t *vam = &vat_main;
19899 if (VAT_JSON_ARRAY != vam->json_tree.type)
19901 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19902 vat_json_init_array (&vam->json_tree);
19905 node = vat_json_array_add (&vam->json_tree);
19906 vat_json_init_object (node);
19908 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
19909 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
19910 vat_json_object_add_uint (node, "transport_protocol",
19911 mp->transport_protocol);
19915 api_sw_interface_span_enable_disable (vat_main_t * vam)
19917 unformat_input_t *i = vam->input;
19918 vl_api_sw_interface_span_enable_disable_t *mp;
19919 u32 src_sw_if_index = ~0;
19920 u32 dst_sw_if_index = ~0;
19925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19928 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
19930 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
19934 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
19936 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
19938 else if (unformat (i, "disable"))
19940 else if (unformat (i, "rx"))
19942 else if (unformat (i, "tx"))
19944 else if (unformat (i, "both"))
19946 else if (unformat (i, "l2"))
19952 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
19954 mp->sw_if_index_from = htonl (src_sw_if_index);
19955 mp->sw_if_index_to = htonl (dst_sw_if_index);
19965 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
19968 vat_main_t *vam = &vat_main;
19969 u8 *sw_if_from_name = 0;
19970 u8 *sw_if_to_name = 0;
19971 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
19972 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
19973 char *states[] = { "none", "rx", "tx", "both" };
19977 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
19979 if ((u32) p->value[0] == sw_if_index_from)
19981 sw_if_from_name = (u8 *)(p->key);
19985 if ((u32) p->value[0] == sw_if_index_to)
19987 sw_if_to_name = (u8 *)(p->key);
19988 if (sw_if_from_name)
19993 print (vam->ofp, "%20s => %20s (%s) %s",
19994 sw_if_from_name, sw_if_to_name, states[mp->state],
19995 mp->is_l2 ? "l2" : "device");
19999 vl_api_sw_interface_span_details_t_handler_json
20000 (vl_api_sw_interface_span_details_t * mp)
20002 vat_main_t *vam = &vat_main;
20003 vat_json_node_t *node = NULL;
20004 u8 *sw_if_from_name = 0;
20005 u8 *sw_if_to_name = 0;
20006 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
20007 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
20011 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
20013 if ((u32) p->value[0] == sw_if_index_from)
20015 sw_if_from_name = (u8 *)(p->key);
20019 if ((u32) p->value[0] == sw_if_index_to)
20021 sw_if_to_name = (u8 *)(p->key);
20022 if (sw_if_from_name)
20028 if (VAT_JSON_ARRAY != vam->json_tree.type)
20030 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20031 vat_json_init_array (&vam->json_tree);
20033 node = vat_json_array_add (&vam->json_tree);
20035 vat_json_init_object (node);
20036 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
20037 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
20038 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
20039 if (0 != sw_if_to_name)
20041 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
20043 vat_json_object_add_uint (node, "state", mp->state);
20044 vat_json_object_add_uint (node, "is-l2", mp->is_l2);
20048 api_sw_interface_span_dump (vat_main_t * vam)
20050 unformat_input_t *input = vam->input;
20051 vl_api_sw_interface_span_dump_t *mp;
20052 vl_api_control_ping_t *mp_ping;
20056 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20058 if (unformat (input, "l2"))
20064 M (SW_INTERFACE_SPAN_DUMP, mp);
20068 /* Use a control ping for synchronization */
20069 MPING (CONTROL_PING, mp_ping);
20077 api_pg_create_interface (vat_main_t * vam)
20079 unformat_input_t *input = vam->input;
20080 vl_api_pg_create_interface_t *mp;
20084 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20086 if (unformat (input, "if_id %d", &if_id))
20093 errmsg ("missing pg interface index");
20097 /* Construct the API message */
20098 M (PG_CREATE_INTERFACE, mp);
20100 mp->interface_id = ntohl (if_id);
20108 api_pg_capture (vat_main_t * vam)
20110 unformat_input_t *input = vam->input;
20111 vl_api_pg_capture_t *mp;
20116 u8 pcap_file_set = 0;
20119 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20121 if (unformat (input, "if_id %d", &if_id))
20123 else if (unformat (input, "pcap %s", &pcap_file))
20125 else if (unformat (input, "count %d", &count))
20127 else if (unformat (input, "disable"))
20134 errmsg ("missing pg interface index");
20137 if (pcap_file_set > 0)
20139 if (vec_len (pcap_file) > 255)
20141 errmsg ("pcap file name is too long");
20146 u32 name_len = vec_len (pcap_file);
20147 /* Construct the API message */
20148 M (PG_CAPTURE, mp);
20150 mp->interface_id = ntohl (if_id);
20151 mp->is_enabled = enable;
20152 mp->count = ntohl (count);
20153 mp->pcap_name_length = ntohl (name_len);
20154 if (pcap_file_set != 0)
20156 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
20158 vec_free (pcap_file);
20166 api_pg_enable_disable (vat_main_t * vam)
20168 unformat_input_t *input = vam->input;
20169 vl_api_pg_enable_disable_t *mp;
20172 u8 stream_name_set = 0;
20173 u8 *stream_name = 0;
20175 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20177 if (unformat (input, "stream %s", &stream_name))
20178 stream_name_set = 1;
20179 else if (unformat (input, "disable"))
20185 if (stream_name_set > 0)
20187 if (vec_len (stream_name) > 255)
20189 errmsg ("stream name too long");
20194 u32 name_len = vec_len (stream_name);
20195 /* Construct the API message */
20196 M (PG_ENABLE_DISABLE, mp);
20198 mp->is_enabled = enable;
20199 if (stream_name_set != 0)
20201 mp->stream_name_length = ntohl (name_len);
20202 clib_memcpy (mp->stream_name, stream_name, name_len);
20204 vec_free (stream_name);
20212 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
20214 unformat_input_t *input = vam->input;
20215 vl_api_ip_source_and_port_range_check_add_del_t *mp;
20217 u16 *low_ports = 0;
20218 u16 *high_ports = 0;
20221 vl_api_prefix_t prefix;
20229 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20231 if (unformat (input, "%U", unformat_vl_api_prefix, &prefix))
20233 else if (unformat (input, "vrf %d", &vrf_id))
20235 else if (unformat (input, "del"))
20237 else if (unformat (input, "port %d", &tmp))
20239 if (tmp == 0 || tmp > 65535)
20241 errmsg ("port %d out of range", tmp);
20245 this_hi = this_low + 1;
20246 vec_add1 (low_ports, this_low);
20247 vec_add1 (high_ports, this_hi);
20249 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
20251 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
20253 errmsg ("incorrect range parameters");
20257 /* Note: in debug CLI +1 is added to high before
20258 passing to real fn that does "the work"
20259 (ip_source_and_port_range_check_add_del).
20260 This fn is a wrapper around the binary API fn a
20261 control plane will call, which expects this increment
20262 to have occurred. Hence letting the binary API control
20263 plane fn do the increment for consistency between VAT
20264 and other control planes.
20267 vec_add1 (low_ports, this_low);
20268 vec_add1 (high_ports, this_hi);
20274 if (prefix_set == 0)
20276 errmsg ("<address>/<mask> not specified");
20282 errmsg ("VRF ID required, not specified");
20289 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20293 if (vec_len (low_ports) == 0)
20295 errmsg ("At least one port or port range required");
20299 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
20301 mp->is_add = is_add;
20303 clib_memcpy (&mp->prefix, &prefix, sizeof (prefix));
20305 mp->number_of_ranges = vec_len (low_ports);
20307 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
20308 vec_free (low_ports);
20310 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
20311 vec_free (high_ports);
20313 mp->vrf_id = ntohl (vrf_id);
20321 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
20323 unformat_input_t *input = vam->input;
20324 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
20325 u32 sw_if_index = ~0;
20327 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
20328 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
20332 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
20334 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20336 else if (unformat (input, "sw_if_index %d", &sw_if_index))
20338 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
20340 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
20342 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
20344 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
20346 else if (unformat (input, "del"))
20352 if (sw_if_index == ~0)
20354 errmsg ("Interface required but not specified");
20360 errmsg ("VRF ID required but not specified");
20364 if (tcp_out_vrf_id == 0
20365 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
20368 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
20372 /* Construct the API message */
20373 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
20375 mp->sw_if_index = ntohl (sw_if_index);
20376 mp->is_add = is_add;
20377 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
20378 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
20379 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
20380 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
20385 /* Wait for a reply... */
20391 api_ipsec_gre_tunnel_add_del (vat_main_t * vam)
20393 unformat_input_t *i = vam->input;
20394 vl_api_ipsec_gre_tunnel_add_del_t *mp;
20395 u32 local_sa_id = 0;
20396 u32 remote_sa_id = 0;
20397 vl_api_ip4_address_t src_address;
20398 vl_api_ip4_address_t dst_address;
20402 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20404 if (unformat (i, "local_sa %d", &local_sa_id))
20406 else if (unformat (i, "remote_sa %d", &remote_sa_id))
20409 if (unformat (i, "src %U", unformat_vl_api_ip4_address, &src_address))
20412 if (unformat (i, "dst %U", unformat_vl_api_ip4_address, &dst_address))
20414 else if (unformat (i, "del"))
20418 clib_warning ("parse error '%U'", format_unformat_error, i);
20423 M (IPSEC_GRE_TUNNEL_ADD_DEL, mp);
20425 mp->tunnel.local_sa_id = ntohl (local_sa_id);
20426 mp->tunnel.remote_sa_id = ntohl (remote_sa_id);
20427 clib_memcpy (mp->tunnel.src, &src_address, sizeof (src_address));
20428 clib_memcpy (mp->tunnel.dst, &dst_address, sizeof (dst_address));
20429 mp->is_add = is_add;
20437 api_set_punt (vat_main_t * vam)
20439 unformat_input_t *i = vam->input;
20440 vl_api_set_punt_t *mp;
20447 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20449 if (unformat (i, "ip %d", &ipv))
20451 else if (unformat (i, "protocol %d", &protocol))
20453 else if (unformat (i, "port %d", &port))
20455 else if (unformat (i, "del"))
20459 clib_warning ("parse error '%U'", format_unformat_error, i);
20466 mp->is_add = (u8) is_add;
20467 mp->punt.ipv = (u8) ipv;
20468 mp->punt.l4_protocol = (u8) protocol;
20469 mp->punt.l4_port = htons ((u16) port);
20476 static void vl_api_ipsec_gre_tunnel_details_t_handler
20477 (vl_api_ipsec_gre_tunnel_details_t * mp)
20479 vat_main_t *vam = &vat_main;
20481 print (vam->ofp, "%11d%15U%15U%14d%14d",
20482 ntohl (mp->tunnel.sw_if_index),
20483 format_vl_api_ip4_address, mp->tunnel.src,
20484 format_vl_api_ip4_address, mp->tunnel.dst,
20485 ntohl (mp->tunnel.local_sa_id), ntohl (mp->tunnel.remote_sa_id));
20489 vat_json_object_add_vl_api_ip4 (vat_json_node_t * node,
20491 const vl_api_ip4_address_t addr)
20493 struct in_addr ip4;
20495 clib_memcpy (&ip4, addr, sizeof (ip4));
20496 vat_json_object_add_ip4 (node, name, ip4);
20499 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
20500 (vl_api_ipsec_gre_tunnel_details_t * mp)
20502 vat_main_t *vam = &vat_main;
20503 vat_json_node_t *node = NULL;
20504 struct in_addr ip4;
20506 if (VAT_JSON_ARRAY != vam->json_tree.type)
20508 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20509 vat_json_init_array (&vam->json_tree);
20511 node = vat_json_array_add (&vam->json_tree);
20513 vat_json_init_object (node);
20514 vat_json_object_add_uint (node, "sw_if_index",
20515 ntohl (mp->tunnel.sw_if_index));
20516 vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.src);
20517 vat_json_object_add_vl_api_ip4 (node, "src", mp->tunnel.dst);
20518 vat_json_object_add_uint (node, "local_sa_id",
20519 ntohl (mp->tunnel.local_sa_id));
20520 vat_json_object_add_uint (node, "remote_sa_id",
20521 ntohl (mp->tunnel.remote_sa_id));
20525 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
20527 unformat_input_t *i = vam->input;
20528 vl_api_ipsec_gre_tunnel_dump_t *mp;
20529 vl_api_control_ping_t *mp_ping;
20531 u8 sw_if_index_set = 0;
20534 /* Parse args required to build the message */
20535 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20537 if (unformat (i, "sw_if_index %d", &sw_if_index))
20538 sw_if_index_set = 1;
20543 if (sw_if_index_set == 0)
20548 if (!vam->json_output)
20550 print (vam->ofp, "%11s%15s%15s%14s%14s",
20551 "sw_if_index", "src_address", "dst_address",
20552 "local_sa_id", "remote_sa_id");
20555 /* Get list of gre-tunnel interfaces */
20556 M (IPSEC_GRE_TUNNEL_DUMP, mp);
20558 mp->sw_if_index = htonl (sw_if_index);
20562 /* Use a control ping for synchronization */
20563 MPING (CONTROL_PING, mp_ping);
20571 api_delete_subif (vat_main_t * vam)
20573 unformat_input_t *i = vam->input;
20574 vl_api_delete_subif_t *mp;
20575 u32 sw_if_index = ~0;
20578 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20580 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20582 if (unformat (i, "sw_if_index %d", &sw_if_index))
20588 if (sw_if_index == ~0)
20590 errmsg ("missing sw_if_index");
20594 /* Construct the API message */
20595 M (DELETE_SUBIF, mp);
20596 mp->sw_if_index = ntohl (sw_if_index);
20603 #define foreach_pbb_vtr_op \
20604 _("disable", L2_VTR_DISABLED) \
20605 _("pop", L2_VTR_POP_2) \
20606 _("push", L2_VTR_PUSH_2)
20609 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
20611 unformat_input_t *i = vam->input;
20612 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
20613 u32 sw_if_index = ~0, vtr_op = ~0;
20614 u16 outer_tag = ~0;
20615 u8 dmac[6], smac[6];
20616 u8 dmac_set = 0, smac_set = 0;
20622 /* Shut up coverity */
20623 clib_memset (dmac, 0, sizeof (dmac));
20624 clib_memset (smac, 0, sizeof (smac));
20626 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20628 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20630 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20632 else if (unformat (i, "vtr_op %d", &vtr_op))
20634 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
20637 else if (unformat (i, "translate_pbb_stag"))
20639 if (unformat (i, "%d", &tmp))
20641 vtr_op = L2_VTR_TRANSLATE_2_1;
20647 ("translate_pbb_stag operation requires outer tag definition");
20651 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
20653 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
20655 else if (unformat (i, "sid %d", &sid))
20657 else if (unformat (i, "vlanid %d", &tmp))
20661 clib_warning ("parse error '%U'", format_unformat_error, i);
20666 if ((sw_if_index == ~0) || (vtr_op == ~0))
20668 errmsg ("missing sw_if_index or vtr operation");
20671 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
20672 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
20675 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
20679 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
20680 mp->sw_if_index = ntohl (sw_if_index);
20681 mp->vtr_op = ntohl (vtr_op);
20682 mp->outer_tag = ntohs (outer_tag);
20683 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
20684 clib_memcpy (mp->b_smac, smac, sizeof (smac));
20685 mp->b_vlanid = ntohs (vlanid);
20686 mp->i_sid = ntohl (sid);
20694 api_flow_classify_set_interface (vat_main_t * vam)
20696 unformat_input_t *i = vam->input;
20697 vl_api_flow_classify_set_interface_t *mp;
20699 int sw_if_index_set;
20700 u32 ip4_table_index = ~0;
20701 u32 ip6_table_index = ~0;
20705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20707 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20708 sw_if_index_set = 1;
20709 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20710 sw_if_index_set = 1;
20711 else if (unformat (i, "del"))
20713 else if (unformat (i, "ip4-table %d", &ip4_table_index))
20715 else if (unformat (i, "ip6-table %d", &ip6_table_index))
20719 clib_warning ("parse error '%U'", format_unformat_error, i);
20724 if (sw_if_index_set == 0)
20726 errmsg ("missing interface name or sw_if_index");
20730 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
20732 mp->sw_if_index = ntohl (sw_if_index);
20733 mp->ip4_table_index = ntohl (ip4_table_index);
20734 mp->ip6_table_index = ntohl (ip6_table_index);
20735 mp->is_add = is_add;
20743 api_flow_classify_dump (vat_main_t * vam)
20745 unformat_input_t *i = vam->input;
20746 vl_api_flow_classify_dump_t *mp;
20747 vl_api_control_ping_t *mp_ping;
20748 u8 type = FLOW_CLASSIFY_N_TABLES;
20751 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
20755 errmsg ("classify table type must be specified");
20759 if (!vam->json_output)
20761 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
20764 M (FLOW_CLASSIFY_DUMP, mp);
20769 /* Use a control ping for synchronization */
20770 MPING (CONTROL_PING, mp_ping);
20773 /* Wait for a reply... */
20779 api_feature_enable_disable (vat_main_t * vam)
20781 unformat_input_t *i = vam->input;
20782 vl_api_feature_enable_disable_t *mp;
20784 u8 *feature_name = 0;
20785 u32 sw_if_index = ~0;
20789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20791 if (unformat (i, "arc_name %s", &arc_name))
20793 else if (unformat (i, "feature_name %s", &feature_name))
20796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20800 else if (unformat (i, "disable"))
20808 errmsg ("missing arc name");
20811 if (vec_len (arc_name) > 63)
20813 errmsg ("arc name too long");
20816 if (feature_name == 0)
20818 errmsg ("missing feature name");
20821 if (vec_len (feature_name) > 63)
20823 errmsg ("feature name too long");
20826 if (sw_if_index == ~0)
20828 errmsg ("missing interface name or sw_if_index");
20832 /* Construct the API message */
20833 M (FEATURE_ENABLE_DISABLE, mp);
20834 mp->sw_if_index = ntohl (sw_if_index);
20835 mp->enable = enable;
20836 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
20837 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
20838 vec_free (arc_name);
20839 vec_free (feature_name);
20847 api_sw_interface_tag_add_del (vat_main_t * vam)
20849 unformat_input_t *i = vam->input;
20850 vl_api_sw_interface_tag_add_del_t *mp;
20851 u32 sw_if_index = ~0;
20856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20858 if (unformat (i, "tag %s", &tag))
20860 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20862 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20864 else if (unformat (i, "del"))
20870 if (sw_if_index == ~0)
20872 errmsg ("missing interface name or sw_if_index");
20876 if (enable && (tag == 0))
20878 errmsg ("no tag specified");
20882 /* Construct the API message */
20883 M (SW_INTERFACE_TAG_ADD_DEL, mp);
20884 mp->sw_if_index = ntohl (sw_if_index);
20885 mp->is_add = enable;
20887 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
20895 static void vl_api_l2_xconnect_details_t_handler
20896 (vl_api_l2_xconnect_details_t * mp)
20898 vat_main_t *vam = &vat_main;
20900 print (vam->ofp, "%15d%15d",
20901 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
20904 static void vl_api_l2_xconnect_details_t_handler_json
20905 (vl_api_l2_xconnect_details_t * mp)
20907 vat_main_t *vam = &vat_main;
20908 vat_json_node_t *node = NULL;
20910 if (VAT_JSON_ARRAY != vam->json_tree.type)
20912 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
20913 vat_json_init_array (&vam->json_tree);
20915 node = vat_json_array_add (&vam->json_tree);
20917 vat_json_init_object (node);
20918 vat_json_object_add_uint (node, "rx_sw_if_index",
20919 ntohl (mp->rx_sw_if_index));
20920 vat_json_object_add_uint (node, "tx_sw_if_index",
20921 ntohl (mp->tx_sw_if_index));
20925 api_l2_xconnect_dump (vat_main_t * vam)
20927 vl_api_l2_xconnect_dump_t *mp;
20928 vl_api_control_ping_t *mp_ping;
20931 if (!vam->json_output)
20933 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
20936 M (L2_XCONNECT_DUMP, mp);
20940 /* Use a control ping for synchronization */
20941 MPING (CONTROL_PING, mp_ping);
20949 api_hw_interface_set_mtu (vat_main_t * vam)
20951 unformat_input_t *i = vam->input;
20952 vl_api_hw_interface_set_mtu_t *mp;
20953 u32 sw_if_index = ~0;
20957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
20959 if (unformat (i, "mtu %d", &mtu))
20961 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
20963 else if (unformat (i, "sw_if_index %d", &sw_if_index))
20969 if (sw_if_index == ~0)
20971 errmsg ("missing interface name or sw_if_index");
20977 errmsg ("no mtu specified");
20981 /* Construct the API message */
20982 M (HW_INTERFACE_SET_MTU, mp);
20983 mp->sw_if_index = ntohl (sw_if_index);
20984 mp->mtu = ntohs ((u16) mtu);
20992 api_p2p_ethernet_add (vat_main_t * vam)
20994 unformat_input_t *i = vam->input;
20995 vl_api_p2p_ethernet_add_t *mp;
20996 u32 parent_if_index = ~0;
21002 clib_memset (remote_mac, 0, sizeof (remote_mac));
21003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21005 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21007 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21011 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21013 else if (unformat (i, "sub_id %d", &sub_id))
21017 clib_warning ("parse error '%U'", format_unformat_error, i);
21022 if (parent_if_index == ~0)
21024 errmsg ("missing interface name or sw_if_index");
21029 errmsg ("missing remote mac address");
21034 errmsg ("missing sub-interface id");
21038 M (P2P_ETHERNET_ADD, mp);
21039 mp->parent_if_index = ntohl (parent_if_index);
21040 mp->subif_id = ntohl (sub_id);
21041 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21049 api_p2p_ethernet_del (vat_main_t * vam)
21051 unformat_input_t *i = vam->input;
21052 vl_api_p2p_ethernet_del_t *mp;
21053 u32 parent_if_index = ~0;
21058 clib_memset (remote_mac, 0, sizeof (remote_mac));
21059 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21061 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
21063 else if (unformat (i, "sw_if_index %d", &parent_if_index))
21067 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
21071 clib_warning ("parse error '%U'", format_unformat_error, i);
21076 if (parent_if_index == ~0)
21078 errmsg ("missing interface name or sw_if_index");
21083 errmsg ("missing remote mac address");
21087 M (P2P_ETHERNET_DEL, mp);
21088 mp->parent_if_index = ntohl (parent_if_index);
21089 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
21097 api_lldp_config (vat_main_t * vam)
21099 unformat_input_t *i = vam->input;
21100 vl_api_lldp_config_t *mp;
21102 int tx_interval = 0;
21103 u8 *sys_name = NULL;
21106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21108 if (unformat (i, "system-name %s", &sys_name))
21110 else if (unformat (i, "tx-hold %d", &tx_hold))
21112 else if (unformat (i, "tx-interval %d", &tx_interval))
21116 clib_warning ("parse error '%U'", format_unformat_error, i);
21121 vec_add1 (sys_name, 0);
21123 M (LLDP_CONFIG, mp);
21124 mp->tx_hold = htonl (tx_hold);
21125 mp->tx_interval = htonl (tx_interval);
21126 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
21127 vec_free (sys_name);
21135 api_sw_interface_set_lldp (vat_main_t * vam)
21137 unformat_input_t *i = vam->input;
21138 vl_api_sw_interface_set_lldp_t *mp;
21139 u32 sw_if_index = ~0;
21141 u8 *port_desc = NULL, *mgmt_oid = NULL;
21142 ip4_address_t ip4_addr;
21143 ip6_address_t ip6_addr;
21146 clib_memset (&ip4_addr, 0, sizeof (ip4_addr));
21147 clib_memset (&ip6_addr, 0, sizeof (ip6_addr));
21149 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21151 if (unformat (i, "disable"))
21154 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21156 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21158 else if (unformat (i, "port-desc %s", &port_desc))
21160 else if (unformat (i, "mgmt-ip4 %U", unformat_ip4_address, &ip4_addr))
21162 else if (unformat (i, "mgmt-ip6 %U", unformat_ip6_address, &ip6_addr))
21164 else if (unformat (i, "mgmt-oid %s", &mgmt_oid))
21170 if (sw_if_index == ~0)
21172 errmsg ("missing interface name or sw_if_index");
21176 /* Construct the API message */
21177 vec_add1 (port_desc, 0);
21178 vec_add1 (mgmt_oid, 0);
21179 M (SW_INTERFACE_SET_LLDP, mp);
21180 mp->sw_if_index = ntohl (sw_if_index);
21181 mp->enable = enable;
21182 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
21183 clib_memcpy (mp->mgmt_oid, mgmt_oid, vec_len (mgmt_oid));
21184 clib_memcpy (mp->mgmt_ip4, &ip4_addr, sizeof (ip4_addr));
21185 clib_memcpy (mp->mgmt_ip6, &ip6_addr, sizeof (ip6_addr));
21186 vec_free (port_desc);
21187 vec_free (mgmt_oid);
21195 api_tcp_configure_src_addresses (vat_main_t * vam)
21197 vl_api_tcp_configure_src_addresses_t *mp;
21198 unformat_input_t *i = vam->input;
21199 ip4_address_t v4first, v4last;
21200 ip6_address_t v6first, v6last;
21205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21207 if (unformat (i, "%U - %U",
21208 unformat_ip4_address, &v4first,
21209 unformat_ip4_address, &v4last))
21213 errmsg ("one range per message (range already set)");
21218 else if (unformat (i, "%U - %U",
21219 unformat_ip6_address, &v6first,
21220 unformat_ip6_address, &v6last))
21224 errmsg ("one range per message (range already set)");
21229 else if (unformat (i, "vrf %d", &vrf_id))
21235 if (range_set == 0)
21237 errmsg ("address range not set");
21241 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
21242 mp->vrf_id = ntohl (vrf_id);
21244 if (range_set == 2)
21247 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
21248 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
21253 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
21254 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
21261 static void vl_api_app_namespace_add_del_reply_t_handler
21262 (vl_api_app_namespace_add_del_reply_t * mp)
21264 vat_main_t *vam = &vat_main;
21265 i32 retval = ntohl (mp->retval);
21266 if (vam->async_mode)
21268 vam->async_errors += (retval < 0);
21272 vam->retval = retval;
21274 errmsg ("app ns index %d\n", ntohl (mp->appns_index));
21275 vam->result_ready = 1;
21279 static void vl_api_app_namespace_add_del_reply_t_handler_json
21280 (vl_api_app_namespace_add_del_reply_t * mp)
21282 vat_main_t *vam = &vat_main;
21283 vat_json_node_t node;
21285 vat_json_init_object (&node);
21286 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
21287 vat_json_object_add_uint (&node, "appns_index", ntohl (mp->appns_index));
21289 vat_json_print (vam->ofp, &node);
21290 vat_json_free (&node);
21292 vam->retval = ntohl (mp->retval);
21293 vam->result_ready = 1;
21297 api_app_namespace_add_del (vat_main_t * vam)
21299 vl_api_app_namespace_add_del_t *mp;
21300 unformat_input_t *i = vam->input;
21301 u8 *ns_id = 0, secret_set = 0, sw_if_index_set = 0;
21302 u32 sw_if_index, ip4_fib_id, ip6_fib_id;
21306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21308 if (unformat (i, "id %_%v%_", &ns_id))
21310 else if (unformat (i, "secret %lu", &secret))
21312 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21313 sw_if_index_set = 1;
21314 else if (unformat (i, "ip4_fib_id %d", &ip4_fib_id))
21316 else if (unformat (i, "ip6_fib_id %d", &ip6_fib_id))
21321 if (!ns_id || !secret_set || !sw_if_index_set)
21323 errmsg ("namespace id, secret and sw_if_index must be set");
21326 if (vec_len (ns_id) > 64)
21328 errmsg ("namespace id too long");
21331 M (APP_NAMESPACE_ADD_DEL, mp);
21333 clib_memcpy (mp->namespace_id, ns_id, vec_len (ns_id));
21334 mp->namespace_id_len = vec_len (ns_id);
21335 mp->secret = clib_host_to_net_u64 (secret);
21336 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21337 mp->ip4_fib_id = clib_host_to_net_u32 (ip4_fib_id);
21338 mp->ip6_fib_id = clib_host_to_net_u32 (ip6_fib_id);
21346 api_sock_init_shm (vat_main_t * vam)
21348 #if VPP_API_TEST_BUILTIN == 0
21349 unformat_input_t *i = vam->input;
21350 vl_api_shm_elem_config_t *config = 0;
21351 u64 size = 64 << 20;
21354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21356 if (unformat (i, "size %U", unformat_memory_size, &size))
21363 * Canned custom ring allocator config.
21364 * Should probably parse all of this
21366 vec_validate (config, 6);
21367 config[0].type = VL_API_VLIB_RING;
21368 config[0].size = 256;
21369 config[0].count = 32;
21371 config[1].type = VL_API_VLIB_RING;
21372 config[1].size = 1024;
21373 config[1].count = 16;
21375 config[2].type = VL_API_VLIB_RING;
21376 config[2].size = 4096;
21377 config[2].count = 2;
21379 config[3].type = VL_API_CLIENT_RING;
21380 config[3].size = 256;
21381 config[3].count = 32;
21383 config[4].type = VL_API_CLIENT_RING;
21384 config[4].size = 1024;
21385 config[4].count = 16;
21387 config[5].type = VL_API_CLIENT_RING;
21388 config[5].size = 4096;
21389 config[5].count = 2;
21391 config[6].type = VL_API_QUEUE;
21392 config[6].count = 128;
21393 config[6].size = sizeof (uword);
21395 rv = vl_socket_client_init_shm (config, 1 /* want_pthread */ );
21397 vam->client_index_invalid = 1;
21405 api_dns_enable_disable (vat_main_t * vam)
21407 unformat_input_t *line_input = vam->input;
21408 vl_api_dns_enable_disable_t *mp;
21409 u8 enable_disable = 1;
21412 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21414 if (unformat (line_input, "disable"))
21415 enable_disable = 0;
21416 if (unformat (line_input, "enable"))
21417 enable_disable = 1;
21422 /* Construct the API message */
21423 M (DNS_ENABLE_DISABLE, mp);
21424 mp->enable = enable_disable;
21428 /* Wait for the reply */
21434 api_dns_resolve_name (vat_main_t * vam)
21436 unformat_input_t *line_input = vam->input;
21437 vl_api_dns_resolve_name_t *mp;
21441 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21443 if (unformat (line_input, "%s", &name))
21449 if (vec_len (name) > 127)
21451 errmsg ("name too long");
21455 /* Construct the API message */
21456 M (DNS_RESOLVE_NAME, mp);
21457 memcpy (mp->name, name, vec_len (name));
21462 /* Wait for the reply */
21468 api_dns_resolve_ip (vat_main_t * vam)
21470 unformat_input_t *line_input = vam->input;
21471 vl_api_dns_resolve_ip_t *mp;
21473 ip4_address_t addr4;
21474 ip6_address_t addr6;
21477 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
21479 if (unformat (line_input, "%U", unformat_ip6_address, &addr6))
21481 else if (unformat (line_input, "%U", unformat_ip4_address, &addr4))
21489 errmsg ("missing address");
21493 /* Construct the API message */
21494 M (DNS_RESOLVE_IP, mp);
21495 mp->is_ip6 = is_ip6;
21497 memcpy (mp->address, &addr6, sizeof (addr6));
21499 memcpy (mp->address, &addr4, sizeof (addr4));
21503 /* Wait for the reply */
21509 api_dns_name_server_add_del (vat_main_t * vam)
21511 unformat_input_t *i = vam->input;
21512 vl_api_dns_name_server_add_del_t *mp;
21514 ip6_address_t ip6_server;
21515 ip4_address_t ip4_server;
21520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21522 if (unformat (i, "%U", unformat_ip6_address, &ip6_server))
21524 else if (unformat (i, "%U", unformat_ip4_address, &ip4_server))
21526 else if (unformat (i, "del"))
21530 clib_warning ("parse error '%U'", format_unformat_error, i);
21535 if (ip4_set && ip6_set)
21537 errmsg ("Only one server address allowed per message");
21540 if ((ip4_set + ip6_set) == 0)
21542 errmsg ("Server address required");
21546 /* Construct the API message */
21547 M (DNS_NAME_SERVER_ADD_DEL, mp);
21551 memcpy (mp->server_address, &ip6_server, sizeof (ip6_address_t));
21556 memcpy (mp->server_address, &ip4_server, sizeof (ip4_address_t));
21560 mp->is_add = is_add;
21565 /* Wait for a reply, return good/bad news */
21571 vl_api_session_rules_details_t_handler (vl_api_session_rules_details_t * mp)
21573 vat_main_t *vam = &vat_main;
21578 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21579 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21580 mp->scope, format_ip4_address, &mp->lcl_ip, mp->lcl_plen,
21581 clib_net_to_host_u16 (mp->lcl_port), format_ip4_address,
21582 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21583 clib_net_to_host_u32 (mp->action_index), mp->tag);
21588 "appns %u tp %u scope %d %U/%d %d %U/%d %d action: %d tag: %s",
21589 clib_net_to_host_u32 (mp->appns_index), mp->transport_proto,
21590 mp->scope, format_ip6_address, &mp->lcl_ip, mp->lcl_plen,
21591 clib_net_to_host_u16 (mp->lcl_port), format_ip6_address,
21592 &mp->rmt_ip, mp->rmt_plen, clib_net_to_host_u16 (mp->rmt_port),
21593 clib_net_to_host_u32 (mp->action_index), mp->tag);
21598 vl_api_session_rules_details_t_handler_json (vl_api_session_rules_details_t *
21601 vat_main_t *vam = &vat_main;
21602 vat_json_node_t *node = NULL;
21603 struct in6_addr ip6;
21604 struct in_addr ip4;
21606 if (VAT_JSON_ARRAY != vam->json_tree.type)
21608 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
21609 vat_json_init_array (&vam->json_tree);
21611 node = vat_json_array_add (&vam->json_tree);
21612 vat_json_init_object (node);
21614 vat_json_object_add_uint (node, "is_ip4", mp->is_ip4 ? 1 : 0);
21615 vat_json_object_add_uint (node, "appns_index",
21616 clib_net_to_host_u32 (mp->appns_index));
21617 vat_json_object_add_uint (node, "transport_proto", mp->transport_proto);
21618 vat_json_object_add_uint (node, "scope", mp->scope);
21619 vat_json_object_add_uint (node, "action_index",
21620 clib_net_to_host_u32 (mp->action_index));
21621 vat_json_object_add_uint (node, "lcl_port",
21622 clib_net_to_host_u16 (mp->lcl_port));
21623 vat_json_object_add_uint (node, "rmt_port",
21624 clib_net_to_host_u16 (mp->rmt_port));
21625 vat_json_object_add_uint (node, "lcl_plen", mp->lcl_plen);
21626 vat_json_object_add_uint (node, "rmt_plen", mp->rmt_plen);
21627 vat_json_object_add_string_copy (node, "tag", mp->tag);
21630 clib_memcpy (&ip4, mp->lcl_ip, sizeof (ip4));
21631 vat_json_object_add_ip4 (node, "lcl_ip", ip4);
21632 clib_memcpy (&ip4, mp->rmt_ip, sizeof (ip4));
21633 vat_json_object_add_ip4 (node, "rmt_ip", ip4);
21637 clib_memcpy (&ip6, mp->lcl_ip, sizeof (ip6));
21638 vat_json_object_add_ip6 (node, "lcl_ip", ip6);
21639 clib_memcpy (&ip6, mp->rmt_ip, sizeof (ip6));
21640 vat_json_object_add_ip6 (node, "rmt_ip", ip6);
21645 api_session_rule_add_del (vat_main_t * vam)
21647 vl_api_session_rule_add_del_t *mp;
21648 unformat_input_t *i = vam->input;
21649 u32 proto = ~0, lcl_port, rmt_port, action = 0, lcl_plen, rmt_plen;
21650 u32 appns_index = 0, scope = 0;
21651 ip4_address_t lcl_ip4, rmt_ip4;
21652 ip6_address_t lcl_ip6, rmt_ip6;
21653 u8 is_ip4 = 1, conn_set = 0;
21654 u8 is_add = 1, *tag = 0;
21657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21659 if (unformat (i, "del"))
21661 else if (unformat (i, "add"))
21663 else if (unformat (i, "proto tcp"))
21665 else if (unformat (i, "proto udp"))
21667 else if (unformat (i, "appns %d", &appns_index))
21669 else if (unformat (i, "scope %d", &scope))
21671 else if (unformat (i, "tag %_%v%_", &tag))
21675 (i, "%U/%d %d %U/%d %d", unformat_ip4_address, &lcl_ip4,
21676 &lcl_plen, &lcl_port, unformat_ip4_address, &rmt_ip4, &rmt_plen,
21684 (i, "%U/%d %d %U/%d %d", unformat_ip6_address, &lcl_ip6,
21685 &lcl_plen, &lcl_port, unformat_ip6_address, &rmt_ip6, &rmt_plen,
21691 else if (unformat (i, "action %d", &action))
21696 if (proto == ~0 || !conn_set || action == ~0)
21698 errmsg ("transport proto, connection and action must be set");
21704 errmsg ("scope should be 0-3");
21708 M (SESSION_RULE_ADD_DEL, mp);
21710 mp->is_ip4 = is_ip4;
21711 mp->transport_proto = proto;
21712 mp->lcl_port = clib_host_to_net_u16 ((u16) lcl_port);
21713 mp->rmt_port = clib_host_to_net_u16 ((u16) rmt_port);
21714 mp->lcl_plen = lcl_plen;
21715 mp->rmt_plen = rmt_plen;
21716 mp->action_index = clib_host_to_net_u32 (action);
21717 mp->appns_index = clib_host_to_net_u32 (appns_index);
21719 mp->is_add = is_add;
21722 clib_memcpy (mp->lcl_ip, &lcl_ip4, sizeof (lcl_ip4));
21723 clib_memcpy (mp->rmt_ip, &rmt_ip4, sizeof (rmt_ip4));
21727 clib_memcpy (mp->lcl_ip, &lcl_ip6, sizeof (lcl_ip6));
21728 clib_memcpy (mp->rmt_ip, &rmt_ip6, sizeof (rmt_ip6));
21732 clib_memcpy (mp->tag, tag, vec_len (tag));
21742 api_session_rules_dump (vat_main_t * vam)
21744 vl_api_session_rules_dump_t *mp;
21745 vl_api_control_ping_t *mp_ping;
21748 if (!vam->json_output)
21750 print (vam->ofp, "%=20s", "Session Rules");
21753 M (SESSION_RULES_DUMP, mp);
21757 /* Use a control ping for synchronization */
21758 MPING (CONTROL_PING, mp_ping);
21761 /* Wait for a reply... */
21767 api_ip_container_proxy_add_del (vat_main_t * vam)
21769 vl_api_ip_container_proxy_add_del_t *mp;
21770 unformat_input_t *i = vam->input;
21771 u32 sw_if_index = ~0;
21772 vl_api_prefix_t pfx = { };
21776 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21778 if (unformat (i, "del"))
21780 else if (unformat (i, "add"))
21782 if (unformat (i, "%U", unformat_vl_api_prefix, &pfx))
21784 else if (unformat (i, "sw_if_index %u", &sw_if_index))
21789 if (sw_if_index == ~0 || pfx.address_length == 0)
21791 errmsg ("address and sw_if_index must be set");
21795 M (IP_CONTAINER_PROXY_ADD_DEL, mp);
21797 mp->sw_if_index = clib_host_to_net_u32 (sw_if_index);
21798 mp->is_add = is_add;
21799 clib_memcpy (&mp->pfx, &pfx, sizeof (pfx));
21807 api_qos_record_enable_disable (vat_main_t * vam)
21809 unformat_input_t *i = vam->input;
21810 vl_api_qos_record_enable_disable_t *mp;
21811 u32 sw_if_index, qs = 0xff;
21812 u8 sw_if_index_set = 0;
21816 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
21818 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
21819 sw_if_index_set = 1;
21820 else if (unformat (i, "sw_if_index %d", &sw_if_index))
21821 sw_if_index_set = 1;
21822 else if (unformat (i, "%U", unformat_qos_source, &qs))
21824 else if (unformat (i, "disable"))
21828 clib_warning ("parse error '%U'", format_unformat_error, i);
21833 if (sw_if_index_set == 0)
21835 errmsg ("missing interface name or sw_if_index");
21840 errmsg ("input location must be specified");
21844 M (QOS_RECORD_ENABLE_DISABLE, mp);
21846 mp->sw_if_index = ntohl (sw_if_index);
21847 mp->input_source = qs;
21848 mp->enable = enable;
21857 q_or_quit (vat_main_t * vam)
21859 #if VPP_API_TEST_BUILTIN == 0
21860 longjmp (vam->jump_buf, 1);
21862 return 0; /* not so much */
21866 q (vat_main_t * vam)
21868 return q_or_quit (vam);
21872 quit (vat_main_t * vam)
21874 return q_or_quit (vam);
21878 comment (vat_main_t * vam)
21884 statseg (vat_main_t * vam)
21886 ssvm_private_t *ssvmp = &vam->stat_segment;
21887 ssvm_shared_header_t *shared_header = ssvmp->sh;
21888 vlib_counter_t **counters;
21889 u64 thread0_index1_packets;
21890 u64 thread0_index1_bytes;
21891 f64 vector_rate, input_rate;
21894 uword *counter_vector_by_name;
21895 if (vam->stat_segment_lockp == 0)
21897 errmsg ("Stat segment not mapped...");
21901 /* look up "/if/rx for sw_if_index 1 as a test */
21903 clib_spinlock_lock (vam->stat_segment_lockp);
21905 counter_vector_by_name = (uword *) shared_header->opaque[1];
21907 p = hash_get_mem (counter_vector_by_name, "/if/rx");
21910 clib_spinlock_unlock (vam->stat_segment_lockp);
21911 errmsg ("/if/tx not found?");
21915 /* Fish per-thread vector of combined counters from shared memory */
21916 counters = (vlib_counter_t **) p[0];
21918 if (vec_len (counters[0]) < 2)
21920 clib_spinlock_unlock (vam->stat_segment_lockp);
21921 errmsg ("/if/tx vector length %d", vec_len (counters[0]));
21925 /* Read thread 0 sw_if_index 1 counter */
21926 thread0_index1_packets = counters[0][1].packets;
21927 thread0_index1_bytes = counters[0][1].bytes;
21929 p = hash_get_mem (counter_vector_by_name, "vector_rate");
21932 clib_spinlock_unlock (vam->stat_segment_lockp);
21933 errmsg ("vector_rate not found?");
21937 vector_rate = *(f64 *) (p[0]);
21938 p = hash_get_mem (counter_vector_by_name, "input_rate");
21941 clib_spinlock_unlock (vam->stat_segment_lockp);
21942 errmsg ("input_rate not found?");
21945 input_rate = *(f64 *) (p[0]);
21947 clib_spinlock_unlock (vam->stat_segment_lockp);
21949 print (vam->ofp, "vector_rate %.2f input_rate %.2f",
21950 vector_rate, input_rate);
21951 print (vam->ofp, "thread 0 sw_if_index 1 rx pkts %lld, bytes %lld",
21952 thread0_index1_packets, thread0_index1_bytes);
21958 cmd_cmp (void *a1, void *a2)
21963 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
21967 help (vat_main_t * vam)
21972 unformat_input_t *i = vam->input;
21975 if (unformat (i, "%s", &name))
21979 vec_add1 (name, 0);
21981 hs = hash_get_mem (vam->help_by_name, name);
21983 print (vam->ofp, "usage: %s %s", name, hs[0]);
21985 print (vam->ofp, "No such msg / command '%s'", name);
21990 print (vam->ofp, "Help is available for the following:");
21993 hash_foreach_pair (p, vam->function_by_name,
21995 vec_add1 (cmds, (u8 *)(p->key));
21999 vec_sort_with_function (cmds, cmd_cmp);
22001 for (j = 0; j < vec_len (cmds); j++)
22002 print (vam->ofp, "%s", cmds[j]);
22009 set (vat_main_t * vam)
22011 u8 *name = 0, *value = 0;
22012 unformat_input_t *i = vam->input;
22014 if (unformat (i, "%s", &name))
22016 /* The input buffer is a vector, not a string. */
22017 value = vec_dup (i->buffer);
22018 vec_delete (value, i->index, 0);
22019 /* Almost certainly has a trailing newline */
22020 if (value[vec_len (value) - 1] == '\n')
22021 value[vec_len (value) - 1] = 0;
22022 /* Make sure it's a proper string, one way or the other */
22023 vec_add1 (value, 0);
22024 (void) clib_macro_set_value (&vam->macro_main,
22025 (char *) name, (char *) value);
22028 errmsg ("usage: set <name> <value>");
22036 unset (vat_main_t * vam)
22040 if (unformat (vam->input, "%s", &name))
22041 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
22042 errmsg ("unset: %s wasn't set", name);
22055 macro_sort_cmp (void *a1, void *a2)
22057 macro_sort_t *s1 = a1;
22058 macro_sort_t *s2 = a2;
22060 return strcmp ((char *) (s1->name), (char *) (s2->name));
22064 dump_macro_table (vat_main_t * vam)
22066 macro_sort_t *sort_me = 0, *sm;
22071 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
22073 vec_add2 (sort_me, sm, 1);
22074 sm->name = (u8 *)(p->key);
22075 sm->value = (u8 *) (p->value[0]);
22079 vec_sort_with_function (sort_me, macro_sort_cmp);
22081 if (vec_len (sort_me))
22082 print (vam->ofp, "%-15s%s", "Name", "Value");
22084 print (vam->ofp, "The macro table is empty...");
22086 for (i = 0; i < vec_len (sort_me); i++)
22087 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
22092 dump_node_table (vat_main_t * vam)
22095 vlib_node_t *node, *next_node;
22097 if (vec_len (vam->graph_nodes) == 0)
22099 print (vam->ofp, "Node table empty, issue get_node_graph...");
22103 for (i = 0; i < vec_len (vam->graph_nodes[0]); i++)
22105 node = vam->graph_nodes[0][i];
22106 print (vam->ofp, "[%d] %s", i, node->name);
22107 for (j = 0; j < vec_len (node->next_nodes); j++)
22109 if (node->next_nodes[j] != ~0)
22111 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22112 print (vam->ofp, " [%d] %s", j, next_node->name);
22120 value_sort_cmp (void *a1, void *a2)
22122 name_sort_t *n1 = a1;
22123 name_sort_t *n2 = a2;
22125 if (n1->value < n2->value)
22127 if (n1->value > n2->value)
22134 dump_msg_api_table (vat_main_t * vam)
22136 api_main_t *am = &api_main;
22137 name_sort_t *nses = 0, *ns;
22142 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
22144 vec_add2 (nses, ns, 1);
22145 ns->name = (u8 *)(hp->key);
22146 ns->value = (u32) hp->value[0];
22150 vec_sort_with_function (nses, value_sort_cmp);
22152 for (i = 0; i < vec_len (nses); i++)
22153 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
22159 get_msg_id (vat_main_t * vam)
22164 if (unformat (vam->input, "%s", &name_and_crc))
22166 message_index = vl_msg_api_get_msg_index (name_and_crc);
22167 if (message_index == ~0)
22169 print (vam->ofp, " '%s' not found", name_and_crc);
22172 print (vam->ofp, " '%s' has message index %d",
22173 name_and_crc, message_index);
22176 errmsg ("name_and_crc required...");
22181 search_node_table (vat_main_t * vam)
22183 unformat_input_t *line_input = vam->input;
22186 vlib_node_t *node, *next_node;
22189 if (vam->graph_node_index_by_name == 0)
22191 print (vam->ofp, "Node table empty, issue get_node_graph...");
22195 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
22197 if (unformat (line_input, "%s", &node_to_find))
22199 vec_add1 (node_to_find, 0);
22200 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
22203 print (vam->ofp, "%s not found...", node_to_find);
22206 node = vam->graph_nodes[0][p[0]];
22207 print (vam->ofp, "[%d] %s", p[0], node->name);
22208 for (j = 0; j < vec_len (node->next_nodes); j++)
22210 if (node->next_nodes[j] != ~0)
22212 next_node = vam->graph_nodes[0][node->next_nodes[j]];
22213 print (vam->ofp, " [%d] %s", j, next_node->name);
22220 clib_warning ("parse error '%U'", format_unformat_error,
22226 vec_free (node_to_find);
22235 script (vat_main_t * vam)
22237 #if (VPP_API_TEST_BUILTIN==0)
22239 char *save_current_file;
22240 unformat_input_t save_input;
22241 jmp_buf save_jump_buf;
22242 u32 save_line_number;
22244 FILE *new_fp, *save_ifp;
22246 if (unformat (vam->input, "%s", &s))
22248 new_fp = fopen ((char *) s, "r");
22251 errmsg ("Couldn't open script file %s", s);
22258 errmsg ("Missing script name");
22262 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
22263 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
22264 save_ifp = vam->ifp;
22265 save_line_number = vam->input_line_number;
22266 save_current_file = (char *) vam->current_file;
22268 vam->input_line_number = 0;
22270 vam->current_file = s;
22273 clib_memcpy (&vam->input, &save_input, sizeof (save_input));
22274 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
22275 vam->ifp = save_ifp;
22276 vam->input_line_number = save_line_number;
22277 vam->current_file = (u8 *) save_current_file;
22282 clib_warning ("use the exec command...");
22288 echo (vat_main_t * vam)
22290 print (vam->ofp, "%v", vam->input->buffer);
22294 /* List of API message constructors, CLI names map to api_xxx */
22295 #define foreach_vpe_api_msg \
22296 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
22297 _(sw_interface_dump,"") \
22298 _(sw_interface_set_flags, \
22299 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
22300 _(sw_interface_add_del_address, \
22301 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
22302 _(sw_interface_set_rx_mode, \
22303 "<intfc> | sw_if_index <id> [queue <id>] <polling | interrupt | adaptive>") \
22304 _(sw_interface_set_rx_placement, \
22305 "<intfc> | sw_if_index <id> [queue <id>] [worker <id> | main]") \
22306 _(sw_interface_rx_placement_dump, \
22307 "[<intfc> | sw_if_index <id>]") \
22308 _(sw_interface_set_table, \
22309 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
22310 _(sw_interface_set_mpls_enable, \
22311 "<intfc> | sw_if_index [disable | dis]") \
22312 _(sw_interface_set_vpath, \
22313 "<intfc> | sw_if_index <id> enable | disable") \
22314 _(sw_interface_set_vxlan_bypass, \
22315 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22316 _(sw_interface_set_geneve_bypass, \
22317 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
22318 _(sw_interface_set_l2_xconnect, \
22319 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22320 "enable | disable") \
22321 _(sw_interface_set_l2_bridge, \
22322 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
22323 "[shg <split-horizon-group>] [bvi]\n" \
22324 "enable | disable") \
22325 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
22326 _(bridge_domain_add_del, \
22327 "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") \
22328 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
22330 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
22331 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
22332 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
22334 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22336 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
22338 "id <num> [hw-addr <mac-addr>] [host-ns <name>] [rx-ring-size <num> [tx-ring-size <num>]") \
22340 "<vpp-if-name> | sw_if_index <id>") \
22341 _(sw_interface_tap_v2_dump, "") \
22342 _(virtio_pci_create, \
22343 "pci-addr <pci-address> [use_random_mac | hw-addr <mac-addr>] [tx-ring-size <num> [rx-ring-size <num>] [features <hex-value>]") \
22344 _(virtio_pci_delete, \
22345 "<vpp-if-name> | sw_if_index <id>") \
22346 _(sw_interface_virtio_pci_dump, "") \
22348 "[hw-addr <mac-addr>] {round-robin | active-backup | " \
22349 "broadcast | {lacp | xor} [load-balance { l2 | l23 | l34 }]} " \
22352 "<vpp-if-name> | sw_if_index <id>") \
22354 "sw_if_index <n> bond <sw_if_index> [is_passive] [is_long_timeout]") \
22355 _(bond_detach_slave, \
22356 "sw_if_index <n>") \
22357 _(sw_interface_bond_dump, "") \
22358 _(sw_interface_slave_dump, \
22359 "<vpp-if-name> | sw_if_index <id>") \
22360 _(ip_table_add_del, \
22361 "table <n> [ipv6] [add | del]\n") \
22362 _(ip_add_del_route, \
22363 "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
22364 "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
22365 "[weight <n>] [drop] [local] [classify <n>] [out-label <n>]\n" \
22366 "[multipath] [count <n>] [del]") \
22367 _(ip_mroute_add_del, \
22368 "<src> <grp>/<mask> [table-id <n>]\n" \
22369 "[<intfc> | sw_if_index <id>] [local] [del]") \
22370 _(mpls_table_add_del, \
22371 "table <n> [add | del]\n") \
22372 _(mpls_route_add_del, \
22373 "<label> <eos> via <addr | next-hop-table <n> | via-label <n> |\n" \
22374 "lookup-ip4-table <n> | lookup-in-ip6-table <n> |\n" \
22375 "l2-input-on <intfc> | l2-input-on sw_if_index <id>>\n" \
22376 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>] [weight <n>]\n" \
22377 "[drop] [local] [classify <n>] [out-label <n>] [multipath]\n" \
22378 "[count <n>] [del]") \
22379 _(mpls_ip_bind_unbind, \
22380 "<label> <addr/len>") \
22381 _(mpls_tunnel_add_del, \
22382 "[add | del <intfc | sw_if_index <id>>] via <addr | via-label <n>>\n" \
22383 "[<intfc> | sw_if_index <id> | next-hop-table <id>]\n" \
22384 "[l2-only] [out-label <n>]") \
22385 _(sr_mpls_policy_add, \
22386 "bsid <id> [weight <n>] [spray] next <sid> [next <sid>]") \
22387 _(sr_mpls_policy_del, \
22389 _(bier_table_add_del, \
22390 "<label> <sub-domain> <set> <bsl> [del]") \
22391 _(bier_route_add_del, \
22392 "<bit-position> <sub-domain> <set> <bsl> via <addr> [table-id <n>]\n" \
22393 "[<intfc> | sw_if_index <id>]" \
22394 "[weight <n>] [del] [multipath]") \
22395 _(proxy_arp_add_del, \
22396 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
22397 _(proxy_arp_intfc_enable_disable, \
22398 "<intfc> | sw_if_index <id> enable | disable") \
22399 _(sw_interface_set_unnumbered, \
22400 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
22401 _(ip_neighbor_add_del, \
22402 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
22403 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
22404 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
22405 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
22406 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
22407 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
22408 "[outer_vlan_id_any][inner_vlan_id_any]") \
22409 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
22410 _(reset_fib, "vrf <n> [ipv6]") \
22411 _(dhcp_proxy_config, \
22412 "svr <v46-address> src <v46-address>\n" \
22413 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
22414 _(dhcp_proxy_set_vss, \
22415 "tbl_id <n> [fib_id <n> oui <n> | vpn_ascii_id <text>] [ipv6] [del]") \
22416 _(dhcp_proxy_dump, "ip6") \
22417 _(dhcp_client_config, \
22418 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
22419 _(set_ip_flow_hash, \
22420 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
22421 _(sw_interface_ip6_enable_disable, \
22422 "<intfc> | sw_if_index <id> enable | disable") \
22423 _(ip6nd_proxy_add_del, \
22424 "<intfc> | sw_if_index <id> <ip6-address>") \
22425 _(ip6nd_proxy_dump, "") \
22426 _(sw_interface_ip6nd_ra_prefix, \
22427 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
22428 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
22429 "[nolink] [isno]") \
22430 _(sw_interface_ip6nd_ra_config, \
22431 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
22432 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
22433 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
22434 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
22435 _(l2_patch_add_del, \
22436 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
22437 "enable | disable") \
22438 _(sr_localsid_add_del, \
22439 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
22440 "fib-table <num> (end.psp) sw_if_index <num>") \
22441 _(classify_add_del_table, \
22442 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
22443 " [del] [del-chain] mask <mask-value>\n" \
22444 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
22445 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
22446 _(classify_add_del_session, \
22447 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
22448 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
22449 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
22450 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
22451 _(classify_set_interface_ip_table, \
22452 "<intfc> | sw_if_index <nn> table <nn>") \
22453 _(classify_set_interface_l2_tables, \
22454 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22455 " [other-table <nn>]") \
22456 _(get_node_index, "node <node-name") \
22457 _(add_node_next, "node <node-name> next <next-node-name>") \
22458 _(l2tpv3_create_tunnel, \
22459 "client_address <ip6-addr> our_address <ip6-addr>\n" \
22460 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
22461 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
22462 _(l2tpv3_set_tunnel_cookies, \
22463 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
22464 "[new_remote_cookie <nn>]\n") \
22465 _(l2tpv3_interface_enable_disable, \
22466 "<intfc> | sw_if_index <nn> enable | disable") \
22467 _(l2tpv3_set_lookup_key, \
22468 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
22469 _(sw_if_l2tpv3_tunnel_dump, "") \
22470 _(vxlan_offload_rx, \
22471 "hw { <interface name> | hw_if_index <nn>} " \
22472 "rx { <vxlan tunnel name> | sw_if_index <nn> } [del]") \
22473 _(vxlan_add_del_tunnel, \
22474 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22475 "{ <intfc> | mcast_sw_if_index <nn> } [instance <id>]}\n" \
22476 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22477 _(geneve_add_del_tunnel, \
22478 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
22479 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22480 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
22481 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22482 _(geneve_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22483 _(gre_tunnel_add_del, \
22484 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [instance <n>]\n" \
22485 "[teb | erspan <session-id>] [del]") \
22486 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22487 _(l2_fib_clear_table, "") \
22488 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
22489 _(l2_interface_vlan_tag_rewrite, \
22490 "<intfc> | sw_if_index <nn> \n" \
22491 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
22492 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
22493 _(create_vhost_user_if, \
22494 "socket <filename> [server] [renumber <dev_instance>] " \
22495 "[disable_mrg_rxbuf] [disable_indirect_desc] " \
22496 "[mac <mac_address>]") \
22497 _(modify_vhost_user_if, \
22498 "<intfc> | sw_if_index <nn> socket <filename>\n" \
22499 "[server] [renumber <dev_instance>]") \
22500 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
22501 _(sw_interface_vhost_user_dump, "") \
22502 _(show_version, "") \
22503 _(show_threads, "") \
22504 _(vxlan_gpe_add_del_tunnel, \
22505 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
22506 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
22507 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
22508 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
22509 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
22510 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
22511 _(interface_name_renumber, \
22512 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
22513 _(input_acl_set_interface, \
22514 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22515 " [l2-table <nn>] [del]") \
22516 _(ip_probe_neighbor, "(<intc> | sw_if_index <nn>) address <ip4|ip6-addr>") \
22517 _(ip_scan_neighbor_enable_disable, "[ip4|ip6|both|disable] [interval <n-min>]\n" \
22518 " [max-time <n-usec>] [max-update <n>] [delay <n-msec>] [stale <n-min>]") \
22519 _(want_ip4_arp_events, "address <ip4-address> [del]") \
22520 _(want_ip6_nd_events, "address <ip6-address> [del]") \
22521 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
22522 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
22523 _(ip_dump, "ipv4 | ipv6") \
22524 _(ipsec_spd_add_del, "spd_id <n> [del]") \
22525 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
22527 _(ipsec_sad_entry_add_del, "sad_id <n> spi <n> crypto_alg <alg>\n" \
22528 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
22529 " integ_alg <alg> integ_key <hex>") \
22530 _(ipsec_spd_entry_add_del, "spd_id <n> priority <n> action <action>\n" \
22531 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
22532 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
22533 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
22534 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
22535 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
22536 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
22537 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
22538 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n" \
22539 " [instance <n>]") \
22540 _(ipsec_sa_dump, "[sa_id <n>]") \
22541 _(ipsec_tunnel_if_set_key, "<intfc> <local|remote> <crypto|integ>\n" \
22542 " <alg> <hex>\n") \
22543 _(ipsec_tunnel_if_set_sa, "<intfc> sa_id <n> <inbound|outbound>\n") \
22544 _(delete_loopback,"sw_if_index <nn>") \
22545 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
22546 _(bd_ip_mac_flush, "bd_id <bridge-domain-id>") \
22547 _(bd_ip_mac_dump, "[bd_id] <bridge-domain-id>") \
22548 _(want_interface_events, "enable|disable") \
22549 _(get_first_msg_id, "client <name>") \
22550 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
22551 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
22552 "fib-id <nn> [ip4][ip6][default]") \
22553 _(get_node_graph, " ") \
22554 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
22555 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
22556 _(ioam_disable, "") \
22557 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
22558 " sw_if_index <sw_if_index> p <priority> " \
22559 "w <weight>] [del]") \
22560 _(one_add_del_locator, "locator-set <locator_name> " \
22561 "iface <intf> | sw_if_index <sw_if_index> " \
22562 "p <priority> w <weight> [del]") \
22563 _(one_add_del_local_eid,"vni <vni> eid " \
22564 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22565 "locator-set <locator_name> [del]" \
22566 "[key-id sha1|sha256 secret-key <secret-key>]")\
22567 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
22568 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
22569 _(one_enable_disable, "enable|disable") \
22570 _(one_map_register_enable_disable, "enable|disable") \
22571 _(one_map_register_fallback_threshold, "<value>") \
22572 _(one_rloc_probe_enable_disable, "enable|disable") \
22573 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22575 "rloc <locator> p <prio> " \
22576 "w <weight> [rloc <loc> ... ] " \
22577 "action <action> [del-all]") \
22578 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22580 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22581 _(one_use_petr, "ip-address> | disable") \
22582 _(one_map_request_mode, "src-dst|dst-only") \
22583 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22584 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22585 _(one_locator_set_dump, "[local | remote]") \
22586 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
22587 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22588 "[local] | [remote]") \
22589 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
22590 _(one_ndp_bd_get, "") \
22591 _(one_ndp_entries_get, "bd <bridge-domain>") \
22592 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
22593 _(one_l2_arp_bd_get, "") \
22594 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
22595 _(one_stats_enable_disable, "enable|disable") \
22596 _(show_one_stats_enable_disable, "") \
22597 _(one_eid_table_vni_dump, "") \
22598 _(one_eid_table_map_dump, "l2|l3") \
22599 _(one_map_resolver_dump, "") \
22600 _(one_map_server_dump, "") \
22601 _(one_adjacencies_get, "vni <vni>") \
22602 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
22603 _(show_one_rloc_probe_state, "") \
22604 _(show_one_map_register_state, "") \
22605 _(show_one_status, "") \
22606 _(one_stats_dump, "") \
22607 _(one_stats_flush, "") \
22608 _(one_get_map_request_itr_rlocs, "") \
22609 _(one_map_register_set_ttl, "<ttl>") \
22610 _(one_set_transport_protocol, "udp|api") \
22611 _(one_get_transport_protocol, "") \
22612 _(one_enable_disable_xtr_mode, "enable|disable") \
22613 _(one_show_xtr_mode, "") \
22614 _(one_enable_disable_pitr_mode, "enable|disable") \
22615 _(one_show_pitr_mode, "") \
22616 _(one_enable_disable_petr_mode, "enable|disable") \
22617 _(one_show_petr_mode, "") \
22618 _(show_one_nsh_mapping, "") \
22619 _(show_one_pitr, "") \
22620 _(show_one_use_petr, "") \
22621 _(show_one_map_request_mode, "") \
22622 _(show_one_map_register_ttl, "") \
22623 _(show_one_map_register_fallback_threshold, "") \
22624 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
22625 " sw_if_index <sw_if_index> p <priority> " \
22626 "w <weight>] [del]") \
22627 _(lisp_add_del_locator, "locator-set <locator_name> " \
22628 "iface <intf> | sw_if_index <sw_if_index> " \
22629 "p <priority> w <weight> [del]") \
22630 _(lisp_add_del_local_eid,"vni <vni> eid " \
22631 "<ipv4|ipv6>/<prefix> | <L2 address> " \
22632 "locator-set <locator_name> [del]" \
22633 "[key-id sha1|sha256 secret-key <secret-key>]") \
22634 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
22635 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
22636 _(lisp_enable_disable, "enable|disable") \
22637 _(lisp_map_register_enable_disable, "enable|disable") \
22638 _(lisp_rloc_probe_enable_disable, "enable|disable") \
22639 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
22641 "rloc <locator> p <prio> " \
22642 "w <weight> [rloc <loc> ... ] " \
22643 "action <action> [del-all]") \
22644 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
22646 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
22647 _(lisp_use_petr, "<ip-address> | disable") \
22648 _(lisp_map_request_mode, "src-dst|dst-only") \
22649 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
22650 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
22651 _(lisp_locator_set_dump, "[local | remote]") \
22652 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
22653 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
22654 "[local] | [remote]") \
22655 _(lisp_eid_table_vni_dump, "") \
22656 _(lisp_eid_table_map_dump, "l2|l3") \
22657 _(lisp_map_resolver_dump, "") \
22658 _(lisp_map_server_dump, "") \
22659 _(lisp_adjacencies_get, "vni <vni>") \
22660 _(gpe_fwd_entry_vnis_get, "") \
22661 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
22662 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
22663 "[table <table-id>]") \
22664 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
22665 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
22666 _(gpe_set_encap_mode, "lisp|vxlan") \
22667 _(gpe_get_encap_mode, "") \
22668 _(lisp_gpe_add_del_iface, "up|down") \
22669 _(lisp_gpe_enable_disable, "enable|disable") \
22670 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
22671 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
22672 _(show_lisp_rloc_probe_state, "") \
22673 _(show_lisp_map_register_state, "") \
22674 _(show_lisp_status, "") \
22675 _(lisp_get_map_request_itr_rlocs, "") \
22676 _(show_lisp_pitr, "") \
22677 _(show_lisp_use_petr, "") \
22678 _(show_lisp_map_request_mode, "") \
22679 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
22680 _(af_packet_delete, "name <host interface name>") \
22681 _(af_packet_dump, "") \
22682 _(policer_add_del, "name <policer name> <params> [del]") \
22683 _(policer_dump, "[name <policer name>]") \
22684 _(policer_classify_set_interface, \
22685 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22686 " [l2-table <nn>] [del]") \
22687 _(policer_classify_dump, "type [ip4|ip6|l2]") \
22688 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
22689 "[master|slave]") \
22690 _(netmap_delete, "name <interface name>") \
22691 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
22692 _(mpls_fib_dump, "") \
22693 _(classify_table_ids, "") \
22694 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
22695 _(classify_table_info, "table_id <nn>") \
22696 _(classify_session_dump, "table_id <nn>") \
22697 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
22698 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
22699 "[template_interval <nn>] [udp_checksum]") \
22700 _(ipfix_exporter_dump, "") \
22701 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
22702 _(ipfix_classify_stream_dump, "") \
22703 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
22704 _(ipfix_classify_table_dump, "") \
22705 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
22706 _(sw_interface_span_dump, "[l2]") \
22707 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
22708 _(pg_create_interface, "if_id <nn>") \
22709 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
22710 _(pg_enable_disable, "[stream <id>] disable") \
22711 _(ip_source_and_port_range_check_add_del, \
22712 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
22713 _(ip_source_and_port_range_check_interface_add_del, \
22714 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
22715 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
22716 _(ipsec_gre_tunnel_add_del, \
22717 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
22718 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
22719 _(delete_subif,"<intfc> | sw_if_index <nn>") \
22720 _(l2_interface_pbb_tag_rewrite, \
22721 "<intfc> | sw_if_index <nn> \n" \
22722 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
22723 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
22724 _(set_punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
22725 _(flow_classify_set_interface, \
22726 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
22727 _(flow_classify_dump, "type [ip4|ip6]") \
22728 _(ip_fib_dump, "") \
22729 _(ip_mfib_dump, "") \
22730 _(ip6_fib_dump, "") \
22731 _(ip6_mfib_dump, "") \
22732 _(feature_enable_disable, "arc_name <arc_name> " \
22733 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
22734 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
22736 _(l2_xconnect_dump, "") \
22737 _(hw_interface_set_mtu, "<intfc> | hw_if_index <nn> mtu <nn>") \
22738 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
22739 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
22740 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
22741 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
22742 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
22743 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>]\n" \
22744 " [mgmt-ip4 <ip4>] [mgmt-ip6 <ip6>] [mgmt-oid <object id>] [disable]") \
22745 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]") \
22746 _(sock_init_shm, "size <nnn>") \
22747 _(app_namespace_add_del, "[add] id <ns-id> secret <nn> sw_if_index <nn>")\
22748 _(dns_enable_disable, "[enable][disable]") \
22749 _(dns_name_server_add_del, "<ip-address> [del]") \
22750 _(dns_resolve_name, "<hostname>") \
22751 _(dns_resolve_ip, "<ip4|ip6>") \
22752 _(dns_name_server_add_del, "<ip-address> [del]") \
22753 _(dns_resolve_name, "<hostname>") \
22754 _(session_rule_add_del, "[add|del] proto <tcp/udp> <lcl-ip>/<plen> " \
22755 "<lcl-port> <rmt-ip>/<plen> <rmt-port> action <nn>") \
22756 _(session_rules_dump, "") \
22757 _(ip_container_proxy_add_del, "[add|del] <address> <sw_if_index>") \
22758 _(output_acl_set_interface, \
22759 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
22760 " [l2-table <nn>] [del]") \
22761 _(qos_record_enable_disable, "<record-source> <intfc> | sw_if_index <id> [disable]")
22763 /* List of command functions, CLI names map directly to functions */
22764 #define foreach_cli_function \
22765 _(comment, "usage: comment <ignore-rest-of-line>") \
22766 _(dump_interface_table, "usage: dump_interface_table") \
22767 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
22768 _(dump_ipv4_table, "usage: dump_ipv4_table") \
22769 _(dump_ipv6_table, "usage: dump_ipv6_table") \
22770 _(dump_macro_table, "usage: dump_macro_table ") \
22771 _(dump_node_table, "usage: dump_node_table") \
22772 _(dump_msg_api_table, "usage: dump_msg_api_table") \
22773 _(get_msg_id, "usage: get_msg_id name_and_crc") \
22774 _(echo, "usage: echo <message>") \
22775 _(exec, "usage: exec <vpe-debug-CLI-command>") \
22776 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
22777 _(help, "usage: help") \
22778 _(q, "usage: quit") \
22779 _(quit, "usage: quit") \
22780 _(search_node_table, "usage: search_node_table <name>...") \
22781 _(set, "usage: set <variable-name> <value>") \
22782 _(script, "usage: script <file-name>") \
22783 _(statseg, "usage: statseg"); \
22784 _(unset, "usage: unset <variable-name>")
22787 static void vl_api_##n##_t_handler_uni \
22788 (vl_api_##n##_t * mp) \
22790 vat_main_t * vam = &vat_main; \
22791 if (vam->json_output) { \
22792 vl_api_##n##_t_handler_json(mp); \
22794 vl_api_##n##_t_handler(mp); \
22797 foreach_vpe_api_reply_msg;
22798 #if VPP_API_TEST_BUILTIN == 0
22799 foreach_standalone_reply_msg;
22804 vat_api_hookup (vat_main_t * vam)
22807 vl_msg_api_set_handlers(VL_API_##N, #n, \
22808 vl_api_##n##_t_handler_uni, \
22810 vl_api_##n##_t_endian, \
22811 vl_api_##n##_t_print, \
22812 sizeof(vl_api_##n##_t), 1);
22813 foreach_vpe_api_reply_msg;
22814 #if VPP_API_TEST_BUILTIN == 0
22815 foreach_standalone_reply_msg;
22819 #if (VPP_API_TEST_BUILTIN==0)
22820 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
22822 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
22824 vam->function_by_name = hash_create_string (0, sizeof (uword));
22826 vam->help_by_name = hash_create_string (0, sizeof (uword));
22829 /* API messages we can send */
22830 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
22831 foreach_vpe_api_msg;
22835 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22836 foreach_vpe_api_msg;
22839 /* CLI functions */
22840 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
22841 foreach_cli_function;
22845 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
22846 foreach_cli_function;
22850 #if VPP_API_TEST_BUILTIN
22851 static clib_error_t *
22852 vat_api_hookup_shim (vlib_main_t * vm)
22854 vat_api_hookup (&vat_main);
22858 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
22862 * fd.io coding-style-patch-verification: ON
22865 * eval: (c-set-style "gnu")