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 <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = (u8 *) mp->reply_in_shmem;
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = (u8 *) (mp->reply_in_shmem);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1287 * Special-case: build the bridge domain table, maintain
1288 * the next bd id vbl.
1290 static void vl_api_bridge_domain_details_t_handler
1291 (vl_api_bridge_domain_details_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1296 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1297 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1299 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1300 ntohl (mp->bd_id), mp->learn, mp->forward,
1301 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1304 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1307 static void vl_api_bridge_domain_details_t_handler_json
1308 (vl_api_bridge_domain_details_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 vat_json_node_t *node, *array = NULL;
1313 if (VAT_JSON_ARRAY != vam->json_tree.type)
1315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1316 vat_json_init_array (&vam->json_tree);
1318 node = vat_json_array_add (&vam->json_tree);
1320 vat_json_init_object (node);
1321 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1322 vat_json_object_add_uint (node, "flood", mp->flood);
1323 vat_json_object_add_uint (node, "forward", mp->forward);
1324 vat_json_object_add_uint (node, "learn", mp->learn);
1325 vat_json_object_add_uint (node, "bvi_sw_if_index",
1326 ntohl (mp->bvi_sw_if_index));
1327 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1328 array = vat_json_object_add (node, "sw_if");
1329 vat_json_init_array (array);
1333 * Special-case: build the bridge domain sw if table.
1335 static void vl_api_bridge_domain_sw_if_details_t_handler
1336 (vl_api_bridge_domain_sw_if_details_t * mp)
1338 vat_main_t *vam = &vat_main;
1343 sw_if_index = ntohl (mp->sw_if_index);
1345 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1347 if ((u32) p->value[0] == sw_if_index)
1349 sw_if_name = (u8 *)(p->key);
1355 print (vam->ofp, "%7d %3d %s", sw_if_index,
1356 mp->shg, sw_if_name ? (char *) sw_if_name :
1357 "sw_if_index not found!");
1360 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1361 (vl_api_bridge_domain_sw_if_details_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 vat_json_node_t *node = NULL;
1365 uword last_index = 0;
1367 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1368 ASSERT (vec_len (vam->json_tree.array) >= 1);
1369 last_index = vec_len (vam->json_tree.array) - 1;
1370 node = &vam->json_tree.array[last_index];
1371 node = vat_json_object_get_element (node, "sw_if");
1372 ASSERT (NULL != node);
1373 node = vat_json_array_add (node);
1375 vat_json_init_object (node);
1376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1377 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1378 vat_json_object_add_uint (node, "shg", mp->shg);
1381 static void vl_api_control_ping_reply_t_handler
1382 (vl_api_control_ping_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 i32 retval = ntohl (mp->retval);
1386 if (vam->async_mode)
1388 vam->async_errors += (retval < 0);
1392 vam->retval = retval;
1393 vam->result_ready = 1;
1397 static void vl_api_control_ping_reply_t_handler_json
1398 (vl_api_control_ping_reply_t * mp)
1400 vat_main_t *vam = &vat_main;
1401 i32 retval = ntohl (mp->retval);
1403 if (VAT_JSON_NONE != vam->json_tree.type)
1405 vat_json_print (vam->ofp, &vam->json_tree);
1406 vat_json_free (&vam->json_tree);
1407 vam->json_tree.type = VAT_JSON_NONE;
1412 vat_json_init_array (&vam->json_tree);
1413 vat_json_print (vam->ofp, &vam->json_tree);
1414 vam->json_tree.type = VAT_JSON_NONE;
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 i32 retval = ntohl (mp->retval);
1426 if (vam->async_mode)
1428 vam->async_errors += (retval < 0);
1432 vam->retval = retval;
1433 vam->result_ready = 1;
1437 static void vl_api_l2_flags_reply_t_handler_json
1438 (vl_api_l2_flags_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 vat_json_node_t node;
1443 vat_json_init_object (&node);
1444 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1445 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1446 ntohl (mp->resulting_feature_bitmap));
1448 vat_json_print (vam->ofp, &node);
1449 vat_json_free (&node);
1451 vam->retval = ntohl (mp->retval);
1452 vam->result_ready = 1;
1455 static void vl_api_bridge_flags_reply_t_handler
1456 (vl_api_bridge_flags_reply_t * mp)
1458 vat_main_t *vam = &vat_main;
1459 i32 retval = ntohl (mp->retval);
1460 if (vam->async_mode)
1462 vam->async_errors += (retval < 0);
1466 vam->retval = retval;
1467 vam->result_ready = 1;
1471 static void vl_api_bridge_flags_reply_t_handler_json
1472 (vl_api_bridge_flags_reply_t * mp)
1474 vat_main_t *vam = &vat_main;
1475 vat_json_node_t node;
1477 vat_json_init_object (&node);
1478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1479 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1480 ntohl (mp->resulting_feature_bitmap));
1482 vat_json_print (vam->ofp, &node);
1483 vat_json_free (&node);
1485 vam->retval = ntohl (mp->retval);
1486 vam->result_ready = 1;
1489 static void vl_api_tap_connect_reply_t_handler
1490 (vl_api_tap_connect_reply_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 i32 retval = ntohl (mp->retval);
1494 if (vam->async_mode)
1496 vam->async_errors += (retval < 0);
1500 vam->retval = retval;
1501 vam->sw_if_index = ntohl (mp->sw_if_index);
1502 vam->result_ready = 1;
1507 static void vl_api_tap_connect_reply_t_handler_json
1508 (vl_api_tap_connect_reply_t * mp)
1510 vat_main_t *vam = &vat_main;
1511 vat_json_node_t node;
1513 vat_json_init_object (&node);
1514 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1515 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1517 vat_json_print (vam->ofp, &node);
1518 vat_json_free (&node);
1520 vam->retval = ntohl (mp->retval);
1521 vam->result_ready = 1;
1526 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 i32 retval = ntohl (mp->retval);
1530 if (vam->async_mode)
1532 vam->async_errors += (retval < 0);
1536 vam->retval = retval;
1537 vam->sw_if_index = ntohl (mp->sw_if_index);
1538 vam->result_ready = 1;
1542 static void vl_api_tap_modify_reply_t_handler_json
1543 (vl_api_tap_modify_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1552 vat_json_print (vam->ofp, &node);
1553 vat_json_free (&node);
1555 vam->retval = ntohl (mp->retval);
1556 vam->result_ready = 1;
1560 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_tap_delete_reply_t_handler_json
1576 (vl_api_tap_delete_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_print (vam->ofp, &node);
1585 vat_json_free (&node);
1587 vam->retval = ntohl (mp->retval);
1588 vam->result_ready = 1;
1591 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1592 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1607 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1608 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 vat_json_node_t node;
1613 vat_json_init_object (&node);
1614 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1615 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1616 ntohl (mp->sw_if_index));
1618 vat_json_print (vam->ofp, &node);
1619 vat_json_free (&node);
1621 vam->retval = ntohl (mp->retval);
1622 vam->result_ready = 1;
1625 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1626 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->sw_if_index = ntohl (mp->sw_if_index);
1638 vam->result_ready = 1;
1642 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1643 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 vat_json_node_t node;
1648 vat_json_init_object (&node);
1649 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1650 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 static void vl_api_one_add_del_locator_set_reply_t_handler
1661 (vl_api_one_add_del_locator_set_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1677 (vl_api_one_add_del_locator_set_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1694 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->sw_if_index = ntohl (mp->sw_if_index);
1706 vam->result_ready = 1;
1710 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1711 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1727 static void vl_api_gre_add_del_tunnel_reply_t_handler
1728 (vl_api_gre_add_del_tunnel_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1744 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1745 (vl_api_gre_add_del_tunnel_reply_t * mp)
1747 vat_main_t *vam = &vat_main;
1748 vat_json_node_t node;
1750 vat_json_init_object (&node);
1751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1754 vat_json_print (vam->ofp, &node);
1755 vat_json_free (&node);
1757 vam->retval = ntohl (mp->retval);
1758 vam->result_ready = 1;
1761 static void vl_api_create_vhost_user_if_reply_t_handler
1762 (vl_api_create_vhost_user_if_reply_t * mp)
1764 vat_main_t *vam = &vat_main;
1765 i32 retval = ntohl (mp->retval);
1766 if (vam->async_mode)
1768 vam->async_errors += (retval < 0);
1772 vam->retval = retval;
1773 vam->sw_if_index = ntohl (mp->sw_if_index);
1774 vam->result_ready = 1;
1778 static void vl_api_create_vhost_user_if_reply_t_handler_json
1779 (vl_api_create_vhost_user_if_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1795 static void vl_api_ip_address_details_t_handler
1796 (vl_api_ip_address_details_t * mp)
1798 vat_main_t *vam = &vat_main;
1799 static ip_address_details_t empty_ip_address_details = { {0} };
1800 ip_address_details_t *address = NULL;
1801 ip_details_t *current_ip_details = NULL;
1802 ip_details_t *details = NULL;
1804 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1806 if (!details || vam->current_sw_if_index >= vec_len (details)
1807 || !details[vam->current_sw_if_index].present)
1809 errmsg ("ip address details arrived but not stored");
1810 errmsg ("ip_dump should be called first");
1814 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1816 #define addresses (current_ip_details->addr)
1818 vec_validate_init_empty (addresses, vec_len (addresses),
1819 empty_ip_address_details);
1821 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1823 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1824 address->prefix_length = mp->prefix_length;
1828 static void vl_api_ip_address_details_t_handler_json
1829 (vl_api_ip_address_details_t * mp)
1831 vat_main_t *vam = &vat_main;
1832 vat_json_node_t *node = NULL;
1833 struct in6_addr ip6;
1836 if (VAT_JSON_ARRAY != vam->json_tree.type)
1838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1839 vat_json_init_array (&vam->json_tree);
1841 node = vat_json_array_add (&vam->json_tree);
1843 vat_json_init_object (node);
1846 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1847 vat_json_object_add_ip6 (node, "ip", ip6);
1851 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1852 vat_json_object_add_ip4 (node, "ip", ip4);
1854 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1858 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 static ip_details_t empty_ip_details = { 0 };
1862 ip_details_t *ip = NULL;
1863 u32 sw_if_index = ~0;
1865 sw_if_index = ntohl (mp->sw_if_index);
1867 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1868 sw_if_index, empty_ip_details);
1870 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1877 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1879 vat_main_t *vam = &vat_main;
1881 if (VAT_JSON_ARRAY != vam->json_tree.type)
1883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1884 vat_json_init_array (&vam->json_tree);
1886 vat_json_array_add_uint (&vam->json_tree,
1887 clib_net_to_host_u32 (mp->sw_if_index));
1890 static void vl_api_map_domain_details_t_handler_json
1891 (vl_api_map_domain_details_t * mp)
1893 vat_json_node_t *node = NULL;
1894 vat_main_t *vam = &vat_main;
1895 struct in6_addr ip6;
1898 if (VAT_JSON_ARRAY != vam->json_tree.type)
1900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1901 vat_json_init_array (&vam->json_tree);
1904 node = vat_json_array_add (&vam->json_tree);
1905 vat_json_init_object (node);
1907 vat_json_object_add_uint (node, "domain_index",
1908 clib_net_to_host_u32 (mp->domain_index));
1909 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1910 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1911 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1912 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1913 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1914 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1915 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1916 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1917 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1918 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1919 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1920 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1921 vat_json_object_add_uint (node, "flags", mp->flags);
1922 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1923 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1926 static void vl_api_map_domain_details_t_handler
1927 (vl_api_map_domain_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1931 if (mp->is_translation)
1934 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1935 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1936 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1937 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1938 clib_net_to_host_u32 (mp->domain_index));
1943 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1944 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1945 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1946 format_ip6_address, mp->ip6_src,
1947 clib_net_to_host_u32 (mp->domain_index));
1949 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1950 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1951 mp->is_translation ? "map-t" : "");
1954 static void vl_api_map_rule_details_t_handler_json
1955 (vl_api_map_rule_details_t * mp)
1957 struct in6_addr ip6;
1958 vat_json_node_t *node = NULL;
1959 vat_main_t *vam = &vat_main;
1961 if (VAT_JSON_ARRAY != vam->json_tree.type)
1963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1964 vat_json_init_array (&vam->json_tree);
1967 node = vat_json_array_add (&vam->json_tree);
1968 vat_json_init_object (node);
1970 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1971 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1972 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1976 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1978 vat_main_t *vam = &vat_main;
1979 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1980 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1984 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1986 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1987 "router_addr %U host_mac %U",
1988 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1989 format_ip4_address, &mp->host_address,
1990 format_ip4_address, &mp->router_address,
1991 format_ethernet_address, mp->host_mac);
1994 static void vl_api_dhcp_compl_event_t_handler_json
1995 (vl_api_dhcp_compl_event_t * mp)
1997 /* JSON output not supported */
2001 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2004 vat_main_t *vam = &vat_main;
2005 static u64 default_counter = 0;
2007 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2009 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2010 sw_if_index, default_counter);
2011 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2015 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2016 interface_counter_t counter)
2018 vat_main_t *vam = &vat_main;
2019 static interface_counter_t default_counter = { 0, };
2021 vec_validate_init_empty (vam->combined_interface_counters,
2022 vnet_counter_type, NULL);
2023 vec_validate_init_empty (vam->combined_interface_counters
2024 [vnet_counter_type], sw_if_index, default_counter);
2025 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2028 static void vl_api_vnet_interface_counters_t_handler
2029 (vl_api_vnet_interface_counters_t * mp)
2034 static void vl_api_vnet_interface_counters_t_handler_json
2035 (vl_api_vnet_interface_counters_t * mp)
2037 interface_counter_t counter;
2042 u32 first_sw_if_index;
2045 count = ntohl (mp->count);
2046 first_sw_if_index = ntohl (mp->first_sw_if_index);
2048 if (!mp->is_combined)
2050 v_packets = (u64 *) & mp->data;
2051 for (i = 0; i < count; i++)
2054 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2055 set_simple_interface_counter (mp->vnet_counter_type,
2056 first_sw_if_index + i, packets);
2062 v = (vlib_counter_t *) & mp->data;
2063 for (i = 0; i < count; i++)
2066 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2068 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2069 set_combined_interface_counter (mp->vnet_counter_type,
2070 first_sw_if_index + i, counter);
2077 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2079 vat_main_t *vam = &vat_main;
2082 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2084 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2093 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2095 vat_main_t *vam = &vat_main;
2098 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2100 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2108 static void vl_api_vnet_ip4_fib_counters_t_handler
2109 (vl_api_vnet_ip4_fib_counters_t * mp)
2114 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2115 (vl_api_vnet_ip4_fib_counters_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 vl_api_ip4_fib_counter_t *v;
2119 ip4_fib_counter_t *counter;
2126 vrf_id = ntohl (mp->vrf_id);
2127 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2128 if (~0 == vrf_index)
2130 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2131 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2132 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2133 vec_validate (vam->ip4_fib_counters, vrf_index);
2134 vam->ip4_fib_counters[vrf_index] = NULL;
2137 vec_free (vam->ip4_fib_counters[vrf_index]);
2138 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2139 count = ntohl (mp->count);
2140 for (i = 0; i < count; i++)
2142 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2143 counter = &vam->ip4_fib_counters[vrf_index][i];
2144 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2145 counter->address = ip4;
2146 counter->address_length = v->address_length;
2147 counter->packets = clib_net_to_host_u64 (v->packets);
2148 counter->bytes = clib_net_to_host_u64 (v->bytes);
2153 static void vl_api_vnet_ip4_nbr_counters_t_handler
2154 (vl_api_vnet_ip4_nbr_counters_t * mp)
2159 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2160 (vl_api_vnet_ip4_nbr_counters_t * mp)
2162 vat_main_t *vam = &vat_main;
2163 vl_api_ip4_nbr_counter_t *v;
2164 ip4_nbr_counter_t *counter;
2169 sw_if_index = ntohl (mp->sw_if_index);
2170 count = ntohl (mp->count);
2171 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2174 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2176 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2177 for (i = 0; i < count; i++)
2179 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2180 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2181 counter->address.s_addr = v->address;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2184 counter->linkt = v->link_type;
2189 static void vl_api_vnet_ip6_fib_counters_t_handler
2190 (vl_api_vnet_ip6_fib_counters_t * mp)
2195 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2196 (vl_api_vnet_ip6_fib_counters_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vl_api_ip6_fib_counter_t *v;
2200 ip6_fib_counter_t *counter;
2201 struct in6_addr ip6;
2207 vrf_id = ntohl (mp->vrf_id);
2208 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2209 if (~0 == vrf_index)
2211 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2212 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2213 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2214 vec_validate (vam->ip6_fib_counters, vrf_index);
2215 vam->ip6_fib_counters[vrf_index] = NULL;
2218 vec_free (vam->ip6_fib_counters[vrf_index]);
2219 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2220 count = ntohl (mp->count);
2221 for (i = 0; i < count; i++)
2223 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2224 counter = &vam->ip6_fib_counters[vrf_index][i];
2225 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2226 counter->address = ip6;
2227 counter->address_length = v->address_length;
2228 counter->packets = clib_net_to_host_u64 (v->packets);
2229 counter->bytes = clib_net_to_host_u64 (v->bytes);
2234 static void vl_api_vnet_ip6_nbr_counters_t_handler
2235 (vl_api_vnet_ip6_nbr_counters_t * mp)
2240 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2241 (vl_api_vnet_ip6_nbr_counters_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vl_api_ip6_nbr_counter_t *v;
2245 ip6_nbr_counter_t *counter;
2246 struct in6_addr ip6;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2256 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2263 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2264 counter->address = ip6;
2265 counter->packets = clib_net_to_host_u64 (v->packets);
2266 counter->bytes = clib_net_to_host_u64 (v->bytes);
2271 static void vl_api_get_first_msg_id_reply_t_handler
2272 (vl_api_get_first_msg_id_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 i32 retval = ntohl (mp->retval);
2277 if (vam->async_mode)
2279 vam->async_errors += (retval < 0);
2283 vam->retval = retval;
2284 vam->result_ready = 1;
2288 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2292 static void vl_api_get_first_msg_id_reply_t_handler_json
2293 (vl_api_get_first_msg_id_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2298 vat_json_init_object (&node);
2299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2300 vat_json_object_add_uint (&node, "first_msg_id",
2301 (uint) ntohs (mp->first_msg_id));
2303 vat_json_print (vam->ofp, &node);
2304 vat_json_free (&node);
2306 vam->retval = ntohl (mp->retval);
2307 vam->result_ready = 1;
2310 static void vl_api_get_node_graph_reply_t_handler
2311 (vl_api_get_node_graph_reply_t * mp)
2313 vat_main_t *vam = &vat_main;
2314 api_main_t *am = &api_main;
2315 i32 retval = ntohl (mp->retval);
2316 u8 *pvt_copy, *reply;
2321 if (vam->async_mode)
2323 vam->async_errors += (retval < 0);
2327 vam->retval = retval;
2328 vam->result_ready = 1;
2331 /* "Should never happen..." */
2335 reply = (u8 *) (mp->reply_in_shmem);
2336 pvt_copy = vec_dup (reply);
2338 /* Toss the shared-memory original... */
2339 pthread_mutex_lock (&am->vlib_rp->mutex);
2340 oldheap = svm_push_data_heap (am->vlib_rp);
2344 svm_pop_heap (oldheap);
2345 pthread_mutex_unlock (&am->vlib_rp->mutex);
2347 if (vam->graph_nodes)
2349 hash_free (vam->graph_node_index_by_name);
2351 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2353 node = vam->graph_nodes[i];
2354 vec_free (node->name);
2355 vec_free (node->next_nodes);
2358 vec_free (vam->graph_nodes);
2361 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2362 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2363 vec_free (pvt_copy);
2365 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2367 node = vam->graph_nodes[i];
2368 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2372 static void vl_api_get_node_graph_reply_t_handler_json
2373 (vl_api_get_node_graph_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 api_main_t *am = &api_main;
2378 vat_json_node_t node;
2381 /* $$$$ make this real? */
2382 vat_json_init_object (&node);
2383 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2384 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2386 reply = (u8 *) (mp->reply_in_shmem);
2388 /* Toss the shared-memory original... */
2389 pthread_mutex_lock (&am->vlib_rp->mutex);
2390 oldheap = svm_push_data_heap (am->vlib_rp);
2394 svm_pop_heap (oldheap);
2395 pthread_mutex_unlock (&am->vlib_rp->mutex);
2397 vat_json_print (vam->ofp, &node);
2398 vat_json_free (&node);
2400 vam->retval = ntohl (mp->retval);
2401 vam->result_ready = 1;
2405 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2407 vat_main_t *vam = &vat_main;
2412 s = format (s, "%=16d%=16d%=16d",
2413 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2417 s = format (s, "%=16U%=16d%=16d",
2418 mp->is_ipv6 ? format_ip6_address :
2420 mp->ip_address, mp->priority, mp->weight);
2423 print (vam->ofp, "%v", s);
2428 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 vat_json_node_t *node = NULL;
2432 struct in6_addr ip6;
2435 if (VAT_JSON_ARRAY != vam->json_tree.type)
2437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2438 vat_json_init_array (&vam->json_tree);
2440 node = vat_json_array_add (&vam->json_tree);
2441 vat_json_init_object (node);
2443 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2444 vat_json_object_add_uint (node, "priority", mp->priority);
2445 vat_json_object_add_uint (node, "weight", mp->weight);
2448 vat_json_object_add_uint (node, "sw_if_index",
2449 clib_net_to_host_u32 (mp->sw_if_index));
2454 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2455 vat_json_object_add_ip6 (node, "address", ip6);
2459 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2460 vat_json_object_add_ip4 (node, "address", ip4);
2466 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2469 vat_main_t *vam = &vat_main;
2472 ls_name = format (0, "%s", mp->ls_name);
2474 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2480 vl_api_one_locator_set_details_t_handler_json
2481 (vl_api_one_locator_set_details_t * mp)
2483 vat_main_t *vam = &vat_main;
2484 vat_json_node_t *node = 0;
2487 ls_name = format (0, "%s", mp->ls_name);
2488 vec_add1 (ls_name, 0);
2490 if (VAT_JSON_ARRAY != vam->json_tree.type)
2492 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2493 vat_json_init_array (&vam->json_tree);
2495 node = vat_json_array_add (&vam->json_tree);
2497 vat_json_init_object (node);
2498 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2499 vat_json_object_add_uint (node, "ls_index",
2500 clib_net_to_host_u32 (mp->ls_index));
2505 format_lisp_flat_eid (u8 * s, va_list * args)
2507 u32 type = va_arg (*args, u32);
2508 u8 *eid = va_arg (*args, u8 *);
2509 u32 eid_len = va_arg (*args, u32);
2514 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2516 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2518 return format (s, "%U", format_ethernet_address, eid);
2524 format_lisp_eid_vat (u8 * s, va_list * args)
2526 u32 type = va_arg (*args, u32);
2527 u8 *eid = va_arg (*args, u8 *);
2528 u32 eid_len = va_arg (*args, u32);
2529 u8 *seid = va_arg (*args, u8 *);
2530 u32 seid_len = va_arg (*args, u32);
2531 u32 is_src_dst = va_arg (*args, u32);
2534 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2536 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2542 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2544 vat_main_t *vam = &vat_main;
2545 u8 *s = 0, *eid = 0;
2547 if (~0 == mp->locator_set_index)
2548 s = format (0, "action: %d", mp->action);
2550 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2552 eid = format (0, "%U", format_lisp_eid_vat,
2556 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2559 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2560 clib_net_to_host_u32 (mp->vni),
2562 mp->is_local ? "local" : "remote",
2563 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2564 clib_net_to_host_u16 (mp->key_id), mp->key);
2571 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2574 vat_main_t *vam = &vat_main;
2575 vat_json_node_t *node = 0;
2578 if (VAT_JSON_ARRAY != vam->json_tree.type)
2580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2581 vat_json_init_array (&vam->json_tree);
2583 node = vat_json_array_add (&vam->json_tree);
2585 vat_json_init_object (node);
2586 if (~0 == mp->locator_set_index)
2587 vat_json_object_add_uint (node, "action", mp->action);
2589 vat_json_object_add_uint (node, "locator_set_index",
2590 clib_net_to_host_u32 (mp->locator_set_index));
2592 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2593 eid = format (0, "%U", format_lisp_eid_vat,
2597 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2599 vat_json_object_add_string_copy (node, "eid", eid);
2600 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2602 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2606 vat_json_object_add_uint (node, "key_id",
2607 clib_net_to_host_u16 (mp->key_id));
2608 vat_json_object_add_string_copy (node, "key", mp->key);
2614 vl_api_one_eid_table_map_details_t_handler
2615 (vl_api_one_eid_table_map_details_t * mp)
2617 vat_main_t *vam = &vat_main;
2619 u8 *line = format (0, "%=10d%=10d",
2620 clib_net_to_host_u32 (mp->vni),
2621 clib_net_to_host_u32 (mp->dp_table));
2622 print (vam->ofp, "%v", line);
2627 vl_api_one_eid_table_map_details_t_handler_json
2628 (vl_api_one_eid_table_map_details_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vat_json_node_t *node = NULL;
2633 if (VAT_JSON_ARRAY != vam->json_tree.type)
2635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2636 vat_json_init_array (&vam->json_tree);
2638 node = vat_json_array_add (&vam->json_tree);
2639 vat_json_init_object (node);
2640 vat_json_object_add_uint (node, "dp_table",
2641 clib_net_to_host_u32 (mp->dp_table));
2642 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2646 vl_api_one_eid_table_vni_details_t_handler
2647 (vl_api_one_eid_table_vni_details_t * mp)
2649 vat_main_t *vam = &vat_main;
2651 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2652 print (vam->ofp, "%v", line);
2657 vl_api_one_eid_table_vni_details_t_handler_json
2658 (vl_api_one_eid_table_vni_details_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 vat_json_node_t *node = NULL;
2663 if (VAT_JSON_ARRAY != vam->json_tree.type)
2665 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2666 vat_json_init_array (&vam->json_tree);
2668 node = vat_json_array_add (&vam->json_tree);
2669 vat_json_init_object (node);
2670 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2674 vl_api_show_one_map_register_state_reply_t_handler
2675 (vl_api_show_one_map_register_state_reply_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 int retval = clib_net_to_host_u32 (mp->retval);
2680 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 vl_api_show_one_map_register_state_reply_t_handler_json
2688 (vl_api_show_one_map_register_state_reply_t * mp)
2690 vat_main_t *vam = &vat_main;
2691 vat_json_node_t _node, *node = &_node;
2692 int retval = clib_net_to_host_u32 (mp->retval);
2694 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2696 vat_json_init_object (node);
2697 vat_json_object_add_string_copy (node, "state", s);
2699 vat_json_print (vam->ofp, node);
2700 vat_json_free (node);
2702 vam->retval = retval;
2703 vam->result_ready = 1;
2708 vl_api_show_one_rloc_probe_state_reply_t_handler
2709 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2711 vat_main_t *vam = &vat_main;
2712 int retval = clib_net_to_host_u32 (mp->retval);
2717 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2719 vam->retval = retval;
2720 vam->result_ready = 1;
2724 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2725 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 vat_json_node_t _node, *node = &_node;
2729 int retval = clib_net_to_host_u32 (mp->retval);
2731 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2732 vat_json_init_object (node);
2733 vat_json_object_add_string_copy (node, "state", s);
2735 vat_json_print (vam->ofp, node);
2736 vat_json_free (node);
2738 vam->retval = retval;
2739 vam->result_ready = 1;
2744 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2746 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2747 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2751 gpe_fwd_entries_get_reply_t_net_to_host
2752 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2756 mp->count = clib_net_to_host_u32 (mp->count);
2757 for (i = 0; i < mp->count; i++)
2759 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2764 format_gpe_encap_mode (u8 * s, va_list * args)
2766 u32 mode = va_arg (*args, u32);
2771 return format (s, "lisp");
2773 return format (s, "vxlan");
2779 vl_api_gpe_get_encap_mode_reply_t_handler
2780 (vl_api_gpe_get_encap_mode_reply_t * mp)
2782 vat_main_t *vam = &vat_main;
2784 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2785 vam->retval = ntohl (mp->retval);
2786 vam->result_ready = 1;
2790 vl_api_gpe_get_encap_mode_reply_t_handler_json
2791 (vl_api_gpe_get_encap_mode_reply_t * mp)
2793 vat_main_t *vam = &vat_main;
2794 vat_json_node_t node;
2796 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2797 vec_add1 (encap_mode, 0);
2799 vat_json_init_object (&node);
2800 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2802 vec_free (encap_mode);
2803 vat_json_print (vam->ofp, &node);
2804 vat_json_free (&node);
2806 vam->retval = ntohl (mp->retval);
2807 vam->result_ready = 1;
2811 vl_api_gpe_fwd_entry_path_details_t_handler
2812 (vl_api_gpe_fwd_entry_path_details_t * mp)
2814 vat_main_t *vam = &vat_main;
2815 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2817 if (mp->lcl_loc.is_ip4)
2818 format_ip_address_fcn = format_ip4_address;
2820 format_ip_address_fcn = format_ip6_address;
2822 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2823 format_ip_address_fcn, &mp->lcl_loc,
2824 format_ip_address_fcn, &mp->rmt_loc);
2828 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2830 struct in6_addr ip6;
2835 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2836 vat_json_object_add_ip4 (n, "address", ip4);
2840 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2841 vat_json_object_add_ip6 (n, "address", ip6);
2843 vat_json_object_add_uint (n, "weight", loc->weight);
2847 vl_api_gpe_fwd_entry_path_details_t_handler_json
2848 (vl_api_gpe_fwd_entry_path_details_t * mp)
2850 vat_main_t *vam = &vat_main;
2851 vat_json_node_t *node = NULL;
2852 vat_json_node_t *loc_node;
2854 if (VAT_JSON_ARRAY != vam->json_tree.type)
2856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2857 vat_json_init_array (&vam->json_tree);
2859 node = vat_json_array_add (&vam->json_tree);
2860 vat_json_init_object (node);
2862 loc_node = vat_json_object_add (node, "local_locator");
2863 vat_json_init_object (loc_node);
2864 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2866 loc_node = vat_json_object_add (node, "remote_locator");
2867 vat_json_init_object (loc_node);
2868 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2872 vl_api_gpe_fwd_entries_get_reply_t_handler
2873 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2875 vat_main_t *vam = &vat_main;
2877 int retval = clib_net_to_host_u32 (mp->retval);
2878 vl_api_gpe_fwd_entry_t *e;
2883 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2885 for (i = 0; i < mp->count; i++)
2887 e = &mp->entries[i];
2888 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2889 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2890 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2894 vam->retval = retval;
2895 vam->result_ready = 1;
2899 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2900 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2903 vat_main_t *vam = &vat_main;
2904 vat_json_node_t *e = 0, root;
2906 int retval = clib_net_to_host_u32 (mp->retval);
2907 vl_api_gpe_fwd_entry_t *fwd;
2912 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2913 vat_json_init_array (&root);
2915 for (i = 0; i < mp->count; i++)
2917 e = vat_json_array_add (&root);
2918 fwd = &mp->entries[i];
2920 vat_json_init_object (e);
2921 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2922 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2924 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2925 fwd->leid_prefix_len);
2927 vat_json_object_add_string_copy (e, "leid", s);
2930 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2931 fwd->reid_prefix_len);
2933 vat_json_object_add_string_copy (e, "reid", s);
2937 vat_json_print (vam->ofp, &root);
2938 vat_json_free (&root);
2941 vam->retval = retval;
2942 vam->result_ready = 1;
2946 vl_api_one_adjacencies_get_reply_t_handler
2947 (vl_api_one_adjacencies_get_reply_t * mp)
2949 vat_main_t *vam = &vat_main;
2951 int retval = clib_net_to_host_u32 (mp->retval);
2952 vl_api_one_adjacency_t *a;
2957 n = clib_net_to_host_u32 (mp->count);
2959 for (i = 0; i < n; i++)
2961 a = &mp->adjacencies[i];
2962 print (vam->ofp, "%U %40U",
2963 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2964 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2968 vam->retval = retval;
2969 vam->result_ready = 1;
2973 vl_api_one_adjacencies_get_reply_t_handler_json
2974 (vl_api_one_adjacencies_get_reply_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vat_json_node_t *e = 0, root;
2980 int retval = clib_net_to_host_u32 (mp->retval);
2981 vl_api_one_adjacency_t *a;
2986 n = clib_net_to_host_u32 (mp->count);
2987 vat_json_init_array (&root);
2989 for (i = 0; i < n; i++)
2991 e = vat_json_array_add (&root);
2992 a = &mp->adjacencies[i];
2994 vat_json_init_object (e);
2995 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2996 a->leid_prefix_len);
2998 vat_json_object_add_string_copy (e, "leid", s);
3001 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3002 a->reid_prefix_len);
3004 vat_json_object_add_string_copy (e, "reid", s);
3008 vat_json_print (vam->ofp, &root);
3009 vat_json_free (&root);
3012 vam->retval = retval;
3013 vam->result_ready = 1;
3017 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3019 vat_main_t *vam = &vat_main;
3021 print (vam->ofp, "%=20U",
3022 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3027 vl_api_one_map_server_details_t_handler_json
3028 (vl_api_one_map_server_details_t * mp)
3030 vat_main_t *vam = &vat_main;
3031 vat_json_node_t *node = NULL;
3032 struct in6_addr ip6;
3035 if (VAT_JSON_ARRAY != vam->json_tree.type)
3037 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3038 vat_json_init_array (&vam->json_tree);
3040 node = vat_json_array_add (&vam->json_tree);
3042 vat_json_init_object (node);
3045 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3046 vat_json_object_add_ip6 (node, "map-server", ip6);
3050 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3051 vat_json_object_add_ip4 (node, "map-server", ip4);
3056 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3059 vat_main_t *vam = &vat_main;
3061 print (vam->ofp, "%=20U",
3062 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3067 vl_api_one_map_resolver_details_t_handler_json
3068 (vl_api_one_map_resolver_details_t * mp)
3070 vat_main_t *vam = &vat_main;
3071 vat_json_node_t *node = NULL;
3072 struct in6_addr ip6;
3075 if (VAT_JSON_ARRAY != vam->json_tree.type)
3077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3078 vat_json_init_array (&vam->json_tree);
3080 node = vat_json_array_add (&vam->json_tree);
3082 vat_json_init_object (node);
3085 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3086 vat_json_object_add_ip6 (node, "map resolver", ip6);
3090 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3091 vat_json_object_add_ip4 (node, "map resolver", ip4);
3096 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3098 vat_main_t *vam = &vat_main;
3099 i32 retval = ntohl (mp->retval);
3103 print (vam->ofp, "feature: %s\ngpe: %s",
3104 mp->feature_status ? "enabled" : "disabled",
3105 mp->gpe_status ? "enabled" : "disabled");
3108 vam->retval = retval;
3109 vam->result_ready = 1;
3113 vl_api_show_one_status_reply_t_handler_json
3114 (vl_api_show_one_status_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3117 vat_json_node_t node;
3118 u8 *gpe_status = NULL;
3119 u8 *feature_status = NULL;
3121 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3122 feature_status = format (0, "%s",
3123 mp->feature_status ? "enabled" : "disabled");
3124 vec_add1 (gpe_status, 0);
3125 vec_add1 (feature_status, 0);
3127 vat_json_init_object (&node);
3128 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3129 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3131 vec_free (gpe_status);
3132 vec_free (feature_status);
3134 vat_json_print (vam->ofp, &node);
3135 vat_json_free (&node);
3137 vam->retval = ntohl (mp->retval);
3138 vam->result_ready = 1;
3142 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3143 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3145 vat_main_t *vam = &vat_main;
3146 i32 retval = ntohl (mp->retval);
3150 print (vam->ofp, "%=20s", mp->locator_set_name);
3153 vam->retval = retval;
3154 vam->result_ready = 1;
3158 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3159 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3161 vat_main_t *vam = &vat_main;
3162 vat_json_node_t *node = NULL;
3164 if (VAT_JSON_ARRAY != vam->json_tree.type)
3166 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3167 vat_json_init_array (&vam->json_tree);
3169 node = vat_json_array_add (&vam->json_tree);
3171 vat_json_init_object (node);
3172 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3174 vat_json_print (vam->ofp, node);
3175 vat_json_free (node);
3177 vam->retval = ntohl (mp->retval);
3178 vam->result_ready = 1;
3182 format_lisp_map_request_mode (u8 * s, va_list * args)
3184 u32 mode = va_arg (*args, u32);
3189 return format (0, "dst-only");
3191 return format (0, "src-dst");
3197 vl_api_show_one_map_request_mode_reply_t_handler
3198 (vl_api_show_one_map_request_mode_reply_t * mp)
3200 vat_main_t *vam = &vat_main;
3201 i32 retval = ntohl (mp->retval);
3205 u32 mode = mp->mode;
3206 print (vam->ofp, "map_request_mode: %U",
3207 format_lisp_map_request_mode, mode);
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_show_one_map_request_mode_reply_t_handler_json
3216 (vl_api_show_one_map_request_mode_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t node;
3224 s = format (0, "%U", format_lisp_map_request_mode, mode);
3227 vat_json_init_object (&node);
3228 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3229 vat_json_print (vam->ofp, &node);
3230 vat_json_free (&node);
3233 vam->retval = ntohl (mp->retval);
3234 vam->result_ready = 1;
3238 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3240 vat_main_t *vam = &vat_main;
3241 i32 retval = ntohl (mp->retval);
3245 print (vam->ofp, "%-20s%-16s",
3246 mp->status ? "enabled" : "disabled",
3247 mp->status ? (char *) mp->locator_set_name : "");
3250 vam->retval = retval;
3251 vam->result_ready = 1;
3255 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3257 vat_main_t *vam = &vat_main;
3258 vat_json_node_t node;
3261 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3262 vec_add1 (status, 0);
3264 vat_json_init_object (&node);
3265 vat_json_object_add_string_copy (&node, "status", status);
3268 vat_json_object_add_string_copy (&node, "locator_set",
3269 mp->locator_set_name);
3274 vat_json_print (vam->ofp, &node);
3275 vat_json_free (&node);
3277 vam->retval = ntohl (mp->retval);
3278 vam->result_ready = 1;
3282 format_policer_type (u8 * s, va_list * va)
3284 u32 i = va_arg (*va, u32);
3286 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3287 s = format (s, "1r2c");
3288 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3289 s = format (s, "1r3c");
3290 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3291 s = format (s, "2r3c-2698");
3292 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3293 s = format (s, "2r3c-4115");
3294 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3295 s = format (s, "2r3c-mef5cf1");
3297 s = format (s, "ILLEGAL");
3302 format_policer_rate_type (u8 * s, va_list * va)
3304 u32 i = va_arg (*va, u32);
3306 if (i == SSE2_QOS_RATE_KBPS)
3307 s = format (s, "kbps");
3308 else if (i == SSE2_QOS_RATE_PPS)
3309 s = format (s, "pps");
3311 s = format (s, "ILLEGAL");
3316 format_policer_round_type (u8 * s, va_list * va)
3318 u32 i = va_arg (*va, u32);
3320 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3321 s = format (s, "closest");
3322 else if (i == SSE2_QOS_ROUND_TO_UP)
3323 s = format (s, "up");
3324 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3325 s = format (s, "down");
3327 s = format (s, "ILLEGAL");
3332 format_policer_action_type (u8 * s, va_list * va)
3334 u32 i = va_arg (*va, u32);
3336 if (i == SSE2_QOS_ACTION_DROP)
3337 s = format (s, "drop");
3338 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3339 s = format (s, "transmit");
3340 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3341 s = format (s, "mark-and-transmit");
3343 s = format (s, "ILLEGAL");
3348 format_dscp (u8 * s, va_list * va)
3350 u32 i = va_arg (*va, u32);
3355 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3359 return format (s, "ILLEGAL");
3361 s = format (s, "%s", t);
3366 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3371 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3372 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3374 conform_dscp_str = format (0, "");
3376 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3377 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3379 exceed_dscp_str = format (0, "");
3381 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3382 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3384 violate_dscp_str = format (0, "");
3386 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3387 "rate type %U, round type %U, %s rate, %s color-aware, "
3388 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3389 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3390 "conform action %U%s, exceed action %U%s, violate action %U%s",
3392 format_policer_type, mp->type,
3395 clib_net_to_host_u64 (mp->cb),
3396 clib_net_to_host_u64 (mp->eb),
3397 format_policer_rate_type, mp->rate_type,
3398 format_policer_round_type, mp->round_type,
3399 mp->single_rate ? "single" : "dual",
3400 mp->color_aware ? "is" : "not",
3401 ntohl (mp->cir_tokens_per_period),
3402 ntohl (mp->pir_tokens_per_period),
3404 ntohl (mp->current_limit),
3405 ntohl (mp->current_bucket),
3406 ntohl (mp->extended_limit),
3407 ntohl (mp->extended_bucket),
3408 clib_net_to_host_u64 (mp->last_update_time),
3409 format_policer_action_type, mp->conform_action_type,
3411 format_policer_action_type, mp->exceed_action_type,
3413 format_policer_action_type, mp->violate_action_type,
3416 vec_free (conform_dscp_str);
3417 vec_free (exceed_dscp_str);
3418 vec_free (violate_dscp_str);
3421 static void vl_api_policer_details_t_handler_json
3422 (vl_api_policer_details_t * mp)
3424 vat_main_t *vam = &vat_main;
3425 vat_json_node_t *node;
3426 u8 *rate_type_str, *round_type_str, *type_str;
3427 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3429 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3431 format (0, "%U", format_policer_round_type, mp->round_type);
3432 type_str = format (0, "%U", format_policer_type, mp->type);
3433 conform_action_str = format (0, "%U", format_policer_action_type,
3434 mp->conform_action_type);
3435 exceed_action_str = format (0, "%U", format_policer_action_type,
3436 mp->exceed_action_type);
3437 violate_action_str = format (0, "%U", format_policer_action_type,
3438 mp->violate_action_type);
3440 if (VAT_JSON_ARRAY != vam->json_tree.type)
3442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3443 vat_json_init_array (&vam->json_tree);
3445 node = vat_json_array_add (&vam->json_tree);
3447 vat_json_init_object (node);
3448 vat_json_object_add_string_copy (node, "name", mp->name);
3449 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3450 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3451 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3452 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3453 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3454 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3455 vat_json_object_add_string_copy (node, "type", type_str);
3456 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3457 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3458 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3459 vat_json_object_add_uint (node, "cir_tokens_per_period",
3460 ntohl (mp->cir_tokens_per_period));
3461 vat_json_object_add_uint (node, "eir_tokens_per_period",
3462 ntohl (mp->pir_tokens_per_period));
3463 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3464 vat_json_object_add_uint (node, "current_bucket",
3465 ntohl (mp->current_bucket));
3466 vat_json_object_add_uint (node, "extended_limit",
3467 ntohl (mp->extended_limit));
3468 vat_json_object_add_uint (node, "extended_bucket",
3469 ntohl (mp->extended_bucket));
3470 vat_json_object_add_uint (node, "last_update_time",
3471 ntohl (mp->last_update_time));
3472 vat_json_object_add_string_copy (node, "conform_action",
3473 conform_action_str);
3474 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3476 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3477 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3478 vec_free (dscp_str);
3480 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3481 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3483 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3484 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3485 vec_free (dscp_str);
3487 vat_json_object_add_string_copy (node, "violate_action",
3488 violate_action_str);
3489 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3491 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3492 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3493 vec_free (dscp_str);
3496 vec_free (rate_type_str);
3497 vec_free (round_type_str);
3498 vec_free (type_str);
3499 vec_free (conform_action_str);
3500 vec_free (exceed_action_str);
3501 vec_free (violate_action_str);
3505 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3508 vat_main_t *vam = &vat_main;
3509 int i, count = ntohl (mp->count);
3512 print (vam->ofp, "classify table ids (%d) : ", count);
3513 for (i = 0; i < count; i++)
3515 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3516 print (vam->ofp, (i < count - 1) ? "," : "");
3518 vam->retval = ntohl (mp->retval);
3519 vam->result_ready = 1;
3523 vl_api_classify_table_ids_reply_t_handler_json
3524 (vl_api_classify_table_ids_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3527 int i, count = ntohl (mp->count);
3531 vat_json_node_t node;
3533 vat_json_init_object (&node);
3534 for (i = 0; i < count; i++)
3536 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3538 vat_json_print (vam->ofp, &node);
3539 vat_json_free (&node);
3541 vam->retval = ntohl (mp->retval);
3542 vam->result_ready = 1;
3546 vl_api_classify_table_by_interface_reply_t_handler
3547 (vl_api_classify_table_by_interface_reply_t * mp)
3549 vat_main_t *vam = &vat_main;
3552 table_id = ntohl (mp->l2_table_id);
3554 print (vam->ofp, "l2 table id : %d", table_id);
3556 print (vam->ofp, "l2 table id : No input ACL tables configured");
3557 table_id = ntohl (mp->ip4_table_id);
3559 print (vam->ofp, "ip4 table id : %d", table_id);
3561 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3562 table_id = ntohl (mp->ip6_table_id);
3564 print (vam->ofp, "ip6 table id : %d", table_id);
3566 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3567 vam->retval = ntohl (mp->retval);
3568 vam->result_ready = 1;
3572 vl_api_classify_table_by_interface_reply_t_handler_json
3573 (vl_api_classify_table_by_interface_reply_t * mp)
3575 vat_main_t *vam = &vat_main;
3576 vat_json_node_t node;
3578 vat_json_init_object (&node);
3580 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3581 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3582 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3584 vat_json_print (vam->ofp, &node);
3585 vat_json_free (&node);
3587 vam->retval = ntohl (mp->retval);
3588 vam->result_ready = 1;
3591 static void vl_api_policer_add_del_reply_t_handler
3592 (vl_api_policer_add_del_reply_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 i32 retval = ntohl (mp->retval);
3596 if (vam->async_mode)
3598 vam->async_errors += (retval < 0);
3602 vam->retval = retval;
3603 vam->result_ready = 1;
3604 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3606 * Note: this is just barely thread-safe, depends on
3607 * the main thread spinning waiting for an answer...
3609 errmsg ("policer index %d", ntohl (mp->policer_index));
3613 static void vl_api_policer_add_del_reply_t_handler_json
3614 (vl_api_policer_add_del_reply_t * mp)
3616 vat_main_t *vam = &vat_main;
3617 vat_json_node_t node;
3619 vat_json_init_object (&node);
3620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3621 vat_json_object_add_uint (&node, "policer_index",
3622 ntohl (mp->policer_index));
3624 vat_json_print (vam->ofp, &node);
3625 vat_json_free (&node);
3627 vam->retval = ntohl (mp->retval);
3628 vam->result_ready = 1;
3631 /* Format hex dump. */
3633 format_hex_bytes (u8 * s, va_list * va)
3635 u8 *bytes = va_arg (*va, u8 *);
3636 int n_bytes = va_arg (*va, int);
3639 /* Print short or long form depending on byte count. */
3640 uword short_form = n_bytes <= 32;
3641 uword indent = format_get_indent (s);
3646 for (i = 0; i < n_bytes; i++)
3648 if (!short_form && (i % 32) == 0)
3649 s = format (s, "%08x: ", i);
3650 s = format (s, "%02x", bytes[i]);
3651 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3652 s = format (s, "\n%U", format_white_space, indent);
3659 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3662 vat_main_t *vam = &vat_main;
3663 i32 retval = ntohl (mp->retval);
3666 print (vam->ofp, "classify table info :");
3667 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3668 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3669 ntohl (mp->miss_next_index));
3670 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3671 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3672 ntohl (mp->match_n_vectors));
3673 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3674 ntohl (mp->mask_length));
3676 vam->retval = retval;
3677 vam->result_ready = 1;
3681 vl_api_classify_table_info_reply_t_handler_json
3682 (vl_api_classify_table_info_reply_t * mp)
3684 vat_main_t *vam = &vat_main;
3685 vat_json_node_t node;
3687 i32 retval = ntohl (mp->retval);
3690 vat_json_init_object (&node);
3692 vat_json_object_add_int (&node, "sessions",
3693 ntohl (mp->active_sessions));
3694 vat_json_object_add_int (&node, "nexttbl",
3695 ntohl (mp->next_table_index));
3696 vat_json_object_add_int (&node, "nextnode",
3697 ntohl (mp->miss_next_index));
3698 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3699 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3700 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3701 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3702 ntohl (mp->mask_length), 0);
3703 vat_json_object_add_string_copy (&node, "mask", s);
3705 vat_json_print (vam->ofp, &node);
3706 vat_json_free (&node);
3708 vam->retval = ntohl (mp->retval);
3709 vam->result_ready = 1;
3713 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3716 vat_main_t *vam = &vat_main;
3718 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3719 ntohl (mp->hit_next_index), ntohl (mp->advance),
3720 ntohl (mp->opaque_index));
3721 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3722 ntohl (mp->match_length));
3726 vl_api_classify_session_details_t_handler_json
3727 (vl_api_classify_session_details_t * mp)
3729 vat_main_t *vam = &vat_main;
3730 vat_json_node_t *node = NULL;
3732 if (VAT_JSON_ARRAY != vam->json_tree.type)
3734 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3735 vat_json_init_array (&vam->json_tree);
3737 node = vat_json_array_add (&vam->json_tree);
3739 vat_json_init_object (node);
3740 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3741 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3742 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3744 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3746 vat_json_object_add_string_copy (node, "match", s);
3749 static void vl_api_pg_create_interface_reply_t_handler
3750 (vl_api_pg_create_interface_reply_t * mp)
3752 vat_main_t *vam = &vat_main;
3754 vam->retval = ntohl (mp->retval);
3755 vam->result_ready = 1;
3758 static void vl_api_pg_create_interface_reply_t_handler_json
3759 (vl_api_pg_create_interface_reply_t * mp)
3761 vat_main_t *vam = &vat_main;
3762 vat_json_node_t node;
3764 i32 retval = ntohl (mp->retval);
3767 vat_json_init_object (&node);
3769 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3771 vat_json_print (vam->ofp, &node);
3772 vat_json_free (&node);
3774 vam->retval = ntohl (mp->retval);
3775 vam->result_ready = 1;
3778 static void vl_api_policer_classify_details_t_handler
3779 (vl_api_policer_classify_details_t * mp)
3781 vat_main_t *vam = &vat_main;
3783 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3784 ntohl (mp->table_index));
3787 static void vl_api_policer_classify_details_t_handler_json
3788 (vl_api_policer_classify_details_t * mp)
3790 vat_main_t *vam = &vat_main;
3791 vat_json_node_t *node;
3793 if (VAT_JSON_ARRAY != vam->json_tree.type)
3795 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3796 vat_json_init_array (&vam->json_tree);
3798 node = vat_json_array_add (&vam->json_tree);
3800 vat_json_init_object (node);
3801 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3802 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3805 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3806 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 i32 retval = ntohl (mp->retval);
3810 if (vam->async_mode)
3812 vam->async_errors += (retval < 0);
3816 vam->retval = retval;
3817 vam->sw_if_index = ntohl (mp->sw_if_index);
3818 vam->result_ready = 1;
3822 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3823 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3825 vat_main_t *vam = &vat_main;
3826 vat_json_node_t node;
3828 vat_json_init_object (&node);
3829 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3830 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3832 vat_json_print (vam->ofp, &node);
3833 vat_json_free (&node);
3835 vam->retval = ntohl (mp->retval);
3836 vam->result_ready = 1;
3839 static void vl_api_flow_classify_details_t_handler
3840 (vl_api_flow_classify_details_t * mp)
3842 vat_main_t *vam = &vat_main;
3844 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3845 ntohl (mp->table_index));
3848 static void vl_api_flow_classify_details_t_handler_json
3849 (vl_api_flow_classify_details_t * mp)
3851 vat_main_t *vam = &vat_main;
3852 vat_json_node_t *node;
3854 if (VAT_JSON_ARRAY != vam->json_tree.type)
3856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3857 vat_json_init_array (&vam->json_tree);
3859 node = vat_json_array_add (&vam->json_tree);
3861 vat_json_init_object (node);
3862 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3863 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3868 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3869 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3870 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3871 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3872 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3873 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3874 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3875 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3876 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3877 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3880 * Generate boilerplate reply handlers, which
3881 * dig the return value out of the xxx_reply_t API message,
3882 * stick it into vam->retval, and set vam->result_ready
3884 * Could also do this by pointing N message decode slots at
3885 * a single function, but that could break in subtle ways.
3888 #define foreach_standard_reply_retval_handler \
3889 _(sw_interface_set_flags_reply) \
3890 _(sw_interface_add_del_address_reply) \
3891 _(sw_interface_set_table_reply) \
3892 _(sw_interface_set_mpls_enable_reply) \
3893 _(sw_interface_set_vpath_reply) \
3894 _(sw_interface_set_vxlan_bypass_reply) \
3895 _(sw_interface_set_l2_bridge_reply) \
3896 _(bridge_domain_add_del_reply) \
3897 _(sw_interface_set_l2_xconnect_reply) \
3898 _(l2fib_add_del_reply) \
3899 _(ip_add_del_route_reply) \
3900 _(ip_mroute_add_del_reply) \
3901 _(mpls_route_add_del_reply) \
3902 _(mpls_ip_bind_unbind_reply) \
3903 _(proxy_arp_add_del_reply) \
3904 _(proxy_arp_intfc_enable_disable_reply) \
3905 _(sw_interface_set_unnumbered_reply) \
3906 _(ip_neighbor_add_del_reply) \
3907 _(reset_vrf_reply) \
3908 _(oam_add_del_reply) \
3909 _(reset_fib_reply) \
3910 _(dhcp_proxy_config_reply) \
3911 _(dhcp_proxy_set_vss_reply) \
3912 _(dhcp_client_config_reply) \
3913 _(set_ip_flow_hash_reply) \
3914 _(sw_interface_ip6_enable_disable_reply) \
3915 _(sw_interface_ip6_set_link_local_address_reply) \
3916 _(sw_interface_ip6nd_ra_prefix_reply) \
3917 _(sw_interface_ip6nd_ra_config_reply) \
3918 _(set_arp_neighbor_limit_reply) \
3919 _(l2_patch_add_del_reply) \
3920 _(sr_policy_add_reply) \
3921 _(sr_policy_mod_reply) \
3922 _(sr_policy_del_reply) \
3923 _(sr_localsid_add_del_reply) \
3924 _(sr_steering_add_del_reply) \
3925 _(classify_add_del_session_reply) \
3926 _(classify_set_interface_ip_table_reply) \
3927 _(classify_set_interface_l2_tables_reply) \
3928 _(l2tpv3_set_tunnel_cookies_reply) \
3929 _(l2tpv3_interface_enable_disable_reply) \
3930 _(l2tpv3_set_lookup_key_reply) \
3931 _(l2_fib_clear_table_reply) \
3932 _(l2_interface_efp_filter_reply) \
3933 _(l2_interface_vlan_tag_rewrite_reply) \
3934 _(modify_vhost_user_if_reply) \
3935 _(delete_vhost_user_if_reply) \
3936 _(want_ip4_arp_events_reply) \
3937 _(want_ip6_nd_events_reply) \
3938 _(input_acl_set_interface_reply) \
3939 _(ipsec_spd_add_del_reply) \
3940 _(ipsec_interface_add_del_spd_reply) \
3941 _(ipsec_spd_add_del_entry_reply) \
3942 _(ipsec_sad_add_del_entry_reply) \
3943 _(ipsec_sa_set_key_reply) \
3944 _(ikev2_profile_add_del_reply) \
3945 _(ikev2_profile_set_auth_reply) \
3946 _(ikev2_profile_set_id_reply) \
3947 _(ikev2_profile_set_ts_reply) \
3948 _(ikev2_set_local_key_reply) \
3949 _(ikev2_set_responder_reply) \
3950 _(ikev2_set_ike_transforms_reply) \
3951 _(ikev2_set_esp_transforms_reply) \
3952 _(ikev2_set_sa_lifetime_reply) \
3953 _(ikev2_initiate_sa_init_reply) \
3954 _(ikev2_initiate_del_ike_sa_reply) \
3955 _(ikev2_initiate_del_child_sa_reply) \
3956 _(ikev2_initiate_rekey_child_sa_reply) \
3957 _(delete_loopback_reply) \
3958 _(bd_ip_mac_add_del_reply) \
3959 _(map_del_domain_reply) \
3960 _(map_add_del_rule_reply) \
3961 _(want_interface_events_reply) \
3962 _(want_stats_reply) \
3963 _(cop_interface_enable_disable_reply) \
3964 _(cop_whitelist_enable_disable_reply) \
3965 _(sw_interface_clear_stats_reply) \
3966 _(ioam_enable_reply) \
3967 _(ioam_disable_reply) \
3968 _(one_add_del_locator_reply) \
3969 _(one_add_del_local_eid_reply) \
3970 _(one_add_del_remote_mapping_reply) \
3971 _(one_add_del_adjacency_reply) \
3972 _(one_add_del_map_resolver_reply) \
3973 _(one_add_del_map_server_reply) \
3974 _(one_enable_disable_reply) \
3975 _(one_rloc_probe_enable_disable_reply) \
3976 _(one_map_register_enable_disable_reply) \
3977 _(one_pitr_set_locator_set_reply) \
3978 _(one_map_request_mode_reply) \
3979 _(one_add_del_map_request_itr_rlocs_reply) \
3980 _(one_eid_table_add_del_map_reply) \
3981 _(gpe_add_del_fwd_entry_reply) \
3982 _(gpe_enable_disable_reply) \
3983 _(gpe_set_encap_mode_reply) \
3984 _(gpe_add_del_iface_reply) \
3985 _(vxlan_gpe_add_del_tunnel_reply) \
3986 _(af_packet_delete_reply) \
3987 _(policer_classify_set_interface_reply) \
3988 _(netmap_create_reply) \
3989 _(netmap_delete_reply) \
3990 _(set_ipfix_exporter_reply) \
3991 _(set_ipfix_classify_stream_reply) \
3992 _(ipfix_classify_table_add_del_reply) \
3993 _(flow_classify_set_interface_reply) \
3994 _(sw_interface_span_enable_disable_reply) \
3995 _(pg_capture_reply) \
3996 _(pg_enable_disable_reply) \
3997 _(ip_source_and_port_range_check_add_del_reply) \
3998 _(ip_source_and_port_range_check_interface_add_del_reply)\
3999 _(delete_subif_reply) \
4000 _(l2_interface_pbb_tag_rewrite_reply) \
4002 _(feature_enable_disable_reply) \
4003 _(sw_interface_tag_add_del_reply) \
4004 _(sw_interface_set_mtu_reply)
4007 static void vl_api_##n##_t_handler \
4008 (vl_api_##n##_t * mp) \
4010 vat_main_t * vam = &vat_main; \
4011 i32 retval = ntohl(mp->retval); \
4012 if (vam->async_mode) { \
4013 vam->async_errors += (retval < 0); \
4015 vam->retval = retval; \
4016 vam->result_ready = 1; \
4019 foreach_standard_reply_retval_handler;
4023 static void vl_api_##n##_t_handler_json \
4024 (vl_api_##n##_t * mp) \
4026 vat_main_t * vam = &vat_main; \
4027 vat_json_node_t node; \
4028 vat_json_init_object(&node); \
4029 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4030 vat_json_print(vam->ofp, &node); \
4031 vam->retval = ntohl(mp->retval); \
4032 vam->result_ready = 1; \
4034 foreach_standard_reply_retval_handler;
4038 * Table of message reply handlers, must include boilerplate handlers
4042 #define foreach_vpe_api_reply_msg \
4043 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4044 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4045 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4046 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4047 _(CONTROL_PING_REPLY, control_ping_reply) \
4048 _(CLI_REPLY, cli_reply) \
4049 _(CLI_INBAND_REPLY, cli_inband_reply) \
4050 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4051 sw_interface_add_del_address_reply) \
4052 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4053 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4054 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4055 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4056 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4057 sw_interface_set_l2_xconnect_reply) \
4058 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4059 sw_interface_set_l2_bridge_reply) \
4060 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4061 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4062 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4063 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4064 _(L2_FLAGS_REPLY, l2_flags_reply) \
4065 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4066 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4067 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4068 _(TAP_DELETE_REPLY, tap_delete_reply) \
4069 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4070 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4071 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4072 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4073 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4074 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4075 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4076 proxy_arp_intfc_enable_disable_reply) \
4077 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4078 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4079 sw_interface_set_unnumbered_reply) \
4080 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4081 _(RESET_VRF_REPLY, reset_vrf_reply) \
4082 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4083 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4084 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4085 _(RESET_FIB_REPLY, reset_fib_reply) \
4086 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4087 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4088 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4089 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4090 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4091 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4092 sw_interface_ip6_enable_disable_reply) \
4093 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4094 sw_interface_ip6_set_link_local_address_reply) \
4095 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4096 sw_interface_ip6nd_ra_prefix_reply) \
4097 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4098 sw_interface_ip6nd_ra_config_reply) \
4099 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4100 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4101 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4102 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4103 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4104 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4105 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4106 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4107 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4108 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4109 classify_set_interface_ip_table_reply) \
4110 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4111 classify_set_interface_l2_tables_reply) \
4112 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4113 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4114 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4115 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4116 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4117 l2tpv3_interface_enable_disable_reply) \
4118 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4119 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4120 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4121 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4122 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4123 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4124 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4125 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4126 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4127 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4128 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4129 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4130 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4131 _(SHOW_VERSION_REPLY, show_version_reply) \
4132 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4133 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4134 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4135 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4136 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4137 _(IP4_ARP_EVENT, ip4_arp_event) \
4138 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4139 _(IP6_ND_EVENT, ip6_nd_event) \
4140 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4141 _(IP_ADDRESS_DETAILS, ip_address_details) \
4142 _(IP_DETAILS, ip_details) \
4143 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4144 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4145 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4146 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4147 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4148 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4149 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4150 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4151 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4152 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4153 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4154 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4155 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4156 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4157 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4158 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4159 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4160 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4161 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4162 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4163 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4164 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4165 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4166 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4167 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4168 _(MAP_RULE_DETAILS, map_rule_details) \
4169 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4170 _(WANT_STATS_REPLY, want_stats_reply) \
4171 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4172 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4173 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4174 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4175 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4176 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4177 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4178 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4179 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4180 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4181 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4182 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4183 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4184 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4185 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4186 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4187 one_map_register_enable_disable_reply) \
4188 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4189 one_rloc_probe_enable_disable_reply) \
4190 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4191 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4192 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4193 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4194 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4195 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4196 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4197 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4198 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4199 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4200 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4201 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4202 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4203 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4204 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4205 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4206 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4207 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4208 gpe_fwd_entry_path_details) \
4209 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4210 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4211 one_add_del_map_request_itr_rlocs_reply) \
4212 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4213 one_get_map_request_itr_rlocs_reply) \
4214 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4215 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4216 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4217 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4218 show_one_map_register_state_reply) \
4219 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4220 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4221 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4222 _(POLICER_DETAILS, policer_details) \
4223 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4224 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4225 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4226 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4227 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4228 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4229 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4230 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4231 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4232 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4233 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4234 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4235 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4236 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4237 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4238 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4239 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4240 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4241 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4242 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4243 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4244 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4245 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4246 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4247 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4248 ip_source_and_port_range_check_add_del_reply) \
4249 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4250 ip_source_and_port_range_check_interface_add_del_reply) \
4251 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4252 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4253 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4254 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4255 _(PUNT_REPLY, punt_reply) \
4256 _(IP_FIB_DETAILS, ip_fib_details) \
4257 _(IP6_FIB_DETAILS, ip6_fib_details) \
4258 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4259 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4260 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4261 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4262 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4263 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4265 #define foreach_standalone_reply_msg \
4266 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4267 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4268 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4269 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4270 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4271 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4280 #define STR_VTR_OP_CASE(op) \
4281 case L2_VTR_ ## op: \
4285 str_vtr_op (u32 vtr_op)
4289 STR_VTR_OP_CASE (DISABLED);
4290 STR_VTR_OP_CASE (PUSH_1);
4291 STR_VTR_OP_CASE (PUSH_2);
4292 STR_VTR_OP_CASE (POP_1);
4293 STR_VTR_OP_CASE (POP_2);
4294 STR_VTR_OP_CASE (TRANSLATE_1_1);
4295 STR_VTR_OP_CASE (TRANSLATE_1_2);
4296 STR_VTR_OP_CASE (TRANSLATE_2_1);
4297 STR_VTR_OP_CASE (TRANSLATE_2_2);
4304 dump_sub_interface_table (vat_main_t * vam)
4306 const sw_interface_subif_t *sub = NULL;
4308 if (vam->json_output)
4311 ("JSON output supported only for VPE API calls and dump_stats_table");
4316 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4317 "Interface", "sw_if_index",
4318 "sub id", "dot1ad", "tags", "outer id",
4319 "inner id", "exact", "default", "outer any", "inner any");
4321 vec_foreach (sub, vam->sw_if_subif_table)
4324 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4325 sub->interface_name,
4327 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4328 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4329 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4330 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4331 if (sub->vtr_op != L2_VTR_DISABLED)
4334 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4335 "tag1: %d tag2: %d ]",
4336 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4337 sub->vtr_tag1, sub->vtr_tag2);
4345 name_sort_cmp (void *a1, void *a2)
4347 name_sort_t *n1 = a1;
4348 name_sort_t *n2 = a2;
4350 return strcmp ((char *) n1->name, (char *) n2->name);
4354 dump_interface_table (vat_main_t * vam)
4357 name_sort_t *nses = 0, *ns;
4359 if (vam->json_output)
4362 ("JSON output supported only for VPE API calls and dump_stats_table");
4367 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4369 vec_add2 (nses, ns, 1);
4370 ns->name = (u8 *)(p->key);
4371 ns->value = (u32) p->value[0];
4375 vec_sort_with_function (nses, name_sort_cmp);
4377 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4378 vec_foreach (ns, nses)
4380 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4387 dump_ip_table (vat_main_t * vam, int is_ipv6)
4389 const ip_details_t *det = NULL;
4390 const ip_address_details_t *address = NULL;
4393 print (vam->ofp, "%-12s", "sw_if_index");
4395 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4402 print (vam->ofp, "%-12d", i);
4403 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4408 vec_foreach (address, det->addr)
4412 is_ipv6 ? format_ip6_address : format_ip4_address,
4413 address->ip, address->prefix_length);
4421 dump_ipv4_table (vat_main_t * vam)
4423 if (vam->json_output)
4426 ("JSON output supported only for VPE API calls and dump_stats_table");
4430 return dump_ip_table (vam, 0);
4434 dump_ipv6_table (vat_main_t * vam)
4436 if (vam->json_output)
4439 ("JSON output supported only for VPE API calls and dump_stats_table");
4443 return dump_ip_table (vam, 1);
4447 counter_type_to_str (u8 counter_type, u8 is_combined)
4451 switch (counter_type)
4453 case VNET_INTERFACE_COUNTER_DROP:
4455 case VNET_INTERFACE_COUNTER_PUNT:
4457 case VNET_INTERFACE_COUNTER_IP4:
4459 case VNET_INTERFACE_COUNTER_IP6:
4461 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4463 case VNET_INTERFACE_COUNTER_RX_MISS:
4465 case VNET_INTERFACE_COUNTER_RX_ERROR:
4467 case VNET_INTERFACE_COUNTER_TX_ERROR:
4470 return "INVALID-COUNTER-TYPE";
4475 switch (counter_type)
4477 case VNET_INTERFACE_COUNTER_RX:
4479 case VNET_INTERFACE_COUNTER_TX:
4482 return "INVALID-COUNTER-TYPE";
4488 dump_stats_table (vat_main_t * vam)
4490 vat_json_node_t node;
4491 vat_json_node_t *msg_array;
4492 vat_json_node_t *msg;
4493 vat_json_node_t *counter_array;
4494 vat_json_node_t *counter;
4495 interface_counter_t c;
4497 ip4_fib_counter_t *c4;
4498 ip6_fib_counter_t *c6;
4499 ip4_nbr_counter_t *n4;
4500 ip6_nbr_counter_t *n6;
4503 if (!vam->json_output)
4505 clib_warning ("dump_stats_table supported only in JSON format");
4509 vat_json_init_object (&node);
4511 /* interface counters */
4512 msg_array = vat_json_object_add (&node, "interface_counters");
4513 vat_json_init_array (msg_array);
4514 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4516 msg = vat_json_array_add (msg_array);
4517 vat_json_init_object (msg);
4518 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4519 (u8 *) counter_type_to_str (i, 0));
4520 vat_json_object_add_int (msg, "is_combined", 0);
4521 counter_array = vat_json_object_add (msg, "data");
4522 vat_json_init_array (counter_array);
4523 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4525 packets = vam->simple_interface_counters[i][j];
4526 vat_json_array_add_uint (counter_array, packets);
4529 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4531 msg = vat_json_array_add (msg_array);
4532 vat_json_init_object (msg);
4533 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4534 (u8 *) counter_type_to_str (i, 1));
4535 vat_json_object_add_int (msg, "is_combined", 1);
4536 counter_array = vat_json_object_add (msg, "data");
4537 vat_json_init_array (counter_array);
4538 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4540 c = vam->combined_interface_counters[i][j];
4541 counter = vat_json_array_add (counter_array);
4542 vat_json_init_object (counter);
4543 vat_json_object_add_uint (counter, "packets", c.packets);
4544 vat_json_object_add_uint (counter, "bytes", c.bytes);
4548 /* ip4 fib counters */
4549 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4550 vat_json_init_array (msg_array);
4551 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4553 msg = vat_json_array_add (msg_array);
4554 vat_json_init_object (msg);
4555 vat_json_object_add_uint (msg, "vrf_id",
4556 vam->ip4_fib_counters_vrf_id_by_index[i]);
4557 counter_array = vat_json_object_add (msg, "c");
4558 vat_json_init_array (counter_array);
4559 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4561 counter = vat_json_array_add (counter_array);
4562 vat_json_init_object (counter);
4563 c4 = &vam->ip4_fib_counters[i][j];
4564 vat_json_object_add_ip4 (counter, "address", c4->address);
4565 vat_json_object_add_uint (counter, "address_length",
4566 c4->address_length);
4567 vat_json_object_add_uint (counter, "packets", c4->packets);
4568 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4572 /* ip6 fib counters */
4573 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4574 vat_json_init_array (msg_array);
4575 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4577 msg = vat_json_array_add (msg_array);
4578 vat_json_init_object (msg);
4579 vat_json_object_add_uint (msg, "vrf_id",
4580 vam->ip6_fib_counters_vrf_id_by_index[i]);
4581 counter_array = vat_json_object_add (msg, "c");
4582 vat_json_init_array (counter_array);
4583 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4585 counter = vat_json_array_add (counter_array);
4586 vat_json_init_object (counter);
4587 c6 = &vam->ip6_fib_counters[i][j];
4588 vat_json_object_add_ip6 (counter, "address", c6->address);
4589 vat_json_object_add_uint (counter, "address_length",
4590 c6->address_length);
4591 vat_json_object_add_uint (counter, "packets", c6->packets);
4592 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4596 /* ip4 nbr counters */
4597 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4598 vat_json_init_array (msg_array);
4599 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4601 msg = vat_json_array_add (msg_array);
4602 vat_json_init_object (msg);
4603 vat_json_object_add_uint (msg, "sw_if_index", i);
4604 counter_array = vat_json_object_add (msg, "c");
4605 vat_json_init_array (counter_array);
4606 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4608 counter = vat_json_array_add (counter_array);
4609 vat_json_init_object (counter);
4610 n4 = &vam->ip4_nbr_counters[i][j];
4611 vat_json_object_add_ip4 (counter, "address", n4->address);
4612 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4613 vat_json_object_add_uint (counter, "packets", n4->packets);
4614 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4618 /* ip6 nbr counters */
4619 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4620 vat_json_init_array (msg_array);
4621 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4623 msg = vat_json_array_add (msg_array);
4624 vat_json_init_object (msg);
4625 vat_json_object_add_uint (msg, "sw_if_index", i);
4626 counter_array = vat_json_object_add (msg, "c");
4627 vat_json_init_array (counter_array);
4628 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4630 counter = vat_json_array_add (counter_array);
4631 vat_json_init_object (counter);
4632 n6 = &vam->ip6_nbr_counters[i][j];
4633 vat_json_object_add_ip6 (counter, "address", n6->address);
4634 vat_json_object_add_uint (counter, "packets", n6->packets);
4635 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4639 vat_json_print (vam->ofp, &node);
4640 vat_json_free (&node);
4646 exec (vat_main_t * vam)
4648 api_main_t *am = &api_main;
4649 vl_api_cli_request_t *mp;
4653 unformat_input_t *i = vam->input;
4655 if (vec_len (i->buffer) == 0)
4658 if (vam->exec_mode == 0 && unformat (i, "mode"))
4663 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4670 M (CLI_REQUEST, mp);
4673 * Copy cmd into shared memory.
4674 * In order for the CLI command to work, it
4675 * must be a vector ending in \n, not a C-string ending
4678 pthread_mutex_lock (&am->vlib_rp->mutex);
4679 oldheap = svm_push_data_heap (am->vlib_rp);
4681 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4682 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4684 svm_pop_heap (oldheap);
4685 pthread_mutex_unlock (&am->vlib_rp->mutex);
4687 mp->cmd_in_shmem = (u64) cmd;
4689 timeout = vat_time_now (vam) + 10.0;
4691 while (vat_time_now (vam) < timeout)
4693 if (vam->result_ready == 1)
4696 if (vam->shmem_result != NULL)
4697 print (vam->ofp, "%s", vam->shmem_result);
4698 pthread_mutex_lock (&am->vlib_rp->mutex);
4699 oldheap = svm_push_data_heap (am->vlib_rp);
4701 free_me = (u8 *) vam->shmem_result;
4704 svm_pop_heap (oldheap);
4705 pthread_mutex_unlock (&am->vlib_rp->mutex);
4713 * Future replacement of exec() that passes CLI buffers directly in
4714 * the API messages instead of an additional shared memory area.
4717 exec_inband (vat_main_t * vam)
4719 vl_api_cli_inband_t *mp;
4720 unformat_input_t *i = vam->input;
4723 if (vec_len (i->buffer) == 0)
4726 if (vam->exec_mode == 0 && unformat (i, "mode"))
4731 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4738 * In order for the CLI command to work, it
4739 * must be a vector ending in \n, not a C-string ending
4742 u32 len = vec_len (vam->input->buffer);
4743 M2 (CLI_INBAND, mp, len);
4744 clib_memcpy (mp->cmd, vam->input->buffer, len);
4745 mp->length = htonl (len);
4748 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4753 api_create_loopback (vat_main_t * vam)
4755 unformat_input_t *i = vam->input;
4756 vl_api_create_loopback_t *mp;
4757 vl_api_create_loopback_instance_t *mp_lbi;
4760 u8 is_specified = 0;
4761 u32 user_instance = 0;
4764 memset (mac_address, 0, sizeof (mac_address));
4766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4768 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4770 if (unformat (i, "instance %d", &user_instance))
4778 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
4779 mp_lbi->is_specified = is_specified;
4781 mp_lbi->user_instance = htonl (user_instance);
4783 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
4788 /* Construct the API message */
4789 M (CREATE_LOOPBACK, mp);
4791 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4800 api_delete_loopback (vat_main_t * vam)
4802 unformat_input_t *i = vam->input;
4803 vl_api_delete_loopback_t *mp;
4804 u32 sw_if_index = ~0;
4807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4809 if (unformat (i, "sw_if_index %d", &sw_if_index))
4815 if (sw_if_index == ~0)
4817 errmsg ("missing sw_if_index");
4821 /* Construct the API message */
4822 M (DELETE_LOOPBACK, mp);
4823 mp->sw_if_index = ntohl (sw_if_index);
4831 api_want_stats (vat_main_t * vam)
4833 unformat_input_t *i = vam->input;
4834 vl_api_want_stats_t *mp;
4838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4840 if (unformat (i, "enable"))
4842 else if (unformat (i, "disable"))
4850 errmsg ("missing enable|disable");
4855 mp->enable_disable = enable;
4863 api_want_interface_events (vat_main_t * vam)
4865 unformat_input_t *i = vam->input;
4866 vl_api_want_interface_events_t *mp;
4870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4872 if (unformat (i, "enable"))
4874 else if (unformat (i, "disable"))
4882 errmsg ("missing enable|disable");
4886 M (WANT_INTERFACE_EVENTS, mp);
4887 mp->enable_disable = enable;
4889 vam->interface_event_display = enable;
4897 /* Note: non-static, called once to set up the initial intfc table */
4899 api_sw_interface_dump (vat_main_t * vam)
4901 vl_api_sw_interface_dump_t *mp;
4902 vl_api_control_ping_t *mp_ping;
4904 name_sort_t *nses = 0, *ns;
4905 sw_interface_subif_t *sub = NULL;
4908 /* Toss the old name table */
4910 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4912 vec_add2 (nses, ns, 1);
4913 ns->name = (u8 *)(p->key);
4914 ns->value = (u32) p->value[0];
4918 hash_free (vam->sw_if_index_by_interface_name);
4920 vec_foreach (ns, nses) vec_free (ns->name);
4924 vec_foreach (sub, vam->sw_if_subif_table)
4926 vec_free (sub->interface_name);
4928 vec_free (vam->sw_if_subif_table);
4930 /* recreate the interface name hash table */
4931 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4933 /* Get list of ethernets */
4934 M (SW_INTERFACE_DUMP, mp);
4935 mp->name_filter_valid = 1;
4936 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4939 /* and local / loopback interfaces */
4940 M (SW_INTERFACE_DUMP, mp);
4941 mp->name_filter_valid = 1;
4942 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4945 /* and packet-generator interfaces */
4946 M (SW_INTERFACE_DUMP, mp);
4947 mp->name_filter_valid = 1;
4948 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4951 /* and vxlan-gpe tunnel interfaces */
4952 M (SW_INTERFACE_DUMP, mp);
4953 mp->name_filter_valid = 1;
4954 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4955 sizeof (mp->name_filter) - 1);
4958 /* and vxlan tunnel interfaces */
4959 M (SW_INTERFACE_DUMP, mp);
4960 mp->name_filter_valid = 1;
4961 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4964 /* and host (af_packet) interfaces */
4965 M (SW_INTERFACE_DUMP, mp);
4966 mp->name_filter_valid = 1;
4967 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4970 /* and l2tpv3 tunnel interfaces */
4971 M (SW_INTERFACE_DUMP, mp);
4972 mp->name_filter_valid = 1;
4973 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4974 sizeof (mp->name_filter) - 1);
4977 /* and GRE tunnel interfaces */
4978 M (SW_INTERFACE_DUMP, mp);
4979 mp->name_filter_valid = 1;
4980 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4983 /* and LISP-GPE interfaces */
4984 M (SW_INTERFACE_DUMP, mp);
4985 mp->name_filter_valid = 1;
4986 strncpy ((char *) mp->name_filter, "lisp_gpe",
4987 sizeof (mp->name_filter) - 1);
4990 /* and IPSEC tunnel interfaces */
4991 M (SW_INTERFACE_DUMP, mp);
4992 mp->name_filter_valid = 1;
4993 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4996 /* Use a control ping for synchronization */
4997 M (CONTROL_PING, mp_ping);
5005 api_sw_interface_set_flags (vat_main_t * vam)
5007 unformat_input_t *i = vam->input;
5008 vl_api_sw_interface_set_flags_t *mp;
5010 u8 sw_if_index_set = 0;
5011 u8 admin_up = 0, link_up = 0;
5014 /* Parse args required to build the message */
5015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5017 if (unformat (i, "admin-up"))
5019 else if (unformat (i, "admin-down"))
5021 else if (unformat (i, "link-up"))
5023 else if (unformat (i, "link-down"))
5026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5027 sw_if_index_set = 1;
5028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5029 sw_if_index_set = 1;
5034 if (sw_if_index_set == 0)
5036 errmsg ("missing interface name or sw_if_index");
5040 /* Construct the API message */
5041 M (SW_INTERFACE_SET_FLAGS, mp);
5042 mp->sw_if_index = ntohl (sw_if_index);
5043 mp->admin_up_down = admin_up;
5044 mp->link_up_down = link_up;
5049 /* Wait for a reply, return the good/bad news... */
5055 api_sw_interface_clear_stats (vat_main_t * vam)
5057 unformat_input_t *i = vam->input;
5058 vl_api_sw_interface_clear_stats_t *mp;
5060 u8 sw_if_index_set = 0;
5063 /* Parse args required to build the message */
5064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5066 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5067 sw_if_index_set = 1;
5068 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5069 sw_if_index_set = 1;
5074 /* Construct the API message */
5075 M (SW_INTERFACE_CLEAR_STATS, mp);
5077 if (sw_if_index_set == 1)
5078 mp->sw_if_index = ntohl (sw_if_index);
5080 mp->sw_if_index = ~0;
5085 /* Wait for a reply, return the good/bad news... */
5091 api_sw_interface_add_del_address (vat_main_t * vam)
5093 unformat_input_t *i = vam->input;
5094 vl_api_sw_interface_add_del_address_t *mp;
5096 u8 sw_if_index_set = 0;
5097 u8 is_add = 1, del_all = 0;
5098 u32 address_length = 0;
5099 u8 v4_address_set = 0;
5100 u8 v6_address_set = 0;
5101 ip4_address_t v4address;
5102 ip6_address_t v6address;
5105 /* Parse args required to build the message */
5106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5108 if (unformat (i, "del-all"))
5110 else if (unformat (i, "del"))
5113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5114 sw_if_index_set = 1;
5115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5116 sw_if_index_set = 1;
5117 else if (unformat (i, "%U/%d",
5118 unformat_ip4_address, &v4address, &address_length))
5120 else if (unformat (i, "%U/%d",
5121 unformat_ip6_address, &v6address, &address_length))
5127 if (sw_if_index_set == 0)
5129 errmsg ("missing interface name or sw_if_index");
5132 if (v4_address_set && v6_address_set)
5134 errmsg ("both v4 and v6 addresses set");
5137 if (!v4_address_set && !v6_address_set && !del_all)
5139 errmsg ("no addresses set");
5143 /* Construct the API message */
5144 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5146 mp->sw_if_index = ntohl (sw_if_index);
5147 mp->is_add = is_add;
5148 mp->del_all = del_all;
5152 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5156 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5158 mp->address_length = address_length;
5163 /* Wait for a reply, return good/bad news */
5169 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5171 unformat_input_t *i = vam->input;
5172 vl_api_sw_interface_set_mpls_enable_t *mp;
5174 u8 sw_if_index_set = 0;
5178 /* Parse args required to build the message */
5179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5182 sw_if_index_set = 1;
5183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5184 sw_if_index_set = 1;
5185 else if (unformat (i, "disable"))
5187 else if (unformat (i, "dis"))
5193 if (sw_if_index_set == 0)
5195 errmsg ("missing interface name or sw_if_index");
5199 /* Construct the API message */
5200 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5202 mp->sw_if_index = ntohl (sw_if_index);
5203 mp->enable = enable;
5208 /* Wait for a reply... */
5214 api_sw_interface_set_table (vat_main_t * vam)
5216 unformat_input_t *i = vam->input;
5217 vl_api_sw_interface_set_table_t *mp;
5218 u32 sw_if_index, vrf_id = 0;
5219 u8 sw_if_index_set = 0;
5223 /* Parse args required to build the message */
5224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5226 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5227 sw_if_index_set = 1;
5228 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5229 sw_if_index_set = 1;
5230 else if (unformat (i, "vrf %d", &vrf_id))
5232 else if (unformat (i, "ipv6"))
5238 if (sw_if_index_set == 0)
5240 errmsg ("missing interface name or sw_if_index");
5244 /* Construct the API message */
5245 M (SW_INTERFACE_SET_TABLE, mp);
5247 mp->sw_if_index = ntohl (sw_if_index);
5248 mp->is_ipv6 = is_ipv6;
5249 mp->vrf_id = ntohl (vrf_id);
5254 /* Wait for a reply... */
5259 static void vl_api_sw_interface_get_table_reply_t_handler
5260 (vl_api_sw_interface_get_table_reply_t * mp)
5262 vat_main_t *vam = &vat_main;
5264 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5266 vam->retval = ntohl (mp->retval);
5267 vam->result_ready = 1;
5271 static void vl_api_sw_interface_get_table_reply_t_handler_json
5272 (vl_api_sw_interface_get_table_reply_t * mp)
5274 vat_main_t *vam = &vat_main;
5275 vat_json_node_t node;
5277 vat_json_init_object (&node);
5278 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5279 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5281 vat_json_print (vam->ofp, &node);
5282 vat_json_free (&node);
5284 vam->retval = ntohl (mp->retval);
5285 vam->result_ready = 1;
5289 api_sw_interface_get_table (vat_main_t * vam)
5291 unformat_input_t *i = vam->input;
5292 vl_api_sw_interface_get_table_t *mp;
5294 u8 sw_if_index_set = 0;
5298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5300 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5301 sw_if_index_set = 1;
5302 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5303 sw_if_index_set = 1;
5304 else if (unformat (i, "ipv6"))
5310 if (sw_if_index_set == 0)
5312 errmsg ("missing interface name or sw_if_index");
5316 M (SW_INTERFACE_GET_TABLE, mp);
5317 mp->sw_if_index = htonl (sw_if_index);
5318 mp->is_ipv6 = is_ipv6;
5326 api_sw_interface_set_vpath (vat_main_t * vam)
5328 unformat_input_t *i = vam->input;
5329 vl_api_sw_interface_set_vpath_t *mp;
5330 u32 sw_if_index = 0;
5331 u8 sw_if_index_set = 0;
5335 /* Parse args required to build the message */
5336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5338 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5339 sw_if_index_set = 1;
5340 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5341 sw_if_index_set = 1;
5342 else if (unformat (i, "enable"))
5344 else if (unformat (i, "disable"))
5350 if (sw_if_index_set == 0)
5352 errmsg ("missing interface name or sw_if_index");
5356 /* Construct the API message */
5357 M (SW_INTERFACE_SET_VPATH, mp);
5359 mp->sw_if_index = ntohl (sw_if_index);
5360 mp->enable = is_enable;
5365 /* Wait for a reply... */
5371 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5373 unformat_input_t *i = vam->input;
5374 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5375 u32 sw_if_index = 0;
5376 u8 sw_if_index_set = 0;
5381 /* Parse args required to build the message */
5382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5385 sw_if_index_set = 1;
5386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5387 sw_if_index_set = 1;
5388 else if (unformat (i, "enable"))
5390 else if (unformat (i, "disable"))
5392 else if (unformat (i, "ip4"))
5394 else if (unformat (i, "ip6"))
5400 if (sw_if_index_set == 0)
5402 errmsg ("missing interface name or sw_if_index");
5406 /* Construct the API message */
5407 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5409 mp->sw_if_index = ntohl (sw_if_index);
5410 mp->enable = is_enable;
5411 mp->is_ipv6 = is_ipv6;
5416 /* Wait for a reply... */
5422 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5424 unformat_input_t *i = vam->input;
5425 vl_api_sw_interface_set_l2_xconnect_t *mp;
5427 u8 rx_sw_if_index_set = 0;
5429 u8 tx_sw_if_index_set = 0;
5433 /* Parse args required to build the message */
5434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5436 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5437 rx_sw_if_index_set = 1;
5438 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5439 tx_sw_if_index_set = 1;
5440 else if (unformat (i, "rx"))
5442 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5444 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5446 rx_sw_if_index_set = 1;
5451 else if (unformat (i, "tx"))
5453 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5455 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5457 tx_sw_if_index_set = 1;
5462 else if (unformat (i, "enable"))
5464 else if (unformat (i, "disable"))
5470 if (rx_sw_if_index_set == 0)
5472 errmsg ("missing rx interface name or rx_sw_if_index");
5476 if (enable && (tx_sw_if_index_set == 0))
5478 errmsg ("missing tx interface name or tx_sw_if_index");
5482 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5484 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5485 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5486 mp->enable = enable;
5494 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5496 unformat_input_t *i = vam->input;
5497 vl_api_sw_interface_set_l2_bridge_t *mp;
5499 u8 rx_sw_if_index_set = 0;
5507 /* Parse args required to build the message */
5508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5510 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5511 rx_sw_if_index_set = 1;
5512 else if (unformat (i, "bd_id %d", &bd_id))
5516 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5517 rx_sw_if_index_set = 1;
5518 else if (unformat (i, "shg %d", &shg))
5520 else if (unformat (i, "bvi"))
5522 else if (unformat (i, "enable"))
5524 else if (unformat (i, "disable"))
5530 if (rx_sw_if_index_set == 0)
5532 errmsg ("missing rx interface name or sw_if_index");
5536 if (enable && (bd_id_set == 0))
5538 errmsg ("missing bridge domain");
5542 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5544 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5545 mp->bd_id = ntohl (bd_id);
5548 mp->enable = enable;
5556 api_bridge_domain_dump (vat_main_t * vam)
5558 unformat_input_t *i = vam->input;
5559 vl_api_bridge_domain_dump_t *mp;
5560 vl_api_control_ping_t *mp_ping;
5564 /* Parse args required to build the message */
5565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5567 if (unformat (i, "bd_id %d", &bd_id))
5573 M (BRIDGE_DOMAIN_DUMP, mp);
5574 mp->bd_id = ntohl (bd_id);
5577 /* Use a control ping for synchronization */
5578 M (CONTROL_PING, mp_ping);
5586 api_bridge_domain_add_del (vat_main_t * vam)
5588 unformat_input_t *i = vam->input;
5589 vl_api_bridge_domain_add_del_t *mp;
5592 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5596 /* Parse args required to build the message */
5597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5599 if (unformat (i, "bd_id %d", &bd_id))
5601 else if (unformat (i, "flood %d", &flood))
5603 else if (unformat (i, "uu-flood %d", &uu_flood))
5605 else if (unformat (i, "forward %d", &forward))
5607 else if (unformat (i, "learn %d", &learn))
5609 else if (unformat (i, "arp-term %d", &arp_term))
5611 else if (unformat (i, "mac-age %d", &mac_age))
5613 else if (unformat (i, "del"))
5616 flood = uu_flood = forward = learn = 0;
5624 errmsg ("missing bridge domain");
5630 errmsg ("mac age must be less than 256 ");
5634 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5636 mp->bd_id = ntohl (bd_id);
5638 mp->uu_flood = uu_flood;
5639 mp->forward = forward;
5641 mp->arp_term = arp_term;
5642 mp->is_add = is_add;
5643 mp->mac_age = (u8) mac_age;
5651 api_l2fib_add_del (vat_main_t * vam)
5653 unformat_input_t *i = vam->input;
5654 vl_api_l2fib_add_del_t *mp;
5660 u32 sw_if_index = ~0;
5661 u8 sw_if_index_set = 0;
5670 /* Parse args required to build the message */
5671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5673 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5675 else if (unformat (i, "bd_id %d", &bd_id))
5677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5678 sw_if_index_set = 1;
5679 else if (unformat (i, "sw_if"))
5681 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5684 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5685 sw_if_index_set = 1;
5690 else if (unformat (i, "static"))
5692 else if (unformat (i, "filter"))
5697 else if (unformat (i, "bvi"))
5702 else if (unformat (i, "del"))
5704 else if (unformat (i, "count %d", &count))
5712 errmsg ("missing mac address");
5718 errmsg ("missing bridge domain");
5722 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5724 errmsg ("missing interface name or sw_if_index");
5730 /* Turn on async mode */
5731 vam->async_mode = 1;
5732 vam->async_errors = 0;
5733 before = vat_time_now (vam);
5736 for (j = 0; j < count; j++)
5738 M (L2FIB_ADD_DEL, mp);
5741 mp->bd_id = ntohl (bd_id);
5742 mp->is_add = is_add;
5746 mp->sw_if_index = ntohl (sw_if_index);
5747 mp->static_mac = static_mac;
5748 mp->filter_mac = filter_mac;
5749 mp->bvi_mac = bvi_mac;
5751 increment_mac_address (&mac);
5758 vl_api_control_ping_t *mp_ping;
5761 /* Shut off async mode */
5762 vam->async_mode = 0;
5764 M (CONTROL_PING, mp_ping);
5767 timeout = vat_time_now (vam) + 1.0;
5768 while (vat_time_now (vam) < timeout)
5769 if (vam->result_ready == 1)
5774 if (vam->retval == -99)
5777 if (vam->async_errors > 0)
5779 errmsg ("%d asynchronous errors", vam->async_errors);
5782 vam->async_errors = 0;
5783 after = vat_time_now (vam);
5785 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5786 count, after - before, count / (after - before));
5792 /* Wait for a reply... */
5796 /* Return the good/bad news */
5797 return (vam->retval);
5801 api_l2_flags (vat_main_t * vam)
5803 unformat_input_t *i = vam->input;
5804 vl_api_l2_flags_t *mp;
5806 u32 feature_bitmap = 0;
5807 u8 sw_if_index_set = 0;
5810 /* Parse args required to build the message */
5811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5813 if (unformat (i, "sw_if_index %d", &sw_if_index))
5814 sw_if_index_set = 1;
5815 else if (unformat (i, "sw_if"))
5817 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5820 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5821 sw_if_index_set = 1;
5826 else if (unformat (i, "learn"))
5827 feature_bitmap |= L2INPUT_FEAT_LEARN;
5828 else if (unformat (i, "forward"))
5829 feature_bitmap |= L2INPUT_FEAT_FWD;
5830 else if (unformat (i, "flood"))
5831 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5832 else if (unformat (i, "uu-flood"))
5833 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5838 if (sw_if_index_set == 0)
5840 errmsg ("missing interface name or sw_if_index");
5846 mp->sw_if_index = ntohl (sw_if_index);
5847 mp->feature_bitmap = ntohl (feature_bitmap);
5855 api_bridge_flags (vat_main_t * vam)
5857 unformat_input_t *i = vam->input;
5858 vl_api_bridge_flags_t *mp;
5865 /* Parse args required to build the message */
5866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5868 if (unformat (i, "bd_id %d", &bd_id))
5870 else if (unformat (i, "learn"))
5872 else if (unformat (i, "forward"))
5874 else if (unformat (i, "flood"))
5876 else if (unformat (i, "uu-flood"))
5877 flags |= L2_UU_FLOOD;
5878 else if (unformat (i, "arp-term"))
5879 flags |= L2_ARP_TERM;
5880 else if (unformat (i, "off"))
5882 else if (unformat (i, "disable"))
5890 errmsg ("missing bridge domain");
5894 M (BRIDGE_FLAGS, mp);
5896 mp->bd_id = ntohl (bd_id);
5897 mp->feature_bitmap = ntohl (flags);
5898 mp->is_set = is_set;
5906 api_bd_ip_mac_add_del (vat_main_t * vam)
5908 unformat_input_t *i = vam->input;
5909 vl_api_bd_ip_mac_add_del_t *mp;
5916 ip4_address_t v4addr;
5917 ip6_address_t v6addr;
5922 /* Parse args required to build the message */
5923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5925 if (unformat (i, "bd_id %d", &bd_id))
5929 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5933 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5938 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5942 else if (unformat (i, "del"))
5950 errmsg ("missing bridge domain");
5953 else if (ip_set == 0)
5955 errmsg ("missing IP address");
5958 else if (mac_set == 0)
5960 errmsg ("missing MAC address");
5964 M (BD_IP_MAC_ADD_DEL, mp);
5966 mp->bd_id = ntohl (bd_id);
5967 mp->is_ipv6 = is_ipv6;
5968 mp->is_add = is_add;
5970 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5972 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5973 clib_memcpy (mp->mac_address, macaddr, 6);
5980 api_tap_connect (vat_main_t * vam)
5982 unformat_input_t *i = vam->input;
5983 vl_api_tap_connect_t *mp;
5989 ip4_address_t ip4_address;
5991 int ip4_address_set = 0;
5992 ip6_address_t ip6_address;
5994 int ip6_address_set = 0;
5997 memset (mac_address, 0, sizeof (mac_address));
5999 /* Parse args required to build the message */
6000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6002 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6006 else if (unformat (i, "random-mac"))
6008 else if (unformat (i, "tapname %s", &tap_name))
6010 else if (unformat (i, "tag %s", &tag))
6012 else if (unformat (i, "address %U/%d",
6013 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6014 ip4_address_set = 1;
6015 else if (unformat (i, "address %U/%d",
6016 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6017 ip6_address_set = 1;
6024 errmsg ("missing tap name");
6027 if (vec_len (tap_name) > 63)
6029 errmsg ("tap name too long");
6032 vec_add1 (tap_name, 0);
6034 if (vec_len (tag) > 63)
6036 errmsg ("tag too long");
6040 /* Construct the API message */
6041 M (TAP_CONNECT, mp);
6043 mp->use_random_mac = random_mac;
6044 clib_memcpy (mp->mac_address, mac_address, 6);
6045 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6047 clib_memcpy (mp->tag, tag, vec_len (tag));
6049 if (ip4_address_set)
6051 mp->ip4_address_set = 1;
6052 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6053 mp->ip4_mask_width = ip4_mask_width;
6055 if (ip6_address_set)
6057 mp->ip6_address_set = 1;
6058 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6059 mp->ip6_mask_width = ip6_mask_width;
6062 vec_free (tap_name);
6068 /* Wait for a reply... */
6074 api_tap_modify (vat_main_t * vam)
6076 unformat_input_t *i = vam->input;
6077 vl_api_tap_modify_t *mp;
6082 u32 sw_if_index = ~0;
6083 u8 sw_if_index_set = 0;
6086 memset (mac_address, 0, sizeof (mac_address));
6088 /* Parse args required to build the message */
6089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6092 sw_if_index_set = 1;
6093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6094 sw_if_index_set = 1;
6095 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6099 else if (unformat (i, "random-mac"))
6101 else if (unformat (i, "tapname %s", &tap_name))
6107 if (sw_if_index_set == 0)
6109 errmsg ("missing vpp interface name");
6114 errmsg ("missing tap name");
6117 if (vec_len (tap_name) > 63)
6119 errmsg ("tap name too long");
6121 vec_add1 (tap_name, 0);
6123 /* Construct the API message */
6126 mp->use_random_mac = random_mac;
6127 mp->sw_if_index = ntohl (sw_if_index);
6128 clib_memcpy (mp->mac_address, mac_address, 6);
6129 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6130 vec_free (tap_name);
6135 /* Wait for a reply... */
6141 api_tap_delete (vat_main_t * vam)
6143 unformat_input_t *i = vam->input;
6144 vl_api_tap_delete_t *mp;
6145 u32 sw_if_index = ~0;
6146 u8 sw_if_index_set = 0;
6149 /* Parse args required to build the message */
6150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6153 sw_if_index_set = 1;
6154 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6155 sw_if_index_set = 1;
6160 if (sw_if_index_set == 0)
6162 errmsg ("missing vpp interface name");
6166 /* Construct the API message */
6169 mp->sw_if_index = ntohl (sw_if_index);
6174 /* Wait for a reply... */
6180 api_ip_add_del_route (vat_main_t * vam)
6182 unformat_input_t *i = vam->input;
6183 vl_api_ip_add_del_route_t *mp;
6184 u32 sw_if_index = ~0, vrf_id = 0;
6186 u8 is_local = 0, is_drop = 0;
6187 u8 is_unreach = 0, is_prohibit = 0;
6188 u8 create_vrf_if_needed = 0;
6190 u32 next_hop_weight = 1;
6192 u8 is_multipath = 0;
6194 u8 address_length_set = 0;
6195 u32 next_hop_table_id = 0;
6196 u32 resolve_attempts = 0;
6197 u32 dst_address_length = 0;
6198 u8 next_hop_set = 0;
6199 ip4_address_t v4_dst_address, v4_next_hop_address;
6200 ip6_address_t v6_dst_address, v6_next_hop_address;
6204 u32 random_add_del = 0;
6205 u32 *random_vector = 0;
6207 u32 random_seed = 0xdeaddabe;
6208 u32 classify_table_index = ~0;
6210 u8 resolve_host = 0, resolve_attached = 0;
6211 mpls_label_t *next_hop_out_label_stack = NULL;
6212 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6213 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6215 /* Parse args required to build the message */
6216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6222 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6227 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6232 else if (unformat (i, "/%d", &dst_address_length))
6234 address_length_set = 1;
6237 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6238 &v4_next_hop_address))
6242 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6243 &v6_next_hop_address))
6247 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6249 else if (unformat (i, "weight %d", &next_hop_weight))
6251 else if (unformat (i, "drop"))
6255 else if (unformat (i, "null-send-unreach"))
6259 else if (unformat (i, "null-send-prohibit"))
6263 else if (unformat (i, "local"))
6267 else if (unformat (i, "classify %d", &classify_table_index))
6271 else if (unformat (i, "del"))
6273 else if (unformat (i, "add"))
6275 else if (unformat (i, "not-last"))
6277 else if (unformat (i, "resolve-via-host"))
6279 else if (unformat (i, "resolve-via-attached"))
6280 resolve_attached = 1;
6281 else if (unformat (i, "multipath"))
6283 else if (unformat (i, "vrf %d", &vrf_id))
6285 else if (unformat (i, "create-vrf"))
6286 create_vrf_if_needed = 1;
6287 else if (unformat (i, "count %d", &count))
6289 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6291 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6293 else if (unformat (i, "out-label %d", &next_hop_out_label))
6294 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6295 else if (unformat (i, "via-label %d", &next_hop_via_label))
6297 else if (unformat (i, "random"))
6299 else if (unformat (i, "seed %d", &random_seed))
6303 clib_warning ("parse error '%U'", format_unformat_error, i);
6308 if (!next_hop_set && !is_drop && !is_local &&
6309 !is_classify && !is_unreach && !is_prohibit &&
6310 MPLS_LABEL_INVALID == next_hop_via_label)
6313 ("next hop / local / drop / unreach / prohibit / classify not set");
6317 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6319 errmsg ("next hop and next-hop via label set");
6322 if (address_set == 0)
6324 errmsg ("missing addresses");
6328 if (address_length_set == 0)
6330 errmsg ("missing address length");
6334 /* Generate a pile of unique, random routes */
6337 u32 this_random_address;
6338 random_hash = hash_create (count, sizeof (uword));
6340 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6341 for (j = 0; j <= count; j++)
6345 this_random_address = random_u32 (&random_seed);
6346 this_random_address =
6347 clib_host_to_net_u32 (this_random_address);
6349 while (hash_get (random_hash, this_random_address));
6350 vec_add1 (random_vector, this_random_address);
6351 hash_set (random_hash, this_random_address, 1);
6353 hash_free (random_hash);
6354 v4_dst_address.as_u32 = random_vector[0];
6359 /* Turn on async mode */
6360 vam->async_mode = 1;
6361 vam->async_errors = 0;
6362 before = vat_time_now (vam);
6365 for (j = 0; j < count; j++)
6367 /* Construct the API message */
6368 M2 (IP_ADD_DEL_ROUTE, mp,
6369 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6371 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6372 mp->table_id = ntohl (vrf_id);
6373 mp->create_vrf_if_needed = create_vrf_if_needed;
6375 mp->is_add = is_add;
6376 mp->is_drop = is_drop;
6377 mp->is_unreach = is_unreach;
6378 mp->is_prohibit = is_prohibit;
6379 mp->is_ipv6 = is_ipv6;
6380 mp->is_local = is_local;
6381 mp->is_classify = is_classify;
6382 mp->is_multipath = is_multipath;
6383 mp->is_resolve_host = resolve_host;
6384 mp->is_resolve_attached = resolve_attached;
6385 mp->not_last = not_last;
6386 mp->next_hop_weight = next_hop_weight;
6387 mp->dst_address_length = dst_address_length;
6388 mp->next_hop_table_id = ntohl (next_hop_table_id);
6389 mp->classify_table_index = ntohl (classify_table_index);
6390 mp->next_hop_via_label = ntohl (next_hop_via_label);
6391 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6392 if (0 != mp->next_hop_n_out_labels)
6394 memcpy (mp->next_hop_out_label_stack,
6395 next_hop_out_label_stack,
6396 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6397 vec_free (next_hop_out_label_stack);
6402 clib_memcpy (mp->dst_address, &v6_dst_address,
6403 sizeof (v6_dst_address));
6405 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6406 sizeof (v6_next_hop_address));
6407 increment_v6_address (&v6_dst_address);
6411 clib_memcpy (mp->dst_address, &v4_dst_address,
6412 sizeof (v4_dst_address));
6414 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6415 sizeof (v4_next_hop_address));
6417 v4_dst_address.as_u32 = random_vector[j + 1];
6419 increment_v4_address (&v4_dst_address);
6423 /* If we receive SIGTERM, stop now... */
6428 /* When testing multiple add/del ops, use a control-ping to sync */
6431 vl_api_control_ping_t *mp_ping;
6435 /* Shut off async mode */
6436 vam->async_mode = 0;
6438 M (CONTROL_PING, mp_ping);
6441 timeout = vat_time_now (vam) + 1.0;
6442 while (vat_time_now (vam) < timeout)
6443 if (vam->result_ready == 1)
6448 if (vam->retval == -99)
6451 if (vam->async_errors > 0)
6453 errmsg ("%d asynchronous errors", vam->async_errors);
6456 vam->async_errors = 0;
6457 after = vat_time_now (vam);
6459 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6463 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6464 count, after - before, count / (after - before));
6470 /* Wait for a reply... */
6475 /* Return the good/bad news */
6476 return (vam->retval);
6480 api_ip_mroute_add_del (vat_main_t * vam)
6482 unformat_input_t *i = vam->input;
6483 vl_api_ip_mroute_add_del_t *mp;
6484 u32 sw_if_index = ~0, vrf_id = 0;
6487 u8 create_vrf_if_needed = 0;
6490 u32 grp_address_length = 0;
6491 ip4_address_t v4_grp_address, v4_src_address;
6492 ip6_address_t v6_grp_address, v6_src_address;
6493 mfib_itf_flags_t iflags = 0;
6494 mfib_entry_flags_t eflags = 0;
6497 /* Parse args required to build the message */
6498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6500 if (unformat (i, "sw_if_index %d", &sw_if_index))
6502 else if (unformat (i, "%U %U",
6503 unformat_ip4_address, &v4_src_address,
6504 unformat_ip4_address, &v4_grp_address))
6506 grp_address_length = 64;
6510 else if (unformat (i, "%U %U",
6511 unformat_ip6_address, &v6_src_address,
6512 unformat_ip6_address, &v6_grp_address))
6514 grp_address_length = 256;
6518 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6520 memset (&v4_src_address, 0, sizeof (v4_src_address));
6521 grp_address_length = 32;
6525 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6527 memset (&v6_src_address, 0, sizeof (v6_src_address));
6528 grp_address_length = 128;
6532 else if (unformat (i, "/%d", &grp_address_length))
6534 else if (unformat (i, "local"))
6538 else if (unformat (i, "del"))
6540 else if (unformat (i, "add"))
6542 else if (unformat (i, "vrf %d", &vrf_id))
6544 else if (unformat (i, "create-vrf"))
6545 create_vrf_if_needed = 1;
6546 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6548 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6552 clib_warning ("parse error '%U'", format_unformat_error, i);
6557 if (address_set == 0)
6559 errmsg ("missing addresses\n");
6563 /* Construct the API message */
6564 M (IP_MROUTE_ADD_DEL, mp);
6566 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6567 mp->table_id = ntohl (vrf_id);
6568 mp->create_vrf_if_needed = create_vrf_if_needed;
6570 mp->is_add = is_add;
6571 mp->is_ipv6 = is_ipv6;
6572 mp->is_local = is_local;
6573 mp->itf_flags = ntohl (iflags);
6574 mp->entry_flags = ntohl (eflags);
6575 mp->grp_address_length = grp_address_length;
6576 mp->grp_address_length = ntohs (mp->grp_address_length);
6580 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6581 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6585 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6586 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6592 /* Wait for a reply... */
6598 api_mpls_route_add_del (vat_main_t * vam)
6600 unformat_input_t *i = vam->input;
6601 vl_api_mpls_route_add_del_t *mp;
6602 u32 sw_if_index = ~0, table_id = 0;
6603 u8 create_table_if_needed = 0;
6605 u32 next_hop_weight = 1;
6606 u8 is_multipath = 0;
6607 u32 next_hop_table_id = 0;
6608 u8 next_hop_set = 0;
6609 ip4_address_t v4_next_hop_address = {
6612 ip6_address_t v6_next_hop_address = { {0} };
6616 u32 classify_table_index = ~0;
6618 u8 resolve_host = 0, resolve_attached = 0;
6619 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6620 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6621 mpls_label_t *next_hop_out_label_stack = NULL;
6622 mpls_label_t local_label = MPLS_LABEL_INVALID;
6624 u8 next_hop_proto_is_ip4 = 1;
6626 /* Parse args required to build the message */
6627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6629 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6631 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6633 else if (unformat (i, "%d", &local_label))
6635 else if (unformat (i, "eos"))
6637 else if (unformat (i, "non-eos"))
6639 else if (unformat (i, "via %U", unformat_ip4_address,
6640 &v4_next_hop_address))
6643 next_hop_proto_is_ip4 = 1;
6645 else if (unformat (i, "via %U", unformat_ip6_address,
6646 &v6_next_hop_address))
6649 next_hop_proto_is_ip4 = 0;
6651 else if (unformat (i, "weight %d", &next_hop_weight))
6653 else if (unformat (i, "create-table"))
6654 create_table_if_needed = 1;
6655 else if (unformat (i, "classify %d", &classify_table_index))
6659 else if (unformat (i, "del"))
6661 else if (unformat (i, "add"))
6663 else if (unformat (i, "resolve-via-host"))
6665 else if (unformat (i, "resolve-via-attached"))
6666 resolve_attached = 1;
6667 else if (unformat (i, "multipath"))
6669 else if (unformat (i, "count %d", &count))
6671 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6674 next_hop_proto_is_ip4 = 1;
6676 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6679 next_hop_proto_is_ip4 = 0;
6681 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6683 else if (unformat (i, "via-label %d", &next_hop_via_label))
6685 else if (unformat (i, "out-label %d", &next_hop_out_label))
6686 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6689 clib_warning ("parse error '%U'", format_unformat_error, i);
6694 if (!next_hop_set && !is_classify)
6696 errmsg ("next hop / classify not set");
6700 if (MPLS_LABEL_INVALID == local_label)
6702 errmsg ("missing label");
6708 /* Turn on async mode */
6709 vam->async_mode = 1;
6710 vam->async_errors = 0;
6711 before = vat_time_now (vam);
6714 for (j = 0; j < count; j++)
6716 /* Construct the API message */
6717 M2 (MPLS_ROUTE_ADD_DEL, mp,
6718 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6720 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6721 mp->mr_table_id = ntohl (table_id);
6722 mp->mr_create_table_if_needed = create_table_if_needed;
6724 mp->mr_is_add = is_add;
6725 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6726 mp->mr_is_classify = is_classify;
6727 mp->mr_is_multipath = is_multipath;
6728 mp->mr_is_resolve_host = resolve_host;
6729 mp->mr_is_resolve_attached = resolve_attached;
6730 mp->mr_next_hop_weight = next_hop_weight;
6731 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6732 mp->mr_classify_table_index = ntohl (classify_table_index);
6733 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6734 mp->mr_label = ntohl (local_label);
6735 mp->mr_eos = is_eos;
6737 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6738 if (0 != mp->mr_next_hop_n_out_labels)
6740 memcpy (mp->mr_next_hop_out_label_stack,
6741 next_hop_out_label_stack,
6742 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6743 vec_free (next_hop_out_label_stack);
6748 if (next_hop_proto_is_ip4)
6750 clib_memcpy (mp->mr_next_hop,
6751 &v4_next_hop_address,
6752 sizeof (v4_next_hop_address));
6756 clib_memcpy (mp->mr_next_hop,
6757 &v6_next_hop_address,
6758 sizeof (v6_next_hop_address));
6765 /* If we receive SIGTERM, stop now... */
6770 /* When testing multiple add/del ops, use a control-ping to sync */
6773 vl_api_control_ping_t *mp_ping;
6777 /* Shut off async mode */
6778 vam->async_mode = 0;
6780 M (CONTROL_PING, mp_ping);
6783 timeout = vat_time_now (vam) + 1.0;
6784 while (vat_time_now (vam) < timeout)
6785 if (vam->result_ready == 1)
6790 if (vam->retval == -99)
6793 if (vam->async_errors > 0)
6795 errmsg ("%d asynchronous errors", vam->async_errors);
6798 vam->async_errors = 0;
6799 after = vat_time_now (vam);
6801 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6805 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6806 count, after - before, count / (after - before));
6812 /* Wait for a reply... */
6817 /* Return the good/bad news */
6818 return (vam->retval);
6822 api_mpls_ip_bind_unbind (vat_main_t * vam)
6824 unformat_input_t *i = vam->input;
6825 vl_api_mpls_ip_bind_unbind_t *mp;
6826 u32 ip_table_id = 0;
6827 u8 create_table_if_needed = 0;
6830 ip4_address_t v4_address;
6831 ip6_address_t v6_address;
6834 mpls_label_t local_label = MPLS_LABEL_INVALID;
6837 /* Parse args required to build the message */
6838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6840 if (unformat (i, "%U/%d", unformat_ip4_address,
6841 &v4_address, &address_length))
6846 else if (unformat (i, "%U/%d", unformat_ip6_address,
6847 &v6_address, &address_length))
6852 else if (unformat (i, "%d", &local_label))
6854 else if (unformat (i, "create-table"))
6855 create_table_if_needed = 1;
6856 else if (unformat (i, "table-id %d", &ip_table_id))
6858 else if (unformat (i, "unbind"))
6860 else if (unformat (i, "bind"))
6864 clib_warning ("parse error '%U'", format_unformat_error, i);
6871 errmsg ("IP addres not set");
6875 if (MPLS_LABEL_INVALID == local_label)
6877 errmsg ("missing label");
6881 /* Construct the API message */
6882 M (MPLS_IP_BIND_UNBIND, mp);
6884 mp->mb_create_table_if_needed = create_table_if_needed;
6885 mp->mb_is_bind = is_bind;
6886 mp->mb_is_ip4 = is_ip4;
6887 mp->mb_ip_table_id = ntohl (ip_table_id);
6888 mp->mb_mpls_table_id = 0;
6889 mp->mb_label = ntohl (local_label);
6890 mp->mb_address_length = address_length;
6893 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6895 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6900 /* Wait for a reply... */
6906 api_proxy_arp_add_del (vat_main_t * vam)
6908 unformat_input_t *i = vam->input;
6909 vl_api_proxy_arp_add_del_t *mp;
6912 ip4_address_t lo, hi;
6916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6918 if (unformat (i, "vrf %d", &vrf_id))
6920 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6921 unformat_ip4_address, &hi))
6923 else if (unformat (i, "del"))
6927 clib_warning ("parse error '%U'", format_unformat_error, i);
6934 errmsg ("address range not set");
6938 M (PROXY_ARP_ADD_DEL, mp);
6940 mp->vrf_id = ntohl (vrf_id);
6941 mp->is_add = is_add;
6942 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6943 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6951 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6953 unformat_input_t *i = vam->input;
6954 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6957 u8 sw_if_index_set = 0;
6960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6962 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6963 sw_if_index_set = 1;
6964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6965 sw_if_index_set = 1;
6966 else if (unformat (i, "enable"))
6968 else if (unformat (i, "disable"))
6972 clib_warning ("parse error '%U'", format_unformat_error, i);
6977 if (sw_if_index_set == 0)
6979 errmsg ("missing interface name or sw_if_index");
6983 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
6985 mp->sw_if_index = ntohl (sw_if_index);
6986 mp->enable_disable = enable;
6994 api_mpls_tunnel_add_del (vat_main_t * vam)
6996 unformat_input_t *i = vam->input;
6997 vl_api_mpls_tunnel_add_del_t *mp;
7001 u32 sw_if_index = ~0;
7002 u32 next_hop_sw_if_index = ~0;
7003 u32 next_hop_proto_is_ip4 = 1;
7005 u32 next_hop_table_id = 0;
7006 ip4_address_t v4_next_hop_address = {
7009 ip6_address_t v6_next_hop_address = { {0} };
7010 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7015 if (unformat (i, "add"))
7017 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7019 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7021 else if (unformat (i, "via %U",
7022 unformat_ip4_address, &v4_next_hop_address))
7024 next_hop_proto_is_ip4 = 1;
7026 else if (unformat (i, "via %U",
7027 unformat_ip6_address, &v6_next_hop_address))
7029 next_hop_proto_is_ip4 = 0;
7031 else if (unformat (i, "l2-only"))
7033 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7035 else if (unformat (i, "out-label %d", &next_hop_out_label))
7036 vec_add1 (labels, ntohl (next_hop_out_label));
7039 clib_warning ("parse error '%U'", format_unformat_error, i);
7044 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7046 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7047 mp->mt_sw_if_index = ntohl (sw_if_index);
7048 mp->mt_is_add = is_add;
7049 mp->mt_l2_only = l2_only;
7050 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7051 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7053 mp->mt_next_hop_n_out_labels = vec_len (labels);
7055 if (0 != mp->mt_next_hop_n_out_labels)
7057 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7058 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7062 if (next_hop_proto_is_ip4)
7064 clib_memcpy (mp->mt_next_hop,
7065 &v4_next_hop_address, sizeof (v4_next_hop_address));
7069 clib_memcpy (mp->mt_next_hop,
7070 &v6_next_hop_address, sizeof (v6_next_hop_address));
7079 api_sw_interface_set_unnumbered (vat_main_t * vam)
7081 unformat_input_t *i = vam->input;
7082 vl_api_sw_interface_set_unnumbered_t *mp;
7084 u32 unnum_sw_index = ~0;
7086 u8 sw_if_index_set = 0;
7089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7092 sw_if_index_set = 1;
7093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7094 sw_if_index_set = 1;
7095 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7097 else if (unformat (i, "del"))
7101 clib_warning ("parse error '%U'", format_unformat_error, i);
7106 if (sw_if_index_set == 0)
7108 errmsg ("missing interface name or sw_if_index");
7112 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7114 mp->sw_if_index = ntohl (sw_if_index);
7115 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7116 mp->is_add = is_add;
7124 api_ip_neighbor_add_del (vat_main_t * vam)
7126 unformat_input_t *i = vam->input;
7127 vl_api_ip_neighbor_add_del_t *mp;
7129 u8 sw_if_index_set = 0;
7134 u8 v4_address_set = 0;
7135 u8 v6_address_set = 0;
7136 ip4_address_t v4address;
7137 ip6_address_t v6address;
7140 memset (mac_address, 0, sizeof (mac_address));
7142 /* Parse args required to build the message */
7143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7145 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7149 else if (unformat (i, "del"))
7152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7153 sw_if_index_set = 1;
7154 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7155 sw_if_index_set = 1;
7156 else if (unformat (i, "is_static"))
7158 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7160 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7164 clib_warning ("parse error '%U'", format_unformat_error, i);
7169 if (sw_if_index_set == 0)
7171 errmsg ("missing interface name or sw_if_index");
7174 if (v4_address_set && v6_address_set)
7176 errmsg ("both v4 and v6 addresses set");
7179 if (!v4_address_set && !v6_address_set)
7181 errmsg ("no address set");
7185 /* Construct the API message */
7186 M (IP_NEIGHBOR_ADD_DEL, mp);
7188 mp->sw_if_index = ntohl (sw_if_index);
7189 mp->is_add = is_add;
7190 mp->is_static = is_static;
7192 clib_memcpy (mp->mac_address, mac_address, 6);
7196 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7200 /* mp->is_ipv6 = 0; via memset in M macro above */
7201 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7207 /* Wait for a reply, return good/bad news */
7213 api_reset_vrf (vat_main_t * vam)
7215 unformat_input_t *i = vam->input;
7216 vl_api_reset_vrf_t *mp;
7222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7224 if (unformat (i, "vrf %d", &vrf_id))
7226 else if (unformat (i, "ipv6"))
7230 clib_warning ("parse error '%U'", format_unformat_error, i);
7235 if (vrf_id_set == 0)
7237 errmsg ("missing vrf id");
7243 mp->vrf_id = ntohl (vrf_id);
7244 mp->is_ipv6 = is_ipv6;
7252 api_create_vlan_subif (vat_main_t * vam)
7254 unformat_input_t *i = vam->input;
7255 vl_api_create_vlan_subif_t *mp;
7257 u8 sw_if_index_set = 0;
7262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7264 if (unformat (i, "sw_if_index %d", &sw_if_index))
7265 sw_if_index_set = 1;
7267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7268 sw_if_index_set = 1;
7269 else if (unformat (i, "vlan %d", &vlan_id))
7273 clib_warning ("parse error '%U'", format_unformat_error, i);
7278 if (sw_if_index_set == 0)
7280 errmsg ("missing interface name or sw_if_index");
7284 if (vlan_id_set == 0)
7286 errmsg ("missing vlan_id");
7289 M (CREATE_VLAN_SUBIF, mp);
7291 mp->sw_if_index = ntohl (sw_if_index);
7292 mp->vlan_id = ntohl (vlan_id);
7299 #define foreach_create_subif_bit \
7306 _(outer_vlan_id_any) \
7307 _(inner_vlan_id_any)
7310 api_create_subif (vat_main_t * vam)
7312 unformat_input_t *i = vam->input;
7313 vl_api_create_subif_t *mp;
7315 u8 sw_if_index_set = 0;
7322 u32 exact_match = 0;
7323 u32 default_sub = 0;
7324 u32 outer_vlan_id_any = 0;
7325 u32 inner_vlan_id_any = 0;
7327 u16 outer_vlan_id = 0;
7328 u16 inner_vlan_id = 0;
7331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7333 if (unformat (i, "sw_if_index %d", &sw_if_index))
7334 sw_if_index_set = 1;
7336 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7337 sw_if_index_set = 1;
7338 else if (unformat (i, "sub_id %d", &sub_id))
7340 else if (unformat (i, "outer_vlan_id %d", &tmp))
7341 outer_vlan_id = tmp;
7342 else if (unformat (i, "inner_vlan_id %d", &tmp))
7343 inner_vlan_id = tmp;
7345 #define _(a) else if (unformat (i, #a)) a = 1 ;
7346 foreach_create_subif_bit
7350 clib_warning ("parse error '%U'", format_unformat_error, i);
7355 if (sw_if_index_set == 0)
7357 errmsg ("missing interface name or sw_if_index");
7361 if (sub_id_set == 0)
7363 errmsg ("missing sub_id");
7366 M (CREATE_SUBIF, mp);
7368 mp->sw_if_index = ntohl (sw_if_index);
7369 mp->sub_id = ntohl (sub_id);
7371 #define _(a) mp->a = a;
7372 foreach_create_subif_bit;
7375 mp->outer_vlan_id = ntohs (outer_vlan_id);
7376 mp->inner_vlan_id = ntohs (inner_vlan_id);
7384 api_oam_add_del (vat_main_t * vam)
7386 unformat_input_t *i = vam->input;
7387 vl_api_oam_add_del_t *mp;
7390 ip4_address_t src, dst;
7395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7397 if (unformat (i, "vrf %d", &vrf_id))
7399 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7401 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7403 else if (unformat (i, "del"))
7407 clib_warning ("parse error '%U'", format_unformat_error, i);
7414 errmsg ("missing src addr");
7420 errmsg ("missing dst addr");
7424 M (OAM_ADD_DEL, mp);
7426 mp->vrf_id = ntohl (vrf_id);
7427 mp->is_add = is_add;
7428 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7429 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7437 api_reset_fib (vat_main_t * vam)
7439 unformat_input_t *i = vam->input;
7440 vl_api_reset_fib_t *mp;
7446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7448 if (unformat (i, "vrf %d", &vrf_id))
7450 else if (unformat (i, "ipv6"))
7454 clib_warning ("parse error '%U'", format_unformat_error, i);
7459 if (vrf_id_set == 0)
7461 errmsg ("missing vrf id");
7467 mp->vrf_id = ntohl (vrf_id);
7468 mp->is_ipv6 = is_ipv6;
7476 api_dhcp_proxy_config (vat_main_t * vam)
7478 unformat_input_t *i = vam->input;
7479 vl_api_dhcp_proxy_config_t *mp;
7481 u32 server_vrf_id = 0;
7483 u8 v4_address_set = 0;
7484 u8 v6_address_set = 0;
7485 ip4_address_t v4address;
7486 ip6_address_t v6address;
7487 u8 v4_src_address_set = 0;
7488 u8 v6_src_address_set = 0;
7489 ip4_address_t v4srcaddress;
7490 ip6_address_t v6srcaddress;
7493 /* Parse args required to build the message */
7494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7496 if (unformat (i, "del"))
7498 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7500 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7502 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7504 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7506 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7507 v4_src_address_set = 1;
7508 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7509 v6_src_address_set = 1;
7514 if (v4_address_set && v6_address_set)
7516 errmsg ("both v4 and v6 server addresses set");
7519 if (!v4_address_set && !v6_address_set)
7521 errmsg ("no server addresses set");
7525 if (v4_src_address_set && v6_src_address_set)
7527 errmsg ("both v4 and v6 src addresses set");
7530 if (!v4_src_address_set && !v6_src_address_set)
7532 errmsg ("no src addresses set");
7536 if (!(v4_src_address_set && v4_address_set) &&
7537 !(v6_src_address_set && v6_address_set))
7539 errmsg ("no matching server and src addresses set");
7543 /* Construct the API message */
7544 M (DHCP_PROXY_CONFIG, mp);
7546 mp->is_add = is_add;
7547 mp->rx_vrf_id = ntohl (rx_vrf_id);
7548 mp->server_vrf_id = ntohl (server_vrf_id);
7552 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7553 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7557 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7558 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7564 /* Wait for a reply, return good/bad news */
7569 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7570 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7573 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7575 vat_main_t *vam = &vat_main;
7579 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7580 ntohl (mp->rx_vrf_id),
7581 ntohl (mp->server_vrf_id),
7582 format_ip6_address, mp->dhcp_server,
7583 format_ip6_address, mp->dhcp_src_address,
7584 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7587 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7588 ntohl (mp->rx_vrf_id),
7589 ntohl (mp->server_vrf_id),
7590 format_ip4_address, mp->dhcp_server,
7591 format_ip4_address, mp->dhcp_src_address,
7592 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7595 static void vl_api_dhcp_proxy_details_t_handler_json
7596 (vl_api_dhcp_proxy_details_t * mp)
7598 vat_main_t *vam = &vat_main;
7599 vat_json_node_t *node = NULL;
7601 struct in6_addr ip6;
7603 if (VAT_JSON_ARRAY != vam->json_tree.type)
7605 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7606 vat_json_init_array (&vam->json_tree);
7608 node = vat_json_array_add (&vam->json_tree);
7610 vat_json_init_object (node);
7611 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7612 vat_json_object_add_uint (node, "server-table-id",
7613 ntohl (mp->server_vrf_id));
7616 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7617 vat_json_object_add_ip6 (node, "server_address", ip6);
7618 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7619 vat_json_object_add_ip6 (node, "src_address", ip6);
7623 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7624 vat_json_object_add_ip4 (node, "server_address", ip4);
7625 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7626 vat_json_object_add_ip4 (node, "src_address", ip4);
7628 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7629 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7633 api_dhcp_proxy_dump (vat_main_t * vam)
7635 unformat_input_t *i = vam->input;
7636 vl_api_control_ping_t *mp_ping;
7637 vl_api_dhcp_proxy_dump_t *mp;
7641 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7643 if (unformat (i, "ipv6"))
7647 clib_warning ("parse error '%U'", format_unformat_error, i);
7652 M (DHCP_PROXY_DUMP, mp);
7654 mp->is_ip6 = is_ipv6;
7657 /* Use a control ping for synchronization */
7658 M (CONTROL_PING, mp_ping);
7666 api_dhcp_proxy_set_vss (vat_main_t * vam)
7668 unformat_input_t *i = vam->input;
7669 vl_api_dhcp_proxy_set_vss_t *mp;
7680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7682 if (unformat (i, "tbl_id %d", &tbl_id))
7684 if (unformat (i, "fib_id %d", &fib_id))
7686 if (unformat (i, "oui %d", &oui))
7688 else if (unformat (i, "ipv6"))
7690 else if (unformat (i, "del"))
7694 clib_warning ("parse error '%U'", format_unformat_error, i);
7699 if (tbl_id_set == 0)
7701 errmsg ("missing tbl id");
7705 if (fib_id_set == 0)
7707 errmsg ("missing fib id");
7712 errmsg ("missing oui");
7716 M (DHCP_PROXY_SET_VSS, mp);
7717 mp->tbl_id = ntohl (tbl_id);
7718 mp->fib_id = ntohl (fib_id);
7719 mp->oui = ntohl (oui);
7720 mp->is_ipv6 = is_ipv6;
7721 mp->is_add = is_add;
7729 api_dhcp_client_config (vat_main_t * vam)
7731 unformat_input_t *i = vam->input;
7732 vl_api_dhcp_client_config_t *mp;
7734 u8 sw_if_index_set = 0;
7737 u8 disable_event = 0;
7740 /* Parse args required to build the message */
7741 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7743 if (unformat (i, "del"))
7746 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7747 sw_if_index_set = 1;
7748 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7749 sw_if_index_set = 1;
7750 else if (unformat (i, "hostname %s", &hostname))
7752 else if (unformat (i, "disable_event"))
7758 if (sw_if_index_set == 0)
7760 errmsg ("missing interface name or sw_if_index");
7764 if (vec_len (hostname) > 63)
7766 errmsg ("hostname too long");
7768 vec_add1 (hostname, 0);
7770 /* Construct the API message */
7771 M (DHCP_CLIENT_CONFIG, mp);
7773 mp->sw_if_index = ntohl (sw_if_index);
7774 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7775 vec_free (hostname);
7776 mp->is_add = is_add;
7777 mp->want_dhcp_event = disable_event ? 0 : 1;
7778 mp->pid = getpid ();
7783 /* Wait for a reply, return good/bad news */
7789 api_set_ip_flow_hash (vat_main_t * vam)
7791 unformat_input_t *i = vam->input;
7792 vl_api_set_ip_flow_hash_t *mp;
7804 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7806 if (unformat (i, "vrf %d", &vrf_id))
7808 else if (unformat (i, "ipv6"))
7810 else if (unformat (i, "src"))
7812 else if (unformat (i, "dst"))
7814 else if (unformat (i, "sport"))
7816 else if (unformat (i, "dport"))
7818 else if (unformat (i, "proto"))
7820 else if (unformat (i, "reverse"))
7825 clib_warning ("parse error '%U'", format_unformat_error, i);
7830 if (vrf_id_set == 0)
7832 errmsg ("missing vrf id");
7836 M (SET_IP_FLOW_HASH, mp);
7842 mp->reverse = reverse;
7843 mp->vrf_id = ntohl (vrf_id);
7844 mp->is_ipv6 = is_ipv6;
7852 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7854 unformat_input_t *i = vam->input;
7855 vl_api_sw_interface_ip6_enable_disable_t *mp;
7857 u8 sw_if_index_set = 0;
7861 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7863 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7864 sw_if_index_set = 1;
7865 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7866 sw_if_index_set = 1;
7867 else if (unformat (i, "enable"))
7869 else if (unformat (i, "disable"))
7873 clib_warning ("parse error '%U'", format_unformat_error, i);
7878 if (sw_if_index_set == 0)
7880 errmsg ("missing interface name or sw_if_index");
7884 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7886 mp->sw_if_index = ntohl (sw_if_index);
7887 mp->enable = enable;
7895 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7897 unformat_input_t *i = vam->input;
7898 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7900 u8 sw_if_index_set = 0;
7901 u8 v6_address_set = 0;
7902 ip6_address_t v6address;
7905 /* Parse args required to build the message */
7906 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7908 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7909 sw_if_index_set = 1;
7910 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7911 sw_if_index_set = 1;
7912 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7918 if (sw_if_index_set == 0)
7920 errmsg ("missing interface name or sw_if_index");
7923 if (!v6_address_set)
7925 errmsg ("no address set");
7929 /* Construct the API message */
7930 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
7932 mp->sw_if_index = ntohl (sw_if_index);
7933 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7938 /* Wait for a reply, return good/bad news */
7945 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7947 unformat_input_t *i = vam->input;
7948 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7950 u8 sw_if_index_set = 0;
7951 u32 address_length = 0;
7952 u8 v6_address_set = 0;
7953 ip6_address_t v6address;
7955 u8 no_advertise = 0;
7957 u8 no_autoconfig = 0;
7960 u32 val_lifetime = 0;
7961 u32 pref_lifetime = 0;
7964 /* Parse args required to build the message */
7965 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7967 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7968 sw_if_index_set = 1;
7969 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7970 sw_if_index_set = 1;
7971 else if (unformat (i, "%U/%d",
7972 unformat_ip6_address, &v6address, &address_length))
7974 else if (unformat (i, "val_life %d", &val_lifetime))
7976 else if (unformat (i, "pref_life %d", &pref_lifetime))
7978 else if (unformat (i, "def"))
7980 else if (unformat (i, "noadv"))
7982 else if (unformat (i, "offl"))
7984 else if (unformat (i, "noauto"))
7986 else if (unformat (i, "nolink"))
7988 else if (unformat (i, "isno"))
7992 clib_warning ("parse error '%U'", format_unformat_error, i);
7997 if (sw_if_index_set == 0)
7999 errmsg ("missing interface name or sw_if_index");
8002 if (!v6_address_set)
8004 errmsg ("no address set");
8008 /* Construct the API message */
8009 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8011 mp->sw_if_index = ntohl (sw_if_index);
8012 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8013 mp->address_length = address_length;
8014 mp->use_default = use_default;
8015 mp->no_advertise = no_advertise;
8016 mp->off_link = off_link;
8017 mp->no_autoconfig = no_autoconfig;
8018 mp->no_onlink = no_onlink;
8020 mp->val_lifetime = ntohl (val_lifetime);
8021 mp->pref_lifetime = ntohl (pref_lifetime);
8026 /* Wait for a reply, return good/bad news */
8032 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8034 unformat_input_t *i = vam->input;
8035 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8037 u8 sw_if_index_set = 0;
8042 u8 send_unicast = 0;
8045 u8 default_router = 0;
8046 u32 max_interval = 0;
8047 u32 min_interval = 0;
8049 u32 initial_count = 0;
8050 u32 initial_interval = 0;
8054 /* Parse args required to build the message */
8055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8057 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8058 sw_if_index_set = 1;
8059 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8060 sw_if_index_set = 1;
8061 else if (unformat (i, "maxint %d", &max_interval))
8063 else if (unformat (i, "minint %d", &min_interval))
8065 else if (unformat (i, "life %d", &lifetime))
8067 else if (unformat (i, "count %d", &initial_count))
8069 else if (unformat (i, "interval %d", &initial_interval))
8071 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8073 else if (unformat (i, "managed"))
8075 else if (unformat (i, "other"))
8077 else if (unformat (i, "ll"))
8079 else if (unformat (i, "send"))
8081 else if (unformat (i, "cease"))
8083 else if (unformat (i, "isno"))
8085 else if (unformat (i, "def"))
8089 clib_warning ("parse error '%U'", format_unformat_error, i);
8094 if (sw_if_index_set == 0)
8096 errmsg ("missing interface name or sw_if_index");
8100 /* Construct the API message */
8101 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8103 mp->sw_if_index = ntohl (sw_if_index);
8104 mp->max_interval = ntohl (max_interval);
8105 mp->min_interval = ntohl (min_interval);
8106 mp->lifetime = ntohl (lifetime);
8107 mp->initial_count = ntohl (initial_count);
8108 mp->initial_interval = ntohl (initial_interval);
8109 mp->suppress = suppress;
8110 mp->managed = managed;
8112 mp->ll_option = ll_option;
8113 mp->send_unicast = send_unicast;
8116 mp->default_router = default_router;
8121 /* Wait for a reply, return good/bad news */
8127 api_set_arp_neighbor_limit (vat_main_t * vam)
8129 unformat_input_t *i = vam->input;
8130 vl_api_set_arp_neighbor_limit_t *mp;
8136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8138 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8140 else if (unformat (i, "ipv6"))
8144 clib_warning ("parse error '%U'", format_unformat_error, i);
8151 errmsg ("missing limit value");
8155 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8157 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8158 mp->is_ipv6 = is_ipv6;
8166 api_l2_patch_add_del (vat_main_t * vam)
8168 unformat_input_t *i = vam->input;
8169 vl_api_l2_patch_add_del_t *mp;
8171 u8 rx_sw_if_index_set = 0;
8173 u8 tx_sw_if_index_set = 0;
8177 /* Parse args required to build the message */
8178 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8180 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8181 rx_sw_if_index_set = 1;
8182 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8183 tx_sw_if_index_set = 1;
8184 else if (unformat (i, "rx"))
8186 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8188 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8190 rx_sw_if_index_set = 1;
8195 else if (unformat (i, "tx"))
8197 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8199 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8201 tx_sw_if_index_set = 1;
8206 else if (unformat (i, "del"))
8212 if (rx_sw_if_index_set == 0)
8214 errmsg ("missing rx interface name or rx_sw_if_index");
8218 if (tx_sw_if_index_set == 0)
8220 errmsg ("missing tx interface name or tx_sw_if_index");
8224 M (L2_PATCH_ADD_DEL, mp);
8226 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8227 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8228 mp->is_add = is_add;
8236 u8 localsid_addr[16];
8245 api_sr_localsid_add_del (vat_main_t * vam)
8247 unformat_input_t *i = vam->input;
8248 vl_api_sr_localsid_add_del_t *mp;
8251 ip6_address_t localsid;
8255 u32 fib_table = ~(u32) 0;
8256 ip6_address_t next_hop;
8258 bool nexthop_set = 0;
8262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8264 if (unformat (i, "del"))
8266 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8267 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8269 else if (unformat (i, "behavior %u", &behavior));
8270 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8271 else if (unformat (i, "fib-table %u", &fib_table));
8272 else if (unformat (i, "end.psp %u", &behavior));
8277 M (SR_LOCALSID_ADD_DEL, mp);
8279 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8281 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8282 mp->behavior = behavior;
8283 mp->sw_if_index = ntohl (sw_if_index);
8284 mp->fib_table = ntohl (fib_table);
8285 mp->end_psp = end_psp;
8286 mp->is_del = is_del;
8294 api_ioam_enable (vat_main_t * vam)
8296 unformat_input_t *input = vam->input;
8297 vl_api_ioam_enable_t *mp;
8299 int has_trace_option = 0;
8300 int has_pot_option = 0;
8301 int has_seqno_option = 0;
8302 int has_analyse_option = 0;
8305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8307 if (unformat (input, "trace"))
8308 has_trace_option = 1;
8309 else if (unformat (input, "pot"))
8311 else if (unformat (input, "seqno"))
8312 has_seqno_option = 1;
8313 else if (unformat (input, "analyse"))
8314 has_analyse_option = 1;
8318 M (IOAM_ENABLE, mp);
8319 mp->id = htons (id);
8320 mp->seqno = has_seqno_option;
8321 mp->analyse = has_analyse_option;
8322 mp->pot_enable = has_pot_option;
8323 mp->trace_enable = has_trace_option;
8332 api_ioam_disable (vat_main_t * vam)
8334 vl_api_ioam_disable_t *mp;
8337 M (IOAM_DISABLE, mp);
8343 #define foreach_tcp_proto_field \
8347 #define foreach_udp_proto_field \
8351 #define foreach_ip4_proto_field \
8363 u16 src_port, dst_port;
8366 #if VPP_API_TEST_BUILTIN == 0
8368 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8370 u8 **maskp = va_arg (*args, u8 **);
8372 u8 found_something = 0;
8375 #define _(a) u8 a=0;
8376 foreach_tcp_proto_field;
8379 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8382 #define _(a) else if (unformat (input, #a)) a=1;
8383 foreach_tcp_proto_field
8389 #define _(a) found_something += a;
8390 foreach_tcp_proto_field;
8393 if (found_something == 0)
8396 vec_validate (mask, sizeof (*tcp) - 1);
8398 tcp = (tcp_header_t *) mask;
8400 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8401 foreach_tcp_proto_field;
8409 unformat_udp_mask (unformat_input_t * input, va_list * args)
8411 u8 **maskp = va_arg (*args, u8 **);
8413 u8 found_something = 0;
8416 #define _(a) u8 a=0;
8417 foreach_udp_proto_field;
8420 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8423 #define _(a) else if (unformat (input, #a)) a=1;
8424 foreach_udp_proto_field
8430 #define _(a) found_something += a;
8431 foreach_udp_proto_field;
8434 if (found_something == 0)
8437 vec_validate (mask, sizeof (*udp) - 1);
8439 udp = (udp_header_t *) mask;
8441 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8442 foreach_udp_proto_field;
8450 unformat_l4_mask (unformat_input_t * input, va_list * args)
8452 u8 **maskp = va_arg (*args, u8 **);
8453 u16 src_port = 0, dst_port = 0;
8454 tcpudp_header_t *tcpudp;
8456 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8458 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8460 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8462 else if (unformat (input, "src_port"))
8464 else if (unformat (input, "dst_port"))
8470 if (!src_port && !dst_port)
8474 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8476 tcpudp = (tcpudp_header_t *) mask;
8477 tcpudp->src_port = src_port;
8478 tcpudp->dst_port = dst_port;
8486 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8488 u8 **maskp = va_arg (*args, u8 **);
8490 u8 found_something = 0;
8493 #define _(a) u8 a=0;
8494 foreach_ip4_proto_field;
8500 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8502 if (unformat (input, "version"))
8504 else if (unformat (input, "hdr_length"))
8506 else if (unformat (input, "src"))
8508 else if (unformat (input, "dst"))
8510 else if (unformat (input, "proto"))
8513 #define _(a) else if (unformat (input, #a)) a=1;
8514 foreach_ip4_proto_field
8520 #define _(a) found_something += a;
8521 foreach_ip4_proto_field;
8524 if (found_something == 0)
8527 vec_validate (mask, sizeof (*ip) - 1);
8529 ip = (ip4_header_t *) mask;
8531 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8532 foreach_ip4_proto_field;
8535 ip->ip_version_and_header_length = 0;
8538 ip->ip_version_and_header_length |= 0xF0;
8541 ip->ip_version_and_header_length |= 0x0F;
8547 #define foreach_ip6_proto_field \
8555 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8557 u8 **maskp = va_arg (*args, u8 **);
8559 u8 found_something = 0;
8561 u32 ip_version_traffic_class_and_flow_label;
8563 #define _(a) u8 a=0;
8564 foreach_ip6_proto_field;
8567 u8 traffic_class = 0;
8570 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8572 if (unformat (input, "version"))
8574 else if (unformat (input, "traffic-class"))
8576 else if (unformat (input, "flow-label"))
8578 else if (unformat (input, "src"))
8580 else if (unformat (input, "dst"))
8582 else if (unformat (input, "proto"))
8585 #define _(a) else if (unformat (input, #a)) a=1;
8586 foreach_ip6_proto_field
8592 #define _(a) found_something += a;
8593 foreach_ip6_proto_field;
8596 if (found_something == 0)
8599 vec_validate (mask, sizeof (*ip) - 1);
8601 ip = (ip6_header_t *) mask;
8603 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8604 foreach_ip6_proto_field;
8607 ip_version_traffic_class_and_flow_label = 0;
8610 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8613 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8616 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8618 ip->ip_version_traffic_class_and_flow_label =
8619 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8626 unformat_l3_mask (unformat_input_t * input, va_list * args)
8628 u8 **maskp = va_arg (*args, u8 **);
8630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8632 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8634 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8643 unformat_l2_mask (unformat_input_t * input, va_list * args)
8645 u8 **maskp = va_arg (*args, u8 **);
8660 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8662 if (unformat (input, "src"))
8664 else if (unformat (input, "dst"))
8666 else if (unformat (input, "proto"))
8668 else if (unformat (input, "tag1"))
8670 else if (unformat (input, "tag2"))
8672 else if (unformat (input, "ignore-tag1"))
8674 else if (unformat (input, "ignore-tag2"))
8676 else if (unformat (input, "cos1"))
8678 else if (unformat (input, "cos2"))
8680 else if (unformat (input, "dot1q"))
8682 else if (unformat (input, "dot1ad"))
8687 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8688 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8691 if (tag1 || ignore_tag1 || cos1 || dot1q)
8693 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8696 vec_validate (mask, len - 1);
8699 memset (mask, 0xff, 6);
8702 memset (mask + 6, 0xff, 6);
8706 /* inner vlan tag */
8715 mask[21] = mask[20] = 0xff;
8736 mask[16] = mask[17] = 0xff;
8746 mask[12] = mask[13] = 0xff;
8753 unformat_classify_mask (unformat_input_t * input, va_list * args)
8755 u8 **maskp = va_arg (*args, u8 **);
8756 u32 *skipp = va_arg (*args, u32 *);
8757 u32 *matchp = va_arg (*args, u32 *);
8765 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8767 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8769 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8771 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8773 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8787 if (mask || l2 || l3 || l4)
8791 /* "With a free Ethernet header in every package" */
8793 vec_validate (l2, 13);
8797 vec_append (mask, l3);
8802 vec_append (mask, l4);
8807 /* Scan forward looking for the first significant mask octet */
8808 for (i = 0; i < vec_len (mask); i++)
8812 /* compute (skip, match) params */
8813 *skipp = i / sizeof (u32x4);
8814 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8816 /* Pad mask to an even multiple of the vector size */
8817 while (vec_len (mask) % sizeof (u32x4))
8820 match = vec_len (mask) / sizeof (u32x4);
8822 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8824 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8825 if (*tmp || *(tmp + 1))
8830 clib_warning ("BUG: match 0");
8832 _vec_len (mask) = match * sizeof (u32x4);
8842 #endif /* VPP_API_TEST_BUILTIN */
8844 #define foreach_l2_next \
8846 _(ethernet, ETHERNET_INPUT) \
8851 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8853 u32 *miss_next_indexp = va_arg (*args, u32 *);
8858 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8862 if (unformat (input, "%d", &tmp))
8871 *miss_next_indexp = next_index;
8875 #define foreach_ip_next \
8881 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
8883 u32 *miss_next_indexp = va_arg (*args, u32 *);
8888 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8892 if (unformat (input, "%d", &tmp))
8901 *miss_next_indexp = next_index;
8905 #define foreach_acl_next \
8909 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
8911 u32 *miss_next_indexp = va_arg (*args, u32 *);
8916 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8920 if (unformat (input, "permit"))
8925 else if (unformat (input, "%d", &tmp))
8934 *miss_next_indexp = next_index;
8939 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8941 u32 *r = va_arg (*args, u32 *);
8943 if (unformat (input, "conform-color"))
8944 *r = POLICE_CONFORM;
8945 else if (unformat (input, "exceed-color"))
8954 api_classify_add_del_table (vat_main_t * vam)
8956 unformat_input_t *i = vam->input;
8957 vl_api_classify_add_del_table_t *mp;
8964 u32 table_index = ~0;
8965 u32 next_table_index = ~0;
8966 u32 miss_next_index = ~0;
8967 u32 memory_size = 32 << 20;
8969 u32 current_data_flag = 0;
8970 int current_data_offset = 0;
8973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8975 if (unformat (i, "del"))
8977 else if (unformat (i, "del-chain"))
8982 else if (unformat (i, "buckets %d", &nbuckets))
8984 else if (unformat (i, "memory_size %d", &memory_size))
8986 else if (unformat (i, "skip %d", &skip))
8988 else if (unformat (i, "match %d", &match))
8990 else if (unformat (i, "table %d", &table_index))
8992 else if (unformat (i, "mask %U", unformat_classify_mask,
8993 &mask, &skip, &match))
8995 else if (unformat (i, "next-table %d", &next_table_index))
8997 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9000 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9003 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9006 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9008 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9014 if (is_add && mask == 0)
9016 errmsg ("Mask required");
9020 if (is_add && skip == ~0)
9022 errmsg ("skip count required");
9026 if (is_add && match == ~0)
9028 errmsg ("match count required");
9032 if (!is_add && table_index == ~0)
9034 errmsg ("table index required for delete");
9038 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9040 mp->is_add = is_add;
9041 mp->del_chain = del_chain;
9042 mp->table_index = ntohl (table_index);
9043 mp->nbuckets = ntohl (nbuckets);
9044 mp->memory_size = ntohl (memory_size);
9045 mp->skip_n_vectors = ntohl (skip);
9046 mp->match_n_vectors = ntohl (match);
9047 mp->next_table_index = ntohl (next_table_index);
9048 mp->miss_next_index = ntohl (miss_next_index);
9049 mp->current_data_flag = ntohl (current_data_flag);
9050 mp->current_data_offset = ntohl (current_data_offset);
9051 clib_memcpy (mp->mask, mask, vec_len (mask));
9060 #if VPP_API_TEST_BUILTIN == 0
9062 unformat_l4_match (unformat_input_t * input, va_list * args)
9064 u8 **matchp = va_arg (*args, u8 **);
9066 u8 *proto_header = 0;
9072 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9074 if (unformat (input, "src_port %d", &src_port))
9076 else if (unformat (input, "dst_port %d", &dst_port))
9082 h.src_port = clib_host_to_net_u16 (src_port);
9083 h.dst_port = clib_host_to_net_u16 (dst_port);
9084 vec_validate (proto_header, sizeof (h) - 1);
9085 memcpy (proto_header, &h, sizeof (h));
9087 *matchp = proto_header;
9093 unformat_ip4_match (unformat_input_t * input, va_list * args)
9095 u8 **matchp = va_arg (*args, u8 **);
9102 int src = 0, dst = 0;
9103 ip4_address_t src_val, dst_val;
9110 int fragment_id = 0;
9111 u32 fragment_id_val;
9117 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9119 if (unformat (input, "version %d", &version_val))
9121 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9123 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9125 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9127 else if (unformat (input, "proto %d", &proto_val))
9129 else if (unformat (input, "tos %d", &tos_val))
9131 else if (unformat (input, "length %d", &length_val))
9133 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9135 else if (unformat (input, "ttl %d", &ttl_val))
9137 else if (unformat (input, "checksum %d", &checksum_val))
9143 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9144 + ttl + checksum == 0)
9148 * Aligned because we use the real comparison functions
9150 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9152 ip = (ip4_header_t *) match;
9154 /* These are realistically matched in practice */
9156 ip->src_address.as_u32 = src_val.as_u32;
9159 ip->dst_address.as_u32 = dst_val.as_u32;
9162 ip->protocol = proto_val;
9165 /* These are not, but they're included for completeness */
9167 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9170 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9176 ip->length = clib_host_to_net_u16 (length_val);
9182 ip->checksum = clib_host_to_net_u16 (checksum_val);
9189 unformat_ip6_match (unformat_input_t * input, va_list * args)
9191 u8 **matchp = va_arg (*args, u8 **);
9196 u8 traffic_class = 0;
9197 u32 traffic_class_val = 0;
9200 int src = 0, dst = 0;
9201 ip6_address_t src_val, dst_val;
9204 int payload_length = 0;
9205 u32 payload_length_val;
9208 u32 ip_version_traffic_class_and_flow_label;
9210 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9212 if (unformat (input, "version %d", &version_val))
9214 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9216 else if (unformat (input, "flow_label %d", &flow_label_val))
9218 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9220 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9222 else if (unformat (input, "proto %d", &proto_val))
9224 else if (unformat (input, "payload_length %d", &payload_length_val))
9226 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9232 if (version + traffic_class + flow_label + src + dst + proto +
9233 payload_length + hop_limit == 0)
9237 * Aligned because we use the real comparison functions
9239 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9241 ip = (ip6_header_t *) match;
9244 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9247 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9250 ip->protocol = proto_val;
9252 ip_version_traffic_class_and_flow_label = 0;
9255 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9258 ip_version_traffic_class_and_flow_label |=
9259 (traffic_class_val & 0xFF) << 20;
9262 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9264 ip->ip_version_traffic_class_and_flow_label =
9265 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9268 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9271 ip->hop_limit = hop_limit_val;
9278 unformat_l3_match (unformat_input_t * input, va_list * args)
9280 u8 **matchp = va_arg (*args, u8 **);
9282 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9284 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9286 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9295 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9297 u8 *tagp = va_arg (*args, u8 *);
9300 if (unformat (input, "%d", &tag))
9302 tagp[0] = (tag >> 8) & 0x0F;
9303 tagp[1] = tag & 0xFF;
9311 unformat_l2_match (unformat_input_t * input, va_list * args)
9313 u8 **matchp = va_arg (*args, u8 **);
9333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9335 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9338 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9340 else if (unformat (input, "proto %U",
9341 unformat_ethernet_type_host_byte_order, &proto_val))
9343 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9345 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9347 else if (unformat (input, "ignore-tag1"))
9349 else if (unformat (input, "ignore-tag2"))
9351 else if (unformat (input, "cos1 %d", &cos1_val))
9353 else if (unformat (input, "cos2 %d", &cos2_val))
9358 if ((src + dst + proto + tag1 + tag2 +
9359 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9362 if (tag1 || ignore_tag1 || cos1)
9364 if (tag2 || ignore_tag2 || cos2)
9367 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9370 clib_memcpy (match, dst_val, 6);
9373 clib_memcpy (match + 6, src_val, 6);
9377 /* inner vlan tag */
9378 match[19] = tag2_val[1];
9379 match[18] = tag2_val[0];
9381 match[18] |= (cos2_val & 0x7) << 5;
9384 match[21] = proto_val & 0xff;
9385 match[20] = proto_val >> 8;
9389 match[15] = tag1_val[1];
9390 match[14] = tag1_val[0];
9393 match[14] |= (cos1_val & 0x7) << 5;
9399 match[15] = tag1_val[1];
9400 match[14] = tag1_val[0];
9403 match[17] = proto_val & 0xff;
9404 match[16] = proto_val >> 8;
9407 match[14] |= (cos1_val & 0x7) << 5;
9413 match[18] |= (cos2_val & 0x7) << 5;
9415 match[14] |= (cos1_val & 0x7) << 5;
9418 match[13] = proto_val & 0xff;
9419 match[12] = proto_val >> 8;
9428 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9430 u8 **matchp = va_arg (*args, u8 **);
9431 u32 skip_n_vectors = va_arg (*args, u32);
9432 u32 match_n_vectors = va_arg (*args, u32);
9439 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9441 if (unformat (input, "hex %U", unformat_hex_string, &match))
9443 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9445 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9447 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9461 if (match || l2 || l3 || l4)
9465 /* "Win a free Ethernet header in every packet" */
9467 vec_validate_aligned (l2, 13, sizeof (u32x4));
9471 vec_append_aligned (match, l3, sizeof (u32x4));
9476 vec_append_aligned (match, l4, sizeof (u32x4));
9481 /* Make sure the vector is big enough even if key is all 0's */
9482 vec_validate_aligned
9483 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9486 /* Set size, include skipped vectors */
9487 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9498 api_classify_add_del_session (vat_main_t * vam)
9500 unformat_input_t *i = vam->input;
9501 vl_api_classify_add_del_session_t *mp;
9503 u32 table_index = ~0;
9504 u32 hit_next_index = ~0;
9505 u32 opaque_index = ~0;
9508 u32 skip_n_vectors = 0;
9509 u32 match_n_vectors = 0;
9515 * Warning: you have to supply skip_n and match_n
9516 * because the API client cant simply look at the classify
9520 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9522 if (unformat (i, "del"))
9524 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9527 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9530 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9533 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9535 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9537 else if (unformat (i, "opaque-index %d", &opaque_index))
9539 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9541 else if (unformat (i, "match_n %d", &match_n_vectors))
9543 else if (unformat (i, "match %U", api_unformat_classify_match,
9544 &match, skip_n_vectors, match_n_vectors))
9546 else if (unformat (i, "advance %d", &advance))
9548 else if (unformat (i, "table-index %d", &table_index))
9550 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9552 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9554 else if (unformat (i, "action %d", &action))
9556 else if (unformat (i, "metadata %d", &metadata))
9562 if (table_index == ~0)
9564 errmsg ("Table index required");
9568 if (is_add && match == 0)
9570 errmsg ("Match value required");
9574 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9576 mp->is_add = is_add;
9577 mp->table_index = ntohl (table_index);
9578 mp->hit_next_index = ntohl (hit_next_index);
9579 mp->opaque_index = ntohl (opaque_index);
9580 mp->advance = ntohl (advance);
9581 mp->action = action;
9582 mp->metadata = ntohl (metadata);
9583 clib_memcpy (mp->match, match, vec_len (match));
9592 api_classify_set_interface_ip_table (vat_main_t * vam)
9594 unformat_input_t *i = vam->input;
9595 vl_api_classify_set_interface_ip_table_t *mp;
9597 int sw_if_index_set;
9598 u32 table_index = ~0;
9602 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9604 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9605 sw_if_index_set = 1;
9606 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9607 sw_if_index_set = 1;
9608 else if (unformat (i, "table %d", &table_index))
9612 clib_warning ("parse error '%U'", format_unformat_error, i);
9617 if (sw_if_index_set == 0)
9619 errmsg ("missing interface name or sw_if_index");
9624 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9626 mp->sw_if_index = ntohl (sw_if_index);
9627 mp->table_index = ntohl (table_index);
9628 mp->is_ipv6 = is_ipv6;
9636 api_classify_set_interface_l2_tables (vat_main_t * vam)
9638 unformat_input_t *i = vam->input;
9639 vl_api_classify_set_interface_l2_tables_t *mp;
9641 int sw_if_index_set;
9642 u32 ip4_table_index = ~0;
9643 u32 ip6_table_index = ~0;
9644 u32 other_table_index = ~0;
9648 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9650 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9651 sw_if_index_set = 1;
9652 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9653 sw_if_index_set = 1;
9654 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9656 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9658 else if (unformat (i, "other-table %d", &other_table_index))
9660 else if (unformat (i, "is-input %d", &is_input))
9664 clib_warning ("parse error '%U'", format_unformat_error, i);
9669 if (sw_if_index_set == 0)
9671 errmsg ("missing interface name or sw_if_index");
9676 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9678 mp->sw_if_index = ntohl (sw_if_index);
9679 mp->ip4_table_index = ntohl (ip4_table_index);
9680 mp->ip6_table_index = ntohl (ip6_table_index);
9681 mp->other_table_index = ntohl (other_table_index);
9682 mp->is_input = (u8) is_input;
9690 api_set_ipfix_exporter (vat_main_t * vam)
9692 unformat_input_t *i = vam->input;
9693 vl_api_set_ipfix_exporter_t *mp;
9694 ip4_address_t collector_address;
9695 u8 collector_address_set = 0;
9696 u32 collector_port = ~0;
9697 ip4_address_t src_address;
9698 u8 src_address_set = 0;
9701 u32 template_interval = ~0;
9702 u8 udp_checksum = 0;
9705 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9707 if (unformat (i, "collector_address %U", unformat_ip4_address,
9708 &collector_address))
9709 collector_address_set = 1;
9710 else if (unformat (i, "collector_port %d", &collector_port))
9712 else if (unformat (i, "src_address %U", unformat_ip4_address,
9714 src_address_set = 1;
9715 else if (unformat (i, "vrf_id %d", &vrf_id))
9717 else if (unformat (i, "path_mtu %d", &path_mtu))
9719 else if (unformat (i, "template_interval %d", &template_interval))
9721 else if (unformat (i, "udp_checksum"))
9727 if (collector_address_set == 0)
9729 errmsg ("collector_address required");
9733 if (src_address_set == 0)
9735 errmsg ("src_address required");
9739 M (SET_IPFIX_EXPORTER, mp);
9741 memcpy (mp->collector_address, collector_address.data,
9742 sizeof (collector_address.data));
9743 mp->collector_port = htons ((u16) collector_port);
9744 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9745 mp->vrf_id = htonl (vrf_id);
9746 mp->path_mtu = htonl (path_mtu);
9747 mp->template_interval = htonl (template_interval);
9748 mp->udp_checksum = udp_checksum;
9756 api_set_ipfix_classify_stream (vat_main_t * vam)
9758 unformat_input_t *i = vam->input;
9759 vl_api_set_ipfix_classify_stream_t *mp;
9761 u32 src_port = UDP_DST_PORT_ipfix;
9764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9766 if (unformat (i, "domain %d", &domain_id))
9768 else if (unformat (i, "src_port %d", &src_port))
9772 errmsg ("unknown input `%U'", format_unformat_error, i);
9777 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9779 mp->domain_id = htonl (domain_id);
9780 mp->src_port = htons ((u16) src_port);
9788 api_ipfix_classify_table_add_del (vat_main_t * vam)
9790 unformat_input_t *i = vam->input;
9791 vl_api_ipfix_classify_table_add_del_t *mp;
9793 u32 classify_table_index = ~0;
9795 u8 transport_protocol = 255;
9798 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9800 if (unformat (i, "add"))
9802 else if (unformat (i, "del"))
9804 else if (unformat (i, "table %d", &classify_table_index))
9806 else if (unformat (i, "ip4"))
9808 else if (unformat (i, "ip6"))
9810 else if (unformat (i, "tcp"))
9811 transport_protocol = 6;
9812 else if (unformat (i, "udp"))
9813 transport_protocol = 17;
9816 errmsg ("unknown input `%U'", format_unformat_error, i);
9823 errmsg ("expecting: add|del");
9826 if (classify_table_index == ~0)
9828 errmsg ("classifier table not specified");
9831 if (ip_version == 0)
9833 errmsg ("IP version not specified");
9837 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
9839 mp->is_add = is_add;
9840 mp->table_id = htonl (classify_table_index);
9841 mp->ip_version = ip_version;
9842 mp->transport_protocol = transport_protocol;
9850 api_get_node_index (vat_main_t * vam)
9852 unformat_input_t *i = vam->input;
9853 vl_api_get_node_index_t *mp;
9857 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9859 if (unformat (i, "node %s", &name))
9866 errmsg ("node name required");
9869 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9871 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9875 M (GET_NODE_INDEX, mp);
9876 clib_memcpy (mp->node_name, name, vec_len (name));
9885 api_get_next_index (vat_main_t * vam)
9887 unformat_input_t *i = vam->input;
9888 vl_api_get_next_index_t *mp;
9889 u8 *node_name = 0, *next_node_name = 0;
9892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9894 if (unformat (i, "node-name %s", &node_name))
9896 else if (unformat (i, "next-node-name %s", &next_node_name))
9902 errmsg ("node name required");
9905 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9907 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9911 if (next_node_name == 0)
9913 errmsg ("next node name required");
9916 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9918 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9922 M (GET_NEXT_INDEX, mp);
9923 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9924 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9925 vec_free (node_name);
9926 vec_free (next_node_name);
9934 api_add_node_next (vat_main_t * vam)
9936 unformat_input_t *i = vam->input;
9937 vl_api_add_node_next_t *mp;
9942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9944 if (unformat (i, "node %s", &name))
9946 else if (unformat (i, "next %s", &next))
9953 errmsg ("node name required");
9956 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9958 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9963 errmsg ("next node required");
9966 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9968 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9972 M (ADD_NODE_NEXT, mp);
9973 clib_memcpy (mp->node_name, name, vec_len (name));
9974 clib_memcpy (mp->next_name, next, vec_len (next));
9984 api_l2tpv3_create_tunnel (vat_main_t * vam)
9986 unformat_input_t *i = vam->input;
9987 ip6_address_t client_address, our_address;
9988 int client_address_set = 0;
9989 int our_address_set = 0;
9990 u32 local_session_id = 0;
9991 u32 remote_session_id = 0;
9992 u64 local_cookie = 0;
9993 u64 remote_cookie = 0;
9994 u8 l2_sublayer_present = 0;
9995 vl_api_l2tpv3_create_tunnel_t *mp;
9998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10000 if (unformat (i, "client_address %U", unformat_ip6_address,
10002 client_address_set = 1;
10003 else if (unformat (i, "our_address %U", unformat_ip6_address,
10005 our_address_set = 1;
10006 else if (unformat (i, "local_session_id %d", &local_session_id))
10008 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10010 else if (unformat (i, "local_cookie %lld", &local_cookie))
10012 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10014 else if (unformat (i, "l2-sublayer-present"))
10015 l2_sublayer_present = 1;
10020 if (client_address_set == 0)
10022 errmsg ("client_address required");
10026 if (our_address_set == 0)
10028 errmsg ("our_address required");
10032 M (L2TPV3_CREATE_TUNNEL, mp);
10034 clib_memcpy (mp->client_address, client_address.as_u8,
10035 sizeof (mp->client_address));
10037 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10039 mp->local_session_id = ntohl (local_session_id);
10040 mp->remote_session_id = ntohl (remote_session_id);
10041 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10042 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10043 mp->l2_sublayer_present = l2_sublayer_present;
10052 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10054 unformat_input_t *i = vam->input;
10056 u8 sw_if_index_set = 0;
10057 u64 new_local_cookie = 0;
10058 u64 new_remote_cookie = 0;
10059 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10065 sw_if_index_set = 1;
10066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10067 sw_if_index_set = 1;
10068 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10070 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10076 if (sw_if_index_set == 0)
10078 errmsg ("missing interface name or sw_if_index");
10082 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10084 mp->sw_if_index = ntohl (sw_if_index);
10085 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10086 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10094 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10096 unformat_input_t *i = vam->input;
10097 vl_api_l2tpv3_interface_enable_disable_t *mp;
10099 u8 sw_if_index_set = 0;
10100 u8 enable_disable = 1;
10103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10106 sw_if_index_set = 1;
10107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10108 sw_if_index_set = 1;
10109 else if (unformat (i, "enable"))
10110 enable_disable = 1;
10111 else if (unformat (i, "disable"))
10112 enable_disable = 0;
10117 if (sw_if_index_set == 0)
10119 errmsg ("missing interface name or sw_if_index");
10123 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10125 mp->sw_if_index = ntohl (sw_if_index);
10126 mp->enable_disable = enable_disable;
10134 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10136 unformat_input_t *i = vam->input;
10137 vl_api_l2tpv3_set_lookup_key_t *mp;
10141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10143 if (unformat (i, "lookup_v6_src"))
10144 key = L2T_LOOKUP_SRC_ADDRESS;
10145 else if (unformat (i, "lookup_v6_dst"))
10146 key = L2T_LOOKUP_DST_ADDRESS;
10147 else if (unformat (i, "lookup_session_id"))
10148 key = L2T_LOOKUP_SESSION_ID;
10153 if (key == (u8) ~ 0)
10155 errmsg ("l2tp session lookup key unset");
10159 M (L2TPV3_SET_LOOKUP_KEY, mp);
10168 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10169 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10171 vat_main_t *vam = &vat_main;
10173 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10174 format_ip6_address, mp->our_address,
10175 format_ip6_address, mp->client_address,
10176 clib_net_to_host_u32 (mp->sw_if_index));
10179 " local cookies %016llx %016llx remote cookie %016llx",
10180 clib_net_to_host_u64 (mp->local_cookie[0]),
10181 clib_net_to_host_u64 (mp->local_cookie[1]),
10182 clib_net_to_host_u64 (mp->remote_cookie));
10184 print (vam->ofp, " local session-id %d remote session-id %d",
10185 clib_net_to_host_u32 (mp->local_session_id),
10186 clib_net_to_host_u32 (mp->remote_session_id));
10188 print (vam->ofp, " l2 specific sublayer %s\n",
10189 mp->l2_sublayer_present ? "preset" : "absent");
10193 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10194 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10196 vat_main_t *vam = &vat_main;
10197 vat_json_node_t *node = NULL;
10198 struct in6_addr addr;
10200 if (VAT_JSON_ARRAY != vam->json_tree.type)
10202 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10203 vat_json_init_array (&vam->json_tree);
10205 node = vat_json_array_add (&vam->json_tree);
10207 vat_json_init_object (node);
10209 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10210 vat_json_object_add_ip6 (node, "our_address", addr);
10211 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10212 vat_json_object_add_ip6 (node, "client_address", addr);
10214 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10215 vat_json_init_array (lc);
10216 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10217 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10218 vat_json_object_add_uint (node, "remote_cookie",
10219 clib_net_to_host_u64 (mp->remote_cookie));
10221 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10222 vat_json_object_add_uint (node, "local_session_id",
10223 clib_net_to_host_u32 (mp->local_session_id));
10224 vat_json_object_add_uint (node, "remote_session_id",
10225 clib_net_to_host_u32 (mp->remote_session_id));
10226 vat_json_object_add_string_copy (node, "l2_sublayer",
10227 mp->l2_sublayer_present ? (u8 *) "present"
10228 : (u8 *) "absent");
10232 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10234 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10235 vl_api_control_ping_t *mp_ping;
10238 /* Get list of l2tpv3-tunnel interfaces */
10239 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10242 /* Use a control ping for synchronization */
10243 M (CONTROL_PING, mp_ping);
10251 static void vl_api_sw_interface_tap_details_t_handler
10252 (vl_api_sw_interface_tap_details_t * mp)
10254 vat_main_t *vam = &vat_main;
10256 print (vam->ofp, "%-16s %d",
10257 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10260 static void vl_api_sw_interface_tap_details_t_handler_json
10261 (vl_api_sw_interface_tap_details_t * mp)
10263 vat_main_t *vam = &vat_main;
10264 vat_json_node_t *node = NULL;
10266 if (VAT_JSON_ARRAY != vam->json_tree.type)
10268 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10269 vat_json_init_array (&vam->json_tree);
10271 node = vat_json_array_add (&vam->json_tree);
10273 vat_json_init_object (node);
10274 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10275 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10279 api_sw_interface_tap_dump (vat_main_t * vam)
10281 vl_api_sw_interface_tap_dump_t *mp;
10282 vl_api_control_ping_t *mp_ping;
10285 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10286 /* Get list of tap interfaces */
10287 M (SW_INTERFACE_TAP_DUMP, mp);
10290 /* Use a control ping for synchronization */
10291 M (CONTROL_PING, mp_ping);
10298 static uword unformat_vxlan_decap_next
10299 (unformat_input_t * input, va_list * args)
10301 u32 *result = va_arg (*args, u32 *);
10304 if (unformat (input, "l2"))
10305 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10306 else if (unformat (input, "%d", &tmp))
10314 api_vxlan_add_del_tunnel (vat_main_t * vam)
10316 unformat_input_t *line_input = vam->input;
10317 vl_api_vxlan_add_del_tunnel_t *mp;
10318 ip46_address_t src, dst;
10320 u8 ipv4_set = 0, ipv6_set = 0;
10324 u32 mcast_sw_if_index = ~0;
10325 u32 encap_vrf_id = 0;
10326 u32 decap_next_index = ~0;
10330 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10331 memset (&src, 0, sizeof src);
10332 memset (&dst, 0, sizeof dst);
10334 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10336 if (unformat (line_input, "del"))
10339 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10345 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10351 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10357 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10362 else if (unformat (line_input, "group %U %U",
10363 unformat_ip4_address, &dst.ip4,
10364 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10366 grp_set = dst_set = 1;
10369 else if (unformat (line_input, "group %U",
10370 unformat_ip4_address, &dst.ip4))
10372 grp_set = dst_set = 1;
10375 else if (unformat (line_input, "group %U %U",
10376 unformat_ip6_address, &dst.ip6,
10377 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10379 grp_set = dst_set = 1;
10382 else if (unformat (line_input, "group %U",
10383 unformat_ip6_address, &dst.ip6))
10385 grp_set = dst_set = 1;
10389 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10391 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10393 else if (unformat (line_input, "decap-next %U",
10394 unformat_vxlan_decap_next, &decap_next_index))
10396 else if (unformat (line_input, "vni %d", &vni))
10400 errmsg ("parse error '%U'", format_unformat_error, line_input);
10407 errmsg ("tunnel src address not specified");
10412 errmsg ("tunnel dst address not specified");
10416 if (grp_set && !ip46_address_is_multicast (&dst))
10418 errmsg ("tunnel group address not multicast");
10421 if (grp_set && mcast_sw_if_index == ~0)
10423 errmsg ("tunnel nonexistent multicast device");
10426 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10428 errmsg ("tunnel dst address must be unicast");
10433 if (ipv4_set && ipv6_set)
10435 errmsg ("both IPv4 and IPv6 addresses specified");
10439 if ((vni == 0) || (vni >> 24))
10441 errmsg ("vni not specified or out of range");
10445 M (VXLAN_ADD_DEL_TUNNEL, mp);
10449 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10450 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10454 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10455 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10457 mp->encap_vrf_id = ntohl (encap_vrf_id);
10458 mp->decap_next_index = ntohl (decap_next_index);
10459 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10460 mp->vni = ntohl (vni);
10461 mp->is_add = is_add;
10462 mp->is_ipv6 = ipv6_set;
10469 static void vl_api_vxlan_tunnel_details_t_handler
10470 (vl_api_vxlan_tunnel_details_t * mp)
10472 vat_main_t *vam = &vat_main;
10473 ip46_address_t src, dst;
10475 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10476 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10478 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10479 ntohl (mp->sw_if_index),
10480 format_ip46_address, &src, IP46_TYPE_ANY,
10481 format_ip46_address, &dst, IP46_TYPE_ANY,
10482 ntohl (mp->encap_vrf_id),
10483 ntohl (mp->decap_next_index), ntohl (mp->vni),
10484 ntohl (mp->mcast_sw_if_index));
10487 static void vl_api_vxlan_tunnel_details_t_handler_json
10488 (vl_api_vxlan_tunnel_details_t * mp)
10490 vat_main_t *vam = &vat_main;
10491 vat_json_node_t *node = NULL;
10493 if (VAT_JSON_ARRAY != vam->json_tree.type)
10495 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10496 vat_json_init_array (&vam->json_tree);
10498 node = vat_json_array_add (&vam->json_tree);
10500 vat_json_init_object (node);
10501 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10504 struct in6_addr ip6;
10506 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10507 vat_json_object_add_ip6 (node, "src_address", ip6);
10508 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10509 vat_json_object_add_ip6 (node, "dst_address", ip6);
10513 struct in_addr ip4;
10515 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10516 vat_json_object_add_ip4 (node, "src_address", ip4);
10517 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10518 vat_json_object_add_ip4 (node, "dst_address", ip4);
10520 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10521 vat_json_object_add_uint (node, "decap_next_index",
10522 ntohl (mp->decap_next_index));
10523 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10524 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10525 vat_json_object_add_uint (node, "mcast_sw_if_index",
10526 ntohl (mp->mcast_sw_if_index));
10530 api_vxlan_tunnel_dump (vat_main_t * vam)
10532 unformat_input_t *i = vam->input;
10533 vl_api_vxlan_tunnel_dump_t *mp;
10534 vl_api_control_ping_t *mp_ping;
10536 u8 sw_if_index_set = 0;
10539 /* Parse args required to build the message */
10540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10542 if (unformat (i, "sw_if_index %d", &sw_if_index))
10543 sw_if_index_set = 1;
10548 if (sw_if_index_set == 0)
10553 if (!vam->json_output)
10555 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10556 "sw_if_index", "src_address", "dst_address",
10557 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10560 /* Get list of vxlan-tunnel interfaces */
10561 M (VXLAN_TUNNEL_DUMP, mp);
10563 mp->sw_if_index = htonl (sw_if_index);
10567 /* Use a control ping for synchronization */
10568 M (CONTROL_PING, mp_ping);
10576 api_gre_add_del_tunnel (vat_main_t * vam)
10578 unformat_input_t *line_input = vam->input;
10579 vl_api_gre_add_del_tunnel_t *mp;
10580 ip4_address_t src4, dst4;
10585 u32 outer_fib_id = 0;
10588 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10590 if (unformat (line_input, "del"))
10592 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10594 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10596 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10598 else if (unformat (line_input, "teb"))
10602 errmsg ("parse error '%U'", format_unformat_error, line_input);
10609 errmsg ("tunnel src address not specified");
10614 errmsg ("tunnel dst address not specified");
10619 M (GRE_ADD_DEL_TUNNEL, mp);
10621 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10622 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10623 mp->outer_fib_id = ntohl (outer_fib_id);
10624 mp->is_add = is_add;
10632 static void vl_api_gre_tunnel_details_t_handler
10633 (vl_api_gre_tunnel_details_t * mp)
10635 vat_main_t *vam = &vat_main;
10637 print (vam->ofp, "%11d%15U%15U%6d%14d",
10638 ntohl (mp->sw_if_index),
10639 format_ip4_address, &mp->src_address,
10640 format_ip4_address, &mp->dst_address,
10641 mp->teb, ntohl (mp->outer_fib_id));
10644 static void vl_api_gre_tunnel_details_t_handler_json
10645 (vl_api_gre_tunnel_details_t * mp)
10647 vat_main_t *vam = &vat_main;
10648 vat_json_node_t *node = NULL;
10649 struct in_addr ip4;
10651 if (VAT_JSON_ARRAY != vam->json_tree.type)
10653 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10654 vat_json_init_array (&vam->json_tree);
10656 node = vat_json_array_add (&vam->json_tree);
10658 vat_json_init_object (node);
10659 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10660 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10661 vat_json_object_add_ip4 (node, "src_address", ip4);
10662 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10663 vat_json_object_add_ip4 (node, "dst_address", ip4);
10664 vat_json_object_add_uint (node, "teb", mp->teb);
10665 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10669 api_gre_tunnel_dump (vat_main_t * vam)
10671 unformat_input_t *i = vam->input;
10672 vl_api_gre_tunnel_dump_t *mp;
10673 vl_api_control_ping_t *mp_ping;
10675 u8 sw_if_index_set = 0;
10678 /* Parse args required to build the message */
10679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10681 if (unformat (i, "sw_if_index %d", &sw_if_index))
10682 sw_if_index_set = 1;
10687 if (sw_if_index_set == 0)
10692 if (!vam->json_output)
10694 print (vam->ofp, "%11s%15s%15s%6s%14s",
10695 "sw_if_index", "src_address", "dst_address", "teb",
10699 /* Get list of gre-tunnel interfaces */
10700 M (GRE_TUNNEL_DUMP, mp);
10702 mp->sw_if_index = htonl (sw_if_index);
10706 /* Use a control ping for synchronization */
10707 M (CONTROL_PING, mp_ping);
10715 api_l2_fib_clear_table (vat_main_t * vam)
10717 // unformat_input_t * i = vam->input;
10718 vl_api_l2_fib_clear_table_t *mp;
10721 M (L2_FIB_CLEAR_TABLE, mp);
10729 api_l2_interface_efp_filter (vat_main_t * vam)
10731 unformat_input_t *i = vam->input;
10732 vl_api_l2_interface_efp_filter_t *mp;
10735 u8 sw_if_index_set = 0;
10738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10740 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10741 sw_if_index_set = 1;
10742 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10743 sw_if_index_set = 1;
10744 else if (unformat (i, "enable"))
10746 else if (unformat (i, "disable"))
10750 clib_warning ("parse error '%U'", format_unformat_error, i);
10755 if (sw_if_index_set == 0)
10757 errmsg ("missing sw_if_index");
10761 M (L2_INTERFACE_EFP_FILTER, mp);
10763 mp->sw_if_index = ntohl (sw_if_index);
10764 mp->enable_disable = enable;
10771 #define foreach_vtr_op \
10772 _("disable", L2_VTR_DISABLED) \
10773 _("push-1", L2_VTR_PUSH_1) \
10774 _("push-2", L2_VTR_PUSH_2) \
10775 _("pop-1", L2_VTR_POP_1) \
10776 _("pop-2", L2_VTR_POP_2) \
10777 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10778 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10779 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10780 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10783 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10785 unformat_input_t *i = vam->input;
10786 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10788 u8 sw_if_index_set = 0;
10791 u32 push_dot1q = 1;
10796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10798 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10799 sw_if_index_set = 1;
10800 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10801 sw_if_index_set = 1;
10802 else if (unformat (i, "vtr_op %d", &vtr_op))
10804 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10807 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10809 else if (unformat (i, "tag1 %d", &tag1))
10811 else if (unformat (i, "tag2 %d", &tag2))
10815 clib_warning ("parse error '%U'", format_unformat_error, i);
10820 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10822 errmsg ("missing vtr operation or sw_if_index");
10826 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
10827 mp->sw_if_index = ntohl (sw_if_index);
10828 mp->vtr_op = ntohl (vtr_op);
10829 mp->push_dot1q = ntohl (push_dot1q);
10830 mp->tag1 = ntohl (tag1);
10831 mp->tag2 = ntohl (tag2);
10839 api_create_vhost_user_if (vat_main_t * vam)
10841 unformat_input_t *i = vam->input;
10842 vl_api_create_vhost_user_if_t *mp;
10845 u8 file_name_set = 0;
10846 u32 custom_dev_instance = ~0;
10848 u8 use_custom_mac = 0;
10852 /* Shut up coverity */
10853 memset (hwaddr, 0, sizeof (hwaddr));
10855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10857 if (unformat (i, "socket %s", &file_name))
10861 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10863 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10864 use_custom_mac = 1;
10865 else if (unformat (i, "server"))
10867 else if (unformat (i, "tag %s", &tag))
10873 if (file_name_set == 0)
10875 errmsg ("missing socket file name");
10879 if (vec_len (file_name) > 255)
10881 errmsg ("socket file name too long");
10884 vec_add1 (file_name, 0);
10886 M (CREATE_VHOST_USER_IF, mp);
10888 mp->is_server = is_server;
10889 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10890 vec_free (file_name);
10891 if (custom_dev_instance != ~0)
10894 mp->custom_dev_instance = ntohl (custom_dev_instance);
10896 mp->use_custom_mac = use_custom_mac;
10897 clib_memcpy (mp->mac_address, hwaddr, 6);
10899 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10908 api_modify_vhost_user_if (vat_main_t * vam)
10910 unformat_input_t *i = vam->input;
10911 vl_api_modify_vhost_user_if_t *mp;
10914 u8 file_name_set = 0;
10915 u32 custom_dev_instance = ~0;
10916 u8 sw_if_index_set = 0;
10917 u32 sw_if_index = (u32) ~ 0;
10920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10922 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10923 sw_if_index_set = 1;
10924 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10925 sw_if_index_set = 1;
10926 else if (unformat (i, "socket %s", &file_name))
10930 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10932 else if (unformat (i, "server"))
10938 if (sw_if_index_set == 0)
10940 errmsg ("missing sw_if_index or interface name");
10944 if (file_name_set == 0)
10946 errmsg ("missing socket file name");
10950 if (vec_len (file_name) > 255)
10952 errmsg ("socket file name too long");
10955 vec_add1 (file_name, 0);
10957 M (MODIFY_VHOST_USER_IF, mp);
10959 mp->sw_if_index = ntohl (sw_if_index);
10960 mp->is_server = is_server;
10961 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10962 vec_free (file_name);
10963 if (custom_dev_instance != ~0)
10966 mp->custom_dev_instance = ntohl (custom_dev_instance);
10975 api_delete_vhost_user_if (vat_main_t * vam)
10977 unformat_input_t *i = vam->input;
10978 vl_api_delete_vhost_user_if_t *mp;
10979 u32 sw_if_index = ~0;
10980 u8 sw_if_index_set = 0;
10983 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10985 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10986 sw_if_index_set = 1;
10987 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10988 sw_if_index_set = 1;
10993 if (sw_if_index_set == 0)
10995 errmsg ("missing sw_if_index or interface name");
11000 M (DELETE_VHOST_USER_IF, mp);
11002 mp->sw_if_index = ntohl (sw_if_index);
11009 static void vl_api_sw_interface_vhost_user_details_t_handler
11010 (vl_api_sw_interface_vhost_user_details_t * mp)
11012 vat_main_t *vam = &vat_main;
11014 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11015 (char *) mp->interface_name,
11016 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11017 clib_net_to_host_u64 (mp->features), mp->is_server,
11018 ntohl (mp->num_regions), (char *) mp->sock_filename);
11019 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11022 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11023 (vl_api_sw_interface_vhost_user_details_t * mp)
11025 vat_main_t *vam = &vat_main;
11026 vat_json_node_t *node = NULL;
11028 if (VAT_JSON_ARRAY != vam->json_tree.type)
11030 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11031 vat_json_init_array (&vam->json_tree);
11033 node = vat_json_array_add (&vam->json_tree);
11035 vat_json_init_object (node);
11036 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11037 vat_json_object_add_string_copy (node, "interface_name",
11038 mp->interface_name);
11039 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11040 ntohl (mp->virtio_net_hdr_sz));
11041 vat_json_object_add_uint (node, "features",
11042 clib_net_to_host_u64 (mp->features));
11043 vat_json_object_add_uint (node, "is_server", mp->is_server);
11044 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11045 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11046 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11050 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11052 vl_api_sw_interface_vhost_user_dump_t *mp;
11053 vl_api_control_ping_t *mp_ping;
11056 "Interface name idx hdr_sz features server regions filename");
11058 /* Get list of vhost-user interfaces */
11059 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11062 /* Use a control ping for synchronization */
11063 M (CONTROL_PING, mp_ping);
11071 api_show_version (vat_main_t * vam)
11073 vl_api_show_version_t *mp;
11076 M (SHOW_VERSION, mp);
11085 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11087 unformat_input_t *line_input = vam->input;
11088 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11089 ip4_address_t local4, remote4;
11090 ip6_address_t local6, remote6;
11092 u8 ipv4_set = 0, ipv6_set = 0;
11095 u32 encap_vrf_id = 0;
11096 u32 decap_vrf_id = 0;
11102 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11104 if (unformat (line_input, "del"))
11106 else if (unformat (line_input, "local %U",
11107 unformat_ip4_address, &local4))
11112 else if (unformat (line_input, "remote %U",
11113 unformat_ip4_address, &remote4))
11118 else if (unformat (line_input, "local %U",
11119 unformat_ip6_address, &local6))
11124 else if (unformat (line_input, "remote %U",
11125 unformat_ip6_address, &remote6))
11130 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11132 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11134 else if (unformat (line_input, "vni %d", &vni))
11136 else if (unformat (line_input, "next-ip4"))
11138 else if (unformat (line_input, "next-ip6"))
11140 else if (unformat (line_input, "next-ethernet"))
11142 else if (unformat (line_input, "next-nsh"))
11146 errmsg ("parse error '%U'", format_unformat_error, line_input);
11151 if (local_set == 0)
11153 errmsg ("tunnel local address not specified");
11156 if (remote_set == 0)
11158 errmsg ("tunnel remote address not specified");
11161 if (ipv4_set && ipv6_set)
11163 errmsg ("both IPv4 and IPv6 addresses specified");
11169 errmsg ("vni not specified");
11173 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11178 clib_memcpy (&mp->local, &local6, sizeof (local6));
11179 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11183 clib_memcpy (&mp->local, &local4, sizeof (local4));
11184 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11187 mp->encap_vrf_id = ntohl (encap_vrf_id);
11188 mp->decap_vrf_id = ntohl (decap_vrf_id);
11189 mp->protocol = protocol;
11190 mp->vni = ntohl (vni);
11191 mp->is_add = is_add;
11192 mp->is_ipv6 = ipv6_set;
11199 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11200 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11202 vat_main_t *vam = &vat_main;
11204 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11205 ntohl (mp->sw_if_index),
11206 format_ip46_address, &(mp->local[0]),
11207 format_ip46_address, &(mp->remote[0]),
11209 ntohl (mp->protocol),
11210 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11213 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11214 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11216 vat_main_t *vam = &vat_main;
11217 vat_json_node_t *node = NULL;
11218 struct in_addr ip4;
11219 struct in6_addr ip6;
11221 if (VAT_JSON_ARRAY != vam->json_tree.type)
11223 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11224 vat_json_init_array (&vam->json_tree);
11226 node = vat_json_array_add (&vam->json_tree);
11228 vat_json_init_object (node);
11229 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11232 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11233 vat_json_object_add_ip6 (node, "local", ip6);
11234 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11235 vat_json_object_add_ip6 (node, "remote", ip6);
11239 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11240 vat_json_object_add_ip4 (node, "local", ip4);
11241 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11242 vat_json_object_add_ip4 (node, "remote", ip4);
11244 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11245 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11246 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11247 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11248 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11252 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11254 unformat_input_t *i = vam->input;
11255 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11256 vl_api_control_ping_t *mp_ping;
11258 u8 sw_if_index_set = 0;
11261 /* Parse args required to build the message */
11262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11264 if (unformat (i, "sw_if_index %d", &sw_if_index))
11265 sw_if_index_set = 1;
11270 if (sw_if_index_set == 0)
11275 if (!vam->json_output)
11277 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11278 "sw_if_index", "local", "remote", "vni",
11279 "protocol", "encap_vrf_id", "decap_vrf_id");
11282 /* Get list of vxlan-tunnel interfaces */
11283 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11285 mp->sw_if_index = htonl (sw_if_index);
11289 /* Use a control ping for synchronization */
11290 M (CONTROL_PING, mp_ping);
11298 format_l2_fib_mac_address (u8 * s, va_list * args)
11300 u8 *a = va_arg (*args, u8 *);
11302 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11303 a[2], a[3], a[4], a[5], a[6], a[7]);
11306 static void vl_api_l2_fib_table_entry_t_handler
11307 (vl_api_l2_fib_table_entry_t * mp)
11309 vat_main_t *vam = &vat_main;
11311 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11313 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11314 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11318 static void vl_api_l2_fib_table_entry_t_handler_json
11319 (vl_api_l2_fib_table_entry_t * mp)
11321 vat_main_t *vam = &vat_main;
11322 vat_json_node_t *node = NULL;
11324 if (VAT_JSON_ARRAY != vam->json_tree.type)
11326 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11327 vat_json_init_array (&vam->json_tree);
11329 node = vat_json_array_add (&vam->json_tree);
11331 vat_json_init_object (node);
11332 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11333 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11334 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11335 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11336 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11337 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11341 api_l2_fib_table_dump (vat_main_t * vam)
11343 unformat_input_t *i = vam->input;
11344 vl_api_l2_fib_table_dump_t *mp;
11345 vl_api_control_ping_t *mp_ping;
11350 /* Parse args required to build the message */
11351 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11353 if (unformat (i, "bd_id %d", &bd_id))
11359 if (bd_id_set == 0)
11361 errmsg ("missing bridge domain");
11365 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11367 /* Get list of l2 fib entries */
11368 M (L2_FIB_TABLE_DUMP, mp);
11370 mp->bd_id = ntohl (bd_id);
11373 /* Use a control ping for synchronization */
11374 M (CONTROL_PING, mp_ping);
11383 api_interface_name_renumber (vat_main_t * vam)
11385 unformat_input_t *line_input = vam->input;
11386 vl_api_interface_name_renumber_t *mp;
11387 u32 sw_if_index = ~0;
11388 u32 new_show_dev_instance = ~0;
11391 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11393 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11396 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11398 else if (unformat (line_input, "new_show_dev_instance %d",
11399 &new_show_dev_instance))
11405 if (sw_if_index == ~0)
11407 errmsg ("missing interface name or sw_if_index");
11411 if (new_show_dev_instance == ~0)
11413 errmsg ("missing new_show_dev_instance");
11417 M (INTERFACE_NAME_RENUMBER, mp);
11419 mp->sw_if_index = ntohl (sw_if_index);
11420 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11428 api_want_ip4_arp_events (vat_main_t * vam)
11430 unformat_input_t *line_input = vam->input;
11431 vl_api_want_ip4_arp_events_t *mp;
11432 ip4_address_t address;
11433 int address_set = 0;
11434 u32 enable_disable = 1;
11437 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11439 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11441 else if (unformat (line_input, "del"))
11442 enable_disable = 0;
11447 if (address_set == 0)
11449 errmsg ("missing addresses");
11453 M (WANT_IP4_ARP_EVENTS, mp);
11454 mp->enable_disable = enable_disable;
11455 mp->pid = getpid ();
11456 mp->address = address.as_u32;
11464 api_want_ip6_nd_events (vat_main_t * vam)
11466 unformat_input_t *line_input = vam->input;
11467 vl_api_want_ip6_nd_events_t *mp;
11468 ip6_address_t address;
11469 int address_set = 0;
11470 u32 enable_disable = 1;
11473 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11475 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11477 else if (unformat (line_input, "del"))
11478 enable_disable = 0;
11483 if (address_set == 0)
11485 errmsg ("missing addresses");
11489 M (WANT_IP6_ND_EVENTS, mp);
11490 mp->enable_disable = enable_disable;
11491 mp->pid = getpid ();
11492 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11500 api_input_acl_set_interface (vat_main_t * vam)
11502 unformat_input_t *i = vam->input;
11503 vl_api_input_acl_set_interface_t *mp;
11505 int sw_if_index_set;
11506 u32 ip4_table_index = ~0;
11507 u32 ip6_table_index = ~0;
11508 u32 l2_table_index = ~0;
11512 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11514 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11515 sw_if_index_set = 1;
11516 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11517 sw_if_index_set = 1;
11518 else if (unformat (i, "del"))
11520 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11522 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11524 else if (unformat (i, "l2-table %d", &l2_table_index))
11528 clib_warning ("parse error '%U'", format_unformat_error, i);
11533 if (sw_if_index_set == 0)
11535 errmsg ("missing interface name or sw_if_index");
11539 M (INPUT_ACL_SET_INTERFACE, mp);
11541 mp->sw_if_index = ntohl (sw_if_index);
11542 mp->ip4_table_index = ntohl (ip4_table_index);
11543 mp->ip6_table_index = ntohl (ip6_table_index);
11544 mp->l2_table_index = ntohl (l2_table_index);
11545 mp->is_add = is_add;
11553 api_ip_address_dump (vat_main_t * vam)
11555 unformat_input_t *i = vam->input;
11556 vl_api_ip_address_dump_t *mp;
11557 vl_api_control_ping_t *mp_ping;
11558 u32 sw_if_index = ~0;
11559 u8 sw_if_index_set = 0;
11564 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11566 if (unformat (i, "sw_if_index %d", &sw_if_index))
11567 sw_if_index_set = 1;
11569 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11570 sw_if_index_set = 1;
11571 else if (unformat (i, "ipv4"))
11573 else if (unformat (i, "ipv6"))
11579 if (ipv4_set && ipv6_set)
11581 errmsg ("ipv4 and ipv6 flags cannot be both set");
11585 if ((!ipv4_set) && (!ipv6_set))
11587 errmsg ("no ipv4 nor ipv6 flag set");
11591 if (sw_if_index_set == 0)
11593 errmsg ("missing interface name or sw_if_index");
11597 vam->current_sw_if_index = sw_if_index;
11598 vam->is_ipv6 = ipv6_set;
11600 M (IP_ADDRESS_DUMP, mp);
11601 mp->sw_if_index = ntohl (sw_if_index);
11602 mp->is_ipv6 = ipv6_set;
11605 /* Use a control ping for synchronization */
11606 M (CONTROL_PING, mp_ping);
11614 api_ip_dump (vat_main_t * vam)
11616 vl_api_ip_dump_t *mp;
11617 vl_api_control_ping_t *mp_ping;
11618 unformat_input_t *in = vam->input;
11625 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11627 if (unformat (in, "ipv4"))
11629 else if (unformat (in, "ipv6"))
11635 if (ipv4_set && ipv6_set)
11637 errmsg ("ipv4 and ipv6 flags cannot be both set");
11641 if ((!ipv4_set) && (!ipv6_set))
11643 errmsg ("no ipv4 nor ipv6 flag set");
11647 is_ipv6 = ipv6_set;
11648 vam->is_ipv6 = is_ipv6;
11650 /* free old data */
11651 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11653 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11655 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11658 mp->is_ipv6 = ipv6_set;
11661 /* Use a control ping for synchronization */
11662 M (CONTROL_PING, mp_ping);
11670 api_ipsec_spd_add_del (vat_main_t * vam)
11672 unformat_input_t *i = vam->input;
11673 vl_api_ipsec_spd_add_del_t *mp;
11678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11680 if (unformat (i, "spd_id %d", &spd_id))
11682 else if (unformat (i, "del"))
11686 clib_warning ("parse error '%U'", format_unformat_error, i);
11692 errmsg ("spd_id must be set");
11696 M (IPSEC_SPD_ADD_DEL, mp);
11698 mp->spd_id = ntohl (spd_id);
11699 mp->is_add = is_add;
11707 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11709 unformat_input_t *i = vam->input;
11710 vl_api_ipsec_interface_add_del_spd_t *mp;
11712 u8 sw_if_index_set = 0;
11713 u32 spd_id = (u32) ~ 0;
11717 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11719 if (unformat (i, "del"))
11721 else if (unformat (i, "spd_id %d", &spd_id))
11724 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11725 sw_if_index_set = 1;
11726 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11727 sw_if_index_set = 1;
11730 clib_warning ("parse error '%U'", format_unformat_error, i);
11736 if (spd_id == (u32) ~ 0)
11738 errmsg ("spd_id must be set");
11742 if (sw_if_index_set == 0)
11744 errmsg ("missing interface name or sw_if_index");
11748 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11750 mp->spd_id = ntohl (spd_id);
11751 mp->sw_if_index = ntohl (sw_if_index);
11752 mp->is_add = is_add;
11760 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11762 unformat_input_t *i = vam->input;
11763 vl_api_ipsec_spd_add_del_entry_t *mp;
11764 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11765 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11767 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11768 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11769 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11770 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11773 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11774 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11775 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11776 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11777 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11778 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11780 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11782 if (unformat (i, "del"))
11784 if (unformat (i, "outbound"))
11786 if (unformat (i, "inbound"))
11788 else if (unformat (i, "spd_id %d", &spd_id))
11790 else if (unformat (i, "sa_id %d", &sa_id))
11792 else if (unformat (i, "priority %d", &priority))
11794 else if (unformat (i, "protocol %d", &protocol))
11796 else if (unformat (i, "lport_start %d", &lport_start))
11798 else if (unformat (i, "lport_stop %d", &lport_stop))
11800 else if (unformat (i, "rport_start %d", &rport_start))
11802 else if (unformat (i, "rport_stop %d", &rport_stop))
11806 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11812 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11819 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11825 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11832 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11838 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11845 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11851 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11857 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11859 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11861 clib_warning ("unsupported action: 'resolve'");
11867 clib_warning ("parse error '%U'", format_unformat_error, i);
11873 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
11875 mp->spd_id = ntohl (spd_id);
11876 mp->priority = ntohl (priority);
11877 mp->is_outbound = is_outbound;
11879 mp->is_ipv6 = is_ipv6;
11880 if (is_ipv6 || is_ip_any)
11882 clib_memcpy (mp->remote_address_start, &raddr6_start,
11883 sizeof (ip6_address_t));
11884 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11885 sizeof (ip6_address_t));
11886 clib_memcpy (mp->local_address_start, &laddr6_start,
11887 sizeof (ip6_address_t));
11888 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11889 sizeof (ip6_address_t));
11893 clib_memcpy (mp->remote_address_start, &raddr4_start,
11894 sizeof (ip4_address_t));
11895 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11896 sizeof (ip4_address_t));
11897 clib_memcpy (mp->local_address_start, &laddr4_start,
11898 sizeof (ip4_address_t));
11899 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11900 sizeof (ip4_address_t));
11902 mp->protocol = (u8) protocol;
11903 mp->local_port_start = ntohs ((u16) lport_start);
11904 mp->local_port_stop = ntohs ((u16) lport_stop);
11905 mp->remote_port_start = ntohs ((u16) rport_start);
11906 mp->remote_port_stop = ntohs ((u16) rport_stop);
11907 mp->policy = (u8) policy;
11908 mp->sa_id = ntohl (sa_id);
11909 mp->is_add = is_add;
11910 mp->is_ip_any = is_ip_any;
11917 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11919 unformat_input_t *i = vam->input;
11920 vl_api_ipsec_sad_add_del_entry_t *mp;
11921 u32 sad_id = 0, spi = 0;
11922 u8 *ck = 0, *ik = 0;
11925 u8 protocol = IPSEC_PROTOCOL_AH;
11926 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11927 u32 crypto_alg = 0, integ_alg = 0;
11928 ip4_address_t tun_src4;
11929 ip4_address_t tun_dst4;
11930 ip6_address_t tun_src6;
11931 ip6_address_t tun_dst6;
11934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11936 if (unformat (i, "del"))
11938 else if (unformat (i, "sad_id %d", &sad_id))
11940 else if (unformat (i, "spi %d", &spi))
11942 else if (unformat (i, "esp"))
11943 protocol = IPSEC_PROTOCOL_ESP;
11944 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11947 is_tunnel_ipv6 = 0;
11949 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11952 is_tunnel_ipv6 = 0;
11954 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11957 is_tunnel_ipv6 = 1;
11959 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11962 is_tunnel_ipv6 = 1;
11966 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11968 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11969 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11971 clib_warning ("unsupported crypto-alg: '%U'",
11972 format_ipsec_crypto_alg, crypto_alg);
11976 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11980 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11982 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11983 integ_alg >= IPSEC_INTEG_N_ALG)
11985 clib_warning ("unsupported integ-alg: '%U'",
11986 format_ipsec_integ_alg, integ_alg);
11990 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11994 clib_warning ("parse error '%U'", format_unformat_error, i);
12000 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12002 mp->sad_id = ntohl (sad_id);
12003 mp->is_add = is_add;
12004 mp->protocol = protocol;
12005 mp->spi = ntohl (spi);
12006 mp->is_tunnel = is_tunnel;
12007 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12008 mp->crypto_algorithm = crypto_alg;
12009 mp->integrity_algorithm = integ_alg;
12010 mp->crypto_key_length = vec_len (ck);
12011 mp->integrity_key_length = vec_len (ik);
12013 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12014 mp->crypto_key_length = sizeof (mp->crypto_key);
12016 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12017 mp->integrity_key_length = sizeof (mp->integrity_key);
12020 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12022 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12026 if (is_tunnel_ipv6)
12028 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12029 sizeof (ip6_address_t));
12030 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12031 sizeof (ip6_address_t));
12035 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12036 sizeof (ip4_address_t));
12037 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12038 sizeof (ip4_address_t));
12048 api_ipsec_sa_set_key (vat_main_t * vam)
12050 unformat_input_t *i = vam->input;
12051 vl_api_ipsec_sa_set_key_t *mp;
12053 u8 *ck = 0, *ik = 0;
12056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12058 if (unformat (i, "sa_id %d", &sa_id))
12060 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12062 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12066 clib_warning ("parse error '%U'", format_unformat_error, i);
12071 M (IPSEC_SA_SET_KEY, mp);
12073 mp->sa_id = ntohl (sa_id);
12074 mp->crypto_key_length = vec_len (ck);
12075 mp->integrity_key_length = vec_len (ik);
12077 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12078 mp->crypto_key_length = sizeof (mp->crypto_key);
12080 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12081 mp->integrity_key_length = sizeof (mp->integrity_key);
12084 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12086 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12094 api_ikev2_profile_add_del (vat_main_t * vam)
12096 unformat_input_t *i = vam->input;
12097 vl_api_ikev2_profile_add_del_t *mp;
12102 const char *valid_chars = "a-zA-Z0-9_";
12104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12106 if (unformat (i, "del"))
12108 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12109 vec_add1 (name, 0);
12112 errmsg ("parse error '%U'", format_unformat_error, i);
12117 if (!vec_len (name))
12119 errmsg ("profile name must be specified");
12123 if (vec_len (name) > 64)
12125 errmsg ("profile name too long");
12129 M (IKEV2_PROFILE_ADD_DEL, mp);
12131 clib_memcpy (mp->name, name, vec_len (name));
12132 mp->is_add = is_add;
12141 api_ikev2_profile_set_auth (vat_main_t * vam)
12143 unformat_input_t *i = vam->input;
12144 vl_api_ikev2_profile_set_auth_t *mp;
12147 u32 auth_method = 0;
12151 const char *valid_chars = "a-zA-Z0-9_";
12153 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12155 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12156 vec_add1 (name, 0);
12157 else if (unformat (i, "auth_method %U",
12158 unformat_ikev2_auth_method, &auth_method))
12160 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12162 else if (unformat (i, "auth_data %v", &data))
12166 errmsg ("parse error '%U'", format_unformat_error, i);
12171 if (!vec_len (name))
12173 errmsg ("profile name must be specified");
12177 if (vec_len (name) > 64)
12179 errmsg ("profile name too long");
12183 if (!vec_len (data))
12185 errmsg ("auth_data must be specified");
12191 errmsg ("auth_method must be specified");
12195 M (IKEV2_PROFILE_SET_AUTH, mp);
12197 mp->is_hex = is_hex;
12198 mp->auth_method = (u8) auth_method;
12199 mp->data_len = vec_len (data);
12200 clib_memcpy (mp->name, name, vec_len (name));
12201 clib_memcpy (mp->data, data, vec_len (data));
12211 api_ikev2_profile_set_id (vat_main_t * vam)
12213 unformat_input_t *i = vam->input;
12214 vl_api_ikev2_profile_set_id_t *mp;
12222 const char *valid_chars = "a-zA-Z0-9_";
12224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12226 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12227 vec_add1 (name, 0);
12228 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12230 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12232 data = vec_new (u8, 4);
12233 clib_memcpy (data, ip4.as_u8, 4);
12235 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12237 else if (unformat (i, "id_data %v", &data))
12239 else if (unformat (i, "local"))
12241 else if (unformat (i, "remote"))
12245 errmsg ("parse error '%U'", format_unformat_error, i);
12250 if (!vec_len (name))
12252 errmsg ("profile name must be specified");
12256 if (vec_len (name) > 64)
12258 errmsg ("profile name too long");
12262 if (!vec_len (data))
12264 errmsg ("id_data must be specified");
12270 errmsg ("id_type must be specified");
12274 M (IKEV2_PROFILE_SET_ID, mp);
12276 mp->is_local = is_local;
12277 mp->id_type = (u8) id_type;
12278 mp->data_len = vec_len (data);
12279 clib_memcpy (mp->name, name, vec_len (name));
12280 clib_memcpy (mp->data, data, vec_len (data));
12290 api_ikev2_profile_set_ts (vat_main_t * vam)
12292 unformat_input_t *i = vam->input;
12293 vl_api_ikev2_profile_set_ts_t *mp;
12296 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12297 ip4_address_t start_addr, end_addr;
12299 const char *valid_chars = "a-zA-Z0-9_";
12302 start_addr.as_u32 = 0;
12303 end_addr.as_u32 = (u32) ~ 0;
12305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12307 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12308 vec_add1 (name, 0);
12309 else if (unformat (i, "protocol %d", &proto))
12311 else if (unformat (i, "start_port %d", &start_port))
12313 else if (unformat (i, "end_port %d", &end_port))
12316 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12318 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12320 else if (unformat (i, "local"))
12322 else if (unformat (i, "remote"))
12326 errmsg ("parse error '%U'", format_unformat_error, i);
12331 if (!vec_len (name))
12333 errmsg ("profile name must be specified");
12337 if (vec_len (name) > 64)
12339 errmsg ("profile name too long");
12343 M (IKEV2_PROFILE_SET_TS, mp);
12345 mp->is_local = is_local;
12346 mp->proto = (u8) proto;
12347 mp->start_port = (u16) start_port;
12348 mp->end_port = (u16) end_port;
12349 mp->start_addr = start_addr.as_u32;
12350 mp->end_addr = end_addr.as_u32;
12351 clib_memcpy (mp->name, name, vec_len (name));
12360 api_ikev2_set_local_key (vat_main_t * vam)
12362 unformat_input_t *i = vam->input;
12363 vl_api_ikev2_set_local_key_t *mp;
12367 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12369 if (unformat (i, "file %v", &file))
12370 vec_add1 (file, 0);
12373 errmsg ("parse error '%U'", format_unformat_error, i);
12378 if (!vec_len (file))
12380 errmsg ("RSA key file must be specified");
12384 if (vec_len (file) > 256)
12386 errmsg ("file name too long");
12390 M (IKEV2_SET_LOCAL_KEY, mp);
12392 clib_memcpy (mp->key_file, file, vec_len (file));
12401 api_ikev2_set_responder (vat_main_t * vam)
12403 unformat_input_t *i = vam->input;
12404 vl_api_ikev2_set_responder_t *mp;
12407 u32 sw_if_index = ~0;
12408 ip4_address_t address;
12410 const char *valid_chars = "a-zA-Z0-9_";
12412 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12415 (i, "%U interface %d address %U", unformat_token, valid_chars,
12416 &name, &sw_if_index, unformat_ip4_address, &address))
12417 vec_add1 (name, 0);
12420 errmsg ("parse error '%U'", format_unformat_error, i);
12425 if (!vec_len (name))
12427 errmsg ("profile name must be specified");
12431 if (vec_len (name) > 64)
12433 errmsg ("profile name too long");
12437 M (IKEV2_SET_RESPONDER, mp);
12439 clib_memcpy (mp->name, name, vec_len (name));
12442 mp->sw_if_index = sw_if_index;
12443 clib_memcpy (mp->address, &address, sizeof (address));
12451 api_ikev2_set_ike_transforms (vat_main_t * vam)
12453 unformat_input_t *i = vam->input;
12454 vl_api_ikev2_set_ike_transforms_t *mp;
12457 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12459 const char *valid_chars = "a-zA-Z0-9_";
12461 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12463 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12464 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12465 vec_add1 (name, 0);
12468 errmsg ("parse error '%U'", format_unformat_error, i);
12473 if (!vec_len (name))
12475 errmsg ("profile name must be specified");
12479 if (vec_len (name) > 64)
12481 errmsg ("profile name too long");
12485 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12487 clib_memcpy (mp->name, name, vec_len (name));
12489 mp->crypto_alg = crypto_alg;
12490 mp->crypto_key_size = crypto_key_size;
12491 mp->integ_alg = integ_alg;
12492 mp->dh_group = dh_group;
12501 api_ikev2_set_esp_transforms (vat_main_t * vam)
12503 unformat_input_t *i = vam->input;
12504 vl_api_ikev2_set_esp_transforms_t *mp;
12507 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12509 const char *valid_chars = "a-zA-Z0-9_";
12511 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12513 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12514 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12515 vec_add1 (name, 0);
12518 errmsg ("parse error '%U'", format_unformat_error, i);
12523 if (!vec_len (name))
12525 errmsg ("profile name must be specified");
12529 if (vec_len (name) > 64)
12531 errmsg ("profile name too long");
12535 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12537 clib_memcpy (mp->name, name, vec_len (name));
12539 mp->crypto_alg = crypto_alg;
12540 mp->crypto_key_size = crypto_key_size;
12541 mp->integ_alg = integ_alg;
12542 mp->dh_group = dh_group;
12550 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12552 unformat_input_t *i = vam->input;
12553 vl_api_ikev2_set_sa_lifetime_t *mp;
12556 u64 lifetime, lifetime_maxdata;
12557 u32 lifetime_jitter, handover;
12559 const char *valid_chars = "a-zA-Z0-9_";
12561 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12563 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12564 &lifetime, &lifetime_jitter, &handover,
12565 &lifetime_maxdata))
12566 vec_add1 (name, 0);
12569 errmsg ("parse error '%U'", format_unformat_error, i);
12574 if (!vec_len (name))
12576 errmsg ("profile name must be specified");
12580 if (vec_len (name) > 64)
12582 errmsg ("profile name too long");
12586 M (IKEV2_SET_SA_LIFETIME, mp);
12588 clib_memcpy (mp->name, name, vec_len (name));
12590 mp->lifetime = lifetime;
12591 mp->lifetime_jitter = lifetime_jitter;
12592 mp->handover = handover;
12593 mp->lifetime_maxdata = lifetime_maxdata;
12601 api_ikev2_initiate_sa_init (vat_main_t * vam)
12603 unformat_input_t *i = vam->input;
12604 vl_api_ikev2_initiate_sa_init_t *mp;
12608 const char *valid_chars = "a-zA-Z0-9_";
12610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12612 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12613 vec_add1 (name, 0);
12616 errmsg ("parse error '%U'", format_unformat_error, i);
12621 if (!vec_len (name))
12623 errmsg ("profile name must be specified");
12627 if (vec_len (name) > 64)
12629 errmsg ("profile name too long");
12633 M (IKEV2_INITIATE_SA_INIT, mp);
12635 clib_memcpy (mp->name, name, vec_len (name));
12644 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12646 unformat_input_t *i = vam->input;
12647 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12652 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12654 if (unformat (i, "%lx", &ispi))
12658 errmsg ("parse error '%U'", format_unformat_error, i);
12663 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12673 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12675 unformat_input_t *i = vam->input;
12676 vl_api_ikev2_initiate_del_child_sa_t *mp;
12681 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12683 if (unformat (i, "%x", &ispi))
12687 errmsg ("parse error '%U'", format_unformat_error, i);
12692 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12702 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12704 unformat_input_t *i = vam->input;
12705 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12710 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12712 if (unformat (i, "%x", &ispi))
12716 errmsg ("parse error '%U'", format_unformat_error, i);
12721 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12734 api_map_add_domain (vat_main_t * vam)
12736 unformat_input_t *i = vam->input;
12737 vl_api_map_add_domain_t *mp;
12739 ip4_address_t ip4_prefix;
12740 ip6_address_t ip6_prefix;
12741 ip6_address_t ip6_src;
12742 u32 num_m_args = 0;
12743 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12744 0, psid_length = 0;
12745 u8 is_translation = 0;
12747 u32 ip6_src_len = 128;
12750 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12752 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12753 &ip4_prefix, &ip4_prefix_len))
12755 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12756 &ip6_prefix, &ip6_prefix_len))
12760 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12763 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12765 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12767 else if (unformat (i, "psid-offset %d", &psid_offset))
12769 else if (unformat (i, "psid-len %d", &psid_length))
12771 else if (unformat (i, "mtu %d", &mtu))
12773 else if (unformat (i, "map-t"))
12774 is_translation = 1;
12777 clib_warning ("parse error '%U'", format_unformat_error, i);
12782 if (num_m_args < 3)
12784 errmsg ("mandatory argument(s) missing");
12788 /* Construct the API message */
12789 M (MAP_ADD_DOMAIN, mp);
12791 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12792 mp->ip4_prefix_len = ip4_prefix_len;
12794 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12795 mp->ip6_prefix_len = ip6_prefix_len;
12797 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12798 mp->ip6_src_prefix_len = ip6_src_len;
12800 mp->ea_bits_len = ea_bits_len;
12801 mp->psid_offset = psid_offset;
12802 mp->psid_length = psid_length;
12803 mp->is_translation = is_translation;
12804 mp->mtu = htons (mtu);
12809 /* Wait for a reply, return good/bad news */
12815 api_map_del_domain (vat_main_t * vam)
12817 unformat_input_t *i = vam->input;
12818 vl_api_map_del_domain_t *mp;
12820 u32 num_m_args = 0;
12824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12826 if (unformat (i, "index %d", &index))
12830 clib_warning ("parse error '%U'", format_unformat_error, i);
12835 if (num_m_args != 1)
12837 errmsg ("mandatory argument(s) missing");
12841 /* Construct the API message */
12842 M (MAP_DEL_DOMAIN, mp);
12844 mp->index = ntohl (index);
12849 /* Wait for a reply, return good/bad news */
12855 api_map_add_del_rule (vat_main_t * vam)
12857 unformat_input_t *i = vam->input;
12858 vl_api_map_add_del_rule_t *mp;
12860 ip6_address_t ip6_dst;
12861 u32 num_m_args = 0, index, psid = 0;
12864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12866 if (unformat (i, "index %d", &index))
12868 else if (unformat (i, "psid %d", &psid))
12870 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12872 else if (unformat (i, "del"))
12878 clib_warning ("parse error '%U'", format_unformat_error, i);
12883 /* Construct the API message */
12884 M (MAP_ADD_DEL_RULE, mp);
12886 mp->index = ntohl (index);
12887 mp->is_add = is_add;
12888 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12889 mp->psid = ntohs (psid);
12894 /* Wait for a reply, return good/bad news */
12900 api_map_domain_dump (vat_main_t * vam)
12902 vl_api_map_domain_dump_t *mp;
12903 vl_api_control_ping_t *mp_ping;
12906 /* Construct the API message */
12907 M (MAP_DOMAIN_DUMP, mp);
12912 /* Use a control ping for synchronization */
12913 M (CONTROL_PING, mp_ping);
12921 api_map_rule_dump (vat_main_t * vam)
12923 unformat_input_t *i = vam->input;
12924 vl_api_map_rule_dump_t *mp;
12925 vl_api_control_ping_t *mp_ping;
12926 u32 domain_index = ~0;
12929 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12931 if (unformat (i, "index %u", &domain_index))
12937 if (domain_index == ~0)
12939 clib_warning ("parse error: domain index expected");
12943 /* Construct the API message */
12944 M (MAP_RULE_DUMP, mp);
12946 mp->domain_index = htonl (domain_index);
12951 /* Use a control ping for synchronization */
12952 M (CONTROL_PING, mp_ping);
12959 static void vl_api_map_add_domain_reply_t_handler
12960 (vl_api_map_add_domain_reply_t * mp)
12962 vat_main_t *vam = &vat_main;
12963 i32 retval = ntohl (mp->retval);
12965 if (vam->async_mode)
12967 vam->async_errors += (retval < 0);
12971 vam->retval = retval;
12972 vam->result_ready = 1;
12976 static void vl_api_map_add_domain_reply_t_handler_json
12977 (vl_api_map_add_domain_reply_t * mp)
12979 vat_main_t *vam = &vat_main;
12980 vat_json_node_t node;
12982 vat_json_init_object (&node);
12983 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12984 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12986 vat_json_print (vam->ofp, &node);
12987 vat_json_free (&node);
12989 vam->retval = ntohl (mp->retval);
12990 vam->result_ready = 1;
12994 api_get_first_msg_id (vat_main_t * vam)
12996 vl_api_get_first_msg_id_t *mp;
12997 unformat_input_t *i = vam->input;
13002 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13004 if (unformat (i, "client %s", &name))
13012 errmsg ("missing client name");
13015 vec_add1 (name, 0);
13017 if (vec_len (name) > 63)
13019 errmsg ("client name too long");
13023 M (GET_FIRST_MSG_ID, mp);
13024 clib_memcpy (mp->name, name, vec_len (name));
13031 api_cop_interface_enable_disable (vat_main_t * vam)
13033 unformat_input_t *line_input = vam->input;
13034 vl_api_cop_interface_enable_disable_t *mp;
13035 u32 sw_if_index = ~0;
13036 u8 enable_disable = 1;
13039 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13041 if (unformat (line_input, "disable"))
13042 enable_disable = 0;
13043 if (unformat (line_input, "enable"))
13044 enable_disable = 1;
13045 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13046 vam, &sw_if_index))
13048 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13054 if (sw_if_index == ~0)
13056 errmsg ("missing interface name or sw_if_index");
13060 /* Construct the API message */
13061 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13062 mp->sw_if_index = ntohl (sw_if_index);
13063 mp->enable_disable = enable_disable;
13067 /* Wait for the reply */
13073 api_cop_whitelist_enable_disable (vat_main_t * vam)
13075 unformat_input_t *line_input = vam->input;
13076 vl_api_cop_whitelist_enable_disable_t *mp;
13077 u32 sw_if_index = ~0;
13078 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13082 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13084 if (unformat (line_input, "ip4"))
13086 else if (unformat (line_input, "ip6"))
13088 else if (unformat (line_input, "default"))
13090 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13091 vam, &sw_if_index))
13093 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13095 else if (unformat (line_input, "fib-id %d", &fib_id))
13101 if (sw_if_index == ~0)
13103 errmsg ("missing interface name or sw_if_index");
13107 /* Construct the API message */
13108 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13109 mp->sw_if_index = ntohl (sw_if_index);
13110 mp->fib_id = ntohl (fib_id);
13113 mp->default_cop = default_cop;
13117 /* Wait for the reply */
13123 api_get_node_graph (vat_main_t * vam)
13125 vl_api_get_node_graph_t *mp;
13128 M (GET_NODE_GRAPH, mp);
13132 /* Wait for the reply */
13138 /** Used for parsing LISP eids */
13139 typedef CLIB_PACKED(struct{
13140 u8 addr[16]; /**< eid address */
13141 u32 len; /**< prefix length if IP */
13142 u8 type; /**< type of eid */
13147 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13149 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13151 memset (a, 0, sizeof (a[0]));
13153 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13155 a->type = 0; /* ipv4 type */
13157 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13159 a->type = 1; /* ipv6 type */
13161 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13163 a->type = 2; /* mac type */
13170 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13179 lisp_eid_size_vat (u8 type)
13194 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13196 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13200 api_one_add_del_locator_set (vat_main_t * vam)
13202 unformat_input_t *input = vam->input;
13203 vl_api_one_add_del_locator_set_t *mp;
13205 u8 *locator_set_name = NULL;
13206 u8 locator_set_name_set = 0;
13207 vl_api_local_locator_t locator, *locators = 0;
13208 u32 sw_if_index, priority, weight;
13212 /* Parse args required to build the message */
13213 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13215 if (unformat (input, "del"))
13219 else if (unformat (input, "locator-set %s", &locator_set_name))
13221 locator_set_name_set = 1;
13223 else if (unformat (input, "sw_if_index %u p %u w %u",
13224 &sw_if_index, &priority, &weight))
13226 locator.sw_if_index = htonl (sw_if_index);
13227 locator.priority = priority;
13228 locator.weight = weight;
13229 vec_add1 (locators, locator);
13233 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13234 &sw_if_index, &priority, &weight))
13236 locator.sw_if_index = htonl (sw_if_index);
13237 locator.priority = priority;
13238 locator.weight = weight;
13239 vec_add1 (locators, locator);
13245 if (locator_set_name_set == 0)
13247 errmsg ("missing locator-set name");
13248 vec_free (locators);
13252 if (vec_len (locator_set_name) > 64)
13254 errmsg ("locator-set name too long");
13255 vec_free (locator_set_name);
13256 vec_free (locators);
13259 vec_add1 (locator_set_name, 0);
13261 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13263 /* Construct the API message */
13264 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13266 mp->is_add = is_add;
13267 clib_memcpy (mp->locator_set_name, locator_set_name,
13268 vec_len (locator_set_name));
13269 vec_free (locator_set_name);
13271 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13273 clib_memcpy (mp->locators, locators, data_len);
13274 vec_free (locators);
13279 /* Wait for a reply... */
13284 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13287 api_one_add_del_locator (vat_main_t * vam)
13289 unformat_input_t *input = vam->input;
13290 vl_api_one_add_del_locator_t *mp;
13291 u32 tmp_if_index = ~0;
13292 u32 sw_if_index = ~0;
13293 u8 sw_if_index_set = 0;
13294 u8 sw_if_index_if_name_set = 0;
13296 u8 priority_set = 0;
13300 u8 *locator_set_name = NULL;
13301 u8 locator_set_name_set = 0;
13304 /* Parse args required to build the message */
13305 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13307 if (unformat (input, "del"))
13311 else if (unformat (input, "locator-set %s", &locator_set_name))
13313 locator_set_name_set = 1;
13315 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13318 sw_if_index_if_name_set = 1;
13319 sw_if_index = tmp_if_index;
13321 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13323 sw_if_index_set = 1;
13324 sw_if_index = tmp_if_index;
13326 else if (unformat (input, "p %d", &priority))
13330 else if (unformat (input, "w %d", &weight))
13338 if (locator_set_name_set == 0)
13340 errmsg ("missing locator-set name");
13344 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13346 errmsg ("missing sw_if_index");
13347 vec_free (locator_set_name);
13351 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13353 errmsg ("cannot use both params interface name and sw_if_index");
13354 vec_free (locator_set_name);
13358 if (priority_set == 0)
13360 errmsg ("missing locator-set priority");
13361 vec_free (locator_set_name);
13365 if (weight_set == 0)
13367 errmsg ("missing locator-set weight");
13368 vec_free (locator_set_name);
13372 if (vec_len (locator_set_name) > 64)
13374 errmsg ("locator-set name too long");
13375 vec_free (locator_set_name);
13378 vec_add1 (locator_set_name, 0);
13380 /* Construct the API message */
13381 M (ONE_ADD_DEL_LOCATOR, mp);
13383 mp->is_add = is_add;
13384 mp->sw_if_index = ntohl (sw_if_index);
13385 mp->priority = priority;
13386 mp->weight = weight;
13387 clib_memcpy (mp->locator_set_name, locator_set_name,
13388 vec_len (locator_set_name));
13389 vec_free (locator_set_name);
13394 /* Wait for a reply... */
13399 #define api_lisp_add_del_locator api_one_add_del_locator
13402 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13404 u32 *key_id = va_arg (*args, u32 *);
13407 if (unformat (input, "%s", &s))
13409 if (!strcmp ((char *) s, "sha1"))
13410 key_id[0] = HMAC_SHA_1_96;
13411 else if (!strcmp ((char *) s, "sha256"))
13412 key_id[0] = HMAC_SHA_256_128;
13415 clib_warning ("invalid key_id: '%s'", s);
13416 key_id[0] = HMAC_NO_KEY;
13427 api_one_add_del_local_eid (vat_main_t * vam)
13429 unformat_input_t *input = vam->input;
13430 vl_api_one_add_del_local_eid_t *mp;
13433 lisp_eid_vat_t _eid, *eid = &_eid;
13434 u8 *locator_set_name = 0;
13435 u8 locator_set_name_set = 0;
13441 /* Parse args required to build the message */
13442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13444 if (unformat (input, "del"))
13448 else if (unformat (input, "vni %d", &vni))
13452 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13456 else if (unformat (input, "locator-set %s", &locator_set_name))
13458 locator_set_name_set = 1;
13460 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13462 else if (unformat (input, "secret-key %_%v%_", &key))
13468 if (locator_set_name_set == 0)
13470 errmsg ("missing locator-set name");
13476 errmsg ("EID address not set!");
13477 vec_free (locator_set_name);
13481 if (key && (0 == key_id))
13483 errmsg ("invalid key_id!");
13487 if (vec_len (key) > 64)
13489 errmsg ("key too long");
13494 if (vec_len (locator_set_name) > 64)
13496 errmsg ("locator-set name too long");
13497 vec_free (locator_set_name);
13500 vec_add1 (locator_set_name, 0);
13502 /* Construct the API message */
13503 M (ONE_ADD_DEL_LOCAL_EID, mp);
13505 mp->is_add = is_add;
13506 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13507 mp->eid_type = eid->type;
13508 mp->prefix_len = eid->len;
13509 mp->vni = clib_host_to_net_u32 (vni);
13510 mp->key_id = clib_host_to_net_u16 (key_id);
13511 clib_memcpy (mp->locator_set_name, locator_set_name,
13512 vec_len (locator_set_name));
13513 clib_memcpy (mp->key, key, vec_len (key));
13515 vec_free (locator_set_name);
13521 /* Wait for a reply... */
13526 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13529 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13531 u32 dp_table = 0, vni = 0;;
13532 unformat_input_t *input = vam->input;
13533 vl_api_gpe_add_del_fwd_entry_t *mp;
13535 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13536 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13537 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13538 u32 action = ~0, w;
13539 ip4_address_t rmt_rloc4, lcl_rloc4;
13540 ip6_address_t rmt_rloc6, lcl_rloc6;
13541 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13544 memset (&rloc, 0, sizeof (rloc));
13546 /* Parse args required to build the message */
13547 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13549 if (unformat (input, "del"))
13551 else if (unformat (input, "add"))
13553 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13557 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13561 else if (unformat (input, "vrf %d", &dp_table))
13563 else if (unformat (input, "bd %d", &dp_table))
13565 else if (unformat (input, "vni %d", &vni))
13567 else if (unformat (input, "w %d", &w))
13571 errmsg ("No RLOC configured for setting priority/weight!");
13574 curr_rloc->weight = w;
13576 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13577 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13581 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13583 vec_add1 (lcl_locs, rloc);
13585 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13586 vec_add1 (rmt_locs, rloc);
13587 /* weight saved in rmt loc */
13588 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13590 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13591 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13594 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13596 vec_add1 (lcl_locs, rloc);
13598 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13599 vec_add1 (rmt_locs, rloc);
13600 /* weight saved in rmt loc */
13601 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13603 else if (unformat (input, "action %d", &action))
13609 clib_warning ("parse error '%U'", format_unformat_error, input);
13616 errmsg ("remote eid addresses not set");
13620 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13622 errmsg ("eid types don't match");
13626 if (0 == rmt_locs && (u32) ~ 0 == action)
13628 errmsg ("action not set for negative mapping");
13632 /* Construct the API message */
13633 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13634 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13636 mp->is_add = is_add;
13637 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13638 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13639 mp->eid_type = rmt_eid->type;
13640 mp->dp_table = clib_host_to_net_u32 (dp_table);
13641 mp->vni = clib_host_to_net_u32 (vni);
13642 mp->rmt_len = rmt_eid->len;
13643 mp->lcl_len = lcl_eid->len;
13644 mp->action = action;
13646 if (0 != rmt_locs && 0 != lcl_locs)
13648 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13649 clib_memcpy (mp->locs, lcl_locs,
13650 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13652 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13653 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13654 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13656 vec_free (lcl_locs);
13657 vec_free (rmt_locs);
13662 /* Wait for a reply... */
13668 api_one_add_del_map_server (vat_main_t * vam)
13670 unformat_input_t *input = vam->input;
13671 vl_api_one_add_del_map_server_t *mp;
13675 ip4_address_t ipv4;
13676 ip6_address_t ipv6;
13679 /* Parse args required to build the message */
13680 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13682 if (unformat (input, "del"))
13686 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13690 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13698 if (ipv4_set && ipv6_set)
13700 errmsg ("both eid v4 and v6 addresses set");
13704 if (!ipv4_set && !ipv6_set)
13706 errmsg ("eid addresses not set");
13710 /* Construct the API message */
13711 M (ONE_ADD_DEL_MAP_SERVER, mp);
13713 mp->is_add = is_add;
13717 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13722 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13728 /* Wait for a reply... */
13733 #define api_lisp_add_del_map_server api_one_add_del_map_server
13736 api_one_add_del_map_resolver (vat_main_t * vam)
13738 unformat_input_t *input = vam->input;
13739 vl_api_one_add_del_map_resolver_t *mp;
13743 ip4_address_t ipv4;
13744 ip6_address_t ipv6;
13747 /* Parse args required to build the message */
13748 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13750 if (unformat (input, "del"))
13754 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13758 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13766 if (ipv4_set && ipv6_set)
13768 errmsg ("both eid v4 and v6 addresses set");
13772 if (!ipv4_set && !ipv6_set)
13774 errmsg ("eid addresses not set");
13778 /* Construct the API message */
13779 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13781 mp->is_add = is_add;
13785 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13790 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13796 /* Wait for a reply... */
13801 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
13804 api_lisp_gpe_enable_disable (vat_main_t * vam)
13806 unformat_input_t *input = vam->input;
13807 vl_api_gpe_enable_disable_t *mp;
13812 /* Parse args required to build the message */
13813 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13815 if (unformat (input, "enable"))
13820 else if (unformat (input, "disable"))
13831 errmsg ("Value not set");
13835 /* Construct the API message */
13836 M (GPE_ENABLE_DISABLE, mp);
13843 /* Wait for a reply... */
13849 api_one_rloc_probe_enable_disable (vat_main_t * vam)
13851 unformat_input_t *input = vam->input;
13852 vl_api_one_rloc_probe_enable_disable_t *mp;
13857 /* Parse args required to build the message */
13858 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13860 if (unformat (input, "enable"))
13865 else if (unformat (input, "disable"))
13873 errmsg ("Value not set");
13877 /* Construct the API message */
13878 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
13880 mp->is_enabled = is_en;
13885 /* Wait for a reply... */
13890 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
13893 api_one_map_register_enable_disable (vat_main_t * vam)
13895 unformat_input_t *input = vam->input;
13896 vl_api_one_map_register_enable_disable_t *mp;
13901 /* Parse args required to build the message */
13902 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13904 if (unformat (input, "enable"))
13909 else if (unformat (input, "disable"))
13917 errmsg ("Value not set");
13921 /* Construct the API message */
13922 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
13924 mp->is_enabled = is_en;
13929 /* Wait for a reply... */
13934 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
13937 api_one_enable_disable (vat_main_t * vam)
13939 unformat_input_t *input = vam->input;
13940 vl_api_one_enable_disable_t *mp;
13945 /* Parse args required to build the message */
13946 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13948 if (unformat (input, "enable"))
13953 else if (unformat (input, "disable"))
13963 errmsg ("Value not set");
13967 /* Construct the API message */
13968 M (ONE_ENABLE_DISABLE, mp);
13975 /* Wait for a reply... */
13980 #define api_lisp_enable_disable api_one_enable_disable
13983 api_show_one_map_register_state (vat_main_t * vam)
13985 vl_api_show_one_map_register_state_t *mp;
13988 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
13993 /* wait for reply */
13998 #define api_show_lisp_map_register_state api_show_one_map_register_state
14001 api_show_one_rloc_probe_state (vat_main_t * vam)
14003 vl_api_show_one_rloc_probe_state_t *mp;
14006 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14011 /* wait for reply */
14016 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14019 api_show_one_map_request_mode (vat_main_t * vam)
14021 vl_api_show_one_map_request_mode_t *mp;
14024 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14029 /* wait for reply */
14034 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14037 api_one_map_request_mode (vat_main_t * vam)
14039 unformat_input_t *input = vam->input;
14040 vl_api_one_map_request_mode_t *mp;
14044 /* Parse args required to build the message */
14045 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14047 if (unformat (input, "dst-only"))
14049 else if (unformat (input, "src-dst"))
14053 errmsg ("parse error '%U'", format_unformat_error, input);
14058 M (ONE_MAP_REQUEST_MODE, mp);
14065 /* wait for reply */
14070 #define api_lisp_map_request_mode api_one_map_request_mode
14073 * Enable/disable ONE proxy ITR.
14075 * @param vam vpp API test context
14076 * @return return code
14079 api_one_pitr_set_locator_set (vat_main_t * vam)
14081 u8 ls_name_set = 0;
14082 unformat_input_t *input = vam->input;
14083 vl_api_one_pitr_set_locator_set_t *mp;
14088 /* Parse args required to build the message */
14089 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14091 if (unformat (input, "del"))
14093 else if (unformat (input, "locator-set %s", &ls_name))
14097 errmsg ("parse error '%U'", format_unformat_error, input);
14104 errmsg ("locator-set name not set!");
14108 M (ONE_PITR_SET_LOCATOR_SET, mp);
14110 mp->is_add = is_add;
14111 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14112 vec_free (ls_name);
14117 /* wait for reply */
14122 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14125 api_show_one_pitr (vat_main_t * vam)
14127 vl_api_show_one_pitr_t *mp;
14130 if (!vam->json_output)
14132 print (vam->ofp, "%=20s", "lisp status:");
14135 M (SHOW_ONE_PITR, mp);
14139 /* Wait for a reply... */
14144 #define api_show_lisp_pitr api_show_one_pitr
14147 * Add/delete mapping between vni and vrf
14150 api_one_eid_table_add_del_map (vat_main_t * vam)
14152 unformat_input_t *input = vam->input;
14153 vl_api_one_eid_table_add_del_map_t *mp;
14154 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14155 u32 vni, vrf, bd_index;
14158 /* Parse args required to build the message */
14159 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14161 if (unformat (input, "del"))
14163 else if (unformat (input, "vrf %d", &vrf))
14165 else if (unformat (input, "bd_index %d", &bd_index))
14167 else if (unformat (input, "vni %d", &vni))
14173 if (!vni_set || (!vrf_set && !bd_index_set))
14175 errmsg ("missing arguments!");
14179 if (vrf_set && bd_index_set)
14181 errmsg ("error: both vrf and bd entered!");
14185 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14187 mp->is_add = is_add;
14188 mp->vni = htonl (vni);
14189 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14190 mp->is_l2 = bd_index_set;
14195 /* wait for reply */
14200 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14203 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14205 u32 *action = va_arg (*args, u32 *);
14208 if (unformat (input, "%s", &s))
14210 if (!strcmp ((char *) s, "no-action"))
14212 else if (!strcmp ((char *) s, "natively-forward"))
14214 else if (!strcmp ((char *) s, "send-map-request"))
14216 else if (!strcmp ((char *) s, "drop"))
14220 clib_warning ("invalid action: '%s'", s);
14232 * Add/del remote mapping to/from ONE control plane
14234 * @param vam vpp API test context
14235 * @return return code
14238 api_one_add_del_remote_mapping (vat_main_t * vam)
14240 unformat_input_t *input = vam->input;
14241 vl_api_one_add_del_remote_mapping_t *mp;
14243 lisp_eid_vat_t _eid, *eid = &_eid;
14244 lisp_eid_vat_t _seid, *seid = &_seid;
14245 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14246 u32 action = ~0, p, w, data_len;
14247 ip4_address_t rloc4;
14248 ip6_address_t rloc6;
14249 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14252 memset (&rloc, 0, sizeof (rloc));
14254 /* Parse args required to build the message */
14255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14257 if (unformat (input, "del-all"))
14261 else if (unformat (input, "del"))
14265 else if (unformat (input, "add"))
14269 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14273 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14277 else if (unformat (input, "vni %d", &vni))
14281 else if (unformat (input, "p %d w %d", &p, &w))
14285 errmsg ("No RLOC configured for setting priority/weight!");
14288 curr_rloc->priority = p;
14289 curr_rloc->weight = w;
14291 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14294 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14295 vec_add1 (rlocs, rloc);
14296 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14298 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14301 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14302 vec_add1 (rlocs, rloc);
14303 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14305 else if (unformat (input, "action %U",
14306 unformat_negative_mapping_action, &action))
14312 clib_warning ("parse error '%U'", format_unformat_error, input);
14319 errmsg ("missing params!");
14323 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14325 errmsg ("no action set for negative map-reply!");
14329 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14331 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14332 mp->is_add = is_add;
14333 mp->vni = htonl (vni);
14334 mp->action = (u8) action;
14335 mp->is_src_dst = seid_set;
14336 mp->eid_len = eid->len;
14337 mp->seid_len = seid->len;
14338 mp->del_all = del_all;
14339 mp->eid_type = eid->type;
14340 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14341 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14343 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14344 clib_memcpy (mp->rlocs, rlocs, data_len);
14350 /* Wait for a reply... */
14355 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14358 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14359 * forwarding entries in data-plane accordingly.
14361 * @param vam vpp API test context
14362 * @return return code
14365 api_one_add_del_adjacency (vat_main_t * vam)
14367 unformat_input_t *input = vam->input;
14368 vl_api_one_add_del_adjacency_t *mp;
14370 ip4_address_t leid4, reid4;
14371 ip6_address_t leid6, reid6;
14372 u8 reid_mac[6] = { 0 };
14373 u8 leid_mac[6] = { 0 };
14374 u8 reid_type, leid_type;
14375 u32 leid_len = 0, reid_len = 0, len;
14379 leid_type = reid_type = (u8) ~ 0;
14381 /* Parse args required to build the message */
14382 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14384 if (unformat (input, "del"))
14388 else if (unformat (input, "add"))
14392 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14395 reid_type = 0; /* ipv4 */
14398 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14401 reid_type = 1; /* ipv6 */
14404 else if (unformat (input, "reid %U", unformat_ethernet_address,
14407 reid_type = 2; /* mac */
14409 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14412 leid_type = 0; /* ipv4 */
14415 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14418 leid_type = 1; /* ipv6 */
14421 else if (unformat (input, "leid %U", unformat_ethernet_address,
14424 leid_type = 2; /* mac */
14426 else if (unformat (input, "vni %d", &vni))
14432 errmsg ("parse error '%U'", format_unformat_error, input);
14437 if ((u8) ~ 0 == reid_type)
14439 errmsg ("missing params!");
14443 if (leid_type != reid_type)
14445 errmsg ("remote and local EIDs are of different types!");
14449 M (ONE_ADD_DEL_ADJACENCY, mp);
14450 mp->is_add = is_add;
14451 mp->vni = htonl (vni);
14452 mp->leid_len = leid_len;
14453 mp->reid_len = reid_len;
14454 mp->eid_type = reid_type;
14456 switch (mp->eid_type)
14459 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14460 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14463 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14464 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14467 clib_memcpy (mp->leid, leid_mac, 6);
14468 clib_memcpy (mp->reid, reid_mac, 6);
14471 errmsg ("unknown EID type %d!", mp->eid_type);
14478 /* Wait for a reply... */
14483 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14486 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14488 u32 *mode = va_arg (*args, u32 *);
14490 if (unformat (input, "lisp"))
14492 else if (unformat (input, "vxlan"))
14501 api_gpe_get_encap_mode (vat_main_t * vam)
14503 vl_api_gpe_get_encap_mode_t *mp;
14506 /* Construct the API message */
14507 M (GPE_GET_ENCAP_MODE, mp);
14512 /* Wait for a reply... */
14518 api_gpe_set_encap_mode (vat_main_t * vam)
14520 unformat_input_t *input = vam->input;
14521 vl_api_gpe_set_encap_mode_t *mp;
14525 /* Parse args required to build the message */
14526 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14528 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14534 /* Construct the API message */
14535 M (GPE_SET_ENCAP_MODE, mp);
14542 /* Wait for a reply... */
14548 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14550 unformat_input_t *input = vam->input;
14551 vl_api_gpe_add_del_iface_t *mp;
14552 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14553 u32 dp_table = 0, vni = 0;
14556 /* Parse args required to build the message */
14557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14559 if (unformat (input, "up"))
14564 else if (unformat (input, "down"))
14569 else if (unformat (input, "table_id %d", &dp_table))
14573 else if (unformat (input, "bd_id %d", &dp_table))
14578 else if (unformat (input, "vni %d", &vni))
14586 if (action_set == 0)
14588 errmsg ("Action not set");
14591 if (dp_table_set == 0 || vni_set == 0)
14593 errmsg ("vni and dp_table must be set");
14597 /* Construct the API message */
14598 M (GPE_ADD_DEL_IFACE, mp);
14600 mp->is_add = is_add;
14601 mp->dp_table = dp_table;
14608 /* Wait for a reply... */
14614 * Add/del map request itr rlocs from ONE control plane and updates
14616 * @param vam vpp API test context
14617 * @return return code
14620 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14622 unformat_input_t *input = vam->input;
14623 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14624 u8 *locator_set_name = 0;
14625 u8 locator_set_name_set = 0;
14629 /* Parse args required to build the message */
14630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14632 if (unformat (input, "del"))
14636 else if (unformat (input, "%_%v%_", &locator_set_name))
14638 locator_set_name_set = 1;
14642 clib_warning ("parse error '%U'", format_unformat_error, input);
14647 if (is_add && !locator_set_name_set)
14649 errmsg ("itr-rloc is not set!");
14653 if (is_add && vec_len (locator_set_name) > 64)
14655 errmsg ("itr-rloc locator-set name too long");
14656 vec_free (locator_set_name);
14660 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14661 mp->is_add = is_add;
14664 clib_memcpy (mp->locator_set_name, locator_set_name,
14665 vec_len (locator_set_name));
14669 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14671 vec_free (locator_set_name);
14676 /* Wait for a reply... */
14681 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14684 api_one_locator_dump (vat_main_t * vam)
14686 unformat_input_t *input = vam->input;
14687 vl_api_one_locator_dump_t *mp;
14688 vl_api_control_ping_t *mp_ping;
14689 u8 is_index_set = 0, is_name_set = 0;
14694 /* Parse args required to build the message */
14695 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14697 if (unformat (input, "ls_name %_%v%_", &ls_name))
14701 else if (unformat (input, "ls_index %d", &ls_index))
14707 errmsg ("parse error '%U'", format_unformat_error, input);
14712 if (!is_index_set && !is_name_set)
14714 errmsg ("error: expected one of index or name!");
14718 if (is_index_set && is_name_set)
14720 errmsg ("error: only one param expected!");
14724 if (vec_len (ls_name) > 62)
14726 errmsg ("error: locator set name too long!");
14730 if (!vam->json_output)
14732 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14735 M (ONE_LOCATOR_DUMP, mp);
14736 mp->is_index_set = is_index_set;
14739 mp->ls_index = clib_host_to_net_u32 (ls_index);
14742 vec_add1 (ls_name, 0);
14743 strncpy ((char *) mp->ls_name, (char *) ls_name,
14744 sizeof (mp->ls_name) - 1);
14750 /* Use a control ping for synchronization */
14751 M (CONTROL_PING, mp_ping);
14754 /* Wait for a reply... */
14759 #define api_lisp_locator_dump api_one_locator_dump
14762 api_one_locator_set_dump (vat_main_t * vam)
14764 vl_api_one_locator_set_dump_t *mp;
14765 vl_api_control_ping_t *mp_ping;
14766 unformat_input_t *input = vam->input;
14770 /* Parse args required to build the message */
14771 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14773 if (unformat (input, "local"))
14777 else if (unformat (input, "remote"))
14783 errmsg ("parse error '%U'", format_unformat_error, input);
14788 if (!vam->json_output)
14790 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14793 M (ONE_LOCATOR_SET_DUMP, mp);
14795 mp->filter = filter;
14800 /* Use a control ping for synchronization */
14801 M (CONTROL_PING, mp_ping);
14804 /* Wait for a reply... */
14809 #define api_lisp_locator_set_dump api_one_locator_set_dump
14812 api_one_eid_table_map_dump (vat_main_t * vam)
14816 unformat_input_t *input = vam->input;
14817 vl_api_one_eid_table_map_dump_t *mp;
14818 vl_api_control_ping_t *mp_ping;
14821 /* Parse args required to build the message */
14822 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14824 if (unformat (input, "l2"))
14829 else if (unformat (input, "l3"))
14836 errmsg ("parse error '%U'", format_unformat_error, input);
14843 errmsg ("expected one of 'l2' or 'l3' parameter!");
14847 if (!vam->json_output)
14849 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14852 M (ONE_EID_TABLE_MAP_DUMP, mp);
14858 /* Use a control ping for synchronization */
14859 M (CONTROL_PING, mp_ping);
14862 /* Wait for a reply... */
14867 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
14870 api_one_eid_table_vni_dump (vat_main_t * vam)
14872 vl_api_one_eid_table_vni_dump_t *mp;
14873 vl_api_control_ping_t *mp_ping;
14876 if (!vam->json_output)
14878 print (vam->ofp, "VNI");
14881 M (ONE_EID_TABLE_VNI_DUMP, mp);
14886 /* Use a control ping for synchronization */
14887 M (CONTROL_PING, mp_ping);
14890 /* Wait for a reply... */
14895 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
14898 api_one_eid_table_dump (vat_main_t * vam)
14900 unformat_input_t *i = vam->input;
14901 vl_api_one_eid_table_dump_t *mp;
14902 vl_api_control_ping_t *mp_ping;
14903 struct in_addr ip4;
14904 struct in6_addr ip6;
14906 u8 eid_type = ~0, eid_set = 0;
14907 u32 prefix_length = ~0, t, vni = 0;
14911 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14913 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14919 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14925 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14930 else if (unformat (i, "vni %d", &t))
14934 else if (unformat (i, "local"))
14938 else if (unformat (i, "remote"))
14944 errmsg ("parse error '%U'", format_unformat_error, i);
14949 if (!vam->json_output)
14951 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14952 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14955 M (ONE_EID_TABLE_DUMP, mp);
14957 mp->filter = filter;
14961 mp->vni = htonl (vni);
14962 mp->eid_type = eid_type;
14966 mp->prefix_length = prefix_length;
14967 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14970 mp->prefix_length = prefix_length;
14971 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14974 clib_memcpy (mp->eid, mac, sizeof (mac));
14977 errmsg ("unknown EID type %d!", eid_type);
14985 /* Use a control ping for synchronization */
14986 M (CONTROL_PING, mp_ping);
14989 /* Wait for a reply... */
14994 #define api_lisp_eid_table_dump api_one_eid_table_dump
14997 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
14999 unformat_input_t *i = vam->input;
15000 vl_api_gpe_fwd_entries_get_t *mp;
15005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15007 if (unformat (i, "vni %d", &vni))
15013 errmsg ("parse error '%U'", format_unformat_error, i);
15020 errmsg ("vni not set!");
15024 if (!vam->json_output)
15026 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15030 M (GPE_FWD_ENTRIES_GET, mp);
15031 mp->vni = clib_host_to_net_u32 (vni);
15036 /* Wait for a reply... */
15041 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15042 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15043 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15044 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15047 api_one_adjacencies_get (vat_main_t * vam)
15049 unformat_input_t *i = vam->input;
15050 vl_api_one_adjacencies_get_t *mp;
15055 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15057 if (unformat (i, "vni %d", &vni))
15063 errmsg ("parse error '%U'", format_unformat_error, i);
15070 errmsg ("vni not set!");
15074 if (!vam->json_output)
15076 print (vam->ofp, "%s %40s", "leid", "reid");
15079 M (ONE_ADJACENCIES_GET, mp);
15080 mp->vni = clib_host_to_net_u32 (vni);
15085 /* Wait for a reply... */
15090 #define api_lisp_adjacencies_get api_one_adjacencies_get
15093 api_one_map_server_dump (vat_main_t * vam)
15095 vl_api_one_map_server_dump_t *mp;
15096 vl_api_control_ping_t *mp_ping;
15099 if (!vam->json_output)
15101 print (vam->ofp, "%=20s", "Map server");
15104 M (ONE_MAP_SERVER_DUMP, mp);
15108 /* Use a control ping for synchronization */
15109 M (CONTROL_PING, mp_ping);
15112 /* Wait for a reply... */
15117 #define api_lisp_map_server_dump api_one_map_server_dump
15120 api_one_map_resolver_dump (vat_main_t * vam)
15122 vl_api_one_map_resolver_dump_t *mp;
15123 vl_api_control_ping_t *mp_ping;
15126 if (!vam->json_output)
15128 print (vam->ofp, "%=20s", "Map resolver");
15131 M (ONE_MAP_RESOLVER_DUMP, mp);
15135 /* Use a control ping for synchronization */
15136 M (CONTROL_PING, mp_ping);
15139 /* Wait for a reply... */
15144 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15147 api_show_one_status (vat_main_t * vam)
15149 vl_api_show_one_status_t *mp;
15152 if (!vam->json_output)
15154 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15157 M (SHOW_ONE_STATUS, mp);
15160 /* Wait for a reply... */
15165 #define api_show_lisp_status api_show_one_status
15168 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15170 vl_api_gpe_fwd_entry_path_dump_t *mp;
15171 vl_api_control_ping_t *mp_ping;
15172 unformat_input_t *i = vam->input;
15173 u32 fwd_entry_index = ~0;
15176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15178 if (unformat (i, "index %d", &fwd_entry_index))
15184 if (~0 == fwd_entry_index)
15186 errmsg ("no index specified!");
15190 if (!vam->json_output)
15192 print (vam->ofp, "first line");
15195 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15199 /* Use a control ping for synchronization */
15200 M (CONTROL_PING, mp_ping);
15203 /* Wait for a reply... */
15209 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15211 vl_api_one_get_map_request_itr_rlocs_t *mp;
15214 if (!vam->json_output)
15216 print (vam->ofp, "%=20s", "itr-rlocs:");
15219 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15222 /* Wait for a reply... */
15227 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15230 api_af_packet_create (vat_main_t * vam)
15232 unformat_input_t *i = vam->input;
15233 vl_api_af_packet_create_t *mp;
15234 u8 *host_if_name = 0;
15236 u8 random_hw_addr = 1;
15239 memset (hw_addr, 0, sizeof (hw_addr));
15241 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15243 if (unformat (i, "name %s", &host_if_name))
15244 vec_add1 (host_if_name, 0);
15245 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15246 random_hw_addr = 0;
15251 if (!vec_len (host_if_name))
15253 errmsg ("host-interface name must be specified");
15257 if (vec_len (host_if_name) > 64)
15259 errmsg ("host-interface name too long");
15263 M (AF_PACKET_CREATE, mp);
15265 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15266 clib_memcpy (mp->hw_addr, hw_addr, 6);
15267 mp->use_random_hw_addr = random_hw_addr;
15268 vec_free (host_if_name);
15276 fprintf (vam->ofp ? vam->ofp : stderr,
15277 " new sw_if_index = %d\n", vam->sw_if_index);
15284 api_af_packet_delete (vat_main_t * vam)
15286 unformat_input_t *i = vam->input;
15287 vl_api_af_packet_delete_t *mp;
15288 u8 *host_if_name = 0;
15291 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15293 if (unformat (i, "name %s", &host_if_name))
15294 vec_add1 (host_if_name, 0);
15299 if (!vec_len (host_if_name))
15301 errmsg ("host-interface name must be specified");
15305 if (vec_len (host_if_name) > 64)
15307 errmsg ("host-interface name too long");
15311 M (AF_PACKET_DELETE, mp);
15313 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15314 vec_free (host_if_name);
15322 api_policer_add_del (vat_main_t * vam)
15324 unformat_input_t *i = vam->input;
15325 vl_api_policer_add_del_t *mp;
15335 u8 color_aware = 0;
15336 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15339 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15340 conform_action.dscp = 0;
15341 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15342 exceed_action.dscp = 0;
15343 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15344 violate_action.dscp = 0;
15346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15348 if (unformat (i, "del"))
15350 else if (unformat (i, "name %s", &name))
15351 vec_add1 (name, 0);
15352 else if (unformat (i, "cir %u", &cir))
15354 else if (unformat (i, "eir %u", &eir))
15356 else if (unformat (i, "cb %u", &cb))
15358 else if (unformat (i, "eb %u", &eb))
15360 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15363 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15366 else if (unformat (i, "type %U", unformat_policer_type, &type))
15368 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15371 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15374 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15377 else if (unformat (i, "color-aware"))
15383 if (!vec_len (name))
15385 errmsg ("policer name must be specified");
15389 if (vec_len (name) > 64)
15391 errmsg ("policer name too long");
15395 M (POLICER_ADD_DEL, mp);
15397 clib_memcpy (mp->name, name, vec_len (name));
15399 mp->is_add = is_add;
15404 mp->rate_type = rate_type;
15405 mp->round_type = round_type;
15407 mp->conform_action_type = conform_action.action_type;
15408 mp->conform_dscp = conform_action.dscp;
15409 mp->exceed_action_type = exceed_action.action_type;
15410 mp->exceed_dscp = exceed_action.dscp;
15411 mp->violate_action_type = violate_action.action_type;
15412 mp->violate_dscp = violate_action.dscp;
15413 mp->color_aware = color_aware;
15421 api_policer_dump (vat_main_t * vam)
15423 unformat_input_t *i = vam->input;
15424 vl_api_policer_dump_t *mp;
15425 vl_api_control_ping_t *mp_ping;
15426 u8 *match_name = 0;
15427 u8 match_name_valid = 0;
15430 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15432 if (unformat (i, "name %s", &match_name))
15434 vec_add1 (match_name, 0);
15435 match_name_valid = 1;
15441 M (POLICER_DUMP, mp);
15442 mp->match_name_valid = match_name_valid;
15443 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15444 vec_free (match_name);
15448 /* Use a control ping for synchronization */
15449 M (CONTROL_PING, mp_ping);
15452 /* Wait for a reply... */
15458 api_policer_classify_set_interface (vat_main_t * vam)
15460 unformat_input_t *i = vam->input;
15461 vl_api_policer_classify_set_interface_t *mp;
15463 int sw_if_index_set;
15464 u32 ip4_table_index = ~0;
15465 u32 ip6_table_index = ~0;
15466 u32 l2_table_index = ~0;
15470 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15472 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15473 sw_if_index_set = 1;
15474 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15475 sw_if_index_set = 1;
15476 else if (unformat (i, "del"))
15478 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15480 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15482 else if (unformat (i, "l2-table %d", &l2_table_index))
15486 clib_warning ("parse error '%U'", format_unformat_error, i);
15491 if (sw_if_index_set == 0)
15493 errmsg ("missing interface name or sw_if_index");
15497 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15499 mp->sw_if_index = ntohl (sw_if_index);
15500 mp->ip4_table_index = ntohl (ip4_table_index);
15501 mp->ip6_table_index = ntohl (ip6_table_index);
15502 mp->l2_table_index = ntohl (l2_table_index);
15503 mp->is_add = is_add;
15511 api_policer_classify_dump (vat_main_t * vam)
15513 unformat_input_t *i = vam->input;
15514 vl_api_policer_classify_dump_t *mp;
15515 vl_api_control_ping_t *mp_ping;
15516 u8 type = POLICER_CLASSIFY_N_TABLES;
15519 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15523 errmsg ("classify table type must be specified");
15527 if (!vam->json_output)
15529 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15532 M (POLICER_CLASSIFY_DUMP, mp);
15537 /* Use a control ping for synchronization */
15538 M (CONTROL_PING, mp_ping);
15541 /* Wait for a reply... */
15547 api_netmap_create (vat_main_t * vam)
15549 unformat_input_t *i = vam->input;
15550 vl_api_netmap_create_t *mp;
15553 u8 random_hw_addr = 1;
15558 memset (hw_addr, 0, sizeof (hw_addr));
15560 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15562 if (unformat (i, "name %s", &if_name))
15563 vec_add1 (if_name, 0);
15564 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15565 random_hw_addr = 0;
15566 else if (unformat (i, "pipe"))
15568 else if (unformat (i, "master"))
15570 else if (unformat (i, "slave"))
15576 if (!vec_len (if_name))
15578 errmsg ("interface name must be specified");
15582 if (vec_len (if_name) > 64)
15584 errmsg ("interface name too long");
15588 M (NETMAP_CREATE, mp);
15590 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15591 clib_memcpy (mp->hw_addr, hw_addr, 6);
15592 mp->use_random_hw_addr = random_hw_addr;
15593 mp->is_pipe = is_pipe;
15594 mp->is_master = is_master;
15595 vec_free (if_name);
15603 api_netmap_delete (vat_main_t * vam)
15605 unformat_input_t *i = vam->input;
15606 vl_api_netmap_delete_t *mp;
15610 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15612 if (unformat (i, "name %s", &if_name))
15613 vec_add1 (if_name, 0);
15618 if (!vec_len (if_name))
15620 errmsg ("interface name must be specified");
15624 if (vec_len (if_name) > 64)
15626 errmsg ("interface name too long");
15630 M (NETMAP_DELETE, mp);
15632 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15633 vec_free (if_name);
15640 static void vl_api_mpls_tunnel_details_t_handler
15641 (vl_api_mpls_tunnel_details_t * mp)
15643 vat_main_t *vam = &vat_main;
15644 i32 len = mp->mt_next_hop_n_labels;
15647 print (vam->ofp, "[%d]: via %U %d labels ",
15649 format_ip4_address, mp->mt_next_hop,
15650 ntohl (mp->mt_next_hop_sw_if_index));
15651 for (i = 0; i < len; i++)
15653 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15655 print (vam->ofp, "");
15658 static void vl_api_mpls_tunnel_details_t_handler_json
15659 (vl_api_mpls_tunnel_details_t * mp)
15661 vat_main_t *vam = &vat_main;
15662 vat_json_node_t *node = NULL;
15663 struct in_addr ip4;
15665 i32 len = mp->mt_next_hop_n_labels;
15667 if (VAT_JSON_ARRAY != vam->json_tree.type)
15669 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15670 vat_json_init_array (&vam->json_tree);
15672 node = vat_json_array_add (&vam->json_tree);
15674 vat_json_init_object (node);
15675 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15676 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15677 vat_json_object_add_ip4 (node, "next_hop", ip4);
15678 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15679 ntohl (mp->mt_next_hop_sw_if_index));
15680 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15681 vat_json_object_add_uint (node, "label_count", len);
15682 for (i = 0; i < len; i++)
15684 vat_json_object_add_uint (node, "label",
15685 ntohl (mp->mt_next_hop_out_labels[i]));
15690 api_mpls_tunnel_dump (vat_main_t * vam)
15692 vl_api_mpls_tunnel_dump_t *mp;
15693 vl_api_control_ping_t *mp_ping;
15697 /* Parse args required to build the message */
15698 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15700 if (!unformat (vam->input, "tunnel_index %d", &index))
15707 print (vam->ofp, " tunnel_index %d", index);
15709 M (MPLS_TUNNEL_DUMP, mp);
15710 mp->tunnel_index = htonl (index);
15713 /* Use a control ping for synchronization */
15714 M (CONTROL_PING, mp_ping);
15721 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15722 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15725 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15727 vat_main_t *vam = &vat_main;
15728 int count = ntohl (mp->count);
15729 vl_api_fib_path2_t *fp;
15733 "table-id %d, label %u, ess_bit %u",
15734 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15736 for (i = 0; i < count; i++)
15738 if (fp->afi == IP46_TYPE_IP6)
15740 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15741 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15742 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15743 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15744 format_ip6_address, fp->next_hop);
15745 else if (fp->afi == IP46_TYPE_IP4)
15747 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15748 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15749 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15750 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15751 format_ip4_address, fp->next_hop);
15756 static void vl_api_mpls_fib_details_t_handler_json
15757 (vl_api_mpls_fib_details_t * mp)
15759 vat_main_t *vam = &vat_main;
15760 int count = ntohl (mp->count);
15761 vat_json_node_t *node = NULL;
15762 struct in_addr ip4;
15763 struct in6_addr ip6;
15764 vl_api_fib_path2_t *fp;
15767 if (VAT_JSON_ARRAY != vam->json_tree.type)
15769 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15770 vat_json_init_array (&vam->json_tree);
15772 node = vat_json_array_add (&vam->json_tree);
15774 vat_json_init_object (node);
15775 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15776 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15777 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15778 vat_json_object_add_uint (node, "path_count", count);
15780 for (i = 0; i < count; i++)
15782 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15783 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15784 vat_json_object_add_uint (node, "is_local", fp->is_local);
15785 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15786 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15787 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15788 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15789 if (fp->afi == IP46_TYPE_IP4)
15791 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15792 vat_json_object_add_ip4 (node, "next_hop", ip4);
15794 else if (fp->afi == IP46_TYPE_IP6)
15796 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15797 vat_json_object_add_ip6 (node, "next_hop", ip6);
15803 api_mpls_fib_dump (vat_main_t * vam)
15805 vl_api_mpls_fib_dump_t *mp;
15806 vl_api_control_ping_t *mp_ping;
15809 M (MPLS_FIB_DUMP, mp);
15812 /* Use a control ping for synchronization */
15813 M (CONTROL_PING, mp_ping);
15820 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15821 #define vl_api_ip_fib_details_t_print vl_noop_handler
15824 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15826 vat_main_t *vam = &vat_main;
15827 int count = ntohl (mp->count);
15828 vl_api_fib_path_t *fp;
15832 "table-id %d, prefix %U/%d",
15833 ntohl (mp->table_id), format_ip4_address, mp->address,
15834 mp->address_length);
15836 for (i = 0; i < count; i++)
15838 if (fp->afi == IP46_TYPE_IP6)
15840 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15841 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15842 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15843 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15844 format_ip6_address, fp->next_hop);
15845 else if (fp->afi == IP46_TYPE_IP4)
15847 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15848 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15849 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15850 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15851 format_ip4_address, fp->next_hop);
15856 static void vl_api_ip_fib_details_t_handler_json
15857 (vl_api_ip_fib_details_t * mp)
15859 vat_main_t *vam = &vat_main;
15860 int count = ntohl (mp->count);
15861 vat_json_node_t *node = NULL;
15862 struct in_addr ip4;
15863 struct in6_addr ip6;
15864 vl_api_fib_path_t *fp;
15867 if (VAT_JSON_ARRAY != vam->json_tree.type)
15869 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15870 vat_json_init_array (&vam->json_tree);
15872 node = vat_json_array_add (&vam->json_tree);
15874 vat_json_init_object (node);
15875 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15876 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15877 vat_json_object_add_ip4 (node, "prefix", ip4);
15878 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15879 vat_json_object_add_uint (node, "path_count", count);
15881 for (i = 0; i < count; i++)
15883 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15884 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15885 vat_json_object_add_uint (node, "is_local", fp->is_local);
15886 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15887 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15888 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15889 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15890 if (fp->afi == IP46_TYPE_IP4)
15892 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15893 vat_json_object_add_ip4 (node, "next_hop", ip4);
15895 else if (fp->afi == IP46_TYPE_IP6)
15897 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15898 vat_json_object_add_ip6 (node, "next_hop", ip6);
15904 api_ip_fib_dump (vat_main_t * vam)
15906 vl_api_ip_fib_dump_t *mp;
15907 vl_api_control_ping_t *mp_ping;
15910 M (IP_FIB_DUMP, mp);
15913 /* Use a control ping for synchronization */
15914 M (CONTROL_PING, mp_ping);
15922 api_ip_mfib_dump (vat_main_t * vam)
15924 vl_api_ip_mfib_dump_t *mp;
15925 vl_api_control_ping_t *mp_ping;
15928 M (IP_MFIB_DUMP, mp);
15931 /* Use a control ping for synchronization */
15932 M (CONTROL_PING, mp_ping);
15939 static void vl_api_ip_neighbor_details_t_handler
15940 (vl_api_ip_neighbor_details_t * mp)
15942 vat_main_t *vam = &vat_main;
15944 print (vam->ofp, "%c %U %U",
15945 (mp->is_static) ? 'S' : 'D',
15946 format_ethernet_address, &mp->mac_address,
15947 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15951 static void vl_api_ip_neighbor_details_t_handler_json
15952 (vl_api_ip_neighbor_details_t * mp)
15955 vat_main_t *vam = &vat_main;
15956 vat_json_node_t *node;
15957 struct in_addr ip4;
15958 struct in6_addr ip6;
15960 if (VAT_JSON_ARRAY != vam->json_tree.type)
15962 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15963 vat_json_init_array (&vam->json_tree);
15965 node = vat_json_array_add (&vam->json_tree);
15967 vat_json_init_object (node);
15968 vat_json_object_add_string_copy (node, "flag",
15969 (mp->is_static) ? (u8 *) "static" : (u8 *)
15972 vat_json_object_add_string_copy (node, "link_layer",
15973 format (0, "%U", format_ethernet_address,
15974 &mp->mac_address));
15978 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15979 vat_json_object_add_ip6 (node, "ip_address", ip6);
15983 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15984 vat_json_object_add_ip4 (node, "ip_address", ip4);
15989 api_ip_neighbor_dump (vat_main_t * vam)
15991 unformat_input_t *i = vam->input;
15992 vl_api_ip_neighbor_dump_t *mp;
15993 vl_api_control_ping_t *mp_ping;
15995 u32 sw_if_index = ~0;
15998 /* Parse args required to build the message */
15999 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16001 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16003 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16005 else if (unformat (i, "ip6"))
16011 if (sw_if_index == ~0)
16013 errmsg ("missing interface name or sw_if_index");
16017 M (IP_NEIGHBOR_DUMP, mp);
16018 mp->is_ipv6 = (u8) is_ipv6;
16019 mp->sw_if_index = ntohl (sw_if_index);
16022 /* Use a control ping for synchronization */
16023 M (CONTROL_PING, mp_ping);
16030 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16031 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16034 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16036 vat_main_t *vam = &vat_main;
16037 int count = ntohl (mp->count);
16038 vl_api_fib_path_t *fp;
16042 "table-id %d, prefix %U/%d",
16043 ntohl (mp->table_id), format_ip6_address, mp->address,
16044 mp->address_length);
16046 for (i = 0; i < count; i++)
16048 if (fp->afi == IP46_TYPE_IP6)
16050 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16051 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16052 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16053 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16054 format_ip6_address, fp->next_hop);
16055 else if (fp->afi == IP46_TYPE_IP4)
16057 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16058 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16059 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16060 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16061 format_ip4_address, fp->next_hop);
16066 static void vl_api_ip6_fib_details_t_handler_json
16067 (vl_api_ip6_fib_details_t * mp)
16069 vat_main_t *vam = &vat_main;
16070 int count = ntohl (mp->count);
16071 vat_json_node_t *node = NULL;
16072 struct in_addr ip4;
16073 struct in6_addr ip6;
16074 vl_api_fib_path_t *fp;
16077 if (VAT_JSON_ARRAY != vam->json_tree.type)
16079 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16080 vat_json_init_array (&vam->json_tree);
16082 node = vat_json_array_add (&vam->json_tree);
16084 vat_json_init_object (node);
16085 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16086 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16087 vat_json_object_add_ip6 (node, "prefix", ip6);
16088 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16089 vat_json_object_add_uint (node, "path_count", count);
16091 for (i = 0; i < count; i++)
16093 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16094 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16095 vat_json_object_add_uint (node, "is_local", fp->is_local);
16096 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16097 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16098 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16099 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16100 if (fp->afi == IP46_TYPE_IP4)
16102 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16103 vat_json_object_add_ip4 (node, "next_hop", ip4);
16105 else if (fp->afi == IP46_TYPE_IP6)
16107 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16108 vat_json_object_add_ip6 (node, "next_hop", ip6);
16114 api_ip6_fib_dump (vat_main_t * vam)
16116 vl_api_ip6_fib_dump_t *mp;
16117 vl_api_control_ping_t *mp_ping;
16120 M (IP6_FIB_DUMP, mp);
16123 /* Use a control ping for synchronization */
16124 M (CONTROL_PING, mp_ping);
16132 api_ip6_mfib_dump (vat_main_t * vam)
16134 vl_api_ip6_mfib_dump_t *mp;
16135 vl_api_control_ping_t *mp_ping;
16138 M (IP6_MFIB_DUMP, mp);
16141 /* Use a control ping for synchronization */
16142 M (CONTROL_PING, mp_ping);
16150 api_classify_table_ids (vat_main_t * vam)
16152 vl_api_classify_table_ids_t *mp;
16155 /* Construct the API message */
16156 M (CLASSIFY_TABLE_IDS, mp);
16165 api_classify_table_by_interface (vat_main_t * vam)
16167 unformat_input_t *input = vam->input;
16168 vl_api_classify_table_by_interface_t *mp;
16170 u32 sw_if_index = ~0;
16172 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16174 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16176 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16181 if (sw_if_index == ~0)
16183 errmsg ("missing interface name or sw_if_index");
16187 /* Construct the API message */
16188 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16190 mp->sw_if_index = ntohl (sw_if_index);
16198 api_classify_table_info (vat_main_t * vam)
16200 unformat_input_t *input = vam->input;
16201 vl_api_classify_table_info_t *mp;
16205 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16207 if (unformat (input, "table_id %d", &table_id))
16212 if (table_id == ~0)
16214 errmsg ("missing table id");
16218 /* Construct the API message */
16219 M (CLASSIFY_TABLE_INFO, mp);
16221 mp->table_id = ntohl (table_id);
16229 api_classify_session_dump (vat_main_t * vam)
16231 unformat_input_t *input = vam->input;
16232 vl_api_classify_session_dump_t *mp;
16233 vl_api_control_ping_t *mp_ping;
16237 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16239 if (unformat (input, "table_id %d", &table_id))
16244 if (table_id == ~0)
16246 errmsg ("missing table id");
16250 /* Construct the API message */
16251 M (CLASSIFY_SESSION_DUMP, mp);
16253 mp->table_id = ntohl (table_id);
16256 /* Use a control ping for synchronization */
16257 M (CONTROL_PING, mp_ping);
16265 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16267 vat_main_t *vam = &vat_main;
16269 print (vam->ofp, "collector_address %U, collector_port %d, "
16270 "src_address %U, vrf_id %d, path_mtu %u, "
16271 "template_interval %u, udp_checksum %d",
16272 format_ip4_address, mp->collector_address,
16273 ntohs (mp->collector_port),
16274 format_ip4_address, mp->src_address,
16275 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16276 ntohl (mp->template_interval), mp->udp_checksum);
16279 vam->result_ready = 1;
16283 vl_api_ipfix_exporter_details_t_handler_json
16284 (vl_api_ipfix_exporter_details_t * mp)
16286 vat_main_t *vam = &vat_main;
16287 vat_json_node_t node;
16288 struct in_addr collector_address;
16289 struct in_addr src_address;
16291 vat_json_init_object (&node);
16292 clib_memcpy (&collector_address, &mp->collector_address,
16293 sizeof (collector_address));
16294 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16295 vat_json_object_add_uint (&node, "collector_port",
16296 ntohs (mp->collector_port));
16297 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16298 vat_json_object_add_ip4 (&node, "src_address", src_address);
16299 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16300 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16301 vat_json_object_add_uint (&node, "template_interval",
16302 ntohl (mp->template_interval));
16303 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16305 vat_json_print (vam->ofp, &node);
16306 vat_json_free (&node);
16308 vam->result_ready = 1;
16312 api_ipfix_exporter_dump (vat_main_t * vam)
16314 vl_api_ipfix_exporter_dump_t *mp;
16317 /* Construct the API message */
16318 M (IPFIX_EXPORTER_DUMP, mp);
16327 api_ipfix_classify_stream_dump (vat_main_t * vam)
16329 vl_api_ipfix_classify_stream_dump_t *mp;
16332 /* Construct the API message */
16333 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16344 vl_api_ipfix_classify_stream_details_t_handler
16345 (vl_api_ipfix_classify_stream_details_t * mp)
16347 vat_main_t *vam = &vat_main;
16348 print (vam->ofp, "domain_id %d, src_port %d",
16349 ntohl (mp->domain_id), ntohs (mp->src_port));
16351 vam->result_ready = 1;
16355 vl_api_ipfix_classify_stream_details_t_handler_json
16356 (vl_api_ipfix_classify_stream_details_t * mp)
16358 vat_main_t *vam = &vat_main;
16359 vat_json_node_t node;
16361 vat_json_init_object (&node);
16362 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16363 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16365 vat_json_print (vam->ofp, &node);
16366 vat_json_free (&node);
16368 vam->result_ready = 1;
16372 api_ipfix_classify_table_dump (vat_main_t * vam)
16374 vl_api_ipfix_classify_table_dump_t *mp;
16375 vl_api_control_ping_t *mp_ping;
16378 if (!vam->json_output)
16380 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16381 "transport_protocol");
16384 /* Construct the API message */
16385 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16390 /* Use a control ping for synchronization */
16391 M (CONTROL_PING, mp_ping);
16399 vl_api_ipfix_classify_table_details_t_handler
16400 (vl_api_ipfix_classify_table_details_t * mp)
16402 vat_main_t *vam = &vat_main;
16403 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16404 mp->transport_protocol);
16408 vl_api_ipfix_classify_table_details_t_handler_json
16409 (vl_api_ipfix_classify_table_details_t * mp)
16411 vat_json_node_t *node = NULL;
16412 vat_main_t *vam = &vat_main;
16414 if (VAT_JSON_ARRAY != vam->json_tree.type)
16416 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16417 vat_json_init_array (&vam->json_tree);
16420 node = vat_json_array_add (&vam->json_tree);
16421 vat_json_init_object (node);
16423 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16424 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16425 vat_json_object_add_uint (node, "transport_protocol",
16426 mp->transport_protocol);
16430 api_sw_interface_span_enable_disable (vat_main_t * vam)
16432 unformat_input_t *i = vam->input;
16433 vl_api_sw_interface_span_enable_disable_t *mp;
16434 u32 src_sw_if_index = ~0;
16435 u32 dst_sw_if_index = ~0;
16439 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16442 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16444 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16448 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16450 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16452 else if (unformat (i, "disable"))
16454 else if (unformat (i, "rx"))
16456 else if (unformat (i, "tx"))
16458 else if (unformat (i, "both"))
16464 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16466 mp->sw_if_index_from = htonl (src_sw_if_index);
16467 mp->sw_if_index_to = htonl (dst_sw_if_index);
16476 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16479 vat_main_t *vam = &vat_main;
16480 u8 *sw_if_from_name = 0;
16481 u8 *sw_if_to_name = 0;
16482 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16483 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16484 char *states[] = { "none", "rx", "tx", "both" };
16488 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16490 if ((u32) p->value[0] == sw_if_index_from)
16492 sw_if_from_name = (u8 *)(p->key);
16496 if ((u32) p->value[0] == sw_if_index_to)
16498 sw_if_to_name = (u8 *)(p->key);
16499 if (sw_if_from_name)
16504 print (vam->ofp, "%20s => %20s (%s)",
16505 sw_if_from_name, sw_if_to_name, states[mp->state]);
16509 vl_api_sw_interface_span_details_t_handler_json
16510 (vl_api_sw_interface_span_details_t * mp)
16512 vat_main_t *vam = &vat_main;
16513 vat_json_node_t *node = NULL;
16514 u8 *sw_if_from_name = 0;
16515 u8 *sw_if_to_name = 0;
16516 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16517 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16521 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16523 if ((u32) p->value[0] == sw_if_index_from)
16525 sw_if_from_name = (u8 *)(p->key);
16529 if ((u32) p->value[0] == sw_if_index_to)
16531 sw_if_to_name = (u8 *)(p->key);
16532 if (sw_if_from_name)
16538 if (VAT_JSON_ARRAY != vam->json_tree.type)
16540 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16541 vat_json_init_array (&vam->json_tree);
16543 node = vat_json_array_add (&vam->json_tree);
16545 vat_json_init_object (node);
16546 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16547 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16548 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16549 if (0 != sw_if_to_name)
16551 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16553 vat_json_object_add_uint (node, "state", mp->state);
16557 api_sw_interface_span_dump (vat_main_t * vam)
16559 vl_api_sw_interface_span_dump_t *mp;
16560 vl_api_control_ping_t *mp_ping;
16563 M (SW_INTERFACE_SPAN_DUMP, mp);
16566 /* Use a control ping for synchronization */
16567 M (CONTROL_PING, mp_ping);
16575 api_pg_create_interface (vat_main_t * vam)
16577 unformat_input_t *input = vam->input;
16578 vl_api_pg_create_interface_t *mp;
16582 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16584 if (unformat (input, "if_id %d", &if_id))
16591 errmsg ("missing pg interface index");
16595 /* Construct the API message */
16596 M (PG_CREATE_INTERFACE, mp);
16598 mp->interface_id = ntohl (if_id);
16606 api_pg_capture (vat_main_t * vam)
16608 unformat_input_t *input = vam->input;
16609 vl_api_pg_capture_t *mp;
16614 u8 pcap_file_set = 0;
16617 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16619 if (unformat (input, "if_id %d", &if_id))
16621 else if (unformat (input, "pcap %s", &pcap_file))
16623 else if (unformat (input, "count %d", &count))
16625 else if (unformat (input, "disable"))
16632 errmsg ("missing pg interface index");
16635 if (pcap_file_set > 0)
16637 if (vec_len (pcap_file) > 255)
16639 errmsg ("pcap file name is too long");
16644 u32 name_len = vec_len (pcap_file);
16645 /* Construct the API message */
16646 M (PG_CAPTURE, mp);
16648 mp->interface_id = ntohl (if_id);
16649 mp->is_enabled = enable;
16650 mp->count = ntohl (count);
16651 mp->pcap_name_length = ntohl (name_len);
16652 if (pcap_file_set != 0)
16654 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16656 vec_free (pcap_file);
16664 api_pg_enable_disable (vat_main_t * vam)
16666 unformat_input_t *input = vam->input;
16667 vl_api_pg_enable_disable_t *mp;
16670 u8 stream_name_set = 0;
16671 u8 *stream_name = 0;
16673 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16675 if (unformat (input, "stream %s", &stream_name))
16676 stream_name_set = 1;
16677 else if (unformat (input, "disable"))
16683 if (stream_name_set > 0)
16685 if (vec_len (stream_name) > 255)
16687 errmsg ("stream name too long");
16692 u32 name_len = vec_len (stream_name);
16693 /* Construct the API message */
16694 M (PG_ENABLE_DISABLE, mp);
16696 mp->is_enabled = enable;
16697 if (stream_name_set != 0)
16699 mp->stream_name_length = ntohl (name_len);
16700 clib_memcpy (mp->stream_name, stream_name, name_len);
16702 vec_free (stream_name);
16710 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16712 unformat_input_t *input = vam->input;
16713 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16715 u16 *low_ports = 0;
16716 u16 *high_ports = 0;
16719 ip4_address_t ip4_addr;
16720 ip6_address_t ip6_addr;
16729 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16731 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16737 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16742 else if (unformat (input, "vrf %d", &vrf_id))
16744 else if (unformat (input, "del"))
16746 else if (unformat (input, "port %d", &tmp))
16748 if (tmp == 0 || tmp > 65535)
16750 errmsg ("port %d out of range", tmp);
16754 this_hi = this_low + 1;
16755 vec_add1 (low_ports, this_low);
16756 vec_add1 (high_ports, this_hi);
16758 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16760 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16762 errmsg ("incorrect range parameters");
16766 /* Note: in debug CLI +1 is added to high before
16767 passing to real fn that does "the work"
16768 (ip_source_and_port_range_check_add_del).
16769 This fn is a wrapper around the binary API fn a
16770 control plane will call, which expects this increment
16771 to have occurred. Hence letting the binary API control
16772 plane fn do the increment for consistency between VAT
16773 and other control planes.
16776 vec_add1 (low_ports, this_low);
16777 vec_add1 (high_ports, this_hi);
16783 if (prefix_set == 0)
16785 errmsg ("<address>/<mask> not specified");
16791 errmsg ("VRF ID required, not specified");
16798 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16802 if (vec_len (low_ports) == 0)
16804 errmsg ("At least one port or port range required");
16808 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16810 mp->is_add = is_add;
16815 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16820 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16823 mp->mask_length = length;
16824 mp->number_of_ranges = vec_len (low_ports);
16826 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16827 vec_free (low_ports);
16829 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16830 vec_free (high_ports);
16832 mp->vrf_id = ntohl (vrf_id);
16840 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16842 unformat_input_t *input = vam->input;
16843 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16844 u32 sw_if_index = ~0;
16846 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16847 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16851 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16853 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16855 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16857 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16859 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16861 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16863 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16865 else if (unformat (input, "del"))
16871 if (sw_if_index == ~0)
16873 errmsg ("Interface required but not specified");
16879 errmsg ("VRF ID required but not specified");
16883 if (tcp_out_vrf_id == 0
16884 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16887 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16891 /* Construct the API message */
16892 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
16894 mp->sw_if_index = ntohl (sw_if_index);
16895 mp->is_add = is_add;
16896 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16897 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16898 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16899 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16904 /* Wait for a reply... */
16910 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16912 unformat_input_t *i = vam->input;
16913 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16914 u32 local_sa_id = 0;
16915 u32 remote_sa_id = 0;
16916 ip4_address_t src_address;
16917 ip4_address_t dst_address;
16921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16923 if (unformat (i, "local_sa %d", &local_sa_id))
16925 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16927 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16929 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16931 else if (unformat (i, "del"))
16935 clib_warning ("parse error '%U'", format_unformat_error, i);
16940 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
16942 mp->local_sa_id = ntohl (local_sa_id);
16943 mp->remote_sa_id = ntohl (remote_sa_id);
16944 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16945 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16946 mp->is_add = is_add;
16954 api_punt (vat_main_t * vam)
16956 unformat_input_t *i = vam->input;
16964 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16966 if (unformat (i, "ip %d", &ipv))
16968 else if (unformat (i, "protocol %d", &protocol))
16970 else if (unformat (i, "port %d", &port))
16972 else if (unformat (i, "del"))
16976 clib_warning ("parse error '%U'", format_unformat_error, i);
16983 mp->is_add = (u8) is_add;
16984 mp->ipv = (u8) ipv;
16985 mp->l4_protocol = (u8) protocol;
16986 mp->l4_port = htons ((u16) port);
16993 static void vl_api_ipsec_gre_tunnel_details_t_handler
16994 (vl_api_ipsec_gre_tunnel_details_t * mp)
16996 vat_main_t *vam = &vat_main;
16998 print (vam->ofp, "%11d%15U%15U%14d%14d",
16999 ntohl (mp->sw_if_index),
17000 format_ip4_address, &mp->src_address,
17001 format_ip4_address, &mp->dst_address,
17002 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17005 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17006 (vl_api_ipsec_gre_tunnel_details_t * mp)
17008 vat_main_t *vam = &vat_main;
17009 vat_json_node_t *node = NULL;
17010 struct in_addr ip4;
17012 if (VAT_JSON_ARRAY != vam->json_tree.type)
17014 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17015 vat_json_init_array (&vam->json_tree);
17017 node = vat_json_array_add (&vam->json_tree);
17019 vat_json_init_object (node);
17020 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17021 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17022 vat_json_object_add_ip4 (node, "src_address", ip4);
17023 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17024 vat_json_object_add_ip4 (node, "dst_address", ip4);
17025 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17026 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17030 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17032 unformat_input_t *i = vam->input;
17033 vl_api_ipsec_gre_tunnel_dump_t *mp;
17034 vl_api_control_ping_t *mp_ping;
17036 u8 sw_if_index_set = 0;
17039 /* Parse args required to build the message */
17040 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17042 if (unformat (i, "sw_if_index %d", &sw_if_index))
17043 sw_if_index_set = 1;
17048 if (sw_if_index_set == 0)
17053 if (!vam->json_output)
17055 print (vam->ofp, "%11s%15s%15s%14s%14s",
17056 "sw_if_index", "src_address", "dst_address",
17057 "local_sa_id", "remote_sa_id");
17060 /* Get list of gre-tunnel interfaces */
17061 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17063 mp->sw_if_index = htonl (sw_if_index);
17067 /* Use a control ping for synchronization */
17068 M (CONTROL_PING, mp_ping);
17076 api_delete_subif (vat_main_t * vam)
17078 unformat_input_t *i = vam->input;
17079 vl_api_delete_subif_t *mp;
17080 u32 sw_if_index = ~0;
17083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17085 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17087 if (unformat (i, "sw_if_index %d", &sw_if_index))
17093 if (sw_if_index == ~0)
17095 errmsg ("missing sw_if_index");
17099 /* Construct the API message */
17100 M (DELETE_SUBIF, mp);
17101 mp->sw_if_index = ntohl (sw_if_index);
17108 #define foreach_pbb_vtr_op \
17109 _("disable", L2_VTR_DISABLED) \
17110 _("pop", L2_VTR_POP_2) \
17111 _("push", L2_VTR_PUSH_2)
17114 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17116 unformat_input_t *i = vam->input;
17117 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17118 u32 sw_if_index = ~0, vtr_op = ~0;
17119 u16 outer_tag = ~0;
17120 u8 dmac[6], smac[6];
17121 u8 dmac_set = 0, smac_set = 0;
17127 /* Shut up coverity */
17128 memset (dmac, 0, sizeof (dmac));
17129 memset (smac, 0, sizeof (smac));
17131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17133 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17135 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17137 else if (unformat (i, "vtr_op %d", &vtr_op))
17139 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17142 else if (unformat (i, "translate_pbb_stag"))
17144 if (unformat (i, "%d", &tmp))
17146 vtr_op = L2_VTR_TRANSLATE_2_1;
17152 ("translate_pbb_stag operation requires outer tag definition");
17156 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17158 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17160 else if (unformat (i, "sid %d", &sid))
17162 else if (unformat (i, "vlanid %d", &tmp))
17166 clib_warning ("parse error '%U'", format_unformat_error, i);
17171 if ((sw_if_index == ~0) || (vtr_op == ~0))
17173 errmsg ("missing sw_if_index or vtr operation");
17176 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17177 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17180 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17184 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17185 mp->sw_if_index = ntohl (sw_if_index);
17186 mp->vtr_op = ntohl (vtr_op);
17187 mp->outer_tag = ntohs (outer_tag);
17188 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17189 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17190 mp->b_vlanid = ntohs (vlanid);
17191 mp->i_sid = ntohl (sid);
17199 api_flow_classify_set_interface (vat_main_t * vam)
17201 unformat_input_t *i = vam->input;
17202 vl_api_flow_classify_set_interface_t *mp;
17204 int sw_if_index_set;
17205 u32 ip4_table_index = ~0;
17206 u32 ip6_table_index = ~0;
17210 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17212 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17213 sw_if_index_set = 1;
17214 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17215 sw_if_index_set = 1;
17216 else if (unformat (i, "del"))
17218 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17220 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17224 clib_warning ("parse error '%U'", format_unformat_error, i);
17229 if (sw_if_index_set == 0)
17231 errmsg ("missing interface name or sw_if_index");
17235 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17237 mp->sw_if_index = ntohl (sw_if_index);
17238 mp->ip4_table_index = ntohl (ip4_table_index);
17239 mp->ip6_table_index = ntohl (ip6_table_index);
17240 mp->is_add = is_add;
17248 api_flow_classify_dump (vat_main_t * vam)
17250 unformat_input_t *i = vam->input;
17251 vl_api_flow_classify_dump_t *mp;
17252 vl_api_control_ping_t *mp_ping;
17253 u8 type = FLOW_CLASSIFY_N_TABLES;
17256 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17260 errmsg ("classify table type must be specified");
17264 if (!vam->json_output)
17266 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17269 M (FLOW_CLASSIFY_DUMP, mp);
17274 /* Use a control ping for synchronization */
17275 M (CONTROL_PING, mp_ping);
17278 /* Wait for a reply... */
17284 api_feature_enable_disable (vat_main_t * vam)
17286 unformat_input_t *i = vam->input;
17287 vl_api_feature_enable_disable_t *mp;
17289 u8 *feature_name = 0;
17290 u32 sw_if_index = ~0;
17294 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17296 if (unformat (i, "arc_name %s", &arc_name))
17298 else if (unformat (i, "feature_name %s", &feature_name))
17301 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17303 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17305 else if (unformat (i, "disable"))
17313 errmsg ("missing arc name");
17316 if (vec_len (arc_name) > 63)
17318 errmsg ("arc name too long");
17321 if (feature_name == 0)
17323 errmsg ("missing feature name");
17326 if (vec_len (feature_name) > 63)
17328 errmsg ("feature name too long");
17331 if (sw_if_index == ~0)
17333 errmsg ("missing interface name or sw_if_index");
17337 /* Construct the API message */
17338 M (FEATURE_ENABLE_DISABLE, mp);
17339 mp->sw_if_index = ntohl (sw_if_index);
17340 mp->enable = enable;
17341 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17342 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17343 vec_free (arc_name);
17344 vec_free (feature_name);
17352 api_sw_interface_tag_add_del (vat_main_t * vam)
17354 unformat_input_t *i = vam->input;
17355 vl_api_sw_interface_tag_add_del_t *mp;
17356 u32 sw_if_index = ~0;
17361 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17363 if (unformat (i, "tag %s", &tag))
17365 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17367 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17369 else if (unformat (i, "del"))
17375 if (sw_if_index == ~0)
17377 errmsg ("missing interface name or sw_if_index");
17381 if (enable && (tag == 0))
17383 errmsg ("no tag specified");
17387 /* Construct the API message */
17388 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17389 mp->sw_if_index = ntohl (sw_if_index);
17390 mp->is_add = enable;
17392 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17400 static void vl_api_l2_xconnect_details_t_handler
17401 (vl_api_l2_xconnect_details_t * mp)
17403 vat_main_t *vam = &vat_main;
17405 print (vam->ofp, "%15d%15d",
17406 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17409 static void vl_api_l2_xconnect_details_t_handler_json
17410 (vl_api_l2_xconnect_details_t * mp)
17412 vat_main_t *vam = &vat_main;
17413 vat_json_node_t *node = NULL;
17415 if (VAT_JSON_ARRAY != vam->json_tree.type)
17417 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17418 vat_json_init_array (&vam->json_tree);
17420 node = vat_json_array_add (&vam->json_tree);
17422 vat_json_init_object (node);
17423 vat_json_object_add_uint (node, "rx_sw_if_index",
17424 ntohl (mp->rx_sw_if_index));
17425 vat_json_object_add_uint (node, "tx_sw_if_index",
17426 ntohl (mp->tx_sw_if_index));
17430 api_l2_xconnect_dump (vat_main_t * vam)
17432 vl_api_l2_xconnect_dump_t *mp;
17433 vl_api_control_ping_t *mp_ping;
17436 if (!vam->json_output)
17438 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17441 M (L2_XCONNECT_DUMP, mp);
17445 /* Use a control ping for synchronization */
17446 M (CONTROL_PING, mp_ping);
17454 api_sw_interface_set_mtu (vat_main_t * vam)
17456 unformat_input_t *i = vam->input;
17457 vl_api_sw_interface_set_mtu_t *mp;
17458 u32 sw_if_index = ~0;
17462 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17464 if (unformat (i, "mtu %d", &mtu))
17466 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17468 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17474 if (sw_if_index == ~0)
17476 errmsg ("missing interface name or sw_if_index");
17482 errmsg ("no mtu specified");
17486 /* Construct the API message */
17487 M (SW_INTERFACE_SET_MTU, mp);
17488 mp->sw_if_index = ntohl (sw_if_index);
17489 mp->mtu = ntohs ((u16) mtu);
17498 q_or_quit (vat_main_t * vam)
17500 #if VPP_API_TEST_BUILTIN == 0
17501 longjmp (vam->jump_buf, 1);
17503 return 0; /* not so much */
17507 q (vat_main_t * vam)
17509 return q_or_quit (vam);
17513 quit (vat_main_t * vam)
17515 return q_or_quit (vam);
17519 comment (vat_main_t * vam)
17525 cmd_cmp (void *a1, void *a2)
17530 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17534 help (vat_main_t * vam)
17539 unformat_input_t *i = vam->input;
17542 if (unformat (i, "%s", &name))
17546 vec_add1 (name, 0);
17548 hs = hash_get_mem (vam->help_by_name, name);
17550 print (vam->ofp, "usage: %s %s", name, hs[0]);
17552 print (vam->ofp, "No such msg / command '%s'", name);
17557 print (vam->ofp, "Help is available for the following:");
17560 hash_foreach_pair (p, vam->function_by_name,
17562 vec_add1 (cmds, (u8 *)(p->key));
17566 vec_sort_with_function (cmds, cmd_cmp);
17568 for (j = 0; j < vec_len (cmds); j++)
17569 print (vam->ofp, "%s", cmds[j]);
17576 set (vat_main_t * vam)
17578 u8 *name = 0, *value = 0;
17579 unformat_input_t *i = vam->input;
17581 if (unformat (i, "%s", &name))
17583 /* The input buffer is a vector, not a string. */
17584 value = vec_dup (i->buffer);
17585 vec_delete (value, i->index, 0);
17586 /* Almost certainly has a trailing newline */
17587 if (value[vec_len (value) - 1] == '\n')
17588 value[vec_len (value) - 1] = 0;
17589 /* Make sure it's a proper string, one way or the other */
17590 vec_add1 (value, 0);
17591 (void) clib_macro_set_value (&vam->macro_main,
17592 (char *) name, (char *) value);
17595 errmsg ("usage: set <name> <value>");
17603 unset (vat_main_t * vam)
17607 if (unformat (vam->input, "%s", &name))
17608 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17609 errmsg ("unset: %s wasn't set", name);
17622 macro_sort_cmp (void *a1, void *a2)
17624 macro_sort_t *s1 = a1;
17625 macro_sort_t *s2 = a2;
17627 return strcmp ((char *) (s1->name), (char *) (s2->name));
17631 dump_macro_table (vat_main_t * vam)
17633 macro_sort_t *sort_me = 0, *sm;
17638 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17640 vec_add2 (sort_me, sm, 1);
17641 sm->name = (u8 *)(p->key);
17642 sm->value = (u8 *) (p->value[0]);
17646 vec_sort_with_function (sort_me, macro_sort_cmp);
17648 if (vec_len (sort_me))
17649 print (vam->ofp, "%-15s%s", "Name", "Value");
17651 print (vam->ofp, "The macro table is empty...");
17653 for (i = 0; i < vec_len (sort_me); i++)
17654 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17659 dump_node_table (vat_main_t * vam)
17662 vlib_node_t *node, *next_node;
17664 if (vec_len (vam->graph_nodes) == 0)
17666 print (vam->ofp, "Node table empty, issue get_node_graph...");
17670 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17672 node = vam->graph_nodes[i];
17673 print (vam->ofp, "[%d] %s", i, node->name);
17674 for (j = 0; j < vec_len (node->next_nodes); j++)
17676 if (node->next_nodes[j] != ~0)
17678 next_node = vam->graph_nodes[node->next_nodes[j]];
17679 print (vam->ofp, " [%d] %s", j, next_node->name);
17687 value_sort_cmp (void *a1, void *a2)
17689 name_sort_t *n1 = a1;
17690 name_sort_t *n2 = a2;
17692 if (n1->value < n2->value)
17694 if (n1->value > n2->value)
17701 dump_msg_api_table (vat_main_t * vam)
17703 api_main_t *am = &api_main;
17704 name_sort_t *nses = 0, *ns;
17709 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17711 vec_add2 (nses, ns, 1);
17712 ns->name = (u8 *)(hp->key);
17713 ns->value = (u32) hp->value[0];
17717 vec_sort_with_function (nses, value_sort_cmp);
17719 for (i = 0; i < vec_len (nses); i++)
17720 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17726 get_msg_id (vat_main_t * vam)
17731 if (unformat (vam->input, "%s", &name_and_crc))
17733 message_index = vl_api_get_msg_index (name_and_crc);
17734 if (message_index == ~0)
17736 print (vam->ofp, " '%s' not found", name_and_crc);
17739 print (vam->ofp, " '%s' has message index %d",
17740 name_and_crc, message_index);
17743 errmsg ("name_and_crc required...");
17748 search_node_table (vat_main_t * vam)
17750 unformat_input_t *line_input = vam->input;
17753 vlib_node_t *node, *next_node;
17756 if (vam->graph_node_index_by_name == 0)
17758 print (vam->ofp, "Node table empty, issue get_node_graph...");
17762 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17764 if (unformat (line_input, "%s", &node_to_find))
17766 vec_add1 (node_to_find, 0);
17767 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17770 print (vam->ofp, "%s not found...", node_to_find);
17773 node = vam->graph_nodes[p[0]];
17774 print (vam->ofp, "[%d] %s", p[0], node->name);
17775 for (j = 0; j < vec_len (node->next_nodes); j++)
17777 if (node->next_nodes[j] != ~0)
17779 next_node = vam->graph_nodes[node->next_nodes[j]];
17780 print (vam->ofp, " [%d] %s", j, next_node->name);
17787 clib_warning ("parse error '%U'", format_unformat_error,
17793 vec_free (node_to_find);
17802 script (vat_main_t * vam)
17804 #if (VPP_API_TEST_BUILTIN==0)
17806 char *save_current_file;
17807 unformat_input_t save_input;
17808 jmp_buf save_jump_buf;
17809 u32 save_line_number;
17811 FILE *new_fp, *save_ifp;
17813 if (unformat (vam->input, "%s", &s))
17815 new_fp = fopen ((char *) s, "r");
17818 errmsg ("Couldn't open script file %s", s);
17825 errmsg ("Missing script name");
17829 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17830 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17831 save_ifp = vam->ifp;
17832 save_line_number = vam->input_line_number;
17833 save_current_file = (char *) vam->current_file;
17835 vam->input_line_number = 0;
17837 vam->current_file = s;
17840 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17841 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17842 vam->ifp = save_ifp;
17843 vam->input_line_number = save_line_number;
17844 vam->current_file = (u8 *) save_current_file;
17849 clib_warning ("use the exec command...");
17855 echo (vat_main_t * vam)
17857 print (vam->ofp, "%v", vam->input->buffer);
17861 /* List of API message constructors, CLI names map to api_xxx */
17862 #define foreach_vpe_api_msg \
17863 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
17864 _(sw_interface_dump,"") \
17865 _(sw_interface_set_flags, \
17866 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17867 _(sw_interface_add_del_address, \
17868 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17869 _(sw_interface_set_table, \
17870 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17871 _(sw_interface_set_mpls_enable, \
17872 "<intfc> | sw_if_index [disable | dis]") \
17873 _(sw_interface_set_vpath, \
17874 "<intfc> | sw_if_index <id> enable | disable") \
17875 _(sw_interface_set_vxlan_bypass, \
17876 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
17877 _(sw_interface_set_l2_xconnect, \
17878 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17879 "enable | disable") \
17880 _(sw_interface_set_l2_bridge, \
17881 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17882 "[shg <split-horizon-group>] [bvi]\n" \
17883 "enable | disable") \
17884 _(bridge_domain_add_del, \
17885 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17886 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17888 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17890 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17892 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17894 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17896 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17898 "<vpp-if-name> | sw_if_index <id>") \
17899 _(sw_interface_tap_dump, "") \
17900 _(ip_add_del_route, \
17901 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17902 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17903 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17904 "[multipath] [count <n>]") \
17905 _(ip_mroute_add_del, \
17906 "<src> <grp>/<mask> [table-id <n>]\n" \
17907 "[<intfc> | sw_if_index <id>] [local] [del]") \
17908 _(mpls_route_add_del, \
17909 "<label> <eos> via <addr> [table-id <n>]\n" \
17910 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17911 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17912 "[multipath] [count <n>]") \
17913 _(mpls_ip_bind_unbind, \
17914 "<label> <addr/len>") \
17915 _(mpls_tunnel_add_del, \
17916 " via <addr> [table-id <n>]\n" \
17917 "sw_if_index <id>] [l2] [del]") \
17918 _(proxy_arp_add_del, \
17919 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17920 _(proxy_arp_intfc_enable_disable, \
17921 "<intfc> | sw_if_index <id> enable | disable") \
17922 _(sw_interface_set_unnumbered, \
17923 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17924 _(ip_neighbor_add_del, \
17925 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17926 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17927 _(reset_vrf, "vrf <id> [ipv6]") \
17928 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17929 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17930 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17931 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17932 "[outer_vlan_id_any][inner_vlan_id_any]") \
17933 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17934 _(reset_fib, "vrf <n> [ipv6]") \
17935 _(dhcp_proxy_config, \
17936 "svr <v46-address> src <v46-address>\n" \
17937 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
17938 _(dhcp_proxy_set_vss, \
17939 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17940 _(dhcp_proxy_dump, "ip6") \
17941 _(dhcp_client_config, \
17942 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17943 _(set_ip_flow_hash, \
17944 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17945 _(sw_interface_ip6_enable_disable, \
17946 "<intfc> | sw_if_index <id> enable | disable") \
17947 _(sw_interface_ip6_set_link_local_address, \
17948 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17949 _(sw_interface_ip6nd_ra_prefix, \
17950 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17951 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17952 "[nolink] [isno]") \
17953 _(sw_interface_ip6nd_ra_config, \
17954 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17955 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17956 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17957 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17958 _(l2_patch_add_del, \
17959 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17960 "enable | disable") \
17961 _(sr_localsid_add_del, \
17962 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
17963 "fib-table <num> (end.psp) sw_if_index <num>") \
17964 _(classify_add_del_table, \
17965 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17966 " [del] [del-chain] mask <mask-value>\n" \
17967 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17968 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17969 _(classify_add_del_session, \
17970 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17971 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17972 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17973 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17974 _(classify_set_interface_ip_table, \
17975 "<intfc> | sw_if_index <nn> table <nn>") \
17976 _(classify_set_interface_l2_tables, \
17977 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17978 " [other-table <nn>]") \
17979 _(get_node_index, "node <node-name") \
17980 _(add_node_next, "node <node-name> next <next-node-name>") \
17981 _(l2tpv3_create_tunnel, \
17982 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17983 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17984 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17985 _(l2tpv3_set_tunnel_cookies, \
17986 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17987 "[new_remote_cookie <nn>]\n") \
17988 _(l2tpv3_interface_enable_disable, \
17989 "<intfc> | sw_if_index <nn> enable | disable") \
17990 _(l2tpv3_set_lookup_key, \
17991 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17992 _(sw_if_l2tpv3_tunnel_dump, "") \
17993 _(vxlan_add_del_tunnel, \
17994 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17995 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17996 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17997 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17998 _(gre_add_del_tunnel, \
17999 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18000 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18001 _(l2_fib_clear_table, "") \
18002 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18003 _(l2_interface_vlan_tag_rewrite, \
18004 "<intfc> | sw_if_index <nn> \n" \
18005 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18006 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18007 _(create_vhost_user_if, \
18008 "socket <filename> [server] [renumber <dev_instance>] " \
18009 "[mac <mac_address>]") \
18010 _(modify_vhost_user_if, \
18011 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18012 "[server] [renumber <dev_instance>]") \
18013 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18014 _(sw_interface_vhost_user_dump, "") \
18015 _(show_version, "") \
18016 _(vxlan_gpe_add_del_tunnel, \
18017 "local <addr> remote <addr> vni <nn>\n" \
18018 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18019 "[next-ethernet] [next-nsh]\n") \
18020 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18021 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18022 _(interface_name_renumber, \
18023 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18024 _(input_acl_set_interface, \
18025 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18026 " [l2-table <nn>] [del]") \
18027 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18028 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18029 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18030 _(ip_dump, "ipv4 | ipv6") \
18031 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18032 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18034 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18035 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18036 " integ_alg <alg> integ_key <hex>") \
18037 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18038 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18039 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18040 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18041 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18042 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18043 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18044 "(auth_data 0x<data> | auth_data <data>)") \
18045 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18046 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18047 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18048 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18049 "(local|remote)") \
18050 _(ikev2_set_local_key, "file <absolute_file_path>") \
18051 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18052 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18053 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18054 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18055 _(ikev2_initiate_sa_init, "<profile_name>") \
18056 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18057 _(ikev2_initiate_del_child_sa, "<ispi>") \
18058 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18059 _(delete_loopback,"sw_if_index <nn>") \
18060 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18061 _(map_add_domain, \
18062 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18063 "ip6-src <ip6addr> " \
18064 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18065 _(map_del_domain, "index <n>") \
18066 _(map_add_del_rule, \
18067 "index <n> psid <n> dst <ip6addr> [del]") \
18068 _(map_domain_dump, "") \
18069 _(map_rule_dump, "index <map-domain>") \
18070 _(want_interface_events, "enable|disable") \
18071 _(want_stats,"enable|disable") \
18072 _(get_first_msg_id, "client <name>") \
18073 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18074 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18075 "fib-id <nn> [ip4][ip6][default]") \
18076 _(get_node_graph, " ") \
18077 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18078 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18079 _(ioam_disable, "") \
18080 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18081 " sw_if_index <sw_if_index> p <priority> " \
18082 "w <weight>] [del]") \
18083 _(one_add_del_locator, "locator-set <locator_name> " \
18084 "iface <intf> | sw_if_index <sw_if_index> " \
18085 "p <priority> w <weight> [del]") \
18086 _(one_add_del_local_eid,"vni <vni> eid " \
18087 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18088 "locator-set <locator_name> [del]" \
18089 "[key-id sha1|sha256 secret-key <secret-key>]")\
18090 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18091 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18092 _(one_enable_disable, "enable|disable") \
18093 _(one_map_register_enable_disable, "enable|disable") \
18094 _(one_rloc_probe_enable_disable, "enable|disable") \
18095 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18097 "rloc <locator> p <prio> " \
18098 "w <weight> [rloc <loc> ... ] " \
18099 "action <action> [del-all]") \
18100 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18102 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18103 _(one_map_request_mode, "src-dst|dst-only") \
18104 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18105 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18106 _(one_locator_set_dump, "[local | remote]") \
18107 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18108 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18109 "[local] | [remote]") \
18110 _(one_eid_table_vni_dump, "") \
18111 _(one_eid_table_map_dump, "l2|l3") \
18112 _(one_map_resolver_dump, "") \
18113 _(one_map_server_dump, "") \
18114 _(one_adjacencies_get, "vni <vni>") \
18115 _(show_one_rloc_probe_state, "") \
18116 _(show_one_map_register_state, "") \
18117 _(show_one_status, "") \
18118 _(one_get_map_request_itr_rlocs, "") \
18119 _(show_one_pitr, "") \
18120 _(show_one_map_request_mode, "") \
18121 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18122 " sw_if_index <sw_if_index> p <priority> " \
18123 "w <weight>] [del]") \
18124 _(lisp_add_del_locator, "locator-set <locator_name> " \
18125 "iface <intf> | sw_if_index <sw_if_index> " \
18126 "p <priority> w <weight> [del]") \
18127 _(lisp_add_del_local_eid,"vni <vni> eid " \
18128 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18129 "locator-set <locator_name> [del]" \
18130 "[key-id sha1|sha256 secret-key <secret-key>]") \
18131 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18132 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18133 _(lisp_enable_disable, "enable|disable") \
18134 _(lisp_map_register_enable_disable, "enable|disable") \
18135 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18136 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18138 "rloc <locator> p <prio> " \
18139 "w <weight> [rloc <loc> ... ] " \
18140 "action <action> [del-all]") \
18141 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18143 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18144 _(lisp_map_request_mode, "src-dst|dst-only") \
18145 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18146 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18147 _(lisp_locator_set_dump, "[local | remote]") \
18148 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18149 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18150 "[local] | [remote]") \
18151 _(lisp_eid_table_vni_dump, "") \
18152 _(lisp_eid_table_map_dump, "l2|l3") \
18153 _(lisp_map_resolver_dump, "") \
18154 _(lisp_map_server_dump, "") \
18155 _(lisp_adjacencies_get, "vni <vni>") \
18156 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18157 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18158 _(gpe_set_encap_mode, "lisp|vxlan") \
18159 _(gpe_get_encap_mode, "") \
18160 _(lisp_gpe_add_del_iface, "up|down") \
18161 _(lisp_gpe_enable_disable, "enable|disable") \
18162 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18163 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18164 _(show_lisp_rloc_probe_state, "") \
18165 _(show_lisp_map_register_state, "") \
18166 _(show_lisp_status, "") \
18167 _(lisp_get_map_request_itr_rlocs, "") \
18168 _(show_lisp_pitr, "") \
18169 _(show_lisp_map_request_mode, "") \
18170 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18171 _(af_packet_delete, "name <host interface name>") \
18172 _(policer_add_del, "name <policer name> <params> [del]") \
18173 _(policer_dump, "[name <policer name>]") \
18174 _(policer_classify_set_interface, \
18175 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18176 " [l2-table <nn>] [del]") \
18177 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18178 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18179 "[master|slave]") \
18180 _(netmap_delete, "name <interface name>") \
18181 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18182 _(mpls_fib_dump, "") \
18183 _(classify_table_ids, "") \
18184 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18185 _(classify_table_info, "table_id <nn>") \
18186 _(classify_session_dump, "table_id <nn>") \
18187 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18188 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18189 "[template_interval <nn>] [udp_checksum]") \
18190 _(ipfix_exporter_dump, "") \
18191 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18192 _(ipfix_classify_stream_dump, "") \
18193 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18194 _(ipfix_classify_table_dump, "") \
18195 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18196 _(sw_interface_span_dump, "") \
18197 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18198 _(pg_create_interface, "if_id <nn>") \
18199 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18200 _(pg_enable_disable, "[stream <id>] disable") \
18201 _(ip_source_and_port_range_check_add_del, \
18202 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18203 _(ip_source_and_port_range_check_interface_add_del, \
18204 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18205 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18206 _(ipsec_gre_add_del_tunnel, \
18207 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18208 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18209 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18210 _(l2_interface_pbb_tag_rewrite, \
18211 "<intfc> | sw_if_index <nn> \n" \
18212 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18213 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18214 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18215 _(flow_classify_set_interface, \
18216 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18217 _(flow_classify_dump, "type [ip4|ip6]") \
18218 _(ip_fib_dump, "") \
18219 _(ip_mfib_dump, "") \
18220 _(ip6_fib_dump, "") \
18221 _(ip6_mfib_dump, "") \
18222 _(feature_enable_disable, "arc_name <arc_name> " \
18223 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18224 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18226 _(l2_xconnect_dump, "") \
18227 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18228 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18229 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18231 /* List of command functions, CLI names map directly to functions */
18232 #define foreach_cli_function \
18233 _(comment, "usage: comment <ignore-rest-of-line>") \
18234 _(dump_interface_table, "usage: dump_interface_table") \
18235 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18236 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18237 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18238 _(dump_stats_table, "usage: dump_stats_table") \
18239 _(dump_macro_table, "usage: dump_macro_table ") \
18240 _(dump_node_table, "usage: dump_node_table") \
18241 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18242 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18243 _(echo, "usage: echo <message>") \
18244 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18245 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18246 _(help, "usage: help") \
18247 _(q, "usage: quit") \
18248 _(quit, "usage: quit") \
18249 _(search_node_table, "usage: search_node_table <name>...") \
18250 _(set, "usage: set <variable-name> <value>") \
18251 _(script, "usage: script <file-name>") \
18252 _(unset, "usage: unset <variable-name>")
18255 static void vl_api_##n##_t_handler_uni \
18256 (vl_api_##n##_t * mp) \
18258 vat_main_t * vam = &vat_main; \
18259 if (vam->json_output) { \
18260 vl_api_##n##_t_handler_json(mp); \
18262 vl_api_##n##_t_handler(mp); \
18265 foreach_vpe_api_reply_msg;
18266 #if VPP_API_TEST_BUILTIN == 0
18267 foreach_standalone_reply_msg;
18272 vat_api_hookup (vat_main_t * vam)
18275 vl_msg_api_set_handlers(VL_API_##N, #n, \
18276 vl_api_##n##_t_handler_uni, \
18278 vl_api_##n##_t_endian, \
18279 vl_api_##n##_t_print, \
18280 sizeof(vl_api_##n##_t), 1);
18281 foreach_vpe_api_reply_msg;
18282 #if VPP_API_TEST_BUILTIN == 0
18283 foreach_standalone_reply_msg;
18287 #if (VPP_API_TEST_BUILTIN==0)
18288 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18291 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18293 vam->function_by_name = hash_create_string (0, sizeof (uword));
18295 vam->help_by_name = hash_create_string (0, sizeof (uword));
18297 /* API messages we can send */
18298 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18299 foreach_vpe_api_msg;
18303 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18304 foreach_vpe_api_msg;
18307 /* CLI functions */
18308 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18309 foreach_cli_function;
18313 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18314 foreach_cli_function;
18318 #if VPP_API_TEST_BUILTIN
18319 static clib_error_t *
18320 vat_api_hookup_shim (vlib_main_t * vm)
18322 vat_api_hookup (&vat_main);
18326 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18330 * fd.io coding-style-patch-verification: ON
18333 * eval: (c-set-style "gnu")