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_l2_arp_entries_get_reply_t_handler
3397 (vl_api_one_l2_arp_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_ip4_address, &mp->entries[i].ip4,
3410 format_ethernet_address, mp->entries[i].mac);
3413 vam->retval = retval;
3414 vam->result_ready = 1;
3418 vl_api_one_l2_arp_entries_get_reply_t_handler_json
3419 (vl_api_one_l2_arp_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_l2_arp_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_ip4_address, &arp_entry->ip4);
3448 vat_json_object_add_string_copy (e, "ip4", 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_bd_get_reply_t_handler
3462 (vl_api_one_l2_arp_bd_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++)
3475 print (vam->ofp, "%d", clib_net_to_host_u32 (mp->bridge_domains[i]));
3479 vam->retval = retval;
3480 vam->result_ready = 1;
3484 vl_api_one_l2_arp_bd_get_reply_t_handler_json
3485 (vl_api_one_l2_arp_bd_get_reply_t * mp)
3487 vat_main_t *vam = &vat_main;
3488 vat_json_node_t root;
3490 int retval = clib_net_to_host_u32 (mp->retval);
3495 n = clib_net_to_host_u32 (mp->count);
3496 vat_json_init_array (&root);
3498 for (i = 0; i < n; i++)
3500 vat_json_array_add_uint (&root,
3501 clib_net_to_host_u32 (mp->bridge_domains[i]));
3504 vat_json_print (vam->ofp, &root);
3505 vat_json_free (&root);
3508 vam->retval = retval;
3509 vam->result_ready = 1;
3513 vl_api_one_adjacencies_get_reply_t_handler
3514 (vl_api_one_adjacencies_get_reply_t * mp)
3516 vat_main_t *vam = &vat_main;
3518 int retval = clib_net_to_host_u32 (mp->retval);
3519 vl_api_one_adjacency_t *a;
3524 n = clib_net_to_host_u32 (mp->count);
3526 for (i = 0; i < n; i++)
3528 a = &mp->adjacencies[i];
3529 print (vam->ofp, "%U %40U",
3530 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
3531 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
3535 vam->retval = retval;
3536 vam->result_ready = 1;
3540 vl_api_one_adjacencies_get_reply_t_handler_json
3541 (vl_api_one_adjacencies_get_reply_t * mp)
3544 vat_main_t *vam = &vat_main;
3545 vat_json_node_t *e = 0, root;
3547 int retval = clib_net_to_host_u32 (mp->retval);
3548 vl_api_one_adjacency_t *a;
3553 n = clib_net_to_host_u32 (mp->count);
3554 vat_json_init_array (&root);
3556 for (i = 0; i < n; i++)
3558 e = vat_json_array_add (&root);
3559 a = &mp->adjacencies[i];
3561 vat_json_init_object (e);
3562 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
3563 a->leid_prefix_len);
3565 vat_json_object_add_string_copy (e, "leid", s);
3568 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3569 a->reid_prefix_len);
3571 vat_json_object_add_string_copy (e, "reid", s);
3575 vat_json_print (vam->ofp, &root);
3576 vat_json_free (&root);
3579 vam->retval = retval;
3580 vam->result_ready = 1;
3584 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3586 vat_main_t *vam = &vat_main;
3588 print (vam->ofp, "%=20U",
3589 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3594 vl_api_one_map_server_details_t_handler_json
3595 (vl_api_one_map_server_details_t * mp)
3597 vat_main_t *vam = &vat_main;
3598 vat_json_node_t *node = NULL;
3599 struct in6_addr ip6;
3602 if (VAT_JSON_ARRAY != vam->json_tree.type)
3604 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3605 vat_json_init_array (&vam->json_tree);
3607 node = vat_json_array_add (&vam->json_tree);
3609 vat_json_init_object (node);
3612 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3613 vat_json_object_add_ip6 (node, "map-server", ip6);
3617 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3618 vat_json_object_add_ip4 (node, "map-server", ip4);
3623 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3626 vat_main_t *vam = &vat_main;
3628 print (vam->ofp, "%=20U",
3629 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3634 vl_api_one_map_resolver_details_t_handler_json
3635 (vl_api_one_map_resolver_details_t * mp)
3637 vat_main_t *vam = &vat_main;
3638 vat_json_node_t *node = NULL;
3639 struct in6_addr ip6;
3642 if (VAT_JSON_ARRAY != vam->json_tree.type)
3644 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3645 vat_json_init_array (&vam->json_tree);
3647 node = vat_json_array_add (&vam->json_tree);
3649 vat_json_init_object (node);
3652 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3653 vat_json_object_add_ip6 (node, "map resolver", ip6);
3657 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3658 vat_json_object_add_ip4 (node, "map resolver", ip4);
3663 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3665 vat_main_t *vam = &vat_main;
3666 i32 retval = ntohl (mp->retval);
3670 print (vam->ofp, "feature: %s\ngpe: %s",
3671 mp->feature_status ? "enabled" : "disabled",
3672 mp->gpe_status ? "enabled" : "disabled");
3675 vam->retval = retval;
3676 vam->result_ready = 1;
3680 vl_api_show_one_status_reply_t_handler_json
3681 (vl_api_show_one_status_reply_t * mp)
3683 vat_main_t *vam = &vat_main;
3684 vat_json_node_t node;
3685 u8 *gpe_status = NULL;
3686 u8 *feature_status = NULL;
3688 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3689 feature_status = format (0, "%s",
3690 mp->feature_status ? "enabled" : "disabled");
3691 vec_add1 (gpe_status, 0);
3692 vec_add1 (feature_status, 0);
3694 vat_json_init_object (&node);
3695 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3696 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3698 vec_free (gpe_status);
3699 vec_free (feature_status);
3701 vat_json_print (vam->ofp, &node);
3702 vat_json_free (&node);
3704 vam->retval = ntohl (mp->retval);
3705 vam->result_ready = 1;
3709 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3710 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3712 vat_main_t *vam = &vat_main;
3713 i32 retval = ntohl (mp->retval);
3717 print (vam->ofp, "%=20s", mp->locator_set_name);
3720 vam->retval = retval;
3721 vam->result_ready = 1;
3725 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3726 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3728 vat_main_t *vam = &vat_main;
3729 vat_json_node_t *node = NULL;
3731 if (VAT_JSON_ARRAY != vam->json_tree.type)
3733 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3734 vat_json_init_array (&vam->json_tree);
3736 node = vat_json_array_add (&vam->json_tree);
3738 vat_json_init_object (node);
3739 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3741 vat_json_print (vam->ofp, node);
3742 vat_json_free (node);
3744 vam->retval = ntohl (mp->retval);
3745 vam->result_ready = 1;
3749 format_lisp_map_request_mode (u8 * s, va_list * args)
3751 u32 mode = va_arg (*args, u32);
3756 return format (0, "dst-only");
3758 return format (0, "src-dst");
3764 vl_api_show_one_map_request_mode_reply_t_handler
3765 (vl_api_show_one_map_request_mode_reply_t * mp)
3767 vat_main_t *vam = &vat_main;
3768 i32 retval = ntohl (mp->retval);
3772 u32 mode = mp->mode;
3773 print (vam->ofp, "map_request_mode: %U",
3774 format_lisp_map_request_mode, mode);
3777 vam->retval = retval;
3778 vam->result_ready = 1;
3782 vl_api_show_one_map_request_mode_reply_t_handler_json
3783 (vl_api_show_one_map_request_mode_reply_t * mp)
3785 vat_main_t *vam = &vat_main;
3786 vat_json_node_t node;
3791 s = format (0, "%U", format_lisp_map_request_mode, mode);
3794 vat_json_init_object (&node);
3795 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3796 vat_json_print (vam->ofp, &node);
3797 vat_json_free (&node);
3800 vam->retval = ntohl (mp->retval);
3801 vam->result_ready = 1;
3805 vl_api_show_one_use_petr_reply_t_handler
3806 (vl_api_show_one_use_petr_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 i32 retval = ntohl (mp->retval);
3813 print (vam->ofp, "%s\n", mp->status ? "enabled" : "disabled");
3816 print (vam->ofp, "Proxy-ETR address; %U",
3817 mp->is_ip4 ? format_ip4_address : format_ip6_address,
3822 vam->retval = retval;
3823 vam->result_ready = 1;
3827 vl_api_show_one_use_petr_reply_t_handler_json
3828 (vl_api_show_one_use_petr_reply_t * mp)
3830 vat_main_t *vam = &vat_main;
3831 vat_json_node_t node;
3834 struct in6_addr ip6;
3836 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3837 vec_add1 (status, 0);
3839 vat_json_init_object (&node);
3840 vat_json_object_add_string_copy (&node, "status", status);
3845 clib_memcpy (&ip6, mp->address, sizeof (ip6));
3846 vat_json_object_add_ip6 (&node, "address", ip6);
3850 clib_memcpy (&ip4, mp->address, sizeof (ip4));
3851 vat_json_object_add_ip4 (&node, "address", ip4);
3857 vat_json_print (vam->ofp, &node);
3858 vat_json_free (&node);
3860 vam->retval = ntohl (mp->retval);
3861 vam->result_ready = 1;
3865 vl_api_show_one_nsh_mapping_reply_t_handler
3866 (vl_api_show_one_nsh_mapping_reply_t * mp)
3868 vat_main_t *vam = &vat_main;
3869 i32 retval = ntohl (mp->retval);
3873 print (vam->ofp, "%-20s%-16s",
3874 mp->is_set ? "set" : "not-set",
3875 mp->is_set ? (char *) mp->locator_set_name : "");
3878 vam->retval = retval;
3879 vam->result_ready = 1;
3883 vl_api_show_one_nsh_mapping_reply_t_handler_json
3884 (vl_api_show_one_nsh_mapping_reply_t * mp)
3886 vat_main_t *vam = &vat_main;
3887 vat_json_node_t node;
3890 status = format (0, "%s", mp->is_set ? "yes" : "no");
3891 vec_add1 (status, 0);
3893 vat_json_init_object (&node);
3894 vat_json_object_add_string_copy (&node, "is_set", status);
3897 vat_json_object_add_string_copy (&node, "locator_set",
3898 mp->locator_set_name);
3903 vat_json_print (vam->ofp, &node);
3904 vat_json_free (&node);
3906 vam->retval = ntohl (mp->retval);
3907 vam->result_ready = 1;
3911 vl_api_show_one_map_register_ttl_reply_t_handler
3912 (vl_api_show_one_map_register_ttl_reply_t * mp)
3914 vat_main_t *vam = &vat_main;
3915 i32 retval = ntohl (mp->retval);
3917 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3921 print (vam->ofp, "ttl: %u", mp->ttl);
3924 vam->retval = retval;
3925 vam->result_ready = 1;
3929 vl_api_show_one_map_register_ttl_reply_t_handler_json
3930 (vl_api_show_one_map_register_ttl_reply_t * mp)
3932 vat_main_t *vam = &vat_main;
3933 vat_json_node_t node;
3935 vl_api_show_one_map_register_ttl_reply_t_endian (mp);
3936 vat_json_init_object (&node);
3937 vat_json_object_add_uint (&node, "ttl", mp->ttl);
3939 vat_json_print (vam->ofp, &node);
3940 vat_json_free (&node);
3942 vam->retval = ntohl (mp->retval);
3943 vam->result_ready = 1;
3947 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3949 vat_main_t *vam = &vat_main;
3950 i32 retval = ntohl (mp->retval);
3954 print (vam->ofp, "%-20s%-16s",
3955 mp->status ? "enabled" : "disabled",
3956 mp->status ? (char *) mp->locator_set_name : "");
3959 vam->retval = retval;
3960 vam->result_ready = 1;
3964 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3966 vat_main_t *vam = &vat_main;
3967 vat_json_node_t node;
3970 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3971 vec_add1 (status, 0);
3973 vat_json_init_object (&node);
3974 vat_json_object_add_string_copy (&node, "status", status);
3977 vat_json_object_add_string_copy (&node, "locator_set",
3978 mp->locator_set_name);
3983 vat_json_print (vam->ofp, &node);
3984 vat_json_free (&node);
3986 vam->retval = ntohl (mp->retval);
3987 vam->result_ready = 1;
3991 format_policer_type (u8 * s, va_list * va)
3993 u32 i = va_arg (*va, u32);
3995 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3996 s = format (s, "1r2c");
3997 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3998 s = format (s, "1r3c");
3999 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
4000 s = format (s, "2r3c-2698");
4001 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
4002 s = format (s, "2r3c-4115");
4003 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
4004 s = format (s, "2r3c-mef5cf1");
4006 s = format (s, "ILLEGAL");
4011 format_policer_rate_type (u8 * s, va_list * va)
4013 u32 i = va_arg (*va, u32);
4015 if (i == SSE2_QOS_RATE_KBPS)
4016 s = format (s, "kbps");
4017 else if (i == SSE2_QOS_RATE_PPS)
4018 s = format (s, "pps");
4020 s = format (s, "ILLEGAL");
4025 format_policer_round_type (u8 * s, va_list * va)
4027 u32 i = va_arg (*va, u32);
4029 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
4030 s = format (s, "closest");
4031 else if (i == SSE2_QOS_ROUND_TO_UP)
4032 s = format (s, "up");
4033 else if (i == SSE2_QOS_ROUND_TO_DOWN)
4034 s = format (s, "down");
4036 s = format (s, "ILLEGAL");
4041 format_policer_action_type (u8 * s, va_list * va)
4043 u32 i = va_arg (*va, u32);
4045 if (i == SSE2_QOS_ACTION_DROP)
4046 s = format (s, "drop");
4047 else if (i == SSE2_QOS_ACTION_TRANSMIT)
4048 s = format (s, "transmit");
4049 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4050 s = format (s, "mark-and-transmit");
4052 s = format (s, "ILLEGAL");
4057 format_dscp (u8 * s, va_list * va)
4059 u32 i = va_arg (*va, u32);
4064 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
4068 return format (s, "ILLEGAL");
4070 s = format (s, "%s", t);
4075 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
4077 vat_main_t *vam = &vat_main;
4078 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
4080 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4081 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4083 conform_dscp_str = format (0, "");
4085 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4086 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4088 exceed_dscp_str = format (0, "");
4090 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4091 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4093 violate_dscp_str = format (0, "");
4095 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
4096 "rate type %U, round type %U, %s rate, %s color-aware, "
4097 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
4098 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
4099 "conform action %U%s, exceed action %U%s, violate action %U%s",
4101 format_policer_type, mp->type,
4104 clib_net_to_host_u64 (mp->cb),
4105 clib_net_to_host_u64 (mp->eb),
4106 format_policer_rate_type, mp->rate_type,
4107 format_policer_round_type, mp->round_type,
4108 mp->single_rate ? "single" : "dual",
4109 mp->color_aware ? "is" : "not",
4110 ntohl (mp->cir_tokens_per_period),
4111 ntohl (mp->pir_tokens_per_period),
4113 ntohl (mp->current_limit),
4114 ntohl (mp->current_bucket),
4115 ntohl (mp->extended_limit),
4116 ntohl (mp->extended_bucket),
4117 clib_net_to_host_u64 (mp->last_update_time),
4118 format_policer_action_type, mp->conform_action_type,
4120 format_policer_action_type, mp->exceed_action_type,
4122 format_policer_action_type, mp->violate_action_type,
4125 vec_free (conform_dscp_str);
4126 vec_free (exceed_dscp_str);
4127 vec_free (violate_dscp_str);
4130 static void vl_api_policer_details_t_handler_json
4131 (vl_api_policer_details_t * mp)
4133 vat_main_t *vam = &vat_main;
4134 vat_json_node_t *node;
4135 u8 *rate_type_str, *round_type_str, *type_str;
4136 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
4138 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
4140 format (0, "%U", format_policer_round_type, mp->round_type);
4141 type_str = format (0, "%U", format_policer_type, mp->type);
4142 conform_action_str = format (0, "%U", format_policer_action_type,
4143 mp->conform_action_type);
4144 exceed_action_str = format (0, "%U", format_policer_action_type,
4145 mp->exceed_action_type);
4146 violate_action_str = format (0, "%U", format_policer_action_type,
4147 mp->violate_action_type);
4149 if (VAT_JSON_ARRAY != vam->json_tree.type)
4151 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4152 vat_json_init_array (&vam->json_tree);
4154 node = vat_json_array_add (&vam->json_tree);
4156 vat_json_init_object (node);
4157 vat_json_object_add_string_copy (node, "name", mp->name);
4158 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
4159 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
4160 vat_json_object_add_uint (node, "cb", clib_net_to_host_u64 (mp->cb));
4161 vat_json_object_add_uint (node, "eb", clib_net_to_host_u64 (mp->eb));
4162 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
4163 vat_json_object_add_string_copy (node, "round_type", round_type_str);
4164 vat_json_object_add_string_copy (node, "type", type_str);
4165 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
4166 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
4167 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
4168 vat_json_object_add_uint (node, "cir_tokens_per_period",
4169 ntohl (mp->cir_tokens_per_period));
4170 vat_json_object_add_uint (node, "eir_tokens_per_period",
4171 ntohl (mp->pir_tokens_per_period));
4172 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
4173 vat_json_object_add_uint (node, "current_bucket",
4174 ntohl (mp->current_bucket));
4175 vat_json_object_add_uint (node, "extended_limit",
4176 ntohl (mp->extended_limit));
4177 vat_json_object_add_uint (node, "extended_bucket",
4178 ntohl (mp->extended_bucket));
4179 vat_json_object_add_uint (node, "last_update_time",
4180 ntohl (mp->last_update_time));
4181 vat_json_object_add_string_copy (node, "conform_action",
4182 conform_action_str);
4183 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4185 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
4186 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
4187 vec_free (dscp_str);
4189 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
4190 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4192 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
4193 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
4194 vec_free (dscp_str);
4196 vat_json_object_add_string_copy (node, "violate_action",
4197 violate_action_str);
4198 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
4200 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
4201 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
4202 vec_free (dscp_str);
4205 vec_free (rate_type_str);
4206 vec_free (round_type_str);
4207 vec_free (type_str);
4208 vec_free (conform_action_str);
4209 vec_free (exceed_action_str);
4210 vec_free (violate_action_str);
4214 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
4217 vat_main_t *vam = &vat_main;
4218 int i, count = ntohl (mp->count);
4221 print (vam->ofp, "classify table ids (%d) : ", count);
4222 for (i = 0; i < count; i++)
4224 print (vam->ofp, "%d", ntohl (mp->ids[i]));
4225 print (vam->ofp, (i < count - 1) ? "," : "");
4227 vam->retval = ntohl (mp->retval);
4228 vam->result_ready = 1;
4232 vl_api_classify_table_ids_reply_t_handler_json
4233 (vl_api_classify_table_ids_reply_t * mp)
4235 vat_main_t *vam = &vat_main;
4236 int i, count = ntohl (mp->count);
4240 vat_json_node_t node;
4242 vat_json_init_object (&node);
4243 for (i = 0; i < count; i++)
4245 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
4247 vat_json_print (vam->ofp, &node);
4248 vat_json_free (&node);
4250 vam->retval = ntohl (mp->retval);
4251 vam->result_ready = 1;
4255 vl_api_classify_table_by_interface_reply_t_handler
4256 (vl_api_classify_table_by_interface_reply_t * mp)
4258 vat_main_t *vam = &vat_main;
4261 table_id = ntohl (mp->l2_table_id);
4263 print (vam->ofp, "l2 table id : %d", table_id);
4265 print (vam->ofp, "l2 table id : No input ACL tables configured");
4266 table_id = ntohl (mp->ip4_table_id);
4268 print (vam->ofp, "ip4 table id : %d", table_id);
4270 print (vam->ofp, "ip4 table id : No input ACL tables configured");
4271 table_id = ntohl (mp->ip6_table_id);
4273 print (vam->ofp, "ip6 table id : %d", table_id);
4275 print (vam->ofp, "ip6 table id : No input ACL tables configured");
4276 vam->retval = ntohl (mp->retval);
4277 vam->result_ready = 1;
4281 vl_api_classify_table_by_interface_reply_t_handler_json
4282 (vl_api_classify_table_by_interface_reply_t * mp)
4284 vat_main_t *vam = &vat_main;
4285 vat_json_node_t node;
4287 vat_json_init_object (&node);
4289 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
4290 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
4291 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
4293 vat_json_print (vam->ofp, &node);
4294 vat_json_free (&node);
4296 vam->retval = ntohl (mp->retval);
4297 vam->result_ready = 1;
4300 static void vl_api_policer_add_del_reply_t_handler
4301 (vl_api_policer_add_del_reply_t * mp)
4303 vat_main_t *vam = &vat_main;
4304 i32 retval = ntohl (mp->retval);
4305 if (vam->async_mode)
4307 vam->async_errors += (retval < 0);
4311 vam->retval = retval;
4312 vam->result_ready = 1;
4313 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
4315 * Note: this is just barely thread-safe, depends on
4316 * the main thread spinning waiting for an answer...
4318 errmsg ("policer index %d", ntohl (mp->policer_index));
4322 static void vl_api_policer_add_del_reply_t_handler_json
4323 (vl_api_policer_add_del_reply_t * mp)
4325 vat_main_t *vam = &vat_main;
4326 vat_json_node_t node;
4328 vat_json_init_object (&node);
4329 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4330 vat_json_object_add_uint (&node, "policer_index",
4331 ntohl (mp->policer_index));
4333 vat_json_print (vam->ofp, &node);
4334 vat_json_free (&node);
4336 vam->retval = ntohl (mp->retval);
4337 vam->result_ready = 1;
4340 /* Format hex dump. */
4342 format_hex_bytes (u8 * s, va_list * va)
4344 u8 *bytes = va_arg (*va, u8 *);
4345 int n_bytes = va_arg (*va, int);
4348 /* Print short or long form depending on byte count. */
4349 uword short_form = n_bytes <= 32;
4350 uword indent = format_get_indent (s);
4355 for (i = 0; i < n_bytes; i++)
4357 if (!short_form && (i % 32) == 0)
4358 s = format (s, "%08x: ", i);
4359 s = format (s, "%02x", bytes[i]);
4360 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
4361 s = format (s, "\n%U", format_white_space, indent);
4368 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
4371 vat_main_t *vam = &vat_main;
4372 i32 retval = ntohl (mp->retval);
4375 print (vam->ofp, "classify table info :");
4376 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
4377 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
4378 ntohl (mp->miss_next_index));
4379 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
4380 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
4381 ntohl (mp->match_n_vectors));
4382 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
4383 ntohl (mp->mask_length));
4385 vam->retval = retval;
4386 vam->result_ready = 1;
4390 vl_api_classify_table_info_reply_t_handler_json
4391 (vl_api_classify_table_info_reply_t * mp)
4393 vat_main_t *vam = &vat_main;
4394 vat_json_node_t node;
4396 i32 retval = ntohl (mp->retval);
4399 vat_json_init_object (&node);
4401 vat_json_object_add_int (&node, "sessions",
4402 ntohl (mp->active_sessions));
4403 vat_json_object_add_int (&node, "nexttbl",
4404 ntohl (mp->next_table_index));
4405 vat_json_object_add_int (&node, "nextnode",
4406 ntohl (mp->miss_next_index));
4407 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
4408 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
4409 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
4410 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
4411 ntohl (mp->mask_length), 0);
4412 vat_json_object_add_string_copy (&node, "mask", s);
4414 vat_json_print (vam->ofp, &node);
4415 vat_json_free (&node);
4417 vam->retval = ntohl (mp->retval);
4418 vam->result_ready = 1;
4422 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
4425 vat_main_t *vam = &vat_main;
4427 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
4428 ntohl (mp->hit_next_index), ntohl (mp->advance),
4429 ntohl (mp->opaque_index));
4430 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
4431 ntohl (mp->match_length));
4435 vl_api_classify_session_details_t_handler_json
4436 (vl_api_classify_session_details_t * mp)
4438 vat_main_t *vam = &vat_main;
4439 vat_json_node_t *node = NULL;
4441 if (VAT_JSON_ARRAY != vam->json_tree.type)
4443 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4444 vat_json_init_array (&vam->json_tree);
4446 node = vat_json_array_add (&vam->json_tree);
4448 vat_json_init_object (node);
4449 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
4450 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
4451 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
4453 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
4455 vat_json_object_add_string_copy (node, "match", s);
4458 static void vl_api_pg_create_interface_reply_t_handler
4459 (vl_api_pg_create_interface_reply_t * mp)
4461 vat_main_t *vam = &vat_main;
4463 vam->retval = ntohl (mp->retval);
4464 vam->result_ready = 1;
4467 static void vl_api_pg_create_interface_reply_t_handler_json
4468 (vl_api_pg_create_interface_reply_t * mp)
4470 vat_main_t *vam = &vat_main;
4471 vat_json_node_t node;
4473 i32 retval = ntohl (mp->retval);
4476 vat_json_init_object (&node);
4478 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
4480 vat_json_print (vam->ofp, &node);
4481 vat_json_free (&node);
4483 vam->retval = ntohl (mp->retval);
4484 vam->result_ready = 1;
4487 static void vl_api_policer_classify_details_t_handler
4488 (vl_api_policer_classify_details_t * mp)
4490 vat_main_t *vam = &vat_main;
4492 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4493 ntohl (mp->table_index));
4496 static void vl_api_policer_classify_details_t_handler_json
4497 (vl_api_policer_classify_details_t * mp)
4499 vat_main_t *vam = &vat_main;
4500 vat_json_node_t *node;
4502 if (VAT_JSON_ARRAY != vam->json_tree.type)
4504 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4505 vat_json_init_array (&vam->json_tree);
4507 node = vat_json_array_add (&vam->json_tree);
4509 vat_json_init_object (node);
4510 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4511 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4514 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
4515 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4517 vat_main_t *vam = &vat_main;
4518 i32 retval = ntohl (mp->retval);
4519 if (vam->async_mode)
4521 vam->async_errors += (retval < 0);
4525 vam->retval = retval;
4526 vam->sw_if_index = ntohl (mp->sw_if_index);
4527 vam->result_ready = 1;
4531 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
4532 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
4534 vat_main_t *vam = &vat_main;
4535 vat_json_node_t node;
4537 vat_json_init_object (&node);
4538 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
4539 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
4541 vat_json_print (vam->ofp, &node);
4542 vat_json_free (&node);
4544 vam->retval = ntohl (mp->retval);
4545 vam->result_ready = 1;
4548 static void vl_api_flow_classify_details_t_handler
4549 (vl_api_flow_classify_details_t * mp)
4551 vat_main_t *vam = &vat_main;
4553 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
4554 ntohl (mp->table_index));
4557 static void vl_api_flow_classify_details_t_handler_json
4558 (vl_api_flow_classify_details_t * mp)
4560 vat_main_t *vam = &vat_main;
4561 vat_json_node_t *node;
4563 if (VAT_JSON_ARRAY != vam->json_tree.type)
4565 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
4566 vat_json_init_array (&vam->json_tree);
4568 node = vat_json_array_add (&vam->json_tree);
4570 vat_json_init_object (node);
4571 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
4572 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
4575 #define vl_api_vnet_interface_simple_counters_t_endian vl_noop_handler
4576 #define vl_api_vnet_interface_simple_counters_t_print vl_noop_handler
4577 #define vl_api_vnet_interface_combined_counters_t_endian vl_noop_handler
4578 #define vl_api_vnet_interface_combined_counters_t_print vl_noop_handler
4579 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
4580 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
4581 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
4582 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
4583 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
4584 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
4585 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
4586 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
4587 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
4588 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
4589 #define vl_api_one_l2_arp_bd_get_reply_t_print vl_noop_handler
4590 #define vl_api_one_l2_arp_entries_get_reply_t_endian vl_noop_handler
4591 #define vl_api_one_l2_arp_entries_get_reply_t_print vl_noop_handler
4592 #define vl_api_one_l2_arp_bd_get_reply_t_endian vl_noop_handler
4595 * Generate boilerplate reply handlers, which
4596 * dig the return value out of the xxx_reply_t API message,
4597 * stick it into vam->retval, and set vam->result_ready
4599 * Could also do this by pointing N message decode slots at
4600 * a single function, but that could break in subtle ways.
4603 #define foreach_standard_reply_retval_handler \
4604 _(sw_interface_set_flags_reply) \
4605 _(sw_interface_add_del_address_reply) \
4606 _(sw_interface_set_table_reply) \
4607 _(sw_interface_set_mpls_enable_reply) \
4608 _(sw_interface_set_vpath_reply) \
4609 _(sw_interface_set_vxlan_bypass_reply) \
4610 _(sw_interface_set_vxlan_gpe_bypass_reply) \
4611 _(sw_interface_set_l2_bridge_reply) \
4612 _(bridge_domain_add_del_reply) \
4613 _(sw_interface_set_l2_xconnect_reply) \
4614 _(l2fib_add_del_reply) \
4615 _(l2fib_flush_int_reply) \
4616 _(l2fib_flush_bd_reply) \
4617 _(ip_add_del_route_reply) \
4618 _(ip_table_add_del_reply) \
4619 _(ip_mroute_add_del_reply) \
4620 _(mpls_route_add_del_reply) \
4621 _(mpls_table_add_del_reply) \
4622 _(mpls_ip_bind_unbind_reply) \
4623 _(proxy_arp_add_del_reply) \
4624 _(proxy_arp_intfc_enable_disable_reply) \
4625 _(sw_interface_set_unnumbered_reply) \
4626 _(ip_neighbor_add_del_reply) \
4627 _(reset_vrf_reply) \
4628 _(oam_add_del_reply) \
4629 _(reset_fib_reply) \
4630 _(dhcp_proxy_config_reply) \
4631 _(dhcp_proxy_set_vss_reply) \
4632 _(dhcp_client_config_reply) \
4633 _(set_ip_flow_hash_reply) \
4634 _(sw_interface_ip6_enable_disable_reply) \
4635 _(sw_interface_ip6_set_link_local_address_reply) \
4636 _(ip6nd_proxy_add_del_reply) \
4637 _(sw_interface_ip6nd_ra_prefix_reply) \
4638 _(sw_interface_ip6nd_ra_config_reply) \
4639 _(set_arp_neighbor_limit_reply) \
4640 _(l2_patch_add_del_reply) \
4641 _(sr_policy_add_reply) \
4642 _(sr_policy_mod_reply) \
4643 _(sr_policy_del_reply) \
4644 _(sr_localsid_add_del_reply) \
4645 _(sr_steering_add_del_reply) \
4646 _(classify_add_del_session_reply) \
4647 _(classify_set_interface_ip_table_reply) \
4648 _(classify_set_interface_l2_tables_reply) \
4649 _(l2tpv3_set_tunnel_cookies_reply) \
4650 _(l2tpv3_interface_enable_disable_reply) \
4651 _(l2tpv3_set_lookup_key_reply) \
4652 _(l2_fib_clear_table_reply) \
4653 _(l2_interface_efp_filter_reply) \
4654 _(l2_interface_vlan_tag_rewrite_reply) \
4655 _(modify_vhost_user_if_reply) \
4656 _(delete_vhost_user_if_reply) \
4657 _(want_ip4_arp_events_reply) \
4658 _(want_ip6_nd_events_reply) \
4659 _(want_l2_macs_events_reply) \
4660 _(input_acl_set_interface_reply) \
4661 _(ipsec_spd_add_del_reply) \
4662 _(ipsec_interface_add_del_spd_reply) \
4663 _(ipsec_spd_add_del_entry_reply) \
4664 _(ipsec_sad_add_del_entry_reply) \
4665 _(ipsec_sa_set_key_reply) \
4666 _(ipsec_tunnel_if_add_del_reply) \
4667 _(ikev2_profile_add_del_reply) \
4668 _(ikev2_profile_set_auth_reply) \
4669 _(ikev2_profile_set_id_reply) \
4670 _(ikev2_profile_set_ts_reply) \
4671 _(ikev2_set_local_key_reply) \
4672 _(ikev2_set_responder_reply) \
4673 _(ikev2_set_ike_transforms_reply) \
4674 _(ikev2_set_esp_transforms_reply) \
4675 _(ikev2_set_sa_lifetime_reply) \
4676 _(ikev2_initiate_sa_init_reply) \
4677 _(ikev2_initiate_del_ike_sa_reply) \
4678 _(ikev2_initiate_del_child_sa_reply) \
4679 _(ikev2_initiate_rekey_child_sa_reply) \
4680 _(delete_loopback_reply) \
4681 _(bd_ip_mac_add_del_reply) \
4682 _(map_del_domain_reply) \
4683 _(map_add_del_rule_reply) \
4684 _(want_interface_events_reply) \
4685 _(want_stats_reply) \
4686 _(cop_interface_enable_disable_reply) \
4687 _(cop_whitelist_enable_disable_reply) \
4688 _(sw_interface_clear_stats_reply) \
4689 _(ioam_enable_reply) \
4690 _(ioam_disable_reply) \
4691 _(one_add_del_locator_reply) \
4692 _(one_add_del_local_eid_reply) \
4693 _(one_add_del_remote_mapping_reply) \
4694 _(one_add_del_adjacency_reply) \
4695 _(one_add_del_map_resolver_reply) \
4696 _(one_add_del_map_server_reply) \
4697 _(one_enable_disable_reply) \
4698 _(one_rloc_probe_enable_disable_reply) \
4699 _(one_map_register_enable_disable_reply) \
4700 _(one_map_register_set_ttl_reply) \
4701 _(one_map_register_fallback_threshold_reply) \
4702 _(one_pitr_set_locator_set_reply) \
4703 _(one_map_request_mode_reply) \
4704 _(one_add_del_map_request_itr_rlocs_reply) \
4705 _(one_eid_table_add_del_map_reply) \
4706 _(one_use_petr_reply) \
4707 _(one_stats_enable_disable_reply) \
4708 _(one_add_del_l2_arp_entry_reply) \
4709 _(one_stats_flush_reply) \
4710 _(gpe_enable_disable_reply) \
4711 _(gpe_set_encap_mode_reply) \
4712 _(gpe_add_del_iface_reply) \
4713 _(gpe_add_del_native_fwd_rpath_reply) \
4714 _(af_packet_delete_reply) \
4715 _(policer_classify_set_interface_reply) \
4716 _(netmap_create_reply) \
4717 _(netmap_delete_reply) \
4718 _(set_ipfix_exporter_reply) \
4719 _(set_ipfix_classify_stream_reply) \
4720 _(ipfix_classify_table_add_del_reply) \
4721 _(flow_classify_set_interface_reply) \
4722 _(sw_interface_span_enable_disable_reply) \
4723 _(pg_capture_reply) \
4724 _(pg_enable_disable_reply) \
4725 _(ip_source_and_port_range_check_add_del_reply) \
4726 _(ip_source_and_port_range_check_interface_add_del_reply)\
4727 _(delete_subif_reply) \
4728 _(l2_interface_pbb_tag_rewrite_reply) \
4730 _(feature_enable_disable_reply) \
4731 _(sw_interface_tag_add_del_reply) \
4732 _(sw_interface_set_mtu_reply) \
4733 _(p2p_ethernet_add_reply) \
4734 _(p2p_ethernet_del_reply) \
4735 _(lldp_config_reply) \
4736 _(sw_interface_set_lldp_reply) \
4737 _(tcp_configure_src_addresses_reply)
4740 static void vl_api_##n##_t_handler \
4741 (vl_api_##n##_t * mp) \
4743 vat_main_t * vam = &vat_main; \
4744 i32 retval = ntohl(mp->retval); \
4745 if (vam->async_mode) { \
4746 vam->async_errors += (retval < 0); \
4748 vam->retval = retval; \
4749 vam->result_ready = 1; \
4752 foreach_standard_reply_retval_handler;
4756 static void vl_api_##n##_t_handler_json \
4757 (vl_api_##n##_t * mp) \
4759 vat_main_t * vam = &vat_main; \
4760 vat_json_node_t node; \
4761 vat_json_init_object(&node); \
4762 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4763 vat_json_print(vam->ofp, &node); \
4764 vam->retval = ntohl(mp->retval); \
4765 vam->result_ready = 1; \
4767 foreach_standard_reply_retval_handler;
4771 * Table of message reply handlers, must include boilerplate handlers
4775 #define foreach_vpe_api_reply_msg \
4776 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4777 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4778 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4779 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4780 _(CONTROL_PING_REPLY, control_ping_reply) \
4781 _(CLI_REPLY, cli_reply) \
4782 _(CLI_INBAND_REPLY, cli_inband_reply) \
4783 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4784 sw_interface_add_del_address_reply) \
4785 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4786 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4787 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4788 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4789 _(SW_INTERFACE_SET_VXLAN_GPE_BYPASS_REPLY, sw_interface_set_vxlan_gpe_bypass_reply) \
4790 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4791 sw_interface_set_l2_xconnect_reply) \
4792 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4793 sw_interface_set_l2_bridge_reply) \
4794 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4795 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4796 _(BRIDGE_DOMAIN_SET_MAC_AGE_REPLY, bridge_domain_set_mac_age_reply) \
4797 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4798 _(L2FIB_FLUSH_INT_REPLY, l2fib_flush_int_reply) \
4799 _(L2FIB_FLUSH_BD_REPLY, l2fib_flush_bd_reply) \
4800 _(L2_FLAGS_REPLY, l2_flags_reply) \
4801 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4802 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4803 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4804 _(TAP_DELETE_REPLY, tap_delete_reply) \
4805 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4806 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4807 _(IP_TABLE_ADD_DEL_REPLY, ip_table_add_del_reply) \
4808 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4809 _(MPLS_TABLE_ADD_DEL_REPLY, mpls_table_add_del_reply) \
4810 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4811 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4812 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4813 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4814 proxy_arp_intfc_enable_disable_reply) \
4815 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4816 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4817 sw_interface_set_unnumbered_reply) \
4818 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4819 _(RESET_VRF_REPLY, reset_vrf_reply) \
4820 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4821 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4822 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4823 _(RESET_FIB_REPLY, reset_fib_reply) \
4824 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4825 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4826 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4827 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4828 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4829 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4830 sw_interface_ip6_enable_disable_reply) \
4831 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4832 sw_interface_ip6_set_link_local_address_reply) \
4833 _(IP6ND_PROXY_ADD_DEL_REPLY, ip6nd_proxy_add_del_reply) \
4834 _(IP6ND_PROXY_DETAILS, ip6nd_proxy_details) \
4835 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4836 sw_interface_ip6nd_ra_prefix_reply) \
4837 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4838 sw_interface_ip6nd_ra_config_reply) \
4839 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4840 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4841 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4842 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4843 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4844 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4845 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4846 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4847 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4848 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4849 classify_set_interface_ip_table_reply) \
4850 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4851 classify_set_interface_l2_tables_reply) \
4852 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4853 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4854 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4855 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4856 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4857 l2tpv3_interface_enable_disable_reply) \
4858 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4859 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4860 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4861 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4862 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4863 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4864 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4865 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4866 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4867 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4868 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4869 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4870 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4871 _(SHOW_VERSION_REPLY, show_version_reply) \
4872 _(L2_FIB_TABLE_DETAILS, l2_fib_table_details) \
4873 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4874 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4875 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4876 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4877 _(IP4_ARP_EVENT, ip4_arp_event) \
4878 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4879 _(IP6_ND_EVENT, ip6_nd_event) \
4880 _(WANT_L2_MACS_EVENTS_REPLY, want_l2_macs_events_reply) \
4881 _(L2_MACS_EVENT, l2_macs_event) \
4882 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4883 _(IP_ADDRESS_DETAILS, ip_address_details) \
4884 _(IP_DETAILS, ip_details) \
4885 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4886 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4887 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4888 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4889 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4890 _(IPSEC_TUNNEL_IF_ADD_DEL_REPLY, ipsec_tunnel_if_add_del_reply) \
4891 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4892 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4893 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4894 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4895 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4896 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4897 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4898 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4899 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4900 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4901 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4902 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4903 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4904 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4905 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4906 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4907 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4908 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4909 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4910 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4911 _(MAP_RULE_DETAILS, map_rule_details) \
4912 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4913 _(WANT_STATS_REPLY, want_stats_reply) \
4914 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4915 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4916 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4917 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4918 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4919 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4920 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4921 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4922 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4923 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4924 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4925 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4926 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4927 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4928 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4929 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4930 one_map_register_enable_disable_reply) \
4931 _(ONE_MAP_REGISTER_SET_TTL_REPLY, one_map_register_set_ttl_reply) \
4932 _(ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
4933 one_map_register_fallback_threshold_reply) \
4934 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4935 one_rloc_probe_enable_disable_reply) \
4936 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4937 _(ONE_USE_PETR_REPLY, one_use_petr_reply) \
4938 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4939 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4940 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4941 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4942 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4943 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4944 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4945 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4946 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4947 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4948 _(ONE_STATS_DETAILS, one_stats_details) \
4949 _(ONE_STATS_FLUSH_REPLY, one_stats_flush_reply) \
4950 _(ONE_STATS_ENABLE_DISABLE_REPLY, one_stats_enable_disable_reply) \
4951 _(SHOW_ONE_STATS_ENABLE_DISABLE_REPLY, \
4952 show_one_stats_enable_disable_reply) \
4953 _(ONE_ADD_DEL_L2_ARP_ENTRY_REPLY, one_add_del_l2_arp_entry_reply) \
4954 _(ONE_L2_ARP_BD_GET_REPLY, one_l2_arp_bd_get_reply) \
4955 _(ONE_L2_ARP_ENTRIES_GET_REPLY, one_l2_arp_entries_get_reply) \
4956 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4957 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4958 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4959 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4960 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4961 _(GPE_FWD_ENTRY_VNIS_GET_REPLY, gpe_fwd_entry_vnis_get_reply) \
4962 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4963 _(GPE_NATIVE_FWD_RPATHS_GET_REPLY, gpe_native_fwd_rpaths_get_reply) \
4964 _(GPE_ADD_DEL_NATIVE_FWD_RPATH_REPLY, \
4965 gpe_add_del_native_fwd_rpath_reply) \
4966 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4967 gpe_fwd_entry_path_details) \
4968 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4969 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4970 one_add_del_map_request_itr_rlocs_reply) \
4971 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4972 one_get_map_request_itr_rlocs_reply) \
4973 _(SHOW_ONE_NSH_MAPPING_REPLY, show_one_nsh_mapping_reply) \
4974 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4975 _(SHOW_ONE_USE_PETR_REPLY, show_one_use_petr_reply) \
4976 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4977 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4978 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4979 show_one_map_register_state_reply) \
4980 _(SHOW_ONE_MAP_REGISTER_TTL_REPLY, show_one_map_register_ttl_reply) \
4981 _(SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD_REPLY, \
4982 show_one_map_register_fallback_threshold_reply) \
4983 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4984 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4985 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4986 _(POLICER_DETAILS, policer_details) \
4987 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4988 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4989 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4990 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4991 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4992 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4993 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4994 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4995 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4996 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4997 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4998 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4999 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
5000 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
5001 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
5002 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
5003 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
5004 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
5005 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
5006 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
5007 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
5008 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
5009 _(PG_CAPTURE_REPLY, pg_capture_reply) \
5010 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
5011 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
5012 ip_source_and_port_range_check_add_del_reply) \
5013 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
5014 ip_source_and_port_range_check_interface_add_del_reply) \
5015 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
5016 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
5017 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
5018 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
5019 _(PUNT_REPLY, punt_reply) \
5020 _(IP_FIB_DETAILS, ip_fib_details) \
5021 _(IP6_FIB_DETAILS, ip6_fib_details) \
5022 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
5023 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
5024 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
5025 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
5026 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
5027 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply) \
5028 _(P2P_ETHERNET_ADD_REPLY, p2p_ethernet_add_reply) \
5029 _(P2P_ETHERNET_DEL_REPLY, p2p_ethernet_del_reply) \
5030 _(LLDP_CONFIG_REPLY, lldp_config_reply) \
5031 _(SW_INTERFACE_SET_LLDP_REPLY, sw_interface_set_lldp_reply) \
5032 _(TCP_CONFIGURE_SRC_ADDRESSES_REPLY, tcp_configure_src_addresses_reply)
5034 #define foreach_standalone_reply_msg \
5035 _(SW_INTERFACE_EVENT, sw_interface_event) \
5036 _(VNET_INTERFACE_SIMPLE_COUNTERS, vnet_interface_simple_counters) \
5037 _(VNET_INTERFACE_COMBINED_COUNTERS, vnet_interface_combined_counters) \
5038 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
5039 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
5040 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
5041 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
5050 #define STR_VTR_OP_CASE(op) \
5051 case L2_VTR_ ## op: \
5055 str_vtr_op (u32 vtr_op)
5059 STR_VTR_OP_CASE (DISABLED);
5060 STR_VTR_OP_CASE (PUSH_1);
5061 STR_VTR_OP_CASE (PUSH_2);
5062 STR_VTR_OP_CASE (POP_1);
5063 STR_VTR_OP_CASE (POP_2);
5064 STR_VTR_OP_CASE (TRANSLATE_1_1);
5065 STR_VTR_OP_CASE (TRANSLATE_1_2);
5066 STR_VTR_OP_CASE (TRANSLATE_2_1);
5067 STR_VTR_OP_CASE (TRANSLATE_2_2);
5074 dump_sub_interface_table (vat_main_t * vam)
5076 const sw_interface_subif_t *sub = NULL;
5078 if (vam->json_output)
5081 ("JSON output supported only for VPE API calls and dump_stats_table");
5086 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
5087 "Interface", "sw_if_index",
5088 "sub id", "dot1ad", "tags", "outer id",
5089 "inner id", "exact", "default", "outer any", "inner any");
5091 vec_foreach (sub, vam->sw_if_subif_table)
5094 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
5095 sub->interface_name,
5097 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
5098 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
5099 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
5100 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
5101 if (sub->vtr_op != L2_VTR_DISABLED)
5104 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
5105 "tag1: %d tag2: %d ]",
5106 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
5107 sub->vtr_tag1, sub->vtr_tag2);
5115 name_sort_cmp (void *a1, void *a2)
5117 name_sort_t *n1 = a1;
5118 name_sort_t *n2 = a2;
5120 return strcmp ((char *) n1->name, (char *) n2->name);
5124 dump_interface_table (vat_main_t * vam)
5127 name_sort_t *nses = 0, *ns;
5129 if (vam->json_output)
5132 ("JSON output supported only for VPE API calls and dump_stats_table");
5137 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5139 vec_add2 (nses, ns, 1);
5140 ns->name = (u8 *)(p->key);
5141 ns->value = (u32) p->value[0];
5145 vec_sort_with_function (nses, name_sort_cmp);
5147 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
5148 vec_foreach (ns, nses)
5150 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
5157 dump_ip_table (vat_main_t * vam, int is_ipv6)
5159 const ip_details_t *det = NULL;
5160 const ip_address_details_t *address = NULL;
5163 print (vam->ofp, "%-12s", "sw_if_index");
5165 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
5172 print (vam->ofp, "%-12d", i);
5173 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
5178 vec_foreach (address, det->addr)
5182 is_ipv6 ? format_ip6_address : format_ip4_address,
5183 address->ip, address->prefix_length);
5191 dump_ipv4_table (vat_main_t * vam)
5193 if (vam->json_output)
5196 ("JSON output supported only for VPE API calls and dump_stats_table");
5200 return dump_ip_table (vam, 0);
5204 dump_ipv6_table (vat_main_t * vam)
5206 if (vam->json_output)
5209 ("JSON output supported only for VPE API calls and dump_stats_table");
5213 return dump_ip_table (vam, 1);
5217 counter_type_to_str (u8 counter_type, u8 is_combined)
5221 switch (counter_type)
5223 case VNET_INTERFACE_COUNTER_DROP:
5225 case VNET_INTERFACE_COUNTER_PUNT:
5227 case VNET_INTERFACE_COUNTER_IP4:
5229 case VNET_INTERFACE_COUNTER_IP6:
5231 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
5233 case VNET_INTERFACE_COUNTER_RX_MISS:
5235 case VNET_INTERFACE_COUNTER_RX_ERROR:
5237 case VNET_INTERFACE_COUNTER_TX_ERROR:
5240 return "INVALID-COUNTER-TYPE";
5245 switch (counter_type)
5247 case VNET_INTERFACE_COUNTER_RX:
5249 case VNET_INTERFACE_COUNTER_TX:
5252 return "INVALID-COUNTER-TYPE";
5258 dump_stats_table (vat_main_t * vam)
5260 vat_json_node_t node;
5261 vat_json_node_t *msg_array;
5262 vat_json_node_t *msg;
5263 vat_json_node_t *counter_array;
5264 vat_json_node_t *counter;
5265 interface_counter_t c;
5267 ip4_fib_counter_t *c4;
5268 ip6_fib_counter_t *c6;
5269 ip4_nbr_counter_t *n4;
5270 ip6_nbr_counter_t *n6;
5273 if (!vam->json_output)
5275 clib_warning ("dump_stats_table supported only in JSON format");
5279 vat_json_init_object (&node);
5281 /* interface counters */
5282 msg_array = vat_json_object_add (&node, "interface_counters");
5283 vat_json_init_array (msg_array);
5284 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
5286 msg = vat_json_array_add (msg_array);
5287 vat_json_init_object (msg);
5288 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5289 (u8 *) counter_type_to_str (i, 0));
5290 vat_json_object_add_int (msg, "is_combined", 0);
5291 counter_array = vat_json_object_add (msg, "data");
5292 vat_json_init_array (counter_array);
5293 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
5295 packets = vam->simple_interface_counters[i][j];
5296 vat_json_array_add_uint (counter_array, packets);
5299 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
5301 msg = vat_json_array_add (msg_array);
5302 vat_json_init_object (msg);
5303 vat_json_object_add_string_copy (msg, "vnet_counter_type",
5304 (u8 *) counter_type_to_str (i, 1));
5305 vat_json_object_add_int (msg, "is_combined", 1);
5306 counter_array = vat_json_object_add (msg, "data");
5307 vat_json_init_array (counter_array);
5308 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
5310 c = vam->combined_interface_counters[i][j];
5311 counter = vat_json_array_add (counter_array);
5312 vat_json_init_object (counter);
5313 vat_json_object_add_uint (counter, "packets", c.packets);
5314 vat_json_object_add_uint (counter, "bytes", c.bytes);
5318 /* ip4 fib counters */
5319 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
5320 vat_json_init_array (msg_array);
5321 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
5323 msg = vat_json_array_add (msg_array);
5324 vat_json_init_object (msg);
5325 vat_json_object_add_uint (msg, "vrf_id",
5326 vam->ip4_fib_counters_vrf_id_by_index[i]);
5327 counter_array = vat_json_object_add (msg, "c");
5328 vat_json_init_array (counter_array);
5329 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
5331 counter = vat_json_array_add (counter_array);
5332 vat_json_init_object (counter);
5333 c4 = &vam->ip4_fib_counters[i][j];
5334 vat_json_object_add_ip4 (counter, "address", c4->address);
5335 vat_json_object_add_uint (counter, "address_length",
5336 c4->address_length);
5337 vat_json_object_add_uint (counter, "packets", c4->packets);
5338 vat_json_object_add_uint (counter, "bytes", c4->bytes);
5342 /* ip6 fib counters */
5343 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
5344 vat_json_init_array (msg_array);
5345 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
5347 msg = vat_json_array_add (msg_array);
5348 vat_json_init_object (msg);
5349 vat_json_object_add_uint (msg, "vrf_id",
5350 vam->ip6_fib_counters_vrf_id_by_index[i]);
5351 counter_array = vat_json_object_add (msg, "c");
5352 vat_json_init_array (counter_array);
5353 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
5355 counter = vat_json_array_add (counter_array);
5356 vat_json_init_object (counter);
5357 c6 = &vam->ip6_fib_counters[i][j];
5358 vat_json_object_add_ip6 (counter, "address", c6->address);
5359 vat_json_object_add_uint (counter, "address_length",
5360 c6->address_length);
5361 vat_json_object_add_uint (counter, "packets", c6->packets);
5362 vat_json_object_add_uint (counter, "bytes", c6->bytes);
5366 /* ip4 nbr counters */
5367 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
5368 vat_json_init_array (msg_array);
5369 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
5371 msg = vat_json_array_add (msg_array);
5372 vat_json_init_object (msg);
5373 vat_json_object_add_uint (msg, "sw_if_index", i);
5374 counter_array = vat_json_object_add (msg, "c");
5375 vat_json_init_array (counter_array);
5376 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
5378 counter = vat_json_array_add (counter_array);
5379 vat_json_init_object (counter);
5380 n4 = &vam->ip4_nbr_counters[i][j];
5381 vat_json_object_add_ip4 (counter, "address", n4->address);
5382 vat_json_object_add_uint (counter, "link-type", n4->linkt);
5383 vat_json_object_add_uint (counter, "packets", n4->packets);
5384 vat_json_object_add_uint (counter, "bytes", n4->bytes);
5388 /* ip6 nbr counters */
5389 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
5390 vat_json_init_array (msg_array);
5391 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
5393 msg = vat_json_array_add (msg_array);
5394 vat_json_init_object (msg);
5395 vat_json_object_add_uint (msg, "sw_if_index", i);
5396 counter_array = vat_json_object_add (msg, "c");
5397 vat_json_init_array (counter_array);
5398 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
5400 counter = vat_json_array_add (counter_array);
5401 vat_json_init_object (counter);
5402 n6 = &vam->ip6_nbr_counters[i][j];
5403 vat_json_object_add_ip6 (counter, "address", n6->address);
5404 vat_json_object_add_uint (counter, "packets", n6->packets);
5405 vat_json_object_add_uint (counter, "bytes", n6->bytes);
5409 vat_json_print (vam->ofp, &node);
5410 vat_json_free (&node);
5416 exec (vat_main_t * vam)
5418 api_main_t *am = &api_main;
5423 unformat_input_t *i = vam->input;
5425 if (vec_len (i->buffer) == 0)
5428 if (vam->exec_mode == 0 && unformat (i, "mode"))
5433 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5443 * Copy cmd into shared memory.
5444 * In order for the CLI command to work, it
5445 * must be a vector ending in \n, not a C-string ending
5448 pthread_mutex_lock (&am->vlib_rp->mutex);
5449 oldheap = svm_push_data_heap (am->vlib_rp);
5451 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
5452 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
5454 svm_pop_heap (oldheap);
5455 pthread_mutex_unlock (&am->vlib_rp->mutex);
5457 mp->cmd_in_shmem = pointer_to_uword (cmd);
5459 timeout = vat_time_now (vam) + 10.0;
5461 while (vat_time_now (vam) < timeout)
5463 if (vam->result_ready == 1)
5466 if (vam->shmem_result != NULL)
5467 print (vam->ofp, "%s", vam->shmem_result);
5468 pthread_mutex_lock (&am->vlib_rp->mutex);
5469 oldheap = svm_push_data_heap (am->vlib_rp);
5471 free_me = (u8 *) vam->shmem_result;
5474 svm_pop_heap (oldheap);
5475 pthread_mutex_unlock (&am->vlib_rp->mutex);
5483 * Future replacement of exec() that passes CLI buffers directly in
5484 * the API messages instead of an additional shared memory area.
5487 exec_inband (vat_main_t * vam)
5489 vl_api_cli_inband_t *mp;
5490 unformat_input_t *i = vam->input;
5493 if (vec_len (i->buffer) == 0)
5496 if (vam->exec_mode == 0 && unformat (i, "mode"))
5501 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
5508 * In order for the CLI command to work, it
5509 * must be a vector ending in \n, not a C-string ending
5512 u32 len = vec_len (vam->input->buffer);
5513 M2 (CLI_INBAND, mp, len);
5514 clib_memcpy (mp->cmd, vam->input->buffer, len);
5515 mp->length = htonl (len);
5518 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
5523 api_create_loopback (vat_main_t * vam)
5525 unformat_input_t *i = vam->input;
5526 vl_api_create_loopback_t *mp;
5527 vl_api_create_loopback_instance_t *mp_lbi;
5530 u8 is_specified = 0;
5531 u32 user_instance = 0;
5534 memset (mac_address, 0, sizeof (mac_address));
5536 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5538 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
5540 if (unformat (i, "instance %d", &user_instance))
5548 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
5549 mp_lbi->is_specified = is_specified;
5551 mp_lbi->user_instance = htonl (user_instance);
5553 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
5558 /* Construct the API message */
5559 M (CREATE_LOOPBACK, mp);
5561 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
5570 api_delete_loopback (vat_main_t * vam)
5572 unformat_input_t *i = vam->input;
5573 vl_api_delete_loopback_t *mp;
5574 u32 sw_if_index = ~0;
5577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5579 if (unformat (i, "sw_if_index %d", &sw_if_index))
5585 if (sw_if_index == ~0)
5587 errmsg ("missing sw_if_index");
5591 /* Construct the API message */
5592 M (DELETE_LOOPBACK, mp);
5593 mp->sw_if_index = ntohl (sw_if_index);
5601 api_want_stats (vat_main_t * vam)
5603 unformat_input_t *i = vam->input;
5604 vl_api_want_stats_t *mp;
5608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5610 if (unformat (i, "enable"))
5612 else if (unformat (i, "disable"))
5620 errmsg ("missing enable|disable");
5625 mp->enable_disable = enable;
5633 api_want_interface_events (vat_main_t * vam)
5635 unformat_input_t *i = vam->input;
5636 vl_api_want_interface_events_t *mp;
5640 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5642 if (unformat (i, "enable"))
5644 else if (unformat (i, "disable"))
5652 errmsg ("missing enable|disable");
5656 M (WANT_INTERFACE_EVENTS, mp);
5657 mp->enable_disable = enable;
5659 vam->interface_event_display = enable;
5667 /* Note: non-static, called once to set up the initial intfc table */
5669 api_sw_interface_dump (vat_main_t * vam)
5671 vl_api_sw_interface_dump_t *mp;
5672 vl_api_control_ping_t *mp_ping;
5674 name_sort_t *nses = 0, *ns;
5675 sw_interface_subif_t *sub = NULL;
5678 /* Toss the old name table */
5680 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
5682 vec_add2 (nses, ns, 1);
5683 ns->name = (u8 *)(p->key);
5684 ns->value = (u32) p->value[0];
5688 hash_free (vam->sw_if_index_by_interface_name);
5690 vec_foreach (ns, nses) vec_free (ns->name);
5694 vec_foreach (sub, vam->sw_if_subif_table)
5696 vec_free (sub->interface_name);
5698 vec_free (vam->sw_if_subif_table);
5700 /* recreate the interface name hash table */
5701 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
5703 /* Get list of ethernets */
5704 M (SW_INTERFACE_DUMP, mp);
5705 mp->name_filter_valid = 1;
5706 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
5709 /* and local / loopback interfaces */
5710 M (SW_INTERFACE_DUMP, mp);
5711 mp->name_filter_valid = 1;
5712 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
5715 /* and packet-generator interfaces */
5716 M (SW_INTERFACE_DUMP, mp);
5717 mp->name_filter_valid = 1;
5718 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
5721 /* and vxlan-gpe tunnel interfaces */
5722 M (SW_INTERFACE_DUMP, mp);
5723 mp->name_filter_valid = 1;
5724 strncpy ((char *) mp->name_filter, "vxlan_gpe",
5725 sizeof (mp->name_filter) - 1);
5728 /* and vxlan tunnel interfaces */
5729 M (SW_INTERFACE_DUMP, mp);
5730 mp->name_filter_valid = 1;
5731 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
5734 /* and host (af_packet) interfaces */
5735 M (SW_INTERFACE_DUMP, mp);
5736 mp->name_filter_valid = 1;
5737 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
5740 /* and l2tpv3 tunnel interfaces */
5741 M (SW_INTERFACE_DUMP, mp);
5742 mp->name_filter_valid = 1;
5743 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
5744 sizeof (mp->name_filter) - 1);
5747 /* and GRE tunnel interfaces */
5748 M (SW_INTERFACE_DUMP, mp);
5749 mp->name_filter_valid = 1;
5750 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
5753 /* and LISP-GPE interfaces */
5754 M (SW_INTERFACE_DUMP, mp);
5755 mp->name_filter_valid = 1;
5756 strncpy ((char *) mp->name_filter, "lisp_gpe",
5757 sizeof (mp->name_filter) - 1);
5760 /* and IPSEC tunnel interfaces */
5761 M (SW_INTERFACE_DUMP, mp);
5762 mp->name_filter_valid = 1;
5763 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
5766 /* Use a control ping for synchronization */
5767 M (CONTROL_PING, mp_ping);
5775 api_sw_interface_set_flags (vat_main_t * vam)
5777 unformat_input_t *i = vam->input;
5778 vl_api_sw_interface_set_flags_t *mp;
5780 u8 sw_if_index_set = 0;
5784 /* Parse args required to build the message */
5785 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5787 if (unformat (i, "admin-up"))
5789 else if (unformat (i, "admin-down"))
5792 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5793 sw_if_index_set = 1;
5794 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5795 sw_if_index_set = 1;
5800 if (sw_if_index_set == 0)
5802 errmsg ("missing interface name or sw_if_index");
5806 /* Construct the API message */
5807 M (SW_INTERFACE_SET_FLAGS, mp);
5808 mp->sw_if_index = ntohl (sw_if_index);
5809 mp->admin_up_down = admin_up;
5814 /* Wait for a reply, return the good/bad news... */
5820 api_sw_interface_clear_stats (vat_main_t * vam)
5822 unformat_input_t *i = vam->input;
5823 vl_api_sw_interface_clear_stats_t *mp;
5825 u8 sw_if_index_set = 0;
5828 /* Parse args required to build the message */
5829 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5832 sw_if_index_set = 1;
5833 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5834 sw_if_index_set = 1;
5839 /* Construct the API message */
5840 M (SW_INTERFACE_CLEAR_STATS, mp);
5842 if (sw_if_index_set == 1)
5843 mp->sw_if_index = ntohl (sw_if_index);
5845 mp->sw_if_index = ~0;
5850 /* Wait for a reply, return the good/bad news... */
5856 api_sw_interface_add_del_address (vat_main_t * vam)
5858 unformat_input_t *i = vam->input;
5859 vl_api_sw_interface_add_del_address_t *mp;
5861 u8 sw_if_index_set = 0;
5862 u8 is_add = 1, del_all = 0;
5863 u32 address_length = 0;
5864 u8 v4_address_set = 0;
5865 u8 v6_address_set = 0;
5866 ip4_address_t v4address;
5867 ip6_address_t v6address;
5870 /* Parse args required to build the message */
5871 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5873 if (unformat (i, "del-all"))
5875 else if (unformat (i, "del"))
5878 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5879 sw_if_index_set = 1;
5880 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5881 sw_if_index_set = 1;
5882 else if (unformat (i, "%U/%d",
5883 unformat_ip4_address, &v4address, &address_length))
5885 else if (unformat (i, "%U/%d",
5886 unformat_ip6_address, &v6address, &address_length))
5892 if (sw_if_index_set == 0)
5894 errmsg ("missing interface name or sw_if_index");
5897 if (v4_address_set && v6_address_set)
5899 errmsg ("both v4 and v6 addresses set");
5902 if (!v4_address_set && !v6_address_set && !del_all)
5904 errmsg ("no addresses set");
5908 /* Construct the API message */
5909 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5911 mp->sw_if_index = ntohl (sw_if_index);
5912 mp->is_add = is_add;
5913 mp->del_all = del_all;
5917 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5921 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5923 mp->address_length = address_length;
5928 /* Wait for a reply, return good/bad news */
5934 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5936 unformat_input_t *i = vam->input;
5937 vl_api_sw_interface_set_mpls_enable_t *mp;
5939 u8 sw_if_index_set = 0;
5943 /* Parse args required to build the message */
5944 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5946 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5947 sw_if_index_set = 1;
5948 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5949 sw_if_index_set = 1;
5950 else if (unformat (i, "disable"))
5952 else if (unformat (i, "dis"))
5958 if (sw_if_index_set == 0)
5960 errmsg ("missing interface name or sw_if_index");
5964 /* Construct the API message */
5965 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5967 mp->sw_if_index = ntohl (sw_if_index);
5968 mp->enable = enable;
5973 /* Wait for a reply... */
5979 api_sw_interface_set_table (vat_main_t * vam)
5981 unformat_input_t *i = vam->input;
5982 vl_api_sw_interface_set_table_t *mp;
5983 u32 sw_if_index, vrf_id = 0;
5984 u8 sw_if_index_set = 0;
5988 /* Parse args required to build the message */
5989 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5991 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5992 sw_if_index_set = 1;
5993 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5994 sw_if_index_set = 1;
5995 else if (unformat (i, "vrf %d", &vrf_id))
5997 else if (unformat (i, "ipv6"))
6003 if (sw_if_index_set == 0)
6005 errmsg ("missing interface name or sw_if_index");
6009 /* Construct the API message */
6010 M (SW_INTERFACE_SET_TABLE, mp);
6012 mp->sw_if_index = ntohl (sw_if_index);
6013 mp->is_ipv6 = is_ipv6;
6014 mp->vrf_id = ntohl (vrf_id);
6019 /* Wait for a reply... */
6024 static void vl_api_sw_interface_get_table_reply_t_handler
6025 (vl_api_sw_interface_get_table_reply_t * mp)
6027 vat_main_t *vam = &vat_main;
6029 print (vam->ofp, "%d", ntohl (mp->vrf_id));
6031 vam->retval = ntohl (mp->retval);
6032 vam->result_ready = 1;
6036 static void vl_api_sw_interface_get_table_reply_t_handler_json
6037 (vl_api_sw_interface_get_table_reply_t * mp)
6039 vat_main_t *vam = &vat_main;
6040 vat_json_node_t node;
6042 vat_json_init_object (&node);
6043 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
6044 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
6046 vat_json_print (vam->ofp, &node);
6047 vat_json_free (&node);
6049 vam->retval = ntohl (mp->retval);
6050 vam->result_ready = 1;
6054 api_sw_interface_get_table (vat_main_t * vam)
6056 unformat_input_t *i = vam->input;
6057 vl_api_sw_interface_get_table_t *mp;
6059 u8 sw_if_index_set = 0;
6063 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6065 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6066 sw_if_index_set = 1;
6067 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6068 sw_if_index_set = 1;
6069 else if (unformat (i, "ipv6"))
6075 if (sw_if_index_set == 0)
6077 errmsg ("missing interface name or sw_if_index");
6081 M (SW_INTERFACE_GET_TABLE, mp);
6082 mp->sw_if_index = htonl (sw_if_index);
6083 mp->is_ipv6 = is_ipv6;
6091 api_sw_interface_set_vpath (vat_main_t * vam)
6093 unformat_input_t *i = vam->input;
6094 vl_api_sw_interface_set_vpath_t *mp;
6095 u32 sw_if_index = 0;
6096 u8 sw_if_index_set = 0;
6100 /* Parse args required to build the message */
6101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6103 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6104 sw_if_index_set = 1;
6105 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6106 sw_if_index_set = 1;
6107 else if (unformat (i, "enable"))
6109 else if (unformat (i, "disable"))
6115 if (sw_if_index_set == 0)
6117 errmsg ("missing interface name or sw_if_index");
6121 /* Construct the API message */
6122 M (SW_INTERFACE_SET_VPATH, mp);
6124 mp->sw_if_index = ntohl (sw_if_index);
6125 mp->enable = is_enable;
6130 /* Wait for a reply... */
6136 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
6138 unformat_input_t *i = vam->input;
6139 vl_api_sw_interface_set_vxlan_bypass_t *mp;
6140 u32 sw_if_index = 0;
6141 u8 sw_if_index_set = 0;
6146 /* Parse args required to build the message */
6147 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6149 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6150 sw_if_index_set = 1;
6151 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6152 sw_if_index_set = 1;
6153 else if (unformat (i, "enable"))
6155 else if (unformat (i, "disable"))
6157 else if (unformat (i, "ip4"))
6159 else if (unformat (i, "ip6"))
6165 if (sw_if_index_set == 0)
6167 errmsg ("missing interface name or sw_if_index");
6171 /* Construct the API message */
6172 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
6174 mp->sw_if_index = ntohl (sw_if_index);
6175 mp->enable = is_enable;
6176 mp->is_ipv6 = is_ipv6;
6181 /* Wait for a reply... */
6188 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
6190 unformat_input_t *i = vam->input;
6191 vl_api_sw_interface_set_l2_xconnect_t *mp;
6193 u8 rx_sw_if_index_set = 0;
6195 u8 tx_sw_if_index_set = 0;
6199 /* Parse args required to build the message */
6200 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6202 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
6203 rx_sw_if_index_set = 1;
6204 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
6205 tx_sw_if_index_set = 1;
6206 else if (unformat (i, "rx"))
6208 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6210 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6212 rx_sw_if_index_set = 1;
6217 else if (unformat (i, "tx"))
6219 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6221 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
6223 tx_sw_if_index_set = 1;
6228 else if (unformat (i, "enable"))
6230 else if (unformat (i, "disable"))
6236 if (rx_sw_if_index_set == 0)
6238 errmsg ("missing rx interface name or rx_sw_if_index");
6242 if (enable && (tx_sw_if_index_set == 0))
6244 errmsg ("missing tx interface name or tx_sw_if_index");
6248 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
6250 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6251 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
6252 mp->enable = enable;
6260 api_sw_interface_set_l2_bridge (vat_main_t * vam)
6262 unformat_input_t *i = vam->input;
6263 vl_api_sw_interface_set_l2_bridge_t *mp;
6265 u8 rx_sw_if_index_set = 0;
6273 /* Parse args required to build the message */
6274 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6276 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
6277 rx_sw_if_index_set = 1;
6278 else if (unformat (i, "bd_id %d", &bd_id))
6282 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
6283 rx_sw_if_index_set = 1;
6284 else if (unformat (i, "shg %d", &shg))
6286 else if (unformat (i, "bvi"))
6288 else if (unformat (i, "enable"))
6290 else if (unformat (i, "disable"))
6296 if (rx_sw_if_index_set == 0)
6298 errmsg ("missing rx interface name or sw_if_index");
6302 if (enable && (bd_id_set == 0))
6304 errmsg ("missing bridge domain");
6308 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
6310 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
6311 mp->bd_id = ntohl (bd_id);
6314 mp->enable = enable;
6322 api_bridge_domain_dump (vat_main_t * vam)
6324 unformat_input_t *i = vam->input;
6325 vl_api_bridge_domain_dump_t *mp;
6326 vl_api_control_ping_t *mp_ping;
6330 /* Parse args required to build the message */
6331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6333 if (unformat (i, "bd_id %d", &bd_id))
6339 M (BRIDGE_DOMAIN_DUMP, mp);
6340 mp->bd_id = ntohl (bd_id);
6343 /* Use a control ping for synchronization */
6344 M (CONTROL_PING, mp_ping);
6352 api_bridge_domain_add_del (vat_main_t * vam)
6354 unformat_input_t *i = vam->input;
6355 vl_api_bridge_domain_add_del_t *mp;
6358 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
6363 /* Parse args required to build the message */
6364 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6366 if (unformat (i, "bd_id %d", &bd_id))
6368 else if (unformat (i, "flood %d", &flood))
6370 else if (unformat (i, "uu-flood %d", &uu_flood))
6372 else if (unformat (i, "forward %d", &forward))
6374 else if (unformat (i, "learn %d", &learn))
6376 else if (unformat (i, "arp-term %d", &arp_term))
6378 else if (unformat (i, "mac-age %d", &mac_age))
6380 else if (unformat (i, "bd-tag %s", &bd_tag))
6382 else if (unformat (i, "del"))
6385 flood = uu_flood = forward = learn = 0;
6393 errmsg ("missing bridge domain");
6400 errmsg ("mac age must be less than 256 ");
6405 if ((bd_tag) && (strlen ((char *) bd_tag) > 63))
6407 errmsg ("bd-tag cannot be longer than 63");
6412 M (BRIDGE_DOMAIN_ADD_DEL, mp);
6414 mp->bd_id = ntohl (bd_id);
6416 mp->uu_flood = uu_flood;
6417 mp->forward = forward;
6419 mp->arp_term = arp_term;
6420 mp->is_add = is_add;
6421 mp->mac_age = (u8) mac_age;
6423 strcpy ((char *) mp->bd_tag, (char *) bd_tag);
6434 api_l2fib_flush_bd (vat_main_t * vam)
6436 unformat_input_t *i = vam->input;
6437 vl_api_l2fib_flush_bd_t *mp;
6441 /* Parse args required to build the message */
6442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6444 if (unformat (i, "bd_id %d", &bd_id));
6451 errmsg ("missing bridge domain");
6455 M (L2FIB_FLUSH_BD, mp);
6457 mp->bd_id = htonl (bd_id);
6465 api_l2fib_flush_int (vat_main_t * vam)
6467 unformat_input_t *i = vam->input;
6468 vl_api_l2fib_flush_int_t *mp;
6469 u32 sw_if_index = ~0;
6472 /* Parse args required to build the message */
6473 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6475 if (unformat (i, "sw_if_index %d", &sw_if_index));
6477 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index));
6482 if (sw_if_index == ~0)
6484 errmsg ("missing interface name or sw_if_index");
6488 M (L2FIB_FLUSH_INT, mp);
6490 mp->sw_if_index = ntohl (sw_if_index);
6498 api_l2fib_add_del (vat_main_t * vam)
6500 unformat_input_t *i = vam->input;
6501 vl_api_l2fib_add_del_t *mp;
6507 u32 sw_if_index = ~0;
6508 u8 sw_if_index_set = 0;
6517 /* Parse args required to build the message */
6518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6520 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
6522 else if (unformat (i, "bd_id %d", &bd_id))
6524 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6525 sw_if_index_set = 1;
6526 else if (unformat (i, "sw_if"))
6528 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6531 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6532 sw_if_index_set = 1;
6537 else if (unformat (i, "static"))
6539 else if (unformat (i, "filter"))
6544 else if (unformat (i, "bvi"))
6549 else if (unformat (i, "del"))
6551 else if (unformat (i, "count %d", &count))
6559 errmsg ("missing mac address");
6565 errmsg ("missing bridge domain");
6569 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
6571 errmsg ("missing interface name or sw_if_index");
6577 /* Turn on async mode */
6578 vam->async_mode = 1;
6579 vam->async_errors = 0;
6580 before = vat_time_now (vam);
6583 for (j = 0; j < count; j++)
6585 M (L2FIB_ADD_DEL, mp);
6588 mp->bd_id = ntohl (bd_id);
6589 mp->is_add = is_add;
6593 mp->sw_if_index = ntohl (sw_if_index);
6594 mp->static_mac = static_mac;
6595 mp->filter_mac = filter_mac;
6596 mp->bvi_mac = bvi_mac;
6598 increment_mac_address (&mac);
6605 vl_api_control_ping_t *mp_ping;
6608 /* Shut off async mode */
6609 vam->async_mode = 0;
6611 M (CONTROL_PING, mp_ping);
6614 timeout = vat_time_now (vam) + 1.0;
6615 while (vat_time_now (vam) < timeout)
6616 if (vam->result_ready == 1)
6621 if (vam->retval == -99)
6624 if (vam->async_errors > 0)
6626 errmsg ("%d asynchronous errors", vam->async_errors);
6629 vam->async_errors = 0;
6630 after = vat_time_now (vam);
6632 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6633 count, after - before, count / (after - before));
6639 /* Wait for a reply... */
6643 /* Return the good/bad news */
6644 return (vam->retval);
6648 api_bridge_domain_set_mac_age (vat_main_t * vam)
6650 unformat_input_t *i = vam->input;
6651 vl_api_bridge_domain_set_mac_age_t *mp;
6656 /* Parse args required to build the message */
6657 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6659 if (unformat (i, "bd_id %d", &bd_id));
6660 else if (unformat (i, "mac-age %d", &mac_age));
6667 errmsg ("missing bridge domain");
6673 errmsg ("mac age must be less than 256 ");
6677 M (BRIDGE_DOMAIN_SET_MAC_AGE, mp);
6679 mp->bd_id = htonl (bd_id);
6680 mp->mac_age = (u8) mac_age;
6688 api_l2_flags (vat_main_t * vam)
6690 unformat_input_t *i = vam->input;
6691 vl_api_l2_flags_t *mp;
6694 u8 sw_if_index_set = 0;
6698 /* Parse args required to build the message */
6699 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6701 if (unformat (i, "sw_if_index %d", &sw_if_index))
6702 sw_if_index_set = 1;
6703 else if (unformat (i, "sw_if"))
6705 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6708 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6709 sw_if_index_set = 1;
6714 else if (unformat (i, "learn"))
6716 else if (unformat (i, "forward"))
6718 else if (unformat (i, "flood"))
6720 else if (unformat (i, "uu-flood"))
6721 flags |= L2_UU_FLOOD;
6722 else if (unformat (i, "arp-term"))
6723 flags |= L2_ARP_TERM;
6724 else if (unformat (i, "off"))
6726 else if (unformat (i, "disable"))
6732 if (sw_if_index_set == 0)
6734 errmsg ("missing interface name or sw_if_index");
6740 mp->sw_if_index = ntohl (sw_if_index);
6741 mp->feature_bitmap = ntohl (flags);
6742 mp->is_set = is_set;
6750 api_bridge_flags (vat_main_t * vam)
6752 unformat_input_t *i = vam->input;
6753 vl_api_bridge_flags_t *mp;
6760 /* Parse args required to build the message */
6761 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6763 if (unformat (i, "bd_id %d", &bd_id))
6765 else if (unformat (i, "learn"))
6767 else if (unformat (i, "forward"))
6769 else if (unformat (i, "flood"))
6771 else if (unformat (i, "uu-flood"))
6772 flags |= L2_UU_FLOOD;
6773 else if (unformat (i, "arp-term"))
6774 flags |= L2_ARP_TERM;
6775 else if (unformat (i, "off"))
6777 else if (unformat (i, "disable"))
6785 errmsg ("missing bridge domain");
6789 M (BRIDGE_FLAGS, mp);
6791 mp->bd_id = ntohl (bd_id);
6792 mp->feature_bitmap = ntohl (flags);
6793 mp->is_set = is_set;
6801 api_bd_ip_mac_add_del (vat_main_t * vam)
6803 unformat_input_t *i = vam->input;
6804 vl_api_bd_ip_mac_add_del_t *mp;
6811 ip4_address_t v4addr;
6812 ip6_address_t v6addr;
6817 /* Parse args required to build the message */
6818 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6820 if (unformat (i, "bd_id %d", &bd_id))
6824 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
6828 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
6833 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
6837 else if (unformat (i, "del"))
6845 errmsg ("missing bridge domain");
6848 else if (ip_set == 0)
6850 errmsg ("missing IP address");
6853 else if (mac_set == 0)
6855 errmsg ("missing MAC address");
6859 M (BD_IP_MAC_ADD_DEL, mp);
6861 mp->bd_id = ntohl (bd_id);
6862 mp->is_ipv6 = is_ipv6;
6863 mp->is_add = is_add;
6865 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
6867 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
6868 clib_memcpy (mp->mac_address, macaddr, 6);
6875 api_tap_connect (vat_main_t * vam)
6877 unformat_input_t *i = vam->input;
6878 vl_api_tap_connect_t *mp;
6884 ip4_address_t ip4_address;
6886 int ip4_address_set = 0;
6887 ip6_address_t ip6_address;
6889 int ip6_address_set = 0;
6892 memset (mac_address, 0, sizeof (mac_address));
6894 /* Parse args required to build the message */
6895 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6897 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6901 else if (unformat (i, "random-mac"))
6903 else if (unformat (i, "tapname %s", &tap_name))
6905 else if (unformat (i, "tag %s", &tag))
6907 else if (unformat (i, "address %U/%d",
6908 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6909 ip4_address_set = 1;
6910 else if (unformat (i, "address %U/%d",
6911 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6912 ip6_address_set = 1;
6919 errmsg ("missing tap name");
6922 if (vec_len (tap_name) > 63)
6924 errmsg ("tap name too long");
6927 vec_add1 (tap_name, 0);
6929 if (vec_len (tag) > 63)
6931 errmsg ("tag too long");
6935 /* Construct the API message */
6936 M (TAP_CONNECT, mp);
6938 mp->use_random_mac = random_mac;
6939 clib_memcpy (mp->mac_address, mac_address, 6);
6940 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6942 clib_memcpy (mp->tag, tag, vec_len (tag));
6944 if (ip4_address_set)
6946 mp->ip4_address_set = 1;
6947 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6948 mp->ip4_mask_width = ip4_mask_width;
6950 if (ip6_address_set)
6952 mp->ip6_address_set = 1;
6953 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6954 mp->ip6_mask_width = ip6_mask_width;
6957 vec_free (tap_name);
6963 /* Wait for a reply... */
6969 api_tap_modify (vat_main_t * vam)
6971 unformat_input_t *i = vam->input;
6972 vl_api_tap_modify_t *mp;
6977 u32 sw_if_index = ~0;
6978 u8 sw_if_index_set = 0;
6981 memset (mac_address, 0, sizeof (mac_address));
6983 /* Parse args required to build the message */
6984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6986 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6987 sw_if_index_set = 1;
6988 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6989 sw_if_index_set = 1;
6990 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6994 else if (unformat (i, "random-mac"))
6996 else if (unformat (i, "tapname %s", &tap_name))
7002 if (sw_if_index_set == 0)
7004 errmsg ("missing vpp interface name");
7009 errmsg ("missing tap name");
7012 if (vec_len (tap_name) > 63)
7014 errmsg ("tap name too long");
7016 vec_add1 (tap_name, 0);
7018 /* Construct the API message */
7021 mp->use_random_mac = random_mac;
7022 mp->sw_if_index = ntohl (sw_if_index);
7023 clib_memcpy (mp->mac_address, mac_address, 6);
7024 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
7025 vec_free (tap_name);
7030 /* Wait for a reply... */
7036 api_tap_delete (vat_main_t * vam)
7038 unformat_input_t *i = vam->input;
7039 vl_api_tap_delete_t *mp;
7040 u32 sw_if_index = ~0;
7041 u8 sw_if_index_set = 0;
7044 /* Parse args required to build the message */
7045 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7047 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7048 sw_if_index_set = 1;
7049 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7050 sw_if_index_set = 1;
7055 if (sw_if_index_set == 0)
7057 errmsg ("missing vpp interface name");
7061 /* Construct the API message */
7064 mp->sw_if_index = ntohl (sw_if_index);
7069 /* Wait for a reply... */
7075 api_ip_table_add_del (vat_main_t * vam)
7077 unformat_input_t *i = vam->input;
7078 vl_api_ip_table_add_del_t *mp;
7084 /* Parse args required to build the message */
7085 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7087 if (unformat (i, "ipv6"))
7089 else if (unformat (i, "del"))
7091 else if (unformat (i, "add"))
7093 else if (unformat (i, "table %d", &table_id))
7097 clib_warning ("parse error '%U'", format_unformat_error, i);
7104 errmsg ("missing table-ID");
7108 /* Construct the API message */
7109 M (IP_TABLE_ADD_DEL, mp);
7111 mp->table_id = ntohl (table_id);
7112 mp->is_ipv6 = is_ipv6;
7113 mp->is_add = is_add;
7118 /* Wait for a reply... */
7125 api_ip_add_del_route (vat_main_t * vam)
7127 unformat_input_t *i = vam->input;
7128 vl_api_ip_add_del_route_t *mp;
7129 u32 sw_if_index = ~0, vrf_id = 0;
7131 u8 is_local = 0, is_drop = 0;
7132 u8 is_unreach = 0, is_prohibit = 0;
7133 u8 create_vrf_if_needed = 0;
7135 u32 next_hop_weight = 1;
7137 u8 is_multipath = 0;
7139 u8 address_length_set = 0;
7140 u32 next_hop_table_id = 0;
7141 u32 resolve_attempts = 0;
7142 u32 dst_address_length = 0;
7143 u8 next_hop_set = 0;
7144 ip4_address_t v4_dst_address, v4_next_hop_address;
7145 ip6_address_t v6_dst_address, v6_next_hop_address;
7149 u32 random_add_del = 0;
7150 u32 *random_vector = 0;
7152 u32 random_seed = 0xdeaddabe;
7153 u32 classify_table_index = ~0;
7155 u8 resolve_host = 0, resolve_attached = 0;
7156 mpls_label_t *next_hop_out_label_stack = NULL;
7157 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7158 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7160 /* Parse args required to build the message */
7161 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7163 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7165 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7167 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
7172 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
7177 else if (unformat (i, "/%d", &dst_address_length))
7179 address_length_set = 1;
7182 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
7183 &v4_next_hop_address))
7187 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
7188 &v6_next_hop_address))
7192 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
7194 else if (unformat (i, "weight %d", &next_hop_weight))
7196 else if (unformat (i, "drop"))
7200 else if (unformat (i, "null-send-unreach"))
7204 else if (unformat (i, "null-send-prohibit"))
7208 else if (unformat (i, "local"))
7212 else if (unformat (i, "classify %d", &classify_table_index))
7216 else if (unformat (i, "del"))
7218 else if (unformat (i, "add"))
7220 else if (unformat (i, "not-last"))
7222 else if (unformat (i, "resolve-via-host"))
7224 else if (unformat (i, "resolve-via-attached"))
7225 resolve_attached = 1;
7226 else if (unformat (i, "multipath"))
7228 else if (unformat (i, "vrf %d", &vrf_id))
7230 else if (unformat (i, "create-vrf"))
7231 create_vrf_if_needed = 1;
7232 else if (unformat (i, "count %d", &count))
7234 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
7236 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7238 else if (unformat (i, "out-label %d", &next_hop_out_label))
7239 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7240 else if (unformat (i, "via-label %d", &next_hop_via_label))
7242 else if (unformat (i, "random"))
7244 else if (unformat (i, "seed %d", &random_seed))
7248 clib_warning ("parse error '%U'", format_unformat_error, i);
7253 if (!next_hop_set && !is_drop && !is_local &&
7254 !is_classify && !is_unreach && !is_prohibit &&
7255 MPLS_LABEL_INVALID == next_hop_via_label)
7258 ("next hop / local / drop / unreach / prohibit / classify not set");
7262 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
7264 errmsg ("next hop and next-hop via label set");
7267 if (address_set == 0)
7269 errmsg ("missing addresses");
7273 if (address_length_set == 0)
7275 errmsg ("missing address length");
7279 /* Generate a pile of unique, random routes */
7282 u32 this_random_address;
7283 random_hash = hash_create (count, sizeof (uword));
7285 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
7286 for (j = 0; j <= count; j++)
7290 this_random_address = random_u32 (&random_seed);
7291 this_random_address =
7292 clib_host_to_net_u32 (this_random_address);
7294 while (hash_get (random_hash, this_random_address));
7295 vec_add1 (random_vector, this_random_address);
7296 hash_set (random_hash, this_random_address, 1);
7298 hash_free (random_hash);
7299 v4_dst_address.as_u32 = random_vector[0];
7304 /* Turn on async mode */
7305 vam->async_mode = 1;
7306 vam->async_errors = 0;
7307 before = vat_time_now (vam);
7310 for (j = 0; j < count; j++)
7312 /* Construct the API message */
7313 M2 (IP_ADD_DEL_ROUTE, mp,
7314 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7316 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7317 mp->table_id = ntohl (vrf_id);
7318 mp->create_vrf_if_needed = create_vrf_if_needed;
7320 mp->is_add = is_add;
7321 mp->is_drop = is_drop;
7322 mp->is_unreach = is_unreach;
7323 mp->is_prohibit = is_prohibit;
7324 mp->is_ipv6 = is_ipv6;
7325 mp->is_local = is_local;
7326 mp->is_classify = is_classify;
7327 mp->is_multipath = is_multipath;
7328 mp->is_resolve_host = resolve_host;
7329 mp->is_resolve_attached = resolve_attached;
7330 mp->not_last = not_last;
7331 mp->next_hop_weight = next_hop_weight;
7332 mp->dst_address_length = dst_address_length;
7333 mp->next_hop_table_id = ntohl (next_hop_table_id);
7334 mp->classify_table_index = ntohl (classify_table_index);
7335 mp->next_hop_via_label = ntohl (next_hop_via_label);
7336 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7337 if (0 != mp->next_hop_n_out_labels)
7339 memcpy (mp->next_hop_out_label_stack,
7340 next_hop_out_label_stack,
7341 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7342 vec_free (next_hop_out_label_stack);
7347 clib_memcpy (mp->dst_address, &v6_dst_address,
7348 sizeof (v6_dst_address));
7350 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
7351 sizeof (v6_next_hop_address));
7352 increment_v6_address (&v6_dst_address);
7356 clib_memcpy (mp->dst_address, &v4_dst_address,
7357 sizeof (v4_dst_address));
7359 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
7360 sizeof (v4_next_hop_address));
7362 v4_dst_address.as_u32 = random_vector[j + 1];
7364 increment_v4_address (&v4_dst_address);
7368 /* If we receive SIGTERM, stop now... */
7373 /* When testing multiple add/del ops, use a control-ping to sync */
7376 vl_api_control_ping_t *mp_ping;
7380 /* Shut off async mode */
7381 vam->async_mode = 0;
7383 M (CONTROL_PING, mp_ping);
7386 timeout = vat_time_now (vam) + 1.0;
7387 while (vat_time_now (vam) < timeout)
7388 if (vam->result_ready == 1)
7393 if (vam->retval == -99)
7396 if (vam->async_errors > 0)
7398 errmsg ("%d asynchronous errors", vam->async_errors);
7401 vam->async_errors = 0;
7402 after = vat_time_now (vam);
7404 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7408 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7409 count, after - before, count / (after - before));
7415 /* Wait for a reply... */
7420 /* Return the good/bad news */
7421 return (vam->retval);
7425 api_ip_mroute_add_del (vat_main_t * vam)
7427 unformat_input_t *i = vam->input;
7428 vl_api_ip_mroute_add_del_t *mp;
7429 u32 sw_if_index = ~0, vrf_id = 0;
7432 u8 create_vrf_if_needed = 0;
7435 u32 grp_address_length = 0;
7436 ip4_address_t v4_grp_address, v4_src_address;
7437 ip6_address_t v6_grp_address, v6_src_address;
7438 mfib_itf_flags_t iflags = 0;
7439 mfib_entry_flags_t eflags = 0;
7442 /* Parse args required to build the message */
7443 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7445 if (unformat (i, "sw_if_index %d", &sw_if_index))
7447 else if (unformat (i, "%U %U",
7448 unformat_ip4_address, &v4_src_address,
7449 unformat_ip4_address, &v4_grp_address))
7451 grp_address_length = 64;
7455 else if (unformat (i, "%U %U",
7456 unformat_ip6_address, &v6_src_address,
7457 unformat_ip6_address, &v6_grp_address))
7459 grp_address_length = 256;
7463 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
7465 memset (&v4_src_address, 0, sizeof (v4_src_address));
7466 grp_address_length = 32;
7470 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
7472 memset (&v6_src_address, 0, sizeof (v6_src_address));
7473 grp_address_length = 128;
7477 else if (unformat (i, "/%d", &grp_address_length))
7479 else if (unformat (i, "local"))
7483 else if (unformat (i, "del"))
7485 else if (unformat (i, "add"))
7487 else if (unformat (i, "vrf %d", &vrf_id))
7489 else if (unformat (i, "create-vrf"))
7490 create_vrf_if_needed = 1;
7491 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
7493 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
7497 clib_warning ("parse error '%U'", format_unformat_error, i);
7502 if (address_set == 0)
7504 errmsg ("missing addresses\n");
7508 /* Construct the API message */
7509 M (IP_MROUTE_ADD_DEL, mp);
7511 mp->next_hop_sw_if_index = ntohl (sw_if_index);
7512 mp->table_id = ntohl (vrf_id);
7513 mp->create_vrf_if_needed = create_vrf_if_needed;
7515 mp->is_add = is_add;
7516 mp->is_ipv6 = is_ipv6;
7517 mp->is_local = is_local;
7518 mp->itf_flags = ntohl (iflags);
7519 mp->entry_flags = ntohl (eflags);
7520 mp->grp_address_length = grp_address_length;
7521 mp->grp_address_length = ntohs (mp->grp_address_length);
7525 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
7526 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
7530 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
7531 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
7537 /* Wait for a reply... */
7543 api_mpls_table_add_del (vat_main_t * vam)
7545 unformat_input_t *i = vam->input;
7546 vl_api_mpls_table_add_del_t *mp;
7551 /* Parse args required to build the message */
7552 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7554 if (unformat (i, "table %d", &table_id))
7556 else if (unformat (i, "del"))
7558 else if (unformat (i, "add"))
7562 clib_warning ("parse error '%U'", format_unformat_error, i);
7569 errmsg ("missing table-ID");
7573 /* Construct the API message */
7574 M (MPLS_TABLE_ADD_DEL, mp);
7576 mp->mt_table_id = ntohl (table_id);
7577 mp->mt_is_add = is_add;
7582 /* Wait for a reply... */
7589 api_mpls_route_add_del (vat_main_t * vam)
7591 unformat_input_t *i = vam->input;
7592 vl_api_mpls_route_add_del_t *mp;
7593 u32 sw_if_index = ~0, table_id = 0;
7594 u8 create_table_if_needed = 0;
7596 u32 next_hop_weight = 1;
7597 u8 is_multipath = 0;
7598 u32 next_hop_table_id = 0;
7599 u8 next_hop_set = 0;
7600 ip4_address_t v4_next_hop_address = {
7603 ip6_address_t v6_next_hop_address = { {0} };
7607 u32 classify_table_index = ~0;
7609 u8 resolve_host = 0, resolve_attached = 0;
7610 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
7611 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
7612 mpls_label_t *next_hop_out_label_stack = NULL;
7613 mpls_label_t local_label = MPLS_LABEL_INVALID;
7615 dpo_proto_t next_hop_proto = DPO_PROTO_IP4;
7617 /* Parse args required to build the message */
7618 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7620 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7622 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7624 else if (unformat (i, "%d", &local_label))
7626 else if (unformat (i, "eos"))
7628 else if (unformat (i, "non-eos"))
7630 else if (unformat (i, "via %U", unformat_ip4_address,
7631 &v4_next_hop_address))
7634 next_hop_proto = DPO_PROTO_IP4;
7636 else if (unformat (i, "via %U", unformat_ip6_address,
7637 &v6_next_hop_address))
7640 next_hop_proto = DPO_PROTO_IP6;
7642 else if (unformat (i, "weight %d", &next_hop_weight))
7644 else if (unformat (i, "create-table"))
7645 create_table_if_needed = 1;
7646 else if (unformat (i, "classify %d", &classify_table_index))
7650 else if (unformat (i, "del"))
7652 else if (unformat (i, "add"))
7654 else if (unformat (i, "resolve-via-host"))
7656 else if (unformat (i, "resolve-via-attached"))
7657 resolve_attached = 1;
7658 else if (unformat (i, "multipath"))
7660 else if (unformat (i, "count %d", &count))
7662 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
7665 next_hop_proto = DPO_PROTO_IP4;
7667 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
7670 next_hop_proto = DPO_PROTO_IP6;
7672 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7674 else if (unformat (i, "via-label %d", &next_hop_via_label))
7676 else if (unformat (i, "out-label %d", &next_hop_out_label))
7677 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
7680 clib_warning ("parse error '%U'", format_unformat_error, i);
7685 if (!next_hop_set && !is_classify)
7687 errmsg ("next hop / classify not set");
7691 if (MPLS_LABEL_INVALID == local_label)
7693 errmsg ("missing label");
7699 /* Turn on async mode */
7700 vam->async_mode = 1;
7701 vam->async_errors = 0;
7702 before = vat_time_now (vam);
7705 for (j = 0; j < count; j++)
7707 /* Construct the API message */
7708 M2 (MPLS_ROUTE_ADD_DEL, mp,
7709 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
7711 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
7712 mp->mr_table_id = ntohl (table_id);
7713 mp->mr_create_table_if_needed = create_table_if_needed;
7715 mp->mr_is_add = is_add;
7716 mp->mr_next_hop_proto = next_hop_proto;
7717 mp->mr_is_classify = is_classify;
7718 mp->mr_is_multipath = is_multipath;
7719 mp->mr_is_resolve_host = resolve_host;
7720 mp->mr_is_resolve_attached = resolve_attached;
7721 mp->mr_next_hop_weight = next_hop_weight;
7722 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
7723 mp->mr_classify_table_index = ntohl (classify_table_index);
7724 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
7725 mp->mr_label = ntohl (local_label);
7726 mp->mr_eos = is_eos;
7728 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
7729 if (0 != mp->mr_next_hop_n_out_labels)
7731 memcpy (mp->mr_next_hop_out_label_stack,
7732 next_hop_out_label_stack,
7733 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
7734 vec_free (next_hop_out_label_stack);
7739 if (DPO_PROTO_IP4 == next_hop_proto)
7741 clib_memcpy (mp->mr_next_hop,
7742 &v4_next_hop_address,
7743 sizeof (v4_next_hop_address));
7745 else if (DPO_PROTO_IP6 == next_hop_proto)
7748 clib_memcpy (mp->mr_next_hop,
7749 &v6_next_hop_address,
7750 sizeof (v6_next_hop_address));
7757 /* If we receive SIGTERM, stop now... */
7762 /* When testing multiple add/del ops, use a control-ping to sync */
7765 vl_api_control_ping_t *mp_ping;
7769 /* Shut off async mode */
7770 vam->async_mode = 0;
7772 M (CONTROL_PING, mp_ping);
7775 timeout = vat_time_now (vam) + 1.0;
7776 while (vat_time_now (vam) < timeout)
7777 if (vam->result_ready == 1)
7782 if (vam->retval == -99)
7785 if (vam->async_errors > 0)
7787 errmsg ("%d asynchronous errors", vam->async_errors);
7790 vam->async_errors = 0;
7791 after = vat_time_now (vam);
7793 /* slim chance, but we might have eaten SIGTERM on the first iteration */
7797 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
7798 count, after - before, count / (after - before));
7804 /* Wait for a reply... */
7809 /* Return the good/bad news */
7810 return (vam->retval);
7814 api_mpls_ip_bind_unbind (vat_main_t * vam)
7816 unformat_input_t *i = vam->input;
7817 vl_api_mpls_ip_bind_unbind_t *mp;
7818 u32 ip_table_id = 0;
7819 u8 create_table_if_needed = 0;
7822 ip4_address_t v4_address;
7823 ip6_address_t v6_address;
7826 mpls_label_t local_label = MPLS_LABEL_INVALID;
7829 /* Parse args required to build the message */
7830 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7832 if (unformat (i, "%U/%d", unformat_ip4_address,
7833 &v4_address, &address_length))
7838 else if (unformat (i, "%U/%d", unformat_ip6_address,
7839 &v6_address, &address_length))
7844 else if (unformat (i, "%d", &local_label))
7846 else if (unformat (i, "create-table"))
7847 create_table_if_needed = 1;
7848 else if (unformat (i, "table-id %d", &ip_table_id))
7850 else if (unformat (i, "unbind"))
7852 else if (unformat (i, "bind"))
7856 clib_warning ("parse error '%U'", format_unformat_error, i);
7863 errmsg ("IP addres not set");
7867 if (MPLS_LABEL_INVALID == local_label)
7869 errmsg ("missing label");
7873 /* Construct the API message */
7874 M (MPLS_IP_BIND_UNBIND, mp);
7876 mp->mb_create_table_if_needed = create_table_if_needed;
7877 mp->mb_is_bind = is_bind;
7878 mp->mb_is_ip4 = is_ip4;
7879 mp->mb_ip_table_id = ntohl (ip_table_id);
7880 mp->mb_mpls_table_id = 0;
7881 mp->mb_label = ntohl (local_label);
7882 mp->mb_address_length = address_length;
7885 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
7887 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
7892 /* Wait for a reply... */
7898 api_proxy_arp_add_del (vat_main_t * vam)
7900 unformat_input_t *i = vam->input;
7901 vl_api_proxy_arp_add_del_t *mp;
7904 ip4_address_t lo, hi;
7908 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7910 if (unformat (i, "vrf %d", &vrf_id))
7912 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
7913 unformat_ip4_address, &hi))
7915 else if (unformat (i, "del"))
7919 clib_warning ("parse error '%U'", format_unformat_error, i);
7926 errmsg ("address range not set");
7930 M (PROXY_ARP_ADD_DEL, mp);
7932 mp->vrf_id = ntohl (vrf_id);
7933 mp->is_add = is_add;
7934 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
7935 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
7943 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
7945 unformat_input_t *i = vam->input;
7946 vl_api_proxy_arp_intfc_enable_disable_t *mp;
7949 u8 sw_if_index_set = 0;
7952 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7954 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7955 sw_if_index_set = 1;
7956 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7957 sw_if_index_set = 1;
7958 else if (unformat (i, "enable"))
7960 else if (unformat (i, "disable"))
7964 clib_warning ("parse error '%U'", format_unformat_error, i);
7969 if (sw_if_index_set == 0)
7971 errmsg ("missing interface name or sw_if_index");
7975 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
7977 mp->sw_if_index = ntohl (sw_if_index);
7978 mp->enable_disable = enable;
7986 api_mpls_tunnel_add_del (vat_main_t * vam)
7988 unformat_input_t *i = vam->input;
7989 vl_api_mpls_tunnel_add_del_t *mp;
7993 u32 sw_if_index = ~0;
7994 u32 next_hop_sw_if_index = ~0;
7995 u32 next_hop_proto_is_ip4 = 1;
7997 u32 next_hop_table_id = 0;
7998 ip4_address_t v4_next_hop_address = {
8001 ip6_address_t v6_next_hop_address = { {0} };
8002 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
8005 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8007 if (unformat (i, "add"))
8009 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
8011 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
8013 else if (unformat (i, "via %U",
8014 unformat_ip4_address, &v4_next_hop_address))
8016 next_hop_proto_is_ip4 = 1;
8018 else if (unformat (i, "via %U",
8019 unformat_ip6_address, &v6_next_hop_address))
8021 next_hop_proto_is_ip4 = 0;
8023 else if (unformat (i, "l2-only"))
8025 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
8027 else if (unformat (i, "out-label %d", &next_hop_out_label))
8028 vec_add1 (labels, ntohl (next_hop_out_label));
8031 clib_warning ("parse error '%U'", format_unformat_error, i);
8036 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
8038 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
8039 mp->mt_sw_if_index = ntohl (sw_if_index);
8040 mp->mt_is_add = is_add;
8041 mp->mt_l2_only = l2_only;
8042 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
8043 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
8045 mp->mt_next_hop_n_out_labels = vec_len (labels);
8047 if (0 != mp->mt_next_hop_n_out_labels)
8049 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
8050 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
8054 if (next_hop_proto_is_ip4)
8056 clib_memcpy (mp->mt_next_hop,
8057 &v4_next_hop_address, sizeof (v4_next_hop_address));
8061 clib_memcpy (mp->mt_next_hop,
8062 &v6_next_hop_address, sizeof (v6_next_hop_address));
8071 api_sw_interface_set_unnumbered (vat_main_t * vam)
8073 unformat_input_t *i = vam->input;
8074 vl_api_sw_interface_set_unnumbered_t *mp;
8076 u32 unnum_sw_index = ~0;
8078 u8 sw_if_index_set = 0;
8081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8083 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8084 sw_if_index_set = 1;
8085 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8086 sw_if_index_set = 1;
8087 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
8089 else if (unformat (i, "del"))
8093 clib_warning ("parse error '%U'", format_unformat_error, i);
8098 if (sw_if_index_set == 0)
8100 errmsg ("missing interface name or sw_if_index");
8104 M (SW_INTERFACE_SET_UNNUMBERED, mp);
8106 mp->sw_if_index = ntohl (sw_if_index);
8107 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
8108 mp->is_add = is_add;
8116 api_ip_neighbor_add_del (vat_main_t * vam)
8118 unformat_input_t *i = vam->input;
8119 vl_api_ip_neighbor_add_del_t *mp;
8121 u8 sw_if_index_set = 0;
8124 u8 is_no_fib_entry = 0;
8127 u8 v4_address_set = 0;
8128 u8 v6_address_set = 0;
8129 ip4_address_t v4address;
8130 ip6_address_t v6address;
8133 memset (mac_address, 0, sizeof (mac_address));
8135 /* Parse args required to build the message */
8136 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8138 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
8142 else if (unformat (i, "del"))
8145 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8146 sw_if_index_set = 1;
8147 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8148 sw_if_index_set = 1;
8149 else if (unformat (i, "is_static"))
8151 else if (unformat (i, "no-fib-entry"))
8152 is_no_fib_entry = 1;
8153 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
8155 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
8159 clib_warning ("parse error '%U'", format_unformat_error, i);
8164 if (sw_if_index_set == 0)
8166 errmsg ("missing interface name or sw_if_index");
8169 if (v4_address_set && v6_address_set)
8171 errmsg ("both v4 and v6 addresses set");
8174 if (!v4_address_set && !v6_address_set)
8176 errmsg ("no address set");
8180 /* Construct the API message */
8181 M (IP_NEIGHBOR_ADD_DEL, mp);
8183 mp->sw_if_index = ntohl (sw_if_index);
8184 mp->is_add = is_add;
8185 mp->is_static = is_static;
8186 mp->is_no_adj_fib = is_no_fib_entry;
8188 clib_memcpy (mp->mac_address, mac_address, 6);
8192 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
8196 /* mp->is_ipv6 = 0; via memset in M macro above */
8197 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
8203 /* Wait for a reply, return good/bad news */
8209 api_reset_vrf (vat_main_t * vam)
8211 unformat_input_t *i = vam->input;
8212 vl_api_reset_vrf_t *mp;
8218 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8220 if (unformat (i, "vrf %d", &vrf_id))
8222 else if (unformat (i, "ipv6"))
8226 clib_warning ("parse error '%U'", format_unformat_error, i);
8231 if (vrf_id_set == 0)
8233 errmsg ("missing vrf id");
8239 mp->vrf_id = ntohl (vrf_id);
8240 mp->is_ipv6 = is_ipv6;
8248 api_create_vlan_subif (vat_main_t * vam)
8250 unformat_input_t *i = vam->input;
8251 vl_api_create_vlan_subif_t *mp;
8253 u8 sw_if_index_set = 0;
8258 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8260 if (unformat (i, "sw_if_index %d", &sw_if_index))
8261 sw_if_index_set = 1;
8263 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8264 sw_if_index_set = 1;
8265 else if (unformat (i, "vlan %d", &vlan_id))
8269 clib_warning ("parse error '%U'", format_unformat_error, i);
8274 if (sw_if_index_set == 0)
8276 errmsg ("missing interface name or sw_if_index");
8280 if (vlan_id_set == 0)
8282 errmsg ("missing vlan_id");
8285 M (CREATE_VLAN_SUBIF, mp);
8287 mp->sw_if_index = ntohl (sw_if_index);
8288 mp->vlan_id = ntohl (vlan_id);
8295 #define foreach_create_subif_bit \
8302 _(outer_vlan_id_any) \
8303 _(inner_vlan_id_any)
8306 api_create_subif (vat_main_t * vam)
8308 unformat_input_t *i = vam->input;
8309 vl_api_create_subif_t *mp;
8311 u8 sw_if_index_set = 0;
8318 u32 exact_match = 0;
8319 u32 default_sub = 0;
8320 u32 outer_vlan_id_any = 0;
8321 u32 inner_vlan_id_any = 0;
8323 u16 outer_vlan_id = 0;
8324 u16 inner_vlan_id = 0;
8327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8329 if (unformat (i, "sw_if_index %d", &sw_if_index))
8330 sw_if_index_set = 1;
8332 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8333 sw_if_index_set = 1;
8334 else if (unformat (i, "sub_id %d", &sub_id))
8336 else if (unformat (i, "outer_vlan_id %d", &tmp))
8337 outer_vlan_id = tmp;
8338 else if (unformat (i, "inner_vlan_id %d", &tmp))
8339 inner_vlan_id = tmp;
8341 #define _(a) else if (unformat (i, #a)) a = 1 ;
8342 foreach_create_subif_bit
8346 clib_warning ("parse error '%U'", format_unformat_error, i);
8351 if (sw_if_index_set == 0)
8353 errmsg ("missing interface name or sw_if_index");
8357 if (sub_id_set == 0)
8359 errmsg ("missing sub_id");
8362 M (CREATE_SUBIF, mp);
8364 mp->sw_if_index = ntohl (sw_if_index);
8365 mp->sub_id = ntohl (sub_id);
8367 #define _(a) mp->a = a;
8368 foreach_create_subif_bit;
8371 mp->outer_vlan_id = ntohs (outer_vlan_id);
8372 mp->inner_vlan_id = ntohs (inner_vlan_id);
8380 api_oam_add_del (vat_main_t * vam)
8382 unformat_input_t *i = vam->input;
8383 vl_api_oam_add_del_t *mp;
8386 ip4_address_t src, dst;
8391 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8393 if (unformat (i, "vrf %d", &vrf_id))
8395 else if (unformat (i, "src %U", unformat_ip4_address, &src))
8397 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
8399 else if (unformat (i, "del"))
8403 clib_warning ("parse error '%U'", format_unformat_error, i);
8410 errmsg ("missing src addr");
8416 errmsg ("missing dst addr");
8420 M (OAM_ADD_DEL, mp);
8422 mp->vrf_id = ntohl (vrf_id);
8423 mp->is_add = is_add;
8424 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
8425 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
8433 api_reset_fib (vat_main_t * vam)
8435 unformat_input_t *i = vam->input;
8436 vl_api_reset_fib_t *mp;
8442 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8444 if (unformat (i, "vrf %d", &vrf_id))
8446 else if (unformat (i, "ipv6"))
8450 clib_warning ("parse error '%U'", format_unformat_error, i);
8455 if (vrf_id_set == 0)
8457 errmsg ("missing vrf id");
8463 mp->vrf_id = ntohl (vrf_id);
8464 mp->is_ipv6 = is_ipv6;
8472 api_dhcp_proxy_config (vat_main_t * vam)
8474 unformat_input_t *i = vam->input;
8475 vl_api_dhcp_proxy_config_t *mp;
8477 u32 server_vrf_id = 0;
8479 u8 v4_address_set = 0;
8480 u8 v6_address_set = 0;
8481 ip4_address_t v4address;
8482 ip6_address_t v6address;
8483 u8 v4_src_address_set = 0;
8484 u8 v6_src_address_set = 0;
8485 ip4_address_t v4srcaddress;
8486 ip6_address_t v6srcaddress;
8489 /* Parse args required to build the message */
8490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8492 if (unformat (i, "del"))
8494 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
8496 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
8498 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
8500 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
8502 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
8503 v4_src_address_set = 1;
8504 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
8505 v6_src_address_set = 1;
8510 if (v4_address_set && v6_address_set)
8512 errmsg ("both v4 and v6 server addresses set");
8515 if (!v4_address_set && !v6_address_set)
8517 errmsg ("no server addresses set");
8521 if (v4_src_address_set && v6_src_address_set)
8523 errmsg ("both v4 and v6 src addresses set");
8526 if (!v4_src_address_set && !v6_src_address_set)
8528 errmsg ("no src addresses set");
8532 if (!(v4_src_address_set && v4_address_set) &&
8533 !(v6_src_address_set && v6_address_set))
8535 errmsg ("no matching server and src addresses set");
8539 /* Construct the API message */
8540 M (DHCP_PROXY_CONFIG, mp);
8542 mp->is_add = is_add;
8543 mp->rx_vrf_id = ntohl (rx_vrf_id);
8544 mp->server_vrf_id = ntohl (server_vrf_id);
8548 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
8549 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
8553 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
8554 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
8560 /* Wait for a reply, return good/bad news */
8565 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
8566 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
8569 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
8571 vat_main_t *vam = &vat_main;
8572 u32 i, count = mp->count;
8573 vl_api_dhcp_server_t *s;
8577 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8578 ntohl (mp->rx_vrf_id),
8579 format_ip6_address, mp->dhcp_src_address,
8580 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8583 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
8584 ntohl (mp->rx_vrf_id),
8585 format_ip4_address, mp->dhcp_src_address,
8586 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
8588 for (i = 0; i < count; i++)
8590 s = &mp->servers[i];
8594 " Server Table-ID %d, Server Address %U",
8595 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
8598 " Server Table-ID %d, Server Address %U",
8599 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
8603 static void vl_api_dhcp_proxy_details_t_handler_json
8604 (vl_api_dhcp_proxy_details_t * mp)
8606 vat_main_t *vam = &vat_main;
8607 vat_json_node_t *node = NULL;
8608 u32 i, count = mp->count;
8610 struct in6_addr ip6;
8611 vl_api_dhcp_server_t *s;
8613 if (VAT_JSON_ARRAY != vam->json_tree.type)
8615 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
8616 vat_json_init_array (&vam->json_tree);
8618 node = vat_json_array_add (&vam->json_tree);
8620 vat_json_init_object (node);
8621 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
8622 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
8623 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
8627 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
8628 vat_json_object_add_ip6 (node, "src_address", ip6);
8632 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
8633 vat_json_object_add_ip4 (node, "src_address", ip4);
8636 for (i = 0; i < count; i++)
8638 s = &mp->servers[i];
8640 vat_json_object_add_uint (node, "server-table-id",
8641 ntohl (s->server_vrf_id));
8645 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
8646 vat_json_object_add_ip4 (node, "src_address", ip4);
8650 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
8651 vat_json_object_add_ip6 (node, "server_address", ip6);
8657 api_dhcp_proxy_dump (vat_main_t * vam)
8659 unformat_input_t *i = vam->input;
8660 vl_api_control_ping_t *mp_ping;
8661 vl_api_dhcp_proxy_dump_t *mp;
8665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8667 if (unformat (i, "ipv6"))
8671 clib_warning ("parse error '%U'", format_unformat_error, i);
8676 M (DHCP_PROXY_DUMP, mp);
8678 mp->is_ip6 = is_ipv6;
8681 /* Use a control ping for synchronization */
8682 M (CONTROL_PING, mp_ping);
8690 api_dhcp_proxy_set_vss (vat_main_t * vam)
8692 unformat_input_t *i = vam->input;
8693 vl_api_dhcp_proxy_set_vss_t *mp;
8704 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8706 if (unformat (i, "tbl_id %d", &tbl_id))
8708 if (unformat (i, "fib_id %d", &fib_id))
8710 if (unformat (i, "oui %d", &oui))
8712 else if (unformat (i, "ipv6"))
8714 else if (unformat (i, "del"))
8718 clib_warning ("parse error '%U'", format_unformat_error, i);
8723 if (tbl_id_set == 0)
8725 errmsg ("missing tbl id");
8729 if (fib_id_set == 0)
8731 errmsg ("missing fib id");
8736 errmsg ("missing oui");
8740 M (DHCP_PROXY_SET_VSS, mp);
8741 mp->tbl_id = ntohl (tbl_id);
8742 mp->fib_id = ntohl (fib_id);
8743 mp->oui = ntohl (oui);
8744 mp->is_ipv6 = is_ipv6;
8745 mp->is_add = is_add;
8753 api_dhcp_client_config (vat_main_t * vam)
8755 unformat_input_t *i = vam->input;
8756 vl_api_dhcp_client_config_t *mp;
8758 u8 sw_if_index_set = 0;
8761 u8 disable_event = 0;
8764 /* Parse args required to build the message */
8765 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8767 if (unformat (i, "del"))
8770 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8771 sw_if_index_set = 1;
8772 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8773 sw_if_index_set = 1;
8774 else if (unformat (i, "hostname %s", &hostname))
8776 else if (unformat (i, "disable_event"))
8782 if (sw_if_index_set == 0)
8784 errmsg ("missing interface name or sw_if_index");
8788 if (vec_len (hostname) > 63)
8790 errmsg ("hostname too long");
8792 vec_add1 (hostname, 0);
8794 /* Construct the API message */
8795 M (DHCP_CLIENT_CONFIG, mp);
8797 mp->sw_if_index = htonl (sw_if_index);
8798 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
8799 vec_free (hostname);
8800 mp->is_add = is_add;
8801 mp->want_dhcp_event = disable_event ? 0 : 1;
8802 mp->pid = htonl (getpid ());
8807 /* Wait for a reply, return good/bad news */
8813 api_set_ip_flow_hash (vat_main_t * vam)
8815 unformat_input_t *i = vam->input;
8816 vl_api_set_ip_flow_hash_t *mp;
8828 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8830 if (unformat (i, "vrf %d", &vrf_id))
8832 else if (unformat (i, "ipv6"))
8834 else if (unformat (i, "src"))
8836 else if (unformat (i, "dst"))
8838 else if (unformat (i, "sport"))
8840 else if (unformat (i, "dport"))
8842 else if (unformat (i, "proto"))
8844 else if (unformat (i, "reverse"))
8849 clib_warning ("parse error '%U'", format_unformat_error, i);
8854 if (vrf_id_set == 0)
8856 errmsg ("missing vrf id");
8860 M (SET_IP_FLOW_HASH, mp);
8866 mp->reverse = reverse;
8867 mp->vrf_id = ntohl (vrf_id);
8868 mp->is_ipv6 = is_ipv6;
8876 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
8878 unformat_input_t *i = vam->input;
8879 vl_api_sw_interface_ip6_enable_disable_t *mp;
8881 u8 sw_if_index_set = 0;
8885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8887 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8888 sw_if_index_set = 1;
8889 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8890 sw_if_index_set = 1;
8891 else if (unformat (i, "enable"))
8893 else if (unformat (i, "disable"))
8897 clib_warning ("parse error '%U'", format_unformat_error, i);
8902 if (sw_if_index_set == 0)
8904 errmsg ("missing interface name or sw_if_index");
8908 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
8910 mp->sw_if_index = ntohl (sw_if_index);
8911 mp->enable = enable;
8919 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
8921 unformat_input_t *i = vam->input;
8922 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
8924 u8 sw_if_index_set = 0;
8925 u8 v6_address_set = 0;
8926 ip6_address_t v6address;
8929 /* Parse args required to build the message */
8930 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8932 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8933 sw_if_index_set = 1;
8934 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8935 sw_if_index_set = 1;
8936 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8942 if (sw_if_index_set == 0)
8944 errmsg ("missing interface name or sw_if_index");
8947 if (!v6_address_set)
8949 errmsg ("no address set");
8953 /* Construct the API message */
8954 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
8956 mp->sw_if_index = ntohl (sw_if_index);
8957 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8962 /* Wait for a reply, return good/bad news */
8968 api_ip6nd_proxy_add_del (vat_main_t * vam)
8970 unformat_input_t *i = vam->input;
8971 vl_api_ip6nd_proxy_add_del_t *mp;
8972 u32 sw_if_index = ~0;
8973 u8 v6_address_set = 0;
8974 ip6_address_t v6address;
8978 /* Parse args required to build the message */
8979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8981 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8983 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8985 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
8987 if (unformat (i, "del"))
8991 clib_warning ("parse error '%U'", format_unformat_error, i);
8996 if (sw_if_index == ~0)
8998 errmsg ("missing interface name or sw_if_index");
9001 if (!v6_address_set)
9003 errmsg ("no address set");
9007 /* Construct the API message */
9008 M (IP6ND_PROXY_ADD_DEL, mp);
9010 mp->is_del = is_del;
9011 mp->sw_if_index = ntohl (sw_if_index);
9012 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9017 /* Wait for a reply, return good/bad news */
9023 api_ip6nd_proxy_dump (vat_main_t * vam)
9025 vl_api_ip6nd_proxy_dump_t *mp;
9026 vl_api_control_ping_t *mp_ping;
9029 M (IP6ND_PROXY_DUMP, mp);
9033 /* Use a control ping for synchronization */
9034 M (CONTROL_PING, mp_ping);
9041 static void vl_api_ip6nd_proxy_details_t_handler
9042 (vl_api_ip6nd_proxy_details_t * mp)
9044 vat_main_t *vam = &vat_main;
9046 print (vam->ofp, "host %U sw_if_index %d",
9047 format_ip6_address, mp->address, ntohl (mp->sw_if_index));
9050 static void vl_api_ip6nd_proxy_details_t_handler_json
9051 (vl_api_ip6nd_proxy_details_t * mp)
9053 vat_main_t *vam = &vat_main;
9054 struct in6_addr ip6;
9055 vat_json_node_t *node = NULL;
9057 if (VAT_JSON_ARRAY != vam->json_tree.type)
9059 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
9060 vat_json_init_array (&vam->json_tree);
9062 node = vat_json_array_add (&vam->json_tree);
9064 vat_json_init_object (node);
9065 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
9067 clib_memcpy (&ip6, mp->address, sizeof (ip6));
9068 vat_json_object_add_ip6 (node, "host", ip6);
9072 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
9074 unformat_input_t *i = vam->input;
9075 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
9077 u8 sw_if_index_set = 0;
9078 u32 address_length = 0;
9079 u8 v6_address_set = 0;
9080 ip6_address_t v6address;
9082 u8 no_advertise = 0;
9084 u8 no_autoconfig = 0;
9087 u32 val_lifetime = 0;
9088 u32 pref_lifetime = 0;
9091 /* Parse args required to build the message */
9092 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9094 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9095 sw_if_index_set = 1;
9096 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9097 sw_if_index_set = 1;
9098 else if (unformat (i, "%U/%d",
9099 unformat_ip6_address, &v6address, &address_length))
9101 else if (unformat (i, "val_life %d", &val_lifetime))
9103 else if (unformat (i, "pref_life %d", &pref_lifetime))
9105 else if (unformat (i, "def"))
9107 else if (unformat (i, "noadv"))
9109 else if (unformat (i, "offl"))
9111 else if (unformat (i, "noauto"))
9113 else if (unformat (i, "nolink"))
9115 else if (unformat (i, "isno"))
9119 clib_warning ("parse error '%U'", format_unformat_error, i);
9124 if (sw_if_index_set == 0)
9126 errmsg ("missing interface name or sw_if_index");
9129 if (!v6_address_set)
9131 errmsg ("no address set");
9135 /* Construct the API message */
9136 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
9138 mp->sw_if_index = ntohl (sw_if_index);
9139 clib_memcpy (mp->address, &v6address, sizeof (v6address));
9140 mp->address_length = address_length;
9141 mp->use_default = use_default;
9142 mp->no_advertise = no_advertise;
9143 mp->off_link = off_link;
9144 mp->no_autoconfig = no_autoconfig;
9145 mp->no_onlink = no_onlink;
9147 mp->val_lifetime = ntohl (val_lifetime);
9148 mp->pref_lifetime = ntohl (pref_lifetime);
9153 /* Wait for a reply, return good/bad news */
9159 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
9161 unformat_input_t *i = vam->input;
9162 vl_api_sw_interface_ip6nd_ra_config_t *mp;
9164 u8 sw_if_index_set = 0;
9169 u8 send_unicast = 0;
9172 u8 default_router = 0;
9173 u32 max_interval = 0;
9174 u32 min_interval = 0;
9176 u32 initial_count = 0;
9177 u32 initial_interval = 0;
9181 /* Parse args required to build the message */
9182 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9184 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9185 sw_if_index_set = 1;
9186 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9187 sw_if_index_set = 1;
9188 else if (unformat (i, "maxint %d", &max_interval))
9190 else if (unformat (i, "minint %d", &min_interval))
9192 else if (unformat (i, "life %d", &lifetime))
9194 else if (unformat (i, "count %d", &initial_count))
9196 else if (unformat (i, "interval %d", &initial_interval))
9198 else if (unformat (i, "suppress") || unformat (i, "surpress"))
9200 else if (unformat (i, "managed"))
9202 else if (unformat (i, "other"))
9204 else if (unformat (i, "ll"))
9206 else if (unformat (i, "send"))
9208 else if (unformat (i, "cease"))
9210 else if (unformat (i, "isno"))
9212 else if (unformat (i, "def"))
9216 clib_warning ("parse error '%U'", format_unformat_error, i);
9221 if (sw_if_index_set == 0)
9223 errmsg ("missing interface name or sw_if_index");
9227 /* Construct the API message */
9228 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
9230 mp->sw_if_index = ntohl (sw_if_index);
9231 mp->max_interval = ntohl (max_interval);
9232 mp->min_interval = ntohl (min_interval);
9233 mp->lifetime = ntohl (lifetime);
9234 mp->initial_count = ntohl (initial_count);
9235 mp->initial_interval = ntohl (initial_interval);
9236 mp->suppress = suppress;
9237 mp->managed = managed;
9239 mp->ll_option = ll_option;
9240 mp->send_unicast = send_unicast;
9243 mp->default_router = default_router;
9248 /* Wait for a reply, return good/bad news */
9254 api_set_arp_neighbor_limit (vat_main_t * vam)
9256 unformat_input_t *i = vam->input;
9257 vl_api_set_arp_neighbor_limit_t *mp;
9263 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9265 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
9267 else if (unformat (i, "ipv6"))
9271 clib_warning ("parse error '%U'", format_unformat_error, i);
9278 errmsg ("missing limit value");
9282 M (SET_ARP_NEIGHBOR_LIMIT, mp);
9284 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
9285 mp->is_ipv6 = is_ipv6;
9293 api_l2_patch_add_del (vat_main_t * vam)
9295 unformat_input_t *i = vam->input;
9296 vl_api_l2_patch_add_del_t *mp;
9298 u8 rx_sw_if_index_set = 0;
9300 u8 tx_sw_if_index_set = 0;
9304 /* Parse args required to build the message */
9305 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9307 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
9308 rx_sw_if_index_set = 1;
9309 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
9310 tx_sw_if_index_set = 1;
9311 else if (unformat (i, "rx"))
9313 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9315 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9317 rx_sw_if_index_set = 1;
9322 else if (unformat (i, "tx"))
9324 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9326 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
9328 tx_sw_if_index_set = 1;
9333 else if (unformat (i, "del"))
9339 if (rx_sw_if_index_set == 0)
9341 errmsg ("missing rx interface name or rx_sw_if_index");
9345 if (tx_sw_if_index_set == 0)
9347 errmsg ("missing tx interface name or tx_sw_if_index");
9351 M (L2_PATCH_ADD_DEL, mp);
9353 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
9354 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
9355 mp->is_add = is_add;
9363 u8 localsid_addr[16];
9372 api_sr_localsid_add_del (vat_main_t * vam)
9374 unformat_input_t *i = vam->input;
9375 vl_api_sr_localsid_add_del_t *mp;
9378 ip6_address_t localsid;
9382 u32 fib_table = ~(u32) 0;
9383 ip6_address_t next_hop;
9385 bool nexthop_set = 0;
9389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9391 if (unformat (i, "del"))
9393 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
9394 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
9396 else if (unformat (i, "behavior %u", &behavior));
9397 else if (unformat (i, "sw_if_index %u", &sw_if_index));
9398 else if (unformat (i, "fib-table %u", &fib_table));
9399 else if (unformat (i, "end.psp %u", &behavior));
9404 M (SR_LOCALSID_ADD_DEL, mp);
9406 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
9408 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
9409 mp->behavior = behavior;
9410 mp->sw_if_index = ntohl (sw_if_index);
9411 mp->fib_table = ntohl (fib_table);
9412 mp->end_psp = end_psp;
9413 mp->is_del = is_del;
9421 api_ioam_enable (vat_main_t * vam)
9423 unformat_input_t *input = vam->input;
9424 vl_api_ioam_enable_t *mp;
9426 int has_trace_option = 0;
9427 int has_pot_option = 0;
9428 int has_seqno_option = 0;
9429 int has_analyse_option = 0;
9432 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9434 if (unformat (input, "trace"))
9435 has_trace_option = 1;
9436 else if (unformat (input, "pot"))
9438 else if (unformat (input, "seqno"))
9439 has_seqno_option = 1;
9440 else if (unformat (input, "analyse"))
9441 has_analyse_option = 1;
9445 M (IOAM_ENABLE, mp);
9446 mp->id = htons (id);
9447 mp->seqno = has_seqno_option;
9448 mp->analyse = has_analyse_option;
9449 mp->pot_enable = has_pot_option;
9450 mp->trace_enable = has_trace_option;
9459 api_ioam_disable (vat_main_t * vam)
9461 vl_api_ioam_disable_t *mp;
9464 M (IOAM_DISABLE, mp);
9470 #define foreach_tcp_proto_field \
9474 #define foreach_udp_proto_field \
9478 #define foreach_ip4_proto_field \
9490 u16 src_port, dst_port;
9493 #if VPP_API_TEST_BUILTIN == 0
9495 unformat_tcp_mask (unformat_input_t * input, va_list * args)
9497 u8 **maskp = va_arg (*args, u8 **);
9499 u8 found_something = 0;
9502 #define _(a) u8 a=0;
9503 foreach_tcp_proto_field;
9506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9509 #define _(a) else if (unformat (input, #a)) a=1;
9510 foreach_tcp_proto_field
9516 #define _(a) found_something += a;
9517 foreach_tcp_proto_field;
9520 if (found_something == 0)
9523 vec_validate (mask, sizeof (*tcp) - 1);
9525 tcp = (tcp_header_t *) mask;
9527 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
9528 foreach_tcp_proto_field;
9536 unformat_udp_mask (unformat_input_t * input, va_list * args)
9538 u8 **maskp = va_arg (*args, u8 **);
9540 u8 found_something = 0;
9543 #define _(a) u8 a=0;
9544 foreach_udp_proto_field;
9547 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9550 #define _(a) else if (unformat (input, #a)) a=1;
9551 foreach_udp_proto_field
9557 #define _(a) found_something += a;
9558 foreach_udp_proto_field;
9561 if (found_something == 0)
9564 vec_validate (mask, sizeof (*udp) - 1);
9566 udp = (udp_header_t *) mask;
9568 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
9569 foreach_udp_proto_field;
9577 unformat_l4_mask (unformat_input_t * input, va_list * args)
9579 u8 **maskp = va_arg (*args, u8 **);
9580 u16 src_port = 0, dst_port = 0;
9581 tcpudp_header_t *tcpudp;
9583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9585 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
9587 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
9589 else if (unformat (input, "src_port"))
9591 else if (unformat (input, "dst_port"))
9597 if (!src_port && !dst_port)
9601 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
9603 tcpudp = (tcpudp_header_t *) mask;
9604 tcpudp->src_port = src_port;
9605 tcpudp->dst_port = dst_port;
9613 unformat_ip4_mask (unformat_input_t * input, va_list * args)
9615 u8 **maskp = va_arg (*args, u8 **);
9617 u8 found_something = 0;
9620 #define _(a) u8 a=0;
9621 foreach_ip4_proto_field;
9627 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9629 if (unformat (input, "version"))
9631 else if (unformat (input, "hdr_length"))
9633 else if (unformat (input, "src"))
9635 else if (unformat (input, "dst"))
9637 else if (unformat (input, "proto"))
9640 #define _(a) else if (unformat (input, #a)) a=1;
9641 foreach_ip4_proto_field
9647 #define _(a) found_something += a;
9648 foreach_ip4_proto_field;
9651 if (found_something == 0)
9654 vec_validate (mask, sizeof (*ip) - 1);
9656 ip = (ip4_header_t *) mask;
9658 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9659 foreach_ip4_proto_field;
9662 ip->ip_version_and_header_length = 0;
9665 ip->ip_version_and_header_length |= 0xF0;
9668 ip->ip_version_and_header_length |= 0x0F;
9674 #define foreach_ip6_proto_field \
9682 unformat_ip6_mask (unformat_input_t * input, va_list * args)
9684 u8 **maskp = va_arg (*args, u8 **);
9686 u8 found_something = 0;
9688 u32 ip_version_traffic_class_and_flow_label;
9690 #define _(a) u8 a=0;
9691 foreach_ip6_proto_field;
9694 u8 traffic_class = 0;
9697 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9699 if (unformat (input, "version"))
9701 else if (unformat (input, "traffic-class"))
9703 else if (unformat (input, "flow-label"))
9705 else if (unformat (input, "src"))
9707 else if (unformat (input, "dst"))
9709 else if (unformat (input, "proto"))
9712 #define _(a) else if (unformat (input, #a)) a=1;
9713 foreach_ip6_proto_field
9719 #define _(a) found_something += a;
9720 foreach_ip6_proto_field;
9723 if (found_something == 0)
9726 vec_validate (mask, sizeof (*ip) - 1);
9728 ip = (ip6_header_t *) mask;
9730 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
9731 foreach_ip6_proto_field;
9734 ip_version_traffic_class_and_flow_label = 0;
9737 ip_version_traffic_class_and_flow_label |= 0xF0000000;
9740 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
9743 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
9745 ip->ip_version_traffic_class_and_flow_label =
9746 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9753 unformat_l3_mask (unformat_input_t * input, va_list * args)
9755 u8 **maskp = va_arg (*args, u8 **);
9757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9759 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
9761 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
9770 unformat_l2_mask (unformat_input_t * input, va_list * args)
9772 u8 **maskp = va_arg (*args, u8 **);
9787 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9789 if (unformat (input, "src"))
9791 else if (unformat (input, "dst"))
9793 else if (unformat (input, "proto"))
9795 else if (unformat (input, "tag1"))
9797 else if (unformat (input, "tag2"))
9799 else if (unformat (input, "ignore-tag1"))
9801 else if (unformat (input, "ignore-tag2"))
9803 else if (unformat (input, "cos1"))
9805 else if (unformat (input, "cos2"))
9807 else if (unformat (input, "dot1q"))
9809 else if (unformat (input, "dot1ad"))
9814 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
9815 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9818 if (tag1 || ignore_tag1 || cos1 || dot1q)
9820 if (tag2 || ignore_tag2 || cos2 || dot1ad)
9823 vec_validate (mask, len - 1);
9826 memset (mask, 0xff, 6);
9829 memset (mask + 6, 0xff, 6);
9833 /* inner vlan tag */
9842 mask[21] = mask[20] = 0xff;
9863 mask[16] = mask[17] = 0xff;
9873 mask[12] = mask[13] = 0xff;
9880 unformat_classify_mask (unformat_input_t * input, va_list * args)
9882 u8 **maskp = va_arg (*args, u8 **);
9883 u32 *skipp = va_arg (*args, u32 *);
9884 u32 *matchp = va_arg (*args, u32 *);
9892 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9894 if (unformat (input, "hex %U", unformat_hex_string, &mask))
9896 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
9898 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
9900 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
9914 if (mask || l2 || l3 || l4)
9918 /* "With a free Ethernet header in every package" */
9920 vec_validate (l2, 13);
9924 vec_append (mask, l3);
9929 vec_append (mask, l4);
9934 /* Scan forward looking for the first significant mask octet */
9935 for (i = 0; i < vec_len (mask); i++)
9939 /* compute (skip, match) params */
9940 *skipp = i / sizeof (u32x4);
9941 vec_delete (mask, *skipp * sizeof (u32x4), 0);
9943 /* Pad mask to an even multiple of the vector size */
9944 while (vec_len (mask) % sizeof (u32x4))
9947 match = vec_len (mask) / sizeof (u32x4);
9949 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
9951 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
9952 if (*tmp || *(tmp + 1))
9957 clib_warning ("BUG: match 0");
9959 _vec_len (mask) = match * sizeof (u32x4);
9969 #endif /* VPP_API_TEST_BUILTIN */
9971 #define foreach_l2_next \
9973 _(ethernet, ETHERNET_INPUT) \
9978 unformat_l2_next_index (unformat_input_t * input, va_list * args)
9980 u32 *miss_next_indexp = va_arg (*args, u32 *);
9985 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
9989 if (unformat (input, "%d", &tmp))
9998 *miss_next_indexp = next_index;
10002 #define foreach_ip_next \
10005 _(rewrite, REWRITE)
10008 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
10010 u32 *miss_next_indexp = va_arg (*args, u32 *);
10011 u32 next_index = 0;
10015 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
10019 if (unformat (input, "%d", &tmp))
10028 *miss_next_indexp = next_index;
10032 #define foreach_acl_next \
10036 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
10038 u32 *miss_next_indexp = va_arg (*args, u32 *);
10039 u32 next_index = 0;
10043 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
10047 if (unformat (input, "permit"))
10052 else if (unformat (input, "%d", &tmp))
10061 *miss_next_indexp = next_index;
10066 unformat_policer_precolor (unformat_input_t * input, va_list * args)
10068 u32 *r = va_arg (*args, u32 *);
10070 if (unformat (input, "conform-color"))
10071 *r = POLICE_CONFORM;
10072 else if (unformat (input, "exceed-color"))
10073 *r = POLICE_EXCEED;
10081 api_classify_add_del_table (vat_main_t * vam)
10083 unformat_input_t *i = vam->input;
10084 vl_api_classify_add_del_table_t *mp;
10091 u32 table_index = ~0;
10092 u32 next_table_index = ~0;
10093 u32 miss_next_index = ~0;
10094 u32 memory_size = 32 << 20;
10096 u32 current_data_flag = 0;
10097 int current_data_offset = 0;
10100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10102 if (unformat (i, "del"))
10104 else if (unformat (i, "del-chain"))
10109 else if (unformat (i, "buckets %d", &nbuckets))
10111 else if (unformat (i, "memory_size %d", &memory_size))
10113 else if (unformat (i, "skip %d", &skip))
10115 else if (unformat (i, "match %d", &match))
10117 else if (unformat (i, "table %d", &table_index))
10119 else if (unformat (i, "mask %U", unformat_classify_mask,
10120 &mask, &skip, &match))
10122 else if (unformat (i, "next-table %d", &next_table_index))
10124 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
10127 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
10130 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
10133 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
10135 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
10141 if (is_add && mask == 0)
10143 errmsg ("Mask required");
10147 if (is_add && skip == ~0)
10149 errmsg ("skip count required");
10153 if (is_add && match == ~0)
10155 errmsg ("match count required");
10159 if (!is_add && table_index == ~0)
10161 errmsg ("table index required for delete");
10165 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
10167 mp->is_add = is_add;
10168 mp->del_chain = del_chain;
10169 mp->table_index = ntohl (table_index);
10170 mp->nbuckets = ntohl (nbuckets);
10171 mp->memory_size = ntohl (memory_size);
10172 mp->skip_n_vectors = ntohl (skip);
10173 mp->match_n_vectors = ntohl (match);
10174 mp->next_table_index = ntohl (next_table_index);
10175 mp->miss_next_index = ntohl (miss_next_index);
10176 mp->current_data_flag = ntohl (current_data_flag);
10177 mp->current_data_offset = ntohl (current_data_offset);
10178 clib_memcpy (mp->mask, mask, vec_len (mask));
10187 #if VPP_API_TEST_BUILTIN == 0
10189 unformat_l4_match (unformat_input_t * input, va_list * args)
10191 u8 **matchp = va_arg (*args, u8 **);
10193 u8 *proto_header = 0;
10199 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10201 if (unformat (input, "src_port %d", &src_port))
10203 else if (unformat (input, "dst_port %d", &dst_port))
10209 h.src_port = clib_host_to_net_u16 (src_port);
10210 h.dst_port = clib_host_to_net_u16 (dst_port);
10211 vec_validate (proto_header, sizeof (h) - 1);
10212 memcpy (proto_header, &h, sizeof (h));
10214 *matchp = proto_header;
10220 unformat_ip4_match (unformat_input_t * input, va_list * args)
10222 u8 **matchp = va_arg (*args, u8 **);
10227 int hdr_length = 0;
10228 u32 hdr_length_val;
10229 int src = 0, dst = 0;
10230 ip4_address_t src_val, dst_val;
10237 int fragment_id = 0;
10238 u32 fragment_id_val;
10244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10246 if (unformat (input, "version %d", &version_val))
10248 else if (unformat (input, "hdr_length %d", &hdr_length_val))
10250 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
10252 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
10254 else if (unformat (input, "proto %d", &proto_val))
10256 else if (unformat (input, "tos %d", &tos_val))
10258 else if (unformat (input, "length %d", &length_val))
10260 else if (unformat (input, "fragment_id %d", &fragment_id_val))
10262 else if (unformat (input, "ttl %d", &ttl_val))
10264 else if (unformat (input, "checksum %d", &checksum_val))
10270 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
10271 + ttl + checksum == 0)
10275 * Aligned because we use the real comparison functions
10277 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10279 ip = (ip4_header_t *) match;
10281 /* These are realistically matched in practice */
10283 ip->src_address.as_u32 = src_val.as_u32;
10286 ip->dst_address.as_u32 = dst_val.as_u32;
10289 ip->protocol = proto_val;
10292 /* These are not, but they're included for completeness */
10294 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
10297 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
10303 ip->length = clib_host_to_net_u16 (length_val);
10309 ip->checksum = clib_host_to_net_u16 (checksum_val);
10316 unformat_ip6_match (unformat_input_t * input, va_list * args)
10318 u8 **matchp = va_arg (*args, u8 **);
10323 u8 traffic_class = 0;
10324 u32 traffic_class_val = 0;
10327 int src = 0, dst = 0;
10328 ip6_address_t src_val, dst_val;
10331 int payload_length = 0;
10332 u32 payload_length_val;
10335 u32 ip_version_traffic_class_and_flow_label;
10337 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10339 if (unformat (input, "version %d", &version_val))
10341 else if (unformat (input, "traffic_class %d", &traffic_class_val))
10343 else if (unformat (input, "flow_label %d", &flow_label_val))
10345 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
10347 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
10349 else if (unformat (input, "proto %d", &proto_val))
10351 else if (unformat (input, "payload_length %d", &payload_length_val))
10352 payload_length = 1;
10353 else if (unformat (input, "hop_limit %d", &hop_limit_val))
10359 if (version + traffic_class + flow_label + src + dst + proto +
10360 payload_length + hop_limit == 0)
10364 * Aligned because we use the real comparison functions
10366 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
10368 ip = (ip6_header_t *) match;
10371 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
10374 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
10377 ip->protocol = proto_val;
10379 ip_version_traffic_class_and_flow_label = 0;
10382 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
10385 ip_version_traffic_class_and_flow_label |=
10386 (traffic_class_val & 0xFF) << 20;
10389 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
10391 ip->ip_version_traffic_class_and_flow_label =
10392 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
10394 if (payload_length)
10395 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
10398 ip->hop_limit = hop_limit_val;
10405 unformat_l3_match (unformat_input_t * input, va_list * args)
10407 u8 **matchp = va_arg (*args, u8 **);
10409 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10411 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
10413 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
10422 unformat_vlan_tag (unformat_input_t * input, va_list * args)
10424 u8 *tagp = va_arg (*args, u8 *);
10427 if (unformat (input, "%d", &tag))
10429 tagp[0] = (tag >> 8) & 0x0F;
10430 tagp[1] = tag & 0xFF;
10438 unformat_l2_match (unformat_input_t * input, va_list * args)
10440 u8 **matchp = va_arg (*args, u8 **);
10453 u8 ignore_tag1 = 0;
10454 u8 ignore_tag2 = 0;
10460 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10462 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
10465 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
10467 else if (unformat (input, "proto %U",
10468 unformat_ethernet_type_host_byte_order, &proto_val))
10470 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
10472 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
10474 else if (unformat (input, "ignore-tag1"))
10476 else if (unformat (input, "ignore-tag2"))
10478 else if (unformat (input, "cos1 %d", &cos1_val))
10480 else if (unformat (input, "cos2 %d", &cos2_val))
10485 if ((src + dst + proto + tag1 + tag2 +
10486 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
10489 if (tag1 || ignore_tag1 || cos1)
10491 if (tag2 || ignore_tag2 || cos2)
10494 vec_validate_aligned (match, len - 1, sizeof (u32x4));
10497 clib_memcpy (match, dst_val, 6);
10500 clib_memcpy (match + 6, src_val, 6);
10504 /* inner vlan tag */
10505 match[19] = tag2_val[1];
10506 match[18] = tag2_val[0];
10508 match[18] |= (cos2_val & 0x7) << 5;
10511 match[21] = proto_val & 0xff;
10512 match[20] = proto_val >> 8;
10516 match[15] = tag1_val[1];
10517 match[14] = tag1_val[0];
10520 match[14] |= (cos1_val & 0x7) << 5;
10526 match[15] = tag1_val[1];
10527 match[14] = tag1_val[0];
10530 match[17] = proto_val & 0xff;
10531 match[16] = proto_val >> 8;
10534 match[14] |= (cos1_val & 0x7) << 5;
10540 match[18] |= (cos2_val & 0x7) << 5;
10542 match[14] |= (cos1_val & 0x7) << 5;
10545 match[13] = proto_val & 0xff;
10546 match[12] = proto_val >> 8;
10555 api_unformat_classify_match (unformat_input_t * input, va_list * args)
10557 u8 **matchp = va_arg (*args, u8 **);
10558 u32 skip_n_vectors = va_arg (*args, u32);
10559 u32 match_n_vectors = va_arg (*args, u32);
10566 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
10568 if (unformat (input, "hex %U", unformat_hex_string, &match))
10570 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
10572 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
10574 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
10588 if (match || l2 || l3 || l4)
10590 if (l2 || l3 || l4)
10592 /* "Win a free Ethernet header in every packet" */
10594 vec_validate_aligned (l2, 13, sizeof (u32x4));
10598 vec_append_aligned (match, l3, sizeof (u32x4));
10603 vec_append_aligned (match, l4, sizeof (u32x4));
10608 /* Make sure the vector is big enough even if key is all 0's */
10609 vec_validate_aligned
10610 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
10613 /* Set size, include skipped vectors */
10614 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
10625 api_classify_add_del_session (vat_main_t * vam)
10627 unformat_input_t *i = vam->input;
10628 vl_api_classify_add_del_session_t *mp;
10630 u32 table_index = ~0;
10631 u32 hit_next_index = ~0;
10632 u32 opaque_index = ~0;
10635 u32 skip_n_vectors = 0;
10636 u32 match_n_vectors = 0;
10642 * Warning: you have to supply skip_n and match_n
10643 * because the API client cant simply look at the classify
10647 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10649 if (unformat (i, "del"))
10651 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
10654 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
10657 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
10660 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
10662 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
10664 else if (unformat (i, "opaque-index %d", &opaque_index))
10666 else if (unformat (i, "skip_n %d", &skip_n_vectors))
10668 else if (unformat (i, "match_n %d", &match_n_vectors))
10670 else if (unformat (i, "match %U", api_unformat_classify_match,
10671 &match, skip_n_vectors, match_n_vectors))
10673 else if (unformat (i, "advance %d", &advance))
10675 else if (unformat (i, "table-index %d", &table_index))
10677 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
10679 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
10681 else if (unformat (i, "action %d", &action))
10683 else if (unformat (i, "metadata %d", &metadata))
10689 if (table_index == ~0)
10691 errmsg ("Table index required");
10695 if (is_add && match == 0)
10697 errmsg ("Match value required");
10701 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
10703 mp->is_add = is_add;
10704 mp->table_index = ntohl (table_index);
10705 mp->hit_next_index = ntohl (hit_next_index);
10706 mp->opaque_index = ntohl (opaque_index);
10707 mp->advance = ntohl (advance);
10708 mp->action = action;
10709 mp->metadata = ntohl (metadata);
10710 clib_memcpy (mp->match, match, vec_len (match));
10719 api_classify_set_interface_ip_table (vat_main_t * vam)
10721 unformat_input_t *i = vam->input;
10722 vl_api_classify_set_interface_ip_table_t *mp;
10724 int sw_if_index_set;
10725 u32 table_index = ~0;
10729 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10731 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10732 sw_if_index_set = 1;
10733 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10734 sw_if_index_set = 1;
10735 else if (unformat (i, "table %d", &table_index))
10739 clib_warning ("parse error '%U'", format_unformat_error, i);
10744 if (sw_if_index_set == 0)
10746 errmsg ("missing interface name or sw_if_index");
10751 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
10753 mp->sw_if_index = ntohl (sw_if_index);
10754 mp->table_index = ntohl (table_index);
10755 mp->is_ipv6 = is_ipv6;
10763 api_classify_set_interface_l2_tables (vat_main_t * vam)
10765 unformat_input_t *i = vam->input;
10766 vl_api_classify_set_interface_l2_tables_t *mp;
10768 int sw_if_index_set;
10769 u32 ip4_table_index = ~0;
10770 u32 ip6_table_index = ~0;
10771 u32 other_table_index = ~0;
10775 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10777 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10778 sw_if_index_set = 1;
10779 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10780 sw_if_index_set = 1;
10781 else if (unformat (i, "ip4-table %d", &ip4_table_index))
10783 else if (unformat (i, "ip6-table %d", &ip6_table_index))
10785 else if (unformat (i, "other-table %d", &other_table_index))
10787 else if (unformat (i, "is-input %d", &is_input))
10791 clib_warning ("parse error '%U'", format_unformat_error, i);
10796 if (sw_if_index_set == 0)
10798 errmsg ("missing interface name or sw_if_index");
10803 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
10805 mp->sw_if_index = ntohl (sw_if_index);
10806 mp->ip4_table_index = ntohl (ip4_table_index);
10807 mp->ip6_table_index = ntohl (ip6_table_index);
10808 mp->other_table_index = ntohl (other_table_index);
10809 mp->is_input = (u8) is_input;
10817 api_set_ipfix_exporter (vat_main_t * vam)
10819 unformat_input_t *i = vam->input;
10820 vl_api_set_ipfix_exporter_t *mp;
10821 ip4_address_t collector_address;
10822 u8 collector_address_set = 0;
10823 u32 collector_port = ~0;
10824 ip4_address_t src_address;
10825 u8 src_address_set = 0;
10828 u32 template_interval = ~0;
10829 u8 udp_checksum = 0;
10832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10834 if (unformat (i, "collector_address %U", unformat_ip4_address,
10835 &collector_address))
10836 collector_address_set = 1;
10837 else if (unformat (i, "collector_port %d", &collector_port))
10839 else if (unformat (i, "src_address %U", unformat_ip4_address,
10841 src_address_set = 1;
10842 else if (unformat (i, "vrf_id %d", &vrf_id))
10844 else if (unformat (i, "path_mtu %d", &path_mtu))
10846 else if (unformat (i, "template_interval %d", &template_interval))
10848 else if (unformat (i, "udp_checksum"))
10854 if (collector_address_set == 0)
10856 errmsg ("collector_address required");
10860 if (src_address_set == 0)
10862 errmsg ("src_address required");
10866 M (SET_IPFIX_EXPORTER, mp);
10868 memcpy (mp->collector_address, collector_address.data,
10869 sizeof (collector_address.data));
10870 mp->collector_port = htons ((u16) collector_port);
10871 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
10872 mp->vrf_id = htonl (vrf_id);
10873 mp->path_mtu = htonl (path_mtu);
10874 mp->template_interval = htonl (template_interval);
10875 mp->udp_checksum = udp_checksum;
10883 api_set_ipfix_classify_stream (vat_main_t * vam)
10885 unformat_input_t *i = vam->input;
10886 vl_api_set_ipfix_classify_stream_t *mp;
10888 u32 src_port = UDP_DST_PORT_ipfix;
10891 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10893 if (unformat (i, "domain %d", &domain_id))
10895 else if (unformat (i, "src_port %d", &src_port))
10899 errmsg ("unknown input `%U'", format_unformat_error, i);
10904 M (SET_IPFIX_CLASSIFY_STREAM, mp);
10906 mp->domain_id = htonl (domain_id);
10907 mp->src_port = htons ((u16) src_port);
10915 api_ipfix_classify_table_add_del (vat_main_t * vam)
10917 unformat_input_t *i = vam->input;
10918 vl_api_ipfix_classify_table_add_del_t *mp;
10920 u32 classify_table_index = ~0;
10922 u8 transport_protocol = 255;
10925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10927 if (unformat (i, "add"))
10929 else if (unformat (i, "del"))
10931 else if (unformat (i, "table %d", &classify_table_index))
10933 else if (unformat (i, "ip4"))
10935 else if (unformat (i, "ip6"))
10937 else if (unformat (i, "tcp"))
10938 transport_protocol = 6;
10939 else if (unformat (i, "udp"))
10940 transport_protocol = 17;
10943 errmsg ("unknown input `%U'", format_unformat_error, i);
10950 errmsg ("expecting: add|del");
10953 if (classify_table_index == ~0)
10955 errmsg ("classifier table not specified");
10958 if (ip_version == 0)
10960 errmsg ("IP version not specified");
10964 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
10966 mp->is_add = is_add;
10967 mp->table_id = htonl (classify_table_index);
10968 mp->ip_version = ip_version;
10969 mp->transport_protocol = transport_protocol;
10977 api_get_node_index (vat_main_t * vam)
10979 unformat_input_t *i = vam->input;
10980 vl_api_get_node_index_t *mp;
10984 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10986 if (unformat (i, "node %s", &name))
10993 errmsg ("node name required");
10996 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
10998 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11002 M (GET_NODE_INDEX, mp);
11003 clib_memcpy (mp->node_name, name, vec_len (name));
11012 api_get_next_index (vat_main_t * vam)
11014 unformat_input_t *i = vam->input;
11015 vl_api_get_next_index_t *mp;
11016 u8 *node_name = 0, *next_node_name = 0;
11019 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11021 if (unformat (i, "node-name %s", &node_name))
11023 else if (unformat (i, "next-node-name %s", &next_node_name))
11027 if (node_name == 0)
11029 errmsg ("node name required");
11032 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
11034 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11038 if (next_node_name == 0)
11040 errmsg ("next node name required");
11043 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
11045 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
11049 M (GET_NEXT_INDEX, mp);
11050 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
11051 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
11052 vec_free (node_name);
11053 vec_free (next_node_name);
11061 api_add_node_next (vat_main_t * vam)
11063 unformat_input_t *i = vam->input;
11064 vl_api_add_node_next_t *mp;
11069 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11071 if (unformat (i, "node %s", &name))
11073 else if (unformat (i, "next %s", &next))
11080 errmsg ("node name required");
11083 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
11085 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
11090 errmsg ("next node required");
11093 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
11095 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
11099 M (ADD_NODE_NEXT, mp);
11100 clib_memcpy (mp->node_name, name, vec_len (name));
11101 clib_memcpy (mp->next_name, next, vec_len (next));
11111 api_l2tpv3_create_tunnel (vat_main_t * vam)
11113 unformat_input_t *i = vam->input;
11114 ip6_address_t client_address, our_address;
11115 int client_address_set = 0;
11116 int our_address_set = 0;
11117 u32 local_session_id = 0;
11118 u32 remote_session_id = 0;
11119 u64 local_cookie = 0;
11120 u64 remote_cookie = 0;
11121 u8 l2_sublayer_present = 0;
11122 vl_api_l2tpv3_create_tunnel_t *mp;
11125 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11127 if (unformat (i, "client_address %U", unformat_ip6_address,
11129 client_address_set = 1;
11130 else if (unformat (i, "our_address %U", unformat_ip6_address,
11132 our_address_set = 1;
11133 else if (unformat (i, "local_session_id %d", &local_session_id))
11135 else if (unformat (i, "remote_session_id %d", &remote_session_id))
11137 else if (unformat (i, "local_cookie %lld", &local_cookie))
11139 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
11141 else if (unformat (i, "l2-sublayer-present"))
11142 l2_sublayer_present = 1;
11147 if (client_address_set == 0)
11149 errmsg ("client_address required");
11153 if (our_address_set == 0)
11155 errmsg ("our_address required");
11159 M (L2TPV3_CREATE_TUNNEL, mp);
11161 clib_memcpy (mp->client_address, client_address.as_u8,
11162 sizeof (mp->client_address));
11164 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
11166 mp->local_session_id = ntohl (local_session_id);
11167 mp->remote_session_id = ntohl (remote_session_id);
11168 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
11169 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
11170 mp->l2_sublayer_present = l2_sublayer_present;
11179 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
11181 unformat_input_t *i = vam->input;
11183 u8 sw_if_index_set = 0;
11184 u64 new_local_cookie = 0;
11185 u64 new_remote_cookie = 0;
11186 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
11189 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11191 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11192 sw_if_index_set = 1;
11193 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11194 sw_if_index_set = 1;
11195 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
11197 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
11203 if (sw_if_index_set == 0)
11205 errmsg ("missing interface name or sw_if_index");
11209 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
11211 mp->sw_if_index = ntohl (sw_if_index);
11212 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
11213 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
11221 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
11223 unformat_input_t *i = vam->input;
11224 vl_api_l2tpv3_interface_enable_disable_t *mp;
11226 u8 sw_if_index_set = 0;
11227 u8 enable_disable = 1;
11230 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11232 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11233 sw_if_index_set = 1;
11234 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11235 sw_if_index_set = 1;
11236 else if (unformat (i, "enable"))
11237 enable_disable = 1;
11238 else if (unformat (i, "disable"))
11239 enable_disable = 0;
11244 if (sw_if_index_set == 0)
11246 errmsg ("missing interface name or sw_if_index");
11250 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
11252 mp->sw_if_index = ntohl (sw_if_index);
11253 mp->enable_disable = enable_disable;
11261 api_l2tpv3_set_lookup_key (vat_main_t * vam)
11263 unformat_input_t *i = vam->input;
11264 vl_api_l2tpv3_set_lookup_key_t *mp;
11268 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11270 if (unformat (i, "lookup_v6_src"))
11271 key = L2T_LOOKUP_SRC_ADDRESS;
11272 else if (unformat (i, "lookup_v6_dst"))
11273 key = L2T_LOOKUP_DST_ADDRESS;
11274 else if (unformat (i, "lookup_session_id"))
11275 key = L2T_LOOKUP_SESSION_ID;
11280 if (key == (u8) ~ 0)
11282 errmsg ("l2tp session lookup key unset");
11286 M (L2TPV3_SET_LOOKUP_KEY, mp);
11295 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
11296 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11298 vat_main_t *vam = &vat_main;
11300 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
11301 format_ip6_address, mp->our_address,
11302 format_ip6_address, mp->client_address,
11303 clib_net_to_host_u32 (mp->sw_if_index));
11306 " local cookies %016llx %016llx remote cookie %016llx",
11307 clib_net_to_host_u64 (mp->local_cookie[0]),
11308 clib_net_to_host_u64 (mp->local_cookie[1]),
11309 clib_net_to_host_u64 (mp->remote_cookie));
11311 print (vam->ofp, " local session-id %d remote session-id %d",
11312 clib_net_to_host_u32 (mp->local_session_id),
11313 clib_net_to_host_u32 (mp->remote_session_id));
11315 print (vam->ofp, " l2 specific sublayer %s\n",
11316 mp->l2_sublayer_present ? "preset" : "absent");
11320 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
11321 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
11323 vat_main_t *vam = &vat_main;
11324 vat_json_node_t *node = NULL;
11325 struct in6_addr addr;
11327 if (VAT_JSON_ARRAY != vam->json_tree.type)
11329 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11330 vat_json_init_array (&vam->json_tree);
11332 node = vat_json_array_add (&vam->json_tree);
11334 vat_json_init_object (node);
11336 clib_memcpy (&addr, mp->our_address, sizeof (addr));
11337 vat_json_object_add_ip6 (node, "our_address", addr);
11338 clib_memcpy (&addr, mp->client_address, sizeof (addr));
11339 vat_json_object_add_ip6 (node, "client_address", addr);
11341 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
11342 vat_json_init_array (lc);
11343 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
11344 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
11345 vat_json_object_add_uint (node, "remote_cookie",
11346 clib_net_to_host_u64 (mp->remote_cookie));
11348 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
11349 vat_json_object_add_uint (node, "local_session_id",
11350 clib_net_to_host_u32 (mp->local_session_id));
11351 vat_json_object_add_uint (node, "remote_session_id",
11352 clib_net_to_host_u32 (mp->remote_session_id));
11353 vat_json_object_add_string_copy (node, "l2_sublayer",
11354 mp->l2_sublayer_present ? (u8 *) "present"
11355 : (u8 *) "absent");
11359 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
11361 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
11362 vl_api_control_ping_t *mp_ping;
11365 /* Get list of l2tpv3-tunnel interfaces */
11366 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
11369 /* Use a control ping for synchronization */
11370 M (CONTROL_PING, mp_ping);
11378 static void vl_api_sw_interface_tap_details_t_handler
11379 (vl_api_sw_interface_tap_details_t * mp)
11381 vat_main_t *vam = &vat_main;
11383 print (vam->ofp, "%-16s %d",
11384 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
11387 static void vl_api_sw_interface_tap_details_t_handler_json
11388 (vl_api_sw_interface_tap_details_t * mp)
11390 vat_main_t *vam = &vat_main;
11391 vat_json_node_t *node = NULL;
11393 if (VAT_JSON_ARRAY != vam->json_tree.type)
11395 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11396 vat_json_init_array (&vam->json_tree);
11398 node = vat_json_array_add (&vam->json_tree);
11400 vat_json_init_object (node);
11401 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11402 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
11406 api_sw_interface_tap_dump (vat_main_t * vam)
11408 vl_api_sw_interface_tap_dump_t *mp;
11409 vl_api_control_ping_t *mp_ping;
11412 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
11413 /* Get list of tap interfaces */
11414 M (SW_INTERFACE_TAP_DUMP, mp);
11417 /* Use a control ping for synchronization */
11418 M (CONTROL_PING, mp_ping);
11425 static uword unformat_vxlan_decap_next
11426 (unformat_input_t * input, va_list * args)
11428 u32 *result = va_arg (*args, u32 *);
11431 if (unformat (input, "l2"))
11432 *result = VXLAN_INPUT_NEXT_L2_INPUT;
11433 else if (unformat (input, "%d", &tmp))
11441 api_vxlan_add_del_tunnel (vat_main_t * vam)
11443 unformat_input_t *line_input = vam->input;
11444 vl_api_vxlan_add_del_tunnel_t *mp;
11445 ip46_address_t src, dst;
11447 u8 ipv4_set = 0, ipv6_set = 0;
11451 u32 mcast_sw_if_index = ~0;
11452 u32 encap_vrf_id = 0;
11453 u32 decap_next_index = ~0;
11457 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
11458 memset (&src, 0, sizeof src);
11459 memset (&dst, 0, sizeof dst);
11461 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11463 if (unformat (line_input, "del"))
11466 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
11472 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
11478 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
11484 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
11489 else if (unformat (line_input, "group %U %U",
11490 unformat_ip4_address, &dst.ip4,
11491 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11493 grp_set = dst_set = 1;
11496 else if (unformat (line_input, "group %U",
11497 unformat_ip4_address, &dst.ip4))
11499 grp_set = dst_set = 1;
11502 else if (unformat (line_input, "group %U %U",
11503 unformat_ip6_address, &dst.ip6,
11504 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
11506 grp_set = dst_set = 1;
11509 else if (unformat (line_input, "group %U",
11510 unformat_ip6_address, &dst.ip6))
11512 grp_set = dst_set = 1;
11516 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
11518 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11520 else if (unformat (line_input, "decap-next %U",
11521 unformat_vxlan_decap_next, &decap_next_index))
11523 else if (unformat (line_input, "vni %d", &vni))
11527 errmsg ("parse error '%U'", format_unformat_error, line_input);
11534 errmsg ("tunnel src address not specified");
11539 errmsg ("tunnel dst address not specified");
11543 if (grp_set && !ip46_address_is_multicast (&dst))
11545 errmsg ("tunnel group address not multicast");
11548 if (grp_set && mcast_sw_if_index == ~0)
11550 errmsg ("tunnel nonexistent multicast device");
11553 if (grp_set == 0 && ip46_address_is_multicast (&dst))
11555 errmsg ("tunnel dst address must be unicast");
11560 if (ipv4_set && ipv6_set)
11562 errmsg ("both IPv4 and IPv6 addresses specified");
11566 if ((vni == 0) || (vni >> 24))
11568 errmsg ("vni not specified or out of range");
11572 M (VXLAN_ADD_DEL_TUNNEL, mp);
11576 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
11577 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
11581 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
11582 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
11584 mp->encap_vrf_id = ntohl (encap_vrf_id);
11585 mp->decap_next_index = ntohl (decap_next_index);
11586 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
11587 mp->vni = ntohl (vni);
11588 mp->is_add = is_add;
11589 mp->is_ipv6 = ipv6_set;
11596 static void vl_api_vxlan_tunnel_details_t_handler
11597 (vl_api_vxlan_tunnel_details_t * mp)
11599 vat_main_t *vam = &vat_main;
11600 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->dst_address);
11601 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->src_address);
11603 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
11604 ntohl (mp->sw_if_index),
11605 format_ip46_address, &src, IP46_TYPE_ANY,
11606 format_ip46_address, &dst, IP46_TYPE_ANY,
11607 ntohl (mp->encap_vrf_id),
11608 ntohl (mp->decap_next_index), ntohl (mp->vni),
11609 ntohl (mp->mcast_sw_if_index));
11612 static void vl_api_vxlan_tunnel_details_t_handler_json
11613 (vl_api_vxlan_tunnel_details_t * mp)
11615 vat_main_t *vam = &vat_main;
11616 vat_json_node_t *node = NULL;
11618 if (VAT_JSON_ARRAY != vam->json_tree.type)
11620 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11621 vat_json_init_array (&vam->json_tree);
11623 node = vat_json_array_add (&vam->json_tree);
11625 vat_json_init_object (node);
11626 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11629 struct in6_addr ip6;
11631 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
11632 vat_json_object_add_ip6 (node, "src_address", ip6);
11633 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
11634 vat_json_object_add_ip6 (node, "dst_address", ip6);
11638 struct in_addr ip4;
11640 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
11641 vat_json_object_add_ip4 (node, "src_address", ip4);
11642 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
11643 vat_json_object_add_ip4 (node, "dst_address", ip4);
11645 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11646 vat_json_object_add_uint (node, "decap_next_index",
11647 ntohl (mp->decap_next_index));
11648 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11649 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11650 vat_json_object_add_uint (node, "mcast_sw_if_index",
11651 ntohl (mp->mcast_sw_if_index));
11655 api_vxlan_tunnel_dump (vat_main_t * vam)
11657 unformat_input_t *i = vam->input;
11658 vl_api_vxlan_tunnel_dump_t *mp;
11659 vl_api_control_ping_t *mp_ping;
11661 u8 sw_if_index_set = 0;
11664 /* Parse args required to build the message */
11665 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11667 if (unformat (i, "sw_if_index %d", &sw_if_index))
11668 sw_if_index_set = 1;
11673 if (sw_if_index_set == 0)
11678 if (!vam->json_output)
11680 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
11681 "sw_if_index", "src_address", "dst_address",
11682 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
11685 /* Get list of vxlan-tunnel interfaces */
11686 M (VXLAN_TUNNEL_DUMP, mp);
11688 mp->sw_if_index = htonl (sw_if_index);
11692 /* Use a control ping for synchronization */
11693 M (CONTROL_PING, mp_ping);
11701 api_gre_add_del_tunnel (vat_main_t * vam)
11703 unformat_input_t *line_input = vam->input;
11704 vl_api_gre_add_del_tunnel_t *mp;
11705 ip4_address_t src4, dst4;
11706 ip6_address_t src6, dst6;
11713 u32 outer_fib_id = 0;
11716 memset (&src4, 0, sizeof src4);
11717 memset (&dst4, 0, sizeof dst4);
11718 memset (&src6, 0, sizeof src6);
11719 memset (&dst6, 0, sizeof dst6);
11721 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11723 if (unformat (line_input, "del"))
11725 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
11730 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
11735 else if (unformat (line_input, "src %U", unformat_ip6_address, &src6))
11740 else if (unformat (line_input, "dst %U", unformat_ip6_address, &dst6))
11745 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
11747 else if (unformat (line_input, "teb"))
11751 errmsg ("parse error '%U'", format_unformat_error, line_input);
11758 errmsg ("tunnel src address not specified");
11763 errmsg ("tunnel dst address not specified");
11766 if (ipv4_set && ipv6_set)
11768 errmsg ("both IPv4 and IPv6 addresses specified");
11773 M (GRE_ADD_DEL_TUNNEL, mp);
11777 clib_memcpy (&mp->src_address, &src4, 4);
11778 clib_memcpy (&mp->dst_address, &dst4, 4);
11782 clib_memcpy (&mp->src_address, &src6, 16);
11783 clib_memcpy (&mp->dst_address, &dst6, 16);
11785 mp->outer_fib_id = ntohl (outer_fib_id);
11786 mp->is_add = is_add;
11788 mp->is_ipv6 = ipv6_set;
11795 static void vl_api_gre_tunnel_details_t_handler
11796 (vl_api_gre_tunnel_details_t * mp)
11798 vat_main_t *vam = &vat_main;
11799 ip46_address_t src = to_ip46 (mp->is_ipv6, mp->src_address);
11800 ip46_address_t dst = to_ip46 (mp->is_ipv6, mp->dst_address);
11802 print (vam->ofp, "%11d%24U%24U%6d%14d",
11803 ntohl (mp->sw_if_index),
11804 format_ip46_address, &src, IP46_TYPE_ANY,
11805 format_ip46_address, &dst, IP46_TYPE_ANY,
11806 mp->teb, ntohl (mp->outer_fib_id));
11809 static void vl_api_gre_tunnel_details_t_handler_json
11810 (vl_api_gre_tunnel_details_t * mp)
11812 vat_main_t *vam = &vat_main;
11813 vat_json_node_t *node = NULL;
11814 struct in_addr ip4;
11815 struct in6_addr ip6;
11817 if (VAT_JSON_ARRAY != vam->json_tree.type)
11819 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11820 vat_json_init_array (&vam->json_tree);
11822 node = vat_json_array_add (&vam->json_tree);
11824 vat_json_init_object (node);
11825 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11828 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
11829 vat_json_object_add_ip4 (node, "src_address", ip4);
11830 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
11831 vat_json_object_add_ip4 (node, "dst_address", ip4);
11835 clib_memcpy (&ip6, &mp->src_address, sizeof (ip6));
11836 vat_json_object_add_ip6 (node, "src_address", ip6);
11837 clib_memcpy (&ip6, &mp->dst_address, sizeof (ip6));
11838 vat_json_object_add_ip6 (node, "dst_address", ip6);
11840 vat_json_object_add_uint (node, "teb", mp->teb);
11841 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
11842 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6);
11846 api_gre_tunnel_dump (vat_main_t * vam)
11848 unformat_input_t *i = vam->input;
11849 vl_api_gre_tunnel_dump_t *mp;
11850 vl_api_control_ping_t *mp_ping;
11852 u8 sw_if_index_set = 0;
11855 /* Parse args required to build the message */
11856 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11858 if (unformat (i, "sw_if_index %d", &sw_if_index))
11859 sw_if_index_set = 1;
11864 if (sw_if_index_set == 0)
11869 if (!vam->json_output)
11871 print (vam->ofp, "%11s%24s%24s%6s%14s",
11872 "sw_if_index", "src_address", "dst_address", "teb",
11876 /* Get list of gre-tunnel interfaces */
11877 M (GRE_TUNNEL_DUMP, mp);
11879 mp->sw_if_index = htonl (sw_if_index);
11883 /* Use a control ping for synchronization */
11884 M (CONTROL_PING, mp_ping);
11892 api_l2_fib_clear_table (vat_main_t * vam)
11894 // unformat_input_t * i = vam->input;
11895 vl_api_l2_fib_clear_table_t *mp;
11898 M (L2_FIB_CLEAR_TABLE, mp);
11906 api_l2_interface_efp_filter (vat_main_t * vam)
11908 unformat_input_t *i = vam->input;
11909 vl_api_l2_interface_efp_filter_t *mp;
11912 u8 sw_if_index_set = 0;
11915 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11917 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11918 sw_if_index_set = 1;
11919 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11920 sw_if_index_set = 1;
11921 else if (unformat (i, "enable"))
11923 else if (unformat (i, "disable"))
11927 clib_warning ("parse error '%U'", format_unformat_error, i);
11932 if (sw_if_index_set == 0)
11934 errmsg ("missing sw_if_index");
11938 M (L2_INTERFACE_EFP_FILTER, mp);
11940 mp->sw_if_index = ntohl (sw_if_index);
11941 mp->enable_disable = enable;
11948 #define foreach_vtr_op \
11949 _("disable", L2_VTR_DISABLED) \
11950 _("push-1", L2_VTR_PUSH_1) \
11951 _("push-2", L2_VTR_PUSH_2) \
11952 _("pop-1", L2_VTR_POP_1) \
11953 _("pop-2", L2_VTR_POP_2) \
11954 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
11955 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
11956 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
11957 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
11960 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
11962 unformat_input_t *i = vam->input;
11963 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
11965 u8 sw_if_index_set = 0;
11968 u32 push_dot1q = 1;
11973 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11975 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11976 sw_if_index_set = 1;
11977 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11978 sw_if_index_set = 1;
11979 else if (unformat (i, "vtr_op %d", &vtr_op))
11981 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
11984 else if (unformat (i, "push_dot1q %d", &push_dot1q))
11986 else if (unformat (i, "tag1 %d", &tag1))
11988 else if (unformat (i, "tag2 %d", &tag2))
11992 clib_warning ("parse error '%U'", format_unformat_error, i);
11997 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
11999 errmsg ("missing vtr operation or sw_if_index");
12003 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
12004 mp->sw_if_index = ntohl (sw_if_index);
12005 mp->vtr_op = ntohl (vtr_op);
12006 mp->push_dot1q = ntohl (push_dot1q);
12007 mp->tag1 = ntohl (tag1);
12008 mp->tag2 = ntohl (tag2);
12016 api_create_vhost_user_if (vat_main_t * vam)
12018 unformat_input_t *i = vam->input;
12019 vl_api_create_vhost_user_if_t *mp;
12022 u8 file_name_set = 0;
12023 u32 custom_dev_instance = ~0;
12025 u8 use_custom_mac = 0;
12029 /* Shut up coverity */
12030 memset (hwaddr, 0, sizeof (hwaddr));
12032 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12034 if (unformat (i, "socket %s", &file_name))
12038 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12040 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
12041 use_custom_mac = 1;
12042 else if (unformat (i, "server"))
12044 else if (unformat (i, "tag %s", &tag))
12050 if (file_name_set == 0)
12052 errmsg ("missing socket file name");
12056 if (vec_len (file_name) > 255)
12058 errmsg ("socket file name too long");
12061 vec_add1 (file_name, 0);
12063 M (CREATE_VHOST_USER_IF, mp);
12065 mp->is_server = is_server;
12066 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12067 vec_free (file_name);
12068 if (custom_dev_instance != ~0)
12071 mp->custom_dev_instance = ntohl (custom_dev_instance);
12073 mp->use_custom_mac = use_custom_mac;
12074 clib_memcpy (mp->mac_address, hwaddr, 6);
12076 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
12085 api_modify_vhost_user_if (vat_main_t * vam)
12087 unformat_input_t *i = vam->input;
12088 vl_api_modify_vhost_user_if_t *mp;
12091 u8 file_name_set = 0;
12092 u32 custom_dev_instance = ~0;
12093 u8 sw_if_index_set = 0;
12094 u32 sw_if_index = (u32) ~ 0;
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, "socket %s", &file_name))
12107 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
12109 else if (unformat (i, "server"))
12115 if (sw_if_index_set == 0)
12117 errmsg ("missing sw_if_index or interface name");
12121 if (file_name_set == 0)
12123 errmsg ("missing socket file name");
12127 if (vec_len (file_name) > 255)
12129 errmsg ("socket file name too long");
12132 vec_add1 (file_name, 0);
12134 M (MODIFY_VHOST_USER_IF, mp);
12136 mp->sw_if_index = ntohl (sw_if_index);
12137 mp->is_server = is_server;
12138 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
12139 vec_free (file_name);
12140 if (custom_dev_instance != ~0)
12143 mp->custom_dev_instance = ntohl (custom_dev_instance);
12152 api_delete_vhost_user_if (vat_main_t * vam)
12154 unformat_input_t *i = vam->input;
12155 vl_api_delete_vhost_user_if_t *mp;
12156 u32 sw_if_index = ~0;
12157 u8 sw_if_index_set = 0;
12160 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12162 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12163 sw_if_index_set = 1;
12164 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12165 sw_if_index_set = 1;
12170 if (sw_if_index_set == 0)
12172 errmsg ("missing sw_if_index or interface name");
12177 M (DELETE_VHOST_USER_IF, mp);
12179 mp->sw_if_index = ntohl (sw_if_index);
12186 static void vl_api_sw_interface_vhost_user_details_t_handler
12187 (vl_api_sw_interface_vhost_user_details_t * mp)
12189 vat_main_t *vam = &vat_main;
12191 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
12192 (char *) mp->interface_name,
12193 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
12194 clib_net_to_host_u64 (mp->features), mp->is_server,
12195 ntohl (mp->num_regions), (char *) mp->sock_filename);
12196 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
12199 static void vl_api_sw_interface_vhost_user_details_t_handler_json
12200 (vl_api_sw_interface_vhost_user_details_t * mp)
12202 vat_main_t *vam = &vat_main;
12203 vat_json_node_t *node = NULL;
12205 if (VAT_JSON_ARRAY != vam->json_tree.type)
12207 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12208 vat_json_init_array (&vam->json_tree);
12210 node = vat_json_array_add (&vam->json_tree);
12212 vat_json_init_object (node);
12213 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12214 vat_json_object_add_string_copy (node, "interface_name",
12215 mp->interface_name);
12216 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
12217 ntohl (mp->virtio_net_hdr_sz));
12218 vat_json_object_add_uint (node, "features",
12219 clib_net_to_host_u64 (mp->features));
12220 vat_json_object_add_uint (node, "is_server", mp->is_server);
12221 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
12222 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
12223 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
12227 api_sw_interface_vhost_user_dump (vat_main_t * vam)
12229 vl_api_sw_interface_vhost_user_dump_t *mp;
12230 vl_api_control_ping_t *mp_ping;
12233 "Interface name idx hdr_sz features server regions filename");
12235 /* Get list of vhost-user interfaces */
12236 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
12239 /* Use a control ping for synchronization */
12240 M (CONTROL_PING, mp_ping);
12248 api_show_version (vat_main_t * vam)
12250 vl_api_show_version_t *mp;
12253 M (SHOW_VERSION, mp);
12262 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
12264 unformat_input_t *line_input = vam->input;
12265 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
12266 ip4_address_t local4, remote4;
12267 ip6_address_t local6, remote6;
12269 u8 ipv4_set = 0, ipv6_set = 0;
12273 u32 mcast_sw_if_index = ~0;
12274 u32 encap_vrf_id = 0;
12275 u32 decap_vrf_id = 0;
12281 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
12282 memset (&local4, 0, sizeof local4);
12283 memset (&remote4, 0, sizeof remote4);
12284 memset (&local6, 0, sizeof local6);
12285 memset (&remote6, 0, sizeof remote6);
12287 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12289 if (unformat (line_input, "del"))
12291 else if (unformat (line_input, "local %U",
12292 unformat_ip4_address, &local4))
12297 else if (unformat (line_input, "remote %U",
12298 unformat_ip4_address, &remote4))
12303 else if (unformat (line_input, "local %U",
12304 unformat_ip6_address, &local6))
12309 else if (unformat (line_input, "remote %U",
12310 unformat_ip6_address, &remote6))
12315 else if (unformat (line_input, "group %U %U",
12316 unformat_ip4_address, &remote4,
12317 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12319 grp_set = remote_set = 1;
12322 else if (unformat (line_input, "group %U",
12323 unformat_ip4_address, &remote4))
12325 grp_set = remote_set = 1;
12328 else if (unformat (line_input, "group %U %U",
12329 unformat_ip6_address, &remote6,
12330 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
12332 grp_set = remote_set = 1;
12335 else if (unformat (line_input, "group %U",
12336 unformat_ip6_address, &remote6))
12338 grp_set = remote_set = 1;
12342 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
12344 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
12346 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
12348 else if (unformat (line_input, "vni %d", &vni))
12350 else if (unformat (line_input, "next-ip4"))
12352 else if (unformat (line_input, "next-ip6"))
12354 else if (unformat (line_input, "next-ethernet"))
12356 else if (unformat (line_input, "next-nsh"))
12360 errmsg ("parse error '%U'", format_unformat_error, line_input);
12365 if (local_set == 0)
12367 errmsg ("tunnel local address not specified");
12370 if (remote_set == 0)
12372 errmsg ("tunnel remote address not specified");
12375 if (grp_set && mcast_sw_if_index == ~0)
12377 errmsg ("tunnel nonexistent multicast device");
12380 if (ipv4_set && ipv6_set)
12382 errmsg ("both IPv4 and IPv6 addresses specified");
12388 errmsg ("vni not specified");
12392 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
12397 clib_memcpy (&mp->local, &local6, sizeof (local6));
12398 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
12402 clib_memcpy (&mp->local, &local4, sizeof (local4));
12403 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
12406 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
12407 mp->encap_vrf_id = ntohl (encap_vrf_id);
12408 mp->decap_vrf_id = ntohl (decap_vrf_id);
12409 mp->protocol = protocol;
12410 mp->vni = ntohl (vni);
12411 mp->is_add = is_add;
12412 mp->is_ipv6 = ipv6_set;
12419 static void vl_api_vxlan_gpe_tunnel_details_t_handler
12420 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12422 vat_main_t *vam = &vat_main;
12423 ip46_address_t local = to_ip46 (mp->is_ipv6, mp->local);
12424 ip46_address_t remote = to_ip46 (mp->is_ipv6, mp->remote);
12426 print (vam->ofp, "%11d%24U%24U%13d%12d%19d%14d%14d",
12427 ntohl (mp->sw_if_index),
12428 format_ip46_address, &local, IP46_TYPE_ANY,
12429 format_ip46_address, &remote, IP46_TYPE_ANY,
12430 ntohl (mp->vni), mp->protocol,
12431 ntohl (mp->mcast_sw_if_index),
12432 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
12436 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
12437 (vl_api_vxlan_gpe_tunnel_details_t * mp)
12439 vat_main_t *vam = &vat_main;
12440 vat_json_node_t *node = NULL;
12441 struct in_addr ip4;
12442 struct in6_addr ip6;
12444 if (VAT_JSON_ARRAY != vam->json_tree.type)
12446 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12447 vat_json_init_array (&vam->json_tree);
12449 node = vat_json_array_add (&vam->json_tree);
12451 vat_json_init_object (node);
12452 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12455 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
12456 vat_json_object_add_ip6 (node, "local", ip6);
12457 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
12458 vat_json_object_add_ip6 (node, "remote", ip6);
12462 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
12463 vat_json_object_add_ip4 (node, "local", ip4);
12464 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
12465 vat_json_object_add_ip4 (node, "remote", ip4);
12467 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
12468 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
12469 vat_json_object_add_uint (node, "mcast_sw_if_index",
12470 ntohl (mp->mcast_sw_if_index));
12471 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
12472 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
12473 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
12477 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
12479 unformat_input_t *i = vam->input;
12480 vl_api_vxlan_gpe_tunnel_dump_t *mp;
12481 vl_api_control_ping_t *mp_ping;
12483 u8 sw_if_index_set = 0;
12486 /* Parse args required to build the message */
12487 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12489 if (unformat (i, "sw_if_index %d", &sw_if_index))
12490 sw_if_index_set = 1;
12495 if (sw_if_index_set == 0)
12500 if (!vam->json_output)
12502 print (vam->ofp, "%11s%24s%24s%13s%15s%19s%14s%14s",
12503 "sw_if_index", "local", "remote", "vni",
12504 "protocol", "mcast_sw_if_index", "encap_vrf_id", "decap_vrf_id");
12507 /* Get list of vxlan-tunnel interfaces */
12508 M (VXLAN_GPE_TUNNEL_DUMP, mp);
12510 mp->sw_if_index = htonl (sw_if_index);
12514 /* Use a control ping for synchronization */
12515 M (CONTROL_PING, mp_ping);
12524 format_l2_fib_mac_address (u8 * s, va_list * args)
12526 u8 *a = va_arg (*args, u8 *);
12528 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
12529 a[2], a[3], a[4], a[5], a[6], a[7]);
12532 static void vl_api_l2_fib_table_details_t_handler
12533 (vl_api_l2_fib_table_details_t * mp)
12535 vat_main_t *vam = &vat_main;
12537 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
12539 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
12540 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
12544 static void vl_api_l2_fib_table_details_t_handler_json
12545 (vl_api_l2_fib_table_details_t * mp)
12547 vat_main_t *vam = &vat_main;
12548 vat_json_node_t *node = NULL;
12550 if (VAT_JSON_ARRAY != vam->json_tree.type)
12552 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
12553 vat_json_init_array (&vam->json_tree);
12555 node = vat_json_array_add (&vam->json_tree);
12557 vat_json_init_object (node);
12558 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
12559 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
12560 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
12561 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
12562 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
12563 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
12567 api_l2_fib_table_dump (vat_main_t * vam)
12569 unformat_input_t *i = vam->input;
12570 vl_api_l2_fib_table_dump_t *mp;
12571 vl_api_control_ping_t *mp_ping;
12576 /* Parse args required to build the message */
12577 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12579 if (unformat (i, "bd_id %d", &bd_id))
12585 if (bd_id_set == 0)
12587 errmsg ("missing bridge domain");
12591 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
12593 /* Get list of l2 fib entries */
12594 M (L2_FIB_TABLE_DUMP, mp);
12596 mp->bd_id = ntohl (bd_id);
12599 /* Use a control ping for synchronization */
12600 M (CONTROL_PING, mp_ping);
12609 api_interface_name_renumber (vat_main_t * vam)
12611 unformat_input_t *line_input = vam->input;
12612 vl_api_interface_name_renumber_t *mp;
12613 u32 sw_if_index = ~0;
12614 u32 new_show_dev_instance = ~0;
12617 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12619 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
12622 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
12624 else if (unformat (line_input, "new_show_dev_instance %d",
12625 &new_show_dev_instance))
12631 if (sw_if_index == ~0)
12633 errmsg ("missing interface name or sw_if_index");
12637 if (new_show_dev_instance == ~0)
12639 errmsg ("missing new_show_dev_instance");
12643 M (INTERFACE_NAME_RENUMBER, mp);
12645 mp->sw_if_index = ntohl (sw_if_index);
12646 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
12654 api_want_ip4_arp_events (vat_main_t * vam)
12656 unformat_input_t *line_input = vam->input;
12657 vl_api_want_ip4_arp_events_t *mp;
12658 ip4_address_t address;
12659 int address_set = 0;
12660 u32 enable_disable = 1;
12663 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12665 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
12667 else if (unformat (line_input, "del"))
12668 enable_disable = 0;
12673 if (address_set == 0)
12675 errmsg ("missing addresses");
12679 M (WANT_IP4_ARP_EVENTS, mp);
12680 mp->enable_disable = enable_disable;
12681 mp->pid = htonl (getpid ());
12682 mp->address = address.as_u32;
12690 api_want_ip6_nd_events (vat_main_t * vam)
12692 unformat_input_t *line_input = vam->input;
12693 vl_api_want_ip6_nd_events_t *mp;
12694 ip6_address_t address;
12695 int address_set = 0;
12696 u32 enable_disable = 1;
12699 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12701 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
12703 else if (unformat (line_input, "del"))
12704 enable_disable = 0;
12709 if (address_set == 0)
12711 errmsg ("missing addresses");
12715 M (WANT_IP6_ND_EVENTS, mp);
12716 mp->enable_disable = enable_disable;
12717 mp->pid = htonl (getpid ());
12718 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
12726 api_want_l2_macs_events (vat_main_t * vam)
12728 unformat_input_t *line_input = vam->input;
12729 vl_api_want_l2_macs_events_t *mp;
12730 u8 enable_disable = 1;
12731 u32 scan_delay = 0;
12732 u32 max_macs_in_event = 0;
12733 u32 learn_limit = 0;
12736 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
12738 if (unformat (line_input, "learn-limit %d", &learn_limit))
12740 else if (unformat (line_input, "scan-delay %d", &scan_delay))
12742 else if (unformat (line_input, "max-entries %d", &max_macs_in_event))
12744 else if (unformat (line_input, "disable"))
12745 enable_disable = 0;
12750 M (WANT_L2_MACS_EVENTS, mp);
12751 mp->enable_disable = enable_disable;
12752 mp->pid = htonl (getpid ());
12753 mp->learn_limit = htonl (learn_limit);
12754 mp->scan_delay = (u8) scan_delay;
12755 mp->max_macs_in_event = (u8) (max_macs_in_event / 10);
12762 api_input_acl_set_interface (vat_main_t * vam)
12764 unformat_input_t *i = vam->input;
12765 vl_api_input_acl_set_interface_t *mp;
12767 int sw_if_index_set;
12768 u32 ip4_table_index = ~0;
12769 u32 ip6_table_index = ~0;
12770 u32 l2_table_index = ~0;
12774 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12776 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12777 sw_if_index_set = 1;
12778 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12779 sw_if_index_set = 1;
12780 else if (unformat (i, "del"))
12782 else if (unformat (i, "ip4-table %d", &ip4_table_index))
12784 else if (unformat (i, "ip6-table %d", &ip6_table_index))
12786 else if (unformat (i, "l2-table %d", &l2_table_index))
12790 clib_warning ("parse error '%U'", format_unformat_error, i);
12795 if (sw_if_index_set == 0)
12797 errmsg ("missing interface name or sw_if_index");
12801 M (INPUT_ACL_SET_INTERFACE, mp);
12803 mp->sw_if_index = ntohl (sw_if_index);
12804 mp->ip4_table_index = ntohl (ip4_table_index);
12805 mp->ip6_table_index = ntohl (ip6_table_index);
12806 mp->l2_table_index = ntohl (l2_table_index);
12807 mp->is_add = is_add;
12815 api_ip_address_dump (vat_main_t * vam)
12817 unformat_input_t *i = vam->input;
12818 vl_api_ip_address_dump_t *mp;
12819 vl_api_control_ping_t *mp_ping;
12820 u32 sw_if_index = ~0;
12821 u8 sw_if_index_set = 0;
12826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12828 if (unformat (i, "sw_if_index %d", &sw_if_index))
12829 sw_if_index_set = 1;
12831 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12832 sw_if_index_set = 1;
12833 else if (unformat (i, "ipv4"))
12835 else if (unformat (i, "ipv6"))
12841 if (ipv4_set && ipv6_set)
12843 errmsg ("ipv4 and ipv6 flags cannot be both set");
12847 if ((!ipv4_set) && (!ipv6_set))
12849 errmsg ("no ipv4 nor ipv6 flag set");
12853 if (sw_if_index_set == 0)
12855 errmsg ("missing interface name or sw_if_index");
12859 vam->current_sw_if_index = sw_if_index;
12860 vam->is_ipv6 = ipv6_set;
12862 M (IP_ADDRESS_DUMP, mp);
12863 mp->sw_if_index = ntohl (sw_if_index);
12864 mp->is_ipv6 = ipv6_set;
12867 /* Use a control ping for synchronization */
12868 M (CONTROL_PING, mp_ping);
12876 api_ip_dump (vat_main_t * vam)
12878 vl_api_ip_dump_t *mp;
12879 vl_api_control_ping_t *mp_ping;
12880 unformat_input_t *in = vam->input;
12887 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
12889 if (unformat (in, "ipv4"))
12891 else if (unformat (in, "ipv6"))
12897 if (ipv4_set && ipv6_set)
12899 errmsg ("ipv4 and ipv6 flags cannot be both set");
12903 if ((!ipv4_set) && (!ipv6_set))
12905 errmsg ("no ipv4 nor ipv6 flag set");
12909 is_ipv6 = ipv6_set;
12910 vam->is_ipv6 = is_ipv6;
12912 /* free old data */
12913 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
12915 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
12917 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
12920 mp->is_ipv6 = ipv6_set;
12923 /* Use a control ping for synchronization */
12924 M (CONTROL_PING, mp_ping);
12932 api_ipsec_spd_add_del (vat_main_t * vam)
12934 unformat_input_t *i = vam->input;
12935 vl_api_ipsec_spd_add_del_t *mp;
12940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12942 if (unformat (i, "spd_id %d", &spd_id))
12944 else if (unformat (i, "del"))
12948 clib_warning ("parse error '%U'", format_unformat_error, i);
12954 errmsg ("spd_id must be set");
12958 M (IPSEC_SPD_ADD_DEL, mp);
12960 mp->spd_id = ntohl (spd_id);
12961 mp->is_add = is_add;
12969 api_ipsec_interface_add_del_spd (vat_main_t * vam)
12971 unformat_input_t *i = vam->input;
12972 vl_api_ipsec_interface_add_del_spd_t *mp;
12974 u8 sw_if_index_set = 0;
12975 u32 spd_id = (u32) ~ 0;
12979 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12981 if (unformat (i, "del"))
12983 else if (unformat (i, "spd_id %d", &spd_id))
12986 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
12987 sw_if_index_set = 1;
12988 else if (unformat (i, "sw_if_index %d", &sw_if_index))
12989 sw_if_index_set = 1;
12992 clib_warning ("parse error '%U'", format_unformat_error, i);
12998 if (spd_id == (u32) ~ 0)
13000 errmsg ("spd_id must be set");
13004 if (sw_if_index_set == 0)
13006 errmsg ("missing interface name or sw_if_index");
13010 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
13012 mp->spd_id = ntohl (spd_id);
13013 mp->sw_if_index = ntohl (sw_if_index);
13014 mp->is_add = is_add;
13022 api_ipsec_spd_add_del_entry (vat_main_t * vam)
13024 unformat_input_t *i = vam->input;
13025 vl_api_ipsec_spd_add_del_entry_t *mp;
13026 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
13027 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
13029 u32 rport_start = 0, rport_stop = (u32) ~ 0;
13030 u32 lport_start = 0, lport_stop = (u32) ~ 0;
13031 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
13032 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
13035 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
13036 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
13037 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
13038 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
13039 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
13040 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
13042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13044 if (unformat (i, "del"))
13046 if (unformat (i, "outbound"))
13048 if (unformat (i, "inbound"))
13050 else if (unformat (i, "spd_id %d", &spd_id))
13052 else if (unformat (i, "sa_id %d", &sa_id))
13054 else if (unformat (i, "priority %d", &priority))
13056 else if (unformat (i, "protocol %d", &protocol))
13058 else if (unformat (i, "lport_start %d", &lport_start))
13060 else if (unformat (i, "lport_stop %d", &lport_stop))
13062 else if (unformat (i, "rport_start %d", &rport_start))
13064 else if (unformat (i, "rport_stop %d", &rport_stop))
13068 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
13074 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
13081 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
13087 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
13094 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
13100 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
13107 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
13113 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
13119 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
13121 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
13123 clib_warning ("unsupported action: 'resolve'");
13129 clib_warning ("parse error '%U'", format_unformat_error, i);
13135 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
13137 mp->spd_id = ntohl (spd_id);
13138 mp->priority = ntohl (priority);
13139 mp->is_outbound = is_outbound;
13141 mp->is_ipv6 = is_ipv6;
13142 if (is_ipv6 || is_ip_any)
13144 clib_memcpy (mp->remote_address_start, &raddr6_start,
13145 sizeof (ip6_address_t));
13146 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
13147 sizeof (ip6_address_t));
13148 clib_memcpy (mp->local_address_start, &laddr6_start,
13149 sizeof (ip6_address_t));
13150 clib_memcpy (mp->local_address_stop, &laddr6_stop,
13151 sizeof (ip6_address_t));
13155 clib_memcpy (mp->remote_address_start, &raddr4_start,
13156 sizeof (ip4_address_t));
13157 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
13158 sizeof (ip4_address_t));
13159 clib_memcpy (mp->local_address_start, &laddr4_start,
13160 sizeof (ip4_address_t));
13161 clib_memcpy (mp->local_address_stop, &laddr4_stop,
13162 sizeof (ip4_address_t));
13164 mp->protocol = (u8) protocol;
13165 mp->local_port_start = ntohs ((u16) lport_start);
13166 mp->local_port_stop = ntohs ((u16) lport_stop);
13167 mp->remote_port_start = ntohs ((u16) rport_start);
13168 mp->remote_port_stop = ntohs ((u16) rport_stop);
13169 mp->policy = (u8) policy;
13170 mp->sa_id = ntohl (sa_id);
13171 mp->is_add = is_add;
13172 mp->is_ip_any = is_ip_any;
13179 api_ipsec_sad_add_del_entry (vat_main_t * vam)
13181 unformat_input_t *i = vam->input;
13182 vl_api_ipsec_sad_add_del_entry_t *mp;
13183 u32 sad_id = 0, spi = 0;
13184 u8 *ck = 0, *ik = 0;
13187 u8 protocol = IPSEC_PROTOCOL_AH;
13188 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
13189 u32 crypto_alg = 0, integ_alg = 0;
13190 ip4_address_t tun_src4;
13191 ip4_address_t tun_dst4;
13192 ip6_address_t tun_src6;
13193 ip6_address_t tun_dst6;
13196 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13198 if (unformat (i, "del"))
13200 else if (unformat (i, "sad_id %d", &sad_id))
13202 else if (unformat (i, "spi %d", &spi))
13204 else if (unformat (i, "esp"))
13205 protocol = IPSEC_PROTOCOL_ESP;
13206 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
13209 is_tunnel_ipv6 = 0;
13211 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
13214 is_tunnel_ipv6 = 0;
13216 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
13219 is_tunnel_ipv6 = 1;
13221 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
13224 is_tunnel_ipv6 = 1;
13228 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13230 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13231 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13233 clib_warning ("unsupported crypto-alg: '%U'",
13234 format_ipsec_crypto_alg, crypto_alg);
13238 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13242 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13244 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13245 integ_alg >= IPSEC_INTEG_N_ALG)
13247 clib_warning ("unsupported integ-alg: '%U'",
13248 format_ipsec_integ_alg, integ_alg);
13252 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13256 clib_warning ("parse error '%U'", format_unformat_error, i);
13262 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
13264 mp->sad_id = ntohl (sad_id);
13265 mp->is_add = is_add;
13266 mp->protocol = protocol;
13267 mp->spi = ntohl (spi);
13268 mp->is_tunnel = is_tunnel;
13269 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
13270 mp->crypto_algorithm = crypto_alg;
13271 mp->integrity_algorithm = integ_alg;
13272 mp->crypto_key_length = vec_len (ck);
13273 mp->integrity_key_length = vec_len (ik);
13275 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13276 mp->crypto_key_length = sizeof (mp->crypto_key);
13278 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13279 mp->integrity_key_length = sizeof (mp->integrity_key);
13282 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13284 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13288 if (is_tunnel_ipv6)
13290 clib_memcpy (mp->tunnel_src_address, &tun_src6,
13291 sizeof (ip6_address_t));
13292 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
13293 sizeof (ip6_address_t));
13297 clib_memcpy (mp->tunnel_src_address, &tun_src4,
13298 sizeof (ip4_address_t));
13299 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
13300 sizeof (ip4_address_t));
13310 api_ipsec_sa_set_key (vat_main_t * vam)
13312 unformat_input_t *i = vam->input;
13313 vl_api_ipsec_sa_set_key_t *mp;
13315 u8 *ck = 0, *ik = 0;
13318 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13320 if (unformat (i, "sa_id %d", &sa_id))
13322 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
13324 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
13328 clib_warning ("parse error '%U'", format_unformat_error, i);
13333 M (IPSEC_SA_SET_KEY, mp);
13335 mp->sa_id = ntohl (sa_id);
13336 mp->crypto_key_length = vec_len (ck);
13337 mp->integrity_key_length = vec_len (ik);
13339 if (mp->crypto_key_length > sizeof (mp->crypto_key))
13340 mp->crypto_key_length = sizeof (mp->crypto_key);
13342 if (mp->integrity_key_length > sizeof (mp->integrity_key))
13343 mp->integrity_key_length = sizeof (mp->integrity_key);
13346 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
13348 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
13356 api_ipsec_tunnel_if_add_del (vat_main_t * vam)
13358 unformat_input_t *i = vam->input;
13359 vl_api_ipsec_tunnel_if_add_del_t *mp;
13360 u32 local_spi = 0, remote_spi = 0;
13361 u32 crypto_alg = 0, integ_alg = 0;
13362 u8 *lck = NULL, *rck = NULL;
13363 u8 *lik = NULL, *rik = NULL;
13364 ip4_address_t local_ip = { {0} };
13365 ip4_address_t remote_ip = { {0} };
13368 u8 anti_replay = 0;
13371 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13373 if (unformat (i, "del"))
13375 else if (unformat (i, "esn"))
13377 else if (unformat (i, "anti_replay"))
13379 else if (unformat (i, "local_spi %d", &local_spi))
13381 else if (unformat (i, "remote_spi %d", &remote_spi))
13383 else if (unformat (i, "local_ip %U", unformat_ip4_address, &local_ip))
13385 else if (unformat (i, "remote_ip %U", unformat_ip4_address, &remote_ip))
13387 else if (unformat (i, "local_crypto_key %U", unformat_hex_string, &lck))
13390 if (unformat (i, "remote_crypto_key %U", unformat_hex_string, &rck))
13392 else if (unformat (i, "local_integ_key %U", unformat_hex_string, &lik))
13394 else if (unformat (i, "remote_integ_key %U", unformat_hex_string, &rik))
13398 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
13400 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
13401 crypto_alg >= IPSEC_CRYPTO_N_ALG)
13403 errmsg ("unsupported crypto-alg: '%U'\n",
13404 format_ipsec_crypto_alg, crypto_alg);
13410 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
13412 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
13413 integ_alg >= IPSEC_INTEG_N_ALG)
13415 errmsg ("unsupported integ-alg: '%U'\n",
13416 format_ipsec_integ_alg, integ_alg);
13422 errmsg ("parse error '%U'\n", format_unformat_error, i);
13427 M (IPSEC_TUNNEL_IF_ADD_DEL, mp);
13429 mp->is_add = is_add;
13431 mp->anti_replay = anti_replay;
13433 clib_memcpy (mp->local_ip, &local_ip, sizeof (ip4_address_t));
13434 clib_memcpy (mp->remote_ip, &remote_ip, sizeof (ip4_address_t));
13436 mp->local_spi = htonl (local_spi);
13437 mp->remote_spi = htonl (remote_spi);
13438 mp->crypto_alg = (u8) crypto_alg;
13440 mp->local_crypto_key_len = 0;
13443 mp->local_crypto_key_len = vec_len (lck);
13444 if (mp->local_crypto_key_len > sizeof (mp->local_crypto_key))
13445 mp->local_crypto_key_len = sizeof (mp->local_crypto_key);
13446 clib_memcpy (mp->local_crypto_key, lck, mp->local_crypto_key_len);
13449 mp->remote_crypto_key_len = 0;
13452 mp->remote_crypto_key_len = vec_len (rck);
13453 if (mp->remote_crypto_key_len > sizeof (mp->remote_crypto_key))
13454 mp->remote_crypto_key_len = sizeof (mp->remote_crypto_key);
13455 clib_memcpy (mp->remote_crypto_key, rck, mp->remote_crypto_key_len);
13458 mp->integ_alg = (u8) integ_alg;
13460 mp->local_integ_key_len = 0;
13463 mp->local_integ_key_len = vec_len (lik);
13464 if (mp->local_integ_key_len > sizeof (mp->local_integ_key))
13465 mp->local_integ_key_len = sizeof (mp->local_integ_key);
13466 clib_memcpy (mp->local_integ_key, lik, mp->local_integ_key_len);
13469 mp->remote_integ_key_len = 0;
13472 mp->remote_integ_key_len = vec_len (rik);
13473 if (mp->remote_integ_key_len > sizeof (mp->remote_integ_key))
13474 mp->remote_integ_key_len = sizeof (mp->remote_integ_key);
13475 clib_memcpy (mp->remote_integ_key, rik, mp->remote_integ_key_len);
13484 api_ikev2_profile_add_del (vat_main_t * vam)
13486 unformat_input_t *i = vam->input;
13487 vl_api_ikev2_profile_add_del_t *mp;
13492 const char *valid_chars = "a-zA-Z0-9_";
13494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13496 if (unformat (i, "del"))
13498 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13499 vec_add1 (name, 0);
13502 errmsg ("parse error '%U'", format_unformat_error, i);
13507 if (!vec_len (name))
13509 errmsg ("profile name must be specified");
13513 if (vec_len (name) > 64)
13515 errmsg ("profile name too long");
13519 M (IKEV2_PROFILE_ADD_DEL, mp);
13521 clib_memcpy (mp->name, name, vec_len (name));
13522 mp->is_add = is_add;
13531 api_ikev2_profile_set_auth (vat_main_t * vam)
13533 unformat_input_t *i = vam->input;
13534 vl_api_ikev2_profile_set_auth_t *mp;
13537 u32 auth_method = 0;
13541 const char *valid_chars = "a-zA-Z0-9_";
13543 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13545 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13546 vec_add1 (name, 0);
13547 else if (unformat (i, "auth_method %U",
13548 unformat_ikev2_auth_method, &auth_method))
13550 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
13552 else if (unformat (i, "auth_data %v", &data))
13556 errmsg ("parse error '%U'", format_unformat_error, i);
13561 if (!vec_len (name))
13563 errmsg ("profile name must be specified");
13567 if (vec_len (name) > 64)
13569 errmsg ("profile name too long");
13573 if (!vec_len (data))
13575 errmsg ("auth_data must be specified");
13581 errmsg ("auth_method must be specified");
13585 M (IKEV2_PROFILE_SET_AUTH, mp);
13587 mp->is_hex = is_hex;
13588 mp->auth_method = (u8) auth_method;
13589 mp->data_len = vec_len (data);
13590 clib_memcpy (mp->name, name, vec_len (name));
13591 clib_memcpy (mp->data, data, vec_len (data));
13601 api_ikev2_profile_set_id (vat_main_t * vam)
13603 unformat_input_t *i = vam->input;
13604 vl_api_ikev2_profile_set_id_t *mp;
13612 const char *valid_chars = "a-zA-Z0-9_";
13614 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13616 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13617 vec_add1 (name, 0);
13618 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
13620 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
13622 data = vec_new (u8, 4);
13623 clib_memcpy (data, ip4.as_u8, 4);
13625 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
13627 else if (unformat (i, "id_data %v", &data))
13629 else if (unformat (i, "local"))
13631 else if (unformat (i, "remote"))
13635 errmsg ("parse error '%U'", format_unformat_error, i);
13640 if (!vec_len (name))
13642 errmsg ("profile name must be specified");
13646 if (vec_len (name) > 64)
13648 errmsg ("profile name too long");
13652 if (!vec_len (data))
13654 errmsg ("id_data must be specified");
13660 errmsg ("id_type must be specified");
13664 M (IKEV2_PROFILE_SET_ID, mp);
13666 mp->is_local = is_local;
13667 mp->id_type = (u8) id_type;
13668 mp->data_len = vec_len (data);
13669 clib_memcpy (mp->name, name, vec_len (name));
13670 clib_memcpy (mp->data, data, vec_len (data));
13680 api_ikev2_profile_set_ts (vat_main_t * vam)
13682 unformat_input_t *i = vam->input;
13683 vl_api_ikev2_profile_set_ts_t *mp;
13686 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
13687 ip4_address_t start_addr, end_addr;
13689 const char *valid_chars = "a-zA-Z0-9_";
13692 start_addr.as_u32 = 0;
13693 end_addr.as_u32 = (u32) ~ 0;
13695 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13697 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
13698 vec_add1 (name, 0);
13699 else if (unformat (i, "protocol %d", &proto))
13701 else if (unformat (i, "start_port %d", &start_port))
13703 else if (unformat (i, "end_port %d", &end_port))
13706 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
13708 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
13710 else if (unformat (i, "local"))
13712 else if (unformat (i, "remote"))
13716 errmsg ("parse error '%U'", format_unformat_error, i);
13721 if (!vec_len (name))
13723 errmsg ("profile name must be specified");
13727 if (vec_len (name) > 64)
13729 errmsg ("profile name too long");
13733 M (IKEV2_PROFILE_SET_TS, mp);
13735 mp->is_local = is_local;
13736 mp->proto = (u8) proto;
13737 mp->start_port = (u16) start_port;
13738 mp->end_port = (u16) end_port;
13739 mp->start_addr = start_addr.as_u32;
13740 mp->end_addr = end_addr.as_u32;
13741 clib_memcpy (mp->name, name, vec_len (name));
13750 api_ikev2_set_local_key (vat_main_t * vam)
13752 unformat_input_t *i = vam->input;
13753 vl_api_ikev2_set_local_key_t *mp;
13757 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13759 if (unformat (i, "file %v", &file))
13760 vec_add1 (file, 0);
13763 errmsg ("parse error '%U'", format_unformat_error, i);
13768 if (!vec_len (file))
13770 errmsg ("RSA key file must be specified");
13774 if (vec_len (file) > 256)
13776 errmsg ("file name too long");
13780 M (IKEV2_SET_LOCAL_KEY, mp);
13782 clib_memcpy (mp->key_file, file, vec_len (file));
13791 api_ikev2_set_responder (vat_main_t * vam)
13793 unformat_input_t *i = vam->input;
13794 vl_api_ikev2_set_responder_t *mp;
13797 u32 sw_if_index = ~0;
13798 ip4_address_t address;
13800 const char *valid_chars = "a-zA-Z0-9_";
13802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13805 (i, "%U interface %d address %U", unformat_token, valid_chars,
13806 &name, &sw_if_index, unformat_ip4_address, &address))
13807 vec_add1 (name, 0);
13810 errmsg ("parse error '%U'", format_unformat_error, i);
13815 if (!vec_len (name))
13817 errmsg ("profile name must be specified");
13821 if (vec_len (name) > 64)
13823 errmsg ("profile name too long");
13827 M (IKEV2_SET_RESPONDER, mp);
13829 clib_memcpy (mp->name, name, vec_len (name));
13832 mp->sw_if_index = sw_if_index;
13833 clib_memcpy (mp->address, &address, sizeof (address));
13841 api_ikev2_set_ike_transforms (vat_main_t * vam)
13843 unformat_input_t *i = vam->input;
13844 vl_api_ikev2_set_ike_transforms_t *mp;
13847 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13849 const char *valid_chars = "a-zA-Z0-9_";
13851 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13853 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13854 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13855 vec_add1 (name, 0);
13858 errmsg ("parse error '%U'", format_unformat_error, i);
13863 if (!vec_len (name))
13865 errmsg ("profile name must be specified");
13869 if (vec_len (name) > 64)
13871 errmsg ("profile name too long");
13875 M (IKEV2_SET_IKE_TRANSFORMS, mp);
13877 clib_memcpy (mp->name, name, vec_len (name));
13879 mp->crypto_alg = crypto_alg;
13880 mp->crypto_key_size = crypto_key_size;
13881 mp->integ_alg = integ_alg;
13882 mp->dh_group = dh_group;
13891 api_ikev2_set_esp_transforms (vat_main_t * vam)
13893 unformat_input_t *i = vam->input;
13894 vl_api_ikev2_set_esp_transforms_t *mp;
13897 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
13899 const char *valid_chars = "a-zA-Z0-9_";
13901 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13903 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
13904 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
13905 vec_add1 (name, 0);
13908 errmsg ("parse error '%U'", format_unformat_error, i);
13913 if (!vec_len (name))
13915 errmsg ("profile name must be specified");
13919 if (vec_len (name) > 64)
13921 errmsg ("profile name too long");
13925 M (IKEV2_SET_ESP_TRANSFORMS, mp);
13927 clib_memcpy (mp->name, name, vec_len (name));
13929 mp->crypto_alg = crypto_alg;
13930 mp->crypto_key_size = crypto_key_size;
13931 mp->integ_alg = integ_alg;
13932 mp->dh_group = dh_group;
13940 api_ikev2_set_sa_lifetime (vat_main_t * vam)
13942 unformat_input_t *i = vam->input;
13943 vl_api_ikev2_set_sa_lifetime_t *mp;
13946 u64 lifetime, lifetime_maxdata;
13947 u32 lifetime_jitter, handover;
13949 const char *valid_chars = "a-zA-Z0-9_";
13951 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13953 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
13954 &lifetime, &lifetime_jitter, &handover,
13955 &lifetime_maxdata))
13956 vec_add1 (name, 0);
13959 errmsg ("parse error '%U'", format_unformat_error, i);
13964 if (!vec_len (name))
13966 errmsg ("profile name must be specified");
13970 if (vec_len (name) > 64)
13972 errmsg ("profile name too long");
13976 M (IKEV2_SET_SA_LIFETIME, mp);
13978 clib_memcpy (mp->name, name, vec_len (name));
13980 mp->lifetime = lifetime;
13981 mp->lifetime_jitter = lifetime_jitter;
13982 mp->handover = handover;
13983 mp->lifetime_maxdata = lifetime_maxdata;
13991 api_ikev2_initiate_sa_init (vat_main_t * vam)
13993 unformat_input_t *i = vam->input;
13994 vl_api_ikev2_initiate_sa_init_t *mp;
13998 const char *valid_chars = "a-zA-Z0-9_";
14000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14002 if (unformat (i, "%U", unformat_token, valid_chars, &name))
14003 vec_add1 (name, 0);
14006 errmsg ("parse error '%U'", format_unformat_error, i);
14011 if (!vec_len (name))
14013 errmsg ("profile name must be specified");
14017 if (vec_len (name) > 64)
14019 errmsg ("profile name too long");
14023 M (IKEV2_INITIATE_SA_INIT, mp);
14025 clib_memcpy (mp->name, name, vec_len (name));
14034 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
14036 unformat_input_t *i = vam->input;
14037 vl_api_ikev2_initiate_del_ike_sa_t *mp;
14042 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14044 if (unformat (i, "%lx", &ispi))
14048 errmsg ("parse error '%U'", format_unformat_error, i);
14053 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
14063 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
14065 unformat_input_t *i = vam->input;
14066 vl_api_ikev2_initiate_del_child_sa_t *mp;
14071 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14073 if (unformat (i, "%x", &ispi))
14077 errmsg ("parse error '%U'", format_unformat_error, i);
14082 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
14092 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
14094 unformat_input_t *i = vam->input;
14095 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
14100 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14102 if (unformat (i, "%x", &ispi))
14106 errmsg ("parse error '%U'", format_unformat_error, i);
14111 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
14124 api_map_add_domain (vat_main_t * vam)
14126 unformat_input_t *i = vam->input;
14127 vl_api_map_add_domain_t *mp;
14129 ip4_address_t ip4_prefix;
14130 ip6_address_t ip6_prefix;
14131 ip6_address_t ip6_src;
14132 u32 num_m_args = 0;
14133 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
14134 0, psid_length = 0;
14135 u8 is_translation = 0;
14137 u32 ip6_src_len = 128;
14140 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14142 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
14143 &ip4_prefix, &ip4_prefix_len))
14145 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
14146 &ip6_prefix, &ip6_prefix_len))
14150 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
14153 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
14155 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
14157 else if (unformat (i, "psid-offset %d", &psid_offset))
14159 else if (unformat (i, "psid-len %d", &psid_length))
14161 else if (unformat (i, "mtu %d", &mtu))
14163 else if (unformat (i, "map-t"))
14164 is_translation = 1;
14167 clib_warning ("parse error '%U'", format_unformat_error, i);
14172 if (num_m_args < 3)
14174 errmsg ("mandatory argument(s) missing");
14178 /* Construct the API message */
14179 M (MAP_ADD_DOMAIN, mp);
14181 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
14182 mp->ip4_prefix_len = ip4_prefix_len;
14184 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
14185 mp->ip6_prefix_len = ip6_prefix_len;
14187 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
14188 mp->ip6_src_prefix_len = ip6_src_len;
14190 mp->ea_bits_len = ea_bits_len;
14191 mp->psid_offset = psid_offset;
14192 mp->psid_length = psid_length;
14193 mp->is_translation = is_translation;
14194 mp->mtu = htons (mtu);
14199 /* Wait for a reply, return good/bad news */
14205 api_map_del_domain (vat_main_t * vam)
14207 unformat_input_t *i = vam->input;
14208 vl_api_map_del_domain_t *mp;
14210 u32 num_m_args = 0;
14214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14216 if (unformat (i, "index %d", &index))
14220 clib_warning ("parse error '%U'", format_unformat_error, i);
14225 if (num_m_args != 1)
14227 errmsg ("mandatory argument(s) missing");
14231 /* Construct the API message */
14232 M (MAP_DEL_DOMAIN, mp);
14234 mp->index = ntohl (index);
14239 /* Wait for a reply, return good/bad news */
14245 api_map_add_del_rule (vat_main_t * vam)
14247 unformat_input_t *i = vam->input;
14248 vl_api_map_add_del_rule_t *mp;
14250 ip6_address_t ip6_dst;
14251 u32 num_m_args = 0, index, psid = 0;
14254 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14256 if (unformat (i, "index %d", &index))
14258 else if (unformat (i, "psid %d", &psid))
14260 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
14262 else if (unformat (i, "del"))
14268 clib_warning ("parse error '%U'", format_unformat_error, i);
14273 /* Construct the API message */
14274 M (MAP_ADD_DEL_RULE, mp);
14276 mp->index = ntohl (index);
14277 mp->is_add = is_add;
14278 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
14279 mp->psid = ntohs (psid);
14284 /* Wait for a reply, return good/bad news */
14290 api_map_domain_dump (vat_main_t * vam)
14292 vl_api_map_domain_dump_t *mp;
14293 vl_api_control_ping_t *mp_ping;
14296 /* Construct the API message */
14297 M (MAP_DOMAIN_DUMP, mp);
14302 /* Use a control ping for synchronization */
14303 M (CONTROL_PING, mp_ping);
14311 api_map_rule_dump (vat_main_t * vam)
14313 unformat_input_t *i = vam->input;
14314 vl_api_map_rule_dump_t *mp;
14315 vl_api_control_ping_t *mp_ping;
14316 u32 domain_index = ~0;
14319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14321 if (unformat (i, "index %u", &domain_index))
14327 if (domain_index == ~0)
14329 clib_warning ("parse error: domain index expected");
14333 /* Construct the API message */
14334 M (MAP_RULE_DUMP, mp);
14336 mp->domain_index = htonl (domain_index);
14341 /* Use a control ping for synchronization */
14342 M (CONTROL_PING, mp_ping);
14349 static void vl_api_map_add_domain_reply_t_handler
14350 (vl_api_map_add_domain_reply_t * mp)
14352 vat_main_t *vam = &vat_main;
14353 i32 retval = ntohl (mp->retval);
14355 if (vam->async_mode)
14357 vam->async_errors += (retval < 0);
14361 vam->retval = retval;
14362 vam->result_ready = 1;
14366 static void vl_api_map_add_domain_reply_t_handler_json
14367 (vl_api_map_add_domain_reply_t * mp)
14369 vat_main_t *vam = &vat_main;
14370 vat_json_node_t node;
14372 vat_json_init_object (&node);
14373 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
14374 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
14376 vat_json_print (vam->ofp, &node);
14377 vat_json_free (&node);
14379 vam->retval = ntohl (mp->retval);
14380 vam->result_ready = 1;
14384 api_get_first_msg_id (vat_main_t * vam)
14386 vl_api_get_first_msg_id_t *mp;
14387 unformat_input_t *i = vam->input;
14392 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14394 if (unformat (i, "client %s", &name))
14402 errmsg ("missing client name");
14405 vec_add1 (name, 0);
14407 if (vec_len (name) > 63)
14409 errmsg ("client name too long");
14413 M (GET_FIRST_MSG_ID, mp);
14414 clib_memcpy (mp->name, name, vec_len (name));
14421 api_cop_interface_enable_disable (vat_main_t * vam)
14423 unformat_input_t *line_input = vam->input;
14424 vl_api_cop_interface_enable_disable_t *mp;
14425 u32 sw_if_index = ~0;
14426 u8 enable_disable = 1;
14429 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14431 if (unformat (line_input, "disable"))
14432 enable_disable = 0;
14433 if (unformat (line_input, "enable"))
14434 enable_disable = 1;
14435 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14436 vam, &sw_if_index))
14438 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14444 if (sw_if_index == ~0)
14446 errmsg ("missing interface name or sw_if_index");
14450 /* Construct the API message */
14451 M (COP_INTERFACE_ENABLE_DISABLE, mp);
14452 mp->sw_if_index = ntohl (sw_if_index);
14453 mp->enable_disable = enable_disable;
14457 /* Wait for the reply */
14463 api_cop_whitelist_enable_disable (vat_main_t * vam)
14465 unformat_input_t *line_input = vam->input;
14466 vl_api_cop_whitelist_enable_disable_t *mp;
14467 u32 sw_if_index = ~0;
14468 u8 ip4 = 0, ip6 = 0, default_cop = 0;
14472 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
14474 if (unformat (line_input, "ip4"))
14476 else if (unformat (line_input, "ip6"))
14478 else if (unformat (line_input, "default"))
14480 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
14481 vam, &sw_if_index))
14483 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
14485 else if (unformat (line_input, "fib-id %d", &fib_id))
14491 if (sw_if_index == ~0)
14493 errmsg ("missing interface name or sw_if_index");
14497 /* Construct the API message */
14498 M (COP_WHITELIST_ENABLE_DISABLE, mp);
14499 mp->sw_if_index = ntohl (sw_if_index);
14500 mp->fib_id = ntohl (fib_id);
14503 mp->default_cop = default_cop;
14507 /* Wait for the reply */
14513 api_get_node_graph (vat_main_t * vam)
14515 vl_api_get_node_graph_t *mp;
14518 M (GET_NODE_GRAPH, mp);
14522 /* Wait for the reply */
14528 /** Used for parsing LISP eids */
14529 typedef CLIB_PACKED(struct{
14530 u8 addr[16]; /**< eid address */
14531 u32 len; /**< prefix length if IP */
14532 u8 type; /**< type of eid */
14537 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
14539 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
14541 memset (a, 0, sizeof (a[0]));
14543 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
14545 a->type = 0; /* ipv4 type */
14547 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
14549 a->type = 1; /* ipv6 type */
14551 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
14553 a->type = 2; /* mac type */
14555 else if (unformat (input, "%U", unformat_nsh_address, a->addr))
14557 a->type = 3; /* NSH type */
14558 lisp_nsh_api_t *nsh = (lisp_nsh_api_t *) a->addr;
14559 nsh->spi = clib_host_to_net_u32 (nsh->spi);
14566 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
14575 lisp_eid_size_vat (u8 type)
14592 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
14594 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
14598 api_one_add_del_locator_set (vat_main_t * vam)
14600 unformat_input_t *input = vam->input;
14601 vl_api_one_add_del_locator_set_t *mp;
14603 u8 *locator_set_name = NULL;
14604 u8 locator_set_name_set = 0;
14605 vl_api_local_locator_t locator, *locators = 0;
14606 u32 sw_if_index, priority, weight;
14610 /* Parse args required to build the message */
14611 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14613 if (unformat (input, "del"))
14617 else if (unformat (input, "locator-set %s", &locator_set_name))
14619 locator_set_name_set = 1;
14621 else if (unformat (input, "sw_if_index %u p %u w %u",
14622 &sw_if_index, &priority, &weight))
14624 locator.sw_if_index = htonl (sw_if_index);
14625 locator.priority = priority;
14626 locator.weight = weight;
14627 vec_add1 (locators, locator);
14631 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
14632 &sw_if_index, &priority, &weight))
14634 locator.sw_if_index = htonl (sw_if_index);
14635 locator.priority = priority;
14636 locator.weight = weight;
14637 vec_add1 (locators, locator);
14643 if (locator_set_name_set == 0)
14645 errmsg ("missing locator-set name");
14646 vec_free (locators);
14650 if (vec_len (locator_set_name) > 64)
14652 errmsg ("locator-set name too long");
14653 vec_free (locator_set_name);
14654 vec_free (locators);
14657 vec_add1 (locator_set_name, 0);
14659 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
14661 /* Construct the API message */
14662 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
14664 mp->is_add = is_add;
14665 clib_memcpy (mp->locator_set_name, locator_set_name,
14666 vec_len (locator_set_name));
14667 vec_free (locator_set_name);
14669 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
14671 clib_memcpy (mp->locators, locators, data_len);
14672 vec_free (locators);
14677 /* Wait for a reply... */
14682 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
14685 api_one_add_del_locator (vat_main_t * vam)
14687 unformat_input_t *input = vam->input;
14688 vl_api_one_add_del_locator_t *mp;
14689 u32 tmp_if_index = ~0;
14690 u32 sw_if_index = ~0;
14691 u8 sw_if_index_set = 0;
14692 u8 sw_if_index_if_name_set = 0;
14694 u8 priority_set = 0;
14698 u8 *locator_set_name = NULL;
14699 u8 locator_set_name_set = 0;
14702 /* Parse args required to build the message */
14703 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14705 if (unformat (input, "del"))
14709 else if (unformat (input, "locator-set %s", &locator_set_name))
14711 locator_set_name_set = 1;
14713 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
14716 sw_if_index_if_name_set = 1;
14717 sw_if_index = tmp_if_index;
14719 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
14721 sw_if_index_set = 1;
14722 sw_if_index = tmp_if_index;
14724 else if (unformat (input, "p %d", &priority))
14728 else if (unformat (input, "w %d", &weight))
14736 if (locator_set_name_set == 0)
14738 errmsg ("missing locator-set name");
14742 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
14744 errmsg ("missing sw_if_index");
14745 vec_free (locator_set_name);
14749 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
14751 errmsg ("cannot use both params interface name and sw_if_index");
14752 vec_free (locator_set_name);
14756 if (priority_set == 0)
14758 errmsg ("missing locator-set priority");
14759 vec_free (locator_set_name);
14763 if (weight_set == 0)
14765 errmsg ("missing locator-set weight");
14766 vec_free (locator_set_name);
14770 if (vec_len (locator_set_name) > 64)
14772 errmsg ("locator-set name too long");
14773 vec_free (locator_set_name);
14776 vec_add1 (locator_set_name, 0);
14778 /* Construct the API message */
14779 M (ONE_ADD_DEL_LOCATOR, mp);
14781 mp->is_add = is_add;
14782 mp->sw_if_index = ntohl (sw_if_index);
14783 mp->priority = priority;
14784 mp->weight = weight;
14785 clib_memcpy (mp->locator_set_name, locator_set_name,
14786 vec_len (locator_set_name));
14787 vec_free (locator_set_name);
14792 /* Wait for a reply... */
14797 #define api_lisp_add_del_locator api_one_add_del_locator
14800 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
14802 u32 *key_id = va_arg (*args, u32 *);
14805 if (unformat (input, "%s", &s))
14807 if (!strcmp ((char *) s, "sha1"))
14808 key_id[0] = HMAC_SHA_1_96;
14809 else if (!strcmp ((char *) s, "sha256"))
14810 key_id[0] = HMAC_SHA_256_128;
14813 clib_warning ("invalid key_id: '%s'", s);
14814 key_id[0] = HMAC_NO_KEY;
14825 api_one_add_del_local_eid (vat_main_t * vam)
14827 unformat_input_t *input = vam->input;
14828 vl_api_one_add_del_local_eid_t *mp;
14831 lisp_eid_vat_t _eid, *eid = &_eid;
14832 u8 *locator_set_name = 0;
14833 u8 locator_set_name_set = 0;
14839 /* Parse args required to build the message */
14840 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14842 if (unformat (input, "del"))
14846 else if (unformat (input, "vni %d", &vni))
14850 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14854 else if (unformat (input, "locator-set %s", &locator_set_name))
14856 locator_set_name_set = 1;
14858 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
14860 else if (unformat (input, "secret-key %_%v%_", &key))
14866 if (locator_set_name_set == 0)
14868 errmsg ("missing locator-set name");
14874 errmsg ("EID address not set!");
14875 vec_free (locator_set_name);
14879 if (key && (0 == key_id))
14881 errmsg ("invalid key_id!");
14885 if (vec_len (key) > 64)
14887 errmsg ("key too long");
14892 if (vec_len (locator_set_name) > 64)
14894 errmsg ("locator-set name too long");
14895 vec_free (locator_set_name);
14898 vec_add1 (locator_set_name, 0);
14900 /* Construct the API message */
14901 M (ONE_ADD_DEL_LOCAL_EID, mp);
14903 mp->is_add = is_add;
14904 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14905 mp->eid_type = eid->type;
14906 mp->prefix_len = eid->len;
14907 mp->vni = clib_host_to_net_u32 (vni);
14908 mp->key_id = clib_host_to_net_u16 (key_id);
14909 clib_memcpy (mp->locator_set_name, locator_set_name,
14910 vec_len (locator_set_name));
14911 clib_memcpy (mp->key, key, vec_len (key));
14913 vec_free (locator_set_name);
14919 /* Wait for a reply... */
14924 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
14927 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
14929 u32 dp_table = 0, vni = 0;;
14930 unformat_input_t *input = vam->input;
14931 vl_api_gpe_add_del_fwd_entry_t *mp;
14933 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
14934 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
14935 u8 rmt_eid_set = 0, lcl_eid_set = 0;
14936 u32 action = ~0, w;
14937 ip4_address_t rmt_rloc4, lcl_rloc4;
14938 ip6_address_t rmt_rloc6, lcl_rloc6;
14939 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
14942 memset (&rloc, 0, sizeof (rloc));
14944 /* Parse args required to build the message */
14945 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14947 if (unformat (input, "del"))
14949 else if (unformat (input, "add"))
14951 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
14955 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
14959 else if (unformat (input, "vrf %d", &dp_table))
14961 else if (unformat (input, "bd %d", &dp_table))
14963 else if (unformat (input, "vni %d", &vni))
14965 else if (unformat (input, "w %d", &w))
14969 errmsg ("No RLOC configured for setting priority/weight!");
14972 curr_rloc->weight = w;
14974 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
14975 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
14979 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
14981 vec_add1 (lcl_locs, rloc);
14983 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
14984 vec_add1 (rmt_locs, rloc);
14985 /* weight saved in rmt loc */
14986 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
14988 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
14989 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
14992 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
14994 vec_add1 (lcl_locs, rloc);
14996 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
14997 vec_add1 (rmt_locs, rloc);
14998 /* weight saved in rmt loc */
14999 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
15001 else if (unformat (input, "action %d", &action))
15007 clib_warning ("parse error '%U'", format_unformat_error, input);
15014 errmsg ("remote eid addresses not set");
15018 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
15020 errmsg ("eid types don't match");
15024 if (0 == rmt_locs && (u32) ~ 0 == action)
15026 errmsg ("action not set for negative mapping");
15030 /* Construct the API message */
15031 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
15032 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
15034 mp->is_add = is_add;
15035 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
15036 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
15037 mp->eid_type = rmt_eid->type;
15038 mp->dp_table = clib_host_to_net_u32 (dp_table);
15039 mp->vni = clib_host_to_net_u32 (vni);
15040 mp->rmt_len = rmt_eid->len;
15041 mp->lcl_len = lcl_eid->len;
15042 mp->action = action;
15044 if (0 != rmt_locs && 0 != lcl_locs)
15046 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
15047 clib_memcpy (mp->locs, lcl_locs,
15048 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
15050 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
15051 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
15052 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
15054 vec_free (lcl_locs);
15055 vec_free (rmt_locs);
15060 /* Wait for a reply... */
15066 api_one_add_del_map_server (vat_main_t * vam)
15068 unformat_input_t *input = vam->input;
15069 vl_api_one_add_del_map_server_t *mp;
15073 ip4_address_t ipv4;
15074 ip6_address_t ipv6;
15077 /* Parse args required to build the message */
15078 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15080 if (unformat (input, "del"))
15084 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15088 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15096 if (ipv4_set && ipv6_set)
15098 errmsg ("both eid v4 and v6 addresses set");
15102 if (!ipv4_set && !ipv6_set)
15104 errmsg ("eid addresses not set");
15108 /* Construct the API message */
15109 M (ONE_ADD_DEL_MAP_SERVER, mp);
15111 mp->is_add = is_add;
15115 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15120 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15126 /* Wait for a reply... */
15131 #define api_lisp_add_del_map_server api_one_add_del_map_server
15134 api_one_add_del_map_resolver (vat_main_t * vam)
15136 unformat_input_t *input = vam->input;
15137 vl_api_one_add_del_map_resolver_t *mp;
15141 ip4_address_t ipv4;
15142 ip6_address_t ipv6;
15145 /* Parse args required to build the message */
15146 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15148 if (unformat (input, "del"))
15152 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
15156 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
15164 if (ipv4_set && ipv6_set)
15166 errmsg ("both eid v4 and v6 addresses set");
15170 if (!ipv4_set && !ipv6_set)
15172 errmsg ("eid addresses not set");
15176 /* Construct the API message */
15177 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
15179 mp->is_add = is_add;
15183 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
15188 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
15194 /* Wait for a reply... */
15199 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
15202 api_lisp_gpe_enable_disable (vat_main_t * vam)
15204 unformat_input_t *input = vam->input;
15205 vl_api_gpe_enable_disable_t *mp;
15210 /* Parse args required to build the message */
15211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15213 if (unformat (input, "enable"))
15218 else if (unformat (input, "disable"))
15229 errmsg ("Value not set");
15233 /* Construct the API message */
15234 M (GPE_ENABLE_DISABLE, mp);
15241 /* Wait for a reply... */
15247 api_one_rloc_probe_enable_disable (vat_main_t * vam)
15249 unformat_input_t *input = vam->input;
15250 vl_api_one_rloc_probe_enable_disable_t *mp;
15255 /* Parse args required to build the message */
15256 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15258 if (unformat (input, "enable"))
15263 else if (unformat (input, "disable"))
15271 errmsg ("Value not set");
15275 /* Construct the API message */
15276 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
15278 mp->is_enabled = is_en;
15283 /* Wait for a reply... */
15288 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
15291 api_one_map_register_enable_disable (vat_main_t * vam)
15293 unformat_input_t *input = vam->input;
15294 vl_api_one_map_register_enable_disable_t *mp;
15299 /* Parse args required to build the message */
15300 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15302 if (unformat (input, "enable"))
15307 else if (unformat (input, "disable"))
15315 errmsg ("Value not set");
15319 /* Construct the API message */
15320 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
15322 mp->is_enabled = is_en;
15327 /* Wait for a reply... */
15332 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
15335 api_one_enable_disable (vat_main_t * vam)
15337 unformat_input_t *input = vam->input;
15338 vl_api_one_enable_disable_t *mp;
15343 /* Parse args required to build the message */
15344 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15346 if (unformat (input, "enable"))
15351 else if (unformat (input, "disable"))
15361 errmsg ("Value not set");
15365 /* Construct the API message */
15366 M (ONE_ENABLE_DISABLE, mp);
15373 /* Wait for a reply... */
15378 #define api_lisp_enable_disable api_one_enable_disable
15381 api_show_one_map_register_state (vat_main_t * vam)
15383 vl_api_show_one_map_register_state_t *mp;
15386 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
15391 /* wait for reply */
15396 #define api_show_lisp_map_register_state api_show_one_map_register_state
15399 api_show_one_rloc_probe_state (vat_main_t * vam)
15401 vl_api_show_one_rloc_probe_state_t *mp;
15404 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
15409 /* wait for reply */
15414 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
15417 api_one_add_del_l2_arp_entry (vat_main_t * vam)
15419 vl_api_one_add_del_l2_arp_entry_t *mp;
15420 unformat_input_t *input = vam->input;
15425 u8 mac[6] = { 0, };
15426 u32 ip4 = 0, bd = ~0;
15429 /* Parse args required to build the message */
15430 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15432 if (unformat (input, "del"))
15434 else if (unformat (input, "mac %U", unformat_ethernet_address, mac))
15436 else if (unformat (input, "ip %U", unformat_ip4_address, &ip4))
15438 else if (unformat (input, "bd %d", &bd))
15442 errmsg ("parse error '%U'", format_unformat_error, input);
15447 if (!bd_set || !ip_set || (!mac_set && is_add))
15449 errmsg ("Missing BD, IP or MAC!");
15453 M (ONE_ADD_DEL_L2_ARP_ENTRY, mp);
15454 mp->is_add = is_add;
15455 clib_memcpy (mp->mac, mac, 6);
15456 mp->bd = clib_host_to_net_u32 (bd);
15462 /* wait for reply */
15468 api_one_l2_arp_bd_get (vat_main_t * vam)
15470 vl_api_one_l2_arp_bd_get_t *mp;
15473 M (ONE_L2_ARP_BD_GET, mp);
15478 /* wait for reply */
15484 api_one_l2_arp_entries_get (vat_main_t * vam)
15486 vl_api_one_l2_arp_entries_get_t *mp;
15487 unformat_input_t *input = vam->input;
15492 /* Parse args required to build the message */
15493 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15495 if (unformat (input, "bd %d", &bd))
15499 errmsg ("parse error '%U'", format_unformat_error, input);
15506 errmsg ("Expected bridge domain!");
15510 M (ONE_L2_ARP_ENTRIES_GET, mp);
15511 mp->bd = clib_host_to_net_u32 (bd);
15516 /* wait for reply */
15522 api_one_stats_enable_disable (vat_main_t * vam)
15524 vl_api_one_stats_enable_disable_t *mp;
15525 unformat_input_t *input = vam->input;
15530 /* Parse args required to build the message */
15531 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15533 if (unformat (input, "enable"))
15538 else if (unformat (input, "disable"))
15548 errmsg ("Value not set");
15552 M (ONE_STATS_ENABLE_DISABLE, mp);
15558 /* wait for reply */
15564 api_show_one_stats_enable_disable (vat_main_t * vam)
15566 vl_api_show_one_stats_enable_disable_t *mp;
15569 M (SHOW_ONE_STATS_ENABLE_DISABLE, mp);
15574 /* wait for reply */
15580 api_show_one_map_request_mode (vat_main_t * vam)
15582 vl_api_show_one_map_request_mode_t *mp;
15585 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
15590 /* wait for reply */
15595 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
15598 api_one_map_request_mode (vat_main_t * vam)
15600 unformat_input_t *input = vam->input;
15601 vl_api_one_map_request_mode_t *mp;
15605 /* Parse args required to build the message */
15606 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15608 if (unformat (input, "dst-only"))
15610 else if (unformat (input, "src-dst"))
15614 errmsg ("parse error '%U'", format_unformat_error, input);
15619 M (ONE_MAP_REQUEST_MODE, mp);
15626 /* wait for reply */
15631 #define api_lisp_map_request_mode api_one_map_request_mode
15634 * Enable/disable ONE proxy ITR.
15636 * @param vam vpp API test context
15637 * @return return code
15640 api_one_pitr_set_locator_set (vat_main_t * vam)
15642 u8 ls_name_set = 0;
15643 unformat_input_t *input = vam->input;
15644 vl_api_one_pitr_set_locator_set_t *mp;
15649 /* Parse args required to build the message */
15650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15652 if (unformat (input, "del"))
15654 else if (unformat (input, "locator-set %s", &ls_name))
15658 errmsg ("parse error '%U'", format_unformat_error, input);
15665 errmsg ("locator-set name not set!");
15669 M (ONE_PITR_SET_LOCATOR_SET, mp);
15671 mp->is_add = is_add;
15672 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15673 vec_free (ls_name);
15678 /* wait for reply */
15683 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
15686 api_one_nsh_set_locator_set (vat_main_t * vam)
15688 u8 ls_name_set = 0;
15689 unformat_input_t *input = vam->input;
15690 vl_api_one_nsh_set_locator_set_t *mp;
15695 /* Parse args required to build the message */
15696 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15698 if (unformat (input, "del"))
15700 else if (unformat (input, "ls %s", &ls_name))
15704 errmsg ("parse error '%U'", format_unformat_error, input);
15709 if (!ls_name_set && is_add)
15711 errmsg ("locator-set name not set!");
15715 M (ONE_NSH_SET_LOCATOR_SET, mp);
15717 mp->is_add = is_add;
15718 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
15719 vec_free (ls_name);
15724 /* wait for reply */
15730 api_show_one_pitr (vat_main_t * vam)
15732 vl_api_show_one_pitr_t *mp;
15735 if (!vam->json_output)
15737 print (vam->ofp, "%=20s", "lisp status:");
15740 M (SHOW_ONE_PITR, mp);
15744 /* Wait for a reply... */
15749 #define api_show_lisp_pitr api_show_one_pitr
15752 api_one_use_petr (vat_main_t * vam)
15754 unformat_input_t *input = vam->input;
15755 vl_api_one_use_petr_t *mp;
15760 memset (&ip, 0, sizeof (ip));
15762 /* Parse args required to build the message */
15763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15765 if (unformat (input, "disable"))
15768 if (unformat (input, "%U", unformat_ip4_address, &ip_addr_v4 (&ip)))
15771 ip_addr_version (&ip) = IP4;
15774 if (unformat (input, "%U", unformat_ip6_address, &ip_addr_v6 (&ip)))
15777 ip_addr_version (&ip) = IP6;
15781 errmsg ("parse error '%U'", format_unformat_error, input);
15786 M (ONE_USE_PETR, mp);
15788 mp->is_add = is_add;
15791 mp->is_ip4 = ip_addr_version (&ip) == IP4 ? 1 : 0;
15793 clib_memcpy (mp->address, &ip, 4);
15795 clib_memcpy (mp->address, &ip, 16);
15801 /* wait for reply */
15806 #define api_lisp_use_petr api_one_use_petr
15809 api_show_one_nsh_mapping (vat_main_t * vam)
15811 vl_api_show_one_use_petr_t *mp;
15814 if (!vam->json_output)
15816 print (vam->ofp, "%=20s", "local ONE NSH mapping:");
15819 M (SHOW_ONE_NSH_MAPPING, mp);
15823 /* Wait for a reply... */
15829 api_show_one_use_petr (vat_main_t * vam)
15831 vl_api_show_one_use_petr_t *mp;
15834 if (!vam->json_output)
15836 print (vam->ofp, "%=20s", "Proxy-ETR status:");
15839 M (SHOW_ONE_USE_PETR, mp);
15843 /* Wait for a reply... */
15848 #define api_show_lisp_use_petr api_show_one_use_petr
15851 * Add/delete mapping between vni and vrf
15854 api_one_eid_table_add_del_map (vat_main_t * vam)
15856 unformat_input_t *input = vam->input;
15857 vl_api_one_eid_table_add_del_map_t *mp;
15858 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
15859 u32 vni, vrf, bd_index;
15862 /* Parse args required to build the message */
15863 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15865 if (unformat (input, "del"))
15867 else if (unformat (input, "vrf %d", &vrf))
15869 else if (unformat (input, "bd_index %d", &bd_index))
15871 else if (unformat (input, "vni %d", &vni))
15877 if (!vni_set || (!vrf_set && !bd_index_set))
15879 errmsg ("missing arguments!");
15883 if (vrf_set && bd_index_set)
15885 errmsg ("error: both vrf and bd entered!");
15889 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
15891 mp->is_add = is_add;
15892 mp->vni = htonl (vni);
15893 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
15894 mp->is_l2 = bd_index_set;
15899 /* wait for reply */
15904 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
15907 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
15909 u32 *action = va_arg (*args, u32 *);
15912 if (unformat (input, "%s", &s))
15914 if (!strcmp ((char *) s, "no-action"))
15916 else if (!strcmp ((char *) s, "natively-forward"))
15918 else if (!strcmp ((char *) s, "send-map-request"))
15920 else if (!strcmp ((char *) s, "drop"))
15924 clib_warning ("invalid action: '%s'", s);
15936 * Add/del remote mapping to/from ONE control plane
15938 * @param vam vpp API test context
15939 * @return return code
15942 api_one_add_del_remote_mapping (vat_main_t * vam)
15944 unformat_input_t *input = vam->input;
15945 vl_api_one_add_del_remote_mapping_t *mp;
15947 lisp_eid_vat_t _eid, *eid = &_eid;
15948 lisp_eid_vat_t _seid, *seid = &_seid;
15949 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
15950 u32 action = ~0, p, w, data_len;
15951 ip4_address_t rloc4;
15952 ip6_address_t rloc6;
15953 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
15956 memset (&rloc, 0, sizeof (rloc));
15958 /* Parse args required to build the message */
15959 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
15961 if (unformat (input, "del-all"))
15965 else if (unformat (input, "del"))
15969 else if (unformat (input, "add"))
15973 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
15977 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
15981 else if (unformat (input, "vni %d", &vni))
15985 else if (unformat (input, "p %d w %d", &p, &w))
15989 errmsg ("No RLOC configured for setting priority/weight!");
15992 curr_rloc->priority = p;
15993 curr_rloc->weight = w;
15995 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
15998 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
15999 vec_add1 (rlocs, rloc);
16000 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16002 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
16005 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
16006 vec_add1 (rlocs, rloc);
16007 curr_rloc = &rlocs[vec_len (rlocs) - 1];
16009 else if (unformat (input, "action %U",
16010 unformat_negative_mapping_action, &action))
16016 clib_warning ("parse error '%U'", format_unformat_error, input);
16023 errmsg ("missing params!");
16027 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
16029 errmsg ("no action set for negative map-reply!");
16033 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
16035 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
16036 mp->is_add = is_add;
16037 mp->vni = htonl (vni);
16038 mp->action = (u8) action;
16039 mp->is_src_dst = seid_set;
16040 mp->eid_len = eid->len;
16041 mp->seid_len = seid->len;
16042 mp->del_all = del_all;
16043 mp->eid_type = eid->type;
16044 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
16045 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
16047 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
16048 clib_memcpy (mp->rlocs, rlocs, data_len);
16054 /* Wait for a reply... */
16059 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
16062 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
16063 * forwarding entries in data-plane accordingly.
16065 * @param vam vpp API test context
16066 * @return return code
16069 api_one_add_del_adjacency (vat_main_t * vam)
16071 unformat_input_t *input = vam->input;
16072 vl_api_one_add_del_adjacency_t *mp;
16074 ip4_address_t leid4, reid4;
16075 ip6_address_t leid6, reid6;
16076 u8 reid_mac[6] = { 0 };
16077 u8 leid_mac[6] = { 0 };
16078 u8 reid_type, leid_type;
16079 u32 leid_len = 0, reid_len = 0, len;
16083 leid_type = reid_type = (u8) ~ 0;
16085 /* Parse args required to build the message */
16086 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16088 if (unformat (input, "del"))
16092 else if (unformat (input, "add"))
16096 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
16099 reid_type = 0; /* ipv4 */
16102 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
16105 reid_type = 1; /* ipv6 */
16108 else if (unformat (input, "reid %U", unformat_ethernet_address,
16111 reid_type = 2; /* mac */
16113 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
16116 leid_type = 0; /* ipv4 */
16119 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
16122 leid_type = 1; /* ipv6 */
16125 else if (unformat (input, "leid %U", unformat_ethernet_address,
16128 leid_type = 2; /* mac */
16130 else if (unformat (input, "vni %d", &vni))
16136 errmsg ("parse error '%U'", format_unformat_error, input);
16141 if ((u8) ~ 0 == reid_type)
16143 errmsg ("missing params!");
16147 if (leid_type != reid_type)
16149 errmsg ("remote and local EIDs are of different types!");
16153 M (ONE_ADD_DEL_ADJACENCY, mp);
16154 mp->is_add = is_add;
16155 mp->vni = htonl (vni);
16156 mp->leid_len = leid_len;
16157 mp->reid_len = reid_len;
16158 mp->eid_type = reid_type;
16160 switch (mp->eid_type)
16163 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
16164 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
16167 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
16168 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
16171 clib_memcpy (mp->leid, leid_mac, 6);
16172 clib_memcpy (mp->reid, reid_mac, 6);
16175 errmsg ("unknown EID type %d!", mp->eid_type);
16182 /* Wait for a reply... */
16187 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
16190 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
16192 u32 *mode = va_arg (*args, u32 *);
16194 if (unformat (input, "lisp"))
16196 else if (unformat (input, "vxlan"))
16205 api_gpe_get_encap_mode (vat_main_t * vam)
16207 vl_api_gpe_get_encap_mode_t *mp;
16210 /* Construct the API message */
16211 M (GPE_GET_ENCAP_MODE, mp);
16216 /* Wait for a reply... */
16222 api_gpe_set_encap_mode (vat_main_t * vam)
16224 unformat_input_t *input = vam->input;
16225 vl_api_gpe_set_encap_mode_t *mp;
16229 /* Parse args required to build the message */
16230 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16232 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
16238 /* Construct the API message */
16239 M (GPE_SET_ENCAP_MODE, mp);
16246 /* Wait for a reply... */
16252 api_lisp_gpe_add_del_iface (vat_main_t * vam)
16254 unformat_input_t *input = vam->input;
16255 vl_api_gpe_add_del_iface_t *mp;
16256 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
16257 u32 dp_table = 0, vni = 0;
16260 /* Parse args required to build the message */
16261 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16263 if (unformat (input, "up"))
16268 else if (unformat (input, "down"))
16273 else if (unformat (input, "table_id %d", &dp_table))
16277 else if (unformat (input, "bd_id %d", &dp_table))
16282 else if (unformat (input, "vni %d", &vni))
16290 if (action_set == 0)
16292 errmsg ("Action not set");
16295 if (dp_table_set == 0 || vni_set == 0)
16297 errmsg ("vni and dp_table must be set");
16301 /* Construct the API message */
16302 M (GPE_ADD_DEL_IFACE, mp);
16304 mp->is_add = is_add;
16305 mp->dp_table = clib_host_to_net_u32 (dp_table);
16307 mp->vni = clib_host_to_net_u32 (vni);
16312 /* Wait for a reply... */
16318 api_one_map_register_fallback_threshold (vat_main_t * vam)
16320 unformat_input_t *input = vam->input;
16321 vl_api_one_map_register_fallback_threshold_t *mp;
16326 /* Parse args required to build the message */
16327 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16329 if (unformat (input, "%u", &value))
16333 clib_warning ("parse error '%U'", format_unformat_error, input);
16340 errmsg ("fallback threshold value is missing!");
16344 M (ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16345 mp->value = clib_host_to_net_u32 (value);
16350 /* Wait for a reply... */
16356 api_show_one_map_register_fallback_threshold (vat_main_t * vam)
16358 vl_api_show_one_map_register_fallback_threshold_t *mp;
16361 M (SHOW_ONE_MAP_REGISTER_FALLBACK_THRESHOLD, mp);
16366 /* Wait for a reply... */
16372 api_one_map_register_set_ttl (vat_main_t * vam)
16374 unformat_input_t *input = vam->input;
16375 vl_api_one_map_register_set_ttl_t *mp;
16380 /* Parse args required to build the message */
16381 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16383 if (unformat (input, "%u", &ttl))
16387 clib_warning ("parse error '%U'", format_unformat_error, input);
16394 errmsg ("TTL value missing!");
16398 M (ONE_MAP_REGISTER_SET_TTL, mp);
16399 mp->ttl = clib_host_to_net_u32 (ttl);
16404 /* Wait for a reply... */
16410 api_show_one_map_register_ttl (vat_main_t * vam)
16412 vl_api_show_one_map_register_ttl_t *mp;
16415 M (SHOW_ONE_MAP_REGISTER_TTL, mp);
16420 /* Wait for a reply... */
16426 * Add/del map request itr rlocs from ONE control plane and updates
16428 * @param vam vpp API test context
16429 * @return return code
16432 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
16434 unformat_input_t *input = vam->input;
16435 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
16436 u8 *locator_set_name = 0;
16437 u8 locator_set_name_set = 0;
16441 /* Parse args required to build the message */
16442 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16444 if (unformat (input, "del"))
16448 else if (unformat (input, "%_%v%_", &locator_set_name))
16450 locator_set_name_set = 1;
16454 clib_warning ("parse error '%U'", format_unformat_error, input);
16459 if (is_add && !locator_set_name_set)
16461 errmsg ("itr-rloc is not set!");
16465 if (is_add && vec_len (locator_set_name) > 64)
16467 errmsg ("itr-rloc locator-set name too long");
16468 vec_free (locator_set_name);
16472 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
16473 mp->is_add = is_add;
16476 clib_memcpy (mp->locator_set_name, locator_set_name,
16477 vec_len (locator_set_name));
16481 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
16483 vec_free (locator_set_name);
16488 /* Wait for a reply... */
16493 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
16496 api_one_locator_dump (vat_main_t * vam)
16498 unformat_input_t *input = vam->input;
16499 vl_api_one_locator_dump_t *mp;
16500 vl_api_control_ping_t *mp_ping;
16501 u8 is_index_set = 0, is_name_set = 0;
16506 /* Parse args required to build the message */
16507 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16509 if (unformat (input, "ls_name %_%v%_", &ls_name))
16513 else if (unformat (input, "ls_index %d", &ls_index))
16519 errmsg ("parse error '%U'", format_unformat_error, input);
16524 if (!is_index_set && !is_name_set)
16526 errmsg ("error: expected one of index or name!");
16530 if (is_index_set && is_name_set)
16532 errmsg ("error: only one param expected!");
16536 if (vec_len (ls_name) > 62)
16538 errmsg ("error: locator set name too long!");
16542 if (!vam->json_output)
16544 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
16547 M (ONE_LOCATOR_DUMP, mp);
16548 mp->is_index_set = is_index_set;
16551 mp->ls_index = clib_host_to_net_u32 (ls_index);
16554 vec_add1 (ls_name, 0);
16555 strncpy ((char *) mp->ls_name, (char *) ls_name,
16556 sizeof (mp->ls_name) - 1);
16562 /* Use a control ping for synchronization */
16563 M (CONTROL_PING, mp_ping);
16566 /* Wait for a reply... */
16571 #define api_lisp_locator_dump api_one_locator_dump
16574 api_one_locator_set_dump (vat_main_t * vam)
16576 vl_api_one_locator_set_dump_t *mp;
16577 vl_api_control_ping_t *mp_ping;
16578 unformat_input_t *input = vam->input;
16582 /* Parse args required to build the message */
16583 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16585 if (unformat (input, "local"))
16589 else if (unformat (input, "remote"))
16595 errmsg ("parse error '%U'", format_unformat_error, input);
16600 if (!vam->json_output)
16602 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
16605 M (ONE_LOCATOR_SET_DUMP, mp);
16607 mp->filter = filter;
16612 /* Use a control ping for synchronization */
16613 M (CONTROL_PING, mp_ping);
16616 /* Wait for a reply... */
16621 #define api_lisp_locator_set_dump api_one_locator_set_dump
16624 api_one_eid_table_map_dump (vat_main_t * vam)
16628 unformat_input_t *input = vam->input;
16629 vl_api_one_eid_table_map_dump_t *mp;
16630 vl_api_control_ping_t *mp_ping;
16633 /* Parse args required to build the message */
16634 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16636 if (unformat (input, "l2"))
16641 else if (unformat (input, "l3"))
16648 errmsg ("parse error '%U'", format_unformat_error, input);
16655 errmsg ("expected one of 'l2' or 'l3' parameter!");
16659 if (!vam->json_output)
16661 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
16664 M (ONE_EID_TABLE_MAP_DUMP, mp);
16670 /* Use a control ping for synchronization */
16671 M (CONTROL_PING, mp_ping);
16674 /* Wait for a reply... */
16679 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
16682 api_one_eid_table_vni_dump (vat_main_t * vam)
16684 vl_api_one_eid_table_vni_dump_t *mp;
16685 vl_api_control_ping_t *mp_ping;
16688 if (!vam->json_output)
16690 print (vam->ofp, "VNI");
16693 M (ONE_EID_TABLE_VNI_DUMP, mp);
16698 /* Use a control ping for synchronization */
16699 M (CONTROL_PING, mp_ping);
16702 /* Wait for a reply... */
16707 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
16710 api_one_eid_table_dump (vat_main_t * vam)
16712 unformat_input_t *i = vam->input;
16713 vl_api_one_eid_table_dump_t *mp;
16714 vl_api_control_ping_t *mp_ping;
16715 struct in_addr ip4;
16716 struct in6_addr ip6;
16718 u8 eid_type = ~0, eid_set = 0;
16719 u32 prefix_length = ~0, t, vni = 0;
16722 lisp_nsh_api_t nsh;
16724 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16726 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
16732 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
16738 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
16743 else if (unformat (i, "eid %U", unformat_nsh_address, &nsh))
16748 else if (unformat (i, "vni %d", &t))
16752 else if (unformat (i, "local"))
16756 else if (unformat (i, "remote"))
16762 errmsg ("parse error '%U'", format_unformat_error, i);
16767 if (!vam->json_output)
16769 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
16770 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
16773 M (ONE_EID_TABLE_DUMP, mp);
16775 mp->filter = filter;
16779 mp->vni = htonl (vni);
16780 mp->eid_type = eid_type;
16784 mp->prefix_length = prefix_length;
16785 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
16788 mp->prefix_length = prefix_length;
16789 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
16792 clib_memcpy (mp->eid, mac, sizeof (mac));
16795 clib_memcpy (mp->eid, &nsh, sizeof (nsh));
16798 errmsg ("unknown EID type %d!", eid_type);
16806 /* Use a control ping for synchronization */
16807 M (CONTROL_PING, mp_ping);
16810 /* Wait for a reply... */
16815 #define api_lisp_eid_table_dump api_one_eid_table_dump
16818 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
16820 unformat_input_t *i = vam->input;
16821 vl_api_gpe_fwd_entries_get_t *mp;
16826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16828 if (unformat (i, "vni %d", &vni))
16834 errmsg ("parse error '%U'", format_unformat_error, i);
16841 errmsg ("vni not set!");
16845 if (!vam->json_output)
16847 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
16851 M (GPE_FWD_ENTRIES_GET, mp);
16852 mp->vni = clib_host_to_net_u32 (vni);
16857 /* Wait for a reply... */
16862 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_endian vl_noop_handler
16863 #define vl_api_gpe_native_fwd_rpaths_get_reply_t_print vl_noop_handler
16864 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_endian vl_noop_handler
16865 #define vl_api_gpe_fwd_entry_vnis_get_reply_t_print vl_noop_handler
16866 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
16867 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
16868 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
16869 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
16872 api_one_adjacencies_get (vat_main_t * vam)
16874 unformat_input_t *i = vam->input;
16875 vl_api_one_adjacencies_get_t *mp;
16880 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16882 if (unformat (i, "vni %d", &vni))
16888 errmsg ("parse error '%U'", format_unformat_error, i);
16895 errmsg ("vni not set!");
16899 if (!vam->json_output)
16901 print (vam->ofp, "%s %40s", "leid", "reid");
16904 M (ONE_ADJACENCIES_GET, mp);
16905 mp->vni = clib_host_to_net_u32 (vni);
16910 /* Wait for a reply... */
16915 #define api_lisp_adjacencies_get api_one_adjacencies_get
16918 api_gpe_native_fwd_rpaths_get (vat_main_t * vam)
16920 unformat_input_t *i = vam->input;
16921 vl_api_gpe_native_fwd_rpaths_get_t *mp;
16923 u8 ip_family_set = 0, is_ip4 = 1;
16925 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16927 if (unformat (i, "ip4"))
16932 else if (unformat (i, "ip6"))
16939 errmsg ("parse error '%U'", format_unformat_error, i);
16944 if (!ip_family_set)
16946 errmsg ("ip family not set!");
16950 M (GPE_NATIVE_FWD_RPATHS_GET, mp);
16951 mp->is_ip4 = is_ip4;
16956 /* Wait for a reply... */
16962 api_gpe_fwd_entry_vnis_get (vat_main_t * vam)
16964 vl_api_gpe_fwd_entry_vnis_get_t *mp;
16967 if (!vam->json_output)
16969 print (vam->ofp, "VNIs");
16972 M (GPE_FWD_ENTRY_VNIS_GET, mp);
16977 /* Wait for a reply... */
16983 api_gpe_add_del_native_fwd_rpath (vat_main_t * vam)
16985 unformat_input_t *i = vam->input;
16986 vl_api_gpe_add_del_native_fwd_rpath_t *mp;
16988 u8 is_add = 1, ip_set = 0, is_ip4 = 1;
16989 struct in_addr ip4;
16990 struct in6_addr ip6;
16991 u32 table_id = 0, nh_sw_if_index = ~0;
16993 memset (&ip4, 0, sizeof (ip4));
16994 memset (&ip6, 0, sizeof (ip6));
16996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16998 if (unformat (i, "del"))
17000 else if (unformat (i, "via %U %U", unformat_ip4_address, &ip4,
17001 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17006 else if (unformat (i, "via %U %U", unformat_ip6_address, &ip6,
17007 api_unformat_sw_if_index, vam, &nh_sw_if_index))
17012 else if (unformat (i, "via %U", unformat_ip4_address, &ip4))
17016 nh_sw_if_index = ~0;
17018 else if (unformat (i, "via %U", unformat_ip6_address, &ip6))
17022 nh_sw_if_index = ~0;
17024 else if (unformat (i, "table %d", &table_id))
17028 errmsg ("parse error '%U'", format_unformat_error, i);
17035 errmsg ("nh addr not set!");
17039 M (GPE_ADD_DEL_NATIVE_FWD_RPATH, mp);
17040 mp->is_add = is_add;
17041 mp->table_id = clib_host_to_net_u32 (table_id);
17042 mp->nh_sw_if_index = clib_host_to_net_u32 (nh_sw_if_index);
17043 mp->is_ip4 = is_ip4;
17045 clib_memcpy (mp->nh_addr, &ip4, sizeof (ip4));
17047 clib_memcpy (mp->nh_addr, &ip6, sizeof (ip6));
17052 /* Wait for a reply... */
17058 api_one_map_server_dump (vat_main_t * vam)
17060 vl_api_one_map_server_dump_t *mp;
17061 vl_api_control_ping_t *mp_ping;
17064 if (!vam->json_output)
17066 print (vam->ofp, "%=20s", "Map server");
17069 M (ONE_MAP_SERVER_DUMP, mp);
17073 /* Use a control ping for synchronization */
17074 M (CONTROL_PING, mp_ping);
17077 /* Wait for a reply... */
17082 #define api_lisp_map_server_dump api_one_map_server_dump
17085 api_one_map_resolver_dump (vat_main_t * vam)
17087 vl_api_one_map_resolver_dump_t *mp;
17088 vl_api_control_ping_t *mp_ping;
17091 if (!vam->json_output)
17093 print (vam->ofp, "%=20s", "Map resolver");
17096 M (ONE_MAP_RESOLVER_DUMP, mp);
17100 /* Use a control ping for synchronization */
17101 M (CONTROL_PING, mp_ping);
17104 /* Wait for a reply... */
17109 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
17112 api_one_stats_flush (vat_main_t * vam)
17114 vl_api_one_stats_flush_t *mp;
17117 M (ONE_STATS_FLUSH, mp);
17124 api_one_stats_dump (vat_main_t * vam)
17126 vl_api_one_stats_dump_t *mp;
17127 vl_api_control_ping_t *mp_ping;
17130 M (ONE_STATS_DUMP, mp);
17134 /* Use a control ping for synchronization */
17135 M (CONTROL_PING, mp_ping);
17138 /* Wait for a reply... */
17144 api_show_one_status (vat_main_t * vam)
17146 vl_api_show_one_status_t *mp;
17149 if (!vam->json_output)
17151 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
17154 M (SHOW_ONE_STATUS, mp);
17157 /* Wait for a reply... */
17162 #define api_show_lisp_status api_show_one_status
17165 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
17167 vl_api_gpe_fwd_entry_path_dump_t *mp;
17168 vl_api_control_ping_t *mp_ping;
17169 unformat_input_t *i = vam->input;
17170 u32 fwd_entry_index = ~0;
17173 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17175 if (unformat (i, "index %d", &fwd_entry_index))
17181 if (~0 == fwd_entry_index)
17183 errmsg ("no index specified!");
17187 if (!vam->json_output)
17189 print (vam->ofp, "first line");
17192 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
17196 /* Use a control ping for synchronization */
17197 M (CONTROL_PING, mp_ping);
17200 /* Wait for a reply... */
17206 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
17208 vl_api_one_get_map_request_itr_rlocs_t *mp;
17211 if (!vam->json_output)
17213 print (vam->ofp, "%=20s", "itr-rlocs:");
17216 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
17219 /* Wait for a reply... */
17224 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
17227 api_af_packet_create (vat_main_t * vam)
17229 unformat_input_t *i = vam->input;
17230 vl_api_af_packet_create_t *mp;
17231 u8 *host_if_name = 0;
17233 u8 random_hw_addr = 1;
17236 memset (hw_addr, 0, sizeof (hw_addr));
17238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17240 if (unformat (i, "name %s", &host_if_name))
17241 vec_add1 (host_if_name, 0);
17242 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17243 random_hw_addr = 0;
17248 if (!vec_len (host_if_name))
17250 errmsg ("host-interface name must be specified");
17254 if (vec_len (host_if_name) > 64)
17256 errmsg ("host-interface name too long");
17260 M (AF_PACKET_CREATE, mp);
17262 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17263 clib_memcpy (mp->hw_addr, hw_addr, 6);
17264 mp->use_random_hw_addr = random_hw_addr;
17265 vec_free (host_if_name);
17273 fprintf (vam->ofp ? vam->ofp : stderr,
17274 " new sw_if_index = %d\n", vam->sw_if_index);
17281 api_af_packet_delete (vat_main_t * vam)
17283 unformat_input_t *i = vam->input;
17284 vl_api_af_packet_delete_t *mp;
17285 u8 *host_if_name = 0;
17288 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17290 if (unformat (i, "name %s", &host_if_name))
17291 vec_add1 (host_if_name, 0);
17296 if (!vec_len (host_if_name))
17298 errmsg ("host-interface name must be specified");
17302 if (vec_len (host_if_name) > 64)
17304 errmsg ("host-interface name too long");
17308 M (AF_PACKET_DELETE, mp);
17310 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
17311 vec_free (host_if_name);
17319 api_policer_add_del (vat_main_t * vam)
17321 unformat_input_t *i = vam->input;
17322 vl_api_policer_add_del_t *mp;
17332 u8 color_aware = 0;
17333 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
17336 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
17337 conform_action.dscp = 0;
17338 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
17339 exceed_action.dscp = 0;
17340 violate_action.action_type = SSE2_QOS_ACTION_DROP;
17341 violate_action.dscp = 0;
17343 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17345 if (unformat (i, "del"))
17347 else if (unformat (i, "name %s", &name))
17348 vec_add1 (name, 0);
17349 else if (unformat (i, "cir %u", &cir))
17351 else if (unformat (i, "eir %u", &eir))
17353 else if (unformat (i, "cb %u", &cb))
17355 else if (unformat (i, "eb %u", &eb))
17357 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
17360 else if (unformat (i, "round_type %U", unformat_policer_round_type,
17363 else if (unformat (i, "type %U", unformat_policer_type, &type))
17365 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
17368 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
17371 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
17374 else if (unformat (i, "color-aware"))
17380 if (!vec_len (name))
17382 errmsg ("policer name must be specified");
17386 if (vec_len (name) > 64)
17388 errmsg ("policer name too long");
17392 M (POLICER_ADD_DEL, mp);
17394 clib_memcpy (mp->name, name, vec_len (name));
17396 mp->is_add = is_add;
17401 mp->rate_type = rate_type;
17402 mp->round_type = round_type;
17404 mp->conform_action_type = conform_action.action_type;
17405 mp->conform_dscp = conform_action.dscp;
17406 mp->exceed_action_type = exceed_action.action_type;
17407 mp->exceed_dscp = exceed_action.dscp;
17408 mp->violate_action_type = violate_action.action_type;
17409 mp->violate_dscp = violate_action.dscp;
17410 mp->color_aware = color_aware;
17418 api_policer_dump (vat_main_t * vam)
17420 unformat_input_t *i = vam->input;
17421 vl_api_policer_dump_t *mp;
17422 vl_api_control_ping_t *mp_ping;
17423 u8 *match_name = 0;
17424 u8 match_name_valid = 0;
17427 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17429 if (unformat (i, "name %s", &match_name))
17431 vec_add1 (match_name, 0);
17432 match_name_valid = 1;
17438 M (POLICER_DUMP, mp);
17439 mp->match_name_valid = match_name_valid;
17440 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
17441 vec_free (match_name);
17445 /* Use a control ping for synchronization */
17446 M (CONTROL_PING, mp_ping);
17449 /* Wait for a reply... */
17455 api_policer_classify_set_interface (vat_main_t * vam)
17457 unformat_input_t *i = vam->input;
17458 vl_api_policer_classify_set_interface_t *mp;
17460 int sw_if_index_set;
17461 u32 ip4_table_index = ~0;
17462 u32 ip6_table_index = ~0;
17463 u32 l2_table_index = ~0;
17467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17469 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17470 sw_if_index_set = 1;
17471 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17472 sw_if_index_set = 1;
17473 else if (unformat (i, "del"))
17475 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17477 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17479 else if (unformat (i, "l2-table %d", &l2_table_index))
17483 clib_warning ("parse error '%U'", format_unformat_error, i);
17488 if (sw_if_index_set == 0)
17490 errmsg ("missing interface name or sw_if_index");
17494 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
17496 mp->sw_if_index = ntohl (sw_if_index);
17497 mp->ip4_table_index = ntohl (ip4_table_index);
17498 mp->ip6_table_index = ntohl (ip6_table_index);
17499 mp->l2_table_index = ntohl (l2_table_index);
17500 mp->is_add = is_add;
17508 api_policer_classify_dump (vat_main_t * vam)
17510 unformat_input_t *i = vam->input;
17511 vl_api_policer_classify_dump_t *mp;
17512 vl_api_control_ping_t *mp_ping;
17513 u8 type = POLICER_CLASSIFY_N_TABLES;
17516 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
17520 errmsg ("classify table type must be specified");
17524 if (!vam->json_output)
17526 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17529 M (POLICER_CLASSIFY_DUMP, mp);
17534 /* Use a control ping for synchronization */
17535 M (CONTROL_PING, mp_ping);
17538 /* Wait for a reply... */
17544 api_netmap_create (vat_main_t * vam)
17546 unformat_input_t *i = vam->input;
17547 vl_api_netmap_create_t *mp;
17550 u8 random_hw_addr = 1;
17555 memset (hw_addr, 0, sizeof (hw_addr));
17557 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17559 if (unformat (i, "name %s", &if_name))
17560 vec_add1 (if_name, 0);
17561 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
17562 random_hw_addr = 0;
17563 else if (unformat (i, "pipe"))
17565 else if (unformat (i, "master"))
17567 else if (unformat (i, "slave"))
17573 if (!vec_len (if_name))
17575 errmsg ("interface name must be specified");
17579 if (vec_len (if_name) > 64)
17581 errmsg ("interface name too long");
17585 M (NETMAP_CREATE, mp);
17587 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17588 clib_memcpy (mp->hw_addr, hw_addr, 6);
17589 mp->use_random_hw_addr = random_hw_addr;
17590 mp->is_pipe = is_pipe;
17591 mp->is_master = is_master;
17592 vec_free (if_name);
17600 api_netmap_delete (vat_main_t * vam)
17602 unformat_input_t *i = vam->input;
17603 vl_api_netmap_delete_t *mp;
17607 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17609 if (unformat (i, "name %s", &if_name))
17610 vec_add1 (if_name, 0);
17615 if (!vec_len (if_name))
17617 errmsg ("interface name must be specified");
17621 if (vec_len (if_name) > 64)
17623 errmsg ("interface name too long");
17627 M (NETMAP_DELETE, mp);
17629 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
17630 vec_free (if_name);
17638 vl_api_mpls_fib_path_print (vat_main_t * vam, vl_api_fib_path2_t * fp)
17640 if (fp->afi == IP46_TYPE_IP6)
17642 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17643 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17644 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17645 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17646 format_ip6_address, fp->next_hop);
17647 else if (fp->afi == IP46_TYPE_IP4)
17649 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17650 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17651 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17652 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17653 format_ip4_address, fp->next_hop);
17657 vl_api_mpls_fib_path_json_print (vat_json_node_t * node,
17658 vl_api_fib_path2_t * fp)
17660 struct in_addr ip4;
17661 struct in6_addr ip6;
17663 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17664 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17665 vat_json_object_add_uint (node, "is_local", fp->is_local);
17666 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17667 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17668 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17669 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17670 if (fp->afi == IP46_TYPE_IP4)
17672 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17673 vat_json_object_add_ip4 (node, "next_hop", ip4);
17675 else if (fp->afi == IP46_TYPE_IP6)
17677 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17678 vat_json_object_add_ip6 (node, "next_hop", ip6);
17683 vl_api_mpls_tunnel_details_t_handler (vl_api_mpls_tunnel_details_t * mp)
17685 vat_main_t *vam = &vat_main;
17686 int count = ntohl (mp->mt_count);
17687 vl_api_fib_path2_t *fp;
17690 print (vam->ofp, "[%d]: sw_if_index %d via:",
17691 ntohl (mp->mt_tunnel_index), ntohl (mp->mt_sw_if_index));
17693 for (i = 0; i < count; i++)
17695 vl_api_mpls_fib_path_print (vam, fp);
17699 print (vam->ofp, "");
17702 #define vl_api_mpls_tunnel_details_t_endian vl_noop_handler
17703 #define vl_api_mpls_tunnel_details_t_print vl_noop_handler
17706 vl_api_mpls_tunnel_details_t_handler_json (vl_api_mpls_tunnel_details_t * mp)
17708 vat_main_t *vam = &vat_main;
17709 vat_json_node_t *node = NULL;
17710 int count = ntohl (mp->mt_count);
17711 vl_api_fib_path2_t *fp;
17714 if (VAT_JSON_ARRAY != vam->json_tree.type)
17716 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17717 vat_json_init_array (&vam->json_tree);
17719 node = vat_json_array_add (&vam->json_tree);
17721 vat_json_init_object (node);
17722 vat_json_object_add_uint (node, "tunnel_index",
17723 ntohl (mp->mt_tunnel_index));
17724 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->mt_sw_if_index));
17726 vat_json_object_add_uint (node, "l2_only", mp->mt_l2_only);
17729 for (i = 0; i < count; i++)
17731 vl_api_mpls_fib_path_json_print (node, fp);
17737 api_mpls_tunnel_dump (vat_main_t * vam)
17739 vl_api_mpls_tunnel_dump_t *mp;
17740 vl_api_control_ping_t *mp_ping;
17744 /* Parse args required to build the message */
17745 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
17747 if (!unformat (vam->input, "tunnel_index %d", &index))
17754 print (vam->ofp, " tunnel_index %d", index);
17756 M (MPLS_TUNNEL_DUMP, mp);
17757 mp->tunnel_index = htonl (index);
17760 /* Use a control ping for synchronization */
17761 M (CONTROL_PING, mp_ping);
17768 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
17769 #define vl_api_mpls_fib_details_t_print vl_noop_handler
17773 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
17775 vat_main_t *vam = &vat_main;
17776 int count = ntohl (mp->count);
17777 vl_api_fib_path2_t *fp;
17781 "table-id %d, label %u, ess_bit %u",
17782 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
17784 for (i = 0; i < count; i++)
17786 vl_api_mpls_fib_path_print (vam, fp);
17791 static void vl_api_mpls_fib_details_t_handler_json
17792 (vl_api_mpls_fib_details_t * mp)
17794 vat_main_t *vam = &vat_main;
17795 int count = ntohl (mp->count);
17796 vat_json_node_t *node = NULL;
17797 vl_api_fib_path2_t *fp;
17800 if (VAT_JSON_ARRAY != vam->json_tree.type)
17802 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17803 vat_json_init_array (&vam->json_tree);
17805 node = vat_json_array_add (&vam->json_tree);
17807 vat_json_init_object (node);
17808 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17809 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
17810 vat_json_object_add_uint (node, "label", ntohl (mp->label));
17811 vat_json_object_add_uint (node, "path_count", count);
17813 for (i = 0; i < count; i++)
17815 vl_api_mpls_fib_path_json_print (node, fp);
17821 api_mpls_fib_dump (vat_main_t * vam)
17823 vl_api_mpls_fib_dump_t *mp;
17824 vl_api_control_ping_t *mp_ping;
17827 M (MPLS_FIB_DUMP, mp);
17830 /* Use a control ping for synchronization */
17831 M (CONTROL_PING, mp_ping);
17838 #define vl_api_ip_fib_details_t_endian vl_noop_handler
17839 #define vl_api_ip_fib_details_t_print vl_noop_handler
17842 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
17844 vat_main_t *vam = &vat_main;
17845 int count = ntohl (mp->count);
17846 vl_api_fib_path_t *fp;
17850 "table-id %d, prefix %U/%d",
17851 ntohl (mp->table_id), format_ip4_address, mp->address,
17852 mp->address_length);
17854 for (i = 0; i < count; i++)
17856 if (fp->afi == IP46_TYPE_IP6)
17858 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17859 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17860 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17861 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17862 format_ip6_address, fp->next_hop);
17863 else if (fp->afi == IP46_TYPE_IP4)
17865 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
17866 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
17867 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
17868 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
17869 format_ip4_address, fp->next_hop);
17874 static void vl_api_ip_fib_details_t_handler_json
17875 (vl_api_ip_fib_details_t * mp)
17877 vat_main_t *vam = &vat_main;
17878 int count = ntohl (mp->count);
17879 vat_json_node_t *node = NULL;
17880 struct in_addr ip4;
17881 struct in6_addr ip6;
17882 vl_api_fib_path_t *fp;
17885 if (VAT_JSON_ARRAY != vam->json_tree.type)
17887 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17888 vat_json_init_array (&vam->json_tree);
17890 node = vat_json_array_add (&vam->json_tree);
17892 vat_json_init_object (node);
17893 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
17894 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
17895 vat_json_object_add_ip4 (node, "prefix", ip4);
17896 vat_json_object_add_uint (node, "mask_length", mp->address_length);
17897 vat_json_object_add_uint (node, "path_count", count);
17899 for (i = 0; i < count; i++)
17901 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
17902 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
17903 vat_json_object_add_uint (node, "is_local", fp->is_local);
17904 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
17905 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
17906 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
17907 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
17908 if (fp->afi == IP46_TYPE_IP4)
17910 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
17911 vat_json_object_add_ip4 (node, "next_hop", ip4);
17913 else if (fp->afi == IP46_TYPE_IP6)
17915 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
17916 vat_json_object_add_ip6 (node, "next_hop", ip6);
17922 api_ip_fib_dump (vat_main_t * vam)
17924 vl_api_ip_fib_dump_t *mp;
17925 vl_api_control_ping_t *mp_ping;
17928 M (IP_FIB_DUMP, mp);
17931 /* Use a control ping for synchronization */
17932 M (CONTROL_PING, mp_ping);
17940 api_ip_mfib_dump (vat_main_t * vam)
17942 vl_api_ip_mfib_dump_t *mp;
17943 vl_api_control_ping_t *mp_ping;
17946 M (IP_MFIB_DUMP, mp);
17949 /* Use a control ping for synchronization */
17950 M (CONTROL_PING, mp_ping);
17957 static void vl_api_ip_neighbor_details_t_handler
17958 (vl_api_ip_neighbor_details_t * mp)
17960 vat_main_t *vam = &vat_main;
17962 print (vam->ofp, "%c %U %U",
17963 (mp->is_static) ? 'S' : 'D',
17964 format_ethernet_address, &mp->mac_address,
17965 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
17969 static void vl_api_ip_neighbor_details_t_handler_json
17970 (vl_api_ip_neighbor_details_t * mp)
17973 vat_main_t *vam = &vat_main;
17974 vat_json_node_t *node;
17975 struct in_addr ip4;
17976 struct in6_addr ip6;
17978 if (VAT_JSON_ARRAY != vam->json_tree.type)
17980 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17981 vat_json_init_array (&vam->json_tree);
17983 node = vat_json_array_add (&vam->json_tree);
17985 vat_json_init_object (node);
17986 vat_json_object_add_string_copy (node, "flag",
17987 (mp->is_static) ? (u8 *) "static" : (u8 *)
17990 vat_json_object_add_string_copy (node, "link_layer",
17991 format (0, "%U", format_ethernet_address,
17992 &mp->mac_address));
17996 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
17997 vat_json_object_add_ip6 (node, "ip_address", ip6);
18001 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
18002 vat_json_object_add_ip4 (node, "ip_address", ip4);
18007 api_ip_neighbor_dump (vat_main_t * vam)
18009 unformat_input_t *i = vam->input;
18010 vl_api_ip_neighbor_dump_t *mp;
18011 vl_api_control_ping_t *mp_ping;
18013 u32 sw_if_index = ~0;
18016 /* Parse args required to build the message */
18017 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18019 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18021 else if (unformat (i, "sw_if_index %d", &sw_if_index))
18023 else if (unformat (i, "ip6"))
18029 if (sw_if_index == ~0)
18031 errmsg ("missing interface name or sw_if_index");
18035 M (IP_NEIGHBOR_DUMP, mp);
18036 mp->is_ipv6 = (u8) is_ipv6;
18037 mp->sw_if_index = ntohl (sw_if_index);
18040 /* Use a control ping for synchronization */
18041 M (CONTROL_PING, mp_ping);
18048 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
18049 #define vl_api_ip6_fib_details_t_print vl_noop_handler
18052 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
18054 vat_main_t *vam = &vat_main;
18055 int count = ntohl (mp->count);
18056 vl_api_fib_path_t *fp;
18060 "table-id %d, prefix %U/%d",
18061 ntohl (mp->table_id), format_ip6_address, mp->address,
18062 mp->address_length);
18064 for (i = 0; i < count; i++)
18066 if (fp->afi == IP46_TYPE_IP6)
18068 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18069 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18070 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18071 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18072 format_ip6_address, fp->next_hop);
18073 else if (fp->afi == IP46_TYPE_IP4)
18075 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
18076 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
18077 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
18078 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
18079 format_ip4_address, fp->next_hop);
18084 static void vl_api_ip6_fib_details_t_handler_json
18085 (vl_api_ip6_fib_details_t * mp)
18087 vat_main_t *vam = &vat_main;
18088 int count = ntohl (mp->count);
18089 vat_json_node_t *node = NULL;
18090 struct in_addr ip4;
18091 struct in6_addr ip6;
18092 vl_api_fib_path_t *fp;
18095 if (VAT_JSON_ARRAY != vam->json_tree.type)
18097 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18098 vat_json_init_array (&vam->json_tree);
18100 node = vat_json_array_add (&vam->json_tree);
18102 vat_json_init_object (node);
18103 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
18104 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
18105 vat_json_object_add_ip6 (node, "prefix", ip6);
18106 vat_json_object_add_uint (node, "mask_length", mp->address_length);
18107 vat_json_object_add_uint (node, "path_count", count);
18109 for (i = 0; i < count; i++)
18111 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
18112 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
18113 vat_json_object_add_uint (node, "is_local", fp->is_local);
18114 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
18115 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
18116 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
18117 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
18118 if (fp->afi == IP46_TYPE_IP4)
18120 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
18121 vat_json_object_add_ip4 (node, "next_hop", ip4);
18123 else if (fp->afi == IP46_TYPE_IP6)
18125 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
18126 vat_json_object_add_ip6 (node, "next_hop", ip6);
18132 api_ip6_fib_dump (vat_main_t * vam)
18134 vl_api_ip6_fib_dump_t *mp;
18135 vl_api_control_ping_t *mp_ping;
18138 M (IP6_FIB_DUMP, mp);
18141 /* Use a control ping for synchronization */
18142 M (CONTROL_PING, mp_ping);
18150 api_ip6_mfib_dump (vat_main_t * vam)
18152 vl_api_ip6_mfib_dump_t *mp;
18153 vl_api_control_ping_t *mp_ping;
18156 M (IP6_MFIB_DUMP, mp);
18159 /* Use a control ping for synchronization */
18160 M (CONTROL_PING, mp_ping);
18168 api_classify_table_ids (vat_main_t * vam)
18170 vl_api_classify_table_ids_t *mp;
18173 /* Construct the API message */
18174 M (CLASSIFY_TABLE_IDS, mp);
18183 api_classify_table_by_interface (vat_main_t * vam)
18185 unformat_input_t *input = vam->input;
18186 vl_api_classify_table_by_interface_t *mp;
18188 u32 sw_if_index = ~0;
18190 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18192 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18194 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18199 if (sw_if_index == ~0)
18201 errmsg ("missing interface name or sw_if_index");
18205 /* Construct the API message */
18206 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
18208 mp->sw_if_index = ntohl (sw_if_index);
18216 api_classify_table_info (vat_main_t * vam)
18218 unformat_input_t *input = vam->input;
18219 vl_api_classify_table_info_t *mp;
18223 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18225 if (unformat (input, "table_id %d", &table_id))
18230 if (table_id == ~0)
18232 errmsg ("missing table id");
18236 /* Construct the API message */
18237 M (CLASSIFY_TABLE_INFO, mp);
18239 mp->table_id = ntohl (table_id);
18247 api_classify_session_dump (vat_main_t * vam)
18249 unformat_input_t *input = vam->input;
18250 vl_api_classify_session_dump_t *mp;
18251 vl_api_control_ping_t *mp_ping;
18255 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18257 if (unformat (input, "table_id %d", &table_id))
18262 if (table_id == ~0)
18264 errmsg ("missing table id");
18268 /* Construct the API message */
18269 M (CLASSIFY_SESSION_DUMP, mp);
18271 mp->table_id = ntohl (table_id);
18274 /* Use a control ping for synchronization */
18275 M (CONTROL_PING, mp_ping);
18283 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
18285 vat_main_t *vam = &vat_main;
18287 print (vam->ofp, "collector_address %U, collector_port %d, "
18288 "src_address %U, vrf_id %d, path_mtu %u, "
18289 "template_interval %u, udp_checksum %d",
18290 format_ip4_address, mp->collector_address,
18291 ntohs (mp->collector_port),
18292 format_ip4_address, mp->src_address,
18293 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
18294 ntohl (mp->template_interval), mp->udp_checksum);
18297 vam->result_ready = 1;
18301 vl_api_ipfix_exporter_details_t_handler_json
18302 (vl_api_ipfix_exporter_details_t * mp)
18304 vat_main_t *vam = &vat_main;
18305 vat_json_node_t node;
18306 struct in_addr collector_address;
18307 struct in_addr src_address;
18309 vat_json_init_object (&node);
18310 clib_memcpy (&collector_address, &mp->collector_address,
18311 sizeof (collector_address));
18312 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
18313 vat_json_object_add_uint (&node, "collector_port",
18314 ntohs (mp->collector_port));
18315 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
18316 vat_json_object_add_ip4 (&node, "src_address", src_address);
18317 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
18318 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
18319 vat_json_object_add_uint (&node, "template_interval",
18320 ntohl (mp->template_interval));
18321 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
18323 vat_json_print (vam->ofp, &node);
18324 vat_json_free (&node);
18326 vam->result_ready = 1;
18330 api_ipfix_exporter_dump (vat_main_t * vam)
18332 vl_api_ipfix_exporter_dump_t *mp;
18335 /* Construct the API message */
18336 M (IPFIX_EXPORTER_DUMP, mp);
18345 api_ipfix_classify_stream_dump (vat_main_t * vam)
18347 vl_api_ipfix_classify_stream_dump_t *mp;
18350 /* Construct the API message */
18351 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
18362 vl_api_ipfix_classify_stream_details_t_handler
18363 (vl_api_ipfix_classify_stream_details_t * mp)
18365 vat_main_t *vam = &vat_main;
18366 print (vam->ofp, "domain_id %d, src_port %d",
18367 ntohl (mp->domain_id), ntohs (mp->src_port));
18369 vam->result_ready = 1;
18373 vl_api_ipfix_classify_stream_details_t_handler_json
18374 (vl_api_ipfix_classify_stream_details_t * mp)
18376 vat_main_t *vam = &vat_main;
18377 vat_json_node_t node;
18379 vat_json_init_object (&node);
18380 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
18381 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
18383 vat_json_print (vam->ofp, &node);
18384 vat_json_free (&node);
18386 vam->result_ready = 1;
18390 api_ipfix_classify_table_dump (vat_main_t * vam)
18392 vl_api_ipfix_classify_table_dump_t *mp;
18393 vl_api_control_ping_t *mp_ping;
18396 if (!vam->json_output)
18398 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
18399 "transport_protocol");
18402 /* Construct the API message */
18403 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
18408 /* Use a control ping for synchronization */
18409 M (CONTROL_PING, mp_ping);
18417 vl_api_ipfix_classify_table_details_t_handler
18418 (vl_api_ipfix_classify_table_details_t * mp)
18420 vat_main_t *vam = &vat_main;
18421 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
18422 mp->transport_protocol);
18426 vl_api_ipfix_classify_table_details_t_handler_json
18427 (vl_api_ipfix_classify_table_details_t * mp)
18429 vat_json_node_t *node = NULL;
18430 vat_main_t *vam = &vat_main;
18432 if (VAT_JSON_ARRAY != vam->json_tree.type)
18434 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18435 vat_json_init_array (&vam->json_tree);
18438 node = vat_json_array_add (&vam->json_tree);
18439 vat_json_init_object (node);
18441 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
18442 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
18443 vat_json_object_add_uint (node, "transport_protocol",
18444 mp->transport_protocol);
18448 api_sw_interface_span_enable_disable (vat_main_t * vam)
18450 unformat_input_t *i = vam->input;
18451 vl_api_sw_interface_span_enable_disable_t *mp;
18452 u32 src_sw_if_index = ~0;
18453 u32 dst_sw_if_index = ~0;
18458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18461 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
18463 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
18467 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
18469 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
18471 else if (unformat (i, "disable"))
18473 else if (unformat (i, "rx"))
18475 else if (unformat (i, "tx"))
18477 else if (unformat (i, "both"))
18479 else if (unformat (i, "l2"))
18485 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
18487 mp->sw_if_index_from = htonl (src_sw_if_index);
18488 mp->sw_if_index_to = htonl (dst_sw_if_index);
18498 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
18501 vat_main_t *vam = &vat_main;
18502 u8 *sw_if_from_name = 0;
18503 u8 *sw_if_to_name = 0;
18504 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18505 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18506 char *states[] = { "none", "rx", "tx", "both" };
18510 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18512 if ((u32) p->value[0] == sw_if_index_from)
18514 sw_if_from_name = (u8 *)(p->key);
18518 if ((u32) p->value[0] == sw_if_index_to)
18520 sw_if_to_name = (u8 *)(p->key);
18521 if (sw_if_from_name)
18526 print (vam->ofp, "%20s => %20s (%s)",
18527 sw_if_from_name, sw_if_to_name, states[mp->state]);
18531 vl_api_sw_interface_span_details_t_handler_json
18532 (vl_api_sw_interface_span_details_t * mp)
18534 vat_main_t *vam = &vat_main;
18535 vat_json_node_t *node = NULL;
18536 u8 *sw_if_from_name = 0;
18537 u8 *sw_if_to_name = 0;
18538 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
18539 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
18543 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
18545 if ((u32) p->value[0] == sw_if_index_from)
18547 sw_if_from_name = (u8 *)(p->key);
18551 if ((u32) p->value[0] == sw_if_index_to)
18553 sw_if_to_name = (u8 *)(p->key);
18554 if (sw_if_from_name)
18560 if (VAT_JSON_ARRAY != vam->json_tree.type)
18562 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
18563 vat_json_init_array (&vam->json_tree);
18565 node = vat_json_array_add (&vam->json_tree);
18567 vat_json_init_object (node);
18568 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
18569 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
18570 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
18571 if (0 != sw_if_to_name)
18573 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
18575 vat_json_object_add_uint (node, "state", mp->state);
18579 api_sw_interface_span_dump (vat_main_t * vam)
18581 unformat_input_t *input = vam->input;
18582 vl_api_sw_interface_span_dump_t *mp;
18583 vl_api_control_ping_t *mp_ping;
18587 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18589 if (unformat (input, "l2"))
18595 M (SW_INTERFACE_SPAN_DUMP, mp);
18599 /* Use a control ping for synchronization */
18600 M (CONTROL_PING, mp_ping);
18608 api_pg_create_interface (vat_main_t * vam)
18610 unformat_input_t *input = vam->input;
18611 vl_api_pg_create_interface_t *mp;
18615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18617 if (unformat (input, "if_id %d", &if_id))
18624 errmsg ("missing pg interface index");
18628 /* Construct the API message */
18629 M (PG_CREATE_INTERFACE, mp);
18631 mp->interface_id = ntohl (if_id);
18639 api_pg_capture (vat_main_t * vam)
18641 unformat_input_t *input = vam->input;
18642 vl_api_pg_capture_t *mp;
18647 u8 pcap_file_set = 0;
18650 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18652 if (unformat (input, "if_id %d", &if_id))
18654 else if (unformat (input, "pcap %s", &pcap_file))
18656 else if (unformat (input, "count %d", &count))
18658 else if (unformat (input, "disable"))
18665 errmsg ("missing pg interface index");
18668 if (pcap_file_set > 0)
18670 if (vec_len (pcap_file) > 255)
18672 errmsg ("pcap file name is too long");
18677 u32 name_len = vec_len (pcap_file);
18678 /* Construct the API message */
18679 M (PG_CAPTURE, mp);
18681 mp->interface_id = ntohl (if_id);
18682 mp->is_enabled = enable;
18683 mp->count = ntohl (count);
18684 mp->pcap_name_length = ntohl (name_len);
18685 if (pcap_file_set != 0)
18687 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
18689 vec_free (pcap_file);
18697 api_pg_enable_disable (vat_main_t * vam)
18699 unformat_input_t *input = vam->input;
18700 vl_api_pg_enable_disable_t *mp;
18703 u8 stream_name_set = 0;
18704 u8 *stream_name = 0;
18706 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18708 if (unformat (input, "stream %s", &stream_name))
18709 stream_name_set = 1;
18710 else if (unformat (input, "disable"))
18716 if (stream_name_set > 0)
18718 if (vec_len (stream_name) > 255)
18720 errmsg ("stream name too long");
18725 u32 name_len = vec_len (stream_name);
18726 /* Construct the API message */
18727 M (PG_ENABLE_DISABLE, mp);
18729 mp->is_enabled = enable;
18730 if (stream_name_set != 0)
18732 mp->stream_name_length = ntohl (name_len);
18733 clib_memcpy (mp->stream_name, stream_name, name_len);
18735 vec_free (stream_name);
18743 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
18745 unformat_input_t *input = vam->input;
18746 vl_api_ip_source_and_port_range_check_add_del_t *mp;
18748 u16 *low_ports = 0;
18749 u16 *high_ports = 0;
18752 ip4_address_t ip4_addr;
18753 ip6_address_t ip6_addr;
18762 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18764 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
18770 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
18775 else if (unformat (input, "vrf %d", &vrf_id))
18777 else if (unformat (input, "del"))
18779 else if (unformat (input, "port %d", &tmp))
18781 if (tmp == 0 || tmp > 65535)
18783 errmsg ("port %d out of range", tmp);
18787 this_hi = this_low + 1;
18788 vec_add1 (low_ports, this_low);
18789 vec_add1 (high_ports, this_hi);
18791 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
18793 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
18795 errmsg ("incorrect range parameters");
18799 /* Note: in debug CLI +1 is added to high before
18800 passing to real fn that does "the work"
18801 (ip_source_and_port_range_check_add_del).
18802 This fn is a wrapper around the binary API fn a
18803 control plane will call, which expects this increment
18804 to have occurred. Hence letting the binary API control
18805 plane fn do the increment for consistency between VAT
18806 and other control planes.
18809 vec_add1 (low_ports, this_low);
18810 vec_add1 (high_ports, this_hi);
18816 if (prefix_set == 0)
18818 errmsg ("<address>/<mask> not specified");
18824 errmsg ("VRF ID required, not specified");
18831 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18835 if (vec_len (low_ports) == 0)
18837 errmsg ("At least one port or port range required");
18841 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
18843 mp->is_add = is_add;
18848 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
18853 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
18856 mp->mask_length = length;
18857 mp->number_of_ranges = vec_len (low_ports);
18859 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
18860 vec_free (low_ports);
18862 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
18863 vec_free (high_ports);
18865 mp->vrf_id = ntohl (vrf_id);
18873 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
18875 unformat_input_t *input = vam->input;
18876 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
18877 u32 sw_if_index = ~0;
18879 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
18880 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
18884 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
18886 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
18888 else if (unformat (input, "sw_if_index %d", &sw_if_index))
18890 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
18892 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
18894 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
18896 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
18898 else if (unformat (input, "del"))
18904 if (sw_if_index == ~0)
18906 errmsg ("Interface required but not specified");
18912 errmsg ("VRF ID required but not specified");
18916 if (tcp_out_vrf_id == 0
18917 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
18920 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
18924 /* Construct the API message */
18925 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
18927 mp->sw_if_index = ntohl (sw_if_index);
18928 mp->is_add = is_add;
18929 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
18930 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
18931 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
18932 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
18937 /* Wait for a reply... */
18943 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
18945 unformat_input_t *i = vam->input;
18946 vl_api_ipsec_gre_add_del_tunnel_t *mp;
18947 u32 local_sa_id = 0;
18948 u32 remote_sa_id = 0;
18949 ip4_address_t src_address;
18950 ip4_address_t dst_address;
18954 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18956 if (unformat (i, "local_sa %d", &local_sa_id))
18958 else if (unformat (i, "remote_sa %d", &remote_sa_id))
18960 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
18962 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
18964 else if (unformat (i, "del"))
18968 clib_warning ("parse error '%U'", format_unformat_error, i);
18973 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
18975 mp->local_sa_id = ntohl (local_sa_id);
18976 mp->remote_sa_id = ntohl (remote_sa_id);
18977 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
18978 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
18979 mp->is_add = is_add;
18987 api_punt (vat_main_t * vam)
18989 unformat_input_t *i = vam->input;
18997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
18999 if (unformat (i, "ip %d", &ipv))
19001 else if (unformat (i, "protocol %d", &protocol))
19003 else if (unformat (i, "port %d", &port))
19005 else if (unformat (i, "del"))
19009 clib_warning ("parse error '%U'", format_unformat_error, i);
19016 mp->is_add = (u8) is_add;
19017 mp->ipv = (u8) ipv;
19018 mp->l4_protocol = (u8) protocol;
19019 mp->l4_port = htons ((u16) port);
19026 static void vl_api_ipsec_gre_tunnel_details_t_handler
19027 (vl_api_ipsec_gre_tunnel_details_t * mp)
19029 vat_main_t *vam = &vat_main;
19031 print (vam->ofp, "%11d%15U%15U%14d%14d",
19032 ntohl (mp->sw_if_index),
19033 format_ip4_address, &mp->src_address,
19034 format_ip4_address, &mp->dst_address,
19035 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
19038 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
19039 (vl_api_ipsec_gre_tunnel_details_t * mp)
19041 vat_main_t *vam = &vat_main;
19042 vat_json_node_t *node = NULL;
19043 struct in_addr ip4;
19045 if (VAT_JSON_ARRAY != vam->json_tree.type)
19047 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19048 vat_json_init_array (&vam->json_tree);
19050 node = vat_json_array_add (&vam->json_tree);
19052 vat_json_init_object (node);
19053 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
19054 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
19055 vat_json_object_add_ip4 (node, "src_address", ip4);
19056 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
19057 vat_json_object_add_ip4 (node, "dst_address", ip4);
19058 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
19059 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
19063 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
19065 unformat_input_t *i = vam->input;
19066 vl_api_ipsec_gre_tunnel_dump_t *mp;
19067 vl_api_control_ping_t *mp_ping;
19069 u8 sw_if_index_set = 0;
19072 /* Parse args required to build the message */
19073 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19075 if (unformat (i, "sw_if_index %d", &sw_if_index))
19076 sw_if_index_set = 1;
19081 if (sw_if_index_set == 0)
19086 if (!vam->json_output)
19088 print (vam->ofp, "%11s%15s%15s%14s%14s",
19089 "sw_if_index", "src_address", "dst_address",
19090 "local_sa_id", "remote_sa_id");
19093 /* Get list of gre-tunnel interfaces */
19094 M (IPSEC_GRE_TUNNEL_DUMP, mp);
19096 mp->sw_if_index = htonl (sw_if_index);
19100 /* Use a control ping for synchronization */
19101 M (CONTROL_PING, mp_ping);
19109 api_delete_subif (vat_main_t * vam)
19111 unformat_input_t *i = vam->input;
19112 vl_api_delete_subif_t *mp;
19113 u32 sw_if_index = ~0;
19116 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19118 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19120 if (unformat (i, "sw_if_index %d", &sw_if_index))
19126 if (sw_if_index == ~0)
19128 errmsg ("missing sw_if_index");
19132 /* Construct the API message */
19133 M (DELETE_SUBIF, mp);
19134 mp->sw_if_index = ntohl (sw_if_index);
19141 #define foreach_pbb_vtr_op \
19142 _("disable", L2_VTR_DISABLED) \
19143 _("pop", L2_VTR_POP_2) \
19144 _("push", L2_VTR_PUSH_2)
19147 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
19149 unformat_input_t *i = vam->input;
19150 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
19151 u32 sw_if_index = ~0, vtr_op = ~0;
19152 u16 outer_tag = ~0;
19153 u8 dmac[6], smac[6];
19154 u8 dmac_set = 0, smac_set = 0;
19160 /* Shut up coverity */
19161 memset (dmac, 0, sizeof (dmac));
19162 memset (smac, 0, sizeof (smac));
19164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19166 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19168 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19170 else if (unformat (i, "vtr_op %d", &vtr_op))
19172 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
19175 else if (unformat (i, "translate_pbb_stag"))
19177 if (unformat (i, "%d", &tmp))
19179 vtr_op = L2_VTR_TRANSLATE_2_1;
19185 ("translate_pbb_stag operation requires outer tag definition");
19189 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
19191 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
19193 else if (unformat (i, "sid %d", &sid))
19195 else if (unformat (i, "vlanid %d", &tmp))
19199 clib_warning ("parse error '%U'", format_unformat_error, i);
19204 if ((sw_if_index == ~0) || (vtr_op == ~0))
19206 errmsg ("missing sw_if_index or vtr operation");
19209 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
19210 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
19213 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
19217 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
19218 mp->sw_if_index = ntohl (sw_if_index);
19219 mp->vtr_op = ntohl (vtr_op);
19220 mp->outer_tag = ntohs (outer_tag);
19221 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
19222 clib_memcpy (mp->b_smac, smac, sizeof (smac));
19223 mp->b_vlanid = ntohs (vlanid);
19224 mp->i_sid = ntohl (sid);
19232 api_flow_classify_set_interface (vat_main_t * vam)
19234 unformat_input_t *i = vam->input;
19235 vl_api_flow_classify_set_interface_t *mp;
19237 int sw_if_index_set;
19238 u32 ip4_table_index = ~0;
19239 u32 ip6_table_index = ~0;
19243 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19245 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19246 sw_if_index_set = 1;
19247 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19248 sw_if_index_set = 1;
19249 else if (unformat (i, "del"))
19251 else if (unformat (i, "ip4-table %d", &ip4_table_index))
19253 else if (unformat (i, "ip6-table %d", &ip6_table_index))
19257 clib_warning ("parse error '%U'", format_unformat_error, i);
19262 if (sw_if_index_set == 0)
19264 errmsg ("missing interface name or sw_if_index");
19268 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
19270 mp->sw_if_index = ntohl (sw_if_index);
19271 mp->ip4_table_index = ntohl (ip4_table_index);
19272 mp->ip6_table_index = ntohl (ip6_table_index);
19273 mp->is_add = is_add;
19281 api_flow_classify_dump (vat_main_t * vam)
19283 unformat_input_t *i = vam->input;
19284 vl_api_flow_classify_dump_t *mp;
19285 vl_api_control_ping_t *mp_ping;
19286 u8 type = FLOW_CLASSIFY_N_TABLES;
19289 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
19293 errmsg ("classify table type must be specified");
19297 if (!vam->json_output)
19299 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
19302 M (FLOW_CLASSIFY_DUMP, mp);
19307 /* Use a control ping for synchronization */
19308 M (CONTROL_PING, mp_ping);
19311 /* Wait for a reply... */
19317 api_feature_enable_disable (vat_main_t * vam)
19319 unformat_input_t *i = vam->input;
19320 vl_api_feature_enable_disable_t *mp;
19322 u8 *feature_name = 0;
19323 u32 sw_if_index = ~0;
19327 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19329 if (unformat (i, "arc_name %s", &arc_name))
19331 else if (unformat (i, "feature_name %s", &feature_name))
19334 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19336 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19338 else if (unformat (i, "disable"))
19346 errmsg ("missing arc name");
19349 if (vec_len (arc_name) > 63)
19351 errmsg ("arc name too long");
19354 if (feature_name == 0)
19356 errmsg ("missing feature name");
19359 if (vec_len (feature_name) > 63)
19361 errmsg ("feature name too long");
19364 if (sw_if_index == ~0)
19366 errmsg ("missing interface name or sw_if_index");
19370 /* Construct the API message */
19371 M (FEATURE_ENABLE_DISABLE, mp);
19372 mp->sw_if_index = ntohl (sw_if_index);
19373 mp->enable = enable;
19374 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
19375 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
19376 vec_free (arc_name);
19377 vec_free (feature_name);
19385 api_sw_interface_tag_add_del (vat_main_t * vam)
19387 unformat_input_t *i = vam->input;
19388 vl_api_sw_interface_tag_add_del_t *mp;
19389 u32 sw_if_index = ~0;
19394 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19396 if (unformat (i, "tag %s", &tag))
19398 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19400 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19402 else if (unformat (i, "del"))
19408 if (sw_if_index == ~0)
19410 errmsg ("missing interface name or sw_if_index");
19414 if (enable && (tag == 0))
19416 errmsg ("no tag specified");
19420 /* Construct the API message */
19421 M (SW_INTERFACE_TAG_ADD_DEL, mp);
19422 mp->sw_if_index = ntohl (sw_if_index);
19423 mp->is_add = enable;
19425 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
19433 static void vl_api_l2_xconnect_details_t_handler
19434 (vl_api_l2_xconnect_details_t * mp)
19436 vat_main_t *vam = &vat_main;
19438 print (vam->ofp, "%15d%15d",
19439 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
19442 static void vl_api_l2_xconnect_details_t_handler_json
19443 (vl_api_l2_xconnect_details_t * mp)
19445 vat_main_t *vam = &vat_main;
19446 vat_json_node_t *node = NULL;
19448 if (VAT_JSON_ARRAY != vam->json_tree.type)
19450 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
19451 vat_json_init_array (&vam->json_tree);
19453 node = vat_json_array_add (&vam->json_tree);
19455 vat_json_init_object (node);
19456 vat_json_object_add_uint (node, "rx_sw_if_index",
19457 ntohl (mp->rx_sw_if_index));
19458 vat_json_object_add_uint (node, "tx_sw_if_index",
19459 ntohl (mp->tx_sw_if_index));
19463 api_l2_xconnect_dump (vat_main_t * vam)
19465 vl_api_l2_xconnect_dump_t *mp;
19466 vl_api_control_ping_t *mp_ping;
19469 if (!vam->json_output)
19471 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
19474 M (L2_XCONNECT_DUMP, mp);
19478 /* Use a control ping for synchronization */
19479 M (CONTROL_PING, mp_ping);
19487 api_sw_interface_set_mtu (vat_main_t * vam)
19489 unformat_input_t *i = vam->input;
19490 vl_api_sw_interface_set_mtu_t *mp;
19491 u32 sw_if_index = ~0;
19495 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19497 if (unformat (i, "mtu %d", &mtu))
19499 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19501 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19507 if (sw_if_index == ~0)
19509 errmsg ("missing interface name or sw_if_index");
19515 errmsg ("no mtu specified");
19519 /* Construct the API message */
19520 M (SW_INTERFACE_SET_MTU, mp);
19521 mp->sw_if_index = ntohl (sw_if_index);
19522 mp->mtu = ntohs ((u16) mtu);
19530 api_p2p_ethernet_add (vat_main_t * vam)
19532 unformat_input_t *i = vam->input;
19533 vl_api_p2p_ethernet_add_t *mp;
19534 u32 parent_if_index = ~0;
19540 memset (remote_mac, 0, sizeof (remote_mac));
19541 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19543 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19545 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19549 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19551 else if (unformat (i, "sub_id %d", &sub_id))
19555 clib_warning ("parse error '%U'", format_unformat_error, i);
19560 if (parent_if_index == ~0)
19562 errmsg ("missing interface name or sw_if_index");
19567 errmsg ("missing remote mac address");
19572 errmsg ("missing sub-interface id");
19576 M (P2P_ETHERNET_ADD, mp);
19577 mp->parent_if_index = ntohl (parent_if_index);
19578 mp->subif_id = ntohl (sub_id);
19579 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19587 api_p2p_ethernet_del (vat_main_t * vam)
19589 unformat_input_t *i = vam->input;
19590 vl_api_p2p_ethernet_del_t *mp;
19591 u32 parent_if_index = ~0;
19596 memset (remote_mac, 0, sizeof (remote_mac));
19597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19599 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &parent_if_index))
19601 else if (unformat (i, "sw_if_index %d", &parent_if_index))
19605 (i, "remote_mac %U", unformat_ethernet_address, remote_mac))
19609 clib_warning ("parse error '%U'", format_unformat_error, i);
19614 if (parent_if_index == ~0)
19616 errmsg ("missing interface name or sw_if_index");
19621 errmsg ("missing remote mac address");
19625 M (P2P_ETHERNET_DEL, mp);
19626 mp->parent_if_index = ntohl (parent_if_index);
19627 clib_memcpy (mp->remote_mac, remote_mac, sizeof (remote_mac));
19635 api_lldp_config (vat_main_t * vam)
19637 unformat_input_t *i = vam->input;
19638 vl_api_lldp_config_t *mp;
19640 int tx_interval = 0;
19641 u8 *sys_name = NULL;
19644 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19646 if (unformat (i, "system-name %s", &sys_name))
19648 else if (unformat (i, "tx-hold %d", &tx_hold))
19650 else if (unformat (i, "tx-interval %d", &tx_interval))
19654 clib_warning ("parse error '%U'", format_unformat_error, i);
19659 vec_add1 (sys_name, 0);
19661 M (LLDP_CONFIG, mp);
19662 mp->tx_hold = htonl (tx_hold);
19663 mp->tx_interval = htonl (tx_interval);
19664 clib_memcpy (mp->system_name, sys_name, vec_len (sys_name));
19665 vec_free (sys_name);
19673 api_sw_interface_set_lldp (vat_main_t * vam)
19675 unformat_input_t *i = vam->input;
19676 vl_api_sw_interface_set_lldp_t *mp;
19677 u32 sw_if_index = ~0;
19679 u8 *port_desc = NULL;
19682 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19684 if (unformat (i, "disable"))
19687 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
19689 else if (unformat (i, "sw_if_index %d", &sw_if_index))
19691 else if (unformat (i, "port-desc %s", &port_desc))
19697 if (sw_if_index == ~0)
19699 errmsg ("missing interface name or sw_if_index");
19703 /* Construct the API message */
19704 vec_add1 (port_desc, 0);
19705 M (SW_INTERFACE_SET_LLDP, mp);
19706 mp->sw_if_index = ntohl (sw_if_index);
19707 mp->enable = enable;
19708 clib_memcpy (mp->port_desc, port_desc, vec_len (port_desc));
19709 vec_free (port_desc);
19717 api_tcp_configure_src_addresses (vat_main_t * vam)
19719 vl_api_tcp_configure_src_addresses_t *mp;
19720 unformat_input_t *i = vam->input;
19721 ip4_address_t v4first, v4last;
19722 ip6_address_t v6first, v6last;
19727 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
19729 if (unformat (i, "%U - %U",
19730 unformat_ip4_address, &v4first,
19731 unformat_ip4_address, &v4last))
19735 errmsg ("one range per message (range already set)");
19740 else if (unformat (i, "%U - %U",
19741 unformat_ip6_address, &v6first,
19742 unformat_ip6_address, &v6last))
19746 errmsg ("one range per message (range already set)");
19751 else if (unformat (i, "vrf %d", &vrf_id))
19757 if (range_set == 0)
19759 errmsg ("address range not set");
19763 M (TCP_CONFIGURE_SRC_ADDRESSES, mp);
19764 mp->vrf_id = ntohl (vrf_id);
19766 if (range_set == 2)
19769 clib_memcpy (mp->first_address, &v6first, sizeof (v6first));
19770 clib_memcpy (mp->last_address, &v6last, sizeof (v6last));
19775 clib_memcpy (mp->first_address, &v4first, sizeof (v4first));
19776 clib_memcpy (mp->last_address, &v4last, sizeof (v4last));
19784 q_or_quit (vat_main_t * vam)
19786 #if VPP_API_TEST_BUILTIN == 0
19787 longjmp (vam->jump_buf, 1);
19789 return 0; /* not so much */
19793 q (vat_main_t * vam)
19795 return q_or_quit (vam);
19799 quit (vat_main_t * vam)
19801 return q_or_quit (vam);
19805 comment (vat_main_t * vam)
19811 cmd_cmp (void *a1, void *a2)
19816 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
19820 help (vat_main_t * vam)
19825 unformat_input_t *i = vam->input;
19828 if (unformat (i, "%s", &name))
19832 vec_add1 (name, 0);
19834 hs = hash_get_mem (vam->help_by_name, name);
19836 print (vam->ofp, "usage: %s %s", name, hs[0]);
19838 print (vam->ofp, "No such msg / command '%s'", name);
19843 print (vam->ofp, "Help is available for the following:");
19846 hash_foreach_pair (p, vam->function_by_name,
19848 vec_add1 (cmds, (u8 *)(p->key));
19852 vec_sort_with_function (cmds, cmd_cmp);
19854 for (j = 0; j < vec_len (cmds); j++)
19855 print (vam->ofp, "%s", cmds[j]);
19862 set (vat_main_t * vam)
19864 u8 *name = 0, *value = 0;
19865 unformat_input_t *i = vam->input;
19867 if (unformat (i, "%s", &name))
19869 /* The input buffer is a vector, not a string. */
19870 value = vec_dup (i->buffer);
19871 vec_delete (value, i->index, 0);
19872 /* Almost certainly has a trailing newline */
19873 if (value[vec_len (value) - 1] == '\n')
19874 value[vec_len (value) - 1] = 0;
19875 /* Make sure it's a proper string, one way or the other */
19876 vec_add1 (value, 0);
19877 (void) clib_macro_set_value (&vam->macro_main,
19878 (char *) name, (char *) value);
19881 errmsg ("usage: set <name> <value>");
19889 unset (vat_main_t * vam)
19893 if (unformat (vam->input, "%s", &name))
19894 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
19895 errmsg ("unset: %s wasn't set", name);
19908 macro_sort_cmp (void *a1, void *a2)
19910 macro_sort_t *s1 = a1;
19911 macro_sort_t *s2 = a2;
19913 return strcmp ((char *) (s1->name), (char *) (s2->name));
19917 dump_macro_table (vat_main_t * vam)
19919 macro_sort_t *sort_me = 0, *sm;
19924 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
19926 vec_add2 (sort_me, sm, 1);
19927 sm->name = (u8 *)(p->key);
19928 sm->value = (u8 *) (p->value[0]);
19932 vec_sort_with_function (sort_me, macro_sort_cmp);
19934 if (vec_len (sort_me))
19935 print (vam->ofp, "%-15s%s", "Name", "Value");
19937 print (vam->ofp, "The macro table is empty...");
19939 for (i = 0; i < vec_len (sort_me); i++)
19940 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
19945 dump_node_table (vat_main_t * vam)
19948 vlib_node_t *node, *next_node;
19950 if (vec_len (vam->graph_nodes) == 0)
19952 print (vam->ofp, "Node table empty, issue get_node_graph...");
19956 for (i = 0; i < vec_len (vam->graph_nodes); i++)
19958 node = vam->graph_nodes[i];
19959 print (vam->ofp, "[%d] %s", i, node->name);
19960 for (j = 0; j < vec_len (node->next_nodes); j++)
19962 if (node->next_nodes[j] != ~0)
19964 next_node = vam->graph_nodes[node->next_nodes[j]];
19965 print (vam->ofp, " [%d] %s", j, next_node->name);
19973 value_sort_cmp (void *a1, void *a2)
19975 name_sort_t *n1 = a1;
19976 name_sort_t *n2 = a2;
19978 if (n1->value < n2->value)
19980 if (n1->value > n2->value)
19987 dump_msg_api_table (vat_main_t * vam)
19989 api_main_t *am = &api_main;
19990 name_sort_t *nses = 0, *ns;
19995 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
19997 vec_add2 (nses, ns, 1);
19998 ns->name = (u8 *)(hp->key);
19999 ns->value = (u32) hp->value[0];
20003 vec_sort_with_function (nses, value_sort_cmp);
20005 for (i = 0; i < vec_len (nses); i++)
20006 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
20012 get_msg_id (vat_main_t * vam)
20017 if (unformat (vam->input, "%s", &name_and_crc))
20019 message_index = vl_api_get_msg_index (name_and_crc);
20020 if (message_index == ~0)
20022 print (vam->ofp, " '%s' not found", name_and_crc);
20025 print (vam->ofp, " '%s' has message index %d",
20026 name_and_crc, message_index);
20029 errmsg ("name_and_crc required...");
20034 search_node_table (vat_main_t * vam)
20036 unformat_input_t *line_input = vam->input;
20039 vlib_node_t *node, *next_node;
20042 if (vam->graph_node_index_by_name == 0)
20044 print (vam->ofp, "Node table empty, issue get_node_graph...");
20048 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
20050 if (unformat (line_input, "%s", &node_to_find))
20052 vec_add1 (node_to_find, 0);
20053 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
20056 print (vam->ofp, "%s not found...", node_to_find);
20059 node = vam->graph_nodes[p[0]];
20060 print (vam->ofp, "[%d] %s", p[0], node->name);
20061 for (j = 0; j < vec_len (node->next_nodes); j++)
20063 if (node->next_nodes[j] != ~0)
20065 next_node = vam->graph_nodes[node->next_nodes[j]];
20066 print (vam->ofp, " [%d] %s", j, next_node->name);
20073 clib_warning ("parse error '%U'", format_unformat_error,
20079 vec_free (node_to_find);
20088 script (vat_main_t * vam)
20090 #if (VPP_API_TEST_BUILTIN==0)
20092 char *save_current_file;
20093 unformat_input_t save_input;
20094 jmp_buf save_jump_buf;
20095 u32 save_line_number;
20097 FILE *new_fp, *save_ifp;
20099 if (unformat (vam->input, "%s", &s))
20101 new_fp = fopen ((char *) s, "r");
20104 errmsg ("Couldn't open script file %s", s);
20111 errmsg ("Missing script name");
20115 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
20116 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
20117 save_ifp = vam->ifp;
20118 save_line_number = vam->input_line_number;
20119 save_current_file = (char *) vam->current_file;
20121 vam->input_line_number = 0;
20123 vam->current_file = s;
20126 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
20127 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
20128 vam->ifp = save_ifp;
20129 vam->input_line_number = save_line_number;
20130 vam->current_file = (u8 *) save_current_file;
20135 clib_warning ("use the exec command...");
20141 echo (vat_main_t * vam)
20143 print (vam->ofp, "%v", vam->input->buffer);
20147 /* List of API message constructors, CLI names map to api_xxx */
20148 #define foreach_vpe_api_msg \
20149 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
20150 _(sw_interface_dump,"") \
20151 _(sw_interface_set_flags, \
20152 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
20153 _(sw_interface_add_del_address, \
20154 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
20155 _(sw_interface_set_table, \
20156 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
20157 _(sw_interface_set_mpls_enable, \
20158 "<intfc> | sw_if_index [disable | dis]") \
20159 _(sw_interface_set_vpath, \
20160 "<intfc> | sw_if_index <id> enable | disable") \
20161 _(sw_interface_set_vxlan_bypass, \
20162 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
20163 _(sw_interface_set_l2_xconnect, \
20164 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20165 "enable | disable") \
20166 _(sw_interface_set_l2_bridge, \
20167 "{<intfc> | sw_if_index <id>} bd_id <bridge-domain-id>\n" \
20168 "[shg <split-horizon-group>] [bvi]\n" \
20169 "enable | disable") \
20170 _(bridge_domain_set_mac_age, "bd_id <bridge-domain-id> mac-age 0-255") \
20171 _(bridge_domain_add_del, \
20172 "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") \
20173 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
20175 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
20176 _(l2fib_flush_bd, "bd_id <bridge-domain-id>") \
20177 _(l2fib_flush_int, "<intfc> | sw_if_index <id>") \
20179 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20181 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
20183 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
20185 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
20187 "<vpp-if-name> | sw_if_index <id>") \
20188 _(sw_interface_tap_dump, "") \
20189 _(ip_table_add_del, \
20190 "table-id <n> [ipv6]\n") \
20191 _(ip_add_del_route, \
20192 "<addr>/<mask> via <addr> [table-id <n>]\n" \
20193 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20194 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20195 "[multipath] [count <n>]") \
20196 _(ip_mroute_add_del, \
20197 "<src> <grp>/<mask> [table-id <n>]\n" \
20198 "[<intfc> | sw_if_index <id>] [local] [del]") \
20199 _(mpls_table_add_del, \
20200 "table-id <n>\n") \
20201 _(mpls_route_add_del, \
20202 "<label> <eos> via <addr> [table-id <n>]\n" \
20203 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
20204 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
20205 "[multipath] [count <n>]") \
20206 _(mpls_ip_bind_unbind, \
20207 "<label> <addr/len>") \
20208 _(mpls_tunnel_add_del, \
20209 " via <addr> [table-id <n>]\n" \
20210 "sw_if_index <id>] [l2] [del]") \
20211 _(proxy_arp_add_del, \
20212 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
20213 _(proxy_arp_intfc_enable_disable, \
20214 "<intfc> | sw_if_index <id> enable | disable") \
20215 _(sw_interface_set_unnumbered, \
20216 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
20217 _(ip_neighbor_add_del, \
20218 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
20219 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
20220 _(reset_vrf, "vrf <id> [ipv6]") \
20221 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
20222 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
20223 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
20224 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
20225 "[outer_vlan_id_any][inner_vlan_id_any]") \
20226 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
20227 _(reset_fib, "vrf <n> [ipv6]") \
20228 _(dhcp_proxy_config, \
20229 "svr <v46-address> src <v46-address>\n" \
20230 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
20231 _(dhcp_proxy_set_vss, \
20232 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
20233 _(dhcp_proxy_dump, "ip6") \
20234 _(dhcp_client_config, \
20235 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
20236 _(set_ip_flow_hash, \
20237 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
20238 _(sw_interface_ip6_enable_disable, \
20239 "<intfc> | sw_if_index <id> enable | disable") \
20240 _(sw_interface_ip6_set_link_local_address, \
20241 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
20242 _(ip6nd_proxy_add_del, \
20243 "<intfc> | sw_if_index <id> <ip6-address>") \
20244 _(ip6nd_proxy_dump, "") \
20245 _(sw_interface_ip6nd_ra_prefix, \
20246 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
20247 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
20248 "[nolink] [isno]") \
20249 _(sw_interface_ip6nd_ra_config, \
20250 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
20251 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
20252 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
20253 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
20254 _(l2_patch_add_del, \
20255 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
20256 "enable | disable") \
20257 _(sr_localsid_add_del, \
20258 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
20259 "fib-table <num> (end.psp) sw_if_index <num>") \
20260 _(classify_add_del_table, \
20261 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
20262 " [del] [del-chain] mask <mask-value>\n" \
20263 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
20264 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
20265 _(classify_add_del_session, \
20266 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
20267 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
20268 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
20269 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
20270 _(classify_set_interface_ip_table, \
20271 "<intfc> | sw_if_index <nn> table <nn>") \
20272 _(classify_set_interface_l2_tables, \
20273 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20274 " [other-table <nn>]") \
20275 _(get_node_index, "node <node-name") \
20276 _(add_node_next, "node <node-name> next <next-node-name>") \
20277 _(l2tpv3_create_tunnel, \
20278 "client_address <ip6-addr> our_address <ip6-addr>\n" \
20279 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
20280 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
20281 _(l2tpv3_set_tunnel_cookies, \
20282 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
20283 "[new_remote_cookie <nn>]\n") \
20284 _(l2tpv3_interface_enable_disable, \
20285 "<intfc> | sw_if_index <nn> enable | disable") \
20286 _(l2tpv3_set_lookup_key, \
20287 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
20288 _(sw_if_l2tpv3_tunnel_dump, "") \
20289 _(vxlan_add_del_tunnel, \
20290 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
20291 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20292 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
20293 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20294 _(gre_add_del_tunnel, \
20295 "src <ip-addr> dst <ip-addr> [outer-fib-id <nn>] [teb] [del]\n") \
20296 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20297 _(l2_fib_clear_table, "") \
20298 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
20299 _(l2_interface_vlan_tag_rewrite, \
20300 "<intfc> | sw_if_index <nn> \n" \
20301 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
20302 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
20303 _(create_vhost_user_if, \
20304 "socket <filename> [server] [renumber <dev_instance>] " \
20305 "[mac <mac_address>]") \
20306 _(modify_vhost_user_if, \
20307 "<intfc> | sw_if_index <nn> socket <filename>\n" \
20308 "[server] [renumber <dev_instance>]") \
20309 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
20310 _(sw_interface_vhost_user_dump, "") \
20311 _(show_version, "") \
20312 _(vxlan_gpe_add_del_tunnel, \
20313 "local <addr> remote <addr> | group <mcast-ip-addr>\n" \
20314 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
20315 "vni <nn> [encap-vrf-id <nn>] [decap-vrf-id <nn>]\n" \
20316 "[next-ip4][next-ip6][next-ethernet] [next-nsh] [del]\n") \
20317 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
20318 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
20319 _(interface_name_renumber, \
20320 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
20321 _(input_acl_set_interface, \
20322 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20323 " [l2-table <nn>] [del]") \
20324 _(want_ip4_arp_events, "address <ip4-address> [del]") \
20325 _(want_ip6_nd_events, "address <ip6-address> [del]") \
20326 _(want_l2_macs_events, "[disable] [learn-limit <n>] [scan-delay <n>] [max-entries <n>]") \
20327 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
20328 _(ip_dump, "ipv4 | ipv6") \
20329 _(ipsec_spd_add_del, "spd_id <n> [del]") \
20330 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
20332 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
20333 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
20334 " integ_alg <alg> integ_key <hex>") \
20335 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
20336 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
20337 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
20338 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
20339 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
20340 _(ipsec_tunnel_if_add_del, "local_spi <n> remote_spi <n>\n" \
20341 " crypto_alg <alg> local_crypto_key <hex> remote_crypto_key <hex>\n" \
20342 " integ_alg <alg> local_integ_key <hex> remote_integ_key <hex>\n" \
20343 " local_ip <addr> remote_ip <addr> [esn] [anti_replay] [del]\n") \
20344 _(ikev2_profile_add_del, "name <profile_name> [del]") \
20345 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
20346 "(auth_data 0x<data> | auth_data <data>)") \
20347 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
20348 "(id_data 0x<data> | id_data <data>) (local|remote)") \
20349 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
20350 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
20351 "(local|remote)") \
20352 _(ikev2_set_local_key, "file <absolute_file_path>") \
20353 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
20354 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20355 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
20356 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
20357 _(ikev2_initiate_sa_init, "<profile_name>") \
20358 _(ikev2_initiate_del_ike_sa, "<ispi>") \
20359 _(ikev2_initiate_del_child_sa, "<ispi>") \
20360 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
20361 _(delete_loopback,"sw_if_index <nn>") \
20362 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
20363 _(map_add_domain, \
20364 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
20365 "ip6-src <ip6addr> " \
20366 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
20367 _(map_del_domain, "index <n>") \
20368 _(map_add_del_rule, \
20369 "index <n> psid <n> dst <ip6addr> [del]") \
20370 _(map_domain_dump, "") \
20371 _(map_rule_dump, "index <map-domain>") \
20372 _(want_interface_events, "enable|disable") \
20373 _(want_stats,"enable|disable") \
20374 _(get_first_msg_id, "client <name>") \
20375 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
20376 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
20377 "fib-id <nn> [ip4][ip6][default]") \
20378 _(get_node_graph, " ") \
20379 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
20380 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
20381 _(ioam_disable, "") \
20382 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
20383 " sw_if_index <sw_if_index> p <priority> " \
20384 "w <weight>] [del]") \
20385 _(one_add_del_locator, "locator-set <locator_name> " \
20386 "iface <intf> | sw_if_index <sw_if_index> " \
20387 "p <priority> w <weight> [del]") \
20388 _(one_add_del_local_eid,"vni <vni> eid " \
20389 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20390 "locator-set <locator_name> [del]" \
20391 "[key-id sha1|sha256 secret-key <secret-key>]")\
20392 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
20393 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
20394 _(one_enable_disable, "enable|disable") \
20395 _(one_map_register_enable_disable, "enable|disable") \
20396 _(one_map_register_fallback_threshold, "<value>") \
20397 _(one_rloc_probe_enable_disable, "enable|disable") \
20398 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20400 "rloc <locator> p <prio> " \
20401 "w <weight> [rloc <loc> ... ] " \
20402 "action <action> [del-all]") \
20403 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20405 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20406 _(one_use_petr, "ip-address> | disable") \
20407 _(one_map_request_mode, "src-dst|dst-only") \
20408 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20409 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20410 _(one_locator_set_dump, "[local | remote]") \
20411 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
20412 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20413 "[local] | [remote]") \
20414 _(one_add_del_l2_arp_entry, "[del] mac <mac> bd <bd> ip4 <ip4>") \
20415 _(one_l2_arp_bd_get, "") \
20416 _(one_l2_arp_entries_get, "bd <bridge-domain>") \
20417 _(one_stats_enable_disable, "enable|disalbe") \
20418 _(show_one_stats_enable_disable, "") \
20419 _(one_eid_table_vni_dump, "") \
20420 _(one_eid_table_map_dump, "l2|l3") \
20421 _(one_map_resolver_dump, "") \
20422 _(one_map_server_dump, "") \
20423 _(one_adjacencies_get, "vni <vni>") \
20424 _(one_nsh_set_locator_set, "[del] ls <locator-set-name>") \
20425 _(show_one_rloc_probe_state, "") \
20426 _(show_one_map_register_state, "") \
20427 _(show_one_status, "") \
20428 _(one_stats_dump, "") \
20429 _(one_stats_flush, "") \
20430 _(one_get_map_request_itr_rlocs, "") \
20431 _(one_map_register_set_ttl, "<ttl>") \
20432 _(show_one_nsh_mapping, "") \
20433 _(show_one_pitr, "") \
20434 _(show_one_use_petr, "") \
20435 _(show_one_map_request_mode, "") \
20436 _(show_one_map_register_ttl, "") \
20437 _(show_one_map_register_fallback_threshold, "") \
20438 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
20439 " sw_if_index <sw_if_index> p <priority> " \
20440 "w <weight>] [del]") \
20441 _(lisp_add_del_locator, "locator-set <locator_name> " \
20442 "iface <intf> | sw_if_index <sw_if_index> " \
20443 "p <priority> w <weight> [del]") \
20444 _(lisp_add_del_local_eid,"vni <vni> eid " \
20445 "<ipv4|ipv6>/<prefix> | <L2 address> " \
20446 "locator-set <locator_name> [del]" \
20447 "[key-id sha1|sha256 secret-key <secret-key>]") \
20448 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
20449 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
20450 _(lisp_enable_disable, "enable|disable") \
20451 _(lisp_map_register_enable_disable, "enable|disable") \
20452 _(lisp_rloc_probe_enable_disable, "enable|disable") \
20453 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
20455 "rloc <locator> p <prio> " \
20456 "w <weight> [rloc <loc> ... ] " \
20457 "action <action> [del-all]") \
20458 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
20460 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
20461 _(lisp_use_petr, "<ip-address> | disable") \
20462 _(lisp_map_request_mode, "src-dst|dst-only") \
20463 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
20464 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
20465 _(lisp_locator_set_dump, "[local | remote]") \
20466 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
20467 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
20468 "[local] | [remote]") \
20469 _(lisp_eid_table_vni_dump, "") \
20470 _(lisp_eid_table_map_dump, "l2|l3") \
20471 _(lisp_map_resolver_dump, "") \
20472 _(lisp_map_server_dump, "") \
20473 _(lisp_adjacencies_get, "vni <vni>") \
20474 _(gpe_fwd_entry_vnis_get, "") \
20475 _(gpe_native_fwd_rpaths_get, "ip4 | ip6") \
20476 _(gpe_add_del_native_fwd_rpath, "[del] via <nh-ip-addr> [iface] " \
20477 "[table <table-id>]") \
20478 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
20479 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
20480 _(gpe_set_encap_mode, "lisp|vxlan") \
20481 _(gpe_get_encap_mode, "") \
20482 _(lisp_gpe_add_del_iface, "up|down") \
20483 _(lisp_gpe_enable_disable, "enable|disable") \
20484 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
20485 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
20486 _(show_lisp_rloc_probe_state, "") \
20487 _(show_lisp_map_register_state, "") \
20488 _(show_lisp_status, "") \
20489 _(lisp_get_map_request_itr_rlocs, "") \
20490 _(show_lisp_pitr, "") \
20491 _(show_lisp_use_petr, "") \
20492 _(show_lisp_map_request_mode, "") \
20493 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
20494 _(af_packet_delete, "name <host interface name>") \
20495 _(policer_add_del, "name <policer name> <params> [del]") \
20496 _(policer_dump, "[name <policer name>]") \
20497 _(policer_classify_set_interface, \
20498 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
20499 " [l2-table <nn>] [del]") \
20500 _(policer_classify_dump, "type [ip4|ip6|l2]") \
20501 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
20502 "[master|slave]") \
20503 _(netmap_delete, "name <interface name>") \
20504 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
20505 _(mpls_fib_dump, "") \
20506 _(classify_table_ids, "") \
20507 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
20508 _(classify_table_info, "table_id <nn>") \
20509 _(classify_session_dump, "table_id <nn>") \
20510 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
20511 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
20512 "[template_interval <nn>] [udp_checksum]") \
20513 _(ipfix_exporter_dump, "") \
20514 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
20515 _(ipfix_classify_stream_dump, "") \
20516 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
20517 _(ipfix_classify_table_dump, "") \
20518 _(sw_interface_span_enable_disable, "[l2] [src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
20519 _(sw_interface_span_dump, "[l2]") \
20520 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
20521 _(pg_create_interface, "if_id <nn>") \
20522 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
20523 _(pg_enable_disable, "[stream <id>] disable") \
20524 _(ip_source_and_port_range_check_add_del, \
20525 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
20526 _(ip_source_and_port_range_check_interface_add_del, \
20527 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
20528 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
20529 _(ipsec_gre_add_del_tunnel, \
20530 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
20531 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
20532 _(delete_subif,"<intfc> | sw_if_index <nn>") \
20533 _(l2_interface_pbb_tag_rewrite, \
20534 "<intfc> | sw_if_index <nn> \n" \
20535 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
20536 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
20537 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
20538 _(flow_classify_set_interface, \
20539 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
20540 _(flow_classify_dump, "type [ip4|ip6]") \
20541 _(ip_fib_dump, "") \
20542 _(ip_mfib_dump, "") \
20543 _(ip6_fib_dump, "") \
20544 _(ip6_mfib_dump, "") \
20545 _(feature_enable_disable, "arc_name <arc_name> " \
20546 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
20547 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
20549 _(l2_xconnect_dump, "") \
20550 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
20551 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
20552 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]") \
20553 _(p2p_ethernet_add, "<intfc> | sw_if_index <nn> remote_mac <mac-address> sub_id <id>") \
20554 _(p2p_ethernet_del, "<intfc> | sw_if_index <nn> remote_mac <mac-address>") \
20555 _(lldp_config, "system-name <name> tx-hold <nn> tx-interval <nn>") \
20556 _(sw_interface_set_lldp, "<intfc> | sw_if_index <nn> [port-desc <description>] [disable]") \
20557 _(tcp_configure_src_addresses, "<ip4|6>first-<ip4|6>last [vrf <id>]")
20559 /* List of command functions, CLI names map directly to functions */
20560 #define foreach_cli_function \
20561 _(comment, "usage: comment <ignore-rest-of-line>") \
20562 _(dump_interface_table, "usage: dump_interface_table") \
20563 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
20564 _(dump_ipv4_table, "usage: dump_ipv4_table") \
20565 _(dump_ipv6_table, "usage: dump_ipv6_table") \
20566 _(dump_stats_table, "usage: dump_stats_table") \
20567 _(dump_macro_table, "usage: dump_macro_table ") \
20568 _(dump_node_table, "usage: dump_node_table") \
20569 _(dump_msg_api_table, "usage: dump_msg_api_table") \
20570 _(get_msg_id, "usage: get_msg_id name_and_crc") \
20571 _(echo, "usage: echo <message>") \
20572 _(exec, "usage: exec <vpe-debug-CLI-command>") \
20573 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
20574 _(help, "usage: help") \
20575 _(q, "usage: quit") \
20576 _(quit, "usage: quit") \
20577 _(search_node_table, "usage: search_node_table <name>...") \
20578 _(set, "usage: set <variable-name> <value>") \
20579 _(script, "usage: script <file-name>") \
20580 _(unset, "usage: unset <variable-name>")
20582 static void vl_api_##n##_t_handler_uni \
20583 (vl_api_##n##_t * mp) \
20585 vat_main_t * vam = &vat_main; \
20586 if (vam->json_output) { \
20587 vl_api_##n##_t_handler_json(mp); \
20589 vl_api_##n##_t_handler(mp); \
20592 foreach_vpe_api_reply_msg;
20593 #if VPP_API_TEST_BUILTIN == 0
20594 foreach_standalone_reply_msg;
20599 vat_api_hookup (vat_main_t * vam)
20602 vl_msg_api_set_handlers(VL_API_##N, #n, \
20603 vl_api_##n##_t_handler_uni, \
20605 vl_api_##n##_t_endian, \
20606 vl_api_##n##_t_print, \
20607 sizeof(vl_api_##n##_t), 1);
20608 foreach_vpe_api_reply_msg;
20609 #if VPP_API_TEST_BUILTIN == 0
20610 foreach_standalone_reply_msg;
20614 #if (VPP_API_TEST_BUILTIN==0)
20615 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
20617 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
20619 vam->function_by_name = hash_create_string (0, sizeof (uword));
20621 vam->help_by_name = hash_create_string (0, sizeof (uword));
20624 /* API messages we can send */
20625 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
20626 foreach_vpe_api_msg;
20630 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20631 foreach_vpe_api_msg;
20634 /* CLI functions */
20635 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
20636 foreach_cli_function;
20640 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
20641 foreach_cli_function;
20645 #if VPP_API_TEST_BUILTIN
20646 static clib_error_t *
20647 vat_api_hookup_shim (vlib_main_t * vm)
20649 vat_api_hookup (&vat_main);
20653 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
20657 * fd.io coding-style-patch-verification: ON
20660 * eval: (c-set-style "gnu")