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_event_t_handler
976 (vl_api_sw_interface_event_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_event_t_handler_json
988 (vl_api_sw_interface_event_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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
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 = uword_to_pointer (mp->reply_in_shmem, u8 *);
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: pid %d address %U new mac %U sw_if_index %d\n",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 ntohl (mp->pid), 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: pid %d address %U new mac %U sw_if_index %d\n",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 ntohl (mp->pid), 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 vl_api_l2_macs_event_t_handler (vl_api_l2_macs_event_t * mp)
1289 u32 n_macs = ntohl (mp->n_macs);
1290 errmsg ("L2MAC event recived with pid %d cl-idx %d for %d macs: \n",
1291 ntohl (mp->pid), mp->client_index, n_macs);
1293 for (i = 0; i < n_macs; i++)
1295 vl_api_mac_entry_t *mac = &mp->mac[i];
1296 errmsg (" [%d] sw_if_index %d mac_addr %U is_del %d \n",
1297 i + 1, ntohl (mac->sw_if_index),
1298 format_ethernet_address, mac->mac_addr, mac->is_del);
1305 vl_api_l2_macs_event_t_handler_json (vl_api_l2_macs_event_t * mp)
1307 /* JSON output not supported */
1310 #define vl_api_bridge_domain_details_t_endian vl_noop_handler
1311 #define vl_api_bridge_domain_details_t_print vl_noop_handler
1314 * Special-case: build the bridge domain table, maintain
1315 * the next bd id vbl.
1317 static void vl_api_bridge_domain_details_t_handler
1318 (vl_api_bridge_domain_details_t * mp)
1320 vat_main_t *vam = &vat_main;
1321 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1324 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1325 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1327 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1328 ntohl (mp->bd_id), mp->learn, mp->forward,
1329 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1333 vl_api_bridge_domain_sw_if_t *sw_ifs;
1334 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG",
1337 sw_ifs = mp->sw_if_details;
1338 for (i = 0; i < n_sw_ifs; i++)
1344 sw_if_index = ntohl (sw_ifs->sw_if_index);
1347 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1349 if ((u32) p->value[0] == sw_if_index)
1351 sw_if_name = (u8 *)(p->key);
1356 print (vam->ofp, "%7d %3d %s", sw_if_index,
1357 sw_ifs->shg, sw_if_name ? (char *) sw_if_name :
1358 "sw_if_index not found!");
1365 static void vl_api_bridge_domain_details_t_handler_json
1366 (vl_api_bridge_domain_details_t * mp)
1368 vat_main_t *vam = &vat_main;
1369 vat_json_node_t *node, *array = NULL;
1370 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1372 if (VAT_JSON_ARRAY != vam->json_tree.type)
1374 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1375 vat_json_init_array (&vam->json_tree);
1377 node = vat_json_array_add (&vam->json_tree);
1379 vat_json_init_object (node);
1380 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1381 vat_json_object_add_uint (node, "flood", mp->flood);
1382 vat_json_object_add_uint (node, "forward", mp->forward);
1383 vat_json_object_add_uint (node, "learn", mp->learn);
1384 vat_json_object_add_uint (node, "bvi_sw_if_index",
1385 ntohl (mp->bvi_sw_if_index));
1386 vat_json_object_add_uint (node, "n_sw_ifs", n_sw_ifs);
1387 array = vat_json_object_add (node, "sw_if");
1388 vat_json_init_array (array);
1394 vl_api_bridge_domain_sw_if_t *sw_ifs;
1397 sw_ifs = mp->sw_if_details;
1398 for (i = 0; i < n_sw_ifs; i++)
1400 node = vat_json_array_add (array);
1401 vat_json_init_object (node);
1402 vat_json_object_add_uint (node, "sw_if_index",
1403 ntohl (sw_ifs->sw_if_index));
1404 vat_json_object_add_uint (node, "shg", sw_ifs->shg);
1410 static void vl_api_control_ping_reply_t_handler
1411 (vl_api_control_ping_reply_t * mp)
1413 vat_main_t *vam = &vat_main;
1414 i32 retval = ntohl (mp->retval);
1415 if (vam->async_mode)
1417 vam->async_errors += (retval < 0);
1421 vam->retval = retval;
1422 vam->result_ready = 1;
1426 static void vl_api_control_ping_reply_t_handler_json
1427 (vl_api_control_ping_reply_t * mp)
1429 vat_main_t *vam = &vat_main;
1430 i32 retval = ntohl (mp->retval);
1432 if (VAT_JSON_NONE != vam->json_tree.type)
1434 vat_json_print (vam->ofp, &vam->json_tree);
1435 vat_json_free (&vam->json_tree);
1436 vam->json_tree.type = VAT_JSON_NONE;
1441 vat_json_init_array (&vam->json_tree);
1442 vat_json_print (vam->ofp, &vam->json_tree);
1443 vam->json_tree.type = VAT_JSON_NONE;
1446 vam->retval = retval;
1447 vam->result_ready = 1;
1451 vl_api_bridge_domain_set_mac_age_reply_t_handler
1452 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1454 vat_main_t *vam = &vat_main;
1455 i32 retval = ntohl (mp->retval);
1456 if (vam->async_mode)
1458 vam->async_errors += (retval < 0);
1462 vam->retval = retval;
1463 vam->result_ready = 1;
1467 static void vl_api_bridge_domain_set_mac_age_reply_t_handler_json
1468 (vl_api_bridge_domain_set_mac_age_reply_t * mp)
1470 vat_main_t *vam = &vat_main;
1471 vat_json_node_t node;
1473 vat_json_init_object (&node);
1474 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1476 vat_json_print (vam->ofp, &node);
1477 vat_json_free (&node);
1479 vam->retval = ntohl (mp->retval);
1480 vam->result_ready = 1;
1484 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1486 vat_main_t *vam = &vat_main;
1487 i32 retval = ntohl (mp->retval);
1488 if (vam->async_mode)
1490 vam->async_errors += (retval < 0);
1494 vam->retval = retval;
1495 vam->result_ready = 1;
1499 static void vl_api_l2_flags_reply_t_handler_json
1500 (vl_api_l2_flags_reply_t * mp)
1502 vat_main_t *vam = &vat_main;
1503 vat_json_node_t node;
1505 vat_json_init_object (&node);
1506 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1507 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1508 ntohl (mp->resulting_feature_bitmap));
1510 vat_json_print (vam->ofp, &node);
1511 vat_json_free (&node);
1513 vam->retval = ntohl (mp->retval);
1514 vam->result_ready = 1;
1517 static void vl_api_bridge_flags_reply_t_handler
1518 (vl_api_bridge_flags_reply_t * mp)
1520 vat_main_t *vam = &vat_main;
1521 i32 retval = ntohl (mp->retval);
1522 if (vam->async_mode)
1524 vam->async_errors += (retval < 0);
1528 vam->retval = retval;
1529 vam->result_ready = 1;
1533 static void vl_api_bridge_flags_reply_t_handler_json
1534 (vl_api_bridge_flags_reply_t * mp)
1536 vat_main_t *vam = &vat_main;
1537 vat_json_node_t node;
1539 vat_json_init_object (&node);
1540 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1541 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1542 ntohl (mp->resulting_feature_bitmap));
1544 vat_json_print (vam->ofp, &node);
1545 vat_json_free (&node);
1547 vam->retval = ntohl (mp->retval);
1548 vam->result_ready = 1;
1551 static void vl_api_tap_connect_reply_t_handler
1552 (vl_api_tap_connect_reply_t * mp)
1554 vat_main_t *vam = &vat_main;
1555 i32 retval = ntohl (mp->retval);
1556 if (vam->async_mode)
1558 vam->async_errors += (retval < 0);
1562 vam->retval = retval;
1563 vam->sw_if_index = ntohl (mp->sw_if_index);
1564 vam->result_ready = 1;
1569 static void vl_api_tap_connect_reply_t_handler_json
1570 (vl_api_tap_connect_reply_t * mp)
1572 vat_main_t *vam = &vat_main;
1573 vat_json_node_t node;
1575 vat_json_init_object (&node);
1576 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1577 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1579 vat_json_print (vam->ofp, &node);
1580 vat_json_free (&node);
1582 vam->retval = ntohl (mp->retval);
1583 vam->result_ready = 1;
1588 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1590 vat_main_t *vam = &vat_main;
1591 i32 retval = ntohl (mp->retval);
1592 if (vam->async_mode)
1594 vam->async_errors += (retval < 0);
1598 vam->retval = retval;
1599 vam->sw_if_index = ntohl (mp->sw_if_index);
1600 vam->result_ready = 1;
1604 static void vl_api_tap_modify_reply_t_handler_json
1605 (vl_api_tap_modify_reply_t * mp)
1607 vat_main_t *vam = &vat_main;
1608 vat_json_node_t node;
1610 vat_json_init_object (&node);
1611 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1612 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1614 vat_json_print (vam->ofp, &node);
1615 vat_json_free (&node);
1617 vam->retval = ntohl (mp->retval);
1618 vam->result_ready = 1;
1622 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1624 vat_main_t *vam = &vat_main;
1625 i32 retval = ntohl (mp->retval);
1626 if (vam->async_mode)
1628 vam->async_errors += (retval < 0);
1632 vam->retval = retval;
1633 vam->result_ready = 1;
1637 static void vl_api_tap_delete_reply_t_handler_json
1638 (vl_api_tap_delete_reply_t * mp)
1640 vat_main_t *vam = &vat_main;
1641 vat_json_node_t node;
1643 vat_json_init_object (&node);
1644 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1646 vat_json_print (vam->ofp, &node);
1647 vat_json_free (&node);
1649 vam->retval = ntohl (mp->retval);
1650 vam->result_ready = 1;
1653 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1654 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1656 vat_main_t *vam = &vat_main;
1657 i32 retval = ntohl (mp->retval);
1658 if (vam->async_mode)
1660 vam->async_errors += (retval < 0);
1664 vam->retval = retval;
1665 vam->result_ready = 1;
1669 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1670 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1672 vat_main_t *vam = &vat_main;
1673 vat_json_node_t node;
1675 vat_json_init_object (&node);
1676 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1677 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1678 ntohl (mp->sw_if_index));
1680 vat_json_print (vam->ofp, &node);
1681 vat_json_free (&node);
1683 vam->retval = ntohl (mp->retval);
1684 vam->result_ready = 1;
1687 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1688 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1690 vat_main_t *vam = &vat_main;
1691 i32 retval = ntohl (mp->retval);
1692 if (vam->async_mode)
1694 vam->async_errors += (retval < 0);
1698 vam->retval = retval;
1699 vam->sw_if_index = ntohl (mp->sw_if_index);
1700 vam->result_ready = 1;
1704 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1705 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1707 vat_main_t *vam = &vat_main;
1708 vat_json_node_t node;
1710 vat_json_init_object (&node);
1711 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1712 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1714 vat_json_print (vam->ofp, &node);
1715 vat_json_free (&node);
1717 vam->retval = ntohl (mp->retval);
1718 vam->result_ready = 1;
1721 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler
1722 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1724 vat_main_t *vam = &vat_main;
1725 i32 retval = ntohl (mp->retval);
1726 if (vam->async_mode)
1728 vam->async_errors += (retval < 0);
1732 vam->retval = retval;
1733 vam->result_ready = 1;
1737 static void vl_api_gpe_add_del_fwd_entry_reply_t_handler_json
1738 (vl_api_gpe_add_del_fwd_entry_reply_t * mp)
1740 vat_main_t *vam = &vat_main;
1741 vat_json_node_t node;
1743 vat_json_init_object (&node);
1744 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1745 vat_json_object_add_uint (&node, "fwd_entry_index",
1746 clib_net_to_host_u32 (mp->fwd_entry_index));
1748 vat_json_print (vam->ofp, &node);
1749 vat_json_free (&node);
1751 vam->retval = ntohl (mp->retval);
1752 vam->result_ready = 1;
1755 static void vl_api_one_add_del_locator_set_reply_t_handler
1756 (vl_api_one_add_del_locator_set_reply_t * mp)
1758 vat_main_t *vam = &vat_main;
1759 i32 retval = ntohl (mp->retval);
1760 if (vam->async_mode)
1762 vam->async_errors += (retval < 0);
1766 vam->retval = retval;
1767 vam->result_ready = 1;
1771 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1772 (vl_api_one_add_del_locator_set_reply_t * mp)
1774 vat_main_t *vam = &vat_main;
1775 vat_json_node_t node;
1777 vat_json_init_object (&node);
1778 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1779 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1781 vat_json_print (vam->ofp, &node);
1782 vat_json_free (&node);
1784 vam->retval = ntohl (mp->retval);
1785 vam->result_ready = 1;
1788 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1789 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1791 vat_main_t *vam = &vat_main;
1792 i32 retval = ntohl (mp->retval);
1793 if (vam->async_mode)
1795 vam->async_errors += (retval < 0);
1799 vam->retval = retval;
1800 vam->sw_if_index = ntohl (mp->sw_if_index);
1801 vam->result_ready = 1;
1805 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1806 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1808 vat_main_t *vam = &vat_main;
1809 vat_json_node_t node;
1811 vat_json_init_object (&node);
1812 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1813 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1815 vat_json_print (vam->ofp, &node);
1816 vat_json_free (&node);
1818 vam->retval = ntohl (mp->retval);
1819 vam->result_ready = 1;
1822 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler
1823 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1825 vat_main_t *vam = &vat_main;
1826 i32 retval = ntohl (mp->retval);
1827 if (vam->async_mode)
1829 vam->async_errors += (retval < 0);
1833 vam->retval = retval;
1834 vam->sw_if_index = ntohl (mp->sw_if_index);
1835 vam->result_ready = 1;
1839 static void vl_api_vxlan_gpe_add_del_tunnel_reply_t_handler_json
1840 (vl_api_vxlan_gpe_add_del_tunnel_reply_t * mp)
1842 vat_main_t *vam = &vat_main;
1843 vat_json_node_t node;
1845 vat_json_init_object (&node);
1846 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1847 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1849 vat_json_print (vam->ofp, &node);
1850 vat_json_free (&node);
1852 vam->retval = ntohl (mp->retval);
1853 vam->result_ready = 1;
1856 static void vl_api_gre_add_del_tunnel_reply_t_handler
1857 (vl_api_gre_add_del_tunnel_reply_t * mp)
1859 vat_main_t *vam = &vat_main;
1860 i32 retval = ntohl (mp->retval);
1861 if (vam->async_mode)
1863 vam->async_errors += (retval < 0);
1867 vam->retval = retval;
1868 vam->sw_if_index = ntohl (mp->sw_if_index);
1869 vam->result_ready = 1;
1873 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1874 (vl_api_gre_add_del_tunnel_reply_t * mp)
1876 vat_main_t *vam = &vat_main;
1877 vat_json_node_t node;
1879 vat_json_init_object (&node);
1880 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1881 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1883 vat_json_print (vam->ofp, &node);
1884 vat_json_free (&node);
1886 vam->retval = ntohl (mp->retval);
1887 vam->result_ready = 1;
1890 static void vl_api_create_vhost_user_if_reply_t_handler
1891 (vl_api_create_vhost_user_if_reply_t * mp)
1893 vat_main_t *vam = &vat_main;
1894 i32 retval = ntohl (mp->retval);
1895 if (vam->async_mode)
1897 vam->async_errors += (retval < 0);
1901 vam->retval = retval;
1902 vam->sw_if_index = ntohl (mp->sw_if_index);
1903 vam->result_ready = 1;
1907 static void vl_api_create_vhost_user_if_reply_t_handler_json
1908 (vl_api_create_vhost_user_if_reply_t * mp)
1910 vat_main_t *vam = &vat_main;
1911 vat_json_node_t node;
1913 vat_json_init_object (&node);
1914 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1915 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1917 vat_json_print (vam->ofp, &node);
1918 vat_json_free (&node);
1920 vam->retval = ntohl (mp->retval);
1921 vam->result_ready = 1;
1924 static void vl_api_ip_address_details_t_handler
1925 (vl_api_ip_address_details_t * mp)
1927 vat_main_t *vam = &vat_main;
1928 static ip_address_details_t empty_ip_address_details = { {0} };
1929 ip_address_details_t *address = NULL;
1930 ip_details_t *current_ip_details = NULL;
1931 ip_details_t *details = NULL;
1933 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1935 if (!details || vam->current_sw_if_index >= vec_len (details)
1936 || !details[vam->current_sw_if_index].present)
1938 errmsg ("ip address details arrived but not stored");
1939 errmsg ("ip_dump should be called first");
1943 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1945 #define addresses (current_ip_details->addr)
1947 vec_validate_init_empty (addresses, vec_len (addresses),
1948 empty_ip_address_details);
1950 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1952 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1953 address->prefix_length = mp->prefix_length;
1957 static void vl_api_ip_address_details_t_handler_json
1958 (vl_api_ip_address_details_t * mp)
1960 vat_main_t *vam = &vat_main;
1961 vat_json_node_t *node = NULL;
1962 struct in6_addr ip6;
1965 if (VAT_JSON_ARRAY != vam->json_tree.type)
1967 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1968 vat_json_init_array (&vam->json_tree);
1970 node = vat_json_array_add (&vam->json_tree);
1972 vat_json_init_object (node);
1975 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1976 vat_json_object_add_ip6 (node, "ip", ip6);
1980 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1981 vat_json_object_add_ip4 (node, "ip", ip4);
1983 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1987 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1989 vat_main_t *vam = &vat_main;
1990 static ip_details_t empty_ip_details = { 0 };
1991 ip_details_t *ip = NULL;
1992 u32 sw_if_index = ~0;
1994 sw_if_index = ntohl (mp->sw_if_index);
1996 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1997 sw_if_index, empty_ip_details);
1999 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
2006 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
2008 vat_main_t *vam = &vat_main;
2010 if (VAT_JSON_ARRAY != vam->json_tree.type)
2012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2013 vat_json_init_array (&vam->json_tree);
2015 vat_json_array_add_uint (&vam->json_tree,
2016 clib_net_to_host_u32 (mp->sw_if_index));
2019 static void vl_api_map_domain_details_t_handler_json
2020 (vl_api_map_domain_details_t * mp)
2022 vat_json_node_t *node = NULL;
2023 vat_main_t *vam = &vat_main;
2024 struct in6_addr ip6;
2027 if (VAT_JSON_ARRAY != vam->json_tree.type)
2029 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2030 vat_json_init_array (&vam->json_tree);
2033 node = vat_json_array_add (&vam->json_tree);
2034 vat_json_init_object (node);
2036 vat_json_object_add_uint (node, "domain_index",
2037 clib_net_to_host_u32 (mp->domain_index));
2038 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
2039 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
2040 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
2041 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
2042 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
2043 vat_json_object_add_ip6 (node, "ip6_src", ip6);
2044 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
2045 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
2046 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
2047 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
2048 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
2049 vat_json_object_add_int (node, "psid_length", mp->psid_length);
2050 vat_json_object_add_uint (node, "flags", mp->flags);
2051 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
2052 vat_json_object_add_int (node, "is_translation", mp->is_translation);
2055 static void vl_api_map_domain_details_t_handler
2056 (vl_api_map_domain_details_t * mp)
2058 vat_main_t *vam = &vat_main;
2060 if (mp->is_translation)
2063 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
2064 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2065 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2066 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
2067 clib_net_to_host_u32 (mp->domain_index));
2072 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
2073 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
2074 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
2075 format_ip6_address, mp->ip6_src,
2076 clib_net_to_host_u32 (mp->domain_index));
2078 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
2079 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
2080 mp->is_translation ? "map-t" : "");
2083 static void vl_api_map_rule_details_t_handler_json
2084 (vl_api_map_rule_details_t * mp)
2086 struct in6_addr ip6;
2087 vat_json_node_t *node = NULL;
2088 vat_main_t *vam = &vat_main;
2090 if (VAT_JSON_ARRAY != vam->json_tree.type)
2092 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2093 vat_json_init_array (&vam->json_tree);
2096 node = vat_json_array_add (&vam->json_tree);
2097 vat_json_init_object (node);
2099 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
2100 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
2101 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
2105 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
2107 vat_main_t *vam = &vat_main;
2108 print (vam->ofp, " %d (psid) %U (ip6-dst)",
2109 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
2113 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
2115 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
2116 "router_addr %U host_mac %U",
2117 ntohl (mp->pid), mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
2118 format_ip4_address, &mp->host_address,
2119 format_ip4_address, &mp->router_address,
2120 format_ethernet_address, mp->host_mac);
2123 static void vl_api_dhcp_compl_event_t_handler_json
2124 (vl_api_dhcp_compl_event_t * mp)
2126 /* JSON output not supported */
2130 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2133 vat_main_t *vam = &vat_main;
2134 static u64 default_counter = 0;
2136 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2138 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2139 sw_if_index, default_counter);
2140 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2144 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2145 interface_counter_t counter)
2147 vat_main_t *vam = &vat_main;
2148 static interface_counter_t default_counter = { 0, };
2150 vec_validate_init_empty (vam->combined_interface_counters,
2151 vnet_counter_type, NULL);
2152 vec_validate_init_empty (vam->combined_interface_counters
2153 [vnet_counter_type], sw_if_index, default_counter);
2154 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2157 static void vl_api_vnet_interface_simple_counters_t_handler
2158 (vl_api_vnet_interface_simple_counters_t * mp)
2163 static void vl_api_vnet_interface_combined_counters_t_handler
2164 (vl_api_vnet_interface_combined_counters_t * mp)
2169 static void vl_api_vnet_interface_simple_counters_t_handler_json
2170 (vl_api_vnet_interface_simple_counters_t * mp)
2175 u32 first_sw_if_index;
2178 count = ntohl (mp->count);
2179 first_sw_if_index = ntohl (mp->first_sw_if_index);
2181 v_packets = (u64 *) & mp->data;
2182 for (i = 0; i < count; i++)
2184 packets = clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2185 set_simple_interface_counter (mp->vnet_counter_type,
2186 first_sw_if_index + i, packets);
2191 static void vl_api_vnet_interface_combined_counters_t_handler_json
2192 (vl_api_vnet_interface_combined_counters_t * mp)
2194 interface_counter_t counter;
2196 u32 first_sw_if_index;
2200 count = ntohl (mp->count);
2201 first_sw_if_index = ntohl (mp->first_sw_if_index);
2203 v = (vlib_counter_t *) & mp->data;
2204 for (i = 0; i < count; i++)
2207 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2209 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2210 set_combined_interface_counter (mp->vnet_counter_type,
2211 first_sw_if_index + i, counter);
2217 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2219 vat_main_t *vam = &vat_main;
2222 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2224 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2233 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2235 vat_main_t *vam = &vat_main;
2238 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2240 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2248 static void vl_api_vnet_ip4_fib_counters_t_handler
2249 (vl_api_vnet_ip4_fib_counters_t * mp)
2254 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2255 (vl_api_vnet_ip4_fib_counters_t * mp)
2257 vat_main_t *vam = &vat_main;
2258 vl_api_ip4_fib_counter_t *v;
2259 ip4_fib_counter_t *counter;
2266 vrf_id = ntohl (mp->vrf_id);
2267 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2268 if (~0 == vrf_index)
2270 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2271 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2272 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2273 vec_validate (vam->ip4_fib_counters, vrf_index);
2274 vam->ip4_fib_counters[vrf_index] = NULL;
2277 vec_free (vam->ip4_fib_counters[vrf_index]);
2278 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2279 count = ntohl (mp->count);
2280 for (i = 0; i < count; i++)
2282 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2283 counter = &vam->ip4_fib_counters[vrf_index][i];
2284 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2285 counter->address = ip4;
2286 counter->address_length = v->address_length;
2287 counter->packets = clib_net_to_host_u64 (v->packets);
2288 counter->bytes = clib_net_to_host_u64 (v->bytes);
2293 static void vl_api_vnet_ip4_nbr_counters_t_handler
2294 (vl_api_vnet_ip4_nbr_counters_t * mp)
2299 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2300 (vl_api_vnet_ip4_nbr_counters_t * mp)
2302 vat_main_t *vam = &vat_main;
2303 vl_api_ip4_nbr_counter_t *v;
2304 ip4_nbr_counter_t *counter;
2309 sw_if_index = ntohl (mp->sw_if_index);
2310 count = ntohl (mp->count);
2311 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2314 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2316 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2317 for (i = 0; i < count; i++)
2319 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2320 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2321 counter->address.s_addr = v->address;
2322 counter->packets = clib_net_to_host_u64 (v->packets);
2323 counter->bytes = clib_net_to_host_u64 (v->bytes);
2324 counter->linkt = v->link_type;
2329 static void vl_api_vnet_ip6_fib_counters_t_handler
2330 (vl_api_vnet_ip6_fib_counters_t * mp)
2335 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2336 (vl_api_vnet_ip6_fib_counters_t * mp)
2338 vat_main_t *vam = &vat_main;
2339 vl_api_ip6_fib_counter_t *v;
2340 ip6_fib_counter_t *counter;
2341 struct in6_addr ip6;
2347 vrf_id = ntohl (mp->vrf_id);
2348 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2349 if (~0 == vrf_index)
2351 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2352 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2353 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2354 vec_validate (vam->ip6_fib_counters, vrf_index);
2355 vam->ip6_fib_counters[vrf_index] = NULL;
2358 vec_free (vam->ip6_fib_counters[vrf_index]);
2359 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2360 count = ntohl (mp->count);
2361 for (i = 0; i < count; i++)
2363 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2364 counter = &vam->ip6_fib_counters[vrf_index][i];
2365 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2366 counter->address = ip6;
2367 counter->address_length = v->address_length;
2368 counter->packets = clib_net_to_host_u64 (v->packets);
2369 counter->bytes = clib_net_to_host_u64 (v->bytes);
2374 static void vl_api_vnet_ip6_nbr_counters_t_handler
2375 (vl_api_vnet_ip6_nbr_counters_t * mp)
2380 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2381 (vl_api_vnet_ip6_nbr_counters_t * mp)
2383 vat_main_t *vam = &vat_main;
2384 vl_api_ip6_nbr_counter_t *v;
2385 ip6_nbr_counter_t *counter;
2386 struct in6_addr ip6;
2391 sw_if_index = ntohl (mp->sw_if_index);
2392 count = ntohl (mp->count);
2393 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2396 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2398 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2399 for (i = 0; i < count; i++)
2401 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2402 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2403 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2404 counter->address = ip6;
2405 counter->packets = clib_net_to_host_u64 (v->packets);
2406 counter->bytes = clib_net_to_host_u64 (v->bytes);
2411 static void vl_api_get_first_msg_id_reply_t_handler
2412 (vl_api_get_first_msg_id_reply_t * mp)
2414 vat_main_t *vam = &vat_main;
2415 i32 retval = ntohl (mp->retval);
2417 if (vam->async_mode)
2419 vam->async_errors += (retval < 0);
2423 vam->retval = retval;
2424 vam->result_ready = 1;
2428 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2432 static void vl_api_get_first_msg_id_reply_t_handler_json
2433 (vl_api_get_first_msg_id_reply_t * mp)
2435 vat_main_t *vam = &vat_main;
2436 vat_json_node_t node;
2438 vat_json_init_object (&node);
2439 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2440 vat_json_object_add_uint (&node, "first_msg_id",
2441 (uint) ntohs (mp->first_msg_id));
2443 vat_json_print (vam->ofp, &node);
2444 vat_json_free (&node);
2446 vam->retval = ntohl (mp->retval);
2447 vam->result_ready = 1;
2450 static void vl_api_get_node_graph_reply_t_handler
2451 (vl_api_get_node_graph_reply_t * mp)
2453 vat_main_t *vam = &vat_main;
2454 api_main_t *am = &api_main;
2455 i32 retval = ntohl (mp->retval);
2456 u8 *pvt_copy, *reply;
2461 if (vam->async_mode)
2463 vam->async_errors += (retval < 0);
2467 vam->retval = retval;
2468 vam->result_ready = 1;
2471 /* "Should never happen..." */
2475 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2476 pvt_copy = vec_dup (reply);
2478 /* Toss the shared-memory original... */
2479 pthread_mutex_lock (&am->vlib_rp->mutex);
2480 oldheap = svm_push_data_heap (am->vlib_rp);
2484 svm_pop_heap (oldheap);
2485 pthread_mutex_unlock (&am->vlib_rp->mutex);
2487 if (vam->graph_nodes)
2489 hash_free (vam->graph_node_index_by_name);
2491 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2493 node = vam->graph_nodes[i];
2494 vec_free (node->name);
2495 vec_free (node->next_nodes);
2498 vec_free (vam->graph_nodes);
2501 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2502 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2503 vec_free (pvt_copy);
2505 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2507 node = vam->graph_nodes[i];
2508 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2512 static void vl_api_get_node_graph_reply_t_handler_json
2513 (vl_api_get_node_graph_reply_t * mp)
2515 vat_main_t *vam = &vat_main;
2516 api_main_t *am = &api_main;
2518 vat_json_node_t node;
2521 /* $$$$ make this real? */
2522 vat_json_init_object (&node);
2523 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2524 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2526 reply = uword_to_pointer (mp->reply_in_shmem, u8 *);
2528 /* Toss the shared-memory original... */
2529 pthread_mutex_lock (&am->vlib_rp->mutex);
2530 oldheap = svm_push_data_heap (am->vlib_rp);
2534 svm_pop_heap (oldheap);
2535 pthread_mutex_unlock (&am->vlib_rp->mutex);
2537 vat_json_print (vam->ofp, &node);
2538 vat_json_free (&node);
2540 vam->retval = ntohl (mp->retval);
2541 vam->result_ready = 1;
2545 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2547 vat_main_t *vam = &vat_main;
2552 s = format (s, "%=16d%=16d%=16d",
2553 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2557 s = format (s, "%=16U%=16d%=16d",
2558 mp->is_ipv6 ? format_ip6_address :
2560 mp->ip_address, mp->priority, mp->weight);
2563 print (vam->ofp, "%v", s);
2568 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2570 vat_main_t *vam = &vat_main;
2571 vat_json_node_t *node = NULL;
2572 struct in6_addr ip6;
2575 if (VAT_JSON_ARRAY != vam->json_tree.type)
2577 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2578 vat_json_init_array (&vam->json_tree);
2580 node = vat_json_array_add (&vam->json_tree);
2581 vat_json_init_object (node);
2583 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2584 vat_json_object_add_uint (node, "priority", mp->priority);
2585 vat_json_object_add_uint (node, "weight", mp->weight);
2588 vat_json_object_add_uint (node, "sw_if_index",
2589 clib_net_to_host_u32 (mp->sw_if_index));
2594 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2595 vat_json_object_add_ip6 (node, "address", ip6);
2599 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2600 vat_json_object_add_ip4 (node, "address", ip4);
2606 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2609 vat_main_t *vam = &vat_main;
2612 ls_name = format (0, "%s", mp->ls_name);
2614 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2620 vl_api_one_locator_set_details_t_handler_json
2621 (vl_api_one_locator_set_details_t * mp)
2623 vat_main_t *vam = &vat_main;
2624 vat_json_node_t *node = 0;
2627 ls_name = format (0, "%s", mp->ls_name);
2628 vec_add1 (ls_name, 0);
2630 if (VAT_JSON_ARRAY != vam->json_tree.type)
2632 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2633 vat_json_init_array (&vam->json_tree);
2635 node = vat_json_array_add (&vam->json_tree);
2637 vat_json_init_object (node);
2638 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2639 vat_json_object_add_uint (node, "ls_index",
2640 clib_net_to_host_u32 (mp->ls_index));
2648 } __attribute__ ((__packed__)) lisp_nsh_api_t;
2651 unformat_nsh_address (unformat_input_t * input, va_list * args)
2653 lisp_nsh_api_t *nsh = va_arg (*args, lisp_nsh_api_t *);
2654 return unformat (input, "SPI:%d SI:%d", &nsh->spi, &nsh->si);
2658 format_nsh_address_vat (u8 * s, va_list * args)
2660 nsh_t *a = va_arg (*args, nsh_t *);
2661 return format (s, "SPI:%d SI:%d", clib_net_to_host_u32 (a->spi), a->si);
2665 format_lisp_flat_eid (u8 * s, va_list * args)
2667 u32 type = va_arg (*args, u32);
2668 u8 *eid = va_arg (*args, u8 *);
2669 u32 eid_len = va_arg (*args, u32);
2674 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2676 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2678 return format (s, "%U", format_ethernet_address, eid);
2680 return format (s, "%U", format_nsh_address_vat, eid);
2686 format_lisp_eid_vat (u8 * s, va_list * args)
2688 u32 type = va_arg (*args, u32);
2689 u8 *eid = va_arg (*args, u8 *);
2690 u32 eid_len = va_arg (*args, u32);
2691 u8 *seid = va_arg (*args, u8 *);
2692 u32 seid_len = va_arg (*args, u32);
2693 u32 is_src_dst = va_arg (*args, u32);
2696 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2698 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2704 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2706 vat_main_t *vam = &vat_main;
2707 u8 *s = 0, *eid = 0;
2709 if (~0 == mp->locator_set_index)
2710 s = format (0, "action: %d", mp->action);
2712 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2714 eid = format (0, "%U", format_lisp_eid_vat,
2718 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2721 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2722 clib_net_to_host_u32 (mp->vni),
2724 mp->is_local ? "local" : "remote",
2725 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2726 clib_net_to_host_u16 (mp->key_id), mp->key);
2733 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2736 vat_main_t *vam = &vat_main;
2737 vat_json_node_t *node = 0;
2740 if (VAT_JSON_ARRAY != vam->json_tree.type)
2742 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2743 vat_json_init_array (&vam->json_tree);
2745 node = vat_json_array_add (&vam->json_tree);
2747 vat_json_init_object (node);
2748 if (~0 == mp->locator_set_index)
2749 vat_json_object_add_uint (node, "action", mp->action);
2751 vat_json_object_add_uint (node, "locator_set_index",
2752 clib_net_to_host_u32 (mp->locator_set_index));
2754 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2755 if (mp->eid_type == 3)
2757 vat_json_node_t *nsh_json = vat_json_object_add (node, "eid");
2758 vat_json_init_object (nsh_json);
2759 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) mp->eid;
2760 vat_json_object_add_uint (nsh_json, "spi",
2761 clib_net_to_host_u32 (nsh->spi));
2762 vat_json_object_add_uint (nsh_json, "si", nsh->si);
2766 eid = format (0, "%U", format_lisp_eid_vat,
2770 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2772 vat_json_object_add_string_copy (node, "eid", eid);
2775 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2776 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2777 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2781 vat_json_object_add_uint (node, "key_id",
2782 clib_net_to_host_u16 (mp->key_id));
2783 vat_json_object_add_string_copy (node, "key", mp->key);
2788 vl_api_one_stats_details_t_handler (vl_api_one_stats_details_t * mp)
2790 vat_main_t *vam = &vat_main;
2791 u8 *seid = 0, *deid = 0;
2792 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2794 deid = format (0, "%U", format_lisp_eid_vat,
2795 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2797 seid = format (0, "%U", format_lisp_eid_vat,
2798 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2804 format_ip_address_fcn = format_ip4_address;
2806 format_ip_address_fcn = format_ip6_address;
2809 print (vam->ofp, "([%d] %s %s) (%U %U) %u %u",
2810 clib_net_to_host_u32 (mp->vni),
2812 format_ip_address_fcn, mp->lloc,
2813 format_ip_address_fcn, mp->rloc,
2814 clib_net_to_host_u32 (mp->pkt_count),
2815 clib_net_to_host_u32 (mp->bytes));
2822 vl_api_one_stats_details_t_handler_json (vl_api_one_stats_details_t * mp)
2824 struct in6_addr ip6;
2826 vat_main_t *vam = &vat_main;
2827 vat_json_node_t *node = 0;
2828 u8 *deid = 0, *seid = 0;
2830 if (VAT_JSON_ARRAY != vam->json_tree.type)
2832 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2833 vat_json_init_array (&vam->json_tree);
2835 node = vat_json_array_add (&vam->json_tree);
2837 vat_json_init_object (node);
2838 deid = format (0, "%U", format_lisp_eid_vat,
2839 mp->eid_type, mp->deid, mp->deid_pref_len, 0, 0, 0);
2841 seid = format (0, "%U", format_lisp_eid_vat,
2842 mp->eid_type, mp->seid, mp->seid_pref_len, 0, 0, 0);
2847 vat_json_object_add_string_copy (node, "seid", seid);
2848 vat_json_object_add_string_copy (node, "deid", deid);
2849 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2853 clib_memcpy (&ip4, mp->lloc, sizeof (ip4));
2854 vat_json_object_add_ip4 (node, "lloc", ip4);
2855 clib_memcpy (&ip4, mp->rloc, sizeof (ip4));
2856 vat_json_object_add_ip4 (node, "rloc", ip4);
2860 clib_memcpy (&ip6, mp->lloc, sizeof (ip6));
2861 vat_json_object_add_ip6 (node, "lloc", ip6);
2862 clib_memcpy (&ip6, mp->rloc, sizeof (ip6));
2863 vat_json_object_add_ip6 (node, "rloc", ip6);
2865 vat_json_object_add_uint (node, "pkt_count",
2866 clib_net_to_host_u32 (mp->pkt_count));
2867 vat_json_object_add_uint (node, "bytes", clib_net_to_host_u32 (mp->bytes));
2874 vl_api_one_eid_table_map_details_t_handler
2875 (vl_api_one_eid_table_map_details_t * mp)
2877 vat_main_t *vam = &vat_main;
2879 u8 *line = format (0, "%=10d%=10d",
2880 clib_net_to_host_u32 (mp->vni),
2881 clib_net_to_host_u32 (mp->dp_table));
2882 print (vam->ofp, "%v", line);
2887 vl_api_one_eid_table_map_details_t_handler_json
2888 (vl_api_one_eid_table_map_details_t * mp)
2890 vat_main_t *vam = &vat_main;
2891 vat_json_node_t *node = NULL;
2893 if (VAT_JSON_ARRAY != vam->json_tree.type)
2895 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2896 vat_json_init_array (&vam->json_tree);
2898 node = vat_json_array_add (&vam->json_tree);
2899 vat_json_init_object (node);
2900 vat_json_object_add_uint (node, "dp_table",
2901 clib_net_to_host_u32 (mp->dp_table));
2902 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2906 vl_api_one_eid_table_vni_details_t_handler
2907 (vl_api_one_eid_table_vni_details_t * mp)
2909 vat_main_t *vam = &vat_main;
2911 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2912 print (vam->ofp, "%v", line);
2917 vl_api_one_eid_table_vni_details_t_handler_json
2918 (vl_api_one_eid_table_vni_details_t * mp)
2920 vat_main_t *vam = &vat_main;
2921 vat_json_node_t *node = NULL;
2923 if (VAT_JSON_ARRAY != vam->json_tree.type)
2925 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2926 vat_json_init_array (&vam->json_tree);
2928 node = vat_json_array_add (&vam->json_tree);
2929 vat_json_init_object (node);
2930 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2934 vl_api_show_one_map_register_fallback_threshold_reply_t_handler
2935 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
2937 vat_main_t *vam = &vat_main;
2938 int retval = clib_net_to_host_u32 (mp->retval);
2940 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
2941 print (vam->ofp, "fallback threshold value: %d", mp->value);
2943 vam->retval = retval;
2944 vam->result_ready = 1;
2948 vl_api_show_one_map_register_fallback_threshold_reply_t_handler_json
2949 (vl_api_show_one_map_register_fallback_threshold_reply_t * mp)
2951 vat_main_t *vam = &vat_main;
2952 vat_json_node_t _node, *node = &_node;
2953 int retval = clib_net_to_host_u32 (mp->retval);
2955 vl_api_show_one_map_register_fallback_threshold_reply_t_endian (mp);
2956 vat_json_init_object (node);
2957 vat_json_object_add_uint (node, "value", mp->value);
2959 vat_json_print (vam->ofp, node);
2960 vat_json_free (node);
2962 vam->retval = retval;
2963 vam->result_ready = 1;
2967 vl_api_show_one_map_register_state_reply_t_handler
2968 (vl_api_show_one_map_register_state_reply_t * mp)
2970 vat_main_t *vam = &vat_main;
2971 int retval = clib_net_to_host_u32 (mp->retval);
2973 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2975 vam->retval = retval;
2976 vam->result_ready = 1;
2980 vl_api_show_one_map_register_state_reply_t_handler_json
2981 (vl_api_show_one_map_register_state_reply_t * mp)
2983 vat_main_t *vam = &vat_main;
2984 vat_json_node_t _node, *node = &_node;
2985 int retval = clib_net_to_host_u32 (mp->retval);
2987 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2989 vat_json_init_object (node);
2990 vat_json_object_add_string_copy (node, "state", s);
2992 vat_json_print (vam->ofp, node);
2993 vat_json_free (node);
2995 vam->retval = retval;
2996 vam->result_ready = 1;
3001 vl_api_show_one_rloc_probe_state_reply_t_handler
3002 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3004 vat_main_t *vam = &vat_main;
3005 int retval = clib_net_to_host_u32 (mp->retval);
3010 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
3012 vam->retval = retval;
3013 vam->result_ready = 1;
3017 vl_api_show_one_rloc_probe_state_reply_t_handler_json
3018 (vl_api_show_one_rloc_probe_state_reply_t * mp)
3020 vat_main_t *vam = &vat_main;
3021 vat_json_node_t _node, *node = &_node;
3022 int retval = clib_net_to_host_u32 (mp->retval);
3024 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
3025 vat_json_init_object (node);
3026 vat_json_object_add_string_copy (node, "state", s);
3028 vat_json_print (vam->ofp, node);
3029 vat_json_free (node);
3031 vam->retval = retval;
3032 vam->result_ready = 1;
3037 vl_api_show_one_stats_enable_disable_reply_t_handler
3038 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3040 vat_main_t *vam = &vat_main;
3041 int retval = clib_net_to_host_u32 (mp->retval);
3046 print (vam->ofp, "%s", mp->is_en ? "enabled" : "disabled");
3048 vam->retval = retval;
3049 vam->result_ready = 1;
3053 vl_api_show_one_stats_enable_disable_reply_t_handler_json
3054 (vl_api_show_one_stats_enable_disable_reply_t * mp)
3056 vat_main_t *vam = &vat_main;
3057 vat_json_node_t _node, *node = &_node;
3058 int retval = clib_net_to_host_u32 (mp->retval);
3060 u8 *s = format (0, "%s", mp->is_en ? "enabled" : "disabled");
3061 vat_json_init_object (node);
3062 vat_json_object_add_string_copy (node, "state", s);
3064 vat_json_print (vam->ofp, node);
3065 vat_json_free (node);
3067 vam->retval = retval;
3068 vam->result_ready = 1;
3073 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
3075 e->dp_table = clib_net_to_host_u32 (e->dp_table);
3076 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
3077 e->vni = clib_net_to_host_u32 (e->vni);
3081 gpe_fwd_entries_get_reply_t_net_to_host
3082 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3086 mp->count = clib_net_to_host_u32 (mp->count);
3087 for (i = 0; i < mp->count; i++)
3089 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
3094 format_gpe_encap_mode (u8 * s, va_list * args)
3096 u32 mode = va_arg (*args, u32);
3101 return format (s, "lisp");
3103 return format (s, "vxlan");
3109 vl_api_gpe_get_encap_mode_reply_t_handler
3110 (vl_api_gpe_get_encap_mode_reply_t * mp)
3112 vat_main_t *vam = &vat_main;
3114 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
3115 vam->retval = ntohl (mp->retval);
3116 vam->result_ready = 1;
3120 vl_api_gpe_get_encap_mode_reply_t_handler_json
3121 (vl_api_gpe_get_encap_mode_reply_t * mp)
3123 vat_main_t *vam = &vat_main;
3124 vat_json_node_t node;
3126 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
3127 vec_add1 (encap_mode, 0);
3129 vat_json_init_object (&node);
3130 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
3132 vec_free (encap_mode);
3133 vat_json_print (vam->ofp, &node);
3134 vat_json_free (&node);
3136 vam->retval = ntohl (mp->retval);
3137 vam->result_ready = 1;
3141 vl_api_gpe_fwd_entry_path_details_t_handler
3142 (vl_api_gpe_fwd_entry_path_details_t * mp)
3144 vat_main_t *vam = &vat_main;
3145 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
3147 if (mp->lcl_loc.is_ip4)
3148 format_ip_address_fcn = format_ip4_address;
3150 format_ip_address_fcn = format_ip6_address;
3152 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
3153 format_ip_address_fcn, &mp->lcl_loc,
3154 format_ip_address_fcn, &mp->rmt_loc);
3158 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
3160 struct in6_addr ip6;
3165 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
3166 vat_json_object_add_ip4 (n, "address", ip4);
3170 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
3171 vat_json_object_add_ip6 (n, "address", ip6);
3173 vat_json_object_add_uint (n, "weight", loc->weight);
3177 vl_api_gpe_fwd_entry_path_details_t_handler_json
3178 (vl_api_gpe_fwd_entry_path_details_t * mp)
3180 vat_main_t *vam = &vat_main;
3181 vat_json_node_t *node = NULL;
3182 vat_json_node_t *loc_node;
3184 if (VAT_JSON_ARRAY != vam->json_tree.type)
3186 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3187 vat_json_init_array (&vam->json_tree);
3189 node = vat_json_array_add (&vam->json_tree);
3190 vat_json_init_object (node);
3192 loc_node = vat_json_object_add (node, "local_locator");
3193 vat_json_init_object (loc_node);
3194 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
3196 loc_node = vat_json_object_add (node, "remote_locator");
3197 vat_json_init_object (loc_node);
3198 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
3202 vl_api_gpe_fwd_entries_get_reply_t_handler
3203 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3205 vat_main_t *vam = &vat_main;
3207 int retval = clib_net_to_host_u32 (mp->retval);
3208 vl_api_gpe_fwd_entry_t *e;
3213 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3215 for (i = 0; i < mp->count; i++)
3217 e = &mp->entries[i];
3218 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
3219 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
3220 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
3224 vam->retval = retval;
3225 vam->result_ready = 1;
3229 vl_api_gpe_fwd_entries_get_reply_t_handler_json
3230 (vl_api_gpe_fwd_entries_get_reply_t * mp)
3233 vat_main_t *vam = &vat_main;
3234 vat_json_node_t *e = 0, root;
3236 int retval = clib_net_to_host_u32 (mp->retval);
3237 vl_api_gpe_fwd_entry_t *fwd;
3242 gpe_fwd_entries_get_reply_t_net_to_host (mp);
3243 vat_json_init_array (&root);
3245 for (i = 0; i < mp->count; i++)
3247 e = vat_json_array_add (&root);
3248 fwd = &mp->entries[i];
3250 vat_json_init_object (e);
3251 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
3252 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
3253 vat_json_object_add_int (e, "vni", fwd->vni);
3254 vat_json_object_add_int (e, "action", fwd->action);
3256 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
3257 fwd->leid_prefix_len);
3259 vat_json_object_add_string_copy (e, "leid", s);
3262 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
3263 fwd->reid_prefix_len);
3265 vat_json_object_add_string_copy (e, "reid", s);
3269 vat_json_print (vam->ofp, &root);
3270 vat_json_free (&root);
3273 vam->retval = retval;
3274 vam->result_ready = 1;
3278 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler
3279 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3281 vat_main_t *vam = &vat_main;
3283 int retval = clib_net_to_host_u32 (mp->retval);
3284 vl_api_gpe_native_fwd_rpath_t *r;
3289 n = clib_net_to_host_u32 (mp->count);
3291 for (i = 0; i < n; i++)
3293 r = &mp->entries[i];
3294 print (vam->ofp, "fib_index: %d sw_if_index %d nh %U",
3295 clib_net_to_host_u32 (r->fib_index),
3296 clib_net_to_host_u32 (r->nh_sw_if_index),
3297 r->is_ip4 ? format_ip4_address : format_ip6_address, r->nh_addr);
3301 vam->retval = retval;
3302 vam->result_ready = 1;
3306 vl_api_gpe_native_fwd_rpaths_get_reply_t_handler_json
3307 (vl_api_gpe_native_fwd_rpaths_get_reply_t * mp)
3309 vat_main_t *vam = &vat_main;
3310 vat_json_node_t root, *e;
3312 int retval = clib_net_to_host_u32 (mp->retval);
3313 vl_api_gpe_native_fwd_rpath_t *r;
3319 n = clib_net_to_host_u32 (mp->count);
3320 vat_json_init_array (&root);
3322 for (i = 0; i < n; i++)
3324 e = vat_json_array_add (&root);
3325 vat_json_init_object (e);
3326 r = &mp->entries[i];
3328 format (0, "%U", r->is_ip4 ? format_ip4_address : format_ip6_address,
3331 vat_json_object_add_string_copy (e, "ip4", s);
3334 vat_json_object_add_uint (e, "fib_index",
3335 clib_net_to_host_u32 (r->fib_index));
3336 vat_json_object_add_uint (e, "nh_sw_if_index",
3337 clib_net_to_host_u32 (r->nh_sw_if_index));
3340 vat_json_print (vam->ofp, &root);
3341 vat_json_free (&root);
3344 vam->retval = retval;
3345 vam->result_ready = 1;
3349 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler
3350 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3352 vat_main_t *vam = &vat_main;
3354 int retval = clib_net_to_host_u32 (mp->retval);
3359 n = clib_net_to_host_u32 (mp->count);
3361 for (i = 0; i < n; i++)
3362 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->vnis[i]));
3365 vam->retval = retval;
3366 vam->result_ready = 1;
3370 vl_api_gpe_fwd_entry_vnis_get_reply_t_handler_json
3371 (vl_api_gpe_fwd_entry_vnis_get_reply_t * mp)
3373 vat_main_t *vam = &vat_main;
3374 vat_json_node_t root;
3376 int retval = clib_net_to_host_u32 (mp->retval);
3381 n = clib_net_to_host_u32 (mp->count);
3382 vat_json_init_array (&root);
3384 for (i = 0; i < n; i++)
3385 vat_json_array_add_uint (&root, clib_net_to_host_u32 (mp->vnis[i]));
3387 vat_json_print (vam->ofp, &root);
3388 vat_json_free (&root);
3391 vam->retval = retval;
3392 vam->result_ready = 1;
3396 vl_api_one_ndp_entries_get_reply_t_handler
3397 (vl_api_one_ndp_entries_get_reply_t * mp)
3399 vat_main_t *vam = &vat_main;
3401 int retval = clib_net_to_host_u32 (mp->retval);
3406 n = clib_net_to_host_u32 (mp->count);
3408 for (i = 0; i < n; i++)
3409 print (vam->ofp, "%U -> %U", format_ip6_address, &mp->entries[i].ip6,
3410 format_ethernet_address, mp->entries[i].mac);
3413 vam->retval = retval;
3414 vam->result_ready = 1;
3418 vl_api_one_ndp_entries_get_reply_t_handler_json
3419 (vl_api_one_ndp_entries_get_reply_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 vat_json_node_t *e = 0, root;
3425 int retval = clib_net_to_host_u32 (mp->retval);
3426 vl_api_one_ndp_entry_t *arp_entry;
3431 n = clib_net_to_host_u32 (mp->count);
3432 vat_json_init_array (&root);
3434 for (i = 0; i < n; i++)
3436 e = vat_json_array_add (&root);
3437 arp_entry = &mp->entries[i];
3439 vat_json_init_object (e);
3440 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3443 vat_json_object_add_string_copy (e, "mac", s);
3446 s = format (0, "%U", format_ip6_address, &arp_entry->ip6);
3448 vat_json_object_add_string_copy (e, "ip6", s);
3452 vat_json_print (vam->ofp, &root);
3453 vat_json_free (&root);
3456 vam->retval = retval;
3457 vam->result_ready = 1;
3461 vl_api_one_l2_arp_entries_get_reply_t_handler
3462 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3464 vat_main_t *vam = &vat_main;
3466 int retval = clib_net_to_host_u32 (mp->retval);
3471 n = clib_net_to_host_u32 (mp->count);
3473 for (i = 0; i < n; i++)
3474 print (vam->ofp, "%U -> %U", format_ip4_address, &mp->entries[i].ip4,
3475 format_ethernet_address, mp->entries[i].mac);
3478 vam->retval = retval;
3479 vam->result_ready = 1;
3483 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3484 (vl_api_one_l2_arp_entries_get_reply_t * mp)
3487 vat_main_t *vam = &vat_main;
3488 vat_json_node_t *e = 0, root;
3490 int retval = clib_net_to_host_u32 (mp->retval);
3491 vl_api_one_l2_arp_entry_t *arp_entry;
3496 n = clib_net_to_host_u32 (mp->count);
3497 vat_json_init_array (&root);
3499 for (i = 0; i < n; i++)
3501 e = vat_json_array_add (&root);
3502 arp_entry = &mp->entries[i];
3504 vat_json_init_object (e);
3505 s = format (0, "%U", format_ethernet_address, arp_entry->mac);
3508 vat_json_object_add_string_copy (e, "mac", s);
3511 s = format (0, "%U", format_ip4_address, &arp_entry->ip4);
3513 vat_json_object_add_string_copy (e, "ip4", s);
3517 vat_json_print (vam->ofp, &root);
3518 vat_json_free (&root);
3521 vam->retval = retval;
3522 vam->result_ready = 1;
3526 vl_api_one_ndp_bd_get_reply_t_handler (vl_api_one_ndp_bd_get_reply_t * mp)
3528 vat_main_t *vam = &vat_main;
3530 int retval = clib_net_to_host_u32 (mp->retval);
3535 n = clib_net_to_host_u32 (mp->count);
3537 for (i = 0; i < n; i++)
3539 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3543 vam->retval = retval;
3544 vam->result_ready = 1;
3548 vl_api_one_ndp_bd_get_reply_t_handler_json
3549 (vl_api_one_ndp_bd_get_reply_t * mp)
3551 vat_main_t *vam = &vat_main;
3552 vat_json_node_t root;
3554 int retval = clib_net_to_host_u32 (mp->retval);
3559 n = clib_net_to_host_u32 (mp->count);
3560 vat_json_init_array (&root);
3562 for (i = 0; i < n; i++)
3564 vat_json_array_add_uint (&root,
3565 clib_net_to_host_u32 (mp->bridge_domains[i]));
3568 vat_json_print (vam->ofp, &root);
3569 vat_json_free (&root);
3572 vam->retval = retval;
3573 vam->result_ready = 1;
3577 vl_api_one_l2_arp_bd_get_reply_t_handler
3578 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3580 vat_main_t *vam = &vat_main;
3582 int retval = clib_net_to_host_u32 (mp->retval);
3587 n = clib_net_to_host_u32 (mp->count);
3589 for (i = 0; i < n; i++)
3591 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3595 vam->retval = retval;
3596 vam->result_ready = 1;
3600 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3601 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3603 vat_main_t *vam = &vat_main;
3604 vat_json_node_t root;
3606 int retval = clib_net_to_host_u32 (mp->retval);
3611 n = clib_net_to_host_u32 (mp->count);
3612 vat_json_init_array (&root);
3614 for (i = 0; i < n; i++)
3616 vat_json_array_add_uint (&root,
3617 clib_net_to_host_u32 (mp->bridge_domains[i]));
3620 vat_json_print (vam->ofp, &root);
3621 vat_json_free (&root);
3624 vam->retval = retval;
3625 vam->result_ready = 1;
3629 vl_api_one_adjacencies_get_reply_t_handler
3630 (vl_api_one_adjacencies_get_reply_t * mp)
3632 vat_main_t *vam = &vat_main;
3634 int retval = clib_net_to_host_u32 (mp->retval);
3635 vl_api_one_adjacency_t *a;
3640 n = clib_net_to_host_u32 (mp->count);
3642 for (i = 0; i < n; i++)
3644 a = &mp->adjacencies[i];
3645 print (vam->ofp, "%U %40U",
3646 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3647 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3651 vam->retval = retval;
3652 vam->result_ready = 1;
3656 vl_api_one_adjacencies_get_reply_t_handler_json
3657 (vl_api_one_adjacencies_get_reply_t * mp)
3660 vat_main_t *vam = &vat_main;
3661 vat_json_node_t *e = 0, root;
3663 int retval = clib_net_to_host_u32 (mp->retval);
3664 vl_api_one_adjacency_t *a;
3669 n = clib_net_to_host_u32 (mp->count);
3670 vat_json_init_array (&root);
3672 for (i = 0; i < n; i++)
3674 e = vat_json_array_add (&root);
3675 a = &mp->adjacencies[i];
3677 vat_json_init_object (e);
3678 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3679 a->leid_prefix_len);
3681 vat_json_object_add_string_copy (e, "leid", s);
3684 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3685 a->reid_prefix_len);
3687 vat_json_object_add_string_copy (e, "reid", s);
3691 vat_json_print (vam->ofp, &root);
3692 vat_json_free (&root);
3695 vam->retval = retval;
3696 vam->result_ready = 1;
3700 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3702 vat_main_t *vam = &vat_main;
3704 print (vam->ofp, "%=20U",
3705 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3710 vl_api_one_map_server_details_t_handler_json
3711 (vl_api_one_map_server_details_t * mp)
3713 vat_main_t *vam = &vat_main;
3714 vat_json_node_t *node = NULL;
3715 struct in6_addr ip6;
3718 if (VAT_JSON_ARRAY != vam->json_tree.type)
3720 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3721 vat_json_init_array (&vam->json_tree);
3723 node = vat_json_array_add (&vam->json_tree);
3725 vat_json_init_object (node);
3728 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3729 vat_json_object_add_ip6 (node, "map-server", ip6);
3733 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3734 vat_json_object_add_ip4 (node, "map-server", ip4);
3739 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3742 vat_main_t *vam = &vat_main;
3744 print (vam->ofp, "%=20U",
3745 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3750 vl_api_one_map_resolver_details_t_handler_json
3751 (vl_api_one_map_resolver_details_t * mp)
3753 vat_main_t *vam = &vat_main;
3754 vat_json_node_t *node = NULL;
3755 struct in6_addr ip6;
3758 if (VAT_JSON_ARRAY != vam->json_tree.type)
3760 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3761 vat_json_init_array (&vam->json_tree);
3763 node = vat_json_array_add (&vam->json_tree);
3765 vat_json_init_object (node);
3768 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3769 vat_json_object_add_ip6 (node, "map resolver", ip6);
3773 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3774 vat_json_object_add_ip4 (node, "map resolver", ip4);
3779 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3781 vat_main_t *vam = &vat_main;
3782 i32 retval = ntohl (mp->retval);
3786 print (vam->ofp, "feature: %s\ngpe: %s",
3787 mp->feature_status ? "enabled" : "disabled",
3788 mp->gpe_status ? "enabled" : "disabled");
3791 vam->retval = retval;
3792 vam->result_ready = 1;
3796 vl_api_show_one_status_reply_t_handler_json
3797 (vl_api_show_one_status_reply_t * mp)
3799 vat_main_t *vam = &vat_main;
3800 vat_json_node_t node;
3801 u8 *gpe_status = NULL;
3802 u8 *feature_status = NULL;
3804 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3805 feature_status = format (0, "%s",
3806 mp->feature_status ? "enabled" : "disabled");
3807 vec_add1 (gpe_status, 0);
3808 vec_add1 (feature_status, 0);
3810 vat_json_init_object (&node);
3811 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3812 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3814 vec_free (gpe_status);
3815 vec_free (feature_status);
3817 vat_json_print (vam->ofp, &node);
3818 vat_json_free (&node);
3820 vam->retval = ntohl (mp->retval);
3821 vam->result_ready = 1;
3825 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3826 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3828 vat_main_t *vam = &vat_main;
3829 i32 retval = ntohl (mp->retval);
3833 print (vam->ofp, "%=20s", mp->locator_set_name);
3836 vam->retval = retval;
3837 vam->result_ready = 1;
3841 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3842 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3844 vat_main_t *vam = &vat_main;
3845 vat_json_node_t *node = NULL;
3847 if (VAT_JSON_ARRAY != vam->json_tree.type)
3849 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3850 vat_json_init_array (&vam->json_tree);
3852 node = vat_json_array_add (&vam->json_tree);
3854 vat_json_init_object (node);
3855 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3857 vat_json_print (vam->ofp, node);
3858 vat_json_free (node);
3860 vam->retval = ntohl (mp->retval);
3861 vam->result_ready = 1;
3865 format_lisp_map_request_mode (u8 * s, va_list * args)
3867 u32 mode = va_arg (*args, u32);
3872 return format (0, "dst-only");
3874 return format (0, "src-dst");
3880 vl_api_show_one_map_request_mode_reply_t_handler
3881 (vl_api_show_one_map_request_mode_reply_t * mp)
3883 vat_main_t *vam = &vat_main;
3884 i32 retval = ntohl (mp->retval);
3888 u32 mode = mp->mode;
3889 print (vam->ofp, "map_request_mode: %U",
3890 format_lisp_map_request_mode, mode);
3893 vam->retval = retval;
3894 vam->result_ready = 1;
3898 vl_api_show_one_map_request_mode_reply_t_handler_json
3899 (vl_api_show_one_map_request_mode_reply_t * mp)
3901 vat_main_t *vam = &vat_main;
3902 vat_json_node_t node;
3907 s = format (0, "%U", format_lisp_map_request_mode, mode);
3910 vat_json_init_object (&node);
3911 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3912 vat_json_print (vam->ofp, &node);
3913 vat_json_free (&node);
3916 vam->retval = ntohl (mp->retval);
3917 vam->result_ready = 1;
3921 vl_api_show_one_use_petr_reply_t_handler
3922 (vl_api_show_one_use_petr_reply_t * mp)
3924 vat_main_t *vam = &vat_main;
3925 i32 retval = ntohl (mp->retval);
3929 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3932 print (vam->ofp, "Proxy-ETR address; %U",
3933 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3938 vam->retval = retval;
3939 vam->result_ready = 1;
3943 vl_api_show_one_use_petr_reply_t_handler_json
3944 (vl_api_show_one_use_petr_reply_t * mp)
3946 vat_main_t *vam = &vat_main;
3947 vat_json_node_t node;
3950 struct in6_addr ip6;
3952 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3953 vec_add1 (status, 0);
3955 vat_json_init_object (&node);
3956 vat_json_object_add_string_copy (&node, "status", status);
3961 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3962 vat_json_object_add_ip6 (&node, "address", ip6);
3966 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3967 vat_json_object_add_ip4 (&node, "address", ip4);
3973 vat_json_print (vam->ofp, &node);
3974 vat_json_free (&node);
3976 vam->retval = ntohl (mp->retval);
3977 vam->result_ready = 1;
3981 vl_api_show_one_nsh_mapping_reply_t_handler
3982 (vl_api_show_one_nsh_mapping_reply_t * mp)
3984 vat_main_t *vam = &vat_main;
3985 i32 retval = ntohl (mp->retval);
3989 print (vam->ofp, "%-20s%-16s",
3990 mp->is_set ? "set" : "not-set",
3991 mp->is_set ? (char *) mp->locator_set_name : "");
3994 vam->retval = retval;
3995 vam->result_ready = 1;
3999 vl_api_show_one_nsh_mapping_reply_t_handler_json
4000 (vl_api_show_one_nsh_mapping_reply_t * mp)
4002 vat_main_t *vam = &vat_main;
4003 vat_json_node_t node;
4006 status = format (0, "%s", mp->is_set ? "yes" : "no");
4007 vec_add1 (status, 0);
4009 vat_json_init_object (&node);
4010 vat_json_object_add_string_copy (&node, "is_set", status);
4013 vat_json_object_add_string_copy (&node, "locator_set",
4014 mp->locator_set_name);
4019 vat_json_print (vam->ofp, &node);
4020 vat_json_free (&node);
4022 vam->retval = ntohl (mp->retval);
4023 vam->result_ready = 1;
4027 vl_api_show_one_map_register_ttl_reply_t_handler
4028 (vl_api_show_one_map_register_ttl_reply_t * mp)
4030 vat_main_t *vam = &vat_main;
4031 i32 retval = ntohl (mp->retval);
4033 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4037 print (vam->ofp, "ttl: %u", mp->ttl);
4040 vam->retval = retval;
4041 vam->result_ready = 1;
4045 vl_api_show_one_map_register_ttl_reply_t_handler_json
4046 (vl_api_show_one_map_register_ttl_reply_t * mp)
4048 vat_main_t *vam = &vat_main;
4049 vat_json_node_t node;
4051 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
4052 vat_json_init_object (&node);
4053 vat_json_object_add_uint (&node, "ttl", mp->ttl);
4055 vat_json_print (vam->ofp, &node);
4056 vat_json_free (&node);
4058 vam->retval = ntohl (mp->retval);
4059 vam->result_ready = 1;
4063 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
4065 vat_main_t *vam = &vat_main;
4066 i32 retval = ntohl (mp->retval);
4070 print (vam->ofp, "%-20s%-16s",
4071 mp->status ? "enabled" : "disabled",
4072 mp->status ? (char *) mp->locator_set_name : "");
4075 vam->retval = retval;
4076 vam->result_ready = 1;
4080 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
4082 vat_main_t *vam = &vat_main;
4083 vat_json_node_t node;
4086 status = format (0, "%s", mp->status ? "enabled" : "disabled");
4087 vec_add1 (status, 0);
4089 vat_json_init_object (&node);
4090 vat_json_object_add_string_copy (&node, "status", status);
4093 vat_json_object_add_string_copy (&node, "locator_set",
4094 mp->locator_set_name);
4099 vat_json_print (vam->ofp, &node);
4100 vat_json_free (&node);
4102 vam->retval = ntohl (mp->retval);
4103 vam->result_ready = 1;
4107 format_policer_type (u8 * s, va_list * va)
4109 u32 i = va_arg (*va, u32);
4111 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
4112 s = format (s, "1r2c");
4113 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
4114 s = format (s, "1r3c");
4115 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4116 s = format (s, "2r3c-2698");
4117 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4118 s = format (s, "2r3c-4115");
4119 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4120 s = format (s, "2r3c-mef5cf1");
4122 s = format (s, "ILLEGAL");
4127 format_policer_rate_type (u8 * s, va_list * va)
4129 u32 i = va_arg (*va, u32);
4131 if (i == SSE2_QOS_RATE_KBPS)
4132 s = format (s, "kbps");
4133 else if (i == SSE2_QOS_RATE_PPS)
4134 s = format (s, "pps");
4136 s = format (s, "ILLEGAL");
4141 format_policer_round_type (u8 * s, va_list * va)
4143 u32 i = va_arg (*va, u32);
4145 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4146 s = format (s, "closest");
4147 else if (i == SSE2_QOS_ROUND_TO_UP)
4148 s = format (s, "up");
4149 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4150 s = format (s, "down");
4152 s = format (s, "ILLEGAL");
4157 format_policer_action_type (u8 * s, va_list * va)
4159 u32 i = va_arg (*va, u32);
4161 if (i == SSE2_QOS_ACTION_DROP)
4162 s = format (s, "drop");
4163 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4164 s = format (s, "transmit");
4165 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4166 s = format (s, "mark-and-transmit");
4168 s = format (s, "ILLEGAL");
4173 format_dscp (u8 * s, va_list * va)
4175 u32 i = va_arg (*va, u32);
4180 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4184 return format (s, "ILLEGAL");
4186 s = format (s, "%s", t);
4191 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4193 vat_main_t *vam = &vat_main;
4194 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4196 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4197 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4199 conform_dscp_str = format (0, "");
4201 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4202 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4204 exceed_dscp_str = format (0, "");
4206 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4207 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4209 violate_dscp_str = format (0, "");
4211 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4212 "rate type %U, round type %U, %s rate, %s color-aware, "
4213 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4214 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4215 "conform action %U%s, exceed action %U%s, violate action %U%s",
4217 format_policer_type, mp->type,
4220 clib_net_to_host_u64 (mp->cb),
4221 clib_net_to_host_u64 (mp->eb),
4222 format_policer_rate_type, mp->rate_type,
4223 format_policer_round_type, mp->round_type,
4224 mp->single_rate ? "single" : "dual",
4225 mp->color_aware ? "is" : "not",
4226 ntohl (mp->cir_tokens_per_period),
4227 ntohl (mp->pir_tokens_per_period),
4229 ntohl (mp->current_limit),
4230 ntohl (mp->current_bucket),
4231 ntohl (mp->extended_limit),
4232 ntohl (mp->extended_bucket),
4233 clib_net_to_host_u64 (mp->last_update_time),
4234 format_policer_action_type, mp->conform_action_type,
4236 format_policer_action_type, mp->exceed_action_type,
4238 format_policer_action_type, mp->violate_action_type,
4241 vec_free (conform_dscp_str);
4242 vec_free (exceed_dscp_str);
4243 vec_free (violate_dscp_str);
4246 static void vl_api_policer_details_t_handler_json
4247 (vl_api_policer_details_t * mp)
4249 vat_main_t *vam = &vat_main;
4250 vat_json_node_t *node;
4251 u8 *rate_type_str, *round_type_str, *type_str;
4252 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4254 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4256 format (0, "%U", format_policer_round_type, mp->round_type);
4257 type_str = format (0, "%U", format_policer_type, mp->type);
4258 conform_action_str = format (0, "%U", format_policer_action_type,
4259 mp->conform_action_type);
4260 exceed_action_str = format (0, "%U", format_policer_action_type,
4261 mp->exceed_action_type);
4262 violate_action_str = format (0, "%U", format_policer_action_type,
4263 mp->violate_action_type);
4265 if (VAT_JSON_ARRAY != vam->json_tree.type)
4267 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4268 vat_json_init_array (&vam->json_tree);
4270 node = vat_json_array_add (&vam->json_tree);
4272 vat_json_init_object (node);
4273 vat_json_object_add_string_copy (node, "name", mp->name);
4274 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4275 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4276 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4277 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4278 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4279 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4280 vat_json_object_add_string_copy (node, "type", type_str);
4281 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4282 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4283 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4284 vat_json_object_add_uint (node, "cir_tokens_per_period",
4285 ntohl (mp->cir_tokens_per_period));
4286 vat_json_object_add_uint (node, "eir_tokens_per_period",
4287 ntohl (mp->pir_tokens_per_period));
4288 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4289 vat_json_object_add_uint (node, "current_bucket",
4290 ntohl (mp->current_bucket));
4291 vat_json_object_add_uint (node, "extended_limit",
4292 ntohl (mp->extended_limit));
4293 vat_json_object_add_uint (node, "extended_bucket",
4294 ntohl (mp->extended_bucket));
4295 vat_json_object_add_uint (node, "last_update_time",
4296 ntohl (mp->last_update_time));
4297 vat_json_object_add_string_copy (node, "conform_action",
4298 conform_action_str);
4299 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4301 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4302 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4303 vec_free (dscp_str);
4305 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4306 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4308 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4309 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4310 vec_free (dscp_str);
4312 vat_json_object_add_string_copy (node, "violate_action",
4313 violate_action_str);
4314 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4316 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4317 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4318 vec_free (dscp_str);
4321 vec_free (rate_type_str);
4322 vec_free (round_type_str);
4323 vec_free (type_str);
4324 vec_free (conform_action_str);
4325 vec_free (exceed_action_str);
4326 vec_free (violate_action_str);
4330 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4333 vat_main_t *vam = &vat_main;
4334 int i, count = ntohl (mp->count);
4337 print (vam->ofp, "classify table ids (%d) : ", count);
4338 for (i = 0; i < count; i++)
4340 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4341 print (vam->ofp, (i < count - 1) ? "," : "");
4343 vam->retval = ntohl (mp->retval);
4344 vam->result_ready = 1;
4348 vl_api_classify_table_ids_reply_t_handler_json
4349 (vl_api_classify_table_ids_reply_t * mp)
4351 vat_main_t *vam = &vat_main;
4352 int i, count = ntohl (mp->count);
4356 vat_json_node_t node;
4358 vat_json_init_object (&node);
4359 for (i = 0; i < count; i++)
4361 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4363 vat_json_print (vam->ofp, &node);
4364 vat_json_free (&node);
4366 vam->retval = ntohl (mp->retval);
4367 vam->result_ready = 1;
4371 vl_api_classify_table_by_interface_reply_t_handler
4372 (vl_api_classify_table_by_interface_reply_t * mp)
4374 vat_main_t *vam = &vat_main;
4377 table_id = ntohl (mp->l2_table_id);
4379 print (vam->ofp, "l2 table id : %d", table_id);
4381 print (vam->ofp, "l2 table id : No input ACL tables configured");
4382 table_id = ntohl (mp->ip4_table_id);
4384 print (vam->ofp, "ip4 table id : %d", table_id);
4386 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4387 table_id = ntohl (mp->ip6_table_id);
4389 print (vam->ofp, "ip6 table id : %d", table_id);
4391 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4392 vam->retval = ntohl (mp->retval);
4393 vam->result_ready = 1;
4397 vl_api_classify_table_by_interface_reply_t_handler_json
4398 (vl_api_classify_table_by_interface_reply_t * mp)
4400 vat_main_t *vam = &vat_main;
4401 vat_json_node_t node;
4403 vat_json_init_object (&node);
4405 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4406 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4407 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4409 vat_json_print (vam->ofp, &node);
4410 vat_json_free (&node);
4412 vam->retval = ntohl (mp->retval);
4413 vam->result_ready = 1;
4416 static void vl_api_policer_add_del_reply_t_handler
4417 (vl_api_policer_add_del_reply_t * mp)
4419 vat_main_t *vam = &vat_main;
4420 i32 retval = ntohl (mp->retval);
4421 if (vam->async_mode)
4423 vam->async_errors += (retval < 0);
4427 vam->retval = retval;
4428 vam->result_ready = 1;
4429 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4431 * Note: this is just barely thread-safe, depends on
4432 * the main thread spinning waiting for an answer...
4434 errmsg ("policer index %d", ntohl (mp->policer_index));
4438 static void vl_api_policer_add_del_reply_t_handler_json
4439 (vl_api_policer_add_del_reply_t * mp)
4441 vat_main_t *vam = &vat_main;
4442 vat_json_node_t node;
4444 vat_json_init_object (&node);
4445 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4446 vat_json_object_add_uint (&node, "policer_index",
4447 ntohl (mp->policer_index));
4449 vat_json_print (vam->ofp, &node);
4450 vat_json_free (&node);
4452 vam->retval = ntohl (mp->retval);
4453 vam->result_ready = 1;
4456 /* Format hex dump. */
4458 format_hex_bytes (u8 * s, va_list * va)
4460 u8 *bytes = va_arg (*va, u8 *);
4461 int n_bytes = va_arg (*va, int);
4464 /* Print short or long form depending on byte count. */
4465 uword short_form = n_bytes <= 32;
4466 uword indent = format_get_indent (s);
4471 for (i = 0; i < n_bytes; i++)
4473 if (!short_form && (i % 32) == 0)
4474 s = format (s, "%08x: ", i);
4475 s = format (s, "%02x", bytes[i]);
4476 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4477 s = format (s, "\n%U", format_white_space, indent);
4484 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4487 vat_main_t *vam = &vat_main;
4488 i32 retval = ntohl (mp->retval);
4491 print (vam->ofp, "classify table info :");
4492 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4493 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4494 ntohl (mp->miss_next_index));
4495 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4496 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4497 ntohl (mp->match_n_vectors));
4498 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4499 ntohl (mp->mask_length));
4501 vam->retval = retval;
4502 vam->result_ready = 1;
4506 vl_api_classify_table_info_reply_t_handler_json
4507 (vl_api_classify_table_info_reply_t * mp)
4509 vat_main_t *vam = &vat_main;
4510 vat_json_node_t node;
4512 i32 retval = ntohl (mp->retval);
4515 vat_json_init_object (&node);
4517 vat_json_object_add_int (&node, "sessions",
4518 ntohl (mp->active_sessions));
4519 vat_json_object_add_int (&node, "nexttbl",
4520 ntohl (mp->next_table_index));
4521 vat_json_object_add_int (&node, "nextnode",
4522 ntohl (mp->miss_next_index));
4523 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4524 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4525 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4526 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4527 ntohl (mp->mask_length), 0);
4528 vat_json_object_add_string_copy (&node, "mask", s);
4530 vat_json_print (vam->ofp, &node);
4531 vat_json_free (&node);
4533 vam->retval = ntohl (mp->retval);
4534 vam->result_ready = 1;
4538 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4541 vat_main_t *vam = &vat_main;
4543 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4544 ntohl (mp->hit_next_index), ntohl (mp->advance),
4545 ntohl (mp->opaque_index));
4546 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4547 ntohl (mp->match_length));
4551 vl_api_classify_session_details_t_handler_json
4552 (vl_api_classify_session_details_t * mp)
4554 vat_main_t *vam = &vat_main;
4555 vat_json_node_t *node = NULL;
4557 if (VAT_JSON_ARRAY != vam->json_tree.type)
4559 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4560 vat_json_init_array (&vam->json_tree);
4562 node = vat_json_array_add (&vam->json_tree);
4564 vat_json_init_object (node);
4565 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4566 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4567 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4569 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4571 vat_json_object_add_string_copy (node, "match", s);
4574 static void vl_api_pg_create_interface_reply_t_handler
4575 (vl_api_pg_create_interface_reply_t * mp)
4577 vat_main_t *vam = &vat_main;
4579 vam->retval = ntohl (mp->retval);
4580 vam->result_ready = 1;
4583 static void vl_api_pg_create_interface_reply_t_handler_json
4584 (vl_api_pg_create_interface_reply_t * mp)
4586 vat_main_t *vam = &vat_main;
4587 vat_json_node_t node;
4589 i32 retval = ntohl (mp->retval);
4592 vat_json_init_object (&node);
4594 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4596 vat_json_print (vam->ofp, &node);
4597 vat_json_free (&node);
4599 vam->retval = ntohl (mp->retval);
4600 vam->result_ready = 1;
4603 static void vl_api_policer_classify_details_t_handler
4604 (vl_api_policer_classify_details_t * mp)
4606 vat_main_t *vam = &vat_main;
4608 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4609 ntohl (mp->table_index));
4612 static void vl_api_policer_classify_details_t_handler_json
4613 (vl_api_policer_classify_details_t * mp)
4615 vat_main_t *vam = &vat_main;
4616 vat_json_node_t *node;
4618 if (VAT_JSON_ARRAY != vam->json_tree.type)
4620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4621 vat_json_init_array (&vam->json_tree);
4623 node = vat_json_array_add (&vam->json_tree);
4625 vat_json_init_object (node);
4626 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4627 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4630 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4631 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4633 vat_main_t *vam = &vat_main;
4634 i32 retval = ntohl (mp->retval);
4635 if (vam->async_mode)
4637 vam->async_errors += (retval < 0);
4641 vam->retval = retval;
4642 vam->sw_if_index = ntohl (mp->sw_if_index);
4643 vam->result_ready = 1;
4647 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4648 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4650 vat_main_t *vam = &vat_main;
4651 vat_json_node_t node;
4653 vat_json_init_object (&node);
4654 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4655 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4657 vat_json_print (vam->ofp, &node);
4658 vat_json_free (&node);
4660 vam->retval = ntohl (mp->retval);
4661 vam->result_ready = 1;
4664 static void vl_api_flow_classify_details_t_handler
4665 (vl_api_flow_classify_details_t * mp)
4667 vat_main_t *vam = &vat_main;
4669 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4670 ntohl (mp->table_index));
4673 static void vl_api_flow_classify_details_t_handler_json
4674 (vl_api_flow_classify_details_t * mp)
4676 vat_main_t *vam = &vat_main;
4677 vat_json_node_t *node;
4679 if (VAT_JSON_ARRAY != vam->json_tree.type)
4681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4682 vat_json_init_array (&vam->json_tree);
4684 node = vat_json_array_add (&vam->json_tree);
4686 vat_json_init_object (node);
4687 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4688 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4691 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4692 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4693 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4694 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4695 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4696 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4697 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4698 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4699 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4700 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4701 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4702 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4703 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4704 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4705 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4706 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4707 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4708 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4709 #define vl_api_one_ndp_bd_get_reply_t_endian vl_noop_handler
4710 #define vl_api_one_ndp_bd_get_reply_t_print vl_noop_handler
4711 #define vl_api_one_ndp_entries_get_reply_t_print vl_noop_handler
4712 #define vl_api_one_ndp_entries_get_reply_t_endian vl_noop_handler
4715 * Generate boilerplate reply handlers, which
4716 * dig the return value out of the xxx_reply_t API message,
4717 * stick it into vam->retval, and set vam->result_ready
4719 * Could also do this by pointing N message decode slots at
4720 * a single function, but that could break in subtle ways.
4723 #define foreach_standard_reply_retval_handler \
4724 _(sw_interface_set_flags_reply) \
4725 _(sw_interface_add_del_address_reply) \
4726 _(sw_interface_set_table_reply) \
4727 _(sw_interface_set_mpls_enable_reply) \
4728 _(sw_interface_set_vpath_reply) \
4729 _(sw_interface_set_vxlan_bypass_reply) \
4730 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4731 _(sw_interface_set_l2_bridge_reply) \
4732 _(bridge_domain_add_del_reply) \
4733 _(sw_interface_set_l2_xconnect_reply) \
4734 _(l2fib_add_del_reply) \
4735 _(l2fib_flush_int_reply) \
4736 _(l2fib_flush_bd_reply) \
4737 _(ip_add_del_route_reply) \
4738 _(ip_table_add_del_reply) \
4739 _(ip_mroute_add_del_reply) \
4740 _(mpls_route_add_del_reply) \
4741 _(mpls_table_add_del_reply) \
4742 _(mpls_ip_bind_unbind_reply) \
4743 _(proxy_arp_add_del_reply) \
4744 _(proxy_arp_intfc_enable_disable_reply) \
4745 _(sw_interface_set_unnumbered_reply) \
4746 _(ip_neighbor_add_del_reply) \
4747 _(reset_vrf_reply) \
4748 _(oam_add_del_reply) \
4749 _(reset_fib_reply) \
4750 _(dhcp_proxy_config_reply) \
4751 _(dhcp_proxy_set_vss_reply) \
4752 _(dhcp_client_config_reply) \
4753 _(set_ip_flow_hash_reply) \
4754 _(sw_interface_ip6_enable_disable_reply) \
4755 _(sw_interface_ip6_set_link_local_address_reply) \
4756 _(ip6nd_proxy_add_del_reply) \
4757 _(sw_interface_ip6nd_ra_prefix_reply) \
4758 _(sw_interface_ip6nd_ra_config_reply) \
4759 _(set_arp_neighbor_limit_reply) \
4760 _(l2_patch_add_del_reply) \
4761 _(sr_policy_add_reply) \
4762 _(sr_policy_mod_reply) \
4763 _(sr_policy_del_reply) \
4764 _(sr_localsid_add_del_reply) \
4765 _(sr_steering_add_del_reply) \
4766 _(classify_add_del_session_reply) \
4767 _(classify_set_interface_ip_table_reply) \
4768 _(classify_set_interface_l2_tables_reply) \
4769 _(l2tpv3_set_tunnel_cookies_reply) \
4770 _(l2tpv3_interface_enable_disable_reply) \
4771 _(l2tpv3_set_lookup_key_reply) \
4772 _(l2_fib_clear_table_reply) \
4773 _(l2_interface_efp_filter_reply) \
4774 _(l2_interface_vlan_tag_rewrite_reply) \
4775 _(modify_vhost_user_if_reply) \
4776 _(delete_vhost_user_if_reply) \
4777 _(want_ip4_arp_events_reply) \
4778 _(want_ip6_nd_events_reply) \
4779 _(want_l2_macs_events_reply) \
4780 _(input_acl_set_interface_reply) \
4781 _(ipsec_spd_add_del_reply) \
4782 _(ipsec_interface_add_del_spd_reply) \
4783 _(ipsec_spd_add_del_entry_reply) \
4784 _(ipsec_sad_add_del_entry_reply) \
4785 _(ipsec_sa_set_key_reply) \
4786 _(ipsec_tunnel_if_add_del_reply) \
4787 _(ikev2_profile_add_del_reply) \
4788 _(ikev2_profile_set_auth_reply) \
4789 _(ikev2_profile_set_id_reply) \
4790 _(ikev2_profile_set_ts_reply) \
4791 _(ikev2_set_local_key_reply) \
4792 _(ikev2_set_responder_reply) \
4793 _(ikev2_set_ike_transforms_reply) \
4794 _(ikev2_set_esp_transforms_reply) \
4795 _(ikev2_set_sa_lifetime_reply) \
4796 _(ikev2_initiate_sa_init_reply) \
4797 _(ikev2_initiate_del_ike_sa_reply) \
4798 _(ikev2_initiate_del_child_sa_reply) \
4799 _(ikev2_initiate_rekey_child_sa_reply) \
4800 _(delete_loopback_reply) \
4801 _(bd_ip_mac_add_del_reply) \
4802 _(map_del_domain_reply) \
4803 _(map_add_del_rule_reply) \
4804 _(want_interface_events_reply) \
4805 _(want_stats_reply) \
4806 _(cop_interface_enable_disable_reply) \
4807 _(cop_whitelist_enable_disable_reply) \
4808 _(sw_interface_clear_stats_reply) \
4809 _(ioam_enable_reply) \
4810 _(ioam_disable_reply) \
4811 _(one_add_del_locator_reply) \
4812 _(one_add_del_local_eid_reply) \
4813 _(one_add_del_remote_mapping_reply) \
4814 _(one_add_del_adjacency_reply) \
4815 _(one_add_del_map_resolver_reply) \
4816 _(one_add_del_map_server_reply) \
4817 _(one_enable_disable_reply) \
4818 _(one_rloc_probe_enable_disable_reply) \
4819 _(one_map_register_enable_disable_reply) \
4820 _(one_map_register_set_ttl_reply) \
4821 _(one_map_register_fallback_threshold_reply) \
4822 _(one_pitr_set_locator_set_reply) \
4823 _(one_map_request_mode_reply) \
4824 _(one_add_del_map_request_itr_rlocs_reply) \
4825 _(one_eid_table_add_del_map_reply) \
4826 _(one_use_petr_reply) \
4827 _(one_stats_enable_disable_reply) \
4828 _(one_add_del_l2_arp_entry_reply) \
4829 _(one_add_del_ndp_entry_reply) \
4830 _(one_stats_flush_reply) \
4831 _(gpe_enable_disable_reply) \
4832 _(gpe_set_encap_mode_reply) \
4833 _(gpe_add_del_iface_reply) \
4834 _(gpe_add_del_native_fwd_rpath_reply) \
4835 _(af_packet_delete_reply) \
4836 _(policer_classify_set_interface_reply) \
4837 _(netmap_create_reply) \
4838 _(netmap_delete_reply) \
4839 _(set_ipfix_exporter_reply) \
4840 _(set_ipfix_classify_stream_reply) \
4841 _(ipfix_classify_table_add_del_reply) \
4842 _(flow_classify_set_interface_reply) \
4843 _(sw_interface_span_enable_disable_reply) \
4844 _(pg_capture_reply) \
4845 _(pg_enable_disable_reply) \
4846 _(ip_source_and_port_range_check_add_del_reply) \
4847 _(ip_source_and_port_range_check_interface_add_del_reply)\
4848 _(delete_subif_reply) \
4849 _(l2_interface_pbb_tag_rewrite_reply) \
4851 _(feature_enable_disable_reply) \
4852 _(sw_interface_tag_add_del_reply) \
4853 _(sw_interface_set_mtu_reply) \
4854 _(p2p_ethernet_add_reply) \
4855 _(p2p_ethernet_del_reply) \
4856 _(lldp_config_reply) \
4857 _(sw_interface_set_lldp_reply) \
4858 _(tcp_configure_src_addresses_reply)
4861 static void vl_api_##n##_t_handler \
4862 (vl_api_##n##_t * mp) \
4864 vat_main_t * vam = &vat_main; \
4865 i32 retval = ntohl(mp->retval); \
4866 if (vam->async_mode) { \
4867 vam->async_errors += (retval < 0); \
4869 vam->retval = retval; \
4870 vam->result_ready = 1; \
4873 foreach_standard_reply_retval_handler;
4877 static void vl_api_##n##_t_handler_json \
4878 (vl_api_##n##_t * mp) \
4880 vat_main_t * vam = &vat_main; \
4881 vat_json_node_t node; \
4882 vat_json_init_object(&node); \
4883 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4884 vat_json_print(vam->ofp, &node); \
4885 vam->retval = ntohl(mp->retval); \
4886 vam->result_ready = 1; \
4888 foreach_standard_reply_retval_handler;
4892 * Table of message reply handlers, must include boilerplate handlers
4896 #define foreach_vpe_api_reply_msg \
4897 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4898 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4899 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4900 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4901 _(CONTROL_PING_REPLY, control_ping_reply) \
4902 _(CLI_REPLY, cli_reply) \
4903 _(CLI_INBAND_REPLY, cli_inband_reply) \
4904 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4905 sw_interface_add_del_address_reply) \
4906 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4907 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4908 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4909 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4910 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4911 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4912 sw_interface_set_l2_xconnect_reply) \
4913 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4914 sw_interface_set_l2_bridge_reply) \
4915 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4916 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4917 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4918 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4919 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4920 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4921 _(L2_FLAGS_REPLY, l2_flags_reply) \
4922 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4923 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4924 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4925 _(TAP_DELETE_REPLY, tap_delete_reply) \
4926 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4927 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4928 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
4929 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4930 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
4931 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4932 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4933 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4934 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4935 proxy_arp_intfc_enable_disable_reply) \
4936 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4937 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4938 sw_interface_set_unnumbered_reply) \
4939 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4940 _(RESET_VRF_REPLY, reset_vrf_reply) \
4941 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4942 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4943 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4944 _(RESET_FIB_REPLY, reset_fib_reply) \
4945 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4946 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4947 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4948 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4949 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4950 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4951 sw_interface_ip6_enable_disable_reply) \
4952 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4953 sw_interface_ip6_set_link_local_address_reply) \
4954 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4955 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4956 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4957 sw_interface_ip6nd_ra_prefix_reply) \
4958 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4959 sw_interface_ip6nd_ra_config_reply) \
4960 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4961 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4962 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4963 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4964 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4965 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4966 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4967 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4968 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4969 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4970 classify_set_interface_ip_table_reply) \
4971 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4972 classify_set_interface_l2_tables_reply) \
4973 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4974 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4975 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4976 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4977 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4978 l2tpv3_interface_enable_disable_reply) \
4979 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4980 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4981 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4982 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4983 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4984 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4985 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4986 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4987 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4988 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4989 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4990 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4991 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4992 _(SHOW_VERSION_REPLY, show_version_reply) \
4993 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4994 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4995 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4996 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4997 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4998 _(IP4_ARP_EVENT, ip4_arp_event) \
4999 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
5000 _(IP6_ND_EVENT, ip6_nd_event) \
5001 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
5002 _(L2_MACS_EVENT, l2_macs_event) \
5003 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
5004 _(IP_ADDRESS_DETAILS, ip_address_details) \
5005 _(IP_DETAILS, ip_details) \
5006 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
5007 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
5008 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
5009 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
5010 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
5011 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
5012 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
5013 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
5014 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
5015 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
5016 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
5017 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
5018 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
5019 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
5020 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
5021 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
5022 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
5023 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
5024 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
5025 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
5026 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
5027 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
5028 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
5029 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
5030 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
5031 _(MAP_DOMAIN_DETAILS, map_domain_details) \
5032 _(MAP_RULE_DETAILS, map_rule_details) \
5033 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
5034 _(WANT_STATS_REPLY, want_stats_reply) \
5035 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
5036 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
5037 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
5038 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
5039 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
5040 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
5041 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
5042 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
5043 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
5044 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
5045 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
5046 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
5047 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
5048 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
5049 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
5050 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
5051 one_map_register_enable_disable_reply) \
5052 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
5053 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5054 one_map_register_fallback_threshold_reply) \
5055 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
5056 one_rloc_probe_enable_disable_reply) \
5057 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
5058 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
5059 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
5060 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
5061 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
5062 _(ONE_LOCATOR_DETAILS, one_locator_details) \
5063 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
5064 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
5065 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
5066 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
5067 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
5068 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
5069 _(ONE_STATS_DETAILS, one_stats_details) \
5070 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
5071 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
5072 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
5073 show_one_stats_enable_disable_reply) \
5074 _(ONE_ADD_DEL_NDP_ENTRY_REPLY, one_add_del_ndp_entry_reply) \
5075 _(ONE_NDP_BD_GET_REPLY, one_ndp_bd_get_reply) \
5076 _(ONE_NDP_ENTRIES_GET_REPLY, one_ndp_entries_get_reply) \
5077 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
5078 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
5079 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
5080 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
5081 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
5082 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
5083 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
5084 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
5085 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
5086 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
5087 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
5088 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
5089 gpe_add_del_native_fwd_rpath_reply) \
5090 _(GPE_FWD_ENTRY_PATH_DETAILS, \
5091 gpe_fwd_entry_path_details) \
5092 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
5093 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
5094 one_add_del_map_request_itr_rlocs_reply) \
5095 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
5096 one_get_map_request_itr_rlocs_reply) \
5097 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
5098 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
5099 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
5100 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
5101 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
5102 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
5103 show_one_map_register_state_reply) \
5104 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
5105 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
5106 show_one_map_register_fallback_threshold_reply) \
5107 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
5108 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
5109 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
5110 _(POLICER_DETAILS, policer_details) \
5111 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
5112 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
5113 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
5114 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
5115 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
5116 _(MPLS_FIB_DETAILS, mpls_fib_details) \
5117 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
5118 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
5119 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
5120 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
5121 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
5122 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
5123 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5124 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5125 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5126 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5127 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5128 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5129 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5130 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5131 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5132 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5133 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5134 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5135 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5136 ip_source_and_port_range_check_add_del_reply) \
5137 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5138 ip_source_and_port_range_check_interface_add_del_reply) \
5139 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5140 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5141 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5142 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5143 _(PUNT_REPLY, punt_reply) \
5144 _(IP_FIB_DETAILS, ip_fib_details) \
5145 _(IP6_FIB_DETAILS, ip6_fib_details) \
5146 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5147 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5148 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5149 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5150 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5151 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5152 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5153 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5154 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5155 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5156 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply)
5158 #define foreach_standalone_reply_msg \
5159 _(SW_INTERFACE_EVENT, sw_interface_event) \
5160 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5161 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5162 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5163 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5164 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5165 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5174 #define STR_VTR_OP_CASE(op) \
5175 case L2_VTR_ ## op: \
5179 str_vtr_op (u32 vtr_op)
5183 STR_VTR_OP_CASE (DISABLED);
5184 STR_VTR_OP_CASE (PUSH_1);
5185 STR_VTR_OP_CASE (PUSH_2);
5186 STR_VTR_OP_CASE (POP_1);
5187 STR_VTR_OP_CASE (POP_2);
5188 STR_VTR_OP_CASE (TRANSLATE_1_1);
5189 STR_VTR_OP_CASE (TRANSLATE_1_2);
5190 STR_VTR_OP_CASE (TRANSLATE_2_1);
5191 STR_VTR_OP_CASE (TRANSLATE_2_2);
5198 dump_sub_interface_table (vat_main_t * vam)
5200 const sw_interface_subif_t *sub = NULL;
5202 if (vam->json_output)
5205 ("JSON output supported only for VPE API calls and dump_stats_table");
5210 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5211 "Interface", "sw_if_index",
5212 "sub id", "dot1ad", "tags", "outer id",
5213 "inner id", "exact", "default", "outer any", "inner any");
5215 vec_foreach (sub, vam->sw_if_subif_table)
5218 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5219 sub->interface_name,
5221 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5222 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5223 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5224 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5225 if (sub->vtr_op != L2_VTR_DISABLED)
5228 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5229 "tag1: %d tag2: %d ]",
5230 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5231 sub->vtr_tag1, sub->vtr_tag2);
5239 name_sort_cmp (void *a1, void *a2)
5241 name_sort_t *n1 = a1;
5242 name_sort_t *n2 = a2;
5244 return strcmp ((char *) n1->name, (char *) n2->name);
5248 dump_interface_table (vat_main_t * vam)
5251 name_sort_t *nses = 0, *ns;
5253 if (vam->json_output)
5256 ("JSON output supported only for VPE API calls and dump_stats_table");
5261 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5263 vec_add2 (nses, ns, 1);
5264 ns->name = (u8 *)(p->key);
5265 ns->value = (u32) p->value[0];
5269 vec_sort_with_function (nses, name_sort_cmp);
5271 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5272 vec_foreach (ns, nses)
5274 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5281 dump_ip_table (vat_main_t * vam, int is_ipv6)
5283 const ip_details_t *det = NULL;
5284 const ip_address_details_t *address = NULL;
5287 print (vam->ofp, "%-12s", "sw_if_index");
5289 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5296 print (vam->ofp, "%-12d", i);
5297 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5302 vec_foreach (address, det->addr)
5306 is_ipv6 ? format_ip6_address : format_ip4_address,
5307 address->ip, address->prefix_length);
5315 dump_ipv4_table (vat_main_t * vam)
5317 if (vam->json_output)
5320 ("JSON output supported only for VPE API calls and dump_stats_table");
5324 return dump_ip_table (vam, 0);
5328 dump_ipv6_table (vat_main_t * vam)
5330 if (vam->json_output)
5333 ("JSON output supported only for VPE API calls and dump_stats_table");
5337 return dump_ip_table (vam, 1);
5341 counter_type_to_str (u8 counter_type, u8 is_combined)
5345 switch (counter_type)
5347 case VNET_INTERFACE_COUNTER_DROP:
5349 case VNET_INTERFACE_COUNTER_PUNT:
5351 case VNET_INTERFACE_COUNTER_IP4:
5353 case VNET_INTERFACE_COUNTER_IP6:
5355 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5357 case VNET_INTERFACE_COUNTER_RX_MISS:
5359 case VNET_INTERFACE_COUNTER_RX_ERROR:
5361 case VNET_INTERFACE_COUNTER_TX_ERROR:
5364 return "INVALID-COUNTER-TYPE";
5369 switch (counter_type)
5371 case VNET_INTERFACE_COUNTER_RX:
5373 case VNET_INTERFACE_COUNTER_TX:
5376 return "INVALID-COUNTER-TYPE";
5382 dump_stats_table (vat_main_t * vam)
5384 vat_json_node_t node;
5385 vat_json_node_t *msg_array;
5386 vat_json_node_t *msg;
5387 vat_json_node_t *counter_array;
5388 vat_json_node_t *counter;
5389 interface_counter_t c;
5391 ip4_fib_counter_t *c4;
5392 ip6_fib_counter_t *c6;
5393 ip4_nbr_counter_t *n4;
5394 ip6_nbr_counter_t *n6;
5397 if (!vam->json_output)
5399 clib_warning ("dump_stats_table supported only in JSON format");
5403 vat_json_init_object (&node);
5405 /* interface counters */
5406 msg_array = vat_json_object_add (&node, "interface_counters");
5407 vat_json_init_array (msg_array);
5408 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5410 msg = vat_json_array_add (msg_array);
5411 vat_json_init_object (msg);
5412 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5413 (u8 *) counter_type_to_str (i, 0));
5414 vat_json_object_add_int (msg, "is_combined", 0);
5415 counter_array = vat_json_object_add (msg, "data");
5416 vat_json_init_array (counter_array);
5417 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5419 packets = vam->simple_interface_counters[i][j];
5420 vat_json_array_add_uint (counter_array, packets);
5423 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5425 msg = vat_json_array_add (msg_array);
5426 vat_json_init_object (msg);
5427 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5428 (u8 *) counter_type_to_str (i, 1));
5429 vat_json_object_add_int (msg, "is_combined", 1);
5430 counter_array = vat_json_object_add (msg, "data");
5431 vat_json_init_array (counter_array);
5432 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5434 c = vam->combined_interface_counters[i][j];
5435 counter = vat_json_array_add (counter_array);
5436 vat_json_init_object (counter);
5437 vat_json_object_add_uint (counter, "packets", c.packets);
5438 vat_json_object_add_uint (counter, "bytes", c.bytes);
5442 /* ip4 fib counters */
5443 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5444 vat_json_init_array (msg_array);
5445 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5447 msg = vat_json_array_add (msg_array);
5448 vat_json_init_object (msg);
5449 vat_json_object_add_uint (msg, "vrf_id",
5450 vam->ip4_fib_counters_vrf_id_by_index[i]);
5451 counter_array = vat_json_object_add (msg, "c");
5452 vat_json_init_array (counter_array);
5453 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5455 counter = vat_json_array_add (counter_array);
5456 vat_json_init_object (counter);
5457 c4 = &vam->ip4_fib_counters[i][j];
5458 vat_json_object_add_ip4 (counter, "address", c4->address);
5459 vat_json_object_add_uint (counter, "address_length",
5460 c4->address_length);
5461 vat_json_object_add_uint (counter, "packets", c4->packets);
5462 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5466 /* ip6 fib counters */
5467 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5468 vat_json_init_array (msg_array);
5469 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5471 msg = vat_json_array_add (msg_array);
5472 vat_json_init_object (msg);
5473 vat_json_object_add_uint (msg, "vrf_id",
5474 vam->ip6_fib_counters_vrf_id_by_index[i]);
5475 counter_array = vat_json_object_add (msg, "c");
5476 vat_json_init_array (counter_array);
5477 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5479 counter = vat_json_array_add (counter_array);
5480 vat_json_init_object (counter);
5481 c6 = &vam->ip6_fib_counters[i][j];
5482 vat_json_object_add_ip6 (counter, "address", c6->address);
5483 vat_json_object_add_uint (counter, "address_length",
5484 c6->address_length);
5485 vat_json_object_add_uint (counter, "packets", c6->packets);
5486 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5490 /* ip4 nbr counters */
5491 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5492 vat_json_init_array (msg_array);
5493 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5495 msg = vat_json_array_add (msg_array);
5496 vat_json_init_object (msg);
5497 vat_json_object_add_uint (msg, "sw_if_index", i);
5498 counter_array = vat_json_object_add (msg, "c");
5499 vat_json_init_array (counter_array);
5500 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5502 counter = vat_json_array_add (counter_array);
5503 vat_json_init_object (counter);
5504 n4 = &vam->ip4_nbr_counters[i][j];
5505 vat_json_object_add_ip4 (counter, "address", n4->address);
5506 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5507 vat_json_object_add_uint (counter, "packets", n4->packets);
5508 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5512 /* ip6 nbr counters */
5513 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5514 vat_json_init_array (msg_array);
5515 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5517 msg = vat_json_array_add (msg_array);
5518 vat_json_init_object (msg);
5519 vat_json_object_add_uint (msg, "sw_if_index", i);
5520 counter_array = vat_json_object_add (msg, "c");
5521 vat_json_init_array (counter_array);
5522 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5524 counter = vat_json_array_add (counter_array);
5525 vat_json_init_object (counter);
5526 n6 = &vam->ip6_nbr_counters[i][j];
5527 vat_json_object_add_ip6 (counter, "address", n6->address);
5528 vat_json_object_add_uint (counter, "packets", n6->packets);
5529 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5533 vat_json_print (vam->ofp, &node);
5534 vat_json_free (&node);
5540 exec (vat_main_t * vam)
5542 api_main_t *am = &api_main;
5547 unformat_input_t *i = vam->input;
5549 if (vec_len (i->buffer) == 0)
5552 if (vam->exec_mode == 0 && unformat (i, "mode"))
5557 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5567 * Copy cmd into shared memory.
5568 * In order for the CLI command to work, it
5569 * must be a vector ending in \n, not a C-string ending
5572 pthread_mutex_lock (&am->vlib_rp->mutex);
5573 oldheap = svm_push_data_heap (am->vlib_rp);
5575 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5576 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5578 svm_pop_heap (oldheap);
5579 pthread_mutex_unlock (&am->vlib_rp->mutex);
5581 mp->cmd_in_shmem = pointer_to_uword (cmd);
5583 timeout = vat_time_now (vam) + 10.0;
5585 while (vat_time_now (vam) < timeout)
5587 if (vam->result_ready == 1)
5590 if (vam->shmem_result != NULL)
5591 print (vam->ofp, "%s", vam->shmem_result);
5592 pthread_mutex_lock (&am->vlib_rp->mutex);
5593 oldheap = svm_push_data_heap (am->vlib_rp);
5595 free_me = (u8 *) vam->shmem_result;
5598 svm_pop_heap (oldheap);
5599 pthread_mutex_unlock (&am->vlib_rp->mutex);
5607 * Future replacement of exec() that passes CLI buffers directly in
5608 * the API messages instead of an additional shared memory area.
5611 exec_inband (vat_main_t * vam)
5613 vl_api_cli_inband_t *mp;
5614 unformat_input_t *i = vam->input;
5617 if (vec_len (i->buffer) == 0)
5620 if (vam->exec_mode == 0 && unformat (i, "mode"))
5625 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5632 * In order for the CLI command to work, it
5633 * must be a vector ending in \n, not a C-string ending
5636 u32 len = vec_len (vam->input->buffer);
5637 M2 (CLI_INBAND, mp, len);
5638 clib_memcpy (mp->cmd, vam->input->buffer, len);
5639 mp->length = htonl (len);
5642 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5647 api_create_loopback (vat_main_t * vam)
5649 unformat_input_t *i = vam->input;
5650 vl_api_create_loopback_t *mp;
5651 vl_api_create_loopback_instance_t *mp_lbi;
5654 u8 is_specified = 0;
5655 u32 user_instance = 0;
5658 memset (mac_address, 0, sizeof (mac_address));
5660 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5662 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5664 if (unformat (i, "instance %d", &user_instance))
5672 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5673 mp_lbi->is_specified = is_specified;
5675 mp_lbi->user_instance = htonl (user_instance);
5677 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5682 /* Construct the API message */
5683 M (CREATE_LOOPBACK, mp);
5685 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5694 api_delete_loopback (vat_main_t * vam)
5696 unformat_input_t *i = vam->input;
5697 vl_api_delete_loopback_t *mp;
5698 u32 sw_if_index = ~0;
5701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5703 if (unformat (i, "sw_if_index %d", &sw_if_index))
5709 if (sw_if_index == ~0)
5711 errmsg ("missing sw_if_index");
5715 /* Construct the API message */
5716 M (DELETE_LOOPBACK, mp);
5717 mp->sw_if_index = ntohl (sw_if_index);
5725 api_want_stats (vat_main_t * vam)
5727 unformat_input_t *i = vam->input;
5728 vl_api_want_stats_t *mp;
5732 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5734 if (unformat (i, "enable"))
5736 else if (unformat (i, "disable"))
5744 errmsg ("missing enable|disable");
5749 mp->enable_disable = enable;
5757 api_want_interface_events (vat_main_t * vam)
5759 unformat_input_t *i = vam->input;
5760 vl_api_want_interface_events_t *mp;
5764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5766 if (unformat (i, "enable"))
5768 else if (unformat (i, "disable"))
5776 errmsg ("missing enable|disable");
5780 M (WANT_INTERFACE_EVENTS, mp);
5781 mp->enable_disable = enable;
5783 vam->interface_event_display = enable;
5791 /* Note: non-static, called once to set up the initial intfc table */
5793 api_sw_interface_dump (vat_main_t * vam)
5795 vl_api_sw_interface_dump_t *mp;
5796 vl_api_control_ping_t *mp_ping;
5798 name_sort_t *nses = 0, *ns;
5799 sw_interface_subif_t *sub = NULL;
5802 /* Toss the old name table */
5804 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5806 vec_add2 (nses, ns, 1);
5807 ns->name = (u8 *)(p->key);
5808 ns->value = (u32) p->value[0];
5812 hash_free (vam->sw_if_index_by_interface_name);
5814 vec_foreach (ns, nses) vec_free (ns->name);
5818 vec_foreach (sub, vam->sw_if_subif_table)
5820 vec_free (sub->interface_name);
5822 vec_free (vam->sw_if_subif_table);
5824 /* recreate the interface name hash table */
5825 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5827 /* Get list of ethernets */
5828 M (SW_INTERFACE_DUMP, mp);
5829 mp->name_filter_valid = 1;
5830 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5833 /* and local / loopback interfaces */
5834 M (SW_INTERFACE_DUMP, mp);
5835 mp->name_filter_valid = 1;
5836 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5839 /* and packet-generator interfaces */
5840 M (SW_INTERFACE_DUMP, mp);
5841 mp->name_filter_valid = 1;
5842 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5845 /* and vxlan-gpe tunnel interfaces */
5846 M (SW_INTERFACE_DUMP, mp);
5847 mp->name_filter_valid = 1;
5848 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5849 sizeof (mp->name_filter) - 1);
5852 /* and vxlan tunnel interfaces */
5853 M (SW_INTERFACE_DUMP, mp);
5854 mp->name_filter_valid = 1;
5855 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5858 /* and host (af_packet) interfaces */
5859 M (SW_INTERFACE_DUMP, mp);
5860 mp->name_filter_valid = 1;
5861 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5864 /* and l2tpv3 tunnel interfaces */
5865 M (SW_INTERFACE_DUMP, mp);
5866 mp->name_filter_valid = 1;
5867 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5868 sizeof (mp->name_filter) - 1);
5871 /* and GRE tunnel interfaces */
5872 M (SW_INTERFACE_DUMP, mp);
5873 mp->name_filter_valid = 1;
5874 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5877 /* and LISP-GPE interfaces */
5878 M (SW_INTERFACE_DUMP, mp);
5879 mp->name_filter_valid = 1;
5880 strncpy ((char *) mp->name_filter, "lisp_gpe",
5881 sizeof (mp->name_filter) - 1);
5884 /* and IPSEC tunnel interfaces */
5885 M (SW_INTERFACE_DUMP, mp);
5886 mp->name_filter_valid = 1;
5887 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5890 /* Use a control ping for synchronization */
5891 M (CONTROL_PING, mp_ping);
5899 api_sw_interface_set_flags (vat_main_t * vam)
5901 unformat_input_t *i = vam->input;
5902 vl_api_sw_interface_set_flags_t *mp;
5904 u8 sw_if_index_set = 0;
5908 /* Parse args required to build the message */
5909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5911 if (unformat (i, "admin-up"))
5913 else if (unformat (i, "admin-down"))
5916 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5917 sw_if_index_set = 1;
5918 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5919 sw_if_index_set = 1;
5924 if (sw_if_index_set == 0)
5926 errmsg ("missing interface name or sw_if_index");
5930 /* Construct the API message */
5931 M (SW_INTERFACE_SET_FLAGS, mp);
5932 mp->sw_if_index = ntohl (sw_if_index);
5933 mp->admin_up_down = admin_up;
5938 /* Wait for a reply, return the good/bad news... */
5944 api_sw_interface_clear_stats (vat_main_t * vam)
5946 unformat_input_t *i = vam->input;
5947 vl_api_sw_interface_clear_stats_t *mp;
5949 u8 sw_if_index_set = 0;
5952 /* Parse args required to build the message */
5953 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5955 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5956 sw_if_index_set = 1;
5957 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5958 sw_if_index_set = 1;
5963 /* Construct the API message */
5964 M (SW_INTERFACE_CLEAR_STATS, mp);
5966 if (sw_if_index_set == 1)
5967 mp->sw_if_index = ntohl (sw_if_index);
5969 mp->sw_if_index = ~0;
5974 /* Wait for a reply, return the good/bad news... */
5980 api_sw_interface_add_del_address (vat_main_t * vam)
5982 unformat_input_t *i = vam->input;
5983 vl_api_sw_interface_add_del_address_t *mp;
5985 u8 sw_if_index_set = 0;
5986 u8 is_add = 1, del_all = 0;
5987 u32 address_length = 0;
5988 u8 v4_address_set = 0;
5989 u8 v6_address_set = 0;
5990 ip4_address_t v4address;
5991 ip6_address_t v6address;
5994 /* Parse args required to build the message */
5995 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5997 if (unformat (i, "del-all"))
5999 else if (unformat (i, "del"))
6002 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6003 sw_if_index_set = 1;
6004 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6005 sw_if_index_set = 1;
6006 else if (unformat (i, "%U/%d",
6007 unformat_ip4_address, &v4address, &address_length))
6009 else if (unformat (i, "%U/%d",
6010 unformat_ip6_address, &v6address, &address_length))
6016 if (sw_if_index_set == 0)
6018 errmsg ("missing interface name or sw_if_index");
6021 if (v4_address_set && v6_address_set)
6023 errmsg ("both v4 and v6 addresses set");
6026 if (!v4_address_set && !v6_address_set && !del_all)
6028 errmsg ("no addresses set");
6032 /* Construct the API message */
6033 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
6035 mp->sw_if_index = ntohl (sw_if_index);
6036 mp->is_add = is_add;
6037 mp->del_all = del_all;
6041 clib_memcpy (mp->address, &v6address, sizeof (v6address));
6045 clib_memcpy (mp->address, &v4address, sizeof (v4address));
6047 mp->address_length = address_length;
6052 /* Wait for a reply, return good/bad news */
6058 api_sw_interface_set_mpls_enable (vat_main_t * vam)
6060 unformat_input_t *i = vam->input;
6061 vl_api_sw_interface_set_mpls_enable_t *mp;
6063 u8 sw_if_index_set = 0;
6067 /* Parse args required to build the message */
6068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6070 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6071 sw_if_index_set = 1;
6072 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6073 sw_if_index_set = 1;
6074 else if (unformat (i, "disable"))
6076 else if (unformat (i, "dis"))
6082 if (sw_if_index_set == 0)
6084 errmsg ("missing interface name or sw_if_index");
6088 /* Construct the API message */
6089 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
6091 mp->sw_if_index = ntohl (sw_if_index);
6092 mp->enable = enable;
6097 /* Wait for a reply... */
6103 api_sw_interface_set_table (vat_main_t * vam)
6105 unformat_input_t *i = vam->input;
6106 vl_api_sw_interface_set_table_t *mp;
6107 u32 sw_if_index, vrf_id = 0;
6108 u8 sw_if_index_set = 0;
6112 /* Parse args required to build the message */
6113 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6115 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6116 sw_if_index_set = 1;
6117 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6118 sw_if_index_set = 1;
6119 else if (unformat (i, "vrf %d", &vrf_id))
6121 else if (unformat (i, "ipv6"))
6127 if (sw_if_index_set == 0)
6129 errmsg ("missing interface name or sw_if_index");
6133 /* Construct the API message */
6134 M (SW_INTERFACE_SET_TABLE, mp);
6136 mp->sw_if_index = ntohl (sw_if_index);
6137 mp->is_ipv6 = is_ipv6;
6138 mp->vrf_id = ntohl (vrf_id);
6143 /* Wait for a reply... */
6148 static void vl_api_sw_interface_get_table_reply_t_handler
6149 (vl_api_sw_interface_get_table_reply_t * mp)
6151 vat_main_t *vam = &vat_main;
6153 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6155 vam->retval = ntohl (mp->retval);
6156 vam->result_ready = 1;
6160 static void vl_api_sw_interface_get_table_reply_t_handler_json
6161 (vl_api_sw_interface_get_table_reply_t * mp)
6163 vat_main_t *vam = &vat_main;
6164 vat_json_node_t node;
6166 vat_json_init_object (&node);
6167 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6168 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6170 vat_json_print (vam->ofp, &node);
6171 vat_json_free (&node);
6173 vam->retval = ntohl (mp->retval);
6174 vam->result_ready = 1;
6178 api_sw_interface_get_table (vat_main_t * vam)
6180 unformat_input_t *i = vam->input;
6181 vl_api_sw_interface_get_table_t *mp;
6183 u8 sw_if_index_set = 0;
6187 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6189 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6190 sw_if_index_set = 1;
6191 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6192 sw_if_index_set = 1;
6193 else if (unformat (i, "ipv6"))
6199 if (sw_if_index_set == 0)
6201 errmsg ("missing interface name or sw_if_index");
6205 M (SW_INTERFACE_GET_TABLE, mp);
6206 mp->sw_if_index = htonl (sw_if_index);
6207 mp->is_ipv6 = is_ipv6;
6215 api_sw_interface_set_vpath (vat_main_t * vam)
6217 unformat_input_t *i = vam->input;
6218 vl_api_sw_interface_set_vpath_t *mp;
6219 u32 sw_if_index = 0;
6220 u8 sw_if_index_set = 0;
6224 /* Parse args required to build the message */
6225 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6227 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6228 sw_if_index_set = 1;
6229 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6230 sw_if_index_set = 1;
6231 else if (unformat (i, "enable"))
6233 else if (unformat (i, "disable"))
6239 if (sw_if_index_set == 0)
6241 errmsg ("missing interface name or sw_if_index");
6245 /* Construct the API message */
6246 M (SW_INTERFACE_SET_VPATH, mp);
6248 mp->sw_if_index = ntohl (sw_if_index);
6249 mp->enable = is_enable;
6254 /* Wait for a reply... */
6260 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6262 unformat_input_t *i = vam->input;
6263 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6264 u32 sw_if_index = 0;
6265 u8 sw_if_index_set = 0;
6270 /* Parse args required to build the message */
6271 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6273 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6274 sw_if_index_set = 1;
6275 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6276 sw_if_index_set = 1;
6277 else if (unformat (i, "enable"))
6279 else if (unformat (i, "disable"))
6281 else if (unformat (i, "ip4"))
6283 else if (unformat (i, "ip6"))
6289 if (sw_if_index_set == 0)
6291 errmsg ("missing interface name or sw_if_index");
6295 /* Construct the API message */
6296 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6298 mp->sw_if_index = ntohl (sw_if_index);
6299 mp->enable = is_enable;
6300 mp->is_ipv6 = is_ipv6;
6305 /* Wait for a reply... */
6312 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6314 unformat_input_t *i = vam->input;
6315 vl_api_sw_interface_set_l2_xconnect_t *mp;
6317 u8 rx_sw_if_index_set = 0;
6319 u8 tx_sw_if_index_set = 0;
6323 /* Parse args required to build the message */
6324 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6326 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6327 rx_sw_if_index_set = 1;
6328 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6329 tx_sw_if_index_set = 1;
6330 else if (unformat (i, "rx"))
6332 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6334 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6336 rx_sw_if_index_set = 1;
6341 else if (unformat (i, "tx"))
6343 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6345 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6347 tx_sw_if_index_set = 1;
6352 else if (unformat (i, "enable"))
6354 else if (unformat (i, "disable"))
6360 if (rx_sw_if_index_set == 0)
6362 errmsg ("missing rx interface name or rx_sw_if_index");
6366 if (enable && (tx_sw_if_index_set == 0))
6368 errmsg ("missing tx interface name or tx_sw_if_index");
6372 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6374 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6375 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6376 mp->enable = enable;
6384 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6386 unformat_input_t *i = vam->input;
6387 vl_api_sw_interface_set_l2_bridge_t *mp;
6389 u8 rx_sw_if_index_set = 0;
6397 /* Parse args required to build the message */
6398 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6400 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6401 rx_sw_if_index_set = 1;
6402 else if (unformat (i, "bd_id %d", &bd_id))
6406 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6407 rx_sw_if_index_set = 1;
6408 else if (unformat (i, "shg %d", &shg))
6410 else if (unformat (i, "bvi"))
6412 else if (unformat (i, "enable"))
6414 else if (unformat (i, "disable"))
6420 if (rx_sw_if_index_set == 0)
6422 errmsg ("missing rx interface name or sw_if_index");
6426 if (enable && (bd_id_set == 0))
6428 errmsg ("missing bridge domain");
6432 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6434 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6435 mp->bd_id = ntohl (bd_id);
6438 mp->enable = enable;
6446 api_bridge_domain_dump (vat_main_t * vam)
6448 unformat_input_t *i = vam->input;
6449 vl_api_bridge_domain_dump_t *mp;
6450 vl_api_control_ping_t *mp_ping;
6454 /* Parse args required to build the message */
6455 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6457 if (unformat (i, "bd_id %d", &bd_id))
6463 M (BRIDGE_DOMAIN_DUMP, mp);
6464 mp->bd_id = ntohl (bd_id);
6467 /* Use a control ping for synchronization */
6468 M (CONTROL_PING, mp_ping);
6476 api_bridge_domain_add_del (vat_main_t * vam)
6478 unformat_input_t *i = vam->input;
6479 vl_api_bridge_domain_add_del_t *mp;
6482 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6487 /* Parse args required to build the message */
6488 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6490 if (unformat (i, "bd_id %d", &bd_id))
6492 else if (unformat (i, "flood %d", &flood))
6494 else if (unformat (i, "uu-flood %d", &uu_flood))
6496 else if (unformat (i, "forward %d", &forward))
6498 else if (unformat (i, "learn %d", &learn))
6500 else if (unformat (i, "arp-term %d", &arp_term))
6502 else if (unformat (i, "mac-age %d", &mac_age))
6504 else if (unformat (i, "bd-tag %s", &bd_tag))
6506 else if (unformat (i, "del"))
6509 flood = uu_flood = forward = learn = 0;
6517 errmsg ("missing bridge domain");
6524 errmsg ("mac age must be less than 256 ");
6529 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6531 errmsg ("bd-tag cannot be longer than 63");
6536 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6538 mp->bd_id = ntohl (bd_id);
6540 mp->uu_flood = uu_flood;
6541 mp->forward = forward;
6543 mp->arp_term = arp_term;
6544 mp->is_add = is_add;
6545 mp->mac_age = (u8) mac_age;
6547 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6558 api_l2fib_flush_bd (vat_main_t * vam)
6560 unformat_input_t *i = vam->input;
6561 vl_api_l2fib_flush_bd_t *mp;
6565 /* Parse args required to build the message */
6566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6568 if (unformat (i, "bd_id %d", &bd_id));
6575 errmsg ("missing bridge domain");
6579 M (L2FIB_FLUSH_BD, mp);
6581 mp->bd_id = htonl (bd_id);
6589 api_l2fib_flush_int (vat_main_t * vam)
6591 unformat_input_t *i = vam->input;
6592 vl_api_l2fib_flush_int_t *mp;
6593 u32 sw_if_index = ~0;
6596 /* Parse args required to build the message */
6597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6599 if (unformat (i, "sw_if_index %d", &sw_if_index));
6601 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6606 if (sw_if_index == ~0)
6608 errmsg ("missing interface name or sw_if_index");
6612 M (L2FIB_FLUSH_INT, mp);
6614 mp->sw_if_index = ntohl (sw_if_index);
6622 api_l2fib_add_del (vat_main_t * vam)
6624 unformat_input_t *i = vam->input;
6625 vl_api_l2fib_add_del_t *mp;
6631 u32 sw_if_index = ~0;
6632 u8 sw_if_index_set = 0;
6641 /* Parse args required to build the message */
6642 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6644 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6646 else if (unformat (i, "bd_id %d", &bd_id))
6648 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6649 sw_if_index_set = 1;
6650 else if (unformat (i, "sw_if"))
6652 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6655 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6656 sw_if_index_set = 1;
6661 else if (unformat (i, "static"))
6663 else if (unformat (i, "filter"))
6668 else if (unformat (i, "bvi"))
6673 else if (unformat (i, "del"))
6675 else if (unformat (i, "count %d", &count))
6683 errmsg ("missing mac address");
6689 errmsg ("missing bridge domain");
6693 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6695 errmsg ("missing interface name or sw_if_index");
6701 /* Turn on async mode */
6702 vam->async_mode = 1;
6703 vam->async_errors = 0;
6704 before = vat_time_now (vam);
6707 for (j = 0; j < count; j++)
6709 M (L2FIB_ADD_DEL, mp);
6712 mp->bd_id = ntohl (bd_id);
6713 mp->is_add = is_add;
6717 mp->sw_if_index = ntohl (sw_if_index);
6718 mp->static_mac = static_mac;
6719 mp->filter_mac = filter_mac;
6720 mp->bvi_mac = bvi_mac;
6722 increment_mac_address (&mac);
6729 vl_api_control_ping_t *mp_ping;
6732 /* Shut off async mode */
6733 vam->async_mode = 0;
6735 M (CONTROL_PING, mp_ping);
6738 timeout = vat_time_now (vam) + 1.0;
6739 while (vat_time_now (vam) < timeout)
6740 if (vam->result_ready == 1)
6745 if (vam->retval == -99)
6748 if (vam->async_errors > 0)
6750 errmsg ("%d asynchronous errors", vam->async_errors);
6753 vam->async_errors = 0;
6754 after = vat_time_now (vam);
6756 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6757 count, after - before, count / (after - before));
6763 /* Wait for a reply... */
6767 /* Return the good/bad news */
6768 return (vam->retval);
6772 api_bridge_domain_set_mac_age (vat_main_t * vam)
6774 unformat_input_t *i = vam->input;
6775 vl_api_bridge_domain_set_mac_age_t *mp;
6780 /* Parse args required to build the message */
6781 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6783 if (unformat (i, "bd_id %d", &bd_id));
6784 else if (unformat (i, "mac-age %d", &mac_age));
6791 errmsg ("missing bridge domain");
6797 errmsg ("mac age must be less than 256 ");
6801 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6803 mp->bd_id = htonl (bd_id);
6804 mp->mac_age = (u8) mac_age;
6812 api_l2_flags (vat_main_t * vam)
6814 unformat_input_t *i = vam->input;
6815 vl_api_l2_flags_t *mp;
6818 u8 sw_if_index_set = 0;
6822 /* Parse args required to build the message */
6823 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6825 if (unformat (i, "sw_if_index %d", &sw_if_index))
6826 sw_if_index_set = 1;
6827 else if (unformat (i, "sw_if"))
6829 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6832 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6833 sw_if_index_set = 1;
6838 else if (unformat (i, "learn"))
6840 else if (unformat (i, "forward"))
6842 else if (unformat (i, "flood"))
6844 else if (unformat (i, "uu-flood"))
6845 flags |= L2_UU_FLOOD;
6846 else if (unformat (i, "arp-term"))
6847 flags |= L2_ARP_TERM;
6848 else if (unformat (i, "off"))
6850 else if (unformat (i, "disable"))
6856 if (sw_if_index_set == 0)
6858 errmsg ("missing interface name or sw_if_index");
6864 mp->sw_if_index = ntohl (sw_if_index);
6865 mp->feature_bitmap = ntohl (flags);
6866 mp->is_set = is_set;
6874 api_bridge_flags (vat_main_t * vam)
6876 unformat_input_t *i = vam->input;
6877 vl_api_bridge_flags_t *mp;
6884 /* Parse args required to build the message */
6885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6887 if (unformat (i, "bd_id %d", &bd_id))
6889 else if (unformat (i, "learn"))
6891 else if (unformat (i, "forward"))
6893 else if (unformat (i, "flood"))
6895 else if (unformat (i, "uu-flood"))
6896 flags |= L2_UU_FLOOD;
6897 else if (unformat (i, "arp-term"))
6898 flags |= L2_ARP_TERM;
6899 else if (unformat (i, "off"))
6901 else if (unformat (i, "disable"))
6909 errmsg ("missing bridge domain");
6913 M (BRIDGE_FLAGS, mp);
6915 mp->bd_id = ntohl (bd_id);
6916 mp->feature_bitmap = ntohl (flags);
6917 mp->is_set = is_set;
6925 api_bd_ip_mac_add_del (vat_main_t * vam)
6927 unformat_input_t *i = vam->input;
6928 vl_api_bd_ip_mac_add_del_t *mp;
6935 ip4_address_t v4addr;
6936 ip6_address_t v6addr;
6941 /* Parse args required to build the message */
6942 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6944 if (unformat (i, "bd_id %d", &bd_id))
6948 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6952 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6957 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6961 else if (unformat (i, "del"))
6969 errmsg ("missing bridge domain");
6972 else if (ip_set == 0)
6974 errmsg ("missing IP address");
6977 else if (mac_set == 0)
6979 errmsg ("missing MAC address");
6983 M (BD_IP_MAC_ADD_DEL, mp);
6985 mp->bd_id = ntohl (bd_id);
6986 mp->is_ipv6 = is_ipv6;
6987 mp->is_add = is_add;
6989 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6991 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6992 clib_memcpy (mp->mac_address, macaddr, 6);
6999 api_tap_connect (vat_main_t * vam)
7001 unformat_input_t *i = vam->input;
7002 vl_api_tap_connect_t *mp;
7008 ip4_address_t ip4_address;
7010 int ip4_address_set = 0;
7011 ip6_address_t ip6_address;
7013 int ip6_address_set = 0;
7016 memset (mac_address, 0, sizeof (mac_address));
7018 /* Parse args required to build the message */
7019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7021 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7025 else if (unformat (i, "random-mac"))
7027 else if (unformat (i, "tapname %s", &tap_name))
7029 else if (unformat (i, "tag %s", &tag))
7031 else if (unformat (i, "address %U/%d",
7032 unformat_ip4_address, &ip4_address, &ip4_mask_width))
7033 ip4_address_set = 1;
7034 else if (unformat (i, "address %U/%d",
7035 unformat_ip6_address, &ip6_address, &ip6_mask_width))
7036 ip6_address_set = 1;
7043 errmsg ("missing tap name");
7046 if (vec_len (tap_name) > 63)
7048 errmsg ("tap name too long");
7051 vec_add1 (tap_name, 0);
7053 if (vec_len (tag) > 63)
7055 errmsg ("tag too long");
7059 /* Construct the API message */
7060 M (TAP_CONNECT, mp);
7062 mp->use_random_mac = random_mac;
7063 clib_memcpy (mp->mac_address, mac_address, 6);
7064 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7066 clib_memcpy (mp->tag, tag, vec_len (tag));
7068 if (ip4_address_set)
7070 mp->ip4_address_set = 1;
7071 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
7072 mp->ip4_mask_width = ip4_mask_width;
7074 if (ip6_address_set)
7076 mp->ip6_address_set = 1;
7077 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
7078 mp->ip6_mask_width = ip6_mask_width;
7081 vec_free (tap_name);
7087 /* Wait for a reply... */
7093 api_tap_modify (vat_main_t * vam)
7095 unformat_input_t *i = vam->input;
7096 vl_api_tap_modify_t *mp;
7101 u32 sw_if_index = ~0;
7102 u8 sw_if_index_set = 0;
7105 memset (mac_address, 0, sizeof (mac_address));
7107 /* Parse args required to build the message */
7108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7111 sw_if_index_set = 1;
7112 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7113 sw_if_index_set = 1;
7114 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7118 else if (unformat (i, "random-mac"))
7120 else if (unformat (i, "tapname %s", &tap_name))
7126 if (sw_if_index_set == 0)
7128 errmsg ("missing vpp interface name");
7133 errmsg ("missing tap name");
7136 if (vec_len (tap_name) > 63)
7138 errmsg ("tap name too long");
7140 vec_add1 (tap_name, 0);
7142 /* Construct the API message */
7145 mp->use_random_mac = random_mac;
7146 mp->sw_if_index = ntohl (sw_if_index);
7147 clib_memcpy (mp->mac_address, mac_address, 6);
7148 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7149 vec_free (tap_name);
7154 /* Wait for a reply... */
7160 api_tap_delete (vat_main_t * vam)
7162 unformat_input_t *i = vam->input;
7163 vl_api_tap_delete_t *mp;
7164 u32 sw_if_index = ~0;
7165 u8 sw_if_index_set = 0;
7168 /* Parse args required to build the message */
7169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7171 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7172 sw_if_index_set = 1;
7173 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7174 sw_if_index_set = 1;
7179 if (sw_if_index_set == 0)
7181 errmsg ("missing vpp interface name");
7185 /* Construct the API message */
7188 mp->sw_if_index = ntohl (sw_if_index);
7193 /* Wait for a reply... */
7199 api_ip_table_add_del (vat_main_t * vam)
7201 unformat_input_t *i = vam->input;
7202 vl_api_ip_table_add_del_t *mp;
7208 /* Parse args required to build the message */
7209 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7211 if (unformat (i, "ipv6"))
7213 else if (unformat (i, "del"))
7215 else if (unformat (i, "add"))
7217 else if (unformat (i, "table %d", &table_id))
7221 clib_warning ("parse error '%U'", format_unformat_error, i);
7228 errmsg ("missing table-ID");
7232 /* Construct the API message */
7233 M (IP_TABLE_ADD_DEL, mp);
7235 mp->table_id = ntohl (table_id);
7236 mp->is_ipv6 = is_ipv6;
7237 mp->is_add = is_add;
7242 /* Wait for a reply... */
7249 api_ip_add_del_route (vat_main_t * vam)
7251 unformat_input_t *i = vam->input;
7252 vl_api_ip_add_del_route_t *mp;
7253 u32 sw_if_index = ~0, vrf_id = 0;
7255 u8 is_local = 0, is_drop = 0;
7256 u8 is_unreach = 0, is_prohibit = 0;
7257 u8 create_vrf_if_needed = 0;
7259 u32 next_hop_weight = 1;
7261 u8 is_multipath = 0;
7263 u8 address_length_set = 0;
7264 u32 next_hop_table_id = 0;
7265 u32 resolve_attempts = 0;
7266 u32 dst_address_length = 0;
7267 u8 next_hop_set = 0;
7268 ip4_address_t v4_dst_address, v4_next_hop_address;
7269 ip6_address_t v6_dst_address, v6_next_hop_address;
7273 u32 random_add_del = 0;
7274 u32 *random_vector = 0;
7276 u32 random_seed = 0xdeaddabe;
7277 u32 classify_table_index = ~0;
7279 u8 resolve_host = 0, resolve_attached = 0;
7280 mpls_label_t *next_hop_out_label_stack = NULL;
7281 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7282 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7284 /* Parse args required to build the message */
7285 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7287 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7289 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7291 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7296 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7301 else if (unformat (i, "/%d", &dst_address_length))
7303 address_length_set = 1;
7306 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7307 &v4_next_hop_address))
7311 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7312 &v6_next_hop_address))
7316 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7318 else if (unformat (i, "weight %d", &next_hop_weight))
7320 else if (unformat (i, "drop"))
7324 else if (unformat (i, "null-send-unreach"))
7328 else if (unformat (i, "null-send-prohibit"))
7332 else if (unformat (i, "local"))
7336 else if (unformat (i, "classify %d", &classify_table_index))
7340 else if (unformat (i, "del"))
7342 else if (unformat (i, "add"))
7344 else if (unformat (i, "not-last"))
7346 else if (unformat (i, "resolve-via-host"))
7348 else if (unformat (i, "resolve-via-attached"))
7349 resolve_attached = 1;
7350 else if (unformat (i, "multipath"))
7352 else if (unformat (i, "vrf %d", &vrf_id))
7354 else if (unformat (i, "create-vrf"))
7355 create_vrf_if_needed = 1;
7356 else if (unformat (i, "count %d", &count))
7358 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7360 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7362 else if (unformat (i, "out-label %d", &next_hop_out_label))
7363 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7364 else if (unformat (i, "via-label %d", &next_hop_via_label))
7366 else if (unformat (i, "random"))
7368 else if (unformat (i, "seed %d", &random_seed))
7372 clib_warning ("parse error '%U'", format_unformat_error, i);
7377 if (!next_hop_set && !is_drop && !is_local &&
7378 !is_classify && !is_unreach && !is_prohibit &&
7379 MPLS_LABEL_INVALID == next_hop_via_label)
7382 ("next hop / local / drop / unreach / prohibit / classify not set");
7386 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7388 errmsg ("next hop and next-hop via label set");
7391 if (address_set == 0)
7393 errmsg ("missing addresses");
7397 if (address_length_set == 0)
7399 errmsg ("missing address length");
7403 /* Generate a pile of unique, random routes */
7406 u32 this_random_address;
7407 random_hash = hash_create (count, sizeof (uword));
7409 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7410 for (j = 0; j <= count; j++)
7414 this_random_address = random_u32 (&random_seed);
7415 this_random_address =
7416 clib_host_to_net_u32 (this_random_address);
7418 while (hash_get (random_hash, this_random_address));
7419 vec_add1 (random_vector, this_random_address);
7420 hash_set (random_hash, this_random_address, 1);
7422 hash_free (random_hash);
7423 v4_dst_address.as_u32 = random_vector[0];
7428 /* Turn on async mode */
7429 vam->async_mode = 1;
7430 vam->async_errors = 0;
7431 before = vat_time_now (vam);
7434 for (j = 0; j < count; j++)
7436 /* Construct the API message */
7437 M2 (IP_ADD_DEL_ROUTE, mp,
7438 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7440 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7441 mp->table_id = ntohl (vrf_id);
7442 mp->create_vrf_if_needed = create_vrf_if_needed;
7444 mp->is_add = is_add;
7445 mp->is_drop = is_drop;
7446 mp->is_unreach = is_unreach;
7447 mp->is_prohibit = is_prohibit;
7448 mp->is_ipv6 = is_ipv6;
7449 mp->is_local = is_local;
7450 mp->is_classify = is_classify;
7451 mp->is_multipath = is_multipath;
7452 mp->is_resolve_host = resolve_host;
7453 mp->is_resolve_attached = resolve_attached;
7454 mp->not_last = not_last;
7455 mp->next_hop_weight = next_hop_weight;
7456 mp->dst_address_length = dst_address_length;
7457 mp->next_hop_table_id = ntohl (next_hop_table_id);
7458 mp->classify_table_index = ntohl (classify_table_index);
7459 mp->next_hop_via_label = ntohl (next_hop_via_label);
7460 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7461 if (0 != mp->next_hop_n_out_labels)
7463 memcpy (mp->next_hop_out_label_stack,
7464 next_hop_out_label_stack,
7465 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7466 vec_free (next_hop_out_label_stack);
7471 clib_memcpy (mp->dst_address, &v6_dst_address,
7472 sizeof (v6_dst_address));
7474 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7475 sizeof (v6_next_hop_address));
7476 increment_v6_address (&v6_dst_address);
7480 clib_memcpy (mp->dst_address, &v4_dst_address,
7481 sizeof (v4_dst_address));
7483 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7484 sizeof (v4_next_hop_address));
7486 v4_dst_address.as_u32 = random_vector[j + 1];
7488 increment_v4_address (&v4_dst_address);
7492 /* If we receive SIGTERM, stop now... */
7497 /* When testing multiple add/del ops, use a control-ping to sync */
7500 vl_api_control_ping_t *mp_ping;
7504 /* Shut off async mode */
7505 vam->async_mode = 0;
7507 M (CONTROL_PING, mp_ping);
7510 timeout = vat_time_now (vam) + 1.0;
7511 while (vat_time_now (vam) < timeout)
7512 if (vam->result_ready == 1)
7517 if (vam->retval == -99)
7520 if (vam->async_errors > 0)
7522 errmsg ("%d asynchronous errors", vam->async_errors);
7525 vam->async_errors = 0;
7526 after = vat_time_now (vam);
7528 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7532 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7533 count, after - before, count / (after - before));
7539 /* Wait for a reply... */
7544 /* Return the good/bad news */
7545 return (vam->retval);
7549 api_ip_mroute_add_del (vat_main_t * vam)
7551 unformat_input_t *i = vam->input;
7552 vl_api_ip_mroute_add_del_t *mp;
7553 u32 sw_if_index = ~0, vrf_id = 0;
7556 u8 create_vrf_if_needed = 0;
7559 u32 grp_address_length = 0;
7560 ip4_address_t v4_grp_address, v4_src_address;
7561 ip6_address_t v6_grp_address, v6_src_address;
7562 mfib_itf_flags_t iflags = 0;
7563 mfib_entry_flags_t eflags = 0;
7566 /* Parse args required to build the message */
7567 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7569 if (unformat (i, "sw_if_index %d", &sw_if_index))
7571 else if (unformat (i, "%U %U",
7572 unformat_ip4_address, &v4_src_address,
7573 unformat_ip4_address, &v4_grp_address))
7575 grp_address_length = 64;
7579 else if (unformat (i, "%U %U",
7580 unformat_ip6_address, &v6_src_address,
7581 unformat_ip6_address, &v6_grp_address))
7583 grp_address_length = 256;
7587 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7589 memset (&v4_src_address, 0, sizeof (v4_src_address));
7590 grp_address_length = 32;
7594 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7596 memset (&v6_src_address, 0, sizeof (v6_src_address));
7597 grp_address_length = 128;
7601 else if (unformat (i, "/%d", &grp_address_length))
7603 else if (unformat (i, "local"))
7607 else if (unformat (i, "del"))
7609 else if (unformat (i, "add"))
7611 else if (unformat (i, "vrf %d", &vrf_id))
7613 else if (unformat (i, "create-vrf"))
7614 create_vrf_if_needed = 1;
7615 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7617 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7621 clib_warning ("parse error '%U'", format_unformat_error, i);
7626 if (address_set == 0)
7628 errmsg ("missing addresses\n");
7632 /* Construct the API message */
7633 M (IP_MROUTE_ADD_DEL, mp);
7635 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7636 mp->table_id = ntohl (vrf_id);
7637 mp->create_vrf_if_needed = create_vrf_if_needed;
7639 mp->is_add = is_add;
7640 mp->is_ipv6 = is_ipv6;
7641 mp->is_local = is_local;
7642 mp->itf_flags = ntohl (iflags);
7643 mp->entry_flags = ntohl (eflags);
7644 mp->grp_address_length = grp_address_length;
7645 mp->grp_address_length = ntohs (mp->grp_address_length);
7649 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7650 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7654 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7655 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7661 /* Wait for a reply... */
7667 api_mpls_table_add_del (vat_main_t * vam)
7669 unformat_input_t *i = vam->input;
7670 vl_api_mpls_table_add_del_t *mp;
7675 /* Parse args required to build the message */
7676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7678 if (unformat (i, "table %d", &table_id))
7680 else if (unformat (i, "del"))
7682 else if (unformat (i, "add"))
7686 clib_warning ("parse error '%U'", format_unformat_error, i);
7693 errmsg ("missing table-ID");
7697 /* Construct the API message */
7698 M (MPLS_TABLE_ADD_DEL, mp);
7700 mp->mt_table_id = ntohl (table_id);
7701 mp->mt_is_add = is_add;
7706 /* Wait for a reply... */
7713 api_mpls_route_add_del (vat_main_t * vam)
7715 unformat_input_t *i = vam->input;
7716 vl_api_mpls_route_add_del_t *mp;
7717 u32 sw_if_index = ~0, table_id = 0;
7718 u8 create_table_if_needed = 0;
7720 u32 next_hop_weight = 1;
7721 u8 is_multipath = 0;
7722 u32 next_hop_table_id = 0;
7723 u8 next_hop_set = 0;
7724 ip4_address_t v4_next_hop_address = {
7727 ip6_address_t v6_next_hop_address = { {0} };
7731 u32 classify_table_index = ~0;
7733 u8 resolve_host = 0, resolve_attached = 0;
7734 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7735 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7736 mpls_label_t *next_hop_out_label_stack = NULL;
7737 mpls_label_t local_label = MPLS_LABEL_INVALID;
7739 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
7741 /* Parse args required to build the message */
7742 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7748 else if (unformat (i, "%d", &local_label))
7750 else if (unformat (i, "eos"))
7752 else if (unformat (i, "non-eos"))
7754 else if (unformat (i, "via %U", unformat_ip4_address,
7755 &v4_next_hop_address))
7758 next_hop_proto = DPO_PROTO_IP4;
7760 else if (unformat (i, "via %U", unformat_ip6_address,
7761 &v6_next_hop_address))
7764 next_hop_proto = DPO_PROTO_IP6;
7766 else if (unformat (i, "weight %d", &next_hop_weight))
7768 else if (unformat (i, "create-table"))
7769 create_table_if_needed = 1;
7770 else if (unformat (i, "classify %d", &classify_table_index))
7774 else if (unformat (i, "del"))
7776 else if (unformat (i, "add"))
7778 else if (unformat (i, "resolve-via-host"))
7780 else if (unformat (i, "resolve-via-attached"))
7781 resolve_attached = 1;
7782 else if (unformat (i, "multipath"))
7784 else if (unformat (i, "count %d", &count))
7786 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7789 next_hop_proto = DPO_PROTO_IP4;
7791 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7794 next_hop_proto = DPO_PROTO_IP6;
7796 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7798 else if (unformat (i, "via-label %d", &next_hop_via_label))
7800 else if (unformat (i, "out-label %d", &next_hop_out_label))
7801 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7804 clib_warning ("parse error '%U'", format_unformat_error, i);
7809 if (!next_hop_set && !is_classify)
7811 errmsg ("next hop / classify not set");
7815 if (MPLS_LABEL_INVALID == local_label)
7817 errmsg ("missing label");
7823 /* Turn on async mode */
7824 vam->async_mode = 1;
7825 vam->async_errors = 0;
7826 before = vat_time_now (vam);
7829 for (j = 0; j < count; j++)
7831 /* Construct the API message */
7832 M2 (MPLS_ROUTE_ADD_DEL, mp,
7833 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7835 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7836 mp->mr_table_id = ntohl (table_id);
7837 mp->mr_create_table_if_needed = create_table_if_needed;
7839 mp->mr_is_add = is_add;
7840 mp->mr_next_hop_proto = next_hop_proto;
7841 mp->mr_is_classify = is_classify;
7842 mp->mr_is_multipath = is_multipath;
7843 mp->mr_is_resolve_host = resolve_host;
7844 mp->mr_is_resolve_attached = resolve_attached;
7845 mp->mr_next_hop_weight = next_hop_weight;
7846 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7847 mp->mr_classify_table_index = ntohl (classify_table_index);
7848 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7849 mp->mr_label = ntohl (local_label);
7850 mp->mr_eos = is_eos;
7852 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7853 if (0 != mp->mr_next_hop_n_out_labels)
7855 memcpy (mp->mr_next_hop_out_label_stack,
7856 next_hop_out_label_stack,
7857 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7858 vec_free (next_hop_out_label_stack);
7863 if (DPO_PROTO_IP4 == next_hop_proto)
7865 clib_memcpy (mp->mr_next_hop,
7866 &v4_next_hop_address,
7867 sizeof (v4_next_hop_address));
7869 else if (DPO_PROTO_IP6 == next_hop_proto)
7872 clib_memcpy (mp->mr_next_hop,
7873 &v6_next_hop_address,
7874 sizeof (v6_next_hop_address));
7881 /* If we receive SIGTERM, stop now... */
7886 /* When testing multiple add/del ops, use a control-ping to sync */
7889 vl_api_control_ping_t *mp_ping;
7893 /* Shut off async mode */
7894 vam->async_mode = 0;
7896 M (CONTROL_PING, mp_ping);
7899 timeout = vat_time_now (vam) + 1.0;
7900 while (vat_time_now (vam) < timeout)
7901 if (vam->result_ready == 1)
7906 if (vam->retval == -99)
7909 if (vam->async_errors > 0)
7911 errmsg ("%d asynchronous errors", vam->async_errors);
7914 vam->async_errors = 0;
7915 after = vat_time_now (vam);
7917 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7921 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7922 count, after - before, count / (after - before));
7928 /* Wait for a reply... */
7933 /* Return the good/bad news */
7934 return (vam->retval);
7938 api_mpls_ip_bind_unbind (vat_main_t * vam)
7940 unformat_input_t *i = vam->input;
7941 vl_api_mpls_ip_bind_unbind_t *mp;
7942 u32 ip_table_id = 0;
7943 u8 create_table_if_needed = 0;
7946 ip4_address_t v4_address;
7947 ip6_address_t v6_address;
7950 mpls_label_t local_label = MPLS_LABEL_INVALID;
7953 /* Parse args required to build the message */
7954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7956 if (unformat (i, "%U/%d", unformat_ip4_address,
7957 &v4_address, &address_length))
7962 else if (unformat (i, "%U/%d", unformat_ip6_address,
7963 &v6_address, &address_length))
7968 else if (unformat (i, "%d", &local_label))
7970 else if (unformat (i, "create-table"))
7971 create_table_if_needed = 1;
7972 else if (unformat (i, "table-id %d", &ip_table_id))
7974 else if (unformat (i, "unbind"))
7976 else if (unformat (i, "bind"))
7980 clib_warning ("parse error '%U'", format_unformat_error, i);
7987 errmsg ("IP addres not set");
7991 if (MPLS_LABEL_INVALID == local_label)
7993 errmsg ("missing label");
7997 /* Construct the API message */
7998 M (MPLS_IP_BIND_UNBIND, mp);
8000 mp->mb_create_table_if_needed = create_table_if_needed;
8001 mp->mb_is_bind = is_bind;
8002 mp->mb_is_ip4 = is_ip4;
8003 mp->mb_ip_table_id = ntohl (ip_table_id);
8004 mp->mb_mpls_table_id = 0;
8005 mp->mb_label = ntohl (local_label);
8006 mp->mb_address_length = address_length;
8009 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
8011 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
8016 /* Wait for a reply... */
8022 api_proxy_arp_add_del (vat_main_t * vam)
8024 unformat_input_t *i = vam->input;
8025 vl_api_proxy_arp_add_del_t *mp;
8028 ip4_address_t lo, hi;
8032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8034 if (unformat (i, "vrf %d", &vrf_id))
8036 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
8037 unformat_ip4_address, &hi))
8039 else if (unformat (i, "del"))
8043 clib_warning ("parse error '%U'", format_unformat_error, i);
8050 errmsg ("address range not set");
8054 M (PROXY_ARP_ADD_DEL, mp);
8056 mp->vrf_id = ntohl (vrf_id);
8057 mp->is_add = is_add;
8058 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
8059 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
8067 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
8069 unformat_input_t *i = vam->input;
8070 vl_api_proxy_arp_intfc_enable_disable_t *mp;
8073 u8 sw_if_index_set = 0;
8076 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8078 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8079 sw_if_index_set = 1;
8080 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8081 sw_if_index_set = 1;
8082 else if (unformat (i, "enable"))
8084 else if (unformat (i, "disable"))
8088 clib_warning ("parse error '%U'", format_unformat_error, i);
8093 if (sw_if_index_set == 0)
8095 errmsg ("missing interface name or sw_if_index");
8099 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
8101 mp->sw_if_index = ntohl (sw_if_index);
8102 mp->enable_disable = enable;
8110 api_mpls_tunnel_add_del (vat_main_t * vam)
8112 unformat_input_t *i = vam->input;
8113 vl_api_mpls_tunnel_add_del_t *mp;
8117 u32 sw_if_index = ~0;
8118 u32 next_hop_sw_if_index = ~0;
8119 u32 next_hop_proto_is_ip4 = 1;
8121 u32 next_hop_table_id = 0;
8122 ip4_address_t v4_next_hop_address = {
8125 ip6_address_t v6_next_hop_address = { {0} };
8126 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8131 if (unformat (i, "add"))
8133 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8135 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8137 else if (unformat (i, "via %U",
8138 unformat_ip4_address, &v4_next_hop_address))
8140 next_hop_proto_is_ip4 = 1;
8142 else if (unformat (i, "via %U",
8143 unformat_ip6_address, &v6_next_hop_address))
8145 next_hop_proto_is_ip4 = 0;
8147 else if (unformat (i, "l2-only"))
8149 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8151 else if (unformat (i, "out-label %d", &next_hop_out_label))
8152 vec_add1 (labels, ntohl (next_hop_out_label));
8155 clib_warning ("parse error '%U'", format_unformat_error, i);
8160 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8162 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8163 mp->mt_sw_if_index = ntohl (sw_if_index);
8164 mp->mt_is_add = is_add;
8165 mp->mt_l2_only = l2_only;
8166 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8167 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8169 mp->mt_next_hop_n_out_labels = vec_len (labels);
8171 if (0 != mp->mt_next_hop_n_out_labels)
8173 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8174 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8178 if (next_hop_proto_is_ip4)
8180 clib_memcpy (mp->mt_next_hop,
8181 &v4_next_hop_address, sizeof (v4_next_hop_address));
8185 clib_memcpy (mp->mt_next_hop,
8186 &v6_next_hop_address, sizeof (v6_next_hop_address));
8195 api_sw_interface_set_unnumbered (vat_main_t * vam)
8197 unformat_input_t *i = vam->input;
8198 vl_api_sw_interface_set_unnumbered_t *mp;
8200 u32 unnum_sw_index = ~0;
8202 u8 sw_if_index_set = 0;
8205 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8207 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8208 sw_if_index_set = 1;
8209 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8210 sw_if_index_set = 1;
8211 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8213 else if (unformat (i, "del"))
8217 clib_warning ("parse error '%U'", format_unformat_error, i);
8222 if (sw_if_index_set == 0)
8224 errmsg ("missing interface name or sw_if_index");
8228 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8230 mp->sw_if_index = ntohl (sw_if_index);
8231 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8232 mp->is_add = is_add;
8240 api_ip_neighbor_add_del (vat_main_t * vam)
8242 unformat_input_t *i = vam->input;
8243 vl_api_ip_neighbor_add_del_t *mp;
8245 u8 sw_if_index_set = 0;
8248 u8 is_no_fib_entry = 0;
8251 u8 v4_address_set = 0;
8252 u8 v6_address_set = 0;
8253 ip4_address_t v4address;
8254 ip6_address_t v6address;
8257 memset (mac_address, 0, sizeof (mac_address));
8259 /* Parse args required to build the message */
8260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8262 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8266 else if (unformat (i, "del"))
8269 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8270 sw_if_index_set = 1;
8271 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8272 sw_if_index_set = 1;
8273 else if (unformat (i, "is_static"))
8275 else if (unformat (i, "no-fib-entry"))
8276 is_no_fib_entry = 1;
8277 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8279 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8283 clib_warning ("parse error '%U'", format_unformat_error, i);
8288 if (sw_if_index_set == 0)
8290 errmsg ("missing interface name or sw_if_index");
8293 if (v4_address_set && v6_address_set)
8295 errmsg ("both v4 and v6 addresses set");
8298 if (!v4_address_set && !v6_address_set)
8300 errmsg ("no address set");
8304 /* Construct the API message */
8305 M (IP_NEIGHBOR_ADD_DEL, mp);
8307 mp->sw_if_index = ntohl (sw_if_index);
8308 mp->is_add = is_add;
8309 mp->is_static = is_static;
8310 mp->is_no_adj_fib = is_no_fib_entry;
8312 clib_memcpy (mp->mac_address, mac_address, 6);
8316 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8320 /* mp->is_ipv6 = 0; via memset in M macro above */
8321 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8327 /* Wait for a reply, return good/bad news */
8333 api_reset_vrf (vat_main_t * vam)
8335 unformat_input_t *i = vam->input;
8336 vl_api_reset_vrf_t *mp;
8342 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8344 if (unformat (i, "vrf %d", &vrf_id))
8346 else if (unformat (i, "ipv6"))
8350 clib_warning ("parse error '%U'", format_unformat_error, i);
8355 if (vrf_id_set == 0)
8357 errmsg ("missing vrf id");
8363 mp->vrf_id = ntohl (vrf_id);
8364 mp->is_ipv6 = is_ipv6;
8372 api_create_vlan_subif (vat_main_t * vam)
8374 unformat_input_t *i = vam->input;
8375 vl_api_create_vlan_subif_t *mp;
8377 u8 sw_if_index_set = 0;
8382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8384 if (unformat (i, "sw_if_index %d", &sw_if_index))
8385 sw_if_index_set = 1;
8387 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8388 sw_if_index_set = 1;
8389 else if (unformat (i, "vlan %d", &vlan_id))
8393 clib_warning ("parse error '%U'", format_unformat_error, i);
8398 if (sw_if_index_set == 0)
8400 errmsg ("missing interface name or sw_if_index");
8404 if (vlan_id_set == 0)
8406 errmsg ("missing vlan_id");
8409 M (CREATE_VLAN_SUBIF, mp);
8411 mp->sw_if_index = ntohl (sw_if_index);
8412 mp->vlan_id = ntohl (vlan_id);
8419 #define foreach_create_subif_bit \
8426 _(outer_vlan_id_any) \
8427 _(inner_vlan_id_any)
8430 api_create_subif (vat_main_t * vam)
8432 unformat_input_t *i = vam->input;
8433 vl_api_create_subif_t *mp;
8435 u8 sw_if_index_set = 0;
8442 u32 exact_match = 0;
8443 u32 default_sub = 0;
8444 u32 outer_vlan_id_any = 0;
8445 u32 inner_vlan_id_any = 0;
8447 u16 outer_vlan_id = 0;
8448 u16 inner_vlan_id = 0;
8451 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8453 if (unformat (i, "sw_if_index %d", &sw_if_index))
8454 sw_if_index_set = 1;
8456 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8457 sw_if_index_set = 1;
8458 else if (unformat (i, "sub_id %d", &sub_id))
8460 else if (unformat (i, "outer_vlan_id %d", &tmp))
8461 outer_vlan_id = tmp;
8462 else if (unformat (i, "inner_vlan_id %d", &tmp))
8463 inner_vlan_id = tmp;
8465 #define _(a) else if (unformat (i, #a)) a = 1 ;
8466 foreach_create_subif_bit
8470 clib_warning ("parse error '%U'", format_unformat_error, i);
8475 if (sw_if_index_set == 0)
8477 errmsg ("missing interface name or sw_if_index");
8481 if (sub_id_set == 0)
8483 errmsg ("missing sub_id");
8486 M (CREATE_SUBIF, mp);
8488 mp->sw_if_index = ntohl (sw_if_index);
8489 mp->sub_id = ntohl (sub_id);
8491 #define _(a) mp->a = a;
8492 foreach_create_subif_bit;
8495 mp->outer_vlan_id = ntohs (outer_vlan_id);
8496 mp->inner_vlan_id = ntohs (inner_vlan_id);
8504 api_oam_add_del (vat_main_t * vam)
8506 unformat_input_t *i = vam->input;
8507 vl_api_oam_add_del_t *mp;
8510 ip4_address_t src, dst;
8515 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8517 if (unformat (i, "vrf %d", &vrf_id))
8519 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8521 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8523 else if (unformat (i, "del"))
8527 clib_warning ("parse error '%U'", format_unformat_error, i);
8534 errmsg ("missing src addr");
8540 errmsg ("missing dst addr");
8544 M (OAM_ADD_DEL, mp);
8546 mp->vrf_id = ntohl (vrf_id);
8547 mp->is_add = is_add;
8548 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8549 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8557 api_reset_fib (vat_main_t * vam)
8559 unformat_input_t *i = vam->input;
8560 vl_api_reset_fib_t *mp;
8566 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8568 if (unformat (i, "vrf %d", &vrf_id))
8570 else if (unformat (i, "ipv6"))
8574 clib_warning ("parse error '%U'", format_unformat_error, i);
8579 if (vrf_id_set == 0)
8581 errmsg ("missing vrf id");
8587 mp->vrf_id = ntohl (vrf_id);
8588 mp->is_ipv6 = is_ipv6;
8596 api_dhcp_proxy_config (vat_main_t * vam)
8598 unformat_input_t *i = vam->input;
8599 vl_api_dhcp_proxy_config_t *mp;
8601 u32 server_vrf_id = 0;
8603 u8 v4_address_set = 0;
8604 u8 v6_address_set = 0;
8605 ip4_address_t v4address;
8606 ip6_address_t v6address;
8607 u8 v4_src_address_set = 0;
8608 u8 v6_src_address_set = 0;
8609 ip4_address_t v4srcaddress;
8610 ip6_address_t v6srcaddress;
8613 /* Parse args required to build the message */
8614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8616 if (unformat (i, "del"))
8618 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8620 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8622 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8624 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8626 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8627 v4_src_address_set = 1;
8628 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8629 v6_src_address_set = 1;
8634 if (v4_address_set && v6_address_set)
8636 errmsg ("both v4 and v6 server addresses set");
8639 if (!v4_address_set && !v6_address_set)
8641 errmsg ("no server addresses set");
8645 if (v4_src_address_set && v6_src_address_set)
8647 errmsg ("both v4 and v6 src addresses set");
8650 if (!v4_src_address_set && !v6_src_address_set)
8652 errmsg ("no src addresses set");
8656 if (!(v4_src_address_set && v4_address_set) &&
8657 !(v6_src_address_set && v6_address_set))
8659 errmsg ("no matching server and src addresses set");
8663 /* Construct the API message */
8664 M (DHCP_PROXY_CONFIG, mp);
8666 mp->is_add = is_add;
8667 mp->rx_vrf_id = ntohl (rx_vrf_id);
8668 mp->server_vrf_id = ntohl (server_vrf_id);
8672 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8673 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8677 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8678 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8684 /* Wait for a reply, return good/bad news */
8689 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8690 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8693 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8695 vat_main_t *vam = &vat_main;
8696 u32 i, count = mp->count;
8697 vl_api_dhcp_server_t *s;
8701 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8702 ntohl (mp->rx_vrf_id),
8703 format_ip6_address, mp->dhcp_src_address,
8704 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8707 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8708 ntohl (mp->rx_vrf_id),
8709 format_ip4_address, mp->dhcp_src_address,
8710 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8712 for (i = 0; i < count; i++)
8714 s = &mp->servers[i];
8718 " Server Table-ID %d, Server Address %U",
8719 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8722 " Server Table-ID %d, Server Address %U",
8723 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8727 static void vl_api_dhcp_proxy_details_t_handler_json
8728 (vl_api_dhcp_proxy_details_t * mp)
8730 vat_main_t *vam = &vat_main;
8731 vat_json_node_t *node = NULL;
8732 u32 i, count = mp->count;
8734 struct in6_addr ip6;
8735 vl_api_dhcp_server_t *s;
8737 if (VAT_JSON_ARRAY != vam->json_tree.type)
8739 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8740 vat_json_init_array (&vam->json_tree);
8742 node = vat_json_array_add (&vam->json_tree);
8744 vat_json_init_object (node);
8745 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8746 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8747 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8751 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8752 vat_json_object_add_ip6 (node, "src_address", ip6);
8756 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8757 vat_json_object_add_ip4 (node, "src_address", ip4);
8760 for (i = 0; i < count; i++)
8762 s = &mp->servers[i];
8764 vat_json_object_add_uint (node, "server-table-id",
8765 ntohl (s->server_vrf_id));
8769 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8770 vat_json_object_add_ip4 (node, "src_address", ip4);
8774 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8775 vat_json_object_add_ip6 (node, "server_address", ip6);
8781 api_dhcp_proxy_dump (vat_main_t * vam)
8783 unformat_input_t *i = vam->input;
8784 vl_api_control_ping_t *mp_ping;
8785 vl_api_dhcp_proxy_dump_t *mp;
8789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8791 if (unformat (i, "ipv6"))
8795 clib_warning ("parse error '%U'", format_unformat_error, i);
8800 M (DHCP_PROXY_DUMP, mp);
8802 mp->is_ip6 = is_ipv6;
8805 /* Use a control ping for synchronization */
8806 M (CONTROL_PING, mp_ping);
8814 api_dhcp_proxy_set_vss (vat_main_t * vam)
8816 unformat_input_t *i = vam->input;
8817 vl_api_dhcp_proxy_set_vss_t *mp;
8828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8830 if (unformat (i, "tbl_id %d", &tbl_id))
8832 if (unformat (i, "fib_id %d", &fib_id))
8834 if (unformat (i, "oui %d", &oui))
8836 else if (unformat (i, "ipv6"))
8838 else if (unformat (i, "del"))
8842 clib_warning ("parse error '%U'", format_unformat_error, i);
8847 if (tbl_id_set == 0)
8849 errmsg ("missing tbl id");
8853 if (fib_id_set == 0)
8855 errmsg ("missing fib id");
8860 errmsg ("missing oui");
8864 M (DHCP_PROXY_SET_VSS, mp);
8865 mp->tbl_id = ntohl (tbl_id);
8866 mp->fib_id = ntohl (fib_id);
8867 mp->oui = ntohl (oui);
8868 mp->is_ipv6 = is_ipv6;
8869 mp->is_add = is_add;
8877 api_dhcp_client_config (vat_main_t * vam)
8879 unformat_input_t *i = vam->input;
8880 vl_api_dhcp_client_config_t *mp;
8882 u8 sw_if_index_set = 0;
8885 u8 disable_event = 0;
8888 /* Parse args required to build the message */
8889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8891 if (unformat (i, "del"))
8894 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8895 sw_if_index_set = 1;
8896 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8897 sw_if_index_set = 1;
8898 else if (unformat (i, "hostname %s", &hostname))
8900 else if (unformat (i, "disable_event"))
8906 if (sw_if_index_set == 0)
8908 errmsg ("missing interface name or sw_if_index");
8912 if (vec_len (hostname) > 63)
8914 errmsg ("hostname too long");
8916 vec_add1 (hostname, 0);
8918 /* Construct the API message */
8919 M (DHCP_CLIENT_CONFIG, mp);
8921 mp->sw_if_index = htonl (sw_if_index);
8922 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8923 vec_free (hostname);
8924 mp->is_add = is_add;
8925 mp->want_dhcp_event = disable_event ? 0 : 1;
8926 mp->pid = htonl (getpid ());
8931 /* Wait for a reply, return good/bad news */
8937 api_set_ip_flow_hash (vat_main_t * vam)
8939 unformat_input_t *i = vam->input;
8940 vl_api_set_ip_flow_hash_t *mp;
8952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8954 if (unformat (i, "vrf %d", &vrf_id))
8956 else if (unformat (i, "ipv6"))
8958 else if (unformat (i, "src"))
8960 else if (unformat (i, "dst"))
8962 else if (unformat (i, "sport"))
8964 else if (unformat (i, "dport"))
8966 else if (unformat (i, "proto"))
8968 else if (unformat (i, "reverse"))
8973 clib_warning ("parse error '%U'", format_unformat_error, i);
8978 if (vrf_id_set == 0)
8980 errmsg ("missing vrf id");
8984 M (SET_IP_FLOW_HASH, mp);
8990 mp->reverse = reverse;
8991 mp->vrf_id = ntohl (vrf_id);
8992 mp->is_ipv6 = is_ipv6;
9000 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
9002 unformat_input_t *i = vam->input;
9003 vl_api_sw_interface_ip6_enable_disable_t *mp;
9005 u8 sw_if_index_set = 0;
9009 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9011 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9012 sw_if_index_set = 1;
9013 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9014 sw_if_index_set = 1;
9015 else if (unformat (i, "enable"))
9017 else if (unformat (i, "disable"))
9021 clib_warning ("parse error '%U'", format_unformat_error, i);
9026 if (sw_if_index_set == 0)
9028 errmsg ("missing interface name or sw_if_index");
9032 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
9034 mp->sw_if_index = ntohl (sw_if_index);
9035 mp->enable = enable;
9043 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
9045 unformat_input_t *i = vam->input;
9046 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
9048 u8 sw_if_index_set = 0;
9049 u8 v6_address_set = 0;
9050 ip6_address_t v6address;
9053 /* Parse args required to build the message */
9054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9056 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9057 sw_if_index_set = 1;
9058 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9059 sw_if_index_set = 1;
9060 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9066 if (sw_if_index_set == 0)
9068 errmsg ("missing interface name or sw_if_index");
9071 if (!v6_address_set)
9073 errmsg ("no address set");
9077 /* Construct the API message */
9078 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
9080 mp->sw_if_index = ntohl (sw_if_index);
9081 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9086 /* Wait for a reply, return good/bad news */
9092 api_ip6nd_proxy_add_del (vat_main_t * vam)
9094 unformat_input_t *i = vam->input;
9095 vl_api_ip6nd_proxy_add_del_t *mp;
9096 u32 sw_if_index = ~0;
9097 u8 v6_address_set = 0;
9098 ip6_address_t v6address;
9102 /* Parse args required to build the message */
9103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9105 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9107 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9109 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
9111 if (unformat (i, "del"))
9115 clib_warning ("parse error '%U'", format_unformat_error, i);
9120 if (sw_if_index == ~0)
9122 errmsg ("missing interface name or sw_if_index");
9125 if (!v6_address_set)
9127 errmsg ("no address set");
9131 /* Construct the API message */
9132 M (IP6ND_PROXY_ADD_DEL, mp);
9134 mp->is_del = is_del;
9135 mp->sw_if_index = ntohl (sw_if_index);
9136 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9141 /* Wait for a reply, return good/bad news */
9147 api_ip6nd_proxy_dump (vat_main_t * vam)
9149 vl_api_ip6nd_proxy_dump_t *mp;
9150 vl_api_control_ping_t *mp_ping;
9153 M (IP6ND_PROXY_DUMP, mp);
9157 /* Use a control ping for synchronization */
9158 M (CONTROL_PING, mp_ping);
9165 static void vl_api_ip6nd_proxy_details_t_handler
9166 (vl_api_ip6nd_proxy_details_t * mp)
9168 vat_main_t *vam = &vat_main;
9170 print (vam->ofp, "host %U sw_if_index %d",
9171 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9174 static void vl_api_ip6nd_proxy_details_t_handler_json
9175 (vl_api_ip6nd_proxy_details_t * mp)
9177 vat_main_t *vam = &vat_main;
9178 struct in6_addr ip6;
9179 vat_json_node_t *node = NULL;
9181 if (VAT_JSON_ARRAY != vam->json_tree.type)
9183 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9184 vat_json_init_array (&vam->json_tree);
9186 node = vat_json_array_add (&vam->json_tree);
9188 vat_json_init_object (node);
9189 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9191 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9192 vat_json_object_add_ip6 (node, "host", ip6);
9196 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9198 unformat_input_t *i = vam->input;
9199 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9201 u8 sw_if_index_set = 0;
9202 u32 address_length = 0;
9203 u8 v6_address_set = 0;
9204 ip6_address_t v6address;
9206 u8 no_advertise = 0;
9208 u8 no_autoconfig = 0;
9211 u32 val_lifetime = 0;
9212 u32 pref_lifetime = 0;
9215 /* Parse args required to build the message */
9216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9219 sw_if_index_set = 1;
9220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9221 sw_if_index_set = 1;
9222 else if (unformat (i, "%U/%d",
9223 unformat_ip6_address, &v6address, &address_length))
9225 else if (unformat (i, "val_life %d", &val_lifetime))
9227 else if (unformat (i, "pref_life %d", &pref_lifetime))
9229 else if (unformat (i, "def"))
9231 else if (unformat (i, "noadv"))
9233 else if (unformat (i, "offl"))
9235 else if (unformat (i, "noauto"))
9237 else if (unformat (i, "nolink"))
9239 else if (unformat (i, "isno"))
9243 clib_warning ("parse error '%U'", format_unformat_error, i);
9248 if (sw_if_index_set == 0)
9250 errmsg ("missing interface name or sw_if_index");
9253 if (!v6_address_set)
9255 errmsg ("no address set");
9259 /* Construct the API message */
9260 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9262 mp->sw_if_index = ntohl (sw_if_index);
9263 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9264 mp->address_length = address_length;
9265 mp->use_default = use_default;
9266 mp->no_advertise = no_advertise;
9267 mp->off_link = off_link;
9268 mp->no_autoconfig = no_autoconfig;
9269 mp->no_onlink = no_onlink;
9271 mp->val_lifetime = ntohl (val_lifetime);
9272 mp->pref_lifetime = ntohl (pref_lifetime);
9277 /* Wait for a reply, return good/bad news */
9283 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9285 unformat_input_t *i = vam->input;
9286 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9288 u8 sw_if_index_set = 0;
9293 u8 send_unicast = 0;
9296 u8 default_router = 0;
9297 u32 max_interval = 0;
9298 u32 min_interval = 0;
9300 u32 initial_count = 0;
9301 u32 initial_interval = 0;
9305 /* Parse args required to build the message */
9306 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9308 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9309 sw_if_index_set = 1;
9310 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9311 sw_if_index_set = 1;
9312 else if (unformat (i, "maxint %d", &max_interval))
9314 else if (unformat (i, "minint %d", &min_interval))
9316 else if (unformat (i, "life %d", &lifetime))
9318 else if (unformat (i, "count %d", &initial_count))
9320 else if (unformat (i, "interval %d", &initial_interval))
9322 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9324 else if (unformat (i, "managed"))
9326 else if (unformat (i, "other"))
9328 else if (unformat (i, "ll"))
9330 else if (unformat (i, "send"))
9332 else if (unformat (i, "cease"))
9334 else if (unformat (i, "isno"))
9336 else if (unformat (i, "def"))
9340 clib_warning ("parse error '%U'", format_unformat_error, i);
9345 if (sw_if_index_set == 0)
9347 errmsg ("missing interface name or sw_if_index");
9351 /* Construct the API message */
9352 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9354 mp->sw_if_index = ntohl (sw_if_index);
9355 mp->max_interval = ntohl (max_interval);
9356 mp->min_interval = ntohl (min_interval);
9357 mp->lifetime = ntohl (lifetime);
9358 mp->initial_count = ntohl (initial_count);
9359 mp->initial_interval = ntohl (initial_interval);
9360 mp->suppress = suppress;
9361 mp->managed = managed;
9363 mp->ll_option = ll_option;
9364 mp->send_unicast = send_unicast;
9367 mp->default_router = default_router;
9372 /* Wait for a reply, return good/bad news */
9378 api_set_arp_neighbor_limit (vat_main_t * vam)
9380 unformat_input_t *i = vam->input;
9381 vl_api_set_arp_neighbor_limit_t *mp;
9387 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9389 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9391 else if (unformat (i, "ipv6"))
9395 clib_warning ("parse error '%U'", format_unformat_error, i);
9402 errmsg ("missing limit value");
9406 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9408 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9409 mp->is_ipv6 = is_ipv6;
9417 api_l2_patch_add_del (vat_main_t * vam)
9419 unformat_input_t *i = vam->input;
9420 vl_api_l2_patch_add_del_t *mp;
9422 u8 rx_sw_if_index_set = 0;
9424 u8 tx_sw_if_index_set = 0;
9428 /* Parse args required to build the message */
9429 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9431 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9432 rx_sw_if_index_set = 1;
9433 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9434 tx_sw_if_index_set = 1;
9435 else if (unformat (i, "rx"))
9437 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9439 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9441 rx_sw_if_index_set = 1;
9446 else if (unformat (i, "tx"))
9448 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9450 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9452 tx_sw_if_index_set = 1;
9457 else if (unformat (i, "del"))
9463 if (rx_sw_if_index_set == 0)
9465 errmsg ("missing rx interface name or rx_sw_if_index");
9469 if (tx_sw_if_index_set == 0)
9471 errmsg ("missing tx interface name or tx_sw_if_index");
9475 M (L2_PATCH_ADD_DEL, mp);
9477 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9478 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9479 mp->is_add = is_add;
9487 u8 localsid_addr[16];
9496 api_sr_localsid_add_del (vat_main_t * vam)
9498 unformat_input_t *i = vam->input;
9499 vl_api_sr_localsid_add_del_t *mp;
9502 ip6_address_t localsid;
9506 u32 fib_table = ~(u32) 0;
9507 ip6_address_t next_hop;
9509 bool nexthop_set = 0;
9513 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9515 if (unformat (i, "del"))
9517 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9518 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9520 else if (unformat (i, "behavior %u", &behavior));
9521 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9522 else if (unformat (i, "fib-table %u", &fib_table));
9523 else if (unformat (i, "end.psp %u", &behavior));
9528 M (SR_LOCALSID_ADD_DEL, mp);
9530 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9532 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9533 mp->behavior = behavior;
9534 mp->sw_if_index = ntohl (sw_if_index);
9535 mp->fib_table = ntohl (fib_table);
9536 mp->end_psp = end_psp;
9537 mp->is_del = is_del;
9545 api_ioam_enable (vat_main_t * vam)
9547 unformat_input_t *input = vam->input;
9548 vl_api_ioam_enable_t *mp;
9550 int has_trace_option = 0;
9551 int has_pot_option = 0;
9552 int has_seqno_option = 0;
9553 int has_analyse_option = 0;
9556 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9558 if (unformat (input, "trace"))
9559 has_trace_option = 1;
9560 else if (unformat (input, "pot"))
9562 else if (unformat (input, "seqno"))
9563 has_seqno_option = 1;
9564 else if (unformat (input, "analyse"))
9565 has_analyse_option = 1;
9569 M (IOAM_ENABLE, mp);
9570 mp->id = htons (id);
9571 mp->seqno = has_seqno_option;
9572 mp->analyse = has_analyse_option;
9573 mp->pot_enable = has_pot_option;
9574 mp->trace_enable = has_trace_option;
9583 api_ioam_disable (vat_main_t * vam)
9585 vl_api_ioam_disable_t *mp;
9588 M (IOAM_DISABLE, mp);
9594 #define foreach_tcp_proto_field \
9598 #define foreach_udp_proto_field \
9602 #define foreach_ip4_proto_field \
9614 u16 src_port, dst_port;
9617 #if VPP_API_TEST_BUILTIN == 0
9619 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9621 u8 **maskp = va_arg (*args, u8 **);
9623 u8 found_something = 0;
9626 #define _(a) u8 a=0;
9627 foreach_tcp_proto_field;
9630 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9633 #define _(a) else if (unformat (input, #a)) a=1;
9634 foreach_tcp_proto_field
9640 #define _(a) found_something += a;
9641 foreach_tcp_proto_field;
9644 if (found_something == 0)
9647 vec_validate (mask, sizeof (*tcp) - 1);
9649 tcp = (tcp_header_t *) mask;
9651 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9652 foreach_tcp_proto_field;
9660 unformat_udp_mask (unformat_input_t * input, va_list * args)
9662 u8 **maskp = va_arg (*args, u8 **);
9664 u8 found_something = 0;
9667 #define _(a) u8 a=0;
9668 foreach_udp_proto_field;
9671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9674 #define _(a) else if (unformat (input, #a)) a=1;
9675 foreach_udp_proto_field
9681 #define _(a) found_something += a;
9682 foreach_udp_proto_field;
9685 if (found_something == 0)
9688 vec_validate (mask, sizeof (*udp) - 1);
9690 udp = (udp_header_t *) mask;
9692 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9693 foreach_udp_proto_field;
9701 unformat_l4_mask (unformat_input_t * input, va_list * args)
9703 u8 **maskp = va_arg (*args, u8 **);
9704 u16 src_port = 0, dst_port = 0;
9705 tcpudp_header_t *tcpudp;
9707 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9709 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9711 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9713 else if (unformat (input, "src_port"))
9715 else if (unformat (input, "dst_port"))
9721 if (!src_port && !dst_port)
9725 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9727 tcpudp = (tcpudp_header_t *) mask;
9728 tcpudp->src_port = src_port;
9729 tcpudp->dst_port = dst_port;
9737 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9739 u8 **maskp = va_arg (*args, u8 **);
9741 u8 found_something = 0;
9744 #define _(a) u8 a=0;
9745 foreach_ip4_proto_field;
9751 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9753 if (unformat (input, "version"))
9755 else if (unformat (input, "hdr_length"))
9757 else if (unformat (input, "src"))
9759 else if (unformat (input, "dst"))
9761 else if (unformat (input, "proto"))
9764 #define _(a) else if (unformat (input, #a)) a=1;
9765 foreach_ip4_proto_field
9771 #define _(a) found_something += a;
9772 foreach_ip4_proto_field;
9775 if (found_something == 0)
9778 vec_validate (mask, sizeof (*ip) - 1);
9780 ip = (ip4_header_t *) mask;
9782 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9783 foreach_ip4_proto_field;
9786 ip->ip_version_and_header_length = 0;
9789 ip->ip_version_and_header_length |= 0xF0;
9792 ip->ip_version_and_header_length |= 0x0F;
9798 #define foreach_ip6_proto_field \
9806 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9808 u8 **maskp = va_arg (*args, u8 **);
9810 u8 found_something = 0;
9812 u32 ip_version_traffic_class_and_flow_label;
9814 #define _(a) u8 a=0;
9815 foreach_ip6_proto_field;
9818 u8 traffic_class = 0;
9821 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9823 if (unformat (input, "version"))
9825 else if (unformat (input, "traffic-class"))
9827 else if (unformat (input, "flow-label"))
9829 else if (unformat (input, "src"))
9831 else if (unformat (input, "dst"))
9833 else if (unformat (input, "proto"))
9836 #define _(a) else if (unformat (input, #a)) a=1;
9837 foreach_ip6_proto_field
9843 #define _(a) found_something += a;
9844 foreach_ip6_proto_field;
9847 if (found_something == 0)
9850 vec_validate (mask, sizeof (*ip) - 1);
9852 ip = (ip6_header_t *) mask;
9854 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9855 foreach_ip6_proto_field;
9858 ip_version_traffic_class_and_flow_label = 0;
9861 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9864 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9867 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9869 ip->ip_version_traffic_class_and_flow_label =
9870 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9877 unformat_l3_mask (unformat_input_t * input, va_list * args)
9879 u8 **maskp = va_arg (*args, u8 **);
9881 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9883 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9885 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9894 unformat_l2_mask (unformat_input_t * input, va_list * args)
9896 u8 **maskp = va_arg (*args, u8 **);
9911 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9913 if (unformat (input, "src"))
9915 else if (unformat (input, "dst"))
9917 else if (unformat (input, "proto"))
9919 else if (unformat (input, "tag1"))
9921 else if (unformat (input, "tag2"))
9923 else if (unformat (input, "ignore-tag1"))
9925 else if (unformat (input, "ignore-tag2"))
9927 else if (unformat (input, "cos1"))
9929 else if (unformat (input, "cos2"))
9931 else if (unformat (input, "dot1q"))
9933 else if (unformat (input, "dot1ad"))
9938 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9939 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9942 if (tag1 || ignore_tag1 || cos1 || dot1q)
9944 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9947 vec_validate (mask, len - 1);
9950 memset (mask, 0xff, 6);
9953 memset (mask + 6, 0xff, 6);
9957 /* inner vlan tag */
9966 mask[21] = mask[20] = 0xff;
9987 mask[16] = mask[17] = 0xff;
9997 mask[12] = mask[13] = 0xff;
10004 unformat_classify_mask (unformat_input_t * input, va_list * args)
10006 u8 **maskp = va_arg (*args, u8 **);
10007 u32 *skipp = va_arg (*args, u32 *);
10008 u32 *matchp = va_arg (*args, u32 *);
10016 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10018 if (unformat (input, "hex %U", unformat_hex_string, &mask))
10020 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
10022 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
10024 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
10038 if (mask || l2 || l3 || l4)
10040 if (l2 || l3 || l4)
10042 /* "With a free Ethernet header in every package" */
10044 vec_validate (l2, 13);
10048 vec_append (mask, l3);
10053 vec_append (mask, l4);
10058 /* Scan forward looking for the first significant mask octet */
10059 for (i = 0; i < vec_len (mask); i++)
10063 /* compute (skip, match) params */
10064 *skipp = i / sizeof (u32x4);
10065 vec_delete (mask, *skipp * sizeof (u32x4), 0);
10067 /* Pad mask to an even multiple of the vector size */
10068 while (vec_len (mask) % sizeof (u32x4))
10069 vec_add1 (mask, 0);
10071 match = vec_len (mask) / sizeof (u32x4);
10073 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
10075 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
10076 if (*tmp || *(tmp + 1))
10081 clib_warning ("BUG: match 0");
10083 _vec_len (mask) = match * sizeof (u32x4);
10093 #endif /* VPP_API_TEST_BUILTIN */
10095 #define foreach_l2_next \
10097 _(ethernet, ETHERNET_INPUT) \
10098 _(ip4, IP4_INPUT) \
10102 unformat_l2_next_index (unformat_input_t * input, va_list * args)
10104 u32 *miss_next_indexp = va_arg (*args, u32 *);
10105 u32 next_index = 0;
10109 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
10113 if (unformat (input, "%d", &tmp))
10122 *miss_next_indexp = next_index;
10126 #define foreach_ip_next \
10129 _(rewrite, REWRITE)
10132 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10134 u32 *miss_next_indexp = va_arg (*args, u32 *);
10135 u32 next_index = 0;
10139 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10143 if (unformat (input, "%d", &tmp))
10152 *miss_next_indexp = next_index;
10156 #define foreach_acl_next \
10160 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10162 u32 *miss_next_indexp = va_arg (*args, u32 *);
10163 u32 next_index = 0;
10167 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10171 if (unformat (input, "permit"))
10176 else if (unformat (input, "%d", &tmp))
10185 *miss_next_indexp = next_index;
10190 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10192 u32 *r = va_arg (*args, u32 *);
10194 if (unformat (input, "conform-color"))
10195 *r = POLICE_CONFORM;
10196 else if (unformat (input, "exceed-color"))
10197 *r = POLICE_EXCEED;
10205 api_classify_add_del_table (vat_main_t * vam)
10207 unformat_input_t *i = vam->input;
10208 vl_api_classify_add_del_table_t *mp;
10215 u32 table_index = ~0;
10216 u32 next_table_index = ~0;
10217 u32 miss_next_index = ~0;
10218 u32 memory_size = 32 << 20;
10220 u32 current_data_flag = 0;
10221 int current_data_offset = 0;
10224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10226 if (unformat (i, "del"))
10228 else if (unformat (i, "del-chain"))
10233 else if (unformat (i, "buckets %d", &nbuckets))
10235 else if (unformat (i, "memory_size %d", &memory_size))
10237 else if (unformat (i, "skip %d", &skip))
10239 else if (unformat (i, "match %d", &match))
10241 else if (unformat (i, "table %d", &table_index))
10243 else if (unformat (i, "mask %U", unformat_classify_mask,
10244 &mask, &skip, &match))
10246 else if (unformat (i, "next-table %d", &next_table_index))
10248 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10251 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10254 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10257 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10259 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10265 if (is_add && mask == 0)
10267 errmsg ("Mask required");
10271 if (is_add && skip == ~0)
10273 errmsg ("skip count required");
10277 if (is_add && match == ~0)
10279 errmsg ("match count required");
10283 if (!is_add && table_index == ~0)
10285 errmsg ("table index required for delete");
10289 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10291 mp->is_add = is_add;
10292 mp->del_chain = del_chain;
10293 mp->table_index = ntohl (table_index);
10294 mp->nbuckets = ntohl (nbuckets);
10295 mp->memory_size = ntohl (memory_size);
10296 mp->skip_n_vectors = ntohl (skip);
10297 mp->match_n_vectors = ntohl (match);
10298 mp->next_table_index = ntohl (next_table_index);
10299 mp->miss_next_index = ntohl (miss_next_index);
10300 mp->current_data_flag = ntohl (current_data_flag);
10301 mp->current_data_offset = ntohl (current_data_offset);
10302 clib_memcpy (mp->mask, mask, vec_len (mask));
10311 #if VPP_API_TEST_BUILTIN == 0
10313 unformat_l4_match (unformat_input_t * input, va_list * args)
10315 u8 **matchp = va_arg (*args, u8 **);
10317 u8 *proto_header = 0;
10323 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10325 if (unformat (input, "src_port %d", &src_port))
10327 else if (unformat (input, "dst_port %d", &dst_port))
10333 h.src_port = clib_host_to_net_u16 (src_port);
10334 h.dst_port = clib_host_to_net_u16 (dst_port);
10335 vec_validate (proto_header, sizeof (h) - 1);
10336 memcpy (proto_header, &h, sizeof (h));
10338 *matchp = proto_header;
10344 unformat_ip4_match (unformat_input_t * input, va_list * args)
10346 u8 **matchp = va_arg (*args, u8 **);
10351 int hdr_length = 0;
10352 u32 hdr_length_val;
10353 int src = 0, dst = 0;
10354 ip4_address_t src_val, dst_val;
10361 int fragment_id = 0;
10362 u32 fragment_id_val;
10368 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10370 if (unformat (input, "version %d", &version_val))
10372 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10374 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10376 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10378 else if (unformat (input, "proto %d", &proto_val))
10380 else if (unformat (input, "tos %d", &tos_val))
10382 else if (unformat (input, "length %d", &length_val))
10384 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10386 else if (unformat (input, "ttl %d", &ttl_val))
10388 else if (unformat (input, "checksum %d", &checksum_val))
10394 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10395 + ttl + checksum == 0)
10399 * Aligned because we use the real comparison functions
10401 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10403 ip = (ip4_header_t *) match;
10405 /* These are realistically matched in practice */
10407 ip->src_address.as_u32 = src_val.as_u32;
10410 ip->dst_address.as_u32 = dst_val.as_u32;
10413 ip->protocol = proto_val;
10416 /* These are not, but they're included for completeness */
10418 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10421 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10427 ip->length = clib_host_to_net_u16 (length_val);
10433 ip->checksum = clib_host_to_net_u16 (checksum_val);
10440 unformat_ip6_match (unformat_input_t * input, va_list * args)
10442 u8 **matchp = va_arg (*args, u8 **);
10447 u8 traffic_class = 0;
10448 u32 traffic_class_val = 0;
10451 int src = 0, dst = 0;
10452 ip6_address_t src_val, dst_val;
10455 int payload_length = 0;
10456 u32 payload_length_val;
10459 u32 ip_version_traffic_class_and_flow_label;
10461 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10463 if (unformat (input, "version %d", &version_val))
10465 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10467 else if (unformat (input, "flow_label %d", &flow_label_val))
10469 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10471 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10473 else if (unformat (input, "proto %d", &proto_val))
10475 else if (unformat (input, "payload_length %d", &payload_length_val))
10476 payload_length = 1;
10477 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10483 if (version + traffic_class + flow_label + src + dst + proto +
10484 payload_length + hop_limit == 0)
10488 * Aligned because we use the real comparison functions
10490 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10492 ip = (ip6_header_t *) match;
10495 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10498 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10501 ip->protocol = proto_val;
10503 ip_version_traffic_class_and_flow_label = 0;
10506 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10509 ip_version_traffic_class_and_flow_label |=
10510 (traffic_class_val & 0xFF) << 20;
10513 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10515 ip->ip_version_traffic_class_and_flow_label =
10516 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10518 if (payload_length)
10519 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10522 ip->hop_limit = hop_limit_val;
10529 unformat_l3_match (unformat_input_t * input, va_list * args)
10531 u8 **matchp = va_arg (*args, u8 **);
10533 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10535 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10537 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10546 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10548 u8 *tagp = va_arg (*args, u8 *);
10551 if (unformat (input, "%d", &tag))
10553 tagp[0] = (tag >> 8) & 0x0F;
10554 tagp[1] = tag & 0xFF;
10562 unformat_l2_match (unformat_input_t * input, va_list * args)
10564 u8 **matchp = va_arg (*args, u8 **);
10577 u8 ignore_tag1 = 0;
10578 u8 ignore_tag2 = 0;
10584 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10586 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10589 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10591 else if (unformat (input, "proto %U",
10592 unformat_ethernet_type_host_byte_order, &proto_val))
10594 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10596 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10598 else if (unformat (input, "ignore-tag1"))
10600 else if (unformat (input, "ignore-tag2"))
10602 else if (unformat (input, "cos1 %d", &cos1_val))
10604 else if (unformat (input, "cos2 %d", &cos2_val))
10609 if ((src + dst + proto + tag1 + tag2 +
10610 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10613 if (tag1 || ignore_tag1 || cos1)
10615 if (tag2 || ignore_tag2 || cos2)
10618 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10621 clib_memcpy (match, dst_val, 6);
10624 clib_memcpy (match + 6, src_val, 6);
10628 /* inner vlan tag */
10629 match[19] = tag2_val[1];
10630 match[18] = tag2_val[0];
10632 match[18] |= (cos2_val & 0x7) << 5;
10635 match[21] = proto_val & 0xff;
10636 match[20] = proto_val >> 8;
10640 match[15] = tag1_val[1];
10641 match[14] = tag1_val[0];
10644 match[14] |= (cos1_val & 0x7) << 5;
10650 match[15] = tag1_val[1];
10651 match[14] = tag1_val[0];
10654 match[17] = proto_val & 0xff;
10655 match[16] = proto_val >> 8;
10658 match[14] |= (cos1_val & 0x7) << 5;
10664 match[18] |= (cos2_val & 0x7) << 5;
10666 match[14] |= (cos1_val & 0x7) << 5;
10669 match[13] = proto_val & 0xff;
10670 match[12] = proto_val >> 8;
10679 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10681 u8 **matchp = va_arg (*args, u8 **);
10682 u32 skip_n_vectors = va_arg (*args, u32);
10683 u32 match_n_vectors = va_arg (*args, u32);
10690 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10692 if (unformat (input, "hex %U", unformat_hex_string, &match))
10694 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10696 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10698 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10712 if (match || l2 || l3 || l4)
10714 if (l2 || l3 || l4)
10716 /* "Win a free Ethernet header in every packet" */
10718 vec_validate_aligned (l2, 13, sizeof (u32x4));
10722 vec_append_aligned (match, l3, sizeof (u32x4));
10727 vec_append_aligned (match, l4, sizeof (u32x4));
10732 /* Make sure the vector is big enough even if key is all 0's */
10733 vec_validate_aligned
10734 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10737 /* Set size, include skipped vectors */
10738 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10749 api_classify_add_del_session (vat_main_t * vam)
10751 unformat_input_t *i = vam->input;
10752 vl_api_classify_add_del_session_t *mp;
10754 u32 table_index = ~0;
10755 u32 hit_next_index = ~0;
10756 u32 opaque_index = ~0;
10759 u32 skip_n_vectors = 0;
10760 u32 match_n_vectors = 0;
10766 * Warning: you have to supply skip_n and match_n
10767 * because the API client cant simply look at the classify
10771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10773 if (unformat (i, "del"))
10775 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10778 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10781 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10784 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10786 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10788 else if (unformat (i, "opaque-index %d", &opaque_index))
10790 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10792 else if (unformat (i, "match_n %d", &match_n_vectors))
10794 else if (unformat (i, "match %U", api_unformat_classify_match,
10795 &match, skip_n_vectors, match_n_vectors))
10797 else if (unformat (i, "advance %d", &advance))
10799 else if (unformat (i, "table-index %d", &table_index))
10801 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10803 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10805 else if (unformat (i, "action %d", &action))
10807 else if (unformat (i, "metadata %d", &metadata))
10813 if (table_index == ~0)
10815 errmsg ("Table index required");
10819 if (is_add && match == 0)
10821 errmsg ("Match value required");
10825 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10827 mp->is_add = is_add;
10828 mp->table_index = ntohl (table_index);
10829 mp->hit_next_index = ntohl (hit_next_index);
10830 mp->opaque_index = ntohl (opaque_index);
10831 mp->advance = ntohl (advance);
10832 mp->action = action;
10833 mp->metadata = ntohl (metadata);
10834 clib_memcpy (mp->match, match, vec_len (match));
10843 api_classify_set_interface_ip_table (vat_main_t * vam)
10845 unformat_input_t *i = vam->input;
10846 vl_api_classify_set_interface_ip_table_t *mp;
10848 int sw_if_index_set;
10849 u32 table_index = ~0;
10853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10855 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10856 sw_if_index_set = 1;
10857 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10858 sw_if_index_set = 1;
10859 else if (unformat (i, "table %d", &table_index))
10863 clib_warning ("parse error '%U'", format_unformat_error, i);
10868 if (sw_if_index_set == 0)
10870 errmsg ("missing interface name or sw_if_index");
10875 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10877 mp->sw_if_index = ntohl (sw_if_index);
10878 mp->table_index = ntohl (table_index);
10879 mp->is_ipv6 = is_ipv6;
10887 api_classify_set_interface_l2_tables (vat_main_t * vam)
10889 unformat_input_t *i = vam->input;
10890 vl_api_classify_set_interface_l2_tables_t *mp;
10892 int sw_if_index_set;
10893 u32 ip4_table_index = ~0;
10894 u32 ip6_table_index = ~0;
10895 u32 other_table_index = ~0;
10899 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10901 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10902 sw_if_index_set = 1;
10903 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10904 sw_if_index_set = 1;
10905 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10907 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10909 else if (unformat (i, "other-table %d", &other_table_index))
10911 else if (unformat (i, "is-input %d", &is_input))
10915 clib_warning ("parse error '%U'", format_unformat_error, i);
10920 if (sw_if_index_set == 0)
10922 errmsg ("missing interface name or sw_if_index");
10927 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10929 mp->sw_if_index = ntohl (sw_if_index);
10930 mp->ip4_table_index = ntohl (ip4_table_index);
10931 mp->ip6_table_index = ntohl (ip6_table_index);
10932 mp->other_table_index = ntohl (other_table_index);
10933 mp->is_input = (u8) is_input;
10941 api_set_ipfix_exporter (vat_main_t * vam)
10943 unformat_input_t *i = vam->input;
10944 vl_api_set_ipfix_exporter_t *mp;
10945 ip4_address_t collector_address;
10946 u8 collector_address_set = 0;
10947 u32 collector_port = ~0;
10948 ip4_address_t src_address;
10949 u8 src_address_set = 0;
10952 u32 template_interval = ~0;
10953 u8 udp_checksum = 0;
10956 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10958 if (unformat (i, "collector_address %U", unformat_ip4_address,
10959 &collector_address))
10960 collector_address_set = 1;
10961 else if (unformat (i, "collector_port %d", &collector_port))
10963 else if (unformat (i, "src_address %U", unformat_ip4_address,
10965 src_address_set = 1;
10966 else if (unformat (i, "vrf_id %d", &vrf_id))
10968 else if (unformat (i, "path_mtu %d", &path_mtu))
10970 else if (unformat (i, "template_interval %d", &template_interval))
10972 else if (unformat (i, "udp_checksum"))
10978 if (collector_address_set == 0)
10980 errmsg ("collector_address required");
10984 if (src_address_set == 0)
10986 errmsg ("src_address required");
10990 M (SET_IPFIX_EXPORTER, mp);
10992 memcpy (mp->collector_address, collector_address.data,
10993 sizeof (collector_address.data));
10994 mp->collector_port = htons ((u16) collector_port);
10995 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10996 mp->vrf_id = htonl (vrf_id);
10997 mp->path_mtu = htonl (path_mtu);
10998 mp->template_interval = htonl (template_interval);
10999 mp->udp_checksum = udp_checksum;
11007 api_set_ipfix_classify_stream (vat_main_t * vam)
11009 unformat_input_t *i = vam->input;
11010 vl_api_set_ipfix_classify_stream_t *mp;
11012 u32 src_port = UDP_DST_PORT_ipfix;
11015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11017 if (unformat (i, "domain %d", &domain_id))
11019 else if (unformat (i, "src_port %d", &src_port))
11023 errmsg ("unknown input `%U'", format_unformat_error, i);
11028 M (SET_IPFIX_CLASSIFY_STREAM, mp);
11030 mp->domain_id = htonl (domain_id);
11031 mp->src_port = htons ((u16) src_port);
11039 api_ipfix_classify_table_add_del (vat_main_t * vam)
11041 unformat_input_t *i = vam->input;
11042 vl_api_ipfix_classify_table_add_del_t *mp;
11044 u32 classify_table_index = ~0;
11046 u8 transport_protocol = 255;
11049 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11051 if (unformat (i, "add"))
11053 else if (unformat (i, "del"))
11055 else if (unformat (i, "table %d", &classify_table_index))
11057 else if (unformat (i, "ip4"))
11059 else if (unformat (i, "ip6"))
11061 else if (unformat (i, "tcp"))
11062 transport_protocol = 6;
11063 else if (unformat (i, "udp"))
11064 transport_protocol = 17;
11067 errmsg ("unknown input `%U'", format_unformat_error, i);
11074 errmsg ("expecting: add|del");
11077 if (classify_table_index == ~0)
11079 errmsg ("classifier table not specified");
11082 if (ip_version == 0)
11084 errmsg ("IP version not specified");
11088 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
11090 mp->is_add = is_add;
11091 mp->table_id = htonl (classify_table_index);
11092 mp->ip_version = ip_version;
11093 mp->transport_protocol = transport_protocol;
11101 api_get_node_index (vat_main_t * vam)
11103 unformat_input_t *i = vam->input;
11104 vl_api_get_node_index_t *mp;
11108 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11110 if (unformat (i, "node %s", &name))
11117 errmsg ("node name required");
11120 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11122 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11126 M (GET_NODE_INDEX, mp);
11127 clib_memcpy (mp->node_name, name, vec_len (name));
11136 api_get_next_index (vat_main_t * vam)
11138 unformat_input_t *i = vam->input;
11139 vl_api_get_next_index_t *mp;
11140 u8 *node_name = 0, *next_node_name = 0;
11143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11145 if (unformat (i, "node-name %s", &node_name))
11147 else if (unformat (i, "next-node-name %s", &next_node_name))
11151 if (node_name == 0)
11153 errmsg ("node name required");
11156 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11158 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11162 if (next_node_name == 0)
11164 errmsg ("next node name required");
11167 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11169 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11173 M (GET_NEXT_INDEX, mp);
11174 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11175 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11176 vec_free (node_name);
11177 vec_free (next_node_name);
11185 api_add_node_next (vat_main_t * vam)
11187 unformat_input_t *i = vam->input;
11188 vl_api_add_node_next_t *mp;
11193 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11195 if (unformat (i, "node %s", &name))
11197 else if (unformat (i, "next %s", &next))
11204 errmsg ("node name required");
11207 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11209 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11214 errmsg ("next node required");
11217 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11219 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11223 M (ADD_NODE_NEXT, mp);
11224 clib_memcpy (mp->node_name, name, vec_len (name));
11225 clib_memcpy (mp->next_name, next, vec_len (next));
11235 api_l2tpv3_create_tunnel (vat_main_t * vam)
11237 unformat_input_t *i = vam->input;
11238 ip6_address_t client_address, our_address;
11239 int client_address_set = 0;
11240 int our_address_set = 0;
11241 u32 local_session_id = 0;
11242 u32 remote_session_id = 0;
11243 u64 local_cookie = 0;
11244 u64 remote_cookie = 0;
11245 u8 l2_sublayer_present = 0;
11246 vl_api_l2tpv3_create_tunnel_t *mp;
11249 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11251 if (unformat (i, "client_address %U", unformat_ip6_address,
11253 client_address_set = 1;
11254 else if (unformat (i, "our_address %U", unformat_ip6_address,
11256 our_address_set = 1;
11257 else if (unformat (i, "local_session_id %d", &local_session_id))
11259 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11261 else if (unformat (i, "local_cookie %lld", &local_cookie))
11263 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11265 else if (unformat (i, "l2-sublayer-present"))
11266 l2_sublayer_present = 1;
11271 if (client_address_set == 0)
11273 errmsg ("client_address required");
11277 if (our_address_set == 0)
11279 errmsg ("our_address required");
11283 M (L2TPV3_CREATE_TUNNEL, mp);
11285 clib_memcpy (mp->client_address, client_address.as_u8,
11286 sizeof (mp->client_address));
11288 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11290 mp->local_session_id = ntohl (local_session_id);
11291 mp->remote_session_id = ntohl (remote_session_id);
11292 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11293 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11294 mp->l2_sublayer_present = l2_sublayer_present;
11303 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11305 unformat_input_t *i = vam->input;
11307 u8 sw_if_index_set = 0;
11308 u64 new_local_cookie = 0;
11309 u64 new_remote_cookie = 0;
11310 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11313 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11315 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11316 sw_if_index_set = 1;
11317 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11318 sw_if_index_set = 1;
11319 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11321 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11327 if (sw_if_index_set == 0)
11329 errmsg ("missing interface name or sw_if_index");
11333 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11335 mp->sw_if_index = ntohl (sw_if_index);
11336 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11337 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11345 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11347 unformat_input_t *i = vam->input;
11348 vl_api_l2tpv3_interface_enable_disable_t *mp;
11350 u8 sw_if_index_set = 0;
11351 u8 enable_disable = 1;
11354 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11356 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11357 sw_if_index_set = 1;
11358 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11359 sw_if_index_set = 1;
11360 else if (unformat (i, "enable"))
11361 enable_disable = 1;
11362 else if (unformat (i, "disable"))
11363 enable_disable = 0;
11368 if (sw_if_index_set == 0)
11370 errmsg ("missing interface name or sw_if_index");
11374 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11376 mp->sw_if_index = ntohl (sw_if_index);
11377 mp->enable_disable = enable_disable;
11385 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11387 unformat_input_t *i = vam->input;
11388 vl_api_l2tpv3_set_lookup_key_t *mp;
11392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11394 if (unformat (i, "lookup_v6_src"))
11395 key = L2T_LOOKUP_SRC_ADDRESS;
11396 else if (unformat (i, "lookup_v6_dst"))
11397 key = L2T_LOOKUP_DST_ADDRESS;
11398 else if (unformat (i, "lookup_session_id"))
11399 key = L2T_LOOKUP_SESSION_ID;
11404 if (key == (u8) ~ 0)
11406 errmsg ("l2tp session lookup key unset");
11410 M (L2TPV3_SET_LOOKUP_KEY, mp);
11419 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11420 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11422 vat_main_t *vam = &vat_main;
11424 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11425 format_ip6_address, mp->our_address,
11426 format_ip6_address, mp->client_address,
11427 clib_net_to_host_u32 (mp->sw_if_index));
11430 " local cookies %016llx %016llx remote cookie %016llx",
11431 clib_net_to_host_u64 (mp->local_cookie[0]),
11432 clib_net_to_host_u64 (mp->local_cookie[1]),
11433 clib_net_to_host_u64 (mp->remote_cookie));
11435 print (vam->ofp, " local session-id %d remote session-id %d",
11436 clib_net_to_host_u32 (mp->local_session_id),
11437 clib_net_to_host_u32 (mp->remote_session_id));
11439 print (vam->ofp, " l2 specific sublayer %s\n",
11440 mp->l2_sublayer_present ? "preset" : "absent");
11444 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11445 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11447 vat_main_t *vam = &vat_main;
11448 vat_json_node_t *node = NULL;
11449 struct in6_addr addr;
11451 if (VAT_JSON_ARRAY != vam->json_tree.type)
11453 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11454 vat_json_init_array (&vam->json_tree);
11456 node = vat_json_array_add (&vam->json_tree);
11458 vat_json_init_object (node);
11460 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11461 vat_json_object_add_ip6 (node, "our_address", addr);
11462 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11463 vat_json_object_add_ip6 (node, "client_address", addr);
11465 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11466 vat_json_init_array (lc);
11467 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11468 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11469 vat_json_object_add_uint (node, "remote_cookie",
11470 clib_net_to_host_u64 (mp->remote_cookie));
11472 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11473 vat_json_object_add_uint (node, "local_session_id",
11474 clib_net_to_host_u32 (mp->local_session_id));
11475 vat_json_object_add_uint (node, "remote_session_id",
11476 clib_net_to_host_u32 (mp->remote_session_id));
11477 vat_json_object_add_string_copy (node, "l2_sublayer",
11478 mp->l2_sublayer_present ? (u8 *) "present"
11479 : (u8 *) "absent");
11483 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11485 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11486 vl_api_control_ping_t *mp_ping;
11489 /* Get list of l2tpv3-tunnel interfaces */
11490 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11493 /* Use a control ping for synchronization */
11494 M (CONTROL_PING, mp_ping);
11502 static void vl_api_sw_interface_tap_details_t_handler
11503 (vl_api_sw_interface_tap_details_t * mp)
11505 vat_main_t *vam = &vat_main;
11507 print (vam->ofp, "%-16s %d",
11508 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11511 static void vl_api_sw_interface_tap_details_t_handler_json
11512 (vl_api_sw_interface_tap_details_t * mp)
11514 vat_main_t *vam = &vat_main;
11515 vat_json_node_t *node = NULL;
11517 if (VAT_JSON_ARRAY != vam->json_tree.type)
11519 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11520 vat_json_init_array (&vam->json_tree);
11522 node = vat_json_array_add (&vam->json_tree);
11524 vat_json_init_object (node);
11525 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11526 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11530 api_sw_interface_tap_dump (vat_main_t * vam)
11532 vl_api_sw_interface_tap_dump_t *mp;
11533 vl_api_control_ping_t *mp_ping;
11536 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11537 /* Get list of tap interfaces */
11538 M (SW_INTERFACE_TAP_DUMP, mp);
11541 /* Use a control ping for synchronization */
11542 M (CONTROL_PING, mp_ping);
11549 static uword unformat_vxlan_decap_next
11550 (unformat_input_t * input, va_list * args)
11552 u32 *result = va_arg (*args, u32 *);
11555 if (unformat (input, "l2"))
11556 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11557 else if (unformat (input, "%d", &tmp))
11565 api_vxlan_add_del_tunnel (vat_main_t * vam)
11567 unformat_input_t *line_input = vam->input;
11568 vl_api_vxlan_add_del_tunnel_t *mp;
11569 ip46_address_t src, dst;
11571 u8 ipv4_set = 0, ipv6_set = 0;
11575 u32 mcast_sw_if_index = ~0;
11576 u32 encap_vrf_id = 0;
11577 u32 decap_next_index = ~0;
11581 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11582 memset (&src, 0, sizeof src);
11583 memset (&dst, 0, sizeof dst);
11585 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11587 if (unformat (line_input, "del"))
11590 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11596 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11602 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11608 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11613 else if (unformat (line_input, "group %U %U",
11614 unformat_ip4_address, &dst.ip4,
11615 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11617 grp_set = dst_set = 1;
11620 else if (unformat (line_input, "group %U",
11621 unformat_ip4_address, &dst.ip4))
11623 grp_set = dst_set = 1;
11626 else if (unformat (line_input, "group %U %U",
11627 unformat_ip6_address, &dst.ip6,
11628 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11630 grp_set = dst_set = 1;
11633 else if (unformat (line_input, "group %U",
11634 unformat_ip6_address, &dst.ip6))
11636 grp_set = dst_set = 1;
11640 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11642 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11644 else if (unformat (line_input, "decap-next %U",
11645 unformat_vxlan_decap_next, &decap_next_index))
11647 else if (unformat (line_input, "vni %d", &vni))
11651 errmsg ("parse error '%U'", format_unformat_error, line_input);
11658 errmsg ("tunnel src address not specified");
11663 errmsg ("tunnel dst address not specified");
11667 if (grp_set && !ip46_address_is_multicast (&dst))
11669 errmsg ("tunnel group address not multicast");
11672 if (grp_set && mcast_sw_if_index == ~0)
11674 errmsg ("tunnel nonexistent multicast device");
11677 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11679 errmsg ("tunnel dst address must be unicast");
11684 if (ipv4_set && ipv6_set)
11686 errmsg ("both IPv4 and IPv6 addresses specified");
11690 if ((vni == 0) || (vni >> 24))
11692 errmsg ("vni not specified or out of range");
11696 M (VXLAN_ADD_DEL_TUNNEL, mp);
11700 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11701 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11705 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11706 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11708 mp->encap_vrf_id = ntohl (encap_vrf_id);
11709 mp->decap_next_index = ntohl (decap_next_index);
11710 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11711 mp->vni = ntohl (vni);
11712 mp->is_add = is_add;
11713 mp->is_ipv6 = ipv6_set;
11720 static void vl_api_vxlan_tunnel_details_t_handler
11721 (vl_api_vxlan_tunnel_details_t * mp)
11723 vat_main_t *vam = &vat_main;
11724 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11725 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11727 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11728 ntohl (mp->sw_if_index),
11729 format_ip46_address, &src, IP46_TYPE_ANY,
11730 format_ip46_address, &dst, IP46_TYPE_ANY,
11731 ntohl (mp->encap_vrf_id),
11732 ntohl (mp->decap_next_index), ntohl (mp->vni),
11733 ntohl (mp->mcast_sw_if_index));
11736 static void vl_api_vxlan_tunnel_details_t_handler_json
11737 (vl_api_vxlan_tunnel_details_t * mp)
11739 vat_main_t *vam = &vat_main;
11740 vat_json_node_t *node = NULL;
11742 if (VAT_JSON_ARRAY != vam->json_tree.type)
11744 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11745 vat_json_init_array (&vam->json_tree);
11747 node = vat_json_array_add (&vam->json_tree);
11749 vat_json_init_object (node);
11750 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11753 struct in6_addr ip6;
11755 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11756 vat_json_object_add_ip6 (node, "src_address", ip6);
11757 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11758 vat_json_object_add_ip6 (node, "dst_address", ip6);
11762 struct in_addr ip4;
11764 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11765 vat_json_object_add_ip4 (node, "src_address", ip4);
11766 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11767 vat_json_object_add_ip4 (node, "dst_address", ip4);
11769 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11770 vat_json_object_add_uint (node, "decap_next_index",
11771 ntohl (mp->decap_next_index));
11772 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11773 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11774 vat_json_object_add_uint (node, "mcast_sw_if_index",
11775 ntohl (mp->mcast_sw_if_index));
11779 api_vxlan_tunnel_dump (vat_main_t * vam)
11781 unformat_input_t *i = vam->input;
11782 vl_api_vxlan_tunnel_dump_t *mp;
11783 vl_api_control_ping_t *mp_ping;
11785 u8 sw_if_index_set = 0;
11788 /* Parse args required to build the message */
11789 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11791 if (unformat (i, "sw_if_index %d", &sw_if_index))
11792 sw_if_index_set = 1;
11797 if (sw_if_index_set == 0)
11802 if (!vam->json_output)
11804 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11805 "sw_if_index", "src_address", "dst_address",
11806 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11809 /* Get list of vxlan-tunnel interfaces */
11810 M (VXLAN_TUNNEL_DUMP, mp);
11812 mp->sw_if_index = htonl (sw_if_index);
11816 /* Use a control ping for synchronization */
11817 M (CONTROL_PING, mp_ping);
11825 api_gre_add_del_tunnel (vat_main_t * vam)
11827 unformat_input_t *line_input = vam->input;
11828 vl_api_gre_add_del_tunnel_t *mp;
11829 ip4_address_t src4, dst4;
11830 ip6_address_t src6, dst6;
11837 u32 outer_fib_id = 0;
11840 memset (&src4, 0, sizeof src4);
11841 memset (&dst4, 0, sizeof dst4);
11842 memset (&src6, 0, sizeof src6);
11843 memset (&dst6, 0, sizeof dst6);
11845 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11847 if (unformat (line_input, "del"))
11849 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11854 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11859 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11864 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11869 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11871 else if (unformat (line_input, "teb"))
11875 errmsg ("parse error '%U'", format_unformat_error, line_input);
11882 errmsg ("tunnel src address not specified");
11887 errmsg ("tunnel dst address not specified");
11890 if (ipv4_set && ipv6_set)
11892 errmsg ("both IPv4 and IPv6 addresses specified");
11897 M (GRE_ADD_DEL_TUNNEL, mp);
11901 clib_memcpy (&mp->src_address, &src4, 4);
11902 clib_memcpy (&mp->dst_address, &dst4, 4);
11906 clib_memcpy (&mp->src_address, &src6, 16);
11907 clib_memcpy (&mp->dst_address, &dst6, 16);
11909 mp->outer_fib_id = ntohl (outer_fib_id);
11910 mp->is_add = is_add;
11912 mp->is_ipv6 = ipv6_set;
11919 static void vl_api_gre_tunnel_details_t_handler
11920 (vl_api_gre_tunnel_details_t * mp)
11922 vat_main_t *vam = &vat_main;
11923 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11924 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11926 print (vam->ofp, "%11d%24U%24U%6d%14d",
11927 ntohl (mp->sw_if_index),
11928 format_ip46_address, &src, IP46_TYPE_ANY,
11929 format_ip46_address, &dst, IP46_TYPE_ANY,
11930 mp->teb, ntohl (mp->outer_fib_id));
11933 static void vl_api_gre_tunnel_details_t_handler_json
11934 (vl_api_gre_tunnel_details_t * mp)
11936 vat_main_t *vam = &vat_main;
11937 vat_json_node_t *node = NULL;
11938 struct in_addr ip4;
11939 struct in6_addr ip6;
11941 if (VAT_JSON_ARRAY != vam->json_tree.type)
11943 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11944 vat_json_init_array (&vam->json_tree);
11946 node = vat_json_array_add (&vam->json_tree);
11948 vat_json_init_object (node);
11949 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11952 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11953 vat_json_object_add_ip4 (node, "src_address", ip4);
11954 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11955 vat_json_object_add_ip4 (node, "dst_address", ip4);
11959 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11960 vat_json_object_add_ip6 (node, "src_address", ip6);
11961 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11962 vat_json_object_add_ip6 (node, "dst_address", ip6);
11964 vat_json_object_add_uint (node, "teb", mp->teb);
11965 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11966 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11970 api_gre_tunnel_dump (vat_main_t * vam)
11972 unformat_input_t *i = vam->input;
11973 vl_api_gre_tunnel_dump_t *mp;
11974 vl_api_control_ping_t *mp_ping;
11976 u8 sw_if_index_set = 0;
11979 /* Parse args required to build the message */
11980 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11982 if (unformat (i, "sw_if_index %d", &sw_if_index))
11983 sw_if_index_set = 1;
11988 if (sw_if_index_set == 0)
11993 if (!vam->json_output)
11995 print (vam->ofp, "%11s%24s%24s%6s%14s",
11996 "sw_if_index", "src_address", "dst_address", "teb",
12000 /* Get list of gre-tunnel interfaces */
12001 M (GRE_TUNNEL_DUMP, mp);
12003 mp->sw_if_index = htonl (sw_if_index);
12007 /* Use a control ping for synchronization */
12008 M (CONTROL_PING, mp_ping);
12016 api_l2_fib_clear_table (vat_main_t * vam)
12018 // unformat_input_t * i = vam->input;
12019 vl_api_l2_fib_clear_table_t *mp;
12022 M (L2_FIB_CLEAR_TABLE, mp);
12030 api_l2_interface_efp_filter (vat_main_t * vam)
12032 unformat_input_t *i = vam->input;
12033 vl_api_l2_interface_efp_filter_t *mp;
12036 u8 sw_if_index_set = 0;
12039 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12041 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12042 sw_if_index_set = 1;
12043 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12044 sw_if_index_set = 1;
12045 else if (unformat (i, "enable"))
12047 else if (unformat (i, "disable"))
12051 clib_warning ("parse error '%U'", format_unformat_error, i);
12056 if (sw_if_index_set == 0)
12058 errmsg ("missing sw_if_index");
12062 M (L2_INTERFACE_EFP_FILTER, mp);
12064 mp->sw_if_index = ntohl (sw_if_index);
12065 mp->enable_disable = enable;
12072 #define foreach_vtr_op \
12073 _("disable", L2_VTR_DISABLED) \
12074 _("push-1", L2_VTR_PUSH_1) \
12075 _("push-2", L2_VTR_PUSH_2) \
12076 _("pop-1", L2_VTR_POP_1) \
12077 _("pop-2", L2_VTR_POP_2) \
12078 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
12079 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
12080 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
12081 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
12084 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
12086 unformat_input_t *i = vam->input;
12087 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
12089 u8 sw_if_index_set = 0;
12092 u32 push_dot1q = 1;
12097 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12099 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12100 sw_if_index_set = 1;
12101 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12102 sw_if_index_set = 1;
12103 else if (unformat (i, "vtr_op %d", &vtr_op))
12105 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
12108 else if (unformat (i, "push_dot1q %d", &push_dot1q))
12110 else if (unformat (i, "tag1 %d", &tag1))
12112 else if (unformat (i, "tag2 %d", &tag2))
12116 clib_warning ("parse error '%U'", format_unformat_error, i);
12121 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
12123 errmsg ("missing vtr operation or sw_if_index");
12127 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12128 mp->sw_if_index = ntohl (sw_if_index);
12129 mp->vtr_op = ntohl (vtr_op);
12130 mp->push_dot1q = ntohl (push_dot1q);
12131 mp->tag1 = ntohl (tag1);
12132 mp->tag2 = ntohl (tag2);
12140 api_create_vhost_user_if (vat_main_t * vam)
12142 unformat_input_t *i = vam->input;
12143 vl_api_create_vhost_user_if_t *mp;
12146 u8 file_name_set = 0;
12147 u32 custom_dev_instance = ~0;
12149 u8 use_custom_mac = 0;
12153 /* Shut up coverity */
12154 memset (hwaddr, 0, sizeof (hwaddr));
12156 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12158 if (unformat (i, "socket %s", &file_name))
12162 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12164 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12165 use_custom_mac = 1;
12166 else if (unformat (i, "server"))
12168 else if (unformat (i, "tag %s", &tag))
12174 if (file_name_set == 0)
12176 errmsg ("missing socket file name");
12180 if (vec_len (file_name) > 255)
12182 errmsg ("socket file name too long");
12185 vec_add1 (file_name, 0);
12187 M (CREATE_VHOST_USER_IF, mp);
12189 mp->is_server = is_server;
12190 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12191 vec_free (file_name);
12192 if (custom_dev_instance != ~0)
12195 mp->custom_dev_instance = ntohl (custom_dev_instance);
12197 mp->use_custom_mac = use_custom_mac;
12198 clib_memcpy (mp->mac_address, hwaddr, 6);
12200 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12209 api_modify_vhost_user_if (vat_main_t * vam)
12211 unformat_input_t *i = vam->input;
12212 vl_api_modify_vhost_user_if_t *mp;
12215 u8 file_name_set = 0;
12216 u32 custom_dev_instance = ~0;
12217 u8 sw_if_index_set = 0;
12218 u32 sw_if_index = (u32) ~ 0;
12221 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12223 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12224 sw_if_index_set = 1;
12225 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12226 sw_if_index_set = 1;
12227 else if (unformat (i, "socket %s", &file_name))
12231 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12233 else if (unformat (i, "server"))
12239 if (sw_if_index_set == 0)
12241 errmsg ("missing sw_if_index or interface name");
12245 if (file_name_set == 0)
12247 errmsg ("missing socket file name");
12251 if (vec_len (file_name) > 255)
12253 errmsg ("socket file name too long");
12256 vec_add1 (file_name, 0);
12258 M (MODIFY_VHOST_USER_IF, mp);
12260 mp->sw_if_index = ntohl (sw_if_index);
12261 mp->is_server = is_server;
12262 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12263 vec_free (file_name);
12264 if (custom_dev_instance != ~0)
12267 mp->custom_dev_instance = ntohl (custom_dev_instance);
12276 api_delete_vhost_user_if (vat_main_t * vam)
12278 unformat_input_t *i = vam->input;
12279 vl_api_delete_vhost_user_if_t *mp;
12280 u32 sw_if_index = ~0;
12281 u8 sw_if_index_set = 0;
12284 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12286 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12287 sw_if_index_set = 1;
12288 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12289 sw_if_index_set = 1;
12294 if (sw_if_index_set == 0)
12296 errmsg ("missing sw_if_index or interface name");
12301 M (DELETE_VHOST_USER_IF, mp);
12303 mp->sw_if_index = ntohl (sw_if_index);
12310 static void vl_api_sw_interface_vhost_user_details_t_handler
12311 (vl_api_sw_interface_vhost_user_details_t * mp)
12313 vat_main_t *vam = &vat_main;
12315 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12316 (char *) mp->interface_name,
12317 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12318 clib_net_to_host_u64 (mp->features), mp->is_server,
12319 ntohl (mp->num_regions), (char *) mp->sock_filename);
12320 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12323 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12324 (vl_api_sw_interface_vhost_user_details_t * mp)
12326 vat_main_t *vam = &vat_main;
12327 vat_json_node_t *node = NULL;
12329 if (VAT_JSON_ARRAY != vam->json_tree.type)
12331 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12332 vat_json_init_array (&vam->json_tree);
12334 node = vat_json_array_add (&vam->json_tree);
12336 vat_json_init_object (node);
12337 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12338 vat_json_object_add_string_copy (node, "interface_name",
12339 mp->interface_name);
12340 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12341 ntohl (mp->virtio_net_hdr_sz));
12342 vat_json_object_add_uint (node, "features",
12343 clib_net_to_host_u64 (mp->features));
12344 vat_json_object_add_uint (node, "is_server", mp->is_server);
12345 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12346 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12347 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12351 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12353 vl_api_sw_interface_vhost_user_dump_t *mp;
12354 vl_api_control_ping_t *mp_ping;
12357 "Interface name idx hdr_sz features server regions filename");
12359 /* Get list of vhost-user interfaces */
12360 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12363 /* Use a control ping for synchronization */
12364 M (CONTROL_PING, mp_ping);
12372 api_show_version (vat_main_t * vam)
12374 vl_api_show_version_t *mp;
12377 M (SHOW_VERSION, mp);
12386 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12388 unformat_input_t *line_input = vam->input;
12389 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12390 ip4_address_t local4, remote4;
12391 ip6_address_t local6, remote6;
12393 u8 ipv4_set = 0, ipv6_set = 0;
12397 u32 mcast_sw_if_index = ~0;
12398 u32 encap_vrf_id = 0;
12399 u32 decap_vrf_id = 0;
12405 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12406 memset (&local4, 0, sizeof local4);
12407 memset (&remote4, 0, sizeof remote4);
12408 memset (&local6, 0, sizeof local6);
12409 memset (&remote6, 0, sizeof remote6);
12411 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12413 if (unformat (line_input, "del"))
12415 else if (unformat (line_input, "local %U",
12416 unformat_ip4_address, &local4))
12421 else if (unformat (line_input, "remote %U",
12422 unformat_ip4_address, &remote4))
12427 else if (unformat (line_input, "local %U",
12428 unformat_ip6_address, &local6))
12433 else if (unformat (line_input, "remote %U",
12434 unformat_ip6_address, &remote6))
12439 else if (unformat (line_input, "group %U %U",
12440 unformat_ip4_address, &remote4,
12441 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12443 grp_set = remote_set = 1;
12446 else if (unformat (line_input, "group %U",
12447 unformat_ip4_address, &remote4))
12449 grp_set = remote_set = 1;
12452 else if (unformat (line_input, "group %U %U",
12453 unformat_ip6_address, &remote6,
12454 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12456 grp_set = remote_set = 1;
12459 else if (unformat (line_input, "group %U",
12460 unformat_ip6_address, &remote6))
12462 grp_set = remote_set = 1;
12466 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12468 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12470 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12472 else if (unformat (line_input, "vni %d", &vni))
12474 else if (unformat (line_input, "next-ip4"))
12476 else if (unformat (line_input, "next-ip6"))
12478 else if (unformat (line_input, "next-ethernet"))
12480 else if (unformat (line_input, "next-nsh"))
12484 errmsg ("parse error '%U'", format_unformat_error, line_input);
12489 if (local_set == 0)
12491 errmsg ("tunnel local address not specified");
12494 if (remote_set == 0)
12496 errmsg ("tunnel remote address not specified");
12499 if (grp_set && mcast_sw_if_index == ~0)
12501 errmsg ("tunnel nonexistent multicast device");
12504 if (ipv4_set && ipv6_set)
12506 errmsg ("both IPv4 and IPv6 addresses specified");
12512 errmsg ("vni not specified");
12516 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12521 clib_memcpy (&mp->local, &local6, sizeof (local6));
12522 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12526 clib_memcpy (&mp->local, &local4, sizeof (local4));
12527 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12530 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12531 mp->encap_vrf_id = ntohl (encap_vrf_id);
12532 mp->decap_vrf_id = ntohl (decap_vrf_id);
12533 mp->protocol = protocol;
12534 mp->vni = ntohl (vni);
12535 mp->is_add = is_add;
12536 mp->is_ipv6 = ipv6_set;
12543 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12544 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12546 vat_main_t *vam = &vat_main;
12547 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12548 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12550 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12551 ntohl (mp->sw_if_index),
12552 format_ip46_address, &local, IP46_TYPE_ANY,
12553 format_ip46_address, &remote, IP46_TYPE_ANY,
12554 ntohl (mp->vni), mp->protocol,
12555 ntohl (mp->mcast_sw_if_index),
12556 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12560 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12561 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12563 vat_main_t *vam = &vat_main;
12564 vat_json_node_t *node = NULL;
12565 struct in_addr ip4;
12566 struct in6_addr ip6;
12568 if (VAT_JSON_ARRAY != vam->json_tree.type)
12570 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12571 vat_json_init_array (&vam->json_tree);
12573 node = vat_json_array_add (&vam->json_tree);
12575 vat_json_init_object (node);
12576 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12579 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12580 vat_json_object_add_ip6 (node, "local", ip6);
12581 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12582 vat_json_object_add_ip6 (node, "remote", ip6);
12586 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12587 vat_json_object_add_ip4 (node, "local", ip4);
12588 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12589 vat_json_object_add_ip4 (node, "remote", ip4);
12591 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12592 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12593 vat_json_object_add_uint (node, "mcast_sw_if_index",
12594 ntohl (mp->mcast_sw_if_index));
12595 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12596 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12597 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12601 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12603 unformat_input_t *i = vam->input;
12604 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12605 vl_api_control_ping_t *mp_ping;
12607 u8 sw_if_index_set = 0;
12610 /* Parse args required to build the message */
12611 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12613 if (unformat (i, "sw_if_index %d", &sw_if_index))
12614 sw_if_index_set = 1;
12619 if (sw_if_index_set == 0)
12624 if (!vam->json_output)
12626 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12627 "sw_if_index", "local", "remote", "vni",
12628 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12631 /* Get list of vxlan-tunnel interfaces */
12632 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12634 mp->sw_if_index = htonl (sw_if_index);
12638 /* Use a control ping for synchronization */
12639 M (CONTROL_PING, mp_ping);
12648 format_l2_fib_mac_address (u8 * s, va_list * args)
12650 u8 *a = va_arg (*args, u8 *);
12652 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12653 a[2], a[3], a[4], a[5], a[6], a[7]);
12656 static void vl_api_l2_fib_table_details_t_handler
12657 (vl_api_l2_fib_table_details_t * mp)
12659 vat_main_t *vam = &vat_main;
12661 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12663 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12664 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12668 static void vl_api_l2_fib_table_details_t_handler_json
12669 (vl_api_l2_fib_table_details_t * mp)
12671 vat_main_t *vam = &vat_main;
12672 vat_json_node_t *node = NULL;
12674 if (VAT_JSON_ARRAY != vam->json_tree.type)
12676 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12677 vat_json_init_array (&vam->json_tree);
12679 node = vat_json_array_add (&vam->json_tree);
12681 vat_json_init_object (node);
12682 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12683 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12684 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12685 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12686 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12687 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12691 api_l2_fib_table_dump (vat_main_t * vam)
12693 unformat_input_t *i = vam->input;
12694 vl_api_l2_fib_table_dump_t *mp;
12695 vl_api_control_ping_t *mp_ping;
12700 /* Parse args required to build the message */
12701 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12703 if (unformat (i, "bd_id %d", &bd_id))
12709 if (bd_id_set == 0)
12711 errmsg ("missing bridge domain");
12715 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12717 /* Get list of l2 fib entries */
12718 M (L2_FIB_TABLE_DUMP, mp);
12720 mp->bd_id = ntohl (bd_id);
12723 /* Use a control ping for synchronization */
12724 M (CONTROL_PING, mp_ping);
12733 api_interface_name_renumber (vat_main_t * vam)
12735 unformat_input_t *line_input = vam->input;
12736 vl_api_interface_name_renumber_t *mp;
12737 u32 sw_if_index = ~0;
12738 u32 new_show_dev_instance = ~0;
12741 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12743 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12746 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12748 else if (unformat (line_input, "new_show_dev_instance %d",
12749 &new_show_dev_instance))
12755 if (sw_if_index == ~0)
12757 errmsg ("missing interface name or sw_if_index");
12761 if (new_show_dev_instance == ~0)
12763 errmsg ("missing new_show_dev_instance");
12767 M (INTERFACE_NAME_RENUMBER, mp);
12769 mp->sw_if_index = ntohl (sw_if_index);
12770 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12778 api_want_ip4_arp_events (vat_main_t * vam)
12780 unformat_input_t *line_input = vam->input;
12781 vl_api_want_ip4_arp_events_t *mp;
12782 ip4_address_t address;
12783 int address_set = 0;
12784 u32 enable_disable = 1;
12787 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12789 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12791 else if (unformat (line_input, "del"))
12792 enable_disable = 0;
12797 if (address_set == 0)
12799 errmsg ("missing addresses");
12803 M (WANT_IP4_ARP_EVENTS, mp);
12804 mp->enable_disable = enable_disable;
12805 mp->pid = htonl (getpid ());
12806 mp->address = address.as_u32;
12814 api_want_ip6_nd_events (vat_main_t * vam)
12816 unformat_input_t *line_input = vam->input;
12817 vl_api_want_ip6_nd_events_t *mp;
12818 ip6_address_t address;
12819 int address_set = 0;
12820 u32 enable_disable = 1;
12823 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12825 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12827 else if (unformat (line_input, "del"))
12828 enable_disable = 0;
12833 if (address_set == 0)
12835 errmsg ("missing addresses");
12839 M (WANT_IP6_ND_EVENTS, mp);
12840 mp->enable_disable = enable_disable;
12841 mp->pid = htonl (getpid ());
12842 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12850 api_want_l2_macs_events (vat_main_t * vam)
12852 unformat_input_t *line_input = vam->input;
12853 vl_api_want_l2_macs_events_t *mp;
12854 u8 enable_disable = 1;
12855 u32 scan_delay = 0;
12856 u32 max_macs_in_event = 0;
12857 u32 learn_limit = 0;
12860 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12862 if (unformat (line_input, "learn-limit %d", &learn_limit))
12864 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12866 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12868 else if (unformat (line_input, "disable"))
12869 enable_disable = 0;
12874 M (WANT_L2_MACS_EVENTS, mp);
12875 mp->enable_disable = enable_disable;
12876 mp->pid = htonl (getpid ());
12877 mp->learn_limit = htonl (learn_limit);
12878 mp->scan_delay = (u8) scan_delay;
12879 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12886 api_input_acl_set_interface (vat_main_t * vam)
12888 unformat_input_t *i = vam->input;
12889 vl_api_input_acl_set_interface_t *mp;
12891 int sw_if_index_set;
12892 u32 ip4_table_index = ~0;
12893 u32 ip6_table_index = ~0;
12894 u32 l2_table_index = ~0;
12898 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12900 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12901 sw_if_index_set = 1;
12902 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12903 sw_if_index_set = 1;
12904 else if (unformat (i, "del"))
12906 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12908 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12910 else if (unformat (i, "l2-table %d", &l2_table_index))
12914 clib_warning ("parse error '%U'", format_unformat_error, i);
12919 if (sw_if_index_set == 0)
12921 errmsg ("missing interface name or sw_if_index");
12925 M (INPUT_ACL_SET_INTERFACE, mp);
12927 mp->sw_if_index = ntohl (sw_if_index);
12928 mp->ip4_table_index = ntohl (ip4_table_index);
12929 mp->ip6_table_index = ntohl (ip6_table_index);
12930 mp->l2_table_index = ntohl (l2_table_index);
12931 mp->is_add = is_add;
12939 api_ip_address_dump (vat_main_t * vam)
12941 unformat_input_t *i = vam->input;
12942 vl_api_ip_address_dump_t *mp;
12943 vl_api_control_ping_t *mp_ping;
12944 u32 sw_if_index = ~0;
12945 u8 sw_if_index_set = 0;
12950 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12952 if (unformat (i, "sw_if_index %d", &sw_if_index))
12953 sw_if_index_set = 1;
12955 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12956 sw_if_index_set = 1;
12957 else if (unformat (i, "ipv4"))
12959 else if (unformat (i, "ipv6"))
12965 if (ipv4_set && ipv6_set)
12967 errmsg ("ipv4 and ipv6 flags cannot be both set");
12971 if ((!ipv4_set) && (!ipv6_set))
12973 errmsg ("no ipv4 nor ipv6 flag set");
12977 if (sw_if_index_set == 0)
12979 errmsg ("missing interface name or sw_if_index");
12983 vam->current_sw_if_index = sw_if_index;
12984 vam->is_ipv6 = ipv6_set;
12986 M (IP_ADDRESS_DUMP, mp);
12987 mp->sw_if_index = ntohl (sw_if_index);
12988 mp->is_ipv6 = ipv6_set;
12991 /* Use a control ping for synchronization */
12992 M (CONTROL_PING, mp_ping);
13000 api_ip_dump (vat_main_t * vam)
13002 vl_api_ip_dump_t *mp;
13003 vl_api_control_ping_t *mp_ping;
13004 unformat_input_t *in = vam->input;
13011 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
13013 if (unformat (in, "ipv4"))
13015 else if (unformat (in, "ipv6"))
13021 if (ipv4_set && ipv6_set)
13023 errmsg ("ipv4 and ipv6 flags cannot be both set");
13027 if ((!ipv4_set) && (!ipv6_set))
13029 errmsg ("no ipv4 nor ipv6 flag set");
13033 is_ipv6 = ipv6_set;
13034 vam->is_ipv6 = is_ipv6;
13036 /* free old data */
13037 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
13039 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
13041 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
13044 mp->is_ipv6 = ipv6_set;
13047 /* Use a control ping for synchronization */
13048 M (CONTROL_PING, mp_ping);
13056 api_ipsec_spd_add_del (vat_main_t * vam)
13058 unformat_input_t *i = vam->input;
13059 vl_api_ipsec_spd_add_del_t *mp;
13064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13066 if (unformat (i, "spd_id %d", &spd_id))
13068 else if (unformat (i, "del"))
13072 clib_warning ("parse error '%U'", format_unformat_error, i);
13078 errmsg ("spd_id must be set");
13082 M (IPSEC_SPD_ADD_DEL, mp);
13084 mp->spd_id = ntohl (spd_id);
13085 mp->is_add = is_add;
13093 api_ipsec_interface_add_del_spd (vat_main_t * vam)
13095 unformat_input_t *i = vam->input;
13096 vl_api_ipsec_interface_add_del_spd_t *mp;
13098 u8 sw_if_index_set = 0;
13099 u32 spd_id = (u32) ~ 0;
13103 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13105 if (unformat (i, "del"))
13107 else if (unformat (i, "spd_id %d", &spd_id))
13110 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
13111 sw_if_index_set = 1;
13112 else if (unformat (i, "sw_if_index %d", &sw_if_index))
13113 sw_if_index_set = 1;
13116 clib_warning ("parse error '%U'", format_unformat_error, i);
13122 if (spd_id == (u32) ~ 0)
13124 errmsg ("spd_id must be set");
13128 if (sw_if_index_set == 0)
13130 errmsg ("missing interface name or sw_if_index");
13134 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13136 mp->spd_id = ntohl (spd_id);
13137 mp->sw_if_index = ntohl (sw_if_index);
13138 mp->is_add = is_add;
13146 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13148 unformat_input_t *i = vam->input;
13149 vl_api_ipsec_spd_add_del_entry_t *mp;
13150 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13151 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13153 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13154 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13155 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13156 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13159 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13160 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13161 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13162 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13163 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13164 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13168 if (unformat (i, "del"))
13170 if (unformat (i, "outbound"))
13172 if (unformat (i, "inbound"))
13174 else if (unformat (i, "spd_id %d", &spd_id))
13176 else if (unformat (i, "sa_id %d", &sa_id))
13178 else if (unformat (i, "priority %d", &priority))
13180 else if (unformat (i, "protocol %d", &protocol))
13182 else if (unformat (i, "lport_start %d", &lport_start))
13184 else if (unformat (i, "lport_stop %d", &lport_stop))
13186 else if (unformat (i, "rport_start %d", &rport_start))
13188 else if (unformat (i, "rport_stop %d", &rport_stop))
13192 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13198 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13205 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13211 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13218 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13224 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13231 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13237 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13243 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13245 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13247 clib_warning ("unsupported action: 'resolve'");
13253 clib_warning ("parse error '%U'", format_unformat_error, i);
13259 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13261 mp->spd_id = ntohl (spd_id);
13262 mp->priority = ntohl (priority);
13263 mp->is_outbound = is_outbound;
13265 mp->is_ipv6 = is_ipv6;
13266 if (is_ipv6 || is_ip_any)
13268 clib_memcpy (mp->remote_address_start, &raddr6_start,
13269 sizeof (ip6_address_t));
13270 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13271 sizeof (ip6_address_t));
13272 clib_memcpy (mp->local_address_start, &laddr6_start,
13273 sizeof (ip6_address_t));
13274 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13275 sizeof (ip6_address_t));
13279 clib_memcpy (mp->remote_address_start, &raddr4_start,
13280 sizeof (ip4_address_t));
13281 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13282 sizeof (ip4_address_t));
13283 clib_memcpy (mp->local_address_start, &laddr4_start,
13284 sizeof (ip4_address_t));
13285 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13286 sizeof (ip4_address_t));
13288 mp->protocol = (u8) protocol;
13289 mp->local_port_start = ntohs ((u16) lport_start);
13290 mp->local_port_stop = ntohs ((u16) lport_stop);
13291 mp->remote_port_start = ntohs ((u16) rport_start);
13292 mp->remote_port_stop = ntohs ((u16) rport_stop);
13293 mp->policy = (u8) policy;
13294 mp->sa_id = ntohl (sa_id);
13295 mp->is_add = is_add;
13296 mp->is_ip_any = is_ip_any;
13303 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13305 unformat_input_t *i = vam->input;
13306 vl_api_ipsec_sad_add_del_entry_t *mp;
13307 u32 sad_id = 0, spi = 0;
13308 u8 *ck = 0, *ik = 0;
13311 u8 protocol = IPSEC_PROTOCOL_AH;
13312 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13313 u32 crypto_alg = 0, integ_alg = 0;
13314 ip4_address_t tun_src4;
13315 ip4_address_t tun_dst4;
13316 ip6_address_t tun_src6;
13317 ip6_address_t tun_dst6;
13320 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13322 if (unformat (i, "del"))
13324 else if (unformat (i, "sad_id %d", &sad_id))
13326 else if (unformat (i, "spi %d", &spi))
13328 else if (unformat (i, "esp"))
13329 protocol = IPSEC_PROTOCOL_ESP;
13330 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13333 is_tunnel_ipv6 = 0;
13335 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13338 is_tunnel_ipv6 = 0;
13340 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13343 is_tunnel_ipv6 = 1;
13345 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13348 is_tunnel_ipv6 = 1;
13352 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13354 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13355 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13357 clib_warning ("unsupported crypto-alg: '%U'",
13358 format_ipsec_crypto_alg, crypto_alg);
13362 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13366 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13368 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13369 integ_alg >= IPSEC_INTEG_N_ALG)
13371 clib_warning ("unsupported integ-alg: '%U'",
13372 format_ipsec_integ_alg, integ_alg);
13376 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13380 clib_warning ("parse error '%U'", format_unformat_error, i);
13386 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13388 mp->sad_id = ntohl (sad_id);
13389 mp->is_add = is_add;
13390 mp->protocol = protocol;
13391 mp->spi = ntohl (spi);
13392 mp->is_tunnel = is_tunnel;
13393 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13394 mp->crypto_algorithm = crypto_alg;
13395 mp->integrity_algorithm = integ_alg;
13396 mp->crypto_key_length = vec_len (ck);
13397 mp->integrity_key_length = vec_len (ik);
13399 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13400 mp->crypto_key_length = sizeof (mp->crypto_key);
13402 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13403 mp->integrity_key_length = sizeof (mp->integrity_key);
13406 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13408 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13412 if (is_tunnel_ipv6)
13414 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13415 sizeof (ip6_address_t));
13416 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13417 sizeof (ip6_address_t));
13421 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13422 sizeof (ip4_address_t));
13423 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13424 sizeof (ip4_address_t));
13434 api_ipsec_sa_set_key (vat_main_t * vam)
13436 unformat_input_t *i = vam->input;
13437 vl_api_ipsec_sa_set_key_t *mp;
13439 u8 *ck = 0, *ik = 0;
13442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13444 if (unformat (i, "sa_id %d", &sa_id))
13446 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13448 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13452 clib_warning ("parse error '%U'", format_unformat_error, i);
13457 M (IPSEC_SA_SET_KEY, mp);
13459 mp->sa_id = ntohl (sa_id);
13460 mp->crypto_key_length = vec_len (ck);
13461 mp->integrity_key_length = vec_len (ik);
13463 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13464 mp->crypto_key_length = sizeof (mp->crypto_key);
13466 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13467 mp->integrity_key_length = sizeof (mp->integrity_key);
13470 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13472 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13480 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13482 unformat_input_t *i = vam->input;
13483 vl_api_ipsec_tunnel_if_add_del_t *mp;
13484 u32 local_spi = 0, remote_spi = 0;
13485 u32 crypto_alg = 0, integ_alg = 0;
13486 u8 *lck = NULL, *rck = NULL;
13487 u8 *lik = NULL, *rik = NULL;
13488 ip4_address_t local_ip = { {0} };
13489 ip4_address_t remote_ip = { {0} };
13492 u8 anti_replay = 0;
13495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13497 if (unformat (i, "del"))
13499 else if (unformat (i, "esn"))
13501 else if (unformat (i, "anti_replay"))
13503 else if (unformat (i, "local_spi %d", &local_spi))
13505 else if (unformat (i, "remote_spi %d", &remote_spi))
13507 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13509 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13511 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13514 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13516 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13518 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13522 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13524 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13525 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13527 errmsg ("unsupported crypto-alg: '%U'\n",
13528 format_ipsec_crypto_alg, crypto_alg);
13534 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13536 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13537 integ_alg >= IPSEC_INTEG_N_ALG)
13539 errmsg ("unsupported integ-alg: '%U'\n",
13540 format_ipsec_integ_alg, integ_alg);
13546 errmsg ("parse error '%U'\n", format_unformat_error, i);
13551 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13553 mp->is_add = is_add;
13555 mp->anti_replay = anti_replay;
13557 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13558 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13560 mp->local_spi = htonl (local_spi);
13561 mp->remote_spi = htonl (remote_spi);
13562 mp->crypto_alg = (u8) crypto_alg;
13564 mp->local_crypto_key_len = 0;
13567 mp->local_crypto_key_len = vec_len (lck);
13568 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13569 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13570 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13573 mp->remote_crypto_key_len = 0;
13576 mp->remote_crypto_key_len = vec_len (rck);
13577 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13578 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13579 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13582 mp->integ_alg = (u8) integ_alg;
13584 mp->local_integ_key_len = 0;
13587 mp->local_integ_key_len = vec_len (lik);
13588 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13589 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13590 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13593 mp->remote_integ_key_len = 0;
13596 mp->remote_integ_key_len = vec_len (rik);
13597 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13598 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13599 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13608 api_ikev2_profile_add_del (vat_main_t * vam)
13610 unformat_input_t *i = vam->input;
13611 vl_api_ikev2_profile_add_del_t *mp;
13616 const char *valid_chars = "a-zA-Z0-9_";
13618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13620 if (unformat (i, "del"))
13622 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13623 vec_add1 (name, 0);
13626 errmsg ("parse error '%U'", format_unformat_error, i);
13631 if (!vec_len (name))
13633 errmsg ("profile name must be specified");
13637 if (vec_len (name) > 64)
13639 errmsg ("profile name too long");
13643 M (IKEV2_PROFILE_ADD_DEL, mp);
13645 clib_memcpy (mp->name, name, vec_len (name));
13646 mp->is_add = is_add;
13655 api_ikev2_profile_set_auth (vat_main_t * vam)
13657 unformat_input_t *i = vam->input;
13658 vl_api_ikev2_profile_set_auth_t *mp;
13661 u32 auth_method = 0;
13665 const char *valid_chars = "a-zA-Z0-9_";
13667 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13669 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13670 vec_add1 (name, 0);
13671 else if (unformat (i, "auth_method %U",
13672 unformat_ikev2_auth_method, &auth_method))
13674 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13676 else if (unformat (i, "auth_data %v", &data))
13680 errmsg ("parse error '%U'", format_unformat_error, i);
13685 if (!vec_len (name))
13687 errmsg ("profile name must be specified");
13691 if (vec_len (name) > 64)
13693 errmsg ("profile name too long");
13697 if (!vec_len (data))
13699 errmsg ("auth_data must be specified");
13705 errmsg ("auth_method must be specified");
13709 M (IKEV2_PROFILE_SET_AUTH, mp);
13711 mp->is_hex = is_hex;
13712 mp->auth_method = (u8) auth_method;
13713 mp->data_len = vec_len (data);
13714 clib_memcpy (mp->name, name, vec_len (name));
13715 clib_memcpy (mp->data, data, vec_len (data));
13725 api_ikev2_profile_set_id (vat_main_t * vam)
13727 unformat_input_t *i = vam->input;
13728 vl_api_ikev2_profile_set_id_t *mp;
13736 const char *valid_chars = "a-zA-Z0-9_";
13738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13740 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13741 vec_add1 (name, 0);
13742 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13744 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13746 data = vec_new (u8, 4);
13747 clib_memcpy (data, ip4.as_u8, 4);
13749 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13751 else if (unformat (i, "id_data %v", &data))
13753 else if (unformat (i, "local"))
13755 else if (unformat (i, "remote"))
13759 errmsg ("parse error '%U'", format_unformat_error, i);
13764 if (!vec_len (name))
13766 errmsg ("profile name must be specified");
13770 if (vec_len (name) > 64)
13772 errmsg ("profile name too long");
13776 if (!vec_len (data))
13778 errmsg ("id_data must be specified");
13784 errmsg ("id_type must be specified");
13788 M (IKEV2_PROFILE_SET_ID, mp);
13790 mp->is_local = is_local;
13791 mp->id_type = (u8) id_type;
13792 mp->data_len = vec_len (data);
13793 clib_memcpy (mp->name, name, vec_len (name));
13794 clib_memcpy (mp->data, data, vec_len (data));
13804 api_ikev2_profile_set_ts (vat_main_t * vam)
13806 unformat_input_t *i = vam->input;
13807 vl_api_ikev2_profile_set_ts_t *mp;
13810 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13811 ip4_address_t start_addr, end_addr;
13813 const char *valid_chars = "a-zA-Z0-9_";
13816 start_addr.as_u32 = 0;
13817 end_addr.as_u32 = (u32) ~ 0;
13819 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13821 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13822 vec_add1 (name, 0);
13823 else if (unformat (i, "protocol %d", &proto))
13825 else if (unformat (i, "start_port %d", &start_port))
13827 else if (unformat (i, "end_port %d", &end_port))
13830 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13832 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13834 else if (unformat (i, "local"))
13836 else if (unformat (i, "remote"))
13840 errmsg ("parse error '%U'", format_unformat_error, i);
13845 if (!vec_len (name))
13847 errmsg ("profile name must be specified");
13851 if (vec_len (name) > 64)
13853 errmsg ("profile name too long");
13857 M (IKEV2_PROFILE_SET_TS, mp);
13859 mp->is_local = is_local;
13860 mp->proto = (u8) proto;
13861 mp->start_port = (u16) start_port;
13862 mp->end_port = (u16) end_port;
13863 mp->start_addr = start_addr.as_u32;
13864 mp->end_addr = end_addr.as_u32;
13865 clib_memcpy (mp->name, name, vec_len (name));
13874 api_ikev2_set_local_key (vat_main_t * vam)
13876 unformat_input_t *i = vam->input;
13877 vl_api_ikev2_set_local_key_t *mp;
13881 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13883 if (unformat (i, "file %v", &file))
13884 vec_add1 (file, 0);
13887 errmsg ("parse error '%U'", format_unformat_error, i);
13892 if (!vec_len (file))
13894 errmsg ("RSA key file must be specified");
13898 if (vec_len (file) > 256)
13900 errmsg ("file name too long");
13904 M (IKEV2_SET_LOCAL_KEY, mp);
13906 clib_memcpy (mp->key_file, file, vec_len (file));
13915 api_ikev2_set_responder (vat_main_t * vam)
13917 unformat_input_t *i = vam->input;
13918 vl_api_ikev2_set_responder_t *mp;
13921 u32 sw_if_index = ~0;
13922 ip4_address_t address;
13924 const char *valid_chars = "a-zA-Z0-9_";
13926 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13929 (i, "%U interface %d address %U", unformat_token, valid_chars,
13930 &name, &sw_if_index, unformat_ip4_address, &address))
13931 vec_add1 (name, 0);
13934 errmsg ("parse error '%U'", format_unformat_error, i);
13939 if (!vec_len (name))
13941 errmsg ("profile name must be specified");
13945 if (vec_len (name) > 64)
13947 errmsg ("profile name too long");
13951 M (IKEV2_SET_RESPONDER, mp);
13953 clib_memcpy (mp->name, name, vec_len (name));
13956 mp->sw_if_index = sw_if_index;
13957 clib_memcpy (mp->address, &address, sizeof (address));
13965 api_ikev2_set_ike_transforms (vat_main_t * vam)
13967 unformat_input_t *i = vam->input;
13968 vl_api_ikev2_set_ike_transforms_t *mp;
13971 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13973 const char *valid_chars = "a-zA-Z0-9_";
13975 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13977 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13978 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13979 vec_add1 (name, 0);
13982 errmsg ("parse error '%U'", format_unformat_error, i);
13987 if (!vec_len (name))
13989 errmsg ("profile name must be specified");
13993 if (vec_len (name) > 64)
13995 errmsg ("profile name too long");
13999 M (IKEV2_SET_IKE_TRANSFORMS, mp);
14001 clib_memcpy (mp->name, name, vec_len (name));
14003 mp->crypto_alg = crypto_alg;
14004 mp->crypto_key_size = crypto_key_size;
14005 mp->integ_alg = integ_alg;
14006 mp->dh_group = dh_group;
14015 api_ikev2_set_esp_transforms (vat_main_t * vam)
14017 unformat_input_t *i = vam->input;
14018 vl_api_ikev2_set_esp_transforms_t *mp;
14021 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
14023 const char *valid_chars = "a-zA-Z0-9_";
14025 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14027 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
14028 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
14029 vec_add1 (name, 0);
14032 errmsg ("parse error '%U'", format_unformat_error, i);
14037 if (!vec_len (name))
14039 errmsg ("profile name must be specified");
14043 if (vec_len (name) > 64)
14045 errmsg ("profile name too long");
14049 M (IKEV2_SET_ESP_TRANSFORMS, mp);
14051 clib_memcpy (mp->name, name, vec_len (name));
14053 mp->crypto_alg = crypto_alg;
14054 mp->crypto_key_size = crypto_key_size;
14055 mp->integ_alg = integ_alg;
14056 mp->dh_group = dh_group;
14064 api_ikev2_set_sa_lifetime (vat_main_t * vam)
14066 unformat_input_t *i = vam->input;
14067 vl_api_ikev2_set_sa_lifetime_t *mp;
14070 u64 lifetime, lifetime_maxdata;
14071 u32 lifetime_jitter, handover;
14073 const char *valid_chars = "a-zA-Z0-9_";
14075 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14077 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
14078 &lifetime, &lifetime_jitter, &handover,
14079 &lifetime_maxdata))
14080 vec_add1 (name, 0);
14083 errmsg ("parse error '%U'", format_unformat_error, i);
14088 if (!vec_len (name))
14090 errmsg ("profile name must be specified");
14094 if (vec_len (name) > 64)
14096 errmsg ("profile name too long");
14100 M (IKEV2_SET_SA_LIFETIME, mp);
14102 clib_memcpy (mp->name, name, vec_len (name));
14104 mp->lifetime = lifetime;
14105 mp->lifetime_jitter = lifetime_jitter;
14106 mp->handover = handover;
14107 mp->lifetime_maxdata = lifetime_maxdata;
14115 api_ikev2_initiate_sa_init (vat_main_t * vam)
14117 unformat_input_t *i = vam->input;
14118 vl_api_ikev2_initiate_sa_init_t *mp;
14122 const char *valid_chars = "a-zA-Z0-9_";
14124 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14126 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14127 vec_add1 (name, 0);
14130 errmsg ("parse error '%U'", format_unformat_error, i);
14135 if (!vec_len (name))
14137 errmsg ("profile name must be specified");
14141 if (vec_len (name) > 64)
14143 errmsg ("profile name too long");
14147 M (IKEV2_INITIATE_SA_INIT, mp);
14149 clib_memcpy (mp->name, name, vec_len (name));
14158 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14160 unformat_input_t *i = vam->input;
14161 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14166 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14168 if (unformat (i, "%lx", &ispi))
14172 errmsg ("parse error '%U'", format_unformat_error, i);
14177 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14187 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14189 unformat_input_t *i = vam->input;
14190 vl_api_ikev2_initiate_del_child_sa_t *mp;
14195 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14197 if (unformat (i, "%x", &ispi))
14201 errmsg ("parse error '%U'", format_unformat_error, i);
14206 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14216 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14218 unformat_input_t *i = vam->input;
14219 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14226 if (unformat (i, "%x", &ispi))
14230 errmsg ("parse error '%U'", format_unformat_error, i);
14235 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14248 api_map_add_domain (vat_main_t * vam)
14250 unformat_input_t *i = vam->input;
14251 vl_api_map_add_domain_t *mp;
14253 ip4_address_t ip4_prefix;
14254 ip6_address_t ip6_prefix;
14255 ip6_address_t ip6_src;
14256 u32 num_m_args = 0;
14257 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14258 0, psid_length = 0;
14259 u8 is_translation = 0;
14261 u32 ip6_src_len = 128;
14264 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14266 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14267 &ip4_prefix, &ip4_prefix_len))
14269 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14270 &ip6_prefix, &ip6_prefix_len))
14274 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14277 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14279 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14281 else if (unformat (i, "psid-offset %d", &psid_offset))
14283 else if (unformat (i, "psid-len %d", &psid_length))
14285 else if (unformat (i, "mtu %d", &mtu))
14287 else if (unformat (i, "map-t"))
14288 is_translation = 1;
14291 clib_warning ("parse error '%U'", format_unformat_error, i);
14296 if (num_m_args < 3)
14298 errmsg ("mandatory argument(s) missing");
14302 /* Construct the API message */
14303 M (MAP_ADD_DOMAIN, mp);
14305 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14306 mp->ip4_prefix_len = ip4_prefix_len;
14308 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14309 mp->ip6_prefix_len = ip6_prefix_len;
14311 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14312 mp->ip6_src_prefix_len = ip6_src_len;
14314 mp->ea_bits_len = ea_bits_len;
14315 mp->psid_offset = psid_offset;
14316 mp->psid_length = psid_length;
14317 mp->is_translation = is_translation;
14318 mp->mtu = htons (mtu);
14323 /* Wait for a reply, return good/bad news */
14329 api_map_del_domain (vat_main_t * vam)
14331 unformat_input_t *i = vam->input;
14332 vl_api_map_del_domain_t *mp;
14334 u32 num_m_args = 0;
14338 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14340 if (unformat (i, "index %d", &index))
14344 clib_warning ("parse error '%U'", format_unformat_error, i);
14349 if (num_m_args != 1)
14351 errmsg ("mandatory argument(s) missing");
14355 /* Construct the API message */
14356 M (MAP_DEL_DOMAIN, mp);
14358 mp->index = ntohl (index);
14363 /* Wait for a reply, return good/bad news */
14369 api_map_add_del_rule (vat_main_t * vam)
14371 unformat_input_t *i = vam->input;
14372 vl_api_map_add_del_rule_t *mp;
14374 ip6_address_t ip6_dst;
14375 u32 num_m_args = 0, index, psid = 0;
14378 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14380 if (unformat (i, "index %d", &index))
14382 else if (unformat (i, "psid %d", &psid))
14384 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
14386 else if (unformat (i, "del"))
14392 clib_warning ("parse error '%U'", format_unformat_error, i);
14397 /* Construct the API message */
14398 M (MAP_ADD_DEL_RULE, mp);
14400 mp->index = ntohl (index);
14401 mp->is_add = is_add;
14402 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14403 mp->psid = ntohs (psid);
14408 /* Wait for a reply, return good/bad news */
14414 api_map_domain_dump (vat_main_t * vam)
14416 vl_api_map_domain_dump_t *mp;
14417 vl_api_control_ping_t *mp_ping;
14420 /* Construct the API message */
14421 M (MAP_DOMAIN_DUMP, mp);
14426 /* Use a control ping for synchronization */
14427 M (CONTROL_PING, mp_ping);
14435 api_map_rule_dump (vat_main_t * vam)
14437 unformat_input_t *i = vam->input;
14438 vl_api_map_rule_dump_t *mp;
14439 vl_api_control_ping_t *mp_ping;
14440 u32 domain_index = ~0;
14443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14445 if (unformat (i, "index %u", &domain_index))
14451 if (domain_index == ~0)
14453 clib_warning ("parse error: domain index expected");
14457 /* Construct the API message */
14458 M (MAP_RULE_DUMP, mp);
14460 mp->domain_index = htonl (domain_index);
14465 /* Use a control ping for synchronization */
14466 M (CONTROL_PING, mp_ping);
14473 static void vl_api_map_add_domain_reply_t_handler
14474 (vl_api_map_add_domain_reply_t * mp)
14476 vat_main_t *vam = &vat_main;
14477 i32 retval = ntohl (mp->retval);
14479 if (vam->async_mode)
14481 vam->async_errors += (retval < 0);
14485 vam->retval = retval;
14486 vam->result_ready = 1;
14490 static void vl_api_map_add_domain_reply_t_handler_json
14491 (vl_api_map_add_domain_reply_t * mp)
14493 vat_main_t *vam = &vat_main;
14494 vat_json_node_t node;
14496 vat_json_init_object (&node);
14497 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14498 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14500 vat_json_print (vam->ofp, &node);
14501 vat_json_free (&node);
14503 vam->retval = ntohl (mp->retval);
14504 vam->result_ready = 1;
14508 api_get_first_msg_id (vat_main_t * vam)
14510 vl_api_get_first_msg_id_t *mp;
14511 unformat_input_t *i = vam->input;
14516 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14518 if (unformat (i, "client %s", &name))
14526 errmsg ("missing client name");
14529 vec_add1 (name, 0);
14531 if (vec_len (name) > 63)
14533 errmsg ("client name too long");
14537 M (GET_FIRST_MSG_ID, mp);
14538 clib_memcpy (mp->name, name, vec_len (name));
14545 api_cop_interface_enable_disable (vat_main_t * vam)
14547 unformat_input_t *line_input = vam->input;
14548 vl_api_cop_interface_enable_disable_t *mp;
14549 u32 sw_if_index = ~0;
14550 u8 enable_disable = 1;
14553 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14555 if (unformat (line_input, "disable"))
14556 enable_disable = 0;
14557 if (unformat (line_input, "enable"))
14558 enable_disable = 1;
14559 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14560 vam, &sw_if_index))
14562 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14568 if (sw_if_index == ~0)
14570 errmsg ("missing interface name or sw_if_index");
14574 /* Construct the API message */
14575 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14576 mp->sw_if_index = ntohl (sw_if_index);
14577 mp->enable_disable = enable_disable;
14581 /* Wait for the reply */
14587 api_cop_whitelist_enable_disable (vat_main_t * vam)
14589 unformat_input_t *line_input = vam->input;
14590 vl_api_cop_whitelist_enable_disable_t *mp;
14591 u32 sw_if_index = ~0;
14592 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14596 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14598 if (unformat (line_input, "ip4"))
14600 else if (unformat (line_input, "ip6"))
14602 else if (unformat (line_input, "default"))
14604 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14605 vam, &sw_if_index))
14607 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14609 else if (unformat (line_input, "fib-id %d", &fib_id))
14615 if (sw_if_index == ~0)
14617 errmsg ("missing interface name or sw_if_index");
14621 /* Construct the API message */
14622 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14623 mp->sw_if_index = ntohl (sw_if_index);
14624 mp->fib_id = ntohl (fib_id);
14627 mp->default_cop = default_cop;
14631 /* Wait for the reply */
14637 api_get_node_graph (vat_main_t * vam)
14639 vl_api_get_node_graph_t *mp;
14642 M (GET_NODE_GRAPH, mp);
14646 /* Wait for the reply */
14652 /** Used for parsing LISP eids */
14653 typedef CLIB_PACKED(struct{
14654 u8 addr[16]; /**< eid address */
14655 u32 len; /**< prefix length if IP */
14656 u8 type; /**< type of eid */
14661 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14663 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14665 memset (a, 0, sizeof (a[0]));
14667 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14669 a->type = 0; /* ipv4 type */
14671 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14673 a->type = 1; /* ipv6 type */
14675 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14677 a->type = 2; /* mac type */
14679 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14681 a->type = 3; /* NSH type */
14682 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14683 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14690 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14699 lisp_eid_size_vat (u8 type)
14716 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14718 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14722 api_one_add_del_locator_set (vat_main_t * vam)
14724 unformat_input_t *input = vam->input;
14725 vl_api_one_add_del_locator_set_t *mp;
14727 u8 *locator_set_name = NULL;
14728 u8 locator_set_name_set = 0;
14729 vl_api_local_locator_t locator, *locators = 0;
14730 u32 sw_if_index, priority, weight;
14734 /* Parse args required to build the message */
14735 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14737 if (unformat (input, "del"))
14741 else if (unformat (input, "locator-set %s", &locator_set_name))
14743 locator_set_name_set = 1;
14745 else if (unformat (input, "sw_if_index %u p %u w %u",
14746 &sw_if_index, &priority, &weight))
14748 locator.sw_if_index = htonl (sw_if_index);
14749 locator.priority = priority;
14750 locator.weight = weight;
14751 vec_add1 (locators, locator);
14755 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14756 &sw_if_index, &priority, &weight))
14758 locator.sw_if_index = htonl (sw_if_index);
14759 locator.priority = priority;
14760 locator.weight = weight;
14761 vec_add1 (locators, locator);
14767 if (locator_set_name_set == 0)
14769 errmsg ("missing locator-set name");
14770 vec_free (locators);
14774 if (vec_len (locator_set_name) > 64)
14776 errmsg ("locator-set name too long");
14777 vec_free (locator_set_name);
14778 vec_free (locators);
14781 vec_add1 (locator_set_name, 0);
14783 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14785 /* Construct the API message */
14786 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14788 mp->is_add = is_add;
14789 clib_memcpy (mp->locator_set_name, locator_set_name,
14790 vec_len (locator_set_name));
14791 vec_free (locator_set_name);
14793 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14795 clib_memcpy (mp->locators, locators, data_len);
14796 vec_free (locators);
14801 /* Wait for a reply... */
14806 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14809 api_one_add_del_locator (vat_main_t * vam)
14811 unformat_input_t *input = vam->input;
14812 vl_api_one_add_del_locator_t *mp;
14813 u32 tmp_if_index = ~0;
14814 u32 sw_if_index = ~0;
14815 u8 sw_if_index_set = 0;
14816 u8 sw_if_index_if_name_set = 0;
14818 u8 priority_set = 0;
14822 u8 *locator_set_name = NULL;
14823 u8 locator_set_name_set = 0;
14826 /* Parse args required to build the message */
14827 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14829 if (unformat (input, "del"))
14833 else if (unformat (input, "locator-set %s", &locator_set_name))
14835 locator_set_name_set = 1;
14837 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14840 sw_if_index_if_name_set = 1;
14841 sw_if_index = tmp_if_index;
14843 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14845 sw_if_index_set = 1;
14846 sw_if_index = tmp_if_index;
14848 else if (unformat (input, "p %d", &priority))
14852 else if (unformat (input, "w %d", &weight))
14860 if (locator_set_name_set == 0)
14862 errmsg ("missing locator-set name");
14866 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14868 errmsg ("missing sw_if_index");
14869 vec_free (locator_set_name);
14873 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14875 errmsg ("cannot use both params interface name and sw_if_index");
14876 vec_free (locator_set_name);
14880 if (priority_set == 0)
14882 errmsg ("missing locator-set priority");
14883 vec_free (locator_set_name);
14887 if (weight_set == 0)
14889 errmsg ("missing locator-set weight");
14890 vec_free (locator_set_name);
14894 if (vec_len (locator_set_name) > 64)
14896 errmsg ("locator-set name too long");
14897 vec_free (locator_set_name);
14900 vec_add1 (locator_set_name, 0);
14902 /* Construct the API message */
14903 M (ONE_ADD_DEL_LOCATOR, mp);
14905 mp->is_add = is_add;
14906 mp->sw_if_index = ntohl (sw_if_index);
14907 mp->priority = priority;
14908 mp->weight = weight;
14909 clib_memcpy (mp->locator_set_name, locator_set_name,
14910 vec_len (locator_set_name));
14911 vec_free (locator_set_name);
14916 /* Wait for a reply... */
14921 #define api_lisp_add_del_locator api_one_add_del_locator
14924 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14926 u32 *key_id = va_arg (*args, u32 *);
14929 if (unformat (input, "%s", &s))
14931 if (!strcmp ((char *) s, "sha1"))
14932 key_id[0] = HMAC_SHA_1_96;
14933 else if (!strcmp ((char *) s, "sha256"))
14934 key_id[0] = HMAC_SHA_256_128;
14937 clib_warning ("invalid key_id: '%s'", s);
14938 key_id[0] = HMAC_NO_KEY;
14949 api_one_add_del_local_eid (vat_main_t * vam)
14951 unformat_input_t *input = vam->input;
14952 vl_api_one_add_del_local_eid_t *mp;
14955 lisp_eid_vat_t _eid, *eid = &_eid;
14956 u8 *locator_set_name = 0;
14957 u8 locator_set_name_set = 0;
14963 /* Parse args required to build the message */
14964 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14966 if (unformat (input, "del"))
14970 else if (unformat (input, "vni %d", &vni))
14974 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14978 else if (unformat (input, "locator-set %s", &locator_set_name))
14980 locator_set_name_set = 1;
14982 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14984 else if (unformat (input, "secret-key %_%v%_", &key))
14990 if (locator_set_name_set == 0)
14992 errmsg ("missing locator-set name");
14998 errmsg ("EID address not set!");
14999 vec_free (locator_set_name);
15003 if (key && (0 == key_id))
15005 errmsg ("invalid key_id!");
15009 if (vec_len (key) > 64)
15011 errmsg ("key too long");
15016 if (vec_len (locator_set_name) > 64)
15018 errmsg ("locator-set name too long");
15019 vec_free (locator_set_name);
15022 vec_add1 (locator_set_name, 0);
15024 /* Construct the API message */
15025 M (ONE_ADD_DEL_LOCAL_EID, mp);
15027 mp->is_add = is_add;
15028 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
15029 mp->eid_type = eid->type;
15030 mp->prefix_len = eid->len;
15031 mp->vni = clib_host_to_net_u32 (vni);
15032 mp->key_id = clib_host_to_net_u16 (key_id);
15033 clib_memcpy (mp->locator_set_name, locator_set_name,
15034 vec_len (locator_set_name));
15035 clib_memcpy (mp->key, key, vec_len (key));
15037 vec_free (locator_set_name);
15043 /* Wait for a reply... */
15048 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
15051 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
15053 u32 dp_table = 0, vni = 0;;
15054 unformat_input_t *input = vam->input;
15055 vl_api_gpe_add_del_fwd_entry_t *mp;
15057 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
15058 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
15059 u8 rmt_eid_set = 0, lcl_eid_set = 0;
15060 u32 action = ~0, w;
15061 ip4_address_t rmt_rloc4, lcl_rloc4;
15062 ip6_address_t rmt_rloc6, lcl_rloc6;
15063 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
15066 memset (&rloc, 0, sizeof (rloc));
15068 /* Parse args required to build the message */
15069 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15071 if (unformat (input, "del"))
15073 else if (unformat (input, "add"))
15075 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
15079 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
15083 else if (unformat (input, "vrf %d", &dp_table))
15085 else if (unformat (input, "bd %d", &dp_table))
15087 else if (unformat (input, "vni %d", &vni))
15089 else if (unformat (input, "w %d", &w))
15093 errmsg ("No RLOC configured for setting priority/weight!");
15096 curr_rloc->weight = w;
15098 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
15099 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
15103 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
15105 vec_add1 (lcl_locs, rloc);
15107 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
15108 vec_add1 (rmt_locs, rloc);
15109 /* weight saved in rmt loc */
15110 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15112 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
15113 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
15116 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
15118 vec_add1 (lcl_locs, rloc);
15120 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
15121 vec_add1 (rmt_locs, rloc);
15122 /* weight saved in rmt loc */
15123 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15125 else if (unformat (input, "action %d", &action))
15131 clib_warning ("parse error '%U'", format_unformat_error, input);
15138 errmsg ("remote eid addresses not set");
15142 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15144 errmsg ("eid types don't match");
15148 if (0 == rmt_locs && (u32) ~ 0 == action)
15150 errmsg ("action not set for negative mapping");
15154 /* Construct the API message */
15155 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15156 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15158 mp->is_add = is_add;
15159 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15160 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15161 mp->eid_type = rmt_eid->type;
15162 mp->dp_table = clib_host_to_net_u32 (dp_table);
15163 mp->vni = clib_host_to_net_u32 (vni);
15164 mp->rmt_len = rmt_eid->len;
15165 mp->lcl_len = lcl_eid->len;
15166 mp->action = action;
15168 if (0 != rmt_locs && 0 != lcl_locs)
15170 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15171 clib_memcpy (mp->locs, lcl_locs,
15172 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15174 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15175 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15176 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15178 vec_free (lcl_locs);
15179 vec_free (rmt_locs);
15184 /* Wait for a reply... */
15190 api_one_add_del_map_server (vat_main_t * vam)
15192 unformat_input_t *input = vam->input;
15193 vl_api_one_add_del_map_server_t *mp;
15197 ip4_address_t ipv4;
15198 ip6_address_t ipv6;
15201 /* Parse args required to build the message */
15202 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15204 if (unformat (input, "del"))
15208 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15212 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15220 if (ipv4_set && ipv6_set)
15222 errmsg ("both eid v4 and v6 addresses set");
15226 if (!ipv4_set && !ipv6_set)
15228 errmsg ("eid addresses not set");
15232 /* Construct the API message */
15233 M (ONE_ADD_DEL_MAP_SERVER, mp);
15235 mp->is_add = is_add;
15239 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15244 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15250 /* Wait for a reply... */
15255 #define api_lisp_add_del_map_server api_one_add_del_map_server
15258 api_one_add_del_map_resolver (vat_main_t * vam)
15260 unformat_input_t *input = vam->input;
15261 vl_api_one_add_del_map_resolver_t *mp;
15265 ip4_address_t ipv4;
15266 ip6_address_t ipv6;
15269 /* Parse args required to build the message */
15270 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15272 if (unformat (input, "del"))
15276 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15280 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15288 if (ipv4_set && ipv6_set)
15290 errmsg ("both eid v4 and v6 addresses set");
15294 if (!ipv4_set && !ipv6_set)
15296 errmsg ("eid addresses not set");
15300 /* Construct the API message */
15301 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15303 mp->is_add = is_add;
15307 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15312 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15318 /* Wait for a reply... */
15323 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15326 api_lisp_gpe_enable_disable (vat_main_t * vam)
15328 unformat_input_t *input = vam->input;
15329 vl_api_gpe_enable_disable_t *mp;
15334 /* Parse args required to build the message */
15335 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15337 if (unformat (input, "enable"))
15342 else if (unformat (input, "disable"))
15353 errmsg ("Value not set");
15357 /* Construct the API message */
15358 M (GPE_ENABLE_DISABLE, mp);
15365 /* Wait for a reply... */
15371 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15373 unformat_input_t *input = vam->input;
15374 vl_api_one_rloc_probe_enable_disable_t *mp;
15379 /* Parse args required to build the message */
15380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15382 if (unformat (input, "enable"))
15387 else if (unformat (input, "disable"))
15395 errmsg ("Value not set");
15399 /* Construct the API message */
15400 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15402 mp->is_enabled = is_en;
15407 /* Wait for a reply... */
15412 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15415 api_one_map_register_enable_disable (vat_main_t * vam)
15417 unformat_input_t *input = vam->input;
15418 vl_api_one_map_register_enable_disable_t *mp;
15423 /* Parse args required to build the message */
15424 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15426 if (unformat (input, "enable"))
15431 else if (unformat (input, "disable"))
15439 errmsg ("Value not set");
15443 /* Construct the API message */
15444 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15446 mp->is_enabled = is_en;
15451 /* Wait for a reply... */
15456 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15459 api_one_enable_disable (vat_main_t * vam)
15461 unformat_input_t *input = vam->input;
15462 vl_api_one_enable_disable_t *mp;
15467 /* Parse args required to build the message */
15468 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15470 if (unformat (input, "enable"))
15475 else if (unformat (input, "disable"))
15485 errmsg ("Value not set");
15489 /* Construct the API message */
15490 M (ONE_ENABLE_DISABLE, mp);
15497 /* Wait for a reply... */
15502 #define api_lisp_enable_disable api_one_enable_disable
15505 api_show_one_map_register_state (vat_main_t * vam)
15507 vl_api_show_one_map_register_state_t *mp;
15510 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15515 /* wait for reply */
15520 #define api_show_lisp_map_register_state api_show_one_map_register_state
15523 api_show_one_rloc_probe_state (vat_main_t * vam)
15525 vl_api_show_one_rloc_probe_state_t *mp;
15528 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15533 /* wait for reply */
15538 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15541 api_one_add_del_ndp_entry (vat_main_t * vam)
15543 vl_api_one_add_del_ndp_entry_t *mp;
15544 unformat_input_t *input = vam->input;
15549 u8 mac[6] = { 0, };
15550 u8 ip6[16] = { 0, };
15554 /* Parse args required to build the message */
15555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15557 if (unformat (input, "del"))
15559 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15561 else if (unformat (input, "ip %U", unformat_ip6_address, ip6))
15563 else if (unformat (input, "bd %d", &bd))
15567 errmsg ("parse error '%U'", format_unformat_error, input);
15572 if (!bd_set || !ip_set || (!mac_set && is_add))
15574 errmsg ("Missing BD, IP or MAC!");
15578 M (ONE_ADD_DEL_NDP_ENTRY, mp);
15579 mp->is_add = is_add;
15580 clib_memcpy (mp->mac, mac, 6);
15581 mp->bd = clib_host_to_net_u32 (bd);
15582 clib_memcpy (mp->ip6, ip6, sizeof (mp->ip6));
15587 /* wait for reply */
15593 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15595 vl_api_one_add_del_l2_arp_entry_t *mp;
15596 unformat_input_t *input = vam->input;
15601 u8 mac[6] = { 0, };
15602 u32 ip4 = 0, bd = ~0;
15605 /* Parse args required to build the message */
15606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15608 if (unformat (input, "del"))
15610 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15612 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15614 else if (unformat (input, "bd %d", &bd))
15618 errmsg ("parse error '%U'", format_unformat_error, input);
15623 if (!bd_set || !ip_set || (!mac_set && is_add))
15625 errmsg ("Missing BD, IP or MAC!");
15629 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15630 mp->is_add = is_add;
15631 clib_memcpy (mp->mac, mac, 6);
15632 mp->bd = clib_host_to_net_u32 (bd);
15638 /* wait for reply */
15644 api_one_ndp_bd_get (vat_main_t * vam)
15646 vl_api_one_ndp_bd_get_t *mp;
15649 M (ONE_NDP_BD_GET, mp);
15654 /* wait for reply */
15660 api_one_ndp_entries_get (vat_main_t * vam)
15662 vl_api_one_ndp_entries_get_t *mp;
15663 unformat_input_t *input = vam->input;
15668 /* Parse args required to build the message */
15669 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15671 if (unformat (input, "bd %d", &bd))
15675 errmsg ("parse error '%U'", format_unformat_error, input);
15682 errmsg ("Expected bridge domain!");
15686 M (ONE_NDP_ENTRIES_GET, mp);
15687 mp->bd = clib_host_to_net_u32 (bd);
15692 /* wait for reply */
15698 api_one_l2_arp_bd_get (vat_main_t * vam)
15700 vl_api_one_l2_arp_bd_get_t *mp;
15703 M (ONE_L2_ARP_BD_GET, mp);
15708 /* wait for reply */
15714 api_one_l2_arp_entries_get (vat_main_t * vam)
15716 vl_api_one_l2_arp_entries_get_t *mp;
15717 unformat_input_t *input = vam->input;
15722 /* Parse args required to build the message */
15723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15725 if (unformat (input, "bd %d", &bd))
15729 errmsg ("parse error '%U'", format_unformat_error, input);
15736 errmsg ("Expected bridge domain!");
15740 M (ONE_L2_ARP_ENTRIES_GET, mp);
15741 mp->bd = clib_host_to_net_u32 (bd);
15746 /* wait for reply */
15752 api_one_stats_enable_disable (vat_main_t * vam)
15754 vl_api_one_stats_enable_disable_t *mp;
15755 unformat_input_t *input = vam->input;
15760 /* Parse args required to build the message */
15761 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15763 if (unformat (input, "enable"))
15768 else if (unformat (input, "disable"))
15778 errmsg ("Value not set");
15782 M (ONE_STATS_ENABLE_DISABLE, mp);
15788 /* wait for reply */
15794 api_show_one_stats_enable_disable (vat_main_t * vam)
15796 vl_api_show_one_stats_enable_disable_t *mp;
15799 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15804 /* wait for reply */
15810 api_show_one_map_request_mode (vat_main_t * vam)
15812 vl_api_show_one_map_request_mode_t *mp;
15815 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15820 /* wait for reply */
15825 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15828 api_one_map_request_mode (vat_main_t * vam)
15830 unformat_input_t *input = vam->input;
15831 vl_api_one_map_request_mode_t *mp;
15835 /* Parse args required to build the message */
15836 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15838 if (unformat (input, "dst-only"))
15840 else if (unformat (input, "src-dst"))
15844 errmsg ("parse error '%U'", format_unformat_error, input);
15849 M (ONE_MAP_REQUEST_MODE, mp);
15856 /* wait for reply */
15861 #define api_lisp_map_request_mode api_one_map_request_mode
15864 * Enable/disable ONE proxy ITR.
15866 * @param vam vpp API test context
15867 * @return return code
15870 api_one_pitr_set_locator_set (vat_main_t * vam)
15872 u8 ls_name_set = 0;
15873 unformat_input_t *input = vam->input;
15874 vl_api_one_pitr_set_locator_set_t *mp;
15879 /* Parse args required to build the message */
15880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15882 if (unformat (input, "del"))
15884 else if (unformat (input, "locator-set %s", &ls_name))
15888 errmsg ("parse error '%U'", format_unformat_error, input);
15895 errmsg ("locator-set name not set!");
15899 M (ONE_PITR_SET_LOCATOR_SET, mp);
15901 mp->is_add = is_add;
15902 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15903 vec_free (ls_name);
15908 /* wait for reply */
15913 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15916 api_one_nsh_set_locator_set (vat_main_t * vam)
15918 u8 ls_name_set = 0;
15919 unformat_input_t *input = vam->input;
15920 vl_api_one_nsh_set_locator_set_t *mp;
15925 /* Parse args required to build the message */
15926 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15928 if (unformat (input, "del"))
15930 else if (unformat (input, "ls %s", &ls_name))
15934 errmsg ("parse error '%U'", format_unformat_error, input);
15939 if (!ls_name_set && is_add)
15941 errmsg ("locator-set name not set!");
15945 M (ONE_NSH_SET_LOCATOR_SET, mp);
15947 mp->is_add = is_add;
15948 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15949 vec_free (ls_name);
15954 /* wait for reply */
15960 api_show_one_pitr (vat_main_t * vam)
15962 vl_api_show_one_pitr_t *mp;
15965 if (!vam->json_output)
15967 print (vam->ofp, "%=20s", "lisp status:");
15970 M (SHOW_ONE_PITR, mp);
15974 /* Wait for a reply... */
15979 #define api_show_lisp_pitr api_show_one_pitr
15982 api_one_use_petr (vat_main_t * vam)
15984 unformat_input_t *input = vam->input;
15985 vl_api_one_use_petr_t *mp;
15990 memset (&ip, 0, sizeof (ip));
15992 /* Parse args required to build the message */
15993 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15995 if (unformat (input, "disable"))
15998 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
16001 ip_addr_version (&ip) = IP4;
16004 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
16007 ip_addr_version (&ip) = IP6;
16011 errmsg ("parse error '%U'", format_unformat_error, input);
16016 M (ONE_USE_PETR, mp);
16018 mp->is_add = is_add;
16021 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
16023 clib_memcpy (mp->address, &ip, 4);
16025 clib_memcpy (mp->address, &ip, 16);
16031 /* wait for reply */
16036 #define api_lisp_use_petr api_one_use_petr
16039 api_show_one_nsh_mapping (vat_main_t * vam)
16041 vl_api_show_one_use_petr_t *mp;
16044 if (!vam->json_output)
16046 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
16049 M (SHOW_ONE_NSH_MAPPING, mp);
16053 /* Wait for a reply... */
16059 api_show_one_use_petr (vat_main_t * vam)
16061 vl_api_show_one_use_petr_t *mp;
16064 if (!vam->json_output)
16066 print (vam->ofp, "%=20s", "Proxy-ETR status:");
16069 M (SHOW_ONE_USE_PETR, mp);
16073 /* Wait for a reply... */
16078 #define api_show_lisp_use_petr api_show_one_use_petr
16081 * Add/delete mapping between vni and vrf
16084 api_one_eid_table_add_del_map (vat_main_t * vam)
16086 unformat_input_t *input = vam->input;
16087 vl_api_one_eid_table_add_del_map_t *mp;
16088 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
16089 u32 vni, vrf, bd_index;
16092 /* Parse args required to build the message */
16093 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16095 if (unformat (input, "del"))
16097 else if (unformat (input, "vrf %d", &vrf))
16099 else if (unformat (input, "bd_index %d", &bd_index))
16101 else if (unformat (input, "vni %d", &vni))
16107 if (!vni_set || (!vrf_set && !bd_index_set))
16109 errmsg ("missing arguments!");
16113 if (vrf_set && bd_index_set)
16115 errmsg ("error: both vrf and bd entered!");
16119 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
16121 mp->is_add = is_add;
16122 mp->vni = htonl (vni);
16123 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
16124 mp->is_l2 = bd_index_set;
16129 /* wait for reply */
16134 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
16137 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
16139 u32 *action = va_arg (*args, u32 *);
16142 if (unformat (input, "%s", &s))
16144 if (!strcmp ((char *) s, "no-action"))
16146 else if (!strcmp ((char *) s, "natively-forward"))
16148 else if (!strcmp ((char *) s, "send-map-request"))
16150 else if (!strcmp ((char *) s, "drop"))
16154 clib_warning ("invalid action: '%s'", s);
16166 * Add/del remote mapping to/from ONE control plane
16168 * @param vam vpp API test context
16169 * @return return code
16172 api_one_add_del_remote_mapping (vat_main_t * vam)
16174 unformat_input_t *input = vam->input;
16175 vl_api_one_add_del_remote_mapping_t *mp;
16177 lisp_eid_vat_t _eid, *eid = &_eid;
16178 lisp_eid_vat_t _seid, *seid = &_seid;
16179 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
16180 u32 action = ~0, p, w, data_len;
16181 ip4_address_t rloc4;
16182 ip6_address_t rloc6;
16183 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
16186 memset (&rloc, 0, sizeof (rloc));
16188 /* Parse args required to build the message */
16189 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16191 if (unformat (input, "del-all"))
16195 else if (unformat (input, "del"))
16199 else if (unformat (input, "add"))
16203 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
16207 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
16211 else if (unformat (input, "vni %d", &vni))
16215 else if (unformat (input, "p %d w %d", &p, &w))
16219 errmsg ("No RLOC configured for setting priority/weight!");
16222 curr_rloc->priority = p;
16223 curr_rloc->weight = w;
16225 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
16228 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
16229 vec_add1 (rlocs, rloc);
16230 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16232 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16235 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16236 vec_add1 (rlocs, rloc);
16237 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16239 else if (unformat (input, "action %U",
16240 unformat_negative_mapping_action, &action))
16246 clib_warning ("parse error '%U'", format_unformat_error, input);
16253 errmsg ("missing params!");
16257 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16259 errmsg ("no action set for negative map-reply!");
16263 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16265 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16266 mp->is_add = is_add;
16267 mp->vni = htonl (vni);
16268 mp->action = (u8) action;
16269 mp->is_src_dst = seid_set;
16270 mp->eid_len = eid->len;
16271 mp->seid_len = seid->len;
16272 mp->del_all = del_all;
16273 mp->eid_type = eid->type;
16274 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16275 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16277 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16278 clib_memcpy (mp->rlocs, rlocs, data_len);
16284 /* Wait for a reply... */
16289 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16292 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16293 * forwarding entries in data-plane accordingly.
16295 * @param vam vpp API test context
16296 * @return return code
16299 api_one_add_del_adjacency (vat_main_t * vam)
16301 unformat_input_t *input = vam->input;
16302 vl_api_one_add_del_adjacency_t *mp;
16304 ip4_address_t leid4, reid4;
16305 ip6_address_t leid6, reid6;
16306 u8 reid_mac[6] = { 0 };
16307 u8 leid_mac[6] = { 0 };
16308 u8 reid_type, leid_type;
16309 u32 leid_len = 0, reid_len = 0, len;
16313 leid_type = reid_type = (u8) ~ 0;
16315 /* Parse args required to build the message */
16316 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16318 if (unformat (input, "del"))
16322 else if (unformat (input, "add"))
16326 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16329 reid_type = 0; /* ipv4 */
16332 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16335 reid_type = 1; /* ipv6 */
16338 else if (unformat (input, "reid %U", unformat_ethernet_address,
16341 reid_type = 2; /* mac */
16343 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16346 leid_type = 0; /* ipv4 */
16349 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16352 leid_type = 1; /* ipv6 */
16355 else if (unformat (input, "leid %U", unformat_ethernet_address,
16358 leid_type = 2; /* mac */
16360 else if (unformat (input, "vni %d", &vni))
16366 errmsg ("parse error '%U'", format_unformat_error, input);
16371 if ((u8) ~ 0 == reid_type)
16373 errmsg ("missing params!");
16377 if (leid_type != reid_type)
16379 errmsg ("remote and local EIDs are of different types!");
16383 M (ONE_ADD_DEL_ADJACENCY, mp);
16384 mp->is_add = is_add;
16385 mp->vni = htonl (vni);
16386 mp->leid_len = leid_len;
16387 mp->reid_len = reid_len;
16388 mp->eid_type = reid_type;
16390 switch (mp->eid_type)
16393 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16394 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16397 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16398 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16401 clib_memcpy (mp->leid, leid_mac, 6);
16402 clib_memcpy (mp->reid, reid_mac, 6);
16405 errmsg ("unknown EID type %d!", mp->eid_type);
16412 /* Wait for a reply... */
16417 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16420 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16422 u32 *mode = va_arg (*args, u32 *);
16424 if (unformat (input, "lisp"))
16426 else if (unformat (input, "vxlan"))
16435 api_gpe_get_encap_mode (vat_main_t * vam)
16437 vl_api_gpe_get_encap_mode_t *mp;
16440 /* Construct the API message */
16441 M (GPE_GET_ENCAP_MODE, mp);
16446 /* Wait for a reply... */
16452 api_gpe_set_encap_mode (vat_main_t * vam)
16454 unformat_input_t *input = vam->input;
16455 vl_api_gpe_set_encap_mode_t *mp;
16459 /* Parse args required to build the message */
16460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16462 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16468 /* Construct the API message */
16469 M (GPE_SET_ENCAP_MODE, mp);
16476 /* Wait for a reply... */
16482 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16484 unformat_input_t *input = vam->input;
16485 vl_api_gpe_add_del_iface_t *mp;
16486 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16487 u32 dp_table = 0, vni = 0;
16490 /* Parse args required to build the message */
16491 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16493 if (unformat (input, "up"))
16498 else if (unformat (input, "down"))
16503 else if (unformat (input, "table_id %d", &dp_table))
16507 else if (unformat (input, "bd_id %d", &dp_table))
16512 else if (unformat (input, "vni %d", &vni))
16520 if (action_set == 0)
16522 errmsg ("Action not set");
16525 if (dp_table_set == 0 || vni_set == 0)
16527 errmsg ("vni and dp_table must be set");
16531 /* Construct the API message */
16532 M (GPE_ADD_DEL_IFACE, mp);
16534 mp->is_add = is_add;
16535 mp->dp_table = clib_host_to_net_u32 (dp_table);
16537 mp->vni = clib_host_to_net_u32 (vni);
16542 /* Wait for a reply... */
16548 api_one_map_register_fallback_threshold (vat_main_t * vam)
16550 unformat_input_t *input = vam->input;
16551 vl_api_one_map_register_fallback_threshold_t *mp;
16556 /* Parse args required to build the message */
16557 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16559 if (unformat (input, "%u", &value))
16563 clib_warning ("parse error '%U'", format_unformat_error, input);
16570 errmsg ("fallback threshold value is missing!");
16574 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16575 mp->value = clib_host_to_net_u32 (value);
16580 /* Wait for a reply... */
16586 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16588 vl_api_show_one_map_register_fallback_threshold_t *mp;
16591 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16596 /* Wait for a reply... */
16602 api_one_map_register_set_ttl (vat_main_t * vam)
16604 unformat_input_t *input = vam->input;
16605 vl_api_one_map_register_set_ttl_t *mp;
16610 /* Parse args required to build the message */
16611 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16613 if (unformat (input, "%u", &ttl))
16617 clib_warning ("parse error '%U'", format_unformat_error, input);
16624 errmsg ("TTL value missing!");
16628 M (ONE_MAP_REGISTER_SET_TTL, mp);
16629 mp->ttl = clib_host_to_net_u32 (ttl);
16634 /* Wait for a reply... */
16640 api_show_one_map_register_ttl (vat_main_t * vam)
16642 vl_api_show_one_map_register_ttl_t *mp;
16645 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16650 /* Wait for a reply... */
16656 * Add/del map request itr rlocs from ONE control plane and updates
16658 * @param vam vpp API test context
16659 * @return return code
16662 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16664 unformat_input_t *input = vam->input;
16665 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16666 u8 *locator_set_name = 0;
16667 u8 locator_set_name_set = 0;
16671 /* Parse args required to build the message */
16672 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16674 if (unformat (input, "del"))
16678 else if (unformat (input, "%_%v%_", &locator_set_name))
16680 locator_set_name_set = 1;
16684 clib_warning ("parse error '%U'", format_unformat_error, input);
16689 if (is_add && !locator_set_name_set)
16691 errmsg ("itr-rloc is not set!");
16695 if (is_add && vec_len (locator_set_name) > 64)
16697 errmsg ("itr-rloc locator-set name too long");
16698 vec_free (locator_set_name);
16702 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16703 mp->is_add = is_add;
16706 clib_memcpy (mp->locator_set_name, locator_set_name,
16707 vec_len (locator_set_name));
16711 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16713 vec_free (locator_set_name);
16718 /* Wait for a reply... */
16723 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16726 api_one_locator_dump (vat_main_t * vam)
16728 unformat_input_t *input = vam->input;
16729 vl_api_one_locator_dump_t *mp;
16730 vl_api_control_ping_t *mp_ping;
16731 u8 is_index_set = 0, is_name_set = 0;
16736 /* Parse args required to build the message */
16737 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16739 if (unformat (input, "ls_name %_%v%_", &ls_name))
16743 else if (unformat (input, "ls_index %d", &ls_index))
16749 errmsg ("parse error '%U'", format_unformat_error, input);
16754 if (!is_index_set && !is_name_set)
16756 errmsg ("error: expected one of index or name!");
16760 if (is_index_set && is_name_set)
16762 errmsg ("error: only one param expected!");
16766 if (vec_len (ls_name) > 62)
16768 errmsg ("error: locator set name too long!");
16772 if (!vam->json_output)
16774 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16777 M (ONE_LOCATOR_DUMP, mp);
16778 mp->is_index_set = is_index_set;
16781 mp->ls_index = clib_host_to_net_u32 (ls_index);
16784 vec_add1 (ls_name, 0);
16785 strncpy ((char *) mp->ls_name, (char *) ls_name,
16786 sizeof (mp->ls_name) - 1);
16792 /* Use a control ping for synchronization */
16793 M (CONTROL_PING, mp_ping);
16796 /* Wait for a reply... */
16801 #define api_lisp_locator_dump api_one_locator_dump
16804 api_one_locator_set_dump (vat_main_t * vam)
16806 vl_api_one_locator_set_dump_t *mp;
16807 vl_api_control_ping_t *mp_ping;
16808 unformat_input_t *input = vam->input;
16812 /* Parse args required to build the message */
16813 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16815 if (unformat (input, "local"))
16819 else if (unformat (input, "remote"))
16825 errmsg ("parse error '%U'", format_unformat_error, input);
16830 if (!vam->json_output)
16832 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16835 M (ONE_LOCATOR_SET_DUMP, mp);
16837 mp->filter = filter;
16842 /* Use a control ping for synchronization */
16843 M (CONTROL_PING, mp_ping);
16846 /* Wait for a reply... */
16851 #define api_lisp_locator_set_dump api_one_locator_set_dump
16854 api_one_eid_table_map_dump (vat_main_t * vam)
16858 unformat_input_t *input = vam->input;
16859 vl_api_one_eid_table_map_dump_t *mp;
16860 vl_api_control_ping_t *mp_ping;
16863 /* Parse args required to build the message */
16864 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16866 if (unformat (input, "l2"))
16871 else if (unformat (input, "l3"))
16878 errmsg ("parse error '%U'", format_unformat_error, input);
16885 errmsg ("expected one of 'l2' or 'l3' parameter!");
16889 if (!vam->json_output)
16891 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16894 M (ONE_EID_TABLE_MAP_DUMP, mp);
16900 /* Use a control ping for synchronization */
16901 M (CONTROL_PING, mp_ping);
16904 /* Wait for a reply... */
16909 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16912 api_one_eid_table_vni_dump (vat_main_t * vam)
16914 vl_api_one_eid_table_vni_dump_t *mp;
16915 vl_api_control_ping_t *mp_ping;
16918 if (!vam->json_output)
16920 print (vam->ofp, "VNI");
16923 M (ONE_EID_TABLE_VNI_DUMP, mp);
16928 /* Use a control ping for synchronization */
16929 M (CONTROL_PING, mp_ping);
16932 /* Wait for a reply... */
16937 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16940 api_one_eid_table_dump (vat_main_t * vam)
16942 unformat_input_t *i = vam->input;
16943 vl_api_one_eid_table_dump_t *mp;
16944 vl_api_control_ping_t *mp_ping;
16945 struct in_addr ip4;
16946 struct in6_addr ip6;
16948 u8 eid_type = ~0, eid_set = 0;
16949 u32 prefix_length = ~0, t, vni = 0;
16952 lisp_nsh_api_t nsh;
16954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16956 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16962 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16968 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16973 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16978 else if (unformat (i, "vni %d", &t))
16982 else if (unformat (i, "local"))
16986 else if (unformat (i, "remote"))
16992 errmsg ("parse error '%U'", format_unformat_error, i);
16997 if (!vam->json_output)
16999 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
17000 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
17003 M (ONE_EID_TABLE_DUMP, mp);
17005 mp->filter = filter;
17009 mp->vni = htonl (vni);
17010 mp->eid_type = eid_type;
17014 mp->prefix_length = prefix_length;
17015 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
17018 mp->prefix_length = prefix_length;
17019 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
17022 clib_memcpy (mp->eid, mac, sizeof (mac));
17025 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
17028 errmsg ("unknown EID type %d!", eid_type);
17036 /* Use a control ping for synchronization */
17037 M (CONTROL_PING, mp_ping);
17040 /* Wait for a reply... */
17045 #define api_lisp_eid_table_dump api_one_eid_table_dump
17048 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
17050 unformat_input_t *i = vam->input;
17051 vl_api_gpe_fwd_entries_get_t *mp;
17056 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17058 if (unformat (i, "vni %d", &vni))
17064 errmsg ("parse error '%U'", format_unformat_error, i);
17071 errmsg ("vni not set!");
17075 if (!vam->json_output)
17077 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
17081 M (GPE_FWD_ENTRIES_GET, mp);
17082 mp->vni = clib_host_to_net_u32 (vni);
17087 /* Wait for a reply... */
17092 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
17093 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
17094 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
17095 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
17096 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
17097 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
17098 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
17099 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
17102 api_one_adjacencies_get (vat_main_t * vam)
17104 unformat_input_t *i = vam->input;
17105 vl_api_one_adjacencies_get_t *mp;
17110 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17112 if (unformat (i, "vni %d", &vni))
17118 errmsg ("parse error '%U'", format_unformat_error, i);
17125 errmsg ("vni not set!");
17129 if (!vam->json_output)
17131 print (vam->ofp, "%s %40s", "leid", "reid");
17134 M (ONE_ADJACENCIES_GET, mp);
17135 mp->vni = clib_host_to_net_u32 (vni);
17140 /* Wait for a reply... */
17145 #define api_lisp_adjacencies_get api_one_adjacencies_get
17148 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
17150 unformat_input_t *i = vam->input;
17151 vl_api_gpe_native_fwd_rpaths_get_t *mp;
17153 u8 ip_family_set = 0, is_ip4 = 1;
17155 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17157 if (unformat (i, "ip4"))
17162 else if (unformat (i, "ip6"))
17169 errmsg ("parse error '%U'", format_unformat_error, i);
17174 if (!ip_family_set)
17176 errmsg ("ip family not set!");
17180 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
17181 mp->is_ip4 = is_ip4;
17186 /* Wait for a reply... */
17192 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
17194 vl_api_gpe_fwd_entry_vnis_get_t *mp;
17197 if (!vam->json_output)
17199 print (vam->ofp, "VNIs");
17202 M (GPE_FWD_ENTRY_VNIS_GET, mp);
17207 /* Wait for a reply... */
17213 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
17215 unformat_input_t *i = vam->input;
17216 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
17218 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
17219 struct in_addr ip4;
17220 struct in6_addr ip6;
17221 u32 table_id = 0, nh_sw_if_index = ~0;
17223 memset (&ip4, 0, sizeof (ip4));
17224 memset (&ip6, 0, sizeof (ip6));
17226 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17228 if (unformat (i, "del"))
17230 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17231 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17236 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17237 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17242 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17246 nh_sw_if_index = ~0;
17248 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17252 nh_sw_if_index = ~0;
17254 else if (unformat (i, "table %d", &table_id))
17258 errmsg ("parse error '%U'", format_unformat_error, i);
17265 errmsg ("nh addr not set!");
17269 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17270 mp->is_add = is_add;
17271 mp->table_id = clib_host_to_net_u32 (table_id);
17272 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17273 mp->is_ip4 = is_ip4;
17275 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17277 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17282 /* Wait for a reply... */
17288 api_one_map_server_dump (vat_main_t * vam)
17290 vl_api_one_map_server_dump_t *mp;
17291 vl_api_control_ping_t *mp_ping;
17294 if (!vam->json_output)
17296 print (vam->ofp, "%=20s", "Map server");
17299 M (ONE_MAP_SERVER_DUMP, mp);
17303 /* Use a control ping for synchronization */
17304 M (CONTROL_PING, mp_ping);
17307 /* Wait for a reply... */
17312 #define api_lisp_map_server_dump api_one_map_server_dump
17315 api_one_map_resolver_dump (vat_main_t * vam)
17317 vl_api_one_map_resolver_dump_t *mp;
17318 vl_api_control_ping_t *mp_ping;
17321 if (!vam->json_output)
17323 print (vam->ofp, "%=20s", "Map resolver");
17326 M (ONE_MAP_RESOLVER_DUMP, mp);
17330 /* Use a control ping for synchronization */
17331 M (CONTROL_PING, mp_ping);
17334 /* Wait for a reply... */
17339 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17342 api_one_stats_flush (vat_main_t * vam)
17344 vl_api_one_stats_flush_t *mp;
17347 M (ONE_STATS_FLUSH, mp);
17354 api_one_stats_dump (vat_main_t * vam)
17356 vl_api_one_stats_dump_t *mp;
17357 vl_api_control_ping_t *mp_ping;
17360 M (ONE_STATS_DUMP, mp);
17364 /* Use a control ping for synchronization */
17365 M (CONTROL_PING, mp_ping);
17368 /* Wait for a reply... */
17374 api_show_one_status (vat_main_t * vam)
17376 vl_api_show_one_status_t *mp;
17379 if (!vam->json_output)
17381 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17384 M (SHOW_ONE_STATUS, mp);
17387 /* Wait for a reply... */
17392 #define api_show_lisp_status api_show_one_status
17395 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17397 vl_api_gpe_fwd_entry_path_dump_t *mp;
17398 vl_api_control_ping_t *mp_ping;
17399 unformat_input_t *i = vam->input;
17400 u32 fwd_entry_index = ~0;
17403 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17405 if (unformat (i, "index %d", &fwd_entry_index))
17411 if (~0 == fwd_entry_index)
17413 errmsg ("no index specified!");
17417 if (!vam->json_output)
17419 print (vam->ofp, "first line");
17422 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17426 /* Use a control ping for synchronization */
17427 M (CONTROL_PING, mp_ping);
17430 /* Wait for a reply... */
17436 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17438 vl_api_one_get_map_request_itr_rlocs_t *mp;
17441 if (!vam->json_output)
17443 print (vam->ofp, "%=20s", "itr-rlocs:");
17446 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17449 /* Wait for a reply... */
17454 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17457 api_af_packet_create (vat_main_t * vam)
17459 unformat_input_t *i = vam->input;
17460 vl_api_af_packet_create_t *mp;
17461 u8 *host_if_name = 0;
17463 u8 random_hw_addr = 1;
17466 memset (hw_addr, 0, sizeof (hw_addr));
17468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17470 if (unformat (i, "name %s", &host_if_name))
17471 vec_add1 (host_if_name, 0);
17472 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17473 random_hw_addr = 0;
17478 if (!vec_len (host_if_name))
17480 errmsg ("host-interface name must be specified");
17484 if (vec_len (host_if_name) > 64)
17486 errmsg ("host-interface name too long");
17490 M (AF_PACKET_CREATE, mp);
17492 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17493 clib_memcpy (mp->hw_addr, hw_addr, 6);
17494 mp->use_random_hw_addr = random_hw_addr;
17495 vec_free (host_if_name);
17503 fprintf (vam->ofp ? vam->ofp : stderr,
17504 " new sw_if_index = %d\n", vam->sw_if_index);
17511 api_af_packet_delete (vat_main_t * vam)
17513 unformat_input_t *i = vam->input;
17514 vl_api_af_packet_delete_t *mp;
17515 u8 *host_if_name = 0;
17518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17520 if (unformat (i, "name %s", &host_if_name))
17521 vec_add1 (host_if_name, 0);
17526 if (!vec_len (host_if_name))
17528 errmsg ("host-interface name must be specified");
17532 if (vec_len (host_if_name) > 64)
17534 errmsg ("host-interface name too long");
17538 M (AF_PACKET_DELETE, mp);
17540 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17541 vec_free (host_if_name);
17549 api_policer_add_del (vat_main_t * vam)
17551 unformat_input_t *i = vam->input;
17552 vl_api_policer_add_del_t *mp;
17562 u8 color_aware = 0;
17563 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17566 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17567 conform_action.dscp = 0;
17568 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17569 exceed_action.dscp = 0;
17570 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17571 violate_action.dscp = 0;
17573 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17575 if (unformat (i, "del"))
17577 else if (unformat (i, "name %s", &name))
17578 vec_add1 (name, 0);
17579 else if (unformat (i, "cir %u", &cir))
17581 else if (unformat (i, "eir %u", &eir))
17583 else if (unformat (i, "cb %u", &cb))
17585 else if (unformat (i, "eb %u", &eb))
17587 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17590 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17593 else if (unformat (i, "type %U", unformat_policer_type, &type))
17595 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17598 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17601 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17604 else if (unformat (i, "color-aware"))
17610 if (!vec_len (name))
17612 errmsg ("policer name must be specified");
17616 if (vec_len (name) > 64)
17618 errmsg ("policer name too long");
17622 M (POLICER_ADD_DEL, mp);
17624 clib_memcpy (mp->name, name, vec_len (name));
17626 mp->is_add = is_add;
17631 mp->rate_type = rate_type;
17632 mp->round_type = round_type;
17634 mp->conform_action_type = conform_action.action_type;
17635 mp->conform_dscp = conform_action.dscp;
17636 mp->exceed_action_type = exceed_action.action_type;
17637 mp->exceed_dscp = exceed_action.dscp;
17638 mp->violate_action_type = violate_action.action_type;
17639 mp->violate_dscp = violate_action.dscp;
17640 mp->color_aware = color_aware;
17648 api_policer_dump (vat_main_t * vam)
17650 unformat_input_t *i = vam->input;
17651 vl_api_policer_dump_t *mp;
17652 vl_api_control_ping_t *mp_ping;
17653 u8 *match_name = 0;
17654 u8 match_name_valid = 0;
17657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17659 if (unformat (i, "name %s", &match_name))
17661 vec_add1 (match_name, 0);
17662 match_name_valid = 1;
17668 M (POLICER_DUMP, mp);
17669 mp->match_name_valid = match_name_valid;
17670 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17671 vec_free (match_name);
17675 /* Use a control ping for synchronization */
17676 M (CONTROL_PING, mp_ping);
17679 /* Wait for a reply... */
17685 api_policer_classify_set_interface (vat_main_t * vam)
17687 unformat_input_t *i = vam->input;
17688 vl_api_policer_classify_set_interface_t *mp;
17690 int sw_if_index_set;
17691 u32 ip4_table_index = ~0;
17692 u32 ip6_table_index = ~0;
17693 u32 l2_table_index = ~0;
17697 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17699 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17700 sw_if_index_set = 1;
17701 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17702 sw_if_index_set = 1;
17703 else if (unformat (i, "del"))
17705 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17707 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17709 else if (unformat (i, "l2-table %d", &l2_table_index))
17713 clib_warning ("parse error '%U'", format_unformat_error, i);
17718 if (sw_if_index_set == 0)
17720 errmsg ("missing interface name or sw_if_index");
17724 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17726 mp->sw_if_index = ntohl (sw_if_index);
17727 mp->ip4_table_index = ntohl (ip4_table_index);
17728 mp->ip6_table_index = ntohl (ip6_table_index);
17729 mp->l2_table_index = ntohl (l2_table_index);
17730 mp->is_add = is_add;
17738 api_policer_classify_dump (vat_main_t * vam)
17740 unformat_input_t *i = vam->input;
17741 vl_api_policer_classify_dump_t *mp;
17742 vl_api_control_ping_t *mp_ping;
17743 u8 type = POLICER_CLASSIFY_N_TABLES;
17746 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17750 errmsg ("classify table type must be specified");
17754 if (!vam->json_output)
17756 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17759 M (POLICER_CLASSIFY_DUMP, mp);
17764 /* Use a control ping for synchronization */
17765 M (CONTROL_PING, mp_ping);
17768 /* Wait for a reply... */
17774 api_netmap_create (vat_main_t * vam)
17776 unformat_input_t *i = vam->input;
17777 vl_api_netmap_create_t *mp;
17780 u8 random_hw_addr = 1;
17785 memset (hw_addr, 0, sizeof (hw_addr));
17787 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17789 if (unformat (i, "name %s", &if_name))
17790 vec_add1 (if_name, 0);
17791 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17792 random_hw_addr = 0;
17793 else if (unformat (i, "pipe"))
17795 else if (unformat (i, "master"))
17797 else if (unformat (i, "slave"))
17803 if (!vec_len (if_name))
17805 errmsg ("interface name must be specified");
17809 if (vec_len (if_name) > 64)
17811 errmsg ("interface name too long");
17815 M (NETMAP_CREATE, mp);
17817 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17818 clib_memcpy (mp->hw_addr, hw_addr, 6);
17819 mp->use_random_hw_addr = random_hw_addr;
17820 mp->is_pipe = is_pipe;
17821 mp->is_master = is_master;
17822 vec_free (if_name);
17830 api_netmap_delete (vat_main_t * vam)
17832 unformat_input_t *i = vam->input;
17833 vl_api_netmap_delete_t *mp;
17837 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17839 if (unformat (i, "name %s", &if_name))
17840 vec_add1 (if_name, 0);
17845 if (!vec_len (if_name))
17847 errmsg ("interface name must be specified");
17851 if (vec_len (if_name) > 64)
17853 errmsg ("interface name too long");
17857 M (NETMAP_DELETE, mp);
17859 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17860 vec_free (if_name);
17868 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17870 if (fp->afi == IP46_TYPE_IP6)
17872 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17873 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17874 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17875 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17876 format_ip6_address, fp->next_hop);
17877 else if (fp->afi == IP46_TYPE_IP4)
17879 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17880 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17881 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17882 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17883 format_ip4_address, fp->next_hop);
17887 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17888 vl_api_fib_path2_t * fp)
17890 struct in_addr ip4;
17891 struct in6_addr ip6;
17893 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17894 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17895 vat_json_object_add_uint (node, "is_local", fp->is_local);
17896 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17897 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17898 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17899 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17900 if (fp->afi == IP46_TYPE_IP4)
17902 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17903 vat_json_object_add_ip4 (node, "next_hop", ip4);
17905 else if (fp->afi == IP46_TYPE_IP6)
17907 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17908 vat_json_object_add_ip6 (node, "next_hop", ip6);
17913 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17915 vat_main_t *vam = &vat_main;
17916 int count = ntohl (mp->mt_count);
17917 vl_api_fib_path2_t *fp;
17920 print (vam->ofp, "[%d]: sw_if_index %d via:",
17921 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17923 for (i = 0; i < count; i++)
17925 vl_api_mpls_fib_path_print (vam, fp);
17929 print (vam->ofp, "");
17932 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17933 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17936 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17938 vat_main_t *vam = &vat_main;
17939 vat_json_node_t *node = NULL;
17940 int count = ntohl (mp->mt_count);
17941 vl_api_fib_path2_t *fp;
17944 if (VAT_JSON_ARRAY != vam->json_tree.type)
17946 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17947 vat_json_init_array (&vam->json_tree);
17949 node = vat_json_array_add (&vam->json_tree);
17951 vat_json_init_object (node);
17952 vat_json_object_add_uint (node, "tunnel_index",
17953 ntohl (mp->mt_tunnel_index));
17954 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17956 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17959 for (i = 0; i < count; i++)
17961 vl_api_mpls_fib_path_json_print (node, fp);
17967 api_mpls_tunnel_dump (vat_main_t * vam)
17969 vl_api_mpls_tunnel_dump_t *mp;
17970 vl_api_control_ping_t *mp_ping;
17974 /* Parse args required to build the message */
17975 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17977 if (!unformat (vam->input, "tunnel_index %d", &index))
17984 print (vam->ofp, " tunnel_index %d", index);
17986 M (MPLS_TUNNEL_DUMP, mp);
17987 mp->tunnel_index = htonl (index);
17990 /* Use a control ping for synchronization */
17991 M (CONTROL_PING, mp_ping);
17998 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17999 #define vl_api_mpls_fib_details_t_print vl_noop_handler
18003 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
18005 vat_main_t *vam = &vat_main;
18006 int count = ntohl (mp->count);
18007 vl_api_fib_path2_t *fp;
18011 "table-id %d, label %u, ess_bit %u",
18012 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
18014 for (i = 0; i < count; i++)
18016 vl_api_mpls_fib_path_print (vam, fp);
18021 static void vl_api_mpls_fib_details_t_handler_json
18022 (vl_api_mpls_fib_details_t * mp)
18024 vat_main_t *vam = &vat_main;
18025 int count = ntohl (mp->count);
18026 vat_json_node_t *node = NULL;
18027 vl_api_fib_path2_t *fp;
18030 if (VAT_JSON_ARRAY != vam->json_tree.type)
18032 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18033 vat_json_init_array (&vam->json_tree);
18035 node = vat_json_array_add (&vam->json_tree);
18037 vat_json_init_object (node);
18038 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18039 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
18040 vat_json_object_add_uint (node, "label", ntohl (mp->label));
18041 vat_json_object_add_uint (node, "path_count", count);
18043 for (i = 0; i < count; i++)
18045 vl_api_mpls_fib_path_json_print (node, fp);
18051 api_mpls_fib_dump (vat_main_t * vam)
18053 vl_api_mpls_fib_dump_t *mp;
18054 vl_api_control_ping_t *mp_ping;
18057 M (MPLS_FIB_DUMP, mp);
18060 /* Use a control ping for synchronization */
18061 M (CONTROL_PING, mp_ping);
18068 #define vl_api_ip_fib_details_t_endian vl_noop_handler
18069 #define vl_api_ip_fib_details_t_print vl_noop_handler
18072 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
18074 vat_main_t *vam = &vat_main;
18075 int count = ntohl (mp->count);
18076 vl_api_fib_path_t *fp;
18080 "table-id %d, prefix %U/%d",
18081 ntohl (mp->table_id), format_ip4_address, mp->address,
18082 mp->address_length);
18084 for (i = 0; i < count; i++)
18086 if (fp->afi == IP46_TYPE_IP6)
18088 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18089 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18090 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18091 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18092 format_ip6_address, fp->next_hop);
18093 else if (fp->afi == IP46_TYPE_IP4)
18095 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18096 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18097 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18098 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18099 format_ip4_address, fp->next_hop);
18104 static void vl_api_ip_fib_details_t_handler_json
18105 (vl_api_ip_fib_details_t * mp)
18107 vat_main_t *vam = &vat_main;
18108 int count = ntohl (mp->count);
18109 vat_json_node_t *node = NULL;
18110 struct in_addr ip4;
18111 struct in6_addr ip6;
18112 vl_api_fib_path_t *fp;
18115 if (VAT_JSON_ARRAY != vam->json_tree.type)
18117 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18118 vat_json_init_array (&vam->json_tree);
18120 node = vat_json_array_add (&vam->json_tree);
18122 vat_json_init_object (node);
18123 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18124 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
18125 vat_json_object_add_ip4 (node, "prefix", ip4);
18126 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18127 vat_json_object_add_uint (node, "path_count", count);
18129 for (i = 0; i < count; i++)
18131 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18132 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18133 vat_json_object_add_uint (node, "is_local", fp->is_local);
18134 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18135 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18136 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18137 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18138 if (fp->afi == IP46_TYPE_IP4)
18140 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18141 vat_json_object_add_ip4 (node, "next_hop", ip4);
18143 else if (fp->afi == IP46_TYPE_IP6)
18145 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18146 vat_json_object_add_ip6 (node, "next_hop", ip6);
18152 api_ip_fib_dump (vat_main_t * vam)
18154 vl_api_ip_fib_dump_t *mp;
18155 vl_api_control_ping_t *mp_ping;
18158 M (IP_FIB_DUMP, mp);
18161 /* Use a control ping for synchronization */
18162 M (CONTROL_PING, mp_ping);
18170 api_ip_mfib_dump (vat_main_t * vam)
18172 vl_api_ip_mfib_dump_t *mp;
18173 vl_api_control_ping_t *mp_ping;
18176 M (IP_MFIB_DUMP, mp);
18179 /* Use a control ping for synchronization */
18180 M (CONTROL_PING, mp_ping);
18187 static void vl_api_ip_neighbor_details_t_handler
18188 (vl_api_ip_neighbor_details_t * mp)
18190 vat_main_t *vam = &vat_main;
18192 print (vam->ofp, "%c %U %U",
18193 (mp->is_static) ? 'S' : 'D',
18194 format_ethernet_address, &mp->mac_address,
18195 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
18199 static void vl_api_ip_neighbor_details_t_handler_json
18200 (vl_api_ip_neighbor_details_t * mp)
18203 vat_main_t *vam = &vat_main;
18204 vat_json_node_t *node;
18205 struct in_addr ip4;
18206 struct in6_addr ip6;
18208 if (VAT_JSON_ARRAY != vam->json_tree.type)
18210 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18211 vat_json_init_array (&vam->json_tree);
18213 node = vat_json_array_add (&vam->json_tree);
18215 vat_json_init_object (node);
18216 vat_json_object_add_string_copy (node, "flag",
18217 (mp->is_static) ? (u8 *) "static" : (u8 *)
18220 vat_json_object_add_string_copy (node, "link_layer",
18221 format (0, "%U", format_ethernet_address,
18222 &mp->mac_address));
18226 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
18227 vat_json_object_add_ip6 (node, "ip_address", ip6);
18231 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18232 vat_json_object_add_ip4 (node, "ip_address", ip4);
18237 api_ip_neighbor_dump (vat_main_t * vam)
18239 unformat_input_t *i = vam->input;
18240 vl_api_ip_neighbor_dump_t *mp;
18241 vl_api_control_ping_t *mp_ping;
18243 u32 sw_if_index = ~0;
18246 /* Parse args required to build the message */
18247 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18249 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18251 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18253 else if (unformat (i, "ip6"))
18259 if (sw_if_index == ~0)
18261 errmsg ("missing interface name or sw_if_index");
18265 M (IP_NEIGHBOR_DUMP, mp);
18266 mp->is_ipv6 = (u8) is_ipv6;
18267 mp->sw_if_index = ntohl (sw_if_index);
18270 /* Use a control ping for synchronization */
18271 M (CONTROL_PING, mp_ping);
18278 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
18279 #define vl_api_ip6_fib_details_t_print vl_noop_handler
18282 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
18284 vat_main_t *vam = &vat_main;
18285 int count = ntohl (mp->count);
18286 vl_api_fib_path_t *fp;
18290 "table-id %d, prefix %U/%d",
18291 ntohl (mp->table_id), format_ip6_address, mp->address,
18292 mp->address_length);
18294 for (i = 0; i < count; i++)
18296 if (fp->afi == IP46_TYPE_IP6)
18298 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18299 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18300 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18301 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18302 format_ip6_address, fp->next_hop);
18303 else if (fp->afi == IP46_TYPE_IP4)
18305 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18306 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18307 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18308 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18309 format_ip4_address, fp->next_hop);
18314 static void vl_api_ip6_fib_details_t_handler_json
18315 (vl_api_ip6_fib_details_t * mp)
18317 vat_main_t *vam = &vat_main;
18318 int count = ntohl (mp->count);
18319 vat_json_node_t *node = NULL;
18320 struct in_addr ip4;
18321 struct in6_addr ip6;
18322 vl_api_fib_path_t *fp;
18325 if (VAT_JSON_ARRAY != vam->json_tree.type)
18327 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18328 vat_json_init_array (&vam->json_tree);
18330 node = vat_json_array_add (&vam->json_tree);
18332 vat_json_init_object (node);
18333 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18334 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
18335 vat_json_object_add_ip6 (node, "prefix", ip6);
18336 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18337 vat_json_object_add_uint (node, "path_count", count);
18339 for (i = 0; i < count; i++)
18341 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18342 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18343 vat_json_object_add_uint (node, "is_local", fp->is_local);
18344 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18345 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18346 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18347 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18348 if (fp->afi == IP46_TYPE_IP4)
18350 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18351 vat_json_object_add_ip4 (node, "next_hop", ip4);
18353 else if (fp->afi == IP46_TYPE_IP6)
18355 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18356 vat_json_object_add_ip6 (node, "next_hop", ip6);
18362 api_ip6_fib_dump (vat_main_t * vam)
18364 vl_api_ip6_fib_dump_t *mp;
18365 vl_api_control_ping_t *mp_ping;
18368 M (IP6_FIB_DUMP, mp);
18371 /* Use a control ping for synchronization */
18372 M (CONTROL_PING, mp_ping);
18380 api_ip6_mfib_dump (vat_main_t * vam)
18382 vl_api_ip6_mfib_dump_t *mp;
18383 vl_api_control_ping_t *mp_ping;
18386 M (IP6_MFIB_DUMP, mp);
18389 /* Use a control ping for synchronization */
18390 M (CONTROL_PING, mp_ping);
18398 api_classify_table_ids (vat_main_t * vam)
18400 vl_api_classify_table_ids_t *mp;
18403 /* Construct the API message */
18404 M (CLASSIFY_TABLE_IDS, mp);
18413 api_classify_table_by_interface (vat_main_t * vam)
18415 unformat_input_t *input = vam->input;
18416 vl_api_classify_table_by_interface_t *mp;
18418 u32 sw_if_index = ~0;
18420 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18422 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18424 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18429 if (sw_if_index == ~0)
18431 errmsg ("missing interface name or sw_if_index");
18435 /* Construct the API message */
18436 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18438 mp->sw_if_index = ntohl (sw_if_index);
18446 api_classify_table_info (vat_main_t * vam)
18448 unformat_input_t *input = vam->input;
18449 vl_api_classify_table_info_t *mp;
18453 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18455 if (unformat (input, "table_id %d", &table_id))
18460 if (table_id == ~0)
18462 errmsg ("missing table id");
18466 /* Construct the API message */
18467 M (CLASSIFY_TABLE_INFO, mp);
18469 mp->table_id = ntohl (table_id);
18477 api_classify_session_dump (vat_main_t * vam)
18479 unformat_input_t *input = vam->input;
18480 vl_api_classify_session_dump_t *mp;
18481 vl_api_control_ping_t *mp_ping;
18485 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18487 if (unformat (input, "table_id %d", &table_id))
18492 if (table_id == ~0)
18494 errmsg ("missing table id");
18498 /* Construct the API message */
18499 M (CLASSIFY_SESSION_DUMP, mp);
18501 mp->table_id = ntohl (table_id);
18504 /* Use a control ping for synchronization */
18505 M (CONTROL_PING, mp_ping);
18513 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18515 vat_main_t *vam = &vat_main;
18517 print (vam->ofp, "collector_address %U, collector_port %d, "
18518 "src_address %U, vrf_id %d, path_mtu %u, "
18519 "template_interval %u, udp_checksum %d",
18520 format_ip4_address, mp->collector_address,
18521 ntohs (mp->collector_port),
18522 format_ip4_address, mp->src_address,
18523 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18524 ntohl (mp->template_interval), mp->udp_checksum);
18527 vam->result_ready = 1;
18531 vl_api_ipfix_exporter_details_t_handler_json
18532 (vl_api_ipfix_exporter_details_t * mp)
18534 vat_main_t *vam = &vat_main;
18535 vat_json_node_t node;
18536 struct in_addr collector_address;
18537 struct in_addr src_address;
18539 vat_json_init_object (&node);
18540 clib_memcpy (&collector_address, &mp->collector_address,
18541 sizeof (collector_address));
18542 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18543 vat_json_object_add_uint (&node, "collector_port",
18544 ntohs (mp->collector_port));
18545 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18546 vat_json_object_add_ip4 (&node, "src_address", src_address);
18547 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18548 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18549 vat_json_object_add_uint (&node, "template_interval",
18550 ntohl (mp->template_interval));
18551 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18553 vat_json_print (vam->ofp, &node);
18554 vat_json_free (&node);
18556 vam->result_ready = 1;
18560 api_ipfix_exporter_dump (vat_main_t * vam)
18562 vl_api_ipfix_exporter_dump_t *mp;
18565 /* Construct the API message */
18566 M (IPFIX_EXPORTER_DUMP, mp);
18575 api_ipfix_classify_stream_dump (vat_main_t * vam)
18577 vl_api_ipfix_classify_stream_dump_t *mp;
18580 /* Construct the API message */
18581 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18592 vl_api_ipfix_classify_stream_details_t_handler
18593 (vl_api_ipfix_classify_stream_details_t * mp)
18595 vat_main_t *vam = &vat_main;
18596 print (vam->ofp, "domain_id %d, src_port %d",
18597 ntohl (mp->domain_id), ntohs (mp->src_port));
18599 vam->result_ready = 1;
18603 vl_api_ipfix_classify_stream_details_t_handler_json
18604 (vl_api_ipfix_classify_stream_details_t * mp)
18606 vat_main_t *vam = &vat_main;
18607 vat_json_node_t node;
18609 vat_json_init_object (&node);
18610 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18611 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18613 vat_json_print (vam->ofp, &node);
18614 vat_json_free (&node);
18616 vam->result_ready = 1;
18620 api_ipfix_classify_table_dump (vat_main_t * vam)
18622 vl_api_ipfix_classify_table_dump_t *mp;
18623 vl_api_control_ping_t *mp_ping;
18626 if (!vam->json_output)
18628 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18629 "transport_protocol");
18632 /* Construct the API message */
18633 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18638 /* Use a control ping for synchronization */
18639 M (CONTROL_PING, mp_ping);
18647 vl_api_ipfix_classify_table_details_t_handler
18648 (vl_api_ipfix_classify_table_details_t * mp)
18650 vat_main_t *vam = &vat_main;
18651 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18652 mp->transport_protocol);
18656 vl_api_ipfix_classify_table_details_t_handler_json
18657 (vl_api_ipfix_classify_table_details_t * mp)
18659 vat_json_node_t *node = NULL;
18660 vat_main_t *vam = &vat_main;
18662 if (VAT_JSON_ARRAY != vam->json_tree.type)
18664 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18665 vat_json_init_array (&vam->json_tree);
18668 node = vat_json_array_add (&vam->json_tree);
18669 vat_json_init_object (node);
18671 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18672 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18673 vat_json_object_add_uint (node, "transport_protocol",
18674 mp->transport_protocol);
18678 api_sw_interface_span_enable_disable (vat_main_t * vam)
18680 unformat_input_t *i = vam->input;
18681 vl_api_sw_interface_span_enable_disable_t *mp;
18682 u32 src_sw_if_index = ~0;
18683 u32 dst_sw_if_index = ~0;
18688 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18691 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18693 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18697 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18699 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18701 else if (unformat (i, "disable"))
18703 else if (unformat (i, "rx"))
18705 else if (unformat (i, "tx"))
18707 else if (unformat (i, "both"))
18709 else if (unformat (i, "l2"))
18715 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18717 mp->sw_if_index_from = htonl (src_sw_if_index);
18718 mp->sw_if_index_to = htonl (dst_sw_if_index);
18728 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18731 vat_main_t *vam = &vat_main;
18732 u8 *sw_if_from_name = 0;
18733 u8 *sw_if_to_name = 0;
18734 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18735 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18736 char *states[] = { "none", "rx", "tx", "both" };
18740 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18742 if ((u32) p->value[0] == sw_if_index_from)
18744 sw_if_from_name = (u8 *)(p->key);
18748 if ((u32) p->value[0] == sw_if_index_to)
18750 sw_if_to_name = (u8 *)(p->key);
18751 if (sw_if_from_name)
18756 print (vam->ofp, "%20s => %20s (%s)",
18757 sw_if_from_name, sw_if_to_name, states[mp->state]);
18761 vl_api_sw_interface_span_details_t_handler_json
18762 (vl_api_sw_interface_span_details_t * mp)
18764 vat_main_t *vam = &vat_main;
18765 vat_json_node_t *node = NULL;
18766 u8 *sw_if_from_name = 0;
18767 u8 *sw_if_to_name = 0;
18768 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18769 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18773 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18775 if ((u32) p->value[0] == sw_if_index_from)
18777 sw_if_from_name = (u8 *)(p->key);
18781 if ((u32) p->value[0] == sw_if_index_to)
18783 sw_if_to_name = (u8 *)(p->key);
18784 if (sw_if_from_name)
18790 if (VAT_JSON_ARRAY != vam->json_tree.type)
18792 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18793 vat_json_init_array (&vam->json_tree);
18795 node = vat_json_array_add (&vam->json_tree);
18797 vat_json_init_object (node);
18798 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18799 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18800 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18801 if (0 != sw_if_to_name)
18803 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18805 vat_json_object_add_uint (node, "state", mp->state);
18809 api_sw_interface_span_dump (vat_main_t * vam)
18811 unformat_input_t *input = vam->input;
18812 vl_api_sw_interface_span_dump_t *mp;
18813 vl_api_control_ping_t *mp_ping;
18817 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18819 if (unformat (input, "l2"))
18825 M (SW_INTERFACE_SPAN_DUMP, mp);
18829 /* Use a control ping for synchronization */
18830 M (CONTROL_PING, mp_ping);
18838 api_pg_create_interface (vat_main_t * vam)
18840 unformat_input_t *input = vam->input;
18841 vl_api_pg_create_interface_t *mp;
18845 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18847 if (unformat (input, "if_id %d", &if_id))
18854 errmsg ("missing pg interface index");
18858 /* Construct the API message */
18859 M (PG_CREATE_INTERFACE, mp);
18861 mp->interface_id = ntohl (if_id);
18869 api_pg_capture (vat_main_t * vam)
18871 unformat_input_t *input = vam->input;
18872 vl_api_pg_capture_t *mp;
18877 u8 pcap_file_set = 0;
18880 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18882 if (unformat (input, "if_id %d", &if_id))
18884 else if (unformat (input, "pcap %s", &pcap_file))
18886 else if (unformat (input, "count %d", &count))
18888 else if (unformat (input, "disable"))
18895 errmsg ("missing pg interface index");
18898 if (pcap_file_set > 0)
18900 if (vec_len (pcap_file) > 255)
18902 errmsg ("pcap file name is too long");
18907 u32 name_len = vec_len (pcap_file);
18908 /* Construct the API message */
18909 M (PG_CAPTURE, mp);
18911 mp->interface_id = ntohl (if_id);
18912 mp->is_enabled = enable;
18913 mp->count = ntohl (count);
18914 mp->pcap_name_length = ntohl (name_len);
18915 if (pcap_file_set != 0)
18917 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18919 vec_free (pcap_file);
18927 api_pg_enable_disable (vat_main_t * vam)
18929 unformat_input_t *input = vam->input;
18930 vl_api_pg_enable_disable_t *mp;
18933 u8 stream_name_set = 0;
18934 u8 *stream_name = 0;
18936 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18938 if (unformat (input, "stream %s", &stream_name))
18939 stream_name_set = 1;
18940 else if (unformat (input, "disable"))
18946 if (stream_name_set > 0)
18948 if (vec_len (stream_name) > 255)
18950 errmsg ("stream name too long");
18955 u32 name_len = vec_len (stream_name);
18956 /* Construct the API message */
18957 M (PG_ENABLE_DISABLE, mp);
18959 mp->is_enabled = enable;
18960 if (stream_name_set != 0)
18962 mp->stream_name_length = ntohl (name_len);
18963 clib_memcpy (mp->stream_name, stream_name, name_len);
18965 vec_free (stream_name);
18973 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18975 unformat_input_t *input = vam->input;
18976 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18978 u16 *low_ports = 0;
18979 u16 *high_ports = 0;
18982 ip4_address_t ip4_addr;
18983 ip6_address_t ip6_addr;
18992 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18994 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
19000 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
19005 else if (unformat (input, "vrf %d", &vrf_id))
19007 else if (unformat (input, "del"))
19009 else if (unformat (input, "port %d", &tmp))
19011 if (tmp == 0 || tmp > 65535)
19013 errmsg ("port %d out of range", tmp);
19017 this_hi = this_low + 1;
19018 vec_add1 (low_ports, this_low);
19019 vec_add1 (high_ports, this_hi);
19021 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
19023 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
19025 errmsg ("incorrect range parameters");
19029 /* Note: in debug CLI +1 is added to high before
19030 passing to real fn that does "the work"
19031 (ip_source_and_port_range_check_add_del).
19032 This fn is a wrapper around the binary API fn a
19033 control plane will call, which expects this increment
19034 to have occurred. Hence letting the binary API control
19035 plane fn do the increment for consistency between VAT
19036 and other control planes.
19039 vec_add1 (low_ports, this_low);
19040 vec_add1 (high_ports, this_hi);
19046 if (prefix_set == 0)
19048 errmsg ("<address>/<mask> not specified");
19054 errmsg ("VRF ID required, not specified");
19061 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19065 if (vec_len (low_ports) == 0)
19067 errmsg ("At least one port or port range required");
19071 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
19073 mp->is_add = is_add;
19078 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
19083 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
19086 mp->mask_length = length;
19087 mp->number_of_ranges = vec_len (low_ports);
19089 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
19090 vec_free (low_ports);
19092 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
19093 vec_free (high_ports);
19095 mp->vrf_id = ntohl (vrf_id);
19103 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
19105 unformat_input_t *input = vam->input;
19106 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
19107 u32 sw_if_index = ~0;
19109 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
19110 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
19114 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
19116 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19118 else if (unformat (input, "sw_if_index %d", &sw_if_index))
19120 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
19122 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
19124 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
19126 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
19128 else if (unformat (input, "del"))
19134 if (sw_if_index == ~0)
19136 errmsg ("Interface required but not specified");
19142 errmsg ("VRF ID required but not specified");
19146 if (tcp_out_vrf_id == 0
19147 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
19150 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
19154 /* Construct the API message */
19155 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
19157 mp->sw_if_index = ntohl (sw_if_index);
19158 mp->is_add = is_add;
19159 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
19160 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
19161 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
19162 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
19167 /* Wait for a reply... */
19173 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
19175 unformat_input_t *i = vam->input;
19176 vl_api_ipsec_gre_add_del_tunnel_t *mp;
19177 u32 local_sa_id = 0;
19178 u32 remote_sa_id = 0;
19179 ip4_address_t src_address;
19180 ip4_address_t dst_address;
19184 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19186 if (unformat (i, "local_sa %d", &local_sa_id))
19188 else if (unformat (i, "remote_sa %d", &remote_sa_id))
19190 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
19192 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
19194 else if (unformat (i, "del"))
19198 clib_warning ("parse error '%U'", format_unformat_error, i);
19203 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
19205 mp->local_sa_id = ntohl (local_sa_id);
19206 mp->remote_sa_id = ntohl (remote_sa_id);
19207 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
19208 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
19209 mp->is_add = is_add;
19217 api_punt (vat_main_t * vam)
19219 unformat_input_t *i = vam->input;
19227 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19229 if (unformat (i, "ip %d", &ipv))
19231 else if (unformat (i, "protocol %d", &protocol))
19233 else if (unformat (i, "port %d", &port))
19235 else if (unformat (i, "del"))
19239 clib_warning ("parse error '%U'", format_unformat_error, i);
19246 mp->is_add = (u8) is_add;
19247 mp->ipv = (u8) ipv;
19248 mp->l4_protocol = (u8) protocol;
19249 mp->l4_port = htons ((u16) port);
19256 static void vl_api_ipsec_gre_tunnel_details_t_handler
19257 (vl_api_ipsec_gre_tunnel_details_t * mp)
19259 vat_main_t *vam = &vat_main;
19261 print (vam->ofp, "%11d%15U%15U%14d%14d",
19262 ntohl (mp->sw_if_index),
19263 format_ip4_address, &mp->src_address,
19264 format_ip4_address, &mp->dst_address,
19265 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
19268 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
19269 (vl_api_ipsec_gre_tunnel_details_t * mp)
19271 vat_main_t *vam = &vat_main;
19272 vat_json_node_t *node = NULL;
19273 struct in_addr ip4;
19275 if (VAT_JSON_ARRAY != vam->json_tree.type)
19277 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19278 vat_json_init_array (&vam->json_tree);
19280 node = vat_json_array_add (&vam->json_tree);
19282 vat_json_init_object (node);
19283 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19284 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
19285 vat_json_object_add_ip4 (node, "src_address", ip4);
19286 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
19287 vat_json_object_add_ip4 (node, "dst_address", ip4);
19288 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
19289 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
19293 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
19295 unformat_input_t *i = vam->input;
19296 vl_api_ipsec_gre_tunnel_dump_t *mp;
19297 vl_api_control_ping_t *mp_ping;
19299 u8 sw_if_index_set = 0;
19302 /* Parse args required to build the message */
19303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19305 if (unformat (i, "sw_if_index %d", &sw_if_index))
19306 sw_if_index_set = 1;
19311 if (sw_if_index_set == 0)
19316 if (!vam->json_output)
19318 print (vam->ofp, "%11s%15s%15s%14s%14s",
19319 "sw_if_index", "src_address", "dst_address",
19320 "local_sa_id", "remote_sa_id");
19323 /* Get list of gre-tunnel interfaces */
19324 M (IPSEC_GRE_TUNNEL_DUMP, mp);
19326 mp->sw_if_index = htonl (sw_if_index);
19330 /* Use a control ping for synchronization */
19331 M (CONTROL_PING, mp_ping);
19339 api_delete_subif (vat_main_t * vam)
19341 unformat_input_t *i = vam->input;
19342 vl_api_delete_subif_t *mp;
19343 u32 sw_if_index = ~0;
19346 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19348 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19350 if (unformat (i, "sw_if_index %d", &sw_if_index))
19356 if (sw_if_index == ~0)
19358 errmsg ("missing sw_if_index");
19362 /* Construct the API message */
19363 M (DELETE_SUBIF, mp);
19364 mp->sw_if_index = ntohl (sw_if_index);
19371 #define foreach_pbb_vtr_op \
19372 _("disable", L2_VTR_DISABLED) \
19373 _("pop", L2_VTR_POP_2) \
19374 _("push", L2_VTR_PUSH_2)
19377 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19379 unformat_input_t *i = vam->input;
19380 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19381 u32 sw_if_index = ~0, vtr_op = ~0;
19382 u16 outer_tag = ~0;
19383 u8 dmac[6], smac[6];
19384 u8 dmac_set = 0, smac_set = 0;
19390 /* Shut up coverity */
19391 memset (dmac, 0, sizeof (dmac));
19392 memset (smac, 0, sizeof (smac));
19394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19396 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19398 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19400 else if (unformat (i, "vtr_op %d", &vtr_op))
19402 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19405 else if (unformat (i, "translate_pbb_stag"))
19407 if (unformat (i, "%d", &tmp))
19409 vtr_op = L2_VTR_TRANSLATE_2_1;
19415 ("translate_pbb_stag operation requires outer tag definition");
19419 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19421 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19423 else if (unformat (i, "sid %d", &sid))
19425 else if (unformat (i, "vlanid %d", &tmp))
19429 clib_warning ("parse error '%U'", format_unformat_error, i);
19434 if ((sw_if_index == ~0) || (vtr_op == ~0))
19436 errmsg ("missing sw_if_index or vtr operation");
19439 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19440 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19443 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19447 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19448 mp->sw_if_index = ntohl (sw_if_index);
19449 mp->vtr_op = ntohl (vtr_op);
19450 mp->outer_tag = ntohs (outer_tag);
19451 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19452 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19453 mp->b_vlanid = ntohs (vlanid);
19454 mp->i_sid = ntohl (sid);
19462 api_flow_classify_set_interface (vat_main_t * vam)
19464 unformat_input_t *i = vam->input;
19465 vl_api_flow_classify_set_interface_t *mp;
19467 int sw_if_index_set;
19468 u32 ip4_table_index = ~0;
19469 u32 ip6_table_index = ~0;
19473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19475 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19476 sw_if_index_set = 1;
19477 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19478 sw_if_index_set = 1;
19479 else if (unformat (i, "del"))
19481 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19483 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19487 clib_warning ("parse error '%U'", format_unformat_error, i);
19492 if (sw_if_index_set == 0)
19494 errmsg ("missing interface name or sw_if_index");
19498 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19500 mp->sw_if_index = ntohl (sw_if_index);
19501 mp->ip4_table_index = ntohl (ip4_table_index);
19502 mp->ip6_table_index = ntohl (ip6_table_index);
19503 mp->is_add = is_add;
19511 api_flow_classify_dump (vat_main_t * vam)
19513 unformat_input_t *i = vam->input;
19514 vl_api_flow_classify_dump_t *mp;
19515 vl_api_control_ping_t *mp_ping;
19516 u8 type = FLOW_CLASSIFY_N_TABLES;
19519 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19523 errmsg ("classify table type must be specified");
19527 if (!vam->json_output)
19529 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19532 M (FLOW_CLASSIFY_DUMP, mp);
19537 /* Use a control ping for synchronization */
19538 M (CONTROL_PING, mp_ping);
19541 /* Wait for a reply... */
19547 api_feature_enable_disable (vat_main_t * vam)
19549 unformat_input_t *i = vam->input;
19550 vl_api_feature_enable_disable_t *mp;
19552 u8 *feature_name = 0;
19553 u32 sw_if_index = ~0;
19557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19559 if (unformat (i, "arc_name %s", &arc_name))
19561 else if (unformat (i, "feature_name %s", &feature_name))
19564 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19566 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19568 else if (unformat (i, "disable"))
19576 errmsg ("missing arc name");
19579 if (vec_len (arc_name) > 63)
19581 errmsg ("arc name too long");
19584 if (feature_name == 0)
19586 errmsg ("missing feature name");
19589 if (vec_len (feature_name) > 63)
19591 errmsg ("feature name too long");
19594 if (sw_if_index == ~0)
19596 errmsg ("missing interface name or sw_if_index");
19600 /* Construct the API message */
19601 M (FEATURE_ENABLE_DISABLE, mp);
19602 mp->sw_if_index = ntohl (sw_if_index);
19603 mp->enable = enable;
19604 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19605 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19606 vec_free (arc_name);
19607 vec_free (feature_name);
19615 api_sw_interface_tag_add_del (vat_main_t * vam)
19617 unformat_input_t *i = vam->input;
19618 vl_api_sw_interface_tag_add_del_t *mp;
19619 u32 sw_if_index = ~0;
19624 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19626 if (unformat (i, "tag %s", &tag))
19628 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19630 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19632 else if (unformat (i, "del"))
19638 if (sw_if_index == ~0)
19640 errmsg ("missing interface name or sw_if_index");
19644 if (enable && (tag == 0))
19646 errmsg ("no tag specified");
19650 /* Construct the API message */
19651 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19652 mp->sw_if_index = ntohl (sw_if_index);
19653 mp->is_add = enable;
19655 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19663 static void vl_api_l2_xconnect_details_t_handler
19664 (vl_api_l2_xconnect_details_t * mp)
19666 vat_main_t *vam = &vat_main;
19668 print (vam->ofp, "%15d%15d",
19669 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19672 static void vl_api_l2_xconnect_details_t_handler_json
19673 (vl_api_l2_xconnect_details_t * mp)
19675 vat_main_t *vam = &vat_main;
19676 vat_json_node_t *node = NULL;
19678 if (VAT_JSON_ARRAY != vam->json_tree.type)
19680 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19681 vat_json_init_array (&vam->json_tree);
19683 node = vat_json_array_add (&vam->json_tree);
19685 vat_json_init_object (node);
19686 vat_json_object_add_uint (node, "rx_sw_if_index",
19687 ntohl (mp->rx_sw_if_index));
19688 vat_json_object_add_uint (node, "tx_sw_if_index",
19689 ntohl (mp->tx_sw_if_index));
19693 api_l2_xconnect_dump (vat_main_t * vam)
19695 vl_api_l2_xconnect_dump_t *mp;
19696 vl_api_control_ping_t *mp_ping;
19699 if (!vam->json_output)
19701 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19704 M (L2_XCONNECT_DUMP, mp);
19708 /* Use a control ping for synchronization */
19709 M (CONTROL_PING, mp_ping);
19717 api_sw_interface_set_mtu (vat_main_t * vam)
19719 unformat_input_t *i = vam->input;
19720 vl_api_sw_interface_set_mtu_t *mp;
19721 u32 sw_if_index = ~0;
19725 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19727 if (unformat (i, "mtu %d", &mtu))
19729 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19731 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19737 if (sw_if_index == ~0)
19739 errmsg ("missing interface name or sw_if_index");
19745 errmsg ("no mtu specified");
19749 /* Construct the API message */
19750 M (SW_INTERFACE_SET_MTU, mp);
19751 mp->sw_if_index = ntohl (sw_if_index);
19752 mp->mtu = ntohs ((u16) mtu);
19760 api_p2p_ethernet_add (vat_main_t * vam)
19762 unformat_input_t *i = vam->input;
19763 vl_api_p2p_ethernet_add_t *mp;
19764 u32 parent_if_index = ~0;
19770 memset (remote_mac, 0, sizeof (remote_mac));
19771 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19773 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19775 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19779 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19781 else if (unformat (i, "sub_id %d", &sub_id))
19785 clib_warning ("parse error '%U'", format_unformat_error, i);
19790 if (parent_if_index == ~0)
19792 errmsg ("missing interface name or sw_if_index");
19797 errmsg ("missing remote mac address");
19802 errmsg ("missing sub-interface id");
19806 M (P2P_ETHERNET_ADD, mp);
19807 mp->parent_if_index = ntohl (parent_if_index);
19808 mp->subif_id = ntohl (sub_id);
19809 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19817 api_p2p_ethernet_del (vat_main_t * vam)
19819 unformat_input_t *i = vam->input;
19820 vl_api_p2p_ethernet_del_t *mp;
19821 u32 parent_if_index = ~0;
19826 memset (remote_mac, 0, sizeof (remote_mac));
19827 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19829 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19831 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19835 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19839 clib_warning ("parse error '%U'", format_unformat_error, i);
19844 if (parent_if_index == ~0)
19846 errmsg ("missing interface name or sw_if_index");
19851 errmsg ("missing remote mac address");
19855 M (P2P_ETHERNET_DEL, mp);
19856 mp->parent_if_index = ntohl (parent_if_index);
19857 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19865 api_lldp_config (vat_main_t * vam)
19867 unformat_input_t *i = vam->input;
19868 vl_api_lldp_config_t *mp;
19870 int tx_interval = 0;
19871 u8 *sys_name = NULL;
19874 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19876 if (unformat (i, "system-name %s", &sys_name))
19878 else if (unformat (i, "tx-hold %d", &tx_hold))
19880 else if (unformat (i, "tx-interval %d", &tx_interval))
19884 clib_warning ("parse error '%U'", format_unformat_error, i);
19889 vec_add1 (sys_name, 0);
19891 M (LLDP_CONFIG, mp);
19892 mp->tx_hold = htonl (tx_hold);
19893 mp->tx_interval = htonl (tx_interval);
19894 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19895 vec_free (sys_name);
19903 api_sw_interface_set_lldp (vat_main_t * vam)
19905 unformat_input_t *i = vam->input;
19906 vl_api_sw_interface_set_lldp_t *mp;
19907 u32 sw_if_index = ~0;
19909 u8 *port_desc = NULL;
19912 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19914 if (unformat (i, "disable"))
19917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19919 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19921 else if (unformat (i, "port-desc %s", &port_desc))
19927 if (sw_if_index == ~0)
19929 errmsg ("missing interface name or sw_if_index");
19933 /* Construct the API message */
19934 vec_add1 (port_desc, 0);
19935 M (SW_INTERFACE_SET_LLDP, mp);
19936 mp->sw_if_index = ntohl (sw_if_index);
19937 mp->enable = enable;
19938 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19939 vec_free (port_desc);
19947 api_tcp_configure_src_addresses (vat_main_t * vam)
19949 vl_api_tcp_configure_src_addresses_t *mp;
19950 unformat_input_t *i = vam->input;
19951 ip4_address_t v4first, v4last;
19952 ip6_address_t v6first, v6last;
19957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19959 if (unformat (i, "%U - %U",
19960 unformat_ip4_address, &v4first,
19961 unformat_ip4_address, &v4last))
19965 errmsg ("one range per message (range already set)");
19970 else if (unformat (i, "%U - %U",
19971 unformat_ip6_address, &v6first,
19972 unformat_ip6_address, &v6last))
19976 errmsg ("one range per message (range already set)");
19981 else if (unformat (i, "vrf %d", &vrf_id))
19987 if (range_set == 0)
19989 errmsg ("address range not set");
19993 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19994 mp->vrf_id = ntohl (vrf_id);
19996 if (range_set == 2)
19999 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
20000 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
20005 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
20006 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
20014 q_or_quit (vat_main_t * vam)
20016 #if VPP_API_TEST_BUILTIN == 0
20017 longjmp (vam->jump_buf, 1);
20019 return 0; /* not so much */
20023 q (vat_main_t * vam)
20025 return q_or_quit (vam);
20029 quit (vat_main_t * vam)
20031 return q_or_quit (vam);
20035 comment (vat_main_t * vam)
20041 cmd_cmp (void *a1, void *a2)
20046 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
20050 help (vat_main_t * vam)
20055 unformat_input_t *i = vam->input;
20058 if (unformat (i, "%s", &name))
20062 vec_add1 (name, 0);
20064 hs = hash_get_mem (vam->help_by_name, name);
20066 print (vam->ofp, "usage: %s %s", name, hs[0]);
20068 print (vam->ofp, "No such msg / command '%s'", name);
20073 print (vam->ofp, "Help is available for the following:");
20076 hash_foreach_pair (p, vam->function_by_name,
20078 vec_add1 (cmds, (u8 *)(p->key));
20082 vec_sort_with_function (cmds, cmd_cmp);
20084 for (j = 0; j < vec_len (cmds); j++)
20085 print (vam->ofp, "%s", cmds[j]);
20092 set (vat_main_t * vam)
20094 u8 *name = 0, *value = 0;
20095 unformat_input_t *i = vam->input;
20097 if (unformat (i, "%s", &name))
20099 /* The input buffer is a vector, not a string. */
20100 value = vec_dup (i->buffer);
20101 vec_delete (value, i->index, 0);
20102 /* Almost certainly has a trailing newline */
20103 if (value[vec_len (value) - 1] == '\n')
20104 value[vec_len (value) - 1] = 0;
20105 /* Make sure it's a proper string, one way or the other */
20106 vec_add1 (value, 0);
20107 (void) clib_macro_set_value (&vam->macro_main,
20108 (char *) name, (char *) value);
20111 errmsg ("usage: set <name> <value>");
20119 unset (vat_main_t * vam)
20123 if (unformat (vam->input, "%s", &name))
20124 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
20125 errmsg ("unset: %s wasn't set", name);
20138 macro_sort_cmp (void *a1, void *a2)
20140 macro_sort_t *s1 = a1;
20141 macro_sort_t *s2 = a2;
20143 return strcmp ((char *) (s1->name), (char *) (s2->name));
20147 dump_macro_table (vat_main_t * vam)
20149 macro_sort_t *sort_me = 0, *sm;
20154 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
20156 vec_add2 (sort_me, sm, 1);
20157 sm->name = (u8 *)(p->key);
20158 sm->value = (u8 *) (p->value[0]);
20162 vec_sort_with_function (sort_me, macro_sort_cmp);
20164 if (vec_len (sort_me))
20165 print (vam->ofp, "%-15s%s", "Name", "Value");
20167 print (vam->ofp, "The macro table is empty...");
20169 for (i = 0; i < vec_len (sort_me); i++)
20170 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
20175 dump_node_table (vat_main_t * vam)
20178 vlib_node_t *node, *next_node;
20180 if (vec_len (vam->graph_nodes) == 0)
20182 print (vam->ofp, "Node table empty, issue get_node_graph...");
20186 for (i = 0; i < vec_len (vam->graph_nodes); i++)
20188 node = vam->graph_nodes[i];
20189 print (vam->ofp, "[%d] %s", i, node->name);
20190 for (j = 0; j < vec_len (node->next_nodes); j++)
20192 if (node->next_nodes[j] != ~0)
20194 next_node = vam->graph_nodes[node->next_nodes[j]];
20195 print (vam->ofp, " [%d] %s", j, next_node->name);
20203 value_sort_cmp (void *a1, void *a2)
20205 name_sort_t *n1 = a1;
20206 name_sort_t *n2 = a2;
20208 if (n1->value < n2->value)
20210 if (n1->value > n2->value)
20217 dump_msg_api_table (vat_main_t * vam)
20219 api_main_t *am = &api_main;
20220 name_sort_t *nses = 0, *ns;
20225 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
20227 vec_add2 (nses, ns, 1);
20228 ns->name = (u8 *)(hp->key);
20229 ns->value = (u32) hp->value[0];
20233 vec_sort_with_function (nses, value_sort_cmp);
20235 for (i = 0; i < vec_len (nses); i++)
20236 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20242 get_msg_id (vat_main_t * vam)
20247 if (unformat (vam->input, "%s", &name_and_crc))
20249 message_index = vl_api_get_msg_index (name_and_crc);
20250 if (message_index == ~0)
20252 print (vam->ofp, " '%s' not found", name_and_crc);
20255 print (vam->ofp, " '%s' has message index %d",
20256 name_and_crc, message_index);
20259 errmsg ("name_and_crc required...");
20264 search_node_table (vat_main_t * vam)
20266 unformat_input_t *line_input = vam->input;
20269 vlib_node_t *node, *next_node;
20272 if (vam->graph_node_index_by_name == 0)
20274 print (vam->ofp, "Node table empty, issue get_node_graph...");
20278 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20280 if (unformat (line_input, "%s", &node_to_find))
20282 vec_add1 (node_to_find, 0);
20283 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20286 print (vam->ofp, "%s not found...", node_to_find);
20289 node = vam->graph_nodes[p[0]];
20290 print (vam->ofp, "[%d] %s", p[0], node->name);
20291 for (j = 0; j < vec_len (node->next_nodes); j++)
20293 if (node->next_nodes[j] != ~0)
20295 next_node = vam->graph_nodes[node->next_nodes[j]];
20296 print (vam->ofp, " [%d] %s", j, next_node->name);
20303 clib_warning ("parse error '%U'", format_unformat_error,
20309 vec_free (node_to_find);
20318 script (vat_main_t * vam)
20320 #if (VPP_API_TEST_BUILTIN==0)
20322 char *save_current_file;
20323 unformat_input_t save_input;
20324 jmp_buf save_jump_buf;
20325 u32 save_line_number;
20327 FILE *new_fp, *save_ifp;
20329 if (unformat (vam->input, "%s", &s))
20331 new_fp = fopen ((char *) s, "r");
20334 errmsg ("Couldn't open script file %s", s);
20341 errmsg ("Missing script name");
20345 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20346 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20347 save_ifp = vam->ifp;
20348 save_line_number = vam->input_line_number;
20349 save_current_file = (char *) vam->current_file;
20351 vam->input_line_number = 0;
20353 vam->current_file = s;
20356 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
20357 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20358 vam->ifp = save_ifp;
20359 vam->input_line_number = save_line_number;
20360 vam->current_file = (u8 *) save_current_file;
20365 clib_warning ("use the exec command...");
20371 echo (vat_main_t * vam)
20373 print (vam->ofp, "%v", vam->input->buffer);
20377 /* List of API message constructors, CLI names map to api_xxx */
20378 #define foreach_vpe_api_msg \
20379 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20380 _(sw_interface_dump,"") \
20381 _(sw_interface_set_flags, \
20382 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20383 _(sw_interface_add_del_address, \
20384 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20385 _(sw_interface_set_table, \
20386 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20387 _(sw_interface_set_mpls_enable, \
20388 "<intfc> | sw_if_index [disable | dis]") \
20389 _(sw_interface_set_vpath, \
20390 "<intfc> | sw_if_index <id> enable | disable") \
20391 _(sw_interface_set_vxlan_bypass, \
20392 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20393 _(sw_interface_set_l2_xconnect, \
20394 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20395 "enable | disable") \
20396 _(sw_interface_set_l2_bridge, \
20397 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20398 "[shg <split-horizon-group>] [bvi]\n" \
20399 "enable | disable") \
20400 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20401 _(bridge_domain_add_del, \
20402 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [mac-age 0-255] [bd-tag <tag>] [del]\n") \
20403 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20405 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20406 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20407 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20409 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20411 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20413 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
20415 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
20417 "<vpp-if-name> | sw_if_index <id>") \
20418 _(sw_interface_tap_dump, "") \
20419 _(ip_table_add_del, \
20420 "table-id <n> [ipv6]\n") \
20421 _(ip_add_del_route, \
20422 "<addr>/<mask> via <addr> [table-id <n>]\n" \
20423 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20424 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20425 "[multipath] [count <n>]") \
20426 _(ip_mroute_add_del, \
20427 "<src> <grp>/<mask> [table-id <n>]\n" \
20428 "[<intfc> | sw_if_index <id>] [local] [del]") \
20429 _(mpls_table_add_del, \
20430 "table-id <n>\n") \
20431 _(mpls_route_add_del, \
20432 "<label> <eos> via <addr> [table-id <n>]\n" \
20433 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20434 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20435 "[multipath] [count <n>]") \
20436 _(mpls_ip_bind_unbind, \
20437 "<label> <addr/len>") \
20438 _(mpls_tunnel_add_del, \
20439 " via <addr> [table-id <n>]\n" \
20440 "sw_if_index <id>] [l2] [del]") \
20441 _(proxy_arp_add_del, \
20442 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
20443 _(proxy_arp_intfc_enable_disable, \
20444 "<intfc> | sw_if_index <id> enable | disable") \
20445 _(sw_interface_set_unnumbered, \
20446 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20447 _(ip_neighbor_add_del, \
20448 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
20449 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
20450 _(reset_vrf, "vrf <id> [ipv6]") \
20451 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20452 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20453 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20454 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20455 "[outer_vlan_id_any][inner_vlan_id_any]") \
20456 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
20457 _(reset_fib, "vrf <n> [ipv6]") \
20458 _(dhcp_proxy_config, \
20459 "svr <v46-address> src <v46-address>\n" \
20460 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
20461 _(dhcp_proxy_set_vss, \
20462 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
20463 _(dhcp_proxy_dump, "ip6") \
20464 _(dhcp_client_config, \
20465 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
20466 _(set_ip_flow_hash, \
20467 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20468 _(sw_interface_ip6_enable_disable, \
20469 "<intfc> | sw_if_index <id> enable | disable") \
20470 _(sw_interface_ip6_set_link_local_address, \
20471 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
20472 _(ip6nd_proxy_add_del, \
20473 "<intfc> | sw_if_index <id> <ip6-address>") \
20474 _(ip6nd_proxy_dump, "") \
20475 _(sw_interface_ip6nd_ra_prefix, \
20476 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
20477 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
20478 "[nolink] [isno]") \
20479 _(sw_interface_ip6nd_ra_config, \
20480 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
20481 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
20482 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
20483 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
20484 _(l2_patch_add_del, \
20485 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20486 "enable | disable") \
20487 _(sr_localsid_add_del, \
20488 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20489 "fib-table <num> (end.psp) sw_if_index <num>") \
20490 _(classify_add_del_table, \
20491 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20492 " [del] [del-chain] mask <mask-value>\n" \
20493 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20494 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20495 _(classify_add_del_session, \
20496 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20497 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20498 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20499 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20500 _(classify_set_interface_ip_table, \
20501 "<intfc> | sw_if_index <nn> table <nn>") \
20502 _(classify_set_interface_l2_tables, \
20503 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20504 " [other-table <nn>]") \
20505 _(get_node_index, "node <node-name") \
20506 _(add_node_next, "node <node-name> next <next-node-name>") \
20507 _(l2tpv3_create_tunnel, \
20508 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20509 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20510 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20511 _(l2tpv3_set_tunnel_cookies, \
20512 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20513 "[new_remote_cookie <nn>]\n") \
20514 _(l2tpv3_interface_enable_disable, \
20515 "<intfc> | sw_if_index <nn> enable | disable") \
20516 _(l2tpv3_set_lookup_key, \
20517 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20518 _(sw_if_l2tpv3_tunnel_dump, "") \
20519 _(vxlan_add_del_tunnel, \
20520 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20521 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20522 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20523 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20524 _(gre_add_del_tunnel, \
20525 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
20526 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20527 _(l2_fib_clear_table, "") \
20528 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20529 _(l2_interface_vlan_tag_rewrite, \
20530 "<intfc> | sw_if_index <nn> \n" \
20531 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20532 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20533 _(create_vhost_user_if, \
20534 "socket <filename> [server] [renumber <dev_instance>] " \
20535 "[mac <mac_address>]") \
20536 _(modify_vhost_user_if, \
20537 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20538 "[server] [renumber <dev_instance>]") \
20539 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20540 _(sw_interface_vhost_user_dump, "") \
20541 _(show_version, "") \
20542 _(vxlan_gpe_add_del_tunnel, \
20543 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20544 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20545 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20546 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20547 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20548 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20549 _(interface_name_renumber, \
20550 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20551 _(input_acl_set_interface, \
20552 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20553 " [l2-table <nn>] [del]") \
20554 _(want_ip4_arp_events, "address <ip4-address> [del]") \
20555 _(want_ip6_nd_events, "address <ip6-address> [del]") \
20556 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20557 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20558 _(ip_dump, "ipv4 | ipv6") \
20559 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20560 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20562 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20563 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20564 " integ_alg <alg> integ_key <hex>") \
20565 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
20566 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20567 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20568 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20569 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
20570 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20571 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20572 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20573 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
20574 _(ikev2_profile_add_del, "name <profile_name> [del]") \
20575 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
20576 "(auth_data 0x<data> | auth_data <data>)") \
20577 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
20578 "(id_data 0x<data> | id_data <data>) (local|remote)") \
20579 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
20580 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
20581 "(local|remote)") \
20582 _(ikev2_set_local_key, "file <absolute_file_path>") \
20583 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
20584 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20585 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20586 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
20587 _(ikev2_initiate_sa_init, "<profile_name>") \
20588 _(ikev2_initiate_del_ike_sa, "<ispi>") \
20589 _(ikev2_initiate_del_child_sa, "<ispi>") \
20590 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
20591 _(delete_loopback,"sw_if_index <nn>") \
20592 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20593 _(map_add_domain, \
20594 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
20595 "ip6-src <ip6addr> " \
20596 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
20597 _(map_del_domain, "index <n>") \
20598 _(map_add_del_rule, \
20599 "index <n> psid <n> dst <ip6addr> [del]") \
20600 _(map_domain_dump, "") \
20601 _(map_rule_dump, "index <map-domain>") \
20602 _(want_interface_events, "enable|disable") \
20603 _(want_stats,"enable|disable") \
20604 _(get_first_msg_id, "client <name>") \
20605 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20606 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20607 "fib-id <nn> [ip4][ip6][default]") \
20608 _(get_node_graph, " ") \
20609 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20610 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20611 _(ioam_disable, "") \
20612 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20613 " sw_if_index <sw_if_index> p <priority> " \
20614 "w <weight>] [del]") \
20615 _(one_add_del_locator, "locator-set <locator_name> " \
20616 "iface <intf> | sw_if_index <sw_if_index> " \
20617 "p <priority> w <weight> [del]") \
20618 _(one_add_del_local_eid,"vni <vni> eid " \
20619 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20620 "locator-set <locator_name> [del]" \
20621 "[key-id sha1|sha256 secret-key <secret-key>]")\
20622 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20623 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20624 _(one_enable_disable, "enable|disable") \
20625 _(one_map_register_enable_disable, "enable|disable") \
20626 _(one_map_register_fallback_threshold, "<value>") \
20627 _(one_rloc_probe_enable_disable, "enable|disable") \
20628 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20630 "rloc <locator> p <prio> " \
20631 "w <weight> [rloc <loc> ... ] " \
20632 "action <action> [del-all]") \
20633 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20635 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20636 _(one_use_petr, "ip-address> | disable") \
20637 _(one_map_request_mode, "src-dst|dst-only") \
20638 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20639 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20640 _(one_locator_set_dump, "[local | remote]") \
20641 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20642 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20643 "[local] | [remote]") \
20644 _(one_add_del_ndp_entry, "[del] mac <mac> bd <bd> ip6 <ip6>") \
20645 _(one_ndp_bd_get, "") \
20646 _(one_ndp_entries_get, "bd <bridge-domain>") \
20647 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20648 _(one_l2_arp_bd_get, "") \
20649 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20650 _(one_stats_enable_disable, "enable|disalbe") \
20651 _(show_one_stats_enable_disable, "") \
20652 _(one_eid_table_vni_dump, "") \
20653 _(one_eid_table_map_dump, "l2|l3") \
20654 _(one_map_resolver_dump, "") \
20655 _(one_map_server_dump, "") \
20656 _(one_adjacencies_get, "vni <vni>") \
20657 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20658 _(show_one_rloc_probe_state, "") \
20659 _(show_one_map_register_state, "") \
20660 _(show_one_status, "") \
20661 _(one_stats_dump, "") \
20662 _(one_stats_flush, "") \
20663 _(one_get_map_request_itr_rlocs, "") \
20664 _(one_map_register_set_ttl, "<ttl>") \
20665 _(show_one_nsh_mapping, "") \
20666 _(show_one_pitr, "") \
20667 _(show_one_use_petr, "") \
20668 _(show_one_map_request_mode, "") \
20669 _(show_one_map_register_ttl, "") \
20670 _(show_one_map_register_fallback_threshold, "") \
20671 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20672 " sw_if_index <sw_if_index> p <priority> " \
20673 "w <weight>] [del]") \
20674 _(lisp_add_del_locator, "locator-set <locator_name> " \
20675 "iface <intf> | sw_if_index <sw_if_index> " \
20676 "p <priority> w <weight> [del]") \
20677 _(lisp_add_del_local_eid,"vni <vni> eid " \
20678 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20679 "locator-set <locator_name> [del]" \
20680 "[key-id sha1|sha256 secret-key <secret-key>]") \
20681 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20682 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20683 _(lisp_enable_disable, "enable|disable") \
20684 _(lisp_map_register_enable_disable, "enable|disable") \
20685 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20686 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20688 "rloc <locator> p <prio> " \
20689 "w <weight> [rloc <loc> ... ] " \
20690 "action <action> [del-all]") \
20691 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20693 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20694 _(lisp_use_petr, "<ip-address> | disable") \
20695 _(lisp_map_request_mode, "src-dst|dst-only") \
20696 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20697 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20698 _(lisp_locator_set_dump, "[local | remote]") \
20699 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20700 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20701 "[local] | [remote]") \
20702 _(lisp_eid_table_vni_dump, "") \
20703 _(lisp_eid_table_map_dump, "l2|l3") \
20704 _(lisp_map_resolver_dump, "") \
20705 _(lisp_map_server_dump, "") \
20706 _(lisp_adjacencies_get, "vni <vni>") \
20707 _(gpe_fwd_entry_vnis_get, "") \
20708 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20709 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20710 "[table <table-id>]") \
20711 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20712 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20713 _(gpe_set_encap_mode, "lisp|vxlan") \
20714 _(gpe_get_encap_mode, "") \
20715 _(lisp_gpe_add_del_iface, "up|down") \
20716 _(lisp_gpe_enable_disable, "enable|disable") \
20717 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20718 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20719 _(show_lisp_rloc_probe_state, "") \
20720 _(show_lisp_map_register_state, "") \
20721 _(show_lisp_status, "") \
20722 _(lisp_get_map_request_itr_rlocs, "") \
20723 _(show_lisp_pitr, "") \
20724 _(show_lisp_use_petr, "") \
20725 _(show_lisp_map_request_mode, "") \
20726 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20727 _(af_packet_delete, "name <host interface name>") \
20728 _(policer_add_del, "name <policer name> <params> [del]") \
20729 _(policer_dump, "[name <policer name>]") \
20730 _(policer_classify_set_interface, \
20731 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20732 " [l2-table <nn>] [del]") \
20733 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20734 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
20735 "[master|slave]") \
20736 _(netmap_delete, "name <interface name>") \
20737 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20738 _(mpls_fib_dump, "") \
20739 _(classify_table_ids, "") \
20740 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20741 _(classify_table_info, "table_id <nn>") \
20742 _(classify_session_dump, "table_id <nn>") \
20743 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20744 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20745 "[template_interval <nn>] [udp_checksum]") \
20746 _(ipfix_exporter_dump, "") \
20747 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20748 _(ipfix_classify_stream_dump, "") \
20749 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20750 _(ipfix_classify_table_dump, "") \
20751 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20752 _(sw_interface_span_dump, "[l2]") \
20753 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20754 _(pg_create_interface, "if_id <nn>") \
20755 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20756 _(pg_enable_disable, "[stream <id>] disable") \
20757 _(ip_source_and_port_range_check_add_del, \
20758 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20759 _(ip_source_and_port_range_check_interface_add_del, \
20760 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20761 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20762 _(ipsec_gre_add_del_tunnel, \
20763 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
20764 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
20765 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20766 _(l2_interface_pbb_tag_rewrite, \
20767 "<intfc> | sw_if_index <nn> \n" \
20768 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20769 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20770 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20771 _(flow_classify_set_interface, \
20772 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20773 _(flow_classify_dump, "type [ip4|ip6]") \
20774 _(ip_fib_dump, "") \
20775 _(ip_mfib_dump, "") \
20776 _(ip6_fib_dump, "") \
20777 _(ip6_mfib_dump, "") \
20778 _(feature_enable_disable, "arc_name <arc_name> " \
20779 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20780 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20782 _(l2_xconnect_dump, "") \
20783 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
20784 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
20785 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20786 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20787 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20788 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20789 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]") \
20790 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]")
20792 /* List of command functions, CLI names map directly to functions */
20793 #define foreach_cli_function \
20794 _(comment, "usage: comment <ignore-rest-of-line>") \
20795 _(dump_interface_table, "usage: dump_interface_table") \
20796 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20797 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20798 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20799 _(dump_stats_table, "usage: dump_stats_table") \
20800 _(dump_macro_table, "usage: dump_macro_table ") \
20801 _(dump_node_table, "usage: dump_node_table") \
20802 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20803 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20804 _(echo, "usage: echo <message>") \
20805 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20806 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20807 _(help, "usage: help") \
20808 _(q, "usage: quit") \
20809 _(quit, "usage: quit") \
20810 _(search_node_table, "usage: search_node_table <name>...") \
20811 _(set, "usage: set <variable-name> <value>") \
20812 _(script, "usage: script <file-name>") \
20813 _(unset, "usage: unset <variable-name>")
20815 static void vl_api_##n##_t_handler_uni \
20816 (vl_api_##n##_t * mp) \
20818 vat_main_t * vam = &vat_main; \
20819 if (vam->json_output) { \
20820 vl_api_##n##_t_handler_json(mp); \
20822 vl_api_##n##_t_handler(mp); \
20825 foreach_vpe_api_reply_msg;
20826 #if VPP_API_TEST_BUILTIN == 0
20827 foreach_standalone_reply_msg;
20832 vat_api_hookup (vat_main_t * vam)
20835 vl_msg_api_set_handlers(VL_API_##N, #n, \
20836 vl_api_##n##_t_handler_uni, \
20838 vl_api_##n##_t_endian, \
20839 vl_api_##n##_t_print, \
20840 sizeof(vl_api_##n##_t), 1);
20841 foreach_vpe_api_reply_msg;
20842 #if VPP_API_TEST_BUILTIN == 0
20843 foreach_standalone_reply_msg;
20847 #if (VPP_API_TEST_BUILTIN==0)
20848 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20850 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20852 vam->function_by_name = hash_create_string (0, sizeof (uword));
20854 vam->help_by_name = hash_create_string (0, sizeof (uword));
20857 /* API messages we can send */
20858 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20859 foreach_vpe_api_msg;
20863 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20864 foreach_vpe_api_msg;
20867 /* CLI functions */
20868 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20869 foreach_cli_function;
20873 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20874 foreach_cli_function;
20878 #if VPP_API_TEST_BUILTIN
20879 static clib_error_t *
20880 vat_api_hookup_shim (vlib_main_t * vm)
20882 vat_api_hookup (&vat_main);
20886 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20890 * fd.io coding-style-patch-verification: ON
20893 * eval: (c-set-style "gnu")