2 *------------------------------------------------------------------
5 * Copyright (c) 2014-2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
21 #include <vlibapi/api.h>
22 #include <vlibmemory/api.h>
23 #include <vlibsocket/api.h>
24 #include <vnet/ip/ip.h>
25 #include <vnet/l2/l2_input.h>
26 #include <vnet/l2tp/l2tp.h>
27 #include <vnet/vxlan/vxlan.h>
28 #include <vnet/gre/gre.h>
29 #include <vnet/vxlan-gpe/vxlan_gpe.h>
30 #include <vnet/lisp-gpe/lisp_gpe.h>
32 #include <vpp/api/vpe_msg_enum.h>
33 #include <vnet/l2/l2_classify.h>
34 #include <vnet/l2/l2_vtr.h>
35 #include <vnet/classify/input_acl.h>
36 #include <vnet/classify/policer_classify.h>
37 #include <vnet/classify/flow_classify.h>
38 #include <vnet/mpls/mpls.h>
39 #include <vnet/ipsec/ipsec.h>
40 #include <vnet/ipsec/ikev2.h>
42 #include <vnet/map/map.h>
43 #include <vnet/cop/cop.h>
44 #include <vnet/ip/ip6_hop_by_hop.h>
45 #include <vnet/ip/ip_source_and_port_range_check.h>
46 #include <vnet/policer/xlate.h>
47 #include <vnet/span/span.h>
48 #include <vnet/policer/policer.h>
49 #include <vnet/policer/police.h>
50 #include <vnet/mfib/mfib_types.h>
52 #include "vat/json_format.h"
57 #define vl_typedefs /* define message structures */
58 #include <vpp/api/vpe_all_api_h.h>
61 /* declare message handlers for each api */
63 #define vl_endianfun /* define message structures */
64 #include <vpp/api/vpe_all_api_h.h>
67 /* instantiate all the print functions we know about */
68 #define vl_print(handle, ...)
70 #include <vpp/api/vpe_all_api_h.h>
73 #define __plugin_msg_base 0
74 #include <vlibapi/vat_helper_macros.h>
77 vat_time_now (vat_main_t * vam)
79 #if VPP_API_TEST_BUILTIN
80 return vlib_time_now (vam->vlib_main);
82 return clib_time_now (&vam->clib_time);
87 errmsg (char *fmt, ...)
89 vat_main_t *vam = &vat_main;
94 s = va_format (0, fmt, &va);
99 #if VPP_API_TEST_BUILTIN
100 vlib_cli_output (vam->vlib_main, (char *) s);
103 if (vam->ifp != stdin)
104 fformat (vam->ofp, "%s(%d): \n", vam->current_file,
105 vam->input_line_number);
106 fformat (vam->ofp, (char *) s);
114 #if VPP_API_TEST_BUILTIN == 0
116 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
118 vat_main_t *vam = va_arg (*args, vat_main_t *);
119 u32 *result = va_arg (*args, u32 *);
123 if (!unformat (input, "%s", &if_name))
126 p = hash_get_mem (vam->sw_if_index_by_interface_name, if_name);
133 /* Parse an IP4 address %d.%d.%d.%d. */
135 unformat_ip4_address (unformat_input_t * input, va_list * args)
137 u8 *result = va_arg (*args, u8 *);
140 if (!unformat (input, "%d.%d.%d.%d", &a[0], &a[1], &a[2], &a[3]))
143 if (a[0] >= 256 || a[1] >= 256 || a[2] >= 256 || a[3] >= 256)
155 unformat_ethernet_address (unformat_input_t * input, va_list * args)
157 u8 *result = va_arg (*args, u8 *);
160 if (!unformat (input, "%_%x:%x:%x:%x:%x:%x%_",
161 &a[0], &a[1], &a[2], &a[3], &a[4], &a[5]))
165 for (i = 0; i < 6; i++)
166 if (a[i] >= (1 << 8))
169 for (i = 0; i < 6; i++)
175 /* Returns ethernet type as an int in host byte order. */
177 unformat_ethernet_type_host_byte_order (unformat_input_t * input,
180 u16 *result = va_arg (*args, u16 *);
184 if (unformat (input, "0x%x", &type) || unformat (input, "%d", &type))
186 if (type >= (1 << 16))
194 /* Parse an IP6 address. */
196 unformat_ip6_address (unformat_input_t * input, va_list * args)
198 ip6_address_t *result = va_arg (*args, ip6_address_t *);
200 uword hex_quad, n_hex_quads, hex_digit, n_hex_digits;
201 uword c, n_colon, double_colon_index;
203 n_hex_quads = hex_quad = n_hex_digits = n_colon = 0;
204 double_colon_index = ARRAY_LEN (hex_quads);
205 while ((c = unformat_get_input (input)) != UNFORMAT_END_OF_INPUT)
208 if (c >= '0' && c <= '9')
210 else if (c >= 'a' && c <= 'f')
211 hex_digit = c + 10 - 'a';
212 else if (c >= 'A' && c <= 'F')
213 hex_digit = c + 10 - 'A';
214 else if (c == ':' && n_colon < 2)
218 unformat_put_input (input);
222 /* Too many hex quads. */
223 if (n_hex_quads >= ARRAY_LEN (hex_quads))
228 hex_quad = (hex_quad << 4) | hex_digit;
230 /* Hex quad must fit in 16 bits. */
231 if (n_hex_digits >= 4)
238 /* Save position of :: */
241 /* More than one :: ? */
242 if (double_colon_index < ARRAY_LEN (hex_quads))
244 double_colon_index = n_hex_quads;
247 if (n_colon > 0 && n_hex_digits > 0)
249 hex_quads[n_hex_quads++] = hex_quad;
255 if (n_hex_digits > 0)
256 hex_quads[n_hex_quads++] = hex_quad;
261 /* Expand :: to appropriate number of zero hex quads. */
262 if (double_colon_index < ARRAY_LEN (hex_quads))
264 word n_zero = ARRAY_LEN (hex_quads) - n_hex_quads;
266 for (i = n_hex_quads - 1; i >= (signed) double_colon_index; i--)
267 hex_quads[n_zero + i] = hex_quads[i];
269 for (i = 0; i < n_zero; i++)
270 hex_quads[double_colon_index + i] = 0;
272 n_hex_quads = ARRAY_LEN (hex_quads);
275 /* Too few hex quads given. */
276 if (n_hex_quads < ARRAY_LEN (hex_quads))
279 for (i = 0; i < ARRAY_LEN (hex_quads); i++)
280 result->as_u16[i] = clib_host_to_net_u16 (hex_quads[i]);
287 unformat_ipsec_policy_action (unformat_input_t * input, va_list * args)
289 u32 *r = va_arg (*args, u32 *);
292 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_POLICY_ACTION_##f;
293 foreach_ipsec_policy_action
301 unformat_ipsec_crypto_alg (unformat_input_t * input, va_list * args)
303 u32 *r = va_arg (*args, u32 *);
306 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_CRYPTO_ALG_##f;
307 foreach_ipsec_crypto_alg
315 format_ipsec_crypto_alg (u8 * s, va_list * args)
317 u32 i = va_arg (*args, u32);
322 #define _(v,f,str) case IPSEC_CRYPTO_ALG_##f: t = (u8 *) str; break;
323 foreach_ipsec_crypto_alg
326 return format (s, "unknown");
328 return format (s, "%s", t);
332 unformat_ipsec_integ_alg (unformat_input_t * input, va_list * args)
334 u32 *r = va_arg (*args, u32 *);
337 #define _(v,f,s) else if (unformat (input, s)) *r = IPSEC_INTEG_ALG_##f;
338 foreach_ipsec_integ_alg
346 format_ipsec_integ_alg (u8 * s, va_list * args)
348 u32 i = va_arg (*args, u32);
353 #define _(v,f,str) case IPSEC_INTEG_ALG_##f: t = (u8 *) str; break;
354 foreach_ipsec_integ_alg
357 return format (s, "unknown");
359 return format (s, "%s", t);
363 unformat_ikev2_auth_method (unformat_input_t * input, va_list * args)
365 u32 *r = va_arg (*args, u32 *);
368 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_AUTH_METHOD_##f;
369 foreach_ikev2_auth_method
377 unformat_ikev2_id_type (unformat_input_t * input, va_list * args)
379 u32 *r = va_arg (*args, u32 *);
382 #define _(v,f,s) else if (unformat (input, s)) *r = IKEV2_ID_TYPE_##f;
383 foreach_ikev2_id_type
389 #else /* VPP_API_TEST_BUILTIN == 1 */
391 api_unformat_sw_if_index (unformat_input_t * input, va_list * args)
393 vat_main_t *vam __attribute__ ((unused)) = va_arg (*args, vat_main_t *);
394 vnet_main_t *vnm = vnet_get_main ();
395 u32 *result = va_arg (*args, u32 *);
398 if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index))
401 *result = sw_if_index;
404 #endif /* VPP_API_TEST_BUILTIN */
407 unformat_policer_rate_type (unformat_input_t * input, va_list * args)
409 u8 *r = va_arg (*args, u8 *);
411 if (unformat (input, "kbps"))
412 *r = SSE2_QOS_RATE_KBPS;
413 else if (unformat (input, "pps"))
414 *r = SSE2_QOS_RATE_PPS;
421 unformat_policer_round_type (unformat_input_t * input, va_list * args)
423 u8 *r = va_arg (*args, u8 *);
425 if (unformat (input, "closest"))
426 *r = SSE2_QOS_ROUND_TO_CLOSEST;
427 else if (unformat (input, "up"))
428 *r = SSE2_QOS_ROUND_TO_UP;
429 else if (unformat (input, "down"))
430 *r = SSE2_QOS_ROUND_TO_DOWN;
437 unformat_policer_type (unformat_input_t * input, va_list * args)
439 u8 *r = va_arg (*args, u8 *);
441 if (unformat (input, "1r2c"))
442 *r = SSE2_QOS_POLICER_TYPE_1R2C;
443 else if (unformat (input, "1r3c"))
444 *r = SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697;
445 else if (unformat (input, "2r3c-2698"))
446 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698;
447 else if (unformat (input, "2r3c-4115"))
448 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115;
449 else if (unformat (input, "2r3c-mef5cf1"))
450 *r = SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1;
457 unformat_dscp (unformat_input_t * input, va_list * va)
459 u8 *r = va_arg (*va, u8 *);
462 #define _(v,f,str) else if (unformat (input, str)) *r = VNET_DSCP_##f;
471 unformat_policer_action_type (unformat_input_t * input, va_list * va)
473 sse2_qos_pol_action_params_st *a
474 = va_arg (*va, sse2_qos_pol_action_params_st *);
476 if (unformat (input, "drop"))
477 a->action_type = SSE2_QOS_ACTION_DROP;
478 else if (unformat (input, "transmit"))
479 a->action_type = SSE2_QOS_ACTION_TRANSMIT;
480 else if (unformat (input, "mark-and-transmit %U", unformat_dscp, &a->dscp))
481 a->action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
488 unformat_policer_classify_table_type (unformat_input_t * input, va_list * va)
490 u32 *r = va_arg (*va, u32 *);
493 if (unformat (input, "ip4"))
494 tid = POLICER_CLASSIFY_TABLE_IP4;
495 else if (unformat (input, "ip6"))
496 tid = POLICER_CLASSIFY_TABLE_IP6;
497 else if (unformat (input, "l2"))
498 tid = POLICER_CLASSIFY_TABLE_L2;
507 unformat_flow_classify_table_type (unformat_input_t * input, va_list * va)
509 u32 *r = va_arg (*va, u32 *);
512 if (unformat (input, "ip4"))
513 tid = FLOW_CLASSIFY_TABLE_IP4;
514 else if (unformat (input, "ip6"))
515 tid = FLOW_CLASSIFY_TABLE_IP6;
523 static const char *mfib_flag_names[] = MFIB_ENTRY_NAMES_SHORT;
524 static const char *mfib_flag_long_names[] = MFIB_ENTRY_NAMES_LONG;
525 static const char *mfib_itf_flag_long_names[] = MFIB_ITF_NAMES_LONG;
526 static const char *mfib_itf_flag_names[] = MFIB_ITF_NAMES_SHORT;
528 #if (VPP_API_TEST_BUILTIN==0)
530 unformat_mfib_itf_flags (unformat_input_t * input, va_list * args)
532 mfib_itf_flags_t old, *iflags = va_arg (*args, mfib_itf_flags_t *);
533 mfib_itf_attribute_t attr;
536 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
538 if (unformat (input, mfib_itf_flag_long_names[attr]))
539 *iflags |= (1 << attr);
541 FOR_EACH_MFIB_ITF_ATTRIBUTE (attr)
543 if (unformat (input, mfib_itf_flag_names[attr]))
544 *iflags |= (1 << attr);
547 return (old == *iflags ? 0 : 1);
551 unformat_mfib_entry_flags (unformat_input_t * input, va_list * args)
553 mfib_entry_flags_t old, *eflags = va_arg (*args, mfib_entry_flags_t *);
554 mfib_entry_attribute_t attr;
557 FOR_EACH_MFIB_ATTRIBUTE (attr)
559 if (unformat (input, mfib_flag_long_names[attr]))
560 *eflags |= (1 << attr);
562 FOR_EACH_MFIB_ATTRIBUTE (attr)
564 if (unformat (input, mfib_flag_names[attr]))
565 *eflags |= (1 << attr);
568 return (old == *eflags ? 0 : 1);
572 format_ip4_address (u8 * s, va_list * args)
574 u8 *a = va_arg (*args, u8 *);
575 return format (s, "%d.%d.%d.%d", a[0], a[1], a[2], a[3]);
579 format_ip6_address (u8 * s, va_list * args)
581 ip6_address_t *a = va_arg (*args, ip6_address_t *);
582 u32 i, i_max_n_zero, max_n_zeros, i_first_zero, n_zeros, last_double_colon;
584 i_max_n_zero = ARRAY_LEN (a->as_u16);
586 i_first_zero = i_max_n_zero;
588 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
590 u32 is_zero = a->as_u16[i] == 0;
591 if (is_zero && i_first_zero >= ARRAY_LEN (a->as_u16))
597 if ((!is_zero && n_zeros > max_n_zeros)
598 || (i + 1 >= ARRAY_LEN (a->as_u16) && n_zeros > max_n_zeros))
600 i_max_n_zero = i_first_zero;
601 max_n_zeros = n_zeros;
602 i_first_zero = ARRAY_LEN (a->as_u16);
607 last_double_colon = 0;
608 for (i = 0; i < ARRAY_LEN (a->as_u16); i++)
610 if (i == i_max_n_zero && max_n_zeros > 1)
612 s = format (s, "::");
613 i += max_n_zeros - 1;
614 last_double_colon = 1;
618 s = format (s, "%s%x",
619 (last_double_colon || i == 0) ? "" : ":",
620 clib_net_to_host_u16 (a->as_u16[i]));
621 last_double_colon = 0;
628 /* Format an IP46 address. */
630 format_ip46_address (u8 * s, va_list * args)
632 ip46_address_t *ip46 = va_arg (*args, ip46_address_t *);
633 ip46_type_t type = va_arg (*args, ip46_type_t);
639 is_ip4 = ip46_address_is_ip4 (ip46);
650 format (s, "%U", format_ip4_address, &ip46->ip4) :
651 format (s, "%U", format_ip6_address, &ip46->ip6);
655 format_ethernet_address (u8 * s, va_list * args)
657 u8 *a = va_arg (*args, u8 *);
659 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
660 a[0], a[1], a[2], a[3], a[4], a[5]);
665 increment_v4_address (ip4_address_t * a)
669 v = ntohl (a->as_u32) + 1;
670 a->as_u32 = ntohl (v);
674 increment_v6_address (ip6_address_t * a)
678 v0 = clib_net_to_host_u64 (a->as_u64[0]);
679 v1 = clib_net_to_host_u64 (a->as_u64[1]);
684 a->as_u64[0] = clib_net_to_host_u64 (v0);
685 a->as_u64[1] = clib_net_to_host_u64 (v1);
689 increment_mac_address (u64 * mac)
693 tmp = clib_net_to_host_u64 (tmp);
694 tmp += 1 << 16; /* skip unused (least significant) octets */
695 tmp = clib_host_to_net_u64 (tmp);
699 static void vl_api_create_loopback_reply_t_handler
700 (vl_api_create_loopback_reply_t * mp)
702 vat_main_t *vam = &vat_main;
703 i32 retval = ntohl (mp->retval);
705 vam->retval = retval;
706 vam->regenerate_interface_table = 1;
707 vam->sw_if_index = ntohl (mp->sw_if_index);
708 vam->result_ready = 1;
711 static void vl_api_create_loopback_reply_t_handler_json
712 (vl_api_create_loopback_reply_t * mp)
714 vat_main_t *vam = &vat_main;
715 vat_json_node_t node;
717 vat_json_init_object (&node);
718 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
719 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
721 vat_json_print (vam->ofp, &node);
722 vat_json_free (&node);
723 vam->retval = ntohl (mp->retval);
724 vam->result_ready = 1;
727 static void vl_api_create_loopback_instance_reply_t_handler
728 (vl_api_create_loopback_instance_reply_t * mp)
730 vat_main_t *vam = &vat_main;
731 i32 retval = ntohl (mp->retval);
733 vam->retval = retval;
734 vam->regenerate_interface_table = 1;
735 vam->sw_if_index = ntohl (mp->sw_if_index);
736 vam->result_ready = 1;
739 static void vl_api_create_loopback_instance_reply_t_handler_json
740 (vl_api_create_loopback_instance_reply_t * mp)
742 vat_main_t *vam = &vat_main;
743 vat_json_node_t node;
745 vat_json_init_object (&node);
746 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
747 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
749 vat_json_print (vam->ofp, &node);
750 vat_json_free (&node);
751 vam->retval = ntohl (mp->retval);
752 vam->result_ready = 1;
755 static void vl_api_af_packet_create_reply_t_handler
756 (vl_api_af_packet_create_reply_t * mp)
758 vat_main_t *vam = &vat_main;
759 i32 retval = ntohl (mp->retval);
761 vam->retval = retval;
762 vam->regenerate_interface_table = 1;
763 vam->sw_if_index = ntohl (mp->sw_if_index);
764 vam->result_ready = 1;
767 static void vl_api_af_packet_create_reply_t_handler_json
768 (vl_api_af_packet_create_reply_t * mp)
770 vat_main_t *vam = &vat_main;
771 vat_json_node_t node;
773 vat_json_init_object (&node);
774 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
775 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
777 vat_json_print (vam->ofp, &node);
778 vat_json_free (&node);
780 vam->retval = ntohl (mp->retval);
781 vam->result_ready = 1;
784 static void vl_api_create_vlan_subif_reply_t_handler
785 (vl_api_create_vlan_subif_reply_t * mp)
787 vat_main_t *vam = &vat_main;
788 i32 retval = ntohl (mp->retval);
790 vam->retval = retval;
791 vam->regenerate_interface_table = 1;
792 vam->sw_if_index = ntohl (mp->sw_if_index);
793 vam->result_ready = 1;
796 static void vl_api_create_vlan_subif_reply_t_handler_json
797 (vl_api_create_vlan_subif_reply_t * mp)
799 vat_main_t *vam = &vat_main;
800 vat_json_node_t node;
802 vat_json_init_object (&node);
803 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
804 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
806 vat_json_print (vam->ofp, &node);
807 vat_json_free (&node);
809 vam->retval = ntohl (mp->retval);
810 vam->result_ready = 1;
813 static void vl_api_create_subif_reply_t_handler
814 (vl_api_create_subif_reply_t * mp)
816 vat_main_t *vam = &vat_main;
817 i32 retval = ntohl (mp->retval);
819 vam->retval = retval;
820 vam->regenerate_interface_table = 1;
821 vam->sw_if_index = ntohl (mp->sw_if_index);
822 vam->result_ready = 1;
825 static void vl_api_create_subif_reply_t_handler_json
826 (vl_api_create_subif_reply_t * mp)
828 vat_main_t *vam = &vat_main;
829 vat_json_node_t node;
831 vat_json_init_object (&node);
832 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
833 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
835 vat_json_print (vam->ofp, &node);
836 vat_json_free (&node);
838 vam->retval = ntohl (mp->retval);
839 vam->result_ready = 1;
842 static void vl_api_interface_name_renumber_reply_t_handler
843 (vl_api_interface_name_renumber_reply_t * mp)
845 vat_main_t *vam = &vat_main;
846 i32 retval = ntohl (mp->retval);
848 vam->retval = retval;
849 vam->regenerate_interface_table = 1;
850 vam->result_ready = 1;
853 static void vl_api_interface_name_renumber_reply_t_handler_json
854 (vl_api_interface_name_renumber_reply_t * mp)
856 vat_main_t *vam = &vat_main;
857 vat_json_node_t node;
859 vat_json_init_object (&node);
860 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
862 vat_json_print (vam->ofp, &node);
863 vat_json_free (&node);
865 vam->retval = ntohl (mp->retval);
866 vam->result_ready = 1;
870 * Special-case: build the interface table, maintain
871 * the next loopback sw_if_index vbl.
873 static void vl_api_sw_interface_details_t_handler
874 (vl_api_sw_interface_details_t * mp)
876 vat_main_t *vam = &vat_main;
877 u8 *s = format (0, "%s%c", mp->interface_name, 0);
879 hash_set_mem (vam->sw_if_index_by_interface_name, s,
880 ntohl (mp->sw_if_index));
882 /* In sub interface case, fill the sub interface table entry */
883 if (mp->sw_if_index != mp->sup_sw_if_index)
885 sw_interface_subif_t *sub = NULL;
887 vec_add2 (vam->sw_if_subif_table, sub, 1);
889 vec_validate (sub->interface_name, strlen ((char *) s) + 1);
890 strncpy ((char *) sub->interface_name, (char *) s,
891 vec_len (sub->interface_name));
892 sub->sw_if_index = ntohl (mp->sw_if_index);
893 sub->sub_id = ntohl (mp->sub_id);
895 sub->sub_dot1ad = mp->sub_dot1ad;
896 sub->sub_number_of_tags = mp->sub_number_of_tags;
897 sub->sub_outer_vlan_id = ntohs (mp->sub_outer_vlan_id);
898 sub->sub_inner_vlan_id = ntohs (mp->sub_inner_vlan_id);
899 sub->sub_exact_match = mp->sub_exact_match;
900 sub->sub_default = mp->sub_default;
901 sub->sub_outer_vlan_id_any = mp->sub_outer_vlan_id_any;
902 sub->sub_inner_vlan_id_any = mp->sub_inner_vlan_id_any;
904 /* vlan tag rewrite */
905 sub->vtr_op = ntohl (mp->vtr_op);
906 sub->vtr_push_dot1q = ntohl (mp->vtr_push_dot1q);
907 sub->vtr_tag1 = ntohl (mp->vtr_tag1);
908 sub->vtr_tag2 = ntohl (mp->vtr_tag2);
912 static void vl_api_sw_interface_details_t_handler_json
913 (vl_api_sw_interface_details_t * mp)
915 vat_main_t *vam = &vat_main;
916 vat_json_node_t *node = NULL;
918 if (VAT_JSON_ARRAY != vam->json_tree.type)
920 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
921 vat_json_init_array (&vam->json_tree);
923 node = vat_json_array_add (&vam->json_tree);
925 vat_json_init_object (node);
926 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
927 vat_json_object_add_uint (node, "sup_sw_if_index",
928 ntohl (mp->sup_sw_if_index));
929 vat_json_object_add_uint (node, "l2_address_length",
930 ntohl (mp->l2_address_length));
931 vat_json_object_add_bytes (node, "l2_address", mp->l2_address,
932 sizeof (mp->l2_address));
933 vat_json_object_add_string_copy (node, "interface_name",
935 vat_json_object_add_uint (node, "admin_up_down", mp->admin_up_down);
936 vat_json_object_add_uint (node, "link_up_down", mp->link_up_down);
937 vat_json_object_add_uint (node, "link_duplex", mp->link_duplex);
938 vat_json_object_add_uint (node, "link_speed", mp->link_speed);
939 vat_json_object_add_uint (node, "mtu", ntohs (mp->link_mtu));
940 vat_json_object_add_uint (node, "sub_id", ntohl (mp->sub_id));
941 vat_json_object_add_uint (node, "sub_dot1ad", mp->sub_dot1ad);
942 vat_json_object_add_uint (node, "sub_number_of_tags",
943 mp->sub_number_of_tags);
944 vat_json_object_add_uint (node, "sub_outer_vlan_id",
945 ntohs (mp->sub_outer_vlan_id));
946 vat_json_object_add_uint (node, "sub_inner_vlan_id",
947 ntohs (mp->sub_inner_vlan_id));
948 vat_json_object_add_uint (node, "sub_exact_match", mp->sub_exact_match);
949 vat_json_object_add_uint (node, "sub_default", mp->sub_default);
950 vat_json_object_add_uint (node, "sub_outer_vlan_id_any",
951 mp->sub_outer_vlan_id_any);
952 vat_json_object_add_uint (node, "sub_inner_vlan_id_any",
953 mp->sub_inner_vlan_id_any);
954 vat_json_object_add_uint (node, "vtr_op", ntohl (mp->vtr_op));
955 vat_json_object_add_uint (node, "vtr_push_dot1q",
956 ntohl (mp->vtr_push_dot1q));
957 vat_json_object_add_uint (node, "vtr_tag1", ntohl (mp->vtr_tag1));
958 vat_json_object_add_uint (node, "vtr_tag2", ntohl (mp->vtr_tag2));
961 vat_json_object_add_string_copy (node, "pbb_vtr_dmac",
963 format_ethernet_address,
965 vat_json_object_add_string_copy (node, "pbb_vtr_smac",
967 format_ethernet_address,
969 vat_json_object_add_uint (node, "pbb_vtr_b_vlanid", mp->b_vlanid);
970 vat_json_object_add_uint (node, "pbb_vtr_i_sid", mp->i_sid);
974 #if VPP_API_TEST_BUILTIN == 0
975 static void vl_api_sw_interface_set_flags_t_handler
976 (vl_api_sw_interface_set_flags_t * mp)
978 vat_main_t *vam = &vat_main;
979 if (vam->interface_event_display)
980 errmsg ("interface flags: sw_if_index %d %s %s",
981 ntohl (mp->sw_if_index),
982 mp->admin_up_down ? "admin-up" : "admin-down",
983 mp->link_up_down ? "link-up" : "link-down");
987 static void vl_api_sw_interface_set_flags_t_handler_json
988 (vl_api_sw_interface_set_flags_t * mp)
990 /* JSON output not supported */
994 vl_api_cli_reply_t_handler (vl_api_cli_reply_t * mp)
996 vat_main_t *vam = &vat_main;
997 i32 retval = ntohl (mp->retval);
999 vam->retval = retval;
1000 vam->shmem_result = (u8 *) mp->reply_in_shmem;
1001 vam->result_ready = 1;
1005 vl_api_cli_reply_t_handler_json (vl_api_cli_reply_t * mp)
1007 vat_main_t *vam = &vat_main;
1008 vat_json_node_t node;
1009 api_main_t *am = &api_main;
1013 vat_json_init_object (&node);
1014 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1015 vat_json_object_add_uint (&node, "reply_in_shmem",
1016 ntohl (mp->reply_in_shmem));
1017 /* Toss the shared-memory original... */
1018 pthread_mutex_lock (&am->vlib_rp->mutex);
1019 oldheap = svm_push_data_heap (am->vlib_rp);
1021 reply = (u8 *) (mp->reply_in_shmem);
1024 svm_pop_heap (oldheap);
1025 pthread_mutex_unlock (&am->vlib_rp->mutex);
1027 vat_json_print (vam->ofp, &node);
1028 vat_json_free (&node);
1030 vam->retval = ntohl (mp->retval);
1031 vam->result_ready = 1;
1035 vl_api_cli_inband_reply_t_handler (vl_api_cli_inband_reply_t * mp)
1037 vat_main_t *vam = &vat_main;
1038 i32 retval = ntohl (mp->retval);
1040 vam->retval = retval;
1041 vam->cmd_reply = mp->reply;
1042 vam->result_ready = 1;
1046 vl_api_cli_inband_reply_t_handler_json (vl_api_cli_inband_reply_t * mp)
1048 vat_main_t *vam = &vat_main;
1049 vat_json_node_t node;
1051 vat_json_init_object (&node);
1052 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1053 vat_json_object_add_string_copy (&node, "reply", mp->reply);
1055 vat_json_print (vam->ofp, &node);
1056 vat_json_free (&node);
1058 vam->retval = ntohl (mp->retval);
1059 vam->result_ready = 1;
1062 static void vl_api_classify_add_del_table_reply_t_handler
1063 (vl_api_classify_add_del_table_reply_t * mp)
1065 vat_main_t *vam = &vat_main;
1066 i32 retval = ntohl (mp->retval);
1067 if (vam->async_mode)
1069 vam->async_errors += (retval < 0);
1073 vam->retval = retval;
1075 ((mp->new_table_index != 0xFFFFFFFF) ||
1076 (mp->skip_n_vectors != 0xFFFFFFFF) ||
1077 (mp->match_n_vectors != 0xFFFFFFFF)))
1079 * Note: this is just barely thread-safe, depends on
1080 * the main thread spinning waiting for an answer...
1082 errmsg ("new index %d, skip_n_vectors %d, match_n_vectors %d",
1083 ntohl (mp->new_table_index),
1084 ntohl (mp->skip_n_vectors), ntohl (mp->match_n_vectors));
1085 vam->result_ready = 1;
1089 static void vl_api_classify_add_del_table_reply_t_handler_json
1090 (vl_api_classify_add_del_table_reply_t * mp)
1092 vat_main_t *vam = &vat_main;
1093 vat_json_node_t node;
1095 vat_json_init_object (&node);
1096 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1097 vat_json_object_add_uint (&node, "new_table_index",
1098 ntohl (mp->new_table_index));
1099 vat_json_object_add_uint (&node, "skip_n_vectors",
1100 ntohl (mp->skip_n_vectors));
1101 vat_json_object_add_uint (&node, "match_n_vectors",
1102 ntohl (mp->match_n_vectors));
1104 vat_json_print (vam->ofp, &node);
1105 vat_json_free (&node);
1107 vam->retval = ntohl (mp->retval);
1108 vam->result_ready = 1;
1111 static void vl_api_get_node_index_reply_t_handler
1112 (vl_api_get_node_index_reply_t * mp)
1114 vat_main_t *vam = &vat_main;
1115 i32 retval = ntohl (mp->retval);
1116 if (vam->async_mode)
1118 vam->async_errors += (retval < 0);
1122 vam->retval = retval;
1124 errmsg ("node index %d", ntohl (mp->node_index));
1125 vam->result_ready = 1;
1129 static void vl_api_get_node_index_reply_t_handler_json
1130 (vl_api_get_node_index_reply_t * mp)
1132 vat_main_t *vam = &vat_main;
1133 vat_json_node_t node;
1135 vat_json_init_object (&node);
1136 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1137 vat_json_object_add_uint (&node, "node_index", ntohl (mp->node_index));
1139 vat_json_print (vam->ofp, &node);
1140 vat_json_free (&node);
1142 vam->retval = ntohl (mp->retval);
1143 vam->result_ready = 1;
1146 static void vl_api_get_next_index_reply_t_handler
1147 (vl_api_get_next_index_reply_t * mp)
1149 vat_main_t *vam = &vat_main;
1150 i32 retval = ntohl (mp->retval);
1151 if (vam->async_mode)
1153 vam->async_errors += (retval < 0);
1157 vam->retval = retval;
1159 errmsg ("next node index %d", ntohl (mp->next_index));
1160 vam->result_ready = 1;
1164 static void vl_api_get_next_index_reply_t_handler_json
1165 (vl_api_get_next_index_reply_t * mp)
1167 vat_main_t *vam = &vat_main;
1168 vat_json_node_t node;
1170 vat_json_init_object (&node);
1171 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1172 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1174 vat_json_print (vam->ofp, &node);
1175 vat_json_free (&node);
1177 vam->retval = ntohl (mp->retval);
1178 vam->result_ready = 1;
1181 static void vl_api_add_node_next_reply_t_handler
1182 (vl_api_add_node_next_reply_t * mp)
1184 vat_main_t *vam = &vat_main;
1185 i32 retval = ntohl (mp->retval);
1186 if (vam->async_mode)
1188 vam->async_errors += (retval < 0);
1192 vam->retval = retval;
1194 errmsg ("next index %d", ntohl (mp->next_index));
1195 vam->result_ready = 1;
1199 static void vl_api_add_node_next_reply_t_handler_json
1200 (vl_api_add_node_next_reply_t * mp)
1202 vat_main_t *vam = &vat_main;
1203 vat_json_node_t node;
1205 vat_json_init_object (&node);
1206 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1207 vat_json_object_add_uint (&node, "next_index", ntohl (mp->next_index));
1209 vat_json_print (vam->ofp, &node);
1210 vat_json_free (&node);
1212 vam->retval = ntohl (mp->retval);
1213 vam->result_ready = 1;
1216 static void vl_api_show_version_reply_t_handler
1217 (vl_api_show_version_reply_t * mp)
1219 vat_main_t *vam = &vat_main;
1220 i32 retval = ntohl (mp->retval);
1224 errmsg (" program: %s", mp->program);
1225 errmsg (" version: %s", mp->version);
1226 errmsg (" build date: %s", mp->build_date);
1227 errmsg ("build directory: %s", mp->build_directory);
1229 vam->retval = retval;
1230 vam->result_ready = 1;
1233 static void vl_api_show_version_reply_t_handler_json
1234 (vl_api_show_version_reply_t * mp)
1236 vat_main_t *vam = &vat_main;
1237 vat_json_node_t node;
1239 vat_json_init_object (&node);
1240 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1241 vat_json_object_add_string_copy (&node, "program", mp->program);
1242 vat_json_object_add_string_copy (&node, "version", mp->version);
1243 vat_json_object_add_string_copy (&node, "build_date", mp->build_date);
1244 vat_json_object_add_string_copy (&node, "build_directory",
1245 mp->build_directory);
1247 vat_json_print (vam->ofp, &node);
1248 vat_json_free (&node);
1250 vam->retval = ntohl (mp->retval);
1251 vam->result_ready = 1;
1255 vl_api_ip4_arp_event_t_handler (vl_api_ip4_arp_event_t * mp)
1257 u32 sw_if_index = ntohl (mp->sw_if_index);
1258 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1259 mp->mac_ip ? "mac/ip binding" : "address resolution",
1260 format_ip4_address, &mp->address,
1261 format_ethernet_address, mp->new_mac, sw_if_index);
1265 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1267 /* JSON output not supported */
1271 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1273 u32 sw_if_index = ntohl (mp->sw_if_index);
1274 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1275 mp->mac_ip ? "mac/ip binding" : "address resolution",
1276 format_ip6_address, mp->address,
1277 format_ethernet_address, mp->new_mac, sw_if_index);
1281 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1283 /* JSON output not supported */
1287 * Special-case: build the bridge domain table, maintain
1288 * the next bd id vbl.
1290 static void vl_api_bridge_domain_details_t_handler
1291 (vl_api_bridge_domain_details_t * mp)
1293 vat_main_t *vam = &vat_main;
1294 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1296 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1297 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1299 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1300 ntohl (mp->bd_id), mp->learn, mp->forward,
1301 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1304 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1307 static void vl_api_bridge_domain_details_t_handler_json
1308 (vl_api_bridge_domain_details_t * mp)
1310 vat_main_t *vam = &vat_main;
1311 vat_json_node_t *node, *array = NULL;
1313 if (VAT_JSON_ARRAY != vam->json_tree.type)
1315 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1316 vat_json_init_array (&vam->json_tree);
1318 node = vat_json_array_add (&vam->json_tree);
1320 vat_json_init_object (node);
1321 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1322 vat_json_object_add_uint (node, "flood", mp->flood);
1323 vat_json_object_add_uint (node, "forward", mp->forward);
1324 vat_json_object_add_uint (node, "learn", mp->learn);
1325 vat_json_object_add_uint (node, "bvi_sw_if_index",
1326 ntohl (mp->bvi_sw_if_index));
1327 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1328 array = vat_json_object_add (node, "sw_if");
1329 vat_json_init_array (array);
1333 * Special-case: build the bridge domain sw if table.
1335 static void vl_api_bridge_domain_sw_if_details_t_handler
1336 (vl_api_bridge_domain_sw_if_details_t * mp)
1338 vat_main_t *vam = &vat_main;
1343 sw_if_index = ntohl (mp->sw_if_index);
1345 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1347 if ((u32) p->value[0] == sw_if_index)
1349 sw_if_name = (u8 *)(p->key);
1355 print (vam->ofp, "%7d %3d %s", sw_if_index,
1356 mp->shg, sw_if_name ? (char *) sw_if_name :
1357 "sw_if_index not found!");
1360 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1361 (vl_api_bridge_domain_sw_if_details_t * mp)
1363 vat_main_t *vam = &vat_main;
1364 vat_json_node_t *node = NULL;
1365 uword last_index = 0;
1367 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1368 ASSERT (vec_len (vam->json_tree.array) >= 1);
1369 last_index = vec_len (vam->json_tree.array) - 1;
1370 node = &vam->json_tree.array[last_index];
1371 node = vat_json_object_get_element (node, "sw_if");
1372 ASSERT (NULL != node);
1373 node = vat_json_array_add (node);
1375 vat_json_init_object (node);
1376 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1377 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1378 vat_json_object_add_uint (node, "shg", mp->shg);
1381 static void vl_api_control_ping_reply_t_handler
1382 (vl_api_control_ping_reply_t * mp)
1384 vat_main_t *vam = &vat_main;
1385 i32 retval = ntohl (mp->retval);
1386 if (vam->async_mode)
1388 vam->async_errors += (retval < 0);
1392 vam->retval = retval;
1393 vam->result_ready = 1;
1397 static void vl_api_control_ping_reply_t_handler_json
1398 (vl_api_control_ping_reply_t * mp)
1400 vat_main_t *vam = &vat_main;
1401 i32 retval = ntohl (mp->retval);
1403 if (VAT_JSON_NONE != vam->json_tree.type)
1405 vat_json_print (vam->ofp, &vam->json_tree);
1406 vat_json_free (&vam->json_tree);
1407 vam->json_tree.type = VAT_JSON_NONE;
1412 vat_json_init_array (&vam->json_tree);
1413 vat_json_print (vam->ofp, &vam->json_tree);
1414 vam->json_tree.type = VAT_JSON_NONE;
1417 vam->retval = retval;
1418 vam->result_ready = 1;
1422 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1424 vat_main_t *vam = &vat_main;
1425 i32 retval = ntohl (mp->retval);
1426 if (vam->async_mode)
1428 vam->async_errors += (retval < 0);
1432 vam->retval = retval;
1433 vam->result_ready = 1;
1437 static void vl_api_l2_flags_reply_t_handler_json
1438 (vl_api_l2_flags_reply_t * mp)
1440 vat_main_t *vam = &vat_main;
1441 vat_json_node_t node;
1443 vat_json_init_object (&node);
1444 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1445 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1446 ntohl (mp->resulting_feature_bitmap));
1448 vat_json_print (vam->ofp, &node);
1449 vat_json_free (&node);
1451 vam->retval = ntohl (mp->retval);
1452 vam->result_ready = 1;
1455 static void vl_api_bridge_flags_reply_t_handler
1456 (vl_api_bridge_flags_reply_t * mp)
1458 vat_main_t *vam = &vat_main;
1459 i32 retval = ntohl (mp->retval);
1460 if (vam->async_mode)
1462 vam->async_errors += (retval < 0);
1466 vam->retval = retval;
1467 vam->result_ready = 1;
1471 static void vl_api_bridge_flags_reply_t_handler_json
1472 (vl_api_bridge_flags_reply_t * mp)
1474 vat_main_t *vam = &vat_main;
1475 vat_json_node_t node;
1477 vat_json_init_object (&node);
1478 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1479 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1480 ntohl (mp->resulting_feature_bitmap));
1482 vat_json_print (vam->ofp, &node);
1483 vat_json_free (&node);
1485 vam->retval = ntohl (mp->retval);
1486 vam->result_ready = 1;
1489 static void vl_api_tap_connect_reply_t_handler
1490 (vl_api_tap_connect_reply_t * mp)
1492 vat_main_t *vam = &vat_main;
1493 i32 retval = ntohl (mp->retval);
1494 if (vam->async_mode)
1496 vam->async_errors += (retval < 0);
1500 vam->retval = retval;
1501 vam->sw_if_index = ntohl (mp->sw_if_index);
1502 vam->result_ready = 1;
1507 static void vl_api_tap_connect_reply_t_handler_json
1508 (vl_api_tap_connect_reply_t * mp)
1510 vat_main_t *vam = &vat_main;
1511 vat_json_node_t node;
1513 vat_json_init_object (&node);
1514 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1515 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1517 vat_json_print (vam->ofp, &node);
1518 vat_json_free (&node);
1520 vam->retval = ntohl (mp->retval);
1521 vam->result_ready = 1;
1526 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1528 vat_main_t *vam = &vat_main;
1529 i32 retval = ntohl (mp->retval);
1530 if (vam->async_mode)
1532 vam->async_errors += (retval < 0);
1536 vam->retval = retval;
1537 vam->sw_if_index = ntohl (mp->sw_if_index);
1538 vam->result_ready = 1;
1542 static void vl_api_tap_modify_reply_t_handler_json
1543 (vl_api_tap_modify_reply_t * mp)
1545 vat_main_t *vam = &vat_main;
1546 vat_json_node_t node;
1548 vat_json_init_object (&node);
1549 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1550 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1552 vat_json_print (vam->ofp, &node);
1553 vat_json_free (&node);
1555 vam->retval = ntohl (mp->retval);
1556 vam->result_ready = 1;
1560 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1562 vat_main_t *vam = &vat_main;
1563 i32 retval = ntohl (mp->retval);
1564 if (vam->async_mode)
1566 vam->async_errors += (retval < 0);
1570 vam->retval = retval;
1571 vam->result_ready = 1;
1575 static void vl_api_tap_delete_reply_t_handler_json
1576 (vl_api_tap_delete_reply_t * mp)
1578 vat_main_t *vam = &vat_main;
1579 vat_json_node_t node;
1581 vat_json_init_object (&node);
1582 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1584 vat_json_print (vam->ofp, &node);
1585 vat_json_free (&node);
1587 vam->retval = ntohl (mp->retval);
1588 vam->result_ready = 1;
1591 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1592 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1594 vat_main_t *vam = &vat_main;
1595 i32 retval = ntohl (mp->retval);
1596 if (vam->async_mode)
1598 vam->async_errors += (retval < 0);
1602 vam->retval = retval;
1603 vam->result_ready = 1;
1607 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1608 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1610 vat_main_t *vam = &vat_main;
1611 vat_json_node_t node;
1613 vat_json_init_object (&node);
1614 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1615 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1616 ntohl (mp->sw_if_index));
1618 vat_json_print (vam->ofp, &node);
1619 vat_json_free (&node);
1621 vam->retval = ntohl (mp->retval);
1622 vam->result_ready = 1;
1625 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1626 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1628 vat_main_t *vam = &vat_main;
1629 i32 retval = ntohl (mp->retval);
1630 if (vam->async_mode)
1632 vam->async_errors += (retval < 0);
1636 vam->retval = retval;
1637 vam->sw_if_index = ntohl (mp->sw_if_index);
1638 vam->result_ready = 1;
1642 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1643 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1645 vat_main_t *vam = &vat_main;
1646 vat_json_node_t node;
1648 vat_json_init_object (&node);
1649 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1650 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1652 vat_json_print (vam->ofp, &node);
1653 vat_json_free (&node);
1655 vam->retval = ntohl (mp->retval);
1656 vam->result_ready = 1;
1660 static void vl_api_one_add_del_locator_set_reply_t_handler
1661 (vl_api_one_add_del_locator_set_reply_t * mp)
1663 vat_main_t *vam = &vat_main;
1664 i32 retval = ntohl (mp->retval);
1665 if (vam->async_mode)
1667 vam->async_errors += (retval < 0);
1671 vam->retval = retval;
1672 vam->result_ready = 1;
1676 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1677 (vl_api_one_add_del_locator_set_reply_t * mp)
1679 vat_main_t *vam = &vat_main;
1680 vat_json_node_t node;
1682 vat_json_init_object (&node);
1683 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1684 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1686 vat_json_print (vam->ofp, &node);
1687 vat_json_free (&node);
1689 vam->retval = ntohl (mp->retval);
1690 vam->result_ready = 1;
1693 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1694 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1696 vat_main_t *vam = &vat_main;
1697 i32 retval = ntohl (mp->retval);
1698 if (vam->async_mode)
1700 vam->async_errors += (retval < 0);
1704 vam->retval = retval;
1705 vam->sw_if_index = ntohl (mp->sw_if_index);
1706 vam->result_ready = 1;
1710 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1711 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1713 vat_main_t *vam = &vat_main;
1714 vat_json_node_t node;
1716 vat_json_init_object (&node);
1717 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1718 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1720 vat_json_print (vam->ofp, &node);
1721 vat_json_free (&node);
1723 vam->retval = ntohl (mp->retval);
1724 vam->result_ready = 1;
1727 static void vl_api_gre_add_del_tunnel_reply_t_handler
1728 (vl_api_gre_add_del_tunnel_reply_t * mp)
1730 vat_main_t *vam = &vat_main;
1731 i32 retval = ntohl (mp->retval);
1732 if (vam->async_mode)
1734 vam->async_errors += (retval < 0);
1738 vam->retval = retval;
1739 vam->sw_if_index = ntohl (mp->sw_if_index);
1740 vam->result_ready = 1;
1744 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1745 (vl_api_gre_add_del_tunnel_reply_t * mp)
1747 vat_main_t *vam = &vat_main;
1748 vat_json_node_t node;
1750 vat_json_init_object (&node);
1751 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1752 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1754 vat_json_print (vam->ofp, &node);
1755 vat_json_free (&node);
1757 vam->retval = ntohl (mp->retval);
1758 vam->result_ready = 1;
1761 static void vl_api_create_vhost_user_if_reply_t_handler
1762 (vl_api_create_vhost_user_if_reply_t * mp)
1764 vat_main_t *vam = &vat_main;
1765 i32 retval = ntohl (mp->retval);
1766 if (vam->async_mode)
1768 vam->async_errors += (retval < 0);
1772 vam->retval = retval;
1773 vam->sw_if_index = ntohl (mp->sw_if_index);
1774 vam->result_ready = 1;
1778 static void vl_api_create_vhost_user_if_reply_t_handler_json
1779 (vl_api_create_vhost_user_if_reply_t * mp)
1781 vat_main_t *vam = &vat_main;
1782 vat_json_node_t node;
1784 vat_json_init_object (&node);
1785 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1786 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1788 vat_json_print (vam->ofp, &node);
1789 vat_json_free (&node);
1791 vam->retval = ntohl (mp->retval);
1792 vam->result_ready = 1;
1795 static void vl_api_ip_address_details_t_handler
1796 (vl_api_ip_address_details_t * mp)
1798 vat_main_t *vam = &vat_main;
1799 static ip_address_details_t empty_ip_address_details = { {0} };
1800 ip_address_details_t *address = NULL;
1801 ip_details_t *current_ip_details = NULL;
1802 ip_details_t *details = NULL;
1804 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1806 if (!details || vam->current_sw_if_index >= vec_len (details)
1807 || !details[vam->current_sw_if_index].present)
1809 errmsg ("ip address details arrived but not stored");
1810 errmsg ("ip_dump should be called first");
1814 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1816 #define addresses (current_ip_details->addr)
1818 vec_validate_init_empty (addresses, vec_len (addresses),
1819 empty_ip_address_details);
1821 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1823 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1824 address->prefix_length = mp->prefix_length;
1828 static void vl_api_ip_address_details_t_handler_json
1829 (vl_api_ip_address_details_t * mp)
1831 vat_main_t *vam = &vat_main;
1832 vat_json_node_t *node = NULL;
1833 struct in6_addr ip6;
1836 if (VAT_JSON_ARRAY != vam->json_tree.type)
1838 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1839 vat_json_init_array (&vam->json_tree);
1841 node = vat_json_array_add (&vam->json_tree);
1843 vat_json_init_object (node);
1846 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1847 vat_json_object_add_ip6 (node, "ip", ip6);
1851 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1852 vat_json_object_add_ip4 (node, "ip", ip4);
1854 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1858 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1860 vat_main_t *vam = &vat_main;
1861 static ip_details_t empty_ip_details = { 0 };
1862 ip_details_t *ip = NULL;
1863 u32 sw_if_index = ~0;
1865 sw_if_index = ntohl (mp->sw_if_index);
1867 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1868 sw_if_index, empty_ip_details);
1870 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1877 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1879 vat_main_t *vam = &vat_main;
1881 if (VAT_JSON_ARRAY != vam->json_tree.type)
1883 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1884 vat_json_init_array (&vam->json_tree);
1886 vat_json_array_add_uint (&vam->json_tree,
1887 clib_net_to_host_u32 (mp->sw_if_index));
1890 static void vl_api_map_domain_details_t_handler_json
1891 (vl_api_map_domain_details_t * mp)
1893 vat_json_node_t *node = NULL;
1894 vat_main_t *vam = &vat_main;
1895 struct in6_addr ip6;
1898 if (VAT_JSON_ARRAY != vam->json_tree.type)
1900 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1901 vat_json_init_array (&vam->json_tree);
1904 node = vat_json_array_add (&vam->json_tree);
1905 vat_json_init_object (node);
1907 vat_json_object_add_uint (node, "domain_index",
1908 clib_net_to_host_u32 (mp->domain_index));
1909 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1910 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1911 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1912 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1913 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1914 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1915 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1916 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1917 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1918 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1919 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1920 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1921 vat_json_object_add_uint (node, "flags", mp->flags);
1922 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1923 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1926 static void vl_api_map_domain_details_t_handler
1927 (vl_api_map_domain_details_t * mp)
1929 vat_main_t *vam = &vat_main;
1931 if (mp->is_translation)
1934 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1935 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1936 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1937 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1938 clib_net_to_host_u32 (mp->domain_index));
1943 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1944 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1945 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1946 format_ip6_address, mp->ip6_src,
1947 clib_net_to_host_u32 (mp->domain_index));
1949 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1950 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1951 mp->is_translation ? "map-t" : "");
1954 static void vl_api_map_rule_details_t_handler_json
1955 (vl_api_map_rule_details_t * mp)
1957 struct in6_addr ip6;
1958 vat_json_node_t *node = NULL;
1959 vat_main_t *vam = &vat_main;
1961 if (VAT_JSON_ARRAY != vam->json_tree.type)
1963 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1964 vat_json_init_array (&vam->json_tree);
1967 node = vat_json_array_add (&vam->json_tree);
1968 vat_json_init_object (node);
1970 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1971 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1972 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1976 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1978 vat_main_t *vam = &vat_main;
1979 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1980 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1984 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1986 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1987 "router_addr %U host_mac %U",
1988 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1989 format_ip4_address, &mp->host_address,
1990 format_ip4_address, &mp->router_address,
1991 format_ethernet_address, mp->host_mac);
1994 static void vl_api_dhcp_compl_event_t_handler_json
1995 (vl_api_dhcp_compl_event_t * mp)
1997 /* JSON output not supported */
2001 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2004 vat_main_t *vam = &vat_main;
2005 static u64 default_counter = 0;
2007 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2009 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2010 sw_if_index, default_counter);
2011 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2015 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2016 interface_counter_t counter)
2018 vat_main_t *vam = &vat_main;
2019 static interface_counter_t default_counter = { 0, };
2021 vec_validate_init_empty (vam->combined_interface_counters,
2022 vnet_counter_type, NULL);
2023 vec_validate_init_empty (vam->combined_interface_counters
2024 [vnet_counter_type], sw_if_index, default_counter);
2025 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2028 static void vl_api_vnet_interface_counters_t_handler
2029 (vl_api_vnet_interface_counters_t * mp)
2034 static void vl_api_vnet_interface_counters_t_handler_json
2035 (vl_api_vnet_interface_counters_t * mp)
2037 interface_counter_t counter;
2042 u32 first_sw_if_index;
2045 count = ntohl (mp->count);
2046 first_sw_if_index = ntohl (mp->first_sw_if_index);
2048 if (!mp->is_combined)
2050 v_packets = (u64 *) & mp->data;
2051 for (i = 0; i < count; i++)
2054 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2055 set_simple_interface_counter (mp->vnet_counter_type,
2056 first_sw_if_index + i, packets);
2062 v = (vlib_counter_t *) & mp->data;
2063 for (i = 0; i < count; i++)
2066 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2068 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2069 set_combined_interface_counter (mp->vnet_counter_type,
2070 first_sw_if_index + i, counter);
2077 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2079 vat_main_t *vam = &vat_main;
2082 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2084 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2093 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2095 vat_main_t *vam = &vat_main;
2098 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2100 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2108 static void vl_api_vnet_ip4_fib_counters_t_handler
2109 (vl_api_vnet_ip4_fib_counters_t * mp)
2114 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2115 (vl_api_vnet_ip4_fib_counters_t * mp)
2117 vat_main_t *vam = &vat_main;
2118 vl_api_ip4_fib_counter_t *v;
2119 ip4_fib_counter_t *counter;
2126 vrf_id = ntohl (mp->vrf_id);
2127 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2128 if (~0 == vrf_index)
2130 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2131 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2132 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2133 vec_validate (vam->ip4_fib_counters, vrf_index);
2134 vam->ip4_fib_counters[vrf_index] = NULL;
2137 vec_free (vam->ip4_fib_counters[vrf_index]);
2138 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2139 count = ntohl (mp->count);
2140 for (i = 0; i < count; i++)
2142 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2143 counter = &vam->ip4_fib_counters[vrf_index][i];
2144 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2145 counter->address = ip4;
2146 counter->address_length = v->address_length;
2147 counter->packets = clib_net_to_host_u64 (v->packets);
2148 counter->bytes = clib_net_to_host_u64 (v->bytes);
2153 static void vl_api_vnet_ip4_nbr_counters_t_handler
2154 (vl_api_vnet_ip4_nbr_counters_t * mp)
2159 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2160 (vl_api_vnet_ip4_nbr_counters_t * mp)
2162 vat_main_t *vam = &vat_main;
2163 vl_api_ip4_nbr_counter_t *v;
2164 ip4_nbr_counter_t *counter;
2169 sw_if_index = ntohl (mp->sw_if_index);
2170 count = ntohl (mp->count);
2171 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2174 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2176 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2177 for (i = 0; i < count; i++)
2179 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2180 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2181 counter->address.s_addr = v->address;
2182 counter->packets = clib_net_to_host_u64 (v->packets);
2183 counter->bytes = clib_net_to_host_u64 (v->bytes);
2184 counter->linkt = v->link_type;
2189 static void vl_api_vnet_ip6_fib_counters_t_handler
2190 (vl_api_vnet_ip6_fib_counters_t * mp)
2195 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2196 (vl_api_vnet_ip6_fib_counters_t * mp)
2198 vat_main_t *vam = &vat_main;
2199 vl_api_ip6_fib_counter_t *v;
2200 ip6_fib_counter_t *counter;
2201 struct in6_addr ip6;
2207 vrf_id = ntohl (mp->vrf_id);
2208 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2209 if (~0 == vrf_index)
2211 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2212 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2213 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2214 vec_validate (vam->ip6_fib_counters, vrf_index);
2215 vam->ip6_fib_counters[vrf_index] = NULL;
2218 vec_free (vam->ip6_fib_counters[vrf_index]);
2219 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2220 count = ntohl (mp->count);
2221 for (i = 0; i < count; i++)
2223 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2224 counter = &vam->ip6_fib_counters[vrf_index][i];
2225 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2226 counter->address = ip6;
2227 counter->address_length = v->address_length;
2228 counter->packets = clib_net_to_host_u64 (v->packets);
2229 counter->bytes = clib_net_to_host_u64 (v->bytes);
2234 static void vl_api_vnet_ip6_nbr_counters_t_handler
2235 (vl_api_vnet_ip6_nbr_counters_t * mp)
2240 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2241 (vl_api_vnet_ip6_nbr_counters_t * mp)
2243 vat_main_t *vam = &vat_main;
2244 vl_api_ip6_nbr_counter_t *v;
2245 ip6_nbr_counter_t *counter;
2246 struct in6_addr ip6;
2251 sw_if_index = ntohl (mp->sw_if_index);
2252 count = ntohl (mp->count);
2253 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2256 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2258 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2259 for (i = 0; i < count; i++)
2261 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2262 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2263 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2264 counter->address = ip6;
2265 counter->packets = clib_net_to_host_u64 (v->packets);
2266 counter->bytes = clib_net_to_host_u64 (v->bytes);
2271 static void vl_api_get_first_msg_id_reply_t_handler
2272 (vl_api_get_first_msg_id_reply_t * mp)
2274 vat_main_t *vam = &vat_main;
2275 i32 retval = ntohl (mp->retval);
2277 if (vam->async_mode)
2279 vam->async_errors += (retval < 0);
2283 vam->retval = retval;
2284 vam->result_ready = 1;
2288 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2292 static void vl_api_get_first_msg_id_reply_t_handler_json
2293 (vl_api_get_first_msg_id_reply_t * mp)
2295 vat_main_t *vam = &vat_main;
2296 vat_json_node_t node;
2298 vat_json_init_object (&node);
2299 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2300 vat_json_object_add_uint (&node, "first_msg_id",
2301 (uint) ntohs (mp->first_msg_id));
2303 vat_json_print (vam->ofp, &node);
2304 vat_json_free (&node);
2306 vam->retval = ntohl (mp->retval);
2307 vam->result_ready = 1;
2310 static void vl_api_get_node_graph_reply_t_handler
2311 (vl_api_get_node_graph_reply_t * mp)
2313 vat_main_t *vam = &vat_main;
2314 api_main_t *am = &api_main;
2315 i32 retval = ntohl (mp->retval);
2316 u8 *pvt_copy, *reply;
2321 if (vam->async_mode)
2323 vam->async_errors += (retval < 0);
2327 vam->retval = retval;
2328 vam->result_ready = 1;
2331 /* "Should never happen..." */
2335 reply = (u8 *) (mp->reply_in_shmem);
2336 pvt_copy = vec_dup (reply);
2338 /* Toss the shared-memory original... */
2339 pthread_mutex_lock (&am->vlib_rp->mutex);
2340 oldheap = svm_push_data_heap (am->vlib_rp);
2344 svm_pop_heap (oldheap);
2345 pthread_mutex_unlock (&am->vlib_rp->mutex);
2347 if (vam->graph_nodes)
2349 hash_free (vam->graph_node_index_by_name);
2351 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2353 node = vam->graph_nodes[i];
2354 vec_free (node->name);
2355 vec_free (node->next_nodes);
2358 vec_free (vam->graph_nodes);
2361 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2362 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2363 vec_free (pvt_copy);
2365 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2367 node = vam->graph_nodes[i];
2368 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2372 static void vl_api_get_node_graph_reply_t_handler_json
2373 (vl_api_get_node_graph_reply_t * mp)
2375 vat_main_t *vam = &vat_main;
2376 api_main_t *am = &api_main;
2378 vat_json_node_t node;
2381 /* $$$$ make this real? */
2382 vat_json_init_object (&node);
2383 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2384 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2386 reply = (u8 *) (mp->reply_in_shmem);
2388 /* Toss the shared-memory original... */
2389 pthread_mutex_lock (&am->vlib_rp->mutex);
2390 oldheap = svm_push_data_heap (am->vlib_rp);
2394 svm_pop_heap (oldheap);
2395 pthread_mutex_unlock (&am->vlib_rp->mutex);
2397 vat_json_print (vam->ofp, &node);
2398 vat_json_free (&node);
2400 vam->retval = ntohl (mp->retval);
2401 vam->result_ready = 1;
2405 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2407 vat_main_t *vam = &vat_main;
2412 s = format (s, "%=16d%=16d%=16d",
2413 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2417 s = format (s, "%=16U%=16d%=16d",
2418 mp->is_ipv6 ? format_ip6_address :
2420 mp->ip_address, mp->priority, mp->weight);
2423 print (vam->ofp, "%v", s);
2428 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2430 vat_main_t *vam = &vat_main;
2431 vat_json_node_t *node = NULL;
2432 struct in6_addr ip6;
2435 if (VAT_JSON_ARRAY != vam->json_tree.type)
2437 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2438 vat_json_init_array (&vam->json_tree);
2440 node = vat_json_array_add (&vam->json_tree);
2441 vat_json_init_object (node);
2443 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2444 vat_json_object_add_uint (node, "priority", mp->priority);
2445 vat_json_object_add_uint (node, "weight", mp->weight);
2448 vat_json_object_add_uint (node, "sw_if_index",
2449 clib_net_to_host_u32 (mp->sw_if_index));
2454 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2455 vat_json_object_add_ip6 (node, "address", ip6);
2459 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2460 vat_json_object_add_ip4 (node, "address", ip4);
2466 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2469 vat_main_t *vam = &vat_main;
2472 ls_name = format (0, "%s", mp->ls_name);
2474 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2480 vl_api_one_locator_set_details_t_handler_json
2481 (vl_api_one_locator_set_details_t * mp)
2483 vat_main_t *vam = &vat_main;
2484 vat_json_node_t *node = 0;
2487 ls_name = format (0, "%s", mp->ls_name);
2488 vec_add1 (ls_name, 0);
2490 if (VAT_JSON_ARRAY != vam->json_tree.type)
2492 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2493 vat_json_init_array (&vam->json_tree);
2495 node = vat_json_array_add (&vam->json_tree);
2497 vat_json_init_object (node);
2498 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2499 vat_json_object_add_uint (node, "ls_index",
2500 clib_net_to_host_u32 (mp->ls_index));
2505 format_lisp_flat_eid (u8 * s, va_list * args)
2507 u32 type = va_arg (*args, u32);
2508 u8 *eid = va_arg (*args, u8 *);
2509 u32 eid_len = va_arg (*args, u32);
2514 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2516 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2518 return format (s, "%U", format_ethernet_address, eid);
2524 format_lisp_eid_vat (u8 * s, va_list * args)
2526 u32 type = va_arg (*args, u32);
2527 u8 *eid = va_arg (*args, u8 *);
2528 u32 eid_len = va_arg (*args, u32);
2529 u8 *seid = va_arg (*args, u8 *);
2530 u32 seid_len = va_arg (*args, u32);
2531 u32 is_src_dst = va_arg (*args, u32);
2534 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2536 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2542 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2544 vat_main_t *vam = &vat_main;
2545 u8 *s = 0, *eid = 0;
2547 if (~0 == mp->locator_set_index)
2548 s = format (0, "action: %d", mp->action);
2550 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2552 eid = format (0, "%U", format_lisp_eid_vat,
2556 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2559 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2560 clib_net_to_host_u32 (mp->vni),
2562 mp->is_local ? "local" : "remote",
2563 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2564 clib_net_to_host_u16 (mp->key_id), mp->key);
2571 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2574 vat_main_t *vam = &vat_main;
2575 vat_json_node_t *node = 0;
2578 if (VAT_JSON_ARRAY != vam->json_tree.type)
2580 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2581 vat_json_init_array (&vam->json_tree);
2583 node = vat_json_array_add (&vam->json_tree);
2585 vat_json_init_object (node);
2586 if (~0 == mp->locator_set_index)
2587 vat_json_object_add_uint (node, "action", mp->action);
2589 vat_json_object_add_uint (node, "locator_set_index",
2590 clib_net_to_host_u32 (mp->locator_set_index));
2592 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2593 eid = format (0, "%U", format_lisp_eid_vat,
2597 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2599 vat_json_object_add_string_copy (node, "eid", eid);
2600 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2601 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2602 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2606 vat_json_object_add_uint (node, "key_id",
2607 clib_net_to_host_u16 (mp->key_id));
2608 vat_json_object_add_string_copy (node, "key", mp->key);
2614 vl_api_one_eid_table_map_details_t_handler
2615 (vl_api_one_eid_table_map_details_t * mp)
2617 vat_main_t *vam = &vat_main;
2619 u8 *line = format (0, "%=10d%=10d",
2620 clib_net_to_host_u32 (mp->vni),
2621 clib_net_to_host_u32 (mp->dp_table));
2622 print (vam->ofp, "%v", line);
2627 vl_api_one_eid_table_map_details_t_handler_json
2628 (vl_api_one_eid_table_map_details_t * mp)
2630 vat_main_t *vam = &vat_main;
2631 vat_json_node_t *node = NULL;
2633 if (VAT_JSON_ARRAY != vam->json_tree.type)
2635 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2636 vat_json_init_array (&vam->json_tree);
2638 node = vat_json_array_add (&vam->json_tree);
2639 vat_json_init_object (node);
2640 vat_json_object_add_uint (node, "dp_table",
2641 clib_net_to_host_u32 (mp->dp_table));
2642 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2646 vl_api_one_eid_table_vni_details_t_handler
2647 (vl_api_one_eid_table_vni_details_t * mp)
2649 vat_main_t *vam = &vat_main;
2651 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2652 print (vam->ofp, "%v", line);
2657 vl_api_one_eid_table_vni_details_t_handler_json
2658 (vl_api_one_eid_table_vni_details_t * mp)
2660 vat_main_t *vam = &vat_main;
2661 vat_json_node_t *node = NULL;
2663 if (VAT_JSON_ARRAY != vam->json_tree.type)
2665 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2666 vat_json_init_array (&vam->json_tree);
2668 node = vat_json_array_add (&vam->json_tree);
2669 vat_json_init_object (node);
2670 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2674 vl_api_show_one_map_register_state_reply_t_handler
2675 (vl_api_show_one_map_register_state_reply_t * mp)
2677 vat_main_t *vam = &vat_main;
2678 int retval = clib_net_to_host_u32 (mp->retval);
2680 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2682 vam->retval = retval;
2683 vam->result_ready = 1;
2687 vl_api_show_one_map_register_state_reply_t_handler_json
2688 (vl_api_show_one_map_register_state_reply_t * mp)
2690 vat_main_t *vam = &vat_main;
2691 vat_json_node_t _node, *node = &_node;
2692 int retval = clib_net_to_host_u32 (mp->retval);
2694 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2696 vat_json_init_object (node);
2697 vat_json_object_add_string_copy (node, "state", s);
2699 vat_json_print (vam->ofp, node);
2700 vat_json_free (node);
2702 vam->retval = retval;
2703 vam->result_ready = 1;
2708 vl_api_show_one_rloc_probe_state_reply_t_handler
2709 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2711 vat_main_t *vam = &vat_main;
2712 int retval = clib_net_to_host_u32 (mp->retval);
2717 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2719 vam->retval = retval;
2720 vam->result_ready = 1;
2724 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2725 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2727 vat_main_t *vam = &vat_main;
2728 vat_json_node_t _node, *node = &_node;
2729 int retval = clib_net_to_host_u32 (mp->retval);
2731 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2732 vat_json_init_object (node);
2733 vat_json_object_add_string_copy (node, "state", s);
2735 vat_json_print (vam->ofp, node);
2736 vat_json_free (node);
2738 vam->retval = retval;
2739 vam->result_ready = 1;
2744 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2746 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2747 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2751 gpe_fwd_entries_get_reply_t_net_to_host
2752 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2756 mp->count = clib_net_to_host_u32 (mp->count);
2757 for (i = 0; i < mp->count; i++)
2759 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2764 format_gpe_encap_mode (u8 * s, va_list * args)
2766 u32 mode = va_arg (*args, u32);
2771 return format (s, "lisp");
2773 return format (s, "vxlan");
2779 vl_api_gpe_get_encap_mode_reply_t_handler
2780 (vl_api_gpe_get_encap_mode_reply_t * mp)
2782 vat_main_t *vam = &vat_main;
2784 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2785 vam->retval = ntohl (mp->retval);
2786 vam->result_ready = 1;
2790 vl_api_gpe_get_encap_mode_reply_t_handler_json
2791 (vl_api_gpe_get_encap_mode_reply_t * mp)
2793 vat_main_t *vam = &vat_main;
2794 vat_json_node_t node;
2796 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2797 vec_add1 (encap_mode, 0);
2799 vat_json_init_object (&node);
2800 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2802 vec_free (encap_mode);
2803 vat_json_print (vam->ofp, &node);
2804 vat_json_free (&node);
2806 vam->retval = ntohl (mp->retval);
2807 vam->result_ready = 1;
2811 vl_api_gpe_fwd_entry_path_details_t_handler
2812 (vl_api_gpe_fwd_entry_path_details_t * mp)
2814 vat_main_t *vam = &vat_main;
2815 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2817 if (mp->lcl_loc.is_ip4)
2818 format_ip_address_fcn = format_ip4_address;
2820 format_ip_address_fcn = format_ip6_address;
2822 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2823 format_ip_address_fcn, &mp->lcl_loc,
2824 format_ip_address_fcn, &mp->rmt_loc);
2828 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2830 struct in6_addr ip6;
2835 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2836 vat_json_object_add_ip4 (n, "address", ip4);
2840 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2841 vat_json_object_add_ip6 (n, "address", ip6);
2843 vat_json_object_add_uint (n, "weight", loc->weight);
2847 vl_api_gpe_fwd_entry_path_details_t_handler_json
2848 (vl_api_gpe_fwd_entry_path_details_t * mp)
2850 vat_main_t *vam = &vat_main;
2851 vat_json_node_t *node = NULL;
2852 vat_json_node_t *loc_node;
2854 if (VAT_JSON_ARRAY != vam->json_tree.type)
2856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2857 vat_json_init_array (&vam->json_tree);
2859 node = vat_json_array_add (&vam->json_tree);
2860 vat_json_init_object (node);
2862 loc_node = vat_json_object_add (node, "local_locator");
2863 vat_json_init_object (loc_node);
2864 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2866 loc_node = vat_json_object_add (node, "remote_locator");
2867 vat_json_init_object (loc_node);
2868 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2872 vl_api_gpe_fwd_entries_get_reply_t_handler
2873 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2875 vat_main_t *vam = &vat_main;
2877 int retval = clib_net_to_host_u32 (mp->retval);
2878 vl_api_gpe_fwd_entry_t *e;
2883 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2885 for (i = 0; i < mp->count; i++)
2887 e = &mp->entries[i];
2888 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2889 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2890 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2894 vam->retval = retval;
2895 vam->result_ready = 1;
2899 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2900 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2903 vat_main_t *vam = &vat_main;
2904 vat_json_node_t *e = 0, root;
2906 int retval = clib_net_to_host_u32 (mp->retval);
2907 vl_api_gpe_fwd_entry_t *fwd;
2912 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2913 vat_json_init_array (&root);
2915 for (i = 0; i < mp->count; i++)
2917 e = vat_json_array_add (&root);
2918 fwd = &mp->entries[i];
2920 vat_json_init_object (e);
2921 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2922 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2924 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2925 fwd->leid_prefix_len);
2927 vat_json_object_add_string_copy (e, "leid", s);
2930 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2931 fwd->reid_prefix_len);
2933 vat_json_object_add_string_copy (e, "reid", s);
2937 vat_json_print (vam->ofp, &root);
2938 vat_json_free (&root);
2941 vam->retval = retval;
2942 vam->result_ready = 1;
2946 vl_api_one_adjacencies_get_reply_t_handler
2947 (vl_api_one_adjacencies_get_reply_t * mp)
2949 vat_main_t *vam = &vat_main;
2951 int retval = clib_net_to_host_u32 (mp->retval);
2952 vl_api_one_adjacency_t *a;
2957 n = clib_net_to_host_u32 (mp->count);
2959 for (i = 0; i < n; i++)
2961 a = &mp->adjacencies[i];
2962 print (vam->ofp, "%U %40U",
2963 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2964 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2968 vam->retval = retval;
2969 vam->result_ready = 1;
2973 vl_api_one_adjacencies_get_reply_t_handler_json
2974 (vl_api_one_adjacencies_get_reply_t * mp)
2977 vat_main_t *vam = &vat_main;
2978 vat_json_node_t *e = 0, root;
2980 int retval = clib_net_to_host_u32 (mp->retval);
2981 vl_api_one_adjacency_t *a;
2986 n = clib_net_to_host_u32 (mp->count);
2987 vat_json_init_array (&root);
2989 for (i = 0; i < n; i++)
2991 e = vat_json_array_add (&root);
2992 a = &mp->adjacencies[i];
2994 vat_json_init_object (e);
2995 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2996 a->leid_prefix_len);
2998 vat_json_object_add_string_copy (e, "leid", s);
3001 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3002 a->reid_prefix_len);
3004 vat_json_object_add_string_copy (e, "reid", s);
3008 vat_json_print (vam->ofp, &root);
3009 vat_json_free (&root);
3012 vam->retval = retval;
3013 vam->result_ready = 1;
3017 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3019 vat_main_t *vam = &vat_main;
3021 print (vam->ofp, "%=20U",
3022 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3027 vl_api_one_map_server_details_t_handler_json
3028 (vl_api_one_map_server_details_t * mp)
3030 vat_main_t *vam = &vat_main;
3031 vat_json_node_t *node = NULL;
3032 struct in6_addr ip6;
3035 if (VAT_JSON_ARRAY != vam->json_tree.type)
3037 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3038 vat_json_init_array (&vam->json_tree);
3040 node = vat_json_array_add (&vam->json_tree);
3042 vat_json_init_object (node);
3045 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3046 vat_json_object_add_ip6 (node, "map-server", ip6);
3050 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3051 vat_json_object_add_ip4 (node, "map-server", ip4);
3056 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3059 vat_main_t *vam = &vat_main;
3061 print (vam->ofp, "%=20U",
3062 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3067 vl_api_one_map_resolver_details_t_handler_json
3068 (vl_api_one_map_resolver_details_t * mp)
3070 vat_main_t *vam = &vat_main;
3071 vat_json_node_t *node = NULL;
3072 struct in6_addr ip6;
3075 if (VAT_JSON_ARRAY != vam->json_tree.type)
3077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3078 vat_json_init_array (&vam->json_tree);
3080 node = vat_json_array_add (&vam->json_tree);
3082 vat_json_init_object (node);
3085 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3086 vat_json_object_add_ip6 (node, "map resolver", ip6);
3090 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3091 vat_json_object_add_ip4 (node, "map resolver", ip4);
3096 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3098 vat_main_t *vam = &vat_main;
3099 i32 retval = ntohl (mp->retval);
3103 print (vam->ofp, "feature: %s\ngpe: %s",
3104 mp->feature_status ? "enabled" : "disabled",
3105 mp->gpe_status ? "enabled" : "disabled");
3108 vam->retval = retval;
3109 vam->result_ready = 1;
3113 vl_api_show_one_status_reply_t_handler_json
3114 (vl_api_show_one_status_reply_t * mp)
3116 vat_main_t *vam = &vat_main;
3117 vat_json_node_t node;
3118 u8 *gpe_status = NULL;
3119 u8 *feature_status = NULL;
3121 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3122 feature_status = format (0, "%s",
3123 mp->feature_status ? "enabled" : "disabled");
3124 vec_add1 (gpe_status, 0);
3125 vec_add1 (feature_status, 0);
3127 vat_json_init_object (&node);
3128 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3129 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3131 vec_free (gpe_status);
3132 vec_free (feature_status);
3134 vat_json_print (vam->ofp, &node);
3135 vat_json_free (&node);
3137 vam->retval = ntohl (mp->retval);
3138 vam->result_ready = 1;
3142 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3143 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3145 vat_main_t *vam = &vat_main;
3146 i32 retval = ntohl (mp->retval);
3150 print (vam->ofp, "%=20s", mp->locator_set_name);
3153 vam->retval = retval;
3154 vam->result_ready = 1;
3158 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3159 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3161 vat_main_t *vam = &vat_main;
3162 vat_json_node_t *node = NULL;
3164 if (VAT_JSON_ARRAY != vam->json_tree.type)
3166 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3167 vat_json_init_array (&vam->json_tree);
3169 node = vat_json_array_add (&vam->json_tree);
3171 vat_json_init_object (node);
3172 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3174 vat_json_print (vam->ofp, node);
3175 vat_json_free (node);
3177 vam->retval = ntohl (mp->retval);
3178 vam->result_ready = 1;
3182 format_lisp_map_request_mode (u8 * s, va_list * args)
3184 u32 mode = va_arg (*args, u32);
3189 return format (0, "dst-only");
3191 return format (0, "src-dst");
3197 vl_api_show_one_map_request_mode_reply_t_handler
3198 (vl_api_show_one_map_request_mode_reply_t * mp)
3200 vat_main_t *vam = &vat_main;
3201 i32 retval = ntohl (mp->retval);
3205 u32 mode = mp->mode;
3206 print (vam->ofp, "map_request_mode: %U",
3207 format_lisp_map_request_mode, mode);
3210 vam->retval = retval;
3211 vam->result_ready = 1;
3215 vl_api_show_one_map_request_mode_reply_t_handler_json
3216 (vl_api_show_one_map_request_mode_reply_t * mp)
3218 vat_main_t *vam = &vat_main;
3219 vat_json_node_t node;
3224 s = format (0, "%U", format_lisp_map_request_mode, mode);
3227 vat_json_init_object (&node);
3228 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3229 vat_json_print (vam->ofp, &node);
3230 vat_json_free (&node);
3233 vam->retval = ntohl (mp->retval);
3234 vam->result_ready = 1;
3238 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3240 vat_main_t *vam = &vat_main;
3241 i32 retval = ntohl (mp->retval);
3245 print (vam->ofp, "%-20s%-16s",
3246 mp->status ? "enabled" : "disabled",
3247 mp->status ? (char *) mp->locator_set_name : "");
3250 vam->retval = retval;
3251 vam->result_ready = 1;
3255 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3257 vat_main_t *vam = &vat_main;
3258 vat_json_node_t node;
3261 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3262 vec_add1 (status, 0);
3264 vat_json_init_object (&node);
3265 vat_json_object_add_string_copy (&node, "status", status);
3268 vat_json_object_add_string_copy (&node, "locator_set",
3269 mp->locator_set_name);
3274 vat_json_print (vam->ofp, &node);
3275 vat_json_free (&node);
3277 vam->retval = ntohl (mp->retval);
3278 vam->result_ready = 1;
3282 format_policer_type (u8 * s, va_list * va)
3284 u32 i = va_arg (*va, u32);
3286 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3287 s = format (s, "1r2c");
3288 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3289 s = format (s, "1r3c");
3290 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3291 s = format (s, "2r3c-2698");
3292 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3293 s = format (s, "2r3c-4115");
3294 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3295 s = format (s, "2r3c-mef5cf1");
3297 s = format (s, "ILLEGAL");
3302 format_policer_rate_type (u8 * s, va_list * va)
3304 u32 i = va_arg (*va, u32);
3306 if (i == SSE2_QOS_RATE_KBPS)
3307 s = format (s, "kbps");
3308 else if (i == SSE2_QOS_RATE_PPS)
3309 s = format (s, "pps");
3311 s = format (s, "ILLEGAL");
3316 format_policer_round_type (u8 * s, va_list * va)
3318 u32 i = va_arg (*va, u32);
3320 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3321 s = format (s, "closest");
3322 else if (i == SSE2_QOS_ROUND_TO_UP)
3323 s = format (s, "up");
3324 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3325 s = format (s, "down");
3327 s = format (s, "ILLEGAL");
3332 format_policer_action_type (u8 * s, va_list * va)
3334 u32 i = va_arg (*va, u32);
3336 if (i == SSE2_QOS_ACTION_DROP)
3337 s = format (s, "drop");
3338 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3339 s = format (s, "transmit");
3340 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3341 s = format (s, "mark-and-transmit");
3343 s = format (s, "ILLEGAL");
3348 format_dscp (u8 * s, va_list * va)
3350 u32 i = va_arg (*va, u32);
3355 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3359 return format (s, "ILLEGAL");
3361 s = format (s, "%s", t);
3366 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3368 vat_main_t *vam = &vat_main;
3369 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3371 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3372 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3374 conform_dscp_str = format (0, "");
3376 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3377 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3379 exceed_dscp_str = format (0, "");
3381 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3382 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3384 violate_dscp_str = format (0, "");
3386 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3387 "rate type %U, round type %U, %s rate, %s color-aware, "
3388 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3389 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3390 "conform action %U%s, exceed action %U%s, violate action %U%s",
3392 format_policer_type, mp->type,
3395 clib_net_to_host_u64 (mp->cb),
3396 clib_net_to_host_u64 (mp->eb),
3397 format_policer_rate_type, mp->rate_type,
3398 format_policer_round_type, mp->round_type,
3399 mp->single_rate ? "single" : "dual",
3400 mp->color_aware ? "is" : "not",
3401 ntohl (mp->cir_tokens_per_period),
3402 ntohl (mp->pir_tokens_per_period),
3404 ntohl (mp->current_limit),
3405 ntohl (mp->current_bucket),
3406 ntohl (mp->extended_limit),
3407 ntohl (mp->extended_bucket),
3408 clib_net_to_host_u64 (mp->last_update_time),
3409 format_policer_action_type, mp->conform_action_type,
3411 format_policer_action_type, mp->exceed_action_type,
3413 format_policer_action_type, mp->violate_action_type,
3416 vec_free (conform_dscp_str);
3417 vec_free (exceed_dscp_str);
3418 vec_free (violate_dscp_str);
3421 static void vl_api_policer_details_t_handler_json
3422 (vl_api_policer_details_t * mp)
3424 vat_main_t *vam = &vat_main;
3425 vat_json_node_t *node;
3426 u8 *rate_type_str, *round_type_str, *type_str;
3427 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3429 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3431 format (0, "%U", format_policer_round_type, mp->round_type);
3432 type_str = format (0, "%U", format_policer_type, mp->type);
3433 conform_action_str = format (0, "%U", format_policer_action_type,
3434 mp->conform_action_type);
3435 exceed_action_str = format (0, "%U", format_policer_action_type,
3436 mp->exceed_action_type);
3437 violate_action_str = format (0, "%U", format_policer_action_type,
3438 mp->violate_action_type);
3440 if (VAT_JSON_ARRAY != vam->json_tree.type)
3442 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3443 vat_json_init_array (&vam->json_tree);
3445 node = vat_json_array_add (&vam->json_tree);
3447 vat_json_init_object (node);
3448 vat_json_object_add_string_copy (node, "name", mp->name);
3449 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3450 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3451 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3452 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3453 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3454 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3455 vat_json_object_add_string_copy (node, "type", type_str);
3456 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3457 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3458 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3459 vat_json_object_add_uint (node, "cir_tokens_per_period",
3460 ntohl (mp->cir_tokens_per_period));
3461 vat_json_object_add_uint (node, "eir_tokens_per_period",
3462 ntohl (mp->pir_tokens_per_period));
3463 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3464 vat_json_object_add_uint (node, "current_bucket",
3465 ntohl (mp->current_bucket));
3466 vat_json_object_add_uint (node, "extended_limit",
3467 ntohl (mp->extended_limit));
3468 vat_json_object_add_uint (node, "extended_bucket",
3469 ntohl (mp->extended_bucket));
3470 vat_json_object_add_uint (node, "last_update_time",
3471 ntohl (mp->last_update_time));
3472 vat_json_object_add_string_copy (node, "conform_action",
3473 conform_action_str);
3474 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3476 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3477 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3478 vec_free (dscp_str);
3480 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3481 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3483 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3484 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3485 vec_free (dscp_str);
3487 vat_json_object_add_string_copy (node, "violate_action",
3488 violate_action_str);
3489 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3491 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3492 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3493 vec_free (dscp_str);
3496 vec_free (rate_type_str);
3497 vec_free (round_type_str);
3498 vec_free (type_str);
3499 vec_free (conform_action_str);
3500 vec_free (exceed_action_str);
3501 vec_free (violate_action_str);
3505 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3508 vat_main_t *vam = &vat_main;
3509 int i, count = ntohl (mp->count);
3512 print (vam->ofp, "classify table ids (%d) : ", count);
3513 for (i = 0; i < count; i++)
3515 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3516 print (vam->ofp, (i < count - 1) ? "," : "");
3518 vam->retval = ntohl (mp->retval);
3519 vam->result_ready = 1;
3523 vl_api_classify_table_ids_reply_t_handler_json
3524 (vl_api_classify_table_ids_reply_t * mp)
3526 vat_main_t *vam = &vat_main;
3527 int i, count = ntohl (mp->count);
3531 vat_json_node_t node;
3533 vat_json_init_object (&node);
3534 for (i = 0; i < count; i++)
3536 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3538 vat_json_print (vam->ofp, &node);
3539 vat_json_free (&node);
3541 vam->retval = ntohl (mp->retval);
3542 vam->result_ready = 1;
3546 vl_api_classify_table_by_interface_reply_t_handler
3547 (vl_api_classify_table_by_interface_reply_t * mp)
3549 vat_main_t *vam = &vat_main;
3552 table_id = ntohl (mp->l2_table_id);
3554 print (vam->ofp, "l2 table id : %d", table_id);
3556 print (vam->ofp, "l2 table id : No input ACL tables configured");
3557 table_id = ntohl (mp->ip4_table_id);
3559 print (vam->ofp, "ip4 table id : %d", table_id);
3561 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3562 table_id = ntohl (mp->ip6_table_id);
3564 print (vam->ofp, "ip6 table id : %d", table_id);
3566 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3567 vam->retval = ntohl (mp->retval);
3568 vam->result_ready = 1;
3572 vl_api_classify_table_by_interface_reply_t_handler_json
3573 (vl_api_classify_table_by_interface_reply_t * mp)
3575 vat_main_t *vam = &vat_main;
3576 vat_json_node_t node;
3578 vat_json_init_object (&node);
3580 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3581 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3582 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3584 vat_json_print (vam->ofp, &node);
3585 vat_json_free (&node);
3587 vam->retval = ntohl (mp->retval);
3588 vam->result_ready = 1;
3591 static void vl_api_policer_add_del_reply_t_handler
3592 (vl_api_policer_add_del_reply_t * mp)
3594 vat_main_t *vam = &vat_main;
3595 i32 retval = ntohl (mp->retval);
3596 if (vam->async_mode)
3598 vam->async_errors += (retval < 0);
3602 vam->retval = retval;
3603 vam->result_ready = 1;
3604 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3606 * Note: this is just barely thread-safe, depends on
3607 * the main thread spinning waiting for an answer...
3609 errmsg ("policer index %d", ntohl (mp->policer_index));
3613 static void vl_api_policer_add_del_reply_t_handler_json
3614 (vl_api_policer_add_del_reply_t * mp)
3616 vat_main_t *vam = &vat_main;
3617 vat_json_node_t node;
3619 vat_json_init_object (&node);
3620 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3621 vat_json_object_add_uint (&node, "policer_index",
3622 ntohl (mp->policer_index));
3624 vat_json_print (vam->ofp, &node);
3625 vat_json_free (&node);
3627 vam->retval = ntohl (mp->retval);
3628 vam->result_ready = 1;
3631 /* Format hex dump. */
3633 format_hex_bytes (u8 * s, va_list * va)
3635 u8 *bytes = va_arg (*va, u8 *);
3636 int n_bytes = va_arg (*va, int);
3639 /* Print short or long form depending on byte count. */
3640 uword short_form = n_bytes <= 32;
3641 uword indent = format_get_indent (s);
3646 for (i = 0; i < n_bytes; i++)
3648 if (!short_form && (i % 32) == 0)
3649 s = format (s, "%08x: ", i);
3650 s = format (s, "%02x", bytes[i]);
3651 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3652 s = format (s, "\n%U", format_white_space, indent);
3659 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3662 vat_main_t *vam = &vat_main;
3663 i32 retval = ntohl (mp->retval);
3666 print (vam->ofp, "classify table info :");
3667 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3668 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3669 ntohl (mp->miss_next_index));
3670 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3671 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3672 ntohl (mp->match_n_vectors));
3673 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3674 ntohl (mp->mask_length));
3676 vam->retval = retval;
3677 vam->result_ready = 1;
3681 vl_api_classify_table_info_reply_t_handler_json
3682 (vl_api_classify_table_info_reply_t * mp)
3684 vat_main_t *vam = &vat_main;
3685 vat_json_node_t node;
3687 i32 retval = ntohl (mp->retval);
3690 vat_json_init_object (&node);
3692 vat_json_object_add_int (&node, "sessions",
3693 ntohl (mp->active_sessions));
3694 vat_json_object_add_int (&node, "nexttbl",
3695 ntohl (mp->next_table_index));
3696 vat_json_object_add_int (&node, "nextnode",
3697 ntohl (mp->miss_next_index));
3698 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3699 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3700 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3701 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3702 ntohl (mp->mask_length), 0);
3703 vat_json_object_add_string_copy (&node, "mask", s);
3705 vat_json_print (vam->ofp, &node);
3706 vat_json_free (&node);
3708 vam->retval = ntohl (mp->retval);
3709 vam->result_ready = 1;
3713 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3716 vat_main_t *vam = &vat_main;
3718 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3719 ntohl (mp->hit_next_index), ntohl (mp->advance),
3720 ntohl (mp->opaque_index));
3721 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3722 ntohl (mp->match_length));
3726 vl_api_classify_session_details_t_handler_json
3727 (vl_api_classify_session_details_t * mp)
3729 vat_main_t *vam = &vat_main;
3730 vat_json_node_t *node = NULL;
3732 if (VAT_JSON_ARRAY != vam->json_tree.type)
3734 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3735 vat_json_init_array (&vam->json_tree);
3737 node = vat_json_array_add (&vam->json_tree);
3739 vat_json_init_object (node);
3740 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3741 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3742 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3744 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3746 vat_json_object_add_string_copy (node, "match", s);
3749 static void vl_api_pg_create_interface_reply_t_handler
3750 (vl_api_pg_create_interface_reply_t * mp)
3752 vat_main_t *vam = &vat_main;
3754 vam->retval = ntohl (mp->retval);
3755 vam->result_ready = 1;
3758 static void vl_api_pg_create_interface_reply_t_handler_json
3759 (vl_api_pg_create_interface_reply_t * mp)
3761 vat_main_t *vam = &vat_main;
3762 vat_json_node_t node;
3764 i32 retval = ntohl (mp->retval);
3767 vat_json_init_object (&node);
3769 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3771 vat_json_print (vam->ofp, &node);
3772 vat_json_free (&node);
3774 vam->retval = ntohl (mp->retval);
3775 vam->result_ready = 1;
3778 static void vl_api_policer_classify_details_t_handler
3779 (vl_api_policer_classify_details_t * mp)
3781 vat_main_t *vam = &vat_main;
3783 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3784 ntohl (mp->table_index));
3787 static void vl_api_policer_classify_details_t_handler_json
3788 (vl_api_policer_classify_details_t * mp)
3790 vat_main_t *vam = &vat_main;
3791 vat_json_node_t *node;
3793 if (VAT_JSON_ARRAY != vam->json_tree.type)
3795 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3796 vat_json_init_array (&vam->json_tree);
3798 node = vat_json_array_add (&vam->json_tree);
3800 vat_json_init_object (node);
3801 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3802 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3805 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3806 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3808 vat_main_t *vam = &vat_main;
3809 i32 retval = ntohl (mp->retval);
3810 if (vam->async_mode)
3812 vam->async_errors += (retval < 0);
3816 vam->retval = retval;
3817 vam->sw_if_index = ntohl (mp->sw_if_index);
3818 vam->result_ready = 1;
3822 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3823 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3825 vat_main_t *vam = &vat_main;
3826 vat_json_node_t node;
3828 vat_json_init_object (&node);
3829 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3830 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3832 vat_json_print (vam->ofp, &node);
3833 vat_json_free (&node);
3835 vam->retval = ntohl (mp->retval);
3836 vam->result_ready = 1;
3839 static void vl_api_flow_classify_details_t_handler
3840 (vl_api_flow_classify_details_t * mp)
3842 vat_main_t *vam = &vat_main;
3844 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3845 ntohl (mp->table_index));
3848 static void vl_api_flow_classify_details_t_handler_json
3849 (vl_api_flow_classify_details_t * mp)
3851 vat_main_t *vam = &vat_main;
3852 vat_json_node_t *node;
3854 if (VAT_JSON_ARRAY != vam->json_tree.type)
3856 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3857 vat_json_init_array (&vam->json_tree);
3859 node = vat_json_array_add (&vam->json_tree);
3861 vat_json_init_object (node);
3862 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3863 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3868 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3869 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3870 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3871 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3872 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3873 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3874 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3875 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3876 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3877 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3880 * Generate boilerplate reply handlers, which
3881 * dig the return value out of the xxx_reply_t API message,
3882 * stick it into vam->retval, and set vam->result_ready
3884 * Could also do this by pointing N message decode slots at
3885 * a single function, but that could break in subtle ways.
3888 #define foreach_standard_reply_retval_handler \
3889 _(sw_interface_set_flags_reply) \
3890 _(sw_interface_add_del_address_reply) \
3891 _(sw_interface_set_table_reply) \
3892 _(sw_interface_set_mpls_enable_reply) \
3893 _(sw_interface_set_vpath_reply) \
3894 _(sw_interface_set_vxlan_bypass_reply) \
3895 _(sw_interface_set_l2_bridge_reply) \
3896 _(bridge_domain_add_del_reply) \
3897 _(sw_interface_set_l2_xconnect_reply) \
3898 _(l2fib_add_del_reply) \
3899 _(ip_add_del_route_reply) \
3900 _(ip_mroute_add_del_reply) \
3901 _(mpls_route_add_del_reply) \
3902 _(mpls_ip_bind_unbind_reply) \
3903 _(proxy_arp_add_del_reply) \
3904 _(proxy_arp_intfc_enable_disable_reply) \
3905 _(sw_interface_set_unnumbered_reply) \
3906 _(ip_neighbor_add_del_reply) \
3907 _(reset_vrf_reply) \
3908 _(oam_add_del_reply) \
3909 _(reset_fib_reply) \
3910 _(dhcp_proxy_config_reply) \
3911 _(dhcp_proxy_set_vss_reply) \
3912 _(dhcp_client_config_reply) \
3913 _(set_ip_flow_hash_reply) \
3914 _(sw_interface_ip6_enable_disable_reply) \
3915 _(sw_interface_ip6_set_link_local_address_reply) \
3916 _(sw_interface_ip6nd_ra_prefix_reply) \
3917 _(sw_interface_ip6nd_ra_config_reply) \
3918 _(set_arp_neighbor_limit_reply) \
3919 _(l2_patch_add_del_reply) \
3920 _(sr_policy_add_reply) \
3921 _(sr_policy_mod_reply) \
3922 _(sr_policy_del_reply) \
3923 _(sr_localsid_add_del_reply) \
3924 _(sr_steering_add_del_reply) \
3925 _(classify_add_del_session_reply) \
3926 _(classify_set_interface_ip_table_reply) \
3927 _(classify_set_interface_l2_tables_reply) \
3928 _(l2tpv3_set_tunnel_cookies_reply) \
3929 _(l2tpv3_interface_enable_disable_reply) \
3930 _(l2tpv3_set_lookup_key_reply) \
3931 _(l2_fib_clear_table_reply) \
3932 _(l2_interface_efp_filter_reply) \
3933 _(l2_interface_vlan_tag_rewrite_reply) \
3934 _(modify_vhost_user_if_reply) \
3935 _(delete_vhost_user_if_reply) \
3936 _(want_ip4_arp_events_reply) \
3937 _(want_ip6_nd_events_reply) \
3938 _(input_acl_set_interface_reply) \
3939 _(ipsec_spd_add_del_reply) \
3940 _(ipsec_interface_add_del_spd_reply) \
3941 _(ipsec_spd_add_del_entry_reply) \
3942 _(ipsec_sad_add_del_entry_reply) \
3943 _(ipsec_sa_set_key_reply) \
3944 _(ikev2_profile_add_del_reply) \
3945 _(ikev2_profile_set_auth_reply) \
3946 _(ikev2_profile_set_id_reply) \
3947 _(ikev2_profile_set_ts_reply) \
3948 _(ikev2_set_local_key_reply) \
3949 _(ikev2_set_responder_reply) \
3950 _(ikev2_set_ike_transforms_reply) \
3951 _(ikev2_set_esp_transforms_reply) \
3952 _(ikev2_set_sa_lifetime_reply) \
3953 _(ikev2_initiate_sa_init_reply) \
3954 _(ikev2_initiate_del_ike_sa_reply) \
3955 _(ikev2_initiate_del_child_sa_reply) \
3956 _(ikev2_initiate_rekey_child_sa_reply) \
3957 _(delete_loopback_reply) \
3958 _(bd_ip_mac_add_del_reply) \
3959 _(map_del_domain_reply) \
3960 _(map_add_del_rule_reply) \
3961 _(want_interface_events_reply) \
3962 _(want_stats_reply) \
3963 _(cop_interface_enable_disable_reply) \
3964 _(cop_whitelist_enable_disable_reply) \
3965 _(sw_interface_clear_stats_reply) \
3966 _(ioam_enable_reply) \
3967 _(ioam_disable_reply) \
3968 _(one_add_del_locator_reply) \
3969 _(one_add_del_local_eid_reply) \
3970 _(one_add_del_remote_mapping_reply) \
3971 _(one_add_del_adjacency_reply) \
3972 _(one_add_del_map_resolver_reply) \
3973 _(one_add_del_map_server_reply) \
3974 _(one_enable_disable_reply) \
3975 _(one_rloc_probe_enable_disable_reply) \
3976 _(one_map_register_enable_disable_reply) \
3977 _(one_pitr_set_locator_set_reply) \
3978 _(one_map_request_mode_reply) \
3979 _(one_add_del_map_request_itr_rlocs_reply) \
3980 _(one_eid_table_add_del_map_reply) \
3981 _(gpe_add_del_fwd_entry_reply) \
3982 _(gpe_enable_disable_reply) \
3983 _(gpe_set_encap_mode_reply) \
3984 _(gpe_add_del_iface_reply) \
3985 _(vxlan_gpe_add_del_tunnel_reply) \
3986 _(af_packet_delete_reply) \
3987 _(policer_classify_set_interface_reply) \
3988 _(netmap_create_reply) \
3989 _(netmap_delete_reply) \
3990 _(set_ipfix_exporter_reply) \
3991 _(set_ipfix_classify_stream_reply) \
3992 _(ipfix_classify_table_add_del_reply) \
3993 _(flow_classify_set_interface_reply) \
3994 _(sw_interface_span_enable_disable_reply) \
3995 _(pg_capture_reply) \
3996 _(pg_enable_disable_reply) \
3997 _(ip_source_and_port_range_check_add_del_reply) \
3998 _(ip_source_and_port_range_check_interface_add_del_reply)\
3999 _(delete_subif_reply) \
4000 _(l2_interface_pbb_tag_rewrite_reply) \
4002 _(feature_enable_disable_reply) \
4003 _(sw_interface_tag_add_del_reply) \
4004 _(sw_interface_set_mtu_reply)
4007 static void vl_api_##n##_t_handler \
4008 (vl_api_##n##_t * mp) \
4010 vat_main_t * vam = &vat_main; \
4011 i32 retval = ntohl(mp->retval); \
4012 if (vam->async_mode) { \
4013 vam->async_errors += (retval < 0); \
4015 vam->retval = retval; \
4016 vam->result_ready = 1; \
4019 foreach_standard_reply_retval_handler;
4023 static void vl_api_##n##_t_handler_json \
4024 (vl_api_##n##_t * mp) \
4026 vat_main_t * vam = &vat_main; \
4027 vat_json_node_t node; \
4028 vat_json_init_object(&node); \
4029 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4030 vat_json_print(vam->ofp, &node); \
4031 vam->retval = ntohl(mp->retval); \
4032 vam->result_ready = 1; \
4034 foreach_standard_reply_retval_handler;
4038 * Table of message reply handlers, must include boilerplate handlers
4042 #define foreach_vpe_api_reply_msg \
4043 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4044 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4045 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4046 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4047 _(CONTROL_PING_REPLY, control_ping_reply) \
4048 _(CLI_REPLY, cli_reply) \
4049 _(CLI_INBAND_REPLY, cli_inband_reply) \
4050 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4051 sw_interface_add_del_address_reply) \
4052 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4053 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4054 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4055 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4056 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4057 sw_interface_set_l2_xconnect_reply) \
4058 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4059 sw_interface_set_l2_bridge_reply) \
4060 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4061 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4062 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4063 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4064 _(L2_FLAGS_REPLY, l2_flags_reply) \
4065 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4066 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4067 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4068 _(TAP_DELETE_REPLY, tap_delete_reply) \
4069 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4070 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4071 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4072 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4073 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4074 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4075 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4076 proxy_arp_intfc_enable_disable_reply) \
4077 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4078 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4079 sw_interface_set_unnumbered_reply) \
4080 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4081 _(RESET_VRF_REPLY, reset_vrf_reply) \
4082 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4083 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4084 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4085 _(RESET_FIB_REPLY, reset_fib_reply) \
4086 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4087 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4088 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4089 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4090 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4091 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4092 sw_interface_ip6_enable_disable_reply) \
4093 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4094 sw_interface_ip6_set_link_local_address_reply) \
4095 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4096 sw_interface_ip6nd_ra_prefix_reply) \
4097 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4098 sw_interface_ip6nd_ra_config_reply) \
4099 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4100 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4101 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4102 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4103 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4104 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4105 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4106 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4107 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4108 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4109 classify_set_interface_ip_table_reply) \
4110 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4111 classify_set_interface_l2_tables_reply) \
4112 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4113 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4114 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4115 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4116 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4117 l2tpv3_interface_enable_disable_reply) \
4118 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4119 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4120 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4121 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4122 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4123 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4124 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4125 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4126 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4127 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4128 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4129 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4130 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4131 _(SHOW_VERSION_REPLY, show_version_reply) \
4132 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4133 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4134 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4135 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4136 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4137 _(IP4_ARP_EVENT, ip4_arp_event) \
4138 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4139 _(IP6_ND_EVENT, ip6_nd_event) \
4140 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4141 _(IP_ADDRESS_DETAILS, ip_address_details) \
4142 _(IP_DETAILS, ip_details) \
4143 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4144 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4145 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4146 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4147 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4148 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4149 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4150 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4151 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4152 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4153 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4154 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4155 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4156 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4157 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4158 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4159 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4160 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4161 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4162 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4163 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4164 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4165 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4166 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4167 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4168 _(MAP_RULE_DETAILS, map_rule_details) \
4169 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4170 _(WANT_STATS_REPLY, want_stats_reply) \
4171 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4172 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4173 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4174 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4175 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4176 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4177 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4178 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4179 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4180 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4181 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4182 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4183 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4184 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4185 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4186 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4187 one_map_register_enable_disable_reply) \
4188 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4189 one_rloc_probe_enable_disable_reply) \
4190 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4191 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4192 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4193 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4194 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4195 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4196 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4197 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4198 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4199 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4200 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4201 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4202 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4203 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4204 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4205 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4206 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4207 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4208 gpe_fwd_entry_path_details) \
4209 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4210 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4211 one_add_del_map_request_itr_rlocs_reply) \
4212 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4213 one_get_map_request_itr_rlocs_reply) \
4214 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4215 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4216 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4217 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4218 show_one_map_register_state_reply) \
4219 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4220 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4221 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4222 _(POLICER_DETAILS, policer_details) \
4223 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4224 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4225 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4226 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4227 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4228 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4229 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4230 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4231 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4232 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4233 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4234 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4235 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4236 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4237 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4238 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4239 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4240 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4241 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4242 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4243 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4244 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4245 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4246 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4247 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4248 ip_source_and_port_range_check_add_del_reply) \
4249 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4250 ip_source_and_port_range_check_interface_add_del_reply) \
4251 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4252 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4253 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4254 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4255 _(PUNT_REPLY, punt_reply) \
4256 _(IP_FIB_DETAILS, ip_fib_details) \
4257 _(IP6_FIB_DETAILS, ip6_fib_details) \
4258 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4259 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4260 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4261 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4262 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4263 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4265 #define foreach_standalone_reply_msg \
4266 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4267 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4268 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4269 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4270 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4271 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4280 #define STR_VTR_OP_CASE(op) \
4281 case L2_VTR_ ## op: \
4285 str_vtr_op (u32 vtr_op)
4289 STR_VTR_OP_CASE (DISABLED);
4290 STR_VTR_OP_CASE (PUSH_1);
4291 STR_VTR_OP_CASE (PUSH_2);
4292 STR_VTR_OP_CASE (POP_1);
4293 STR_VTR_OP_CASE (POP_2);
4294 STR_VTR_OP_CASE (TRANSLATE_1_1);
4295 STR_VTR_OP_CASE (TRANSLATE_1_2);
4296 STR_VTR_OP_CASE (TRANSLATE_2_1);
4297 STR_VTR_OP_CASE (TRANSLATE_2_2);
4304 dump_sub_interface_table (vat_main_t * vam)
4306 const sw_interface_subif_t *sub = NULL;
4308 if (vam->json_output)
4311 ("JSON output supported only for VPE API calls and dump_stats_table");
4316 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4317 "Interface", "sw_if_index",
4318 "sub id", "dot1ad", "tags", "outer id",
4319 "inner id", "exact", "default", "outer any", "inner any");
4321 vec_foreach (sub, vam->sw_if_subif_table)
4324 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4325 sub->interface_name,
4327 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4328 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4329 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4330 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4331 if (sub->vtr_op != L2_VTR_DISABLED)
4334 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4335 "tag1: %d tag2: %d ]",
4336 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4337 sub->vtr_tag1, sub->vtr_tag2);
4345 name_sort_cmp (void *a1, void *a2)
4347 name_sort_t *n1 = a1;
4348 name_sort_t *n2 = a2;
4350 return strcmp ((char *) n1->name, (char *) n2->name);
4354 dump_interface_table (vat_main_t * vam)
4357 name_sort_t *nses = 0, *ns;
4359 if (vam->json_output)
4362 ("JSON output supported only for VPE API calls and dump_stats_table");
4367 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4369 vec_add2 (nses, ns, 1);
4370 ns->name = (u8 *)(p->key);
4371 ns->value = (u32) p->value[0];
4375 vec_sort_with_function (nses, name_sort_cmp);
4377 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4378 vec_foreach (ns, nses)
4380 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4387 dump_ip_table (vat_main_t * vam, int is_ipv6)
4389 const ip_details_t *det = NULL;
4390 const ip_address_details_t *address = NULL;
4393 print (vam->ofp, "%-12s", "sw_if_index");
4395 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4402 print (vam->ofp, "%-12d", i);
4403 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4408 vec_foreach (address, det->addr)
4412 is_ipv6 ? format_ip6_address : format_ip4_address,
4413 address->ip, address->prefix_length);
4421 dump_ipv4_table (vat_main_t * vam)
4423 if (vam->json_output)
4426 ("JSON output supported only for VPE API calls and dump_stats_table");
4430 return dump_ip_table (vam, 0);
4434 dump_ipv6_table (vat_main_t * vam)
4436 if (vam->json_output)
4439 ("JSON output supported only for VPE API calls and dump_stats_table");
4443 return dump_ip_table (vam, 1);
4447 counter_type_to_str (u8 counter_type, u8 is_combined)
4451 switch (counter_type)
4453 case VNET_INTERFACE_COUNTER_DROP:
4455 case VNET_INTERFACE_COUNTER_PUNT:
4457 case VNET_INTERFACE_COUNTER_IP4:
4459 case VNET_INTERFACE_COUNTER_IP6:
4461 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4463 case VNET_INTERFACE_COUNTER_RX_MISS:
4465 case VNET_INTERFACE_COUNTER_RX_ERROR:
4467 case VNET_INTERFACE_COUNTER_TX_ERROR:
4470 return "INVALID-COUNTER-TYPE";
4475 switch (counter_type)
4477 case VNET_INTERFACE_COUNTER_RX:
4479 case VNET_INTERFACE_COUNTER_TX:
4482 return "INVALID-COUNTER-TYPE";
4488 dump_stats_table (vat_main_t * vam)
4490 vat_json_node_t node;
4491 vat_json_node_t *msg_array;
4492 vat_json_node_t *msg;
4493 vat_json_node_t *counter_array;
4494 vat_json_node_t *counter;
4495 interface_counter_t c;
4497 ip4_fib_counter_t *c4;
4498 ip6_fib_counter_t *c6;
4499 ip4_nbr_counter_t *n4;
4500 ip6_nbr_counter_t *n6;
4503 if (!vam->json_output)
4505 clib_warning ("dump_stats_table supported only in JSON format");
4509 vat_json_init_object (&node);
4511 /* interface counters */
4512 msg_array = vat_json_object_add (&node, "interface_counters");
4513 vat_json_init_array (msg_array);
4514 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4516 msg = vat_json_array_add (msg_array);
4517 vat_json_init_object (msg);
4518 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4519 (u8 *) counter_type_to_str (i, 0));
4520 vat_json_object_add_int (msg, "is_combined", 0);
4521 counter_array = vat_json_object_add (msg, "data");
4522 vat_json_init_array (counter_array);
4523 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4525 packets = vam->simple_interface_counters[i][j];
4526 vat_json_array_add_uint (counter_array, packets);
4529 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4531 msg = vat_json_array_add (msg_array);
4532 vat_json_init_object (msg);
4533 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4534 (u8 *) counter_type_to_str (i, 1));
4535 vat_json_object_add_int (msg, "is_combined", 1);
4536 counter_array = vat_json_object_add (msg, "data");
4537 vat_json_init_array (counter_array);
4538 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4540 c = vam->combined_interface_counters[i][j];
4541 counter = vat_json_array_add (counter_array);
4542 vat_json_init_object (counter);
4543 vat_json_object_add_uint (counter, "packets", c.packets);
4544 vat_json_object_add_uint (counter, "bytes", c.bytes);
4548 /* ip4 fib counters */
4549 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4550 vat_json_init_array (msg_array);
4551 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4553 msg = vat_json_array_add (msg_array);
4554 vat_json_init_object (msg);
4555 vat_json_object_add_uint (msg, "vrf_id",
4556 vam->ip4_fib_counters_vrf_id_by_index[i]);
4557 counter_array = vat_json_object_add (msg, "c");
4558 vat_json_init_array (counter_array);
4559 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4561 counter = vat_json_array_add (counter_array);
4562 vat_json_init_object (counter);
4563 c4 = &vam->ip4_fib_counters[i][j];
4564 vat_json_object_add_ip4 (counter, "address", c4->address);
4565 vat_json_object_add_uint (counter, "address_length",
4566 c4->address_length);
4567 vat_json_object_add_uint (counter, "packets", c4->packets);
4568 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4572 /* ip6 fib counters */
4573 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4574 vat_json_init_array (msg_array);
4575 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4577 msg = vat_json_array_add (msg_array);
4578 vat_json_init_object (msg);
4579 vat_json_object_add_uint (msg, "vrf_id",
4580 vam->ip6_fib_counters_vrf_id_by_index[i]);
4581 counter_array = vat_json_object_add (msg, "c");
4582 vat_json_init_array (counter_array);
4583 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4585 counter = vat_json_array_add (counter_array);
4586 vat_json_init_object (counter);
4587 c6 = &vam->ip6_fib_counters[i][j];
4588 vat_json_object_add_ip6 (counter, "address", c6->address);
4589 vat_json_object_add_uint (counter, "address_length",
4590 c6->address_length);
4591 vat_json_object_add_uint (counter, "packets", c6->packets);
4592 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4596 /* ip4 nbr counters */
4597 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4598 vat_json_init_array (msg_array);
4599 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4601 msg = vat_json_array_add (msg_array);
4602 vat_json_init_object (msg);
4603 vat_json_object_add_uint (msg, "sw_if_index", i);
4604 counter_array = vat_json_object_add (msg, "c");
4605 vat_json_init_array (counter_array);
4606 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4608 counter = vat_json_array_add (counter_array);
4609 vat_json_init_object (counter);
4610 n4 = &vam->ip4_nbr_counters[i][j];
4611 vat_json_object_add_ip4 (counter, "address", n4->address);
4612 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4613 vat_json_object_add_uint (counter, "packets", n4->packets);
4614 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4618 /* ip6 nbr counters */
4619 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4620 vat_json_init_array (msg_array);
4621 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4623 msg = vat_json_array_add (msg_array);
4624 vat_json_init_object (msg);
4625 vat_json_object_add_uint (msg, "sw_if_index", i);
4626 counter_array = vat_json_object_add (msg, "c");
4627 vat_json_init_array (counter_array);
4628 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4630 counter = vat_json_array_add (counter_array);
4631 vat_json_init_object (counter);
4632 n6 = &vam->ip6_nbr_counters[i][j];
4633 vat_json_object_add_ip6 (counter, "address", n6->address);
4634 vat_json_object_add_uint (counter, "packets", n6->packets);
4635 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4639 vat_json_print (vam->ofp, &node);
4640 vat_json_free (&node);
4646 exec (vat_main_t * vam)
4648 api_main_t *am = &api_main;
4649 vl_api_cli_request_t *mp;
4653 unformat_input_t *i = vam->input;
4655 if (vec_len (i->buffer) == 0)
4658 if (vam->exec_mode == 0 && unformat (i, "mode"))
4663 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4670 M (CLI_REQUEST, mp);
4673 * Copy cmd into shared memory.
4674 * In order for the CLI command to work, it
4675 * must be a vector ending in \n, not a C-string ending
4678 pthread_mutex_lock (&am->vlib_rp->mutex);
4679 oldheap = svm_push_data_heap (am->vlib_rp);
4681 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4682 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4684 svm_pop_heap (oldheap);
4685 pthread_mutex_unlock (&am->vlib_rp->mutex);
4687 mp->cmd_in_shmem = (u64) cmd;
4689 timeout = vat_time_now (vam) + 10.0;
4691 while (vat_time_now (vam) < timeout)
4693 if (vam->result_ready == 1)
4696 if (vam->shmem_result != NULL)
4697 print (vam->ofp, "%s", vam->shmem_result);
4698 pthread_mutex_lock (&am->vlib_rp->mutex);
4699 oldheap = svm_push_data_heap (am->vlib_rp);
4701 free_me = (u8 *) vam->shmem_result;
4704 svm_pop_heap (oldheap);
4705 pthread_mutex_unlock (&am->vlib_rp->mutex);
4713 * Future replacement of exec() that passes CLI buffers directly in
4714 * the API messages instead of an additional shared memory area.
4717 exec_inband (vat_main_t * vam)
4719 vl_api_cli_inband_t *mp;
4720 unformat_input_t *i = vam->input;
4723 if (vec_len (i->buffer) == 0)
4726 if (vam->exec_mode == 0 && unformat (i, "mode"))
4731 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4738 * In order for the CLI command to work, it
4739 * must be a vector ending in \n, not a C-string ending
4742 u32 len = vec_len (vam->input->buffer);
4743 M2 (CLI_INBAND, mp, len);
4744 clib_memcpy (mp->cmd, vam->input->buffer, len);
4745 mp->length = htonl (len);
4748 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4753 api_create_loopback (vat_main_t * vam)
4755 unformat_input_t *i = vam->input;
4756 vl_api_create_loopback_t *mp;
4757 vl_api_create_loopback_instance_t *mp_lbi;
4760 u8 is_specified = 0;
4761 u32 user_instance = 0;
4764 memset (mac_address, 0, sizeof (mac_address));
4766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4768 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4770 if (unformat (i, "instance %d", &user_instance))
4778 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
4779 mp_lbi->is_specified = is_specified;
4781 mp_lbi->user_instance = htonl (user_instance);
4783 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
4788 /* Construct the API message */
4789 M (CREATE_LOOPBACK, mp);
4791 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4800 api_delete_loopback (vat_main_t * vam)
4802 unformat_input_t *i = vam->input;
4803 vl_api_delete_loopback_t *mp;
4804 u32 sw_if_index = ~0;
4807 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4809 if (unformat (i, "sw_if_index %d", &sw_if_index))
4815 if (sw_if_index == ~0)
4817 errmsg ("missing sw_if_index");
4821 /* Construct the API message */
4822 M (DELETE_LOOPBACK, mp);
4823 mp->sw_if_index = ntohl (sw_if_index);
4831 api_want_stats (vat_main_t * vam)
4833 unformat_input_t *i = vam->input;
4834 vl_api_want_stats_t *mp;
4838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4840 if (unformat (i, "enable"))
4842 else if (unformat (i, "disable"))
4850 errmsg ("missing enable|disable");
4855 mp->enable_disable = enable;
4863 api_want_interface_events (vat_main_t * vam)
4865 unformat_input_t *i = vam->input;
4866 vl_api_want_interface_events_t *mp;
4870 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4872 if (unformat (i, "enable"))
4874 else if (unformat (i, "disable"))
4882 errmsg ("missing enable|disable");
4886 M (WANT_INTERFACE_EVENTS, mp);
4887 mp->enable_disable = enable;
4889 vam->interface_event_display = enable;
4897 /* Note: non-static, called once to set up the initial intfc table */
4899 api_sw_interface_dump (vat_main_t * vam)
4901 vl_api_sw_interface_dump_t *mp;
4902 vl_api_control_ping_t *mp_ping;
4904 name_sort_t *nses = 0, *ns;
4905 sw_interface_subif_t *sub = NULL;
4908 /* Toss the old name table */
4910 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4912 vec_add2 (nses, ns, 1);
4913 ns->name = (u8 *)(p->key);
4914 ns->value = (u32) p->value[0];
4918 hash_free (vam->sw_if_index_by_interface_name);
4920 vec_foreach (ns, nses) vec_free (ns->name);
4924 vec_foreach (sub, vam->sw_if_subif_table)
4926 vec_free (sub->interface_name);
4928 vec_free (vam->sw_if_subif_table);
4930 /* recreate the interface name hash table */
4931 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4933 /* Get list of ethernets */
4934 M (SW_INTERFACE_DUMP, mp);
4935 mp->name_filter_valid = 1;
4936 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4939 /* and local / loopback interfaces */
4940 M (SW_INTERFACE_DUMP, mp);
4941 mp->name_filter_valid = 1;
4942 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4945 /* and packet-generator interfaces */
4946 M (SW_INTERFACE_DUMP, mp);
4947 mp->name_filter_valid = 1;
4948 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4951 /* and vxlan-gpe tunnel interfaces */
4952 M (SW_INTERFACE_DUMP, mp);
4953 mp->name_filter_valid = 1;
4954 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4955 sizeof (mp->name_filter) - 1);
4958 /* and vxlan tunnel interfaces */
4959 M (SW_INTERFACE_DUMP, mp);
4960 mp->name_filter_valid = 1;
4961 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4964 /* and host (af_packet) interfaces */
4965 M (SW_INTERFACE_DUMP, mp);
4966 mp->name_filter_valid = 1;
4967 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4970 /* and l2tpv3 tunnel interfaces */
4971 M (SW_INTERFACE_DUMP, mp);
4972 mp->name_filter_valid = 1;
4973 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4974 sizeof (mp->name_filter) - 1);
4977 /* and GRE tunnel interfaces */
4978 M (SW_INTERFACE_DUMP, mp);
4979 mp->name_filter_valid = 1;
4980 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4983 /* and LISP-GPE interfaces */
4984 M (SW_INTERFACE_DUMP, mp);
4985 mp->name_filter_valid = 1;
4986 strncpy ((char *) mp->name_filter, "lisp_gpe",
4987 sizeof (mp->name_filter) - 1);
4990 /* and IPSEC tunnel interfaces */
4991 M (SW_INTERFACE_DUMP, mp);
4992 mp->name_filter_valid = 1;
4993 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4996 /* Use a control ping for synchronization */
4997 M (CONTROL_PING, mp_ping);
5005 api_sw_interface_set_flags (vat_main_t * vam)
5007 unformat_input_t *i = vam->input;
5008 vl_api_sw_interface_set_flags_t *mp;
5010 u8 sw_if_index_set = 0;
5011 u8 admin_up = 0, link_up = 0;
5014 /* Parse args required to build the message */
5015 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5017 if (unformat (i, "admin-up"))
5019 else if (unformat (i, "admin-down"))
5021 else if (unformat (i, "link-up"))
5023 else if (unformat (i, "link-down"))
5026 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5027 sw_if_index_set = 1;
5028 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5029 sw_if_index_set = 1;
5034 if (sw_if_index_set == 0)
5036 errmsg ("missing interface name or sw_if_index");
5040 /* Construct the API message */
5041 M (SW_INTERFACE_SET_FLAGS, mp);
5042 mp->sw_if_index = ntohl (sw_if_index);
5043 mp->admin_up_down = admin_up;
5044 mp->link_up_down = link_up;
5049 /* Wait for a reply, return the good/bad news... */
5055 api_sw_interface_clear_stats (vat_main_t * vam)
5057 unformat_input_t *i = vam->input;
5058 vl_api_sw_interface_clear_stats_t *mp;
5060 u8 sw_if_index_set = 0;
5063 /* Parse args required to build the message */
5064 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5066 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5067 sw_if_index_set = 1;
5068 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5069 sw_if_index_set = 1;
5074 /* Construct the API message */
5075 M (SW_INTERFACE_CLEAR_STATS, mp);
5077 if (sw_if_index_set == 1)
5078 mp->sw_if_index = ntohl (sw_if_index);
5080 mp->sw_if_index = ~0;
5085 /* Wait for a reply, return the good/bad news... */
5091 api_sw_interface_add_del_address (vat_main_t * vam)
5093 unformat_input_t *i = vam->input;
5094 vl_api_sw_interface_add_del_address_t *mp;
5096 u8 sw_if_index_set = 0;
5097 u8 is_add = 1, del_all = 0;
5098 u32 address_length = 0;
5099 u8 v4_address_set = 0;
5100 u8 v6_address_set = 0;
5101 ip4_address_t v4address;
5102 ip6_address_t v6address;
5105 /* Parse args required to build the message */
5106 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5108 if (unformat (i, "del-all"))
5110 else if (unformat (i, "del"))
5113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5114 sw_if_index_set = 1;
5115 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5116 sw_if_index_set = 1;
5117 else if (unformat (i, "%U/%d",
5118 unformat_ip4_address, &v4address, &address_length))
5120 else if (unformat (i, "%U/%d",
5121 unformat_ip6_address, &v6address, &address_length))
5127 if (sw_if_index_set == 0)
5129 errmsg ("missing interface name or sw_if_index");
5132 if (v4_address_set && v6_address_set)
5134 errmsg ("both v4 and v6 addresses set");
5137 if (!v4_address_set && !v6_address_set && !del_all)
5139 errmsg ("no addresses set");
5143 /* Construct the API message */
5144 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5146 mp->sw_if_index = ntohl (sw_if_index);
5147 mp->is_add = is_add;
5148 mp->del_all = del_all;
5152 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5156 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5158 mp->address_length = address_length;
5163 /* Wait for a reply, return good/bad news */
5169 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5171 unformat_input_t *i = vam->input;
5172 vl_api_sw_interface_set_mpls_enable_t *mp;
5174 u8 sw_if_index_set = 0;
5178 /* Parse args required to build the message */
5179 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5181 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5182 sw_if_index_set = 1;
5183 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5184 sw_if_index_set = 1;
5185 else if (unformat (i, "disable"))
5187 else if (unformat (i, "dis"))
5193 if (sw_if_index_set == 0)
5195 errmsg ("missing interface name or sw_if_index");
5199 /* Construct the API message */
5200 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5202 mp->sw_if_index = ntohl (sw_if_index);
5203 mp->enable = enable;
5208 /* Wait for a reply... */
5214 api_sw_interface_set_table (vat_main_t * vam)
5216 unformat_input_t *i = vam->input;
5217 vl_api_sw_interface_set_table_t *mp;
5218 u32 sw_if_index, vrf_id = 0;
5219 u8 sw_if_index_set = 0;
5223 /* Parse args required to build the message */
5224 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5226 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5227 sw_if_index_set = 1;
5228 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5229 sw_if_index_set = 1;
5230 else if (unformat (i, "vrf %d", &vrf_id))
5232 else if (unformat (i, "ipv6"))
5238 if (sw_if_index_set == 0)
5240 errmsg ("missing interface name or sw_if_index");
5244 /* Construct the API message */
5245 M (SW_INTERFACE_SET_TABLE, mp);
5247 mp->sw_if_index = ntohl (sw_if_index);
5248 mp->is_ipv6 = is_ipv6;
5249 mp->vrf_id = ntohl (vrf_id);
5254 /* Wait for a reply... */
5259 static void vl_api_sw_interface_get_table_reply_t_handler
5260 (vl_api_sw_interface_get_table_reply_t * mp)
5262 vat_main_t *vam = &vat_main;
5264 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5266 vam->retval = ntohl (mp->retval);
5267 vam->result_ready = 1;
5271 static void vl_api_sw_interface_get_table_reply_t_handler_json
5272 (vl_api_sw_interface_get_table_reply_t * mp)
5274 vat_main_t *vam = &vat_main;
5275 vat_json_node_t node;
5277 vat_json_init_object (&node);
5278 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5279 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5281 vat_json_print (vam->ofp, &node);
5282 vat_json_free (&node);
5284 vam->retval = ntohl (mp->retval);
5285 vam->result_ready = 1;
5289 api_sw_interface_get_table (vat_main_t * vam)
5291 unformat_input_t *i = vam->input;
5292 vl_api_sw_interface_get_table_t *mp;
5294 u8 sw_if_index_set = 0;
5298 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5300 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5301 sw_if_index_set = 1;
5302 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5303 sw_if_index_set = 1;
5304 else if (unformat (i, "ipv6"))
5310 if (sw_if_index_set == 0)
5312 errmsg ("missing interface name or sw_if_index");
5316 M (SW_INTERFACE_GET_TABLE, mp);
5317 mp->sw_if_index = htonl (sw_if_index);
5318 mp->is_ipv6 = is_ipv6;
5326 api_sw_interface_set_vpath (vat_main_t * vam)
5328 unformat_input_t *i = vam->input;
5329 vl_api_sw_interface_set_vpath_t *mp;
5330 u32 sw_if_index = 0;
5331 u8 sw_if_index_set = 0;
5335 /* Parse args required to build the message */
5336 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5338 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5339 sw_if_index_set = 1;
5340 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5341 sw_if_index_set = 1;
5342 else if (unformat (i, "enable"))
5344 else if (unformat (i, "disable"))
5350 if (sw_if_index_set == 0)
5352 errmsg ("missing interface name or sw_if_index");
5356 /* Construct the API message */
5357 M (SW_INTERFACE_SET_VPATH, mp);
5359 mp->sw_if_index = ntohl (sw_if_index);
5360 mp->enable = is_enable;
5365 /* Wait for a reply... */
5371 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5373 unformat_input_t *i = vam->input;
5374 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5375 u32 sw_if_index = 0;
5376 u8 sw_if_index_set = 0;
5381 /* Parse args required to build the message */
5382 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5384 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5385 sw_if_index_set = 1;
5386 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5387 sw_if_index_set = 1;
5388 else if (unformat (i, "enable"))
5390 else if (unformat (i, "disable"))
5392 else if (unformat (i, "ip4"))
5394 else if (unformat (i, "ip6"))
5400 if (sw_if_index_set == 0)
5402 errmsg ("missing interface name or sw_if_index");
5406 /* Construct the API message */
5407 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5409 mp->sw_if_index = ntohl (sw_if_index);
5410 mp->enable = is_enable;
5411 mp->is_ipv6 = is_ipv6;
5416 /* Wait for a reply... */
5422 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5424 unformat_input_t *i = vam->input;
5425 vl_api_sw_interface_set_l2_xconnect_t *mp;
5427 u8 rx_sw_if_index_set = 0;
5429 u8 tx_sw_if_index_set = 0;
5433 /* Parse args required to build the message */
5434 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5436 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5437 rx_sw_if_index_set = 1;
5438 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5439 tx_sw_if_index_set = 1;
5440 else if (unformat (i, "rx"))
5442 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5444 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5446 rx_sw_if_index_set = 1;
5451 else if (unformat (i, "tx"))
5453 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5455 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5457 tx_sw_if_index_set = 1;
5462 else if (unformat (i, "enable"))
5464 else if (unformat (i, "disable"))
5470 if (rx_sw_if_index_set == 0)
5472 errmsg ("missing rx interface name or rx_sw_if_index");
5476 if (enable && (tx_sw_if_index_set == 0))
5478 errmsg ("missing tx interface name or tx_sw_if_index");
5482 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5484 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5485 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5486 mp->enable = enable;
5494 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5496 unformat_input_t *i = vam->input;
5497 vl_api_sw_interface_set_l2_bridge_t *mp;
5499 u8 rx_sw_if_index_set = 0;
5507 /* Parse args required to build the message */
5508 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5510 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5511 rx_sw_if_index_set = 1;
5512 else if (unformat (i, "bd_id %d", &bd_id))
5516 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5517 rx_sw_if_index_set = 1;
5518 else if (unformat (i, "shg %d", &shg))
5520 else if (unformat (i, "bvi"))
5522 else if (unformat (i, "enable"))
5524 else if (unformat (i, "disable"))
5530 if (rx_sw_if_index_set == 0)
5532 errmsg ("missing rx interface name or sw_if_index");
5536 if (enable && (bd_id_set == 0))
5538 errmsg ("missing bridge domain");
5542 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5544 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5545 mp->bd_id = ntohl (bd_id);
5548 mp->enable = enable;
5556 api_bridge_domain_dump (vat_main_t * vam)
5558 unformat_input_t *i = vam->input;
5559 vl_api_bridge_domain_dump_t *mp;
5560 vl_api_control_ping_t *mp_ping;
5564 /* Parse args required to build the message */
5565 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5567 if (unformat (i, "bd_id %d", &bd_id))
5573 M (BRIDGE_DOMAIN_DUMP, mp);
5574 mp->bd_id = ntohl (bd_id);
5577 /* Use a control ping for synchronization */
5578 M (CONTROL_PING, mp_ping);
5586 api_bridge_domain_add_del (vat_main_t * vam)
5588 unformat_input_t *i = vam->input;
5589 vl_api_bridge_domain_add_del_t *mp;
5592 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5596 /* Parse args required to build the message */
5597 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5599 if (unformat (i, "bd_id %d", &bd_id))
5601 else if (unformat (i, "flood %d", &flood))
5603 else if (unformat (i, "uu-flood %d", &uu_flood))
5605 else if (unformat (i, "forward %d", &forward))
5607 else if (unformat (i, "learn %d", &learn))
5609 else if (unformat (i, "arp-term %d", &arp_term))
5611 else if (unformat (i, "mac-age %d", &mac_age))
5613 else if (unformat (i, "del"))
5616 flood = uu_flood = forward = learn = 0;
5624 errmsg ("missing bridge domain");
5630 errmsg ("mac age must be less than 256 ");
5634 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5636 mp->bd_id = ntohl (bd_id);
5638 mp->uu_flood = uu_flood;
5639 mp->forward = forward;
5641 mp->arp_term = arp_term;
5642 mp->is_add = is_add;
5643 mp->mac_age = (u8) mac_age;
5651 api_l2fib_add_del (vat_main_t * vam)
5653 unformat_input_t *i = vam->input;
5654 vl_api_l2fib_add_del_t *mp;
5660 u32 sw_if_index = ~0;
5661 u8 sw_if_index_set = 0;
5670 /* Parse args required to build the message */
5671 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5673 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5675 else if (unformat (i, "bd_id %d", &bd_id))
5677 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5678 sw_if_index_set = 1;
5679 else if (unformat (i, "sw_if"))
5681 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5684 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5685 sw_if_index_set = 1;
5690 else if (unformat (i, "static"))
5692 else if (unformat (i, "filter"))
5697 else if (unformat (i, "bvi"))
5702 else if (unformat (i, "del"))
5704 else if (unformat (i, "count %d", &count))
5712 errmsg ("missing mac address");
5718 errmsg ("missing bridge domain");
5722 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5724 errmsg ("missing interface name or sw_if_index");
5730 /* Turn on async mode */
5731 vam->async_mode = 1;
5732 vam->async_errors = 0;
5733 before = vat_time_now (vam);
5736 for (j = 0; j < count; j++)
5738 M (L2FIB_ADD_DEL, mp);
5741 mp->bd_id = ntohl (bd_id);
5742 mp->is_add = is_add;
5746 mp->sw_if_index = ntohl (sw_if_index);
5747 mp->static_mac = static_mac;
5748 mp->filter_mac = filter_mac;
5749 mp->bvi_mac = bvi_mac;
5751 increment_mac_address (&mac);
5758 vl_api_control_ping_t *mp_ping;
5761 /* Shut off async mode */
5762 vam->async_mode = 0;
5764 M (CONTROL_PING, mp_ping);
5767 timeout = vat_time_now (vam) + 1.0;
5768 while (vat_time_now (vam) < timeout)
5769 if (vam->result_ready == 1)
5774 if (vam->retval == -99)
5777 if (vam->async_errors > 0)
5779 errmsg ("%d asynchronous errors", vam->async_errors);
5782 vam->async_errors = 0;
5783 after = vat_time_now (vam);
5785 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5786 count, after - before, count / (after - before));
5792 /* Wait for a reply... */
5796 /* Return the good/bad news */
5797 return (vam->retval);
5801 api_l2_flags (vat_main_t * vam)
5803 unformat_input_t *i = vam->input;
5804 vl_api_l2_flags_t *mp;
5806 u32 feature_bitmap = 0;
5807 u8 sw_if_index_set = 0;
5810 /* Parse args required to build the message */
5811 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5813 if (unformat (i, "sw_if_index %d", &sw_if_index))
5814 sw_if_index_set = 1;
5815 else if (unformat (i, "sw_if"))
5817 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5820 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5821 sw_if_index_set = 1;
5826 else if (unformat (i, "learn"))
5827 feature_bitmap |= L2INPUT_FEAT_LEARN;
5828 else if (unformat (i, "forward"))
5829 feature_bitmap |= L2INPUT_FEAT_FWD;
5830 else if (unformat (i, "flood"))
5831 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5832 else if (unformat (i, "uu-flood"))
5833 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5838 if (sw_if_index_set == 0)
5840 errmsg ("missing interface name or sw_if_index");
5846 mp->sw_if_index = ntohl (sw_if_index);
5847 mp->feature_bitmap = ntohl (feature_bitmap);
5855 api_bridge_flags (vat_main_t * vam)
5857 unformat_input_t *i = vam->input;
5858 vl_api_bridge_flags_t *mp;
5865 /* Parse args required to build the message */
5866 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5868 if (unformat (i, "bd_id %d", &bd_id))
5870 else if (unformat (i, "learn"))
5872 else if (unformat (i, "forward"))
5874 else if (unformat (i, "flood"))
5876 else if (unformat (i, "uu-flood"))
5877 flags |= L2_UU_FLOOD;
5878 else if (unformat (i, "arp-term"))
5879 flags |= L2_ARP_TERM;
5880 else if (unformat (i, "off"))
5882 else if (unformat (i, "disable"))
5890 errmsg ("missing bridge domain");
5894 M (BRIDGE_FLAGS, mp);
5896 mp->bd_id = ntohl (bd_id);
5897 mp->feature_bitmap = ntohl (flags);
5898 mp->is_set = is_set;
5906 api_bd_ip_mac_add_del (vat_main_t * vam)
5908 unformat_input_t *i = vam->input;
5909 vl_api_bd_ip_mac_add_del_t *mp;
5916 ip4_address_t v4addr;
5917 ip6_address_t v6addr;
5922 /* Parse args required to build the message */
5923 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5925 if (unformat (i, "bd_id %d", &bd_id))
5929 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5933 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5938 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5942 else if (unformat (i, "del"))
5950 errmsg ("missing bridge domain");
5953 else if (ip_set == 0)
5955 errmsg ("missing IP address");
5958 else if (mac_set == 0)
5960 errmsg ("missing MAC address");
5964 M (BD_IP_MAC_ADD_DEL, mp);
5966 mp->bd_id = ntohl (bd_id);
5967 mp->is_ipv6 = is_ipv6;
5968 mp->is_add = is_add;
5970 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5972 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5973 clib_memcpy (mp->mac_address, macaddr, 6);
5980 api_tap_connect (vat_main_t * vam)
5982 unformat_input_t *i = vam->input;
5983 vl_api_tap_connect_t *mp;
5989 ip4_address_t ip4_address;
5991 int ip4_address_set = 0;
5992 ip6_address_t ip6_address;
5994 int ip6_address_set = 0;
5997 memset (mac_address, 0, sizeof (mac_address));
5999 /* Parse args required to build the message */
6000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6002 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6006 else if (unformat (i, "random-mac"))
6008 else if (unformat (i, "tapname %s", &tap_name))
6010 else if (unformat (i, "tag %s", &tag))
6012 else if (unformat (i, "address %U/%d",
6013 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6014 ip4_address_set = 1;
6015 else if (unformat (i, "address %U/%d",
6016 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6017 ip6_address_set = 1;
6024 errmsg ("missing tap name");
6027 if (vec_len (tap_name) > 63)
6029 errmsg ("tap name too long");
6032 vec_add1 (tap_name, 0);
6034 if (vec_len (tag) > 63)
6036 errmsg ("tag too long");
6040 /* Construct the API message */
6041 M (TAP_CONNECT, mp);
6043 mp->use_random_mac = random_mac;
6044 clib_memcpy (mp->mac_address, mac_address, 6);
6045 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6047 clib_memcpy (mp->tag, tag, vec_len (tag));
6049 if (ip4_address_set)
6051 mp->ip4_address_set = 1;
6052 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6053 mp->ip4_mask_width = ip4_mask_width;
6055 if (ip6_address_set)
6057 mp->ip6_address_set = 1;
6058 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6059 mp->ip6_mask_width = ip6_mask_width;
6062 vec_free (tap_name);
6068 /* Wait for a reply... */
6074 api_tap_modify (vat_main_t * vam)
6076 unformat_input_t *i = vam->input;
6077 vl_api_tap_modify_t *mp;
6082 u32 sw_if_index = ~0;
6083 u8 sw_if_index_set = 0;
6086 memset (mac_address, 0, sizeof (mac_address));
6088 /* Parse args required to build the message */
6089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6092 sw_if_index_set = 1;
6093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6094 sw_if_index_set = 1;
6095 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6099 else if (unformat (i, "random-mac"))
6101 else if (unformat (i, "tapname %s", &tap_name))
6107 if (sw_if_index_set == 0)
6109 errmsg ("missing vpp interface name");
6114 errmsg ("missing tap name");
6117 if (vec_len (tap_name) > 63)
6119 errmsg ("tap name too long");
6121 vec_add1 (tap_name, 0);
6123 /* Construct the API message */
6126 mp->use_random_mac = random_mac;
6127 mp->sw_if_index = ntohl (sw_if_index);
6128 clib_memcpy (mp->mac_address, mac_address, 6);
6129 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6130 vec_free (tap_name);
6135 /* Wait for a reply... */
6141 api_tap_delete (vat_main_t * vam)
6143 unformat_input_t *i = vam->input;
6144 vl_api_tap_delete_t *mp;
6145 u32 sw_if_index = ~0;
6146 u8 sw_if_index_set = 0;
6149 /* Parse args required to build the message */
6150 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6153 sw_if_index_set = 1;
6154 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6155 sw_if_index_set = 1;
6160 if (sw_if_index_set == 0)
6162 errmsg ("missing vpp interface name");
6166 /* Construct the API message */
6169 mp->sw_if_index = ntohl (sw_if_index);
6174 /* Wait for a reply... */
6180 api_ip_add_del_route (vat_main_t * vam)
6182 unformat_input_t *i = vam->input;
6183 vl_api_ip_add_del_route_t *mp;
6184 u32 sw_if_index = ~0, vrf_id = 0;
6186 u8 is_local = 0, is_drop = 0;
6187 u8 is_unreach = 0, is_prohibit = 0;
6188 u8 create_vrf_if_needed = 0;
6190 u32 next_hop_weight = 1;
6192 u8 is_multipath = 0;
6194 u8 address_length_set = 0;
6195 u32 next_hop_table_id = 0;
6196 u32 resolve_attempts = 0;
6197 u32 dst_address_length = 0;
6198 u8 next_hop_set = 0;
6199 ip4_address_t v4_dst_address, v4_next_hop_address;
6200 ip6_address_t v6_dst_address, v6_next_hop_address;
6204 u32 random_add_del = 0;
6205 u32 *random_vector = 0;
6207 u32 random_seed = 0xdeaddabe;
6208 u32 classify_table_index = ~0;
6210 u8 resolve_host = 0, resolve_attached = 0;
6211 mpls_label_t *next_hop_out_label_stack = NULL;
6212 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6213 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6215 /* Parse args required to build the message */
6216 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6218 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6220 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6222 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6227 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6232 else if (unformat (i, "/%d", &dst_address_length))
6234 address_length_set = 1;
6237 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6238 &v4_next_hop_address))
6242 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6243 &v6_next_hop_address))
6247 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6249 else if (unformat (i, "weight %d", &next_hop_weight))
6251 else if (unformat (i, "drop"))
6255 else if (unformat (i, "null-send-unreach"))
6259 else if (unformat (i, "null-send-prohibit"))
6263 else if (unformat (i, "local"))
6267 else if (unformat (i, "classify %d", &classify_table_index))
6271 else if (unformat (i, "del"))
6273 else if (unformat (i, "add"))
6275 else if (unformat (i, "not-last"))
6277 else if (unformat (i, "resolve-via-host"))
6279 else if (unformat (i, "resolve-via-attached"))
6280 resolve_attached = 1;
6281 else if (unformat (i, "multipath"))
6283 else if (unformat (i, "vrf %d", &vrf_id))
6285 else if (unformat (i, "create-vrf"))
6286 create_vrf_if_needed = 1;
6287 else if (unformat (i, "count %d", &count))
6289 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6291 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6293 else if (unformat (i, "out-label %d", &next_hop_out_label))
6294 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6295 else if (unformat (i, "via-label %d", &next_hop_via_label))
6297 else if (unformat (i, "random"))
6299 else if (unformat (i, "seed %d", &random_seed))
6303 clib_warning ("parse error '%U'", format_unformat_error, i);
6308 if (!next_hop_set && !is_drop && !is_local &&
6309 !is_classify && !is_unreach && !is_prohibit &&
6310 MPLS_LABEL_INVALID == next_hop_via_label)
6313 ("next hop / local / drop / unreach / prohibit / classify not set");
6317 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6319 errmsg ("next hop and next-hop via label set");
6322 if (address_set == 0)
6324 errmsg ("missing addresses");
6328 if (address_length_set == 0)
6330 errmsg ("missing address length");
6334 /* Generate a pile of unique, random routes */
6337 u32 this_random_address;
6338 random_hash = hash_create (count, sizeof (uword));
6340 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6341 for (j = 0; j <= count; j++)
6345 this_random_address = random_u32 (&random_seed);
6346 this_random_address =
6347 clib_host_to_net_u32 (this_random_address);
6349 while (hash_get (random_hash, this_random_address));
6350 vec_add1 (random_vector, this_random_address);
6351 hash_set (random_hash, this_random_address, 1);
6353 hash_free (random_hash);
6354 v4_dst_address.as_u32 = random_vector[0];
6359 /* Turn on async mode */
6360 vam->async_mode = 1;
6361 vam->async_errors = 0;
6362 before = vat_time_now (vam);
6365 for (j = 0; j < count; j++)
6367 /* Construct the API message */
6368 M2 (IP_ADD_DEL_ROUTE, mp,
6369 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6371 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6372 mp->table_id = ntohl (vrf_id);
6373 mp->create_vrf_if_needed = create_vrf_if_needed;
6375 mp->is_add = is_add;
6376 mp->is_drop = is_drop;
6377 mp->is_unreach = is_unreach;
6378 mp->is_prohibit = is_prohibit;
6379 mp->is_ipv6 = is_ipv6;
6380 mp->is_local = is_local;
6381 mp->is_classify = is_classify;
6382 mp->is_multipath = is_multipath;
6383 mp->is_resolve_host = resolve_host;
6384 mp->is_resolve_attached = resolve_attached;
6385 mp->not_last = not_last;
6386 mp->next_hop_weight = next_hop_weight;
6387 mp->dst_address_length = dst_address_length;
6388 mp->next_hop_table_id = ntohl (next_hop_table_id);
6389 mp->classify_table_index = ntohl (classify_table_index);
6390 mp->next_hop_via_label = ntohl (next_hop_via_label);
6391 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6392 if (0 != mp->next_hop_n_out_labels)
6394 memcpy (mp->next_hop_out_label_stack,
6395 next_hop_out_label_stack,
6396 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6397 vec_free (next_hop_out_label_stack);
6402 clib_memcpy (mp->dst_address, &v6_dst_address,
6403 sizeof (v6_dst_address));
6405 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6406 sizeof (v6_next_hop_address));
6407 increment_v6_address (&v6_dst_address);
6411 clib_memcpy (mp->dst_address, &v4_dst_address,
6412 sizeof (v4_dst_address));
6414 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6415 sizeof (v4_next_hop_address));
6417 v4_dst_address.as_u32 = random_vector[j + 1];
6419 increment_v4_address (&v4_dst_address);
6423 /* If we receive SIGTERM, stop now... */
6428 /* When testing multiple add/del ops, use a control-ping to sync */
6431 vl_api_control_ping_t *mp_ping;
6435 /* Shut off async mode */
6436 vam->async_mode = 0;
6438 M (CONTROL_PING, mp_ping);
6441 timeout = vat_time_now (vam) + 1.0;
6442 while (vat_time_now (vam) < timeout)
6443 if (vam->result_ready == 1)
6448 if (vam->retval == -99)
6451 if (vam->async_errors > 0)
6453 errmsg ("%d asynchronous errors", vam->async_errors);
6456 vam->async_errors = 0;
6457 after = vat_time_now (vam);
6459 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6463 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6464 count, after - before, count / (after - before));
6470 /* Wait for a reply... */
6475 /* Return the good/bad news */
6476 return (vam->retval);
6480 api_ip_mroute_add_del (vat_main_t * vam)
6482 unformat_input_t *i = vam->input;
6483 vl_api_ip_mroute_add_del_t *mp;
6484 u32 sw_if_index = ~0, vrf_id = 0;
6487 u8 create_vrf_if_needed = 0;
6490 u32 grp_address_length = 0;
6491 ip4_address_t v4_grp_address, v4_src_address;
6492 ip6_address_t v6_grp_address, v6_src_address;
6493 mfib_itf_flags_t iflags = 0;
6494 mfib_entry_flags_t eflags = 0;
6497 /* Parse args required to build the message */
6498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6500 if (unformat (i, "sw_if_index %d", &sw_if_index))
6502 else if (unformat (i, "%U %U",
6503 unformat_ip4_address, &v4_src_address,
6504 unformat_ip4_address, &v4_grp_address))
6506 grp_address_length = 64;
6510 else if (unformat (i, "%U %U",
6511 unformat_ip6_address, &v6_src_address,
6512 unformat_ip6_address, &v6_grp_address))
6514 grp_address_length = 256;
6518 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6520 memset (&v4_src_address, 0, sizeof (v4_src_address));
6521 grp_address_length = 32;
6525 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6527 memset (&v6_src_address, 0, sizeof (v6_src_address));
6528 grp_address_length = 128;
6532 else if (unformat (i, "/%d", &grp_address_length))
6534 else if (unformat (i, "local"))
6538 else if (unformat (i, "del"))
6540 else if (unformat (i, "add"))
6542 else if (unformat (i, "vrf %d", &vrf_id))
6544 else if (unformat (i, "create-vrf"))
6545 create_vrf_if_needed = 1;
6546 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6548 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6552 clib_warning ("parse error '%U'", format_unformat_error, i);
6557 if (address_set == 0)
6559 errmsg ("missing addresses\n");
6563 /* Construct the API message */
6564 M (IP_MROUTE_ADD_DEL, mp);
6566 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6567 mp->table_id = ntohl (vrf_id);
6568 mp->create_vrf_if_needed = create_vrf_if_needed;
6570 mp->is_add = is_add;
6571 mp->is_ipv6 = is_ipv6;
6572 mp->is_local = is_local;
6573 mp->itf_flags = ntohl (iflags);
6574 mp->entry_flags = ntohl (eflags);
6575 mp->grp_address_length = grp_address_length;
6576 mp->grp_address_length = ntohs (mp->grp_address_length);
6580 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6581 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6585 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6586 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6592 /* Wait for a reply... */
6598 api_mpls_route_add_del (vat_main_t * vam)
6600 unformat_input_t *i = vam->input;
6601 vl_api_mpls_route_add_del_t *mp;
6602 u32 sw_if_index = ~0, table_id = 0;
6603 u8 create_table_if_needed = 0;
6605 u32 next_hop_weight = 1;
6606 u8 is_multipath = 0;
6607 u32 next_hop_table_id = 0;
6608 u8 next_hop_set = 0;
6609 ip4_address_t v4_next_hop_address = {
6612 ip6_address_t v6_next_hop_address = { {0} };
6616 u32 classify_table_index = ~0;
6618 u8 resolve_host = 0, resolve_attached = 0;
6619 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6620 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6621 mpls_label_t *next_hop_out_label_stack = NULL;
6622 mpls_label_t local_label = MPLS_LABEL_INVALID;
6624 u8 next_hop_proto_is_ip4 = 1;
6626 /* Parse args required to build the message */
6627 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6629 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6631 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6633 else if (unformat (i, "%d", &local_label))
6635 else if (unformat (i, "eos"))
6637 else if (unformat (i, "non-eos"))
6639 else if (unformat (i, "via %U", unformat_ip4_address,
6640 &v4_next_hop_address))
6643 next_hop_proto_is_ip4 = 1;
6645 else if (unformat (i, "via %U", unformat_ip6_address,
6646 &v6_next_hop_address))
6649 next_hop_proto_is_ip4 = 0;
6651 else if (unformat (i, "weight %d", &next_hop_weight))
6653 else if (unformat (i, "create-table"))
6654 create_table_if_needed = 1;
6655 else if (unformat (i, "classify %d", &classify_table_index))
6659 else if (unformat (i, "del"))
6661 else if (unformat (i, "add"))
6663 else if (unformat (i, "resolve-via-host"))
6665 else if (unformat (i, "resolve-via-attached"))
6666 resolve_attached = 1;
6667 else if (unformat (i, "multipath"))
6669 else if (unformat (i, "count %d", &count))
6671 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6674 next_hop_proto_is_ip4 = 1;
6676 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6679 next_hop_proto_is_ip4 = 0;
6681 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6683 else if (unformat (i, "via-label %d", &next_hop_via_label))
6685 else if (unformat (i, "out-label %d", &next_hop_out_label))
6686 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6689 clib_warning ("parse error '%U'", format_unformat_error, i);
6694 if (!next_hop_set && !is_classify)
6696 errmsg ("next hop / classify not set");
6700 if (MPLS_LABEL_INVALID == local_label)
6702 errmsg ("missing label");
6708 /* Turn on async mode */
6709 vam->async_mode = 1;
6710 vam->async_errors = 0;
6711 before = vat_time_now (vam);
6714 for (j = 0; j < count; j++)
6716 /* Construct the API message */
6717 M2 (MPLS_ROUTE_ADD_DEL, mp,
6718 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6720 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6721 mp->mr_table_id = ntohl (table_id);
6722 mp->mr_create_table_if_needed = create_table_if_needed;
6724 mp->mr_is_add = is_add;
6725 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6726 mp->mr_is_classify = is_classify;
6727 mp->mr_is_multipath = is_multipath;
6728 mp->mr_is_resolve_host = resolve_host;
6729 mp->mr_is_resolve_attached = resolve_attached;
6730 mp->mr_next_hop_weight = next_hop_weight;
6731 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6732 mp->mr_classify_table_index = ntohl (classify_table_index);
6733 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6734 mp->mr_label = ntohl (local_label);
6735 mp->mr_eos = is_eos;
6737 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6738 if (0 != mp->mr_next_hop_n_out_labels)
6740 memcpy (mp->mr_next_hop_out_label_stack,
6741 next_hop_out_label_stack,
6742 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6743 vec_free (next_hop_out_label_stack);
6748 if (next_hop_proto_is_ip4)
6750 clib_memcpy (mp->mr_next_hop,
6751 &v4_next_hop_address,
6752 sizeof (v4_next_hop_address));
6756 clib_memcpy (mp->mr_next_hop,
6757 &v6_next_hop_address,
6758 sizeof (v6_next_hop_address));
6765 /* If we receive SIGTERM, stop now... */
6770 /* When testing multiple add/del ops, use a control-ping to sync */
6773 vl_api_control_ping_t *mp_ping;
6777 /* Shut off async mode */
6778 vam->async_mode = 0;
6780 M (CONTROL_PING, mp_ping);
6783 timeout = vat_time_now (vam) + 1.0;
6784 while (vat_time_now (vam) < timeout)
6785 if (vam->result_ready == 1)
6790 if (vam->retval == -99)
6793 if (vam->async_errors > 0)
6795 errmsg ("%d asynchronous errors", vam->async_errors);
6798 vam->async_errors = 0;
6799 after = vat_time_now (vam);
6801 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6805 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6806 count, after - before, count / (after - before));
6812 /* Wait for a reply... */
6817 /* Return the good/bad news */
6818 return (vam->retval);
6822 api_mpls_ip_bind_unbind (vat_main_t * vam)
6824 unformat_input_t *i = vam->input;
6825 vl_api_mpls_ip_bind_unbind_t *mp;
6826 u32 ip_table_id = 0;
6827 u8 create_table_if_needed = 0;
6830 ip4_address_t v4_address;
6831 ip6_address_t v6_address;
6834 mpls_label_t local_label = MPLS_LABEL_INVALID;
6837 /* Parse args required to build the message */
6838 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6840 if (unformat (i, "%U/%d", unformat_ip4_address,
6841 &v4_address, &address_length))
6846 else if (unformat (i, "%U/%d", unformat_ip6_address,
6847 &v6_address, &address_length))
6852 else if (unformat (i, "%d", &local_label))
6854 else if (unformat (i, "create-table"))
6855 create_table_if_needed = 1;
6856 else if (unformat (i, "table-id %d", &ip_table_id))
6858 else if (unformat (i, "unbind"))
6860 else if (unformat (i, "bind"))
6864 clib_warning ("parse error '%U'", format_unformat_error, i);
6871 errmsg ("IP addres not set");
6875 if (MPLS_LABEL_INVALID == local_label)
6877 errmsg ("missing label");
6881 /* Construct the API message */
6882 M (MPLS_IP_BIND_UNBIND, mp);
6884 mp->mb_create_table_if_needed = create_table_if_needed;
6885 mp->mb_is_bind = is_bind;
6886 mp->mb_is_ip4 = is_ip4;
6887 mp->mb_ip_table_id = ntohl (ip_table_id);
6888 mp->mb_mpls_table_id = 0;
6889 mp->mb_label = ntohl (local_label);
6890 mp->mb_address_length = address_length;
6893 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6895 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6900 /* Wait for a reply... */
6906 api_proxy_arp_add_del (vat_main_t * vam)
6908 unformat_input_t *i = vam->input;
6909 vl_api_proxy_arp_add_del_t *mp;
6912 ip4_address_t lo, hi;
6916 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6918 if (unformat (i, "vrf %d", &vrf_id))
6920 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6921 unformat_ip4_address, &hi))
6923 else if (unformat (i, "del"))
6927 clib_warning ("parse error '%U'", format_unformat_error, i);
6934 errmsg ("address range not set");
6938 M (PROXY_ARP_ADD_DEL, mp);
6940 mp->vrf_id = ntohl (vrf_id);
6941 mp->is_add = is_add;
6942 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6943 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6951 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6953 unformat_input_t *i = vam->input;
6954 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6957 u8 sw_if_index_set = 0;
6960 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6962 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6963 sw_if_index_set = 1;
6964 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6965 sw_if_index_set = 1;
6966 else if (unformat (i, "enable"))
6968 else if (unformat (i, "disable"))
6972 clib_warning ("parse error '%U'", format_unformat_error, i);
6977 if (sw_if_index_set == 0)
6979 errmsg ("missing interface name or sw_if_index");
6983 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
6985 mp->sw_if_index = ntohl (sw_if_index);
6986 mp->enable_disable = enable;
6994 api_mpls_tunnel_add_del (vat_main_t * vam)
6996 unformat_input_t *i = vam->input;
6997 vl_api_mpls_tunnel_add_del_t *mp;
7001 u32 sw_if_index = ~0;
7002 u32 next_hop_sw_if_index = ~0;
7003 u32 next_hop_proto_is_ip4 = 1;
7005 u32 next_hop_table_id = 0;
7006 ip4_address_t v4_next_hop_address = {
7009 ip6_address_t v6_next_hop_address = { {0} };
7010 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7015 if (unformat (i, "add"))
7017 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7019 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7021 else if (unformat (i, "via %U",
7022 unformat_ip4_address, &v4_next_hop_address))
7024 next_hop_proto_is_ip4 = 1;
7026 else if (unformat (i, "via %U",
7027 unformat_ip6_address, &v6_next_hop_address))
7029 next_hop_proto_is_ip4 = 0;
7031 else if (unformat (i, "l2-only"))
7033 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7035 else if (unformat (i, "out-label %d", &next_hop_out_label))
7036 vec_add1 (labels, ntohl (next_hop_out_label));
7039 clib_warning ("parse error '%U'", format_unformat_error, i);
7044 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7046 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7047 mp->mt_sw_if_index = ntohl (sw_if_index);
7048 mp->mt_is_add = is_add;
7049 mp->mt_l2_only = l2_only;
7050 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7051 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7053 mp->mt_next_hop_n_out_labels = vec_len (labels);
7055 if (0 != mp->mt_next_hop_n_out_labels)
7057 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7058 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7062 if (next_hop_proto_is_ip4)
7064 clib_memcpy (mp->mt_next_hop,
7065 &v4_next_hop_address, sizeof (v4_next_hop_address));
7069 clib_memcpy (mp->mt_next_hop,
7070 &v6_next_hop_address, sizeof (v6_next_hop_address));
7079 api_sw_interface_set_unnumbered (vat_main_t * vam)
7081 unformat_input_t *i = vam->input;
7082 vl_api_sw_interface_set_unnumbered_t *mp;
7084 u32 unnum_sw_index = ~0;
7086 u8 sw_if_index_set = 0;
7089 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7091 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7092 sw_if_index_set = 1;
7093 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7094 sw_if_index_set = 1;
7095 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7097 else if (unformat (i, "del"))
7101 clib_warning ("parse error '%U'", format_unformat_error, i);
7106 if (sw_if_index_set == 0)
7108 errmsg ("missing interface name or sw_if_index");
7112 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7114 mp->sw_if_index = ntohl (sw_if_index);
7115 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7116 mp->is_add = is_add;
7124 api_ip_neighbor_add_del (vat_main_t * vam)
7126 unformat_input_t *i = vam->input;
7127 vl_api_ip_neighbor_add_del_t *mp;
7129 u8 sw_if_index_set = 0;
7134 u8 v4_address_set = 0;
7135 u8 v6_address_set = 0;
7136 ip4_address_t v4address;
7137 ip6_address_t v6address;
7140 memset (mac_address, 0, sizeof (mac_address));
7142 /* Parse args required to build the message */
7143 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7145 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7149 else if (unformat (i, "del"))
7152 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7153 sw_if_index_set = 1;
7154 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7155 sw_if_index_set = 1;
7156 else if (unformat (i, "is_static"))
7158 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7160 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7164 clib_warning ("parse error '%U'", format_unformat_error, i);
7169 if (sw_if_index_set == 0)
7171 errmsg ("missing interface name or sw_if_index");
7174 if (v4_address_set && v6_address_set)
7176 errmsg ("both v4 and v6 addresses set");
7179 if (!v4_address_set && !v6_address_set)
7181 errmsg ("no address set");
7185 /* Construct the API message */
7186 M (IP_NEIGHBOR_ADD_DEL, mp);
7188 mp->sw_if_index = ntohl (sw_if_index);
7189 mp->is_add = is_add;
7190 mp->is_static = is_static;
7192 clib_memcpy (mp->mac_address, mac_address, 6);
7196 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7200 /* mp->is_ipv6 = 0; via memset in M macro above */
7201 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7207 /* Wait for a reply, return good/bad news */
7213 api_reset_vrf (vat_main_t * vam)
7215 unformat_input_t *i = vam->input;
7216 vl_api_reset_vrf_t *mp;
7222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7224 if (unformat (i, "vrf %d", &vrf_id))
7226 else if (unformat (i, "ipv6"))
7230 clib_warning ("parse error '%U'", format_unformat_error, i);
7235 if (vrf_id_set == 0)
7237 errmsg ("missing vrf id");
7243 mp->vrf_id = ntohl (vrf_id);
7244 mp->is_ipv6 = is_ipv6;
7252 api_create_vlan_subif (vat_main_t * vam)
7254 unformat_input_t *i = vam->input;
7255 vl_api_create_vlan_subif_t *mp;
7257 u8 sw_if_index_set = 0;
7262 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7264 if (unformat (i, "sw_if_index %d", &sw_if_index))
7265 sw_if_index_set = 1;
7267 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7268 sw_if_index_set = 1;
7269 else if (unformat (i, "vlan %d", &vlan_id))
7273 clib_warning ("parse error '%U'", format_unformat_error, i);
7278 if (sw_if_index_set == 0)
7280 errmsg ("missing interface name or sw_if_index");
7284 if (vlan_id_set == 0)
7286 errmsg ("missing vlan_id");
7289 M (CREATE_VLAN_SUBIF, mp);
7291 mp->sw_if_index = ntohl (sw_if_index);
7292 mp->vlan_id = ntohl (vlan_id);
7299 #define foreach_create_subif_bit \
7306 _(outer_vlan_id_any) \
7307 _(inner_vlan_id_any)
7310 api_create_subif (vat_main_t * vam)
7312 unformat_input_t *i = vam->input;
7313 vl_api_create_subif_t *mp;
7315 u8 sw_if_index_set = 0;
7322 u32 exact_match = 0;
7323 u32 default_sub = 0;
7324 u32 outer_vlan_id_any = 0;
7325 u32 inner_vlan_id_any = 0;
7327 u16 outer_vlan_id = 0;
7328 u16 inner_vlan_id = 0;
7331 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7333 if (unformat (i, "sw_if_index %d", &sw_if_index))
7334 sw_if_index_set = 1;
7336 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7337 sw_if_index_set = 1;
7338 else if (unformat (i, "sub_id %d", &sub_id))
7340 else if (unformat (i, "outer_vlan_id %d", &tmp))
7341 outer_vlan_id = tmp;
7342 else if (unformat (i, "inner_vlan_id %d", &tmp))
7343 inner_vlan_id = tmp;
7345 #define _(a) else if (unformat (i, #a)) a = 1 ;
7346 foreach_create_subif_bit
7350 clib_warning ("parse error '%U'", format_unformat_error, i);
7355 if (sw_if_index_set == 0)
7357 errmsg ("missing interface name or sw_if_index");
7361 if (sub_id_set == 0)
7363 errmsg ("missing sub_id");
7366 M (CREATE_SUBIF, mp);
7368 mp->sw_if_index = ntohl (sw_if_index);
7369 mp->sub_id = ntohl (sub_id);
7371 #define _(a) mp->a = a;
7372 foreach_create_subif_bit;
7375 mp->outer_vlan_id = ntohs (outer_vlan_id);
7376 mp->inner_vlan_id = ntohs (inner_vlan_id);
7384 api_oam_add_del (vat_main_t * vam)
7386 unformat_input_t *i = vam->input;
7387 vl_api_oam_add_del_t *mp;
7390 ip4_address_t src, dst;
7395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7397 if (unformat (i, "vrf %d", &vrf_id))
7399 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7401 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7403 else if (unformat (i, "del"))
7407 clib_warning ("parse error '%U'", format_unformat_error, i);
7414 errmsg ("missing src addr");
7420 errmsg ("missing dst addr");
7424 M (OAM_ADD_DEL, mp);
7426 mp->vrf_id = ntohl (vrf_id);
7427 mp->is_add = is_add;
7428 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7429 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7437 api_reset_fib (vat_main_t * vam)
7439 unformat_input_t *i = vam->input;
7440 vl_api_reset_fib_t *mp;
7446 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7448 if (unformat (i, "vrf %d", &vrf_id))
7450 else if (unformat (i, "ipv6"))
7454 clib_warning ("parse error '%U'", format_unformat_error, i);
7459 if (vrf_id_set == 0)
7461 errmsg ("missing vrf id");
7467 mp->vrf_id = ntohl (vrf_id);
7468 mp->is_ipv6 = is_ipv6;
7476 api_dhcp_proxy_config (vat_main_t * vam)
7478 unformat_input_t *i = vam->input;
7479 vl_api_dhcp_proxy_config_t *mp;
7481 u32 server_vrf_id = 0;
7483 u8 v4_address_set = 0;
7484 u8 v6_address_set = 0;
7485 ip4_address_t v4address;
7486 ip6_address_t v6address;
7487 u8 v4_src_address_set = 0;
7488 u8 v6_src_address_set = 0;
7489 ip4_address_t v4srcaddress;
7490 ip6_address_t v6srcaddress;
7493 /* Parse args required to build the message */
7494 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7496 if (unformat (i, "del"))
7498 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7500 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7502 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7504 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7506 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7507 v4_src_address_set = 1;
7508 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7509 v6_src_address_set = 1;
7514 if (v4_address_set && v6_address_set)
7516 errmsg ("both v4 and v6 server addresses set");
7519 if (!v4_address_set && !v6_address_set)
7521 errmsg ("no server addresses set");
7525 if (v4_src_address_set && v6_src_address_set)
7527 errmsg ("both v4 and v6 src addresses set");
7530 if (!v4_src_address_set && !v6_src_address_set)
7532 errmsg ("no src addresses set");
7536 if (!(v4_src_address_set && v4_address_set) &&
7537 !(v6_src_address_set && v6_address_set))
7539 errmsg ("no matching server and src addresses set");
7543 /* Construct the API message */
7544 M (DHCP_PROXY_CONFIG, mp);
7546 mp->is_add = is_add;
7547 mp->rx_vrf_id = ntohl (rx_vrf_id);
7548 mp->server_vrf_id = ntohl (server_vrf_id);
7552 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7553 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7557 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7558 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7564 /* Wait for a reply, return good/bad news */
7569 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7570 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7573 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7575 vat_main_t *vam = &vat_main;
7576 u32 i, count = mp->count;
7577 vl_api_dhcp_server_t *s;
7581 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7582 ntohl (mp->rx_vrf_id),
7583 format_ip6_address, mp->dhcp_src_address,
7584 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7587 "RX Table-ID %d, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7588 ntohl (mp->rx_vrf_id),
7589 format_ip4_address, mp->dhcp_src_address,
7590 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7592 for (i = 0; i < count; i++)
7594 s = &mp->servers[i];
7598 " Server Table-ID %d, Server Address %U",
7599 ntohl (s->server_vrf_id), format_ip6_address, s->dhcp_server);
7602 " Server Table-ID %d, Server Address %U",
7603 ntohl (s->server_vrf_id), format_ip4_address, s->dhcp_server);
7607 static void vl_api_dhcp_proxy_details_t_handler_json
7608 (vl_api_dhcp_proxy_details_t * mp)
7610 vat_main_t *vam = &vat_main;
7611 vat_json_node_t *node = NULL;
7612 u32 i, count = mp->count;
7614 struct in6_addr ip6;
7615 vl_api_dhcp_server_t *s;
7617 if (VAT_JSON_ARRAY != vam->json_tree.type)
7619 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7620 vat_json_init_array (&vam->json_tree);
7622 node = vat_json_array_add (&vam->json_tree);
7624 vat_json_init_object (node);
7625 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7626 vat_json_object_add_uint (node, "vss-fib-id", ntohl (mp->vss_fib_id));
7627 vat_json_object_add_uint (node, "vss-oui", ntohl (mp->vss_oui));
7631 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7632 vat_json_object_add_ip6 (node, "src_address", ip6);
7636 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7637 vat_json_object_add_ip4 (node, "src_address", ip4);
7640 for (i = 0; i < count; i++)
7642 s = &mp->servers[i];
7644 vat_json_object_add_uint (node, "server-table-id",
7645 ntohl (s->server_vrf_id));
7649 clib_memcpy (&ip4, &s->dhcp_server, sizeof (ip4));
7650 vat_json_object_add_ip4 (node, "src_address", ip4);
7654 clib_memcpy (&ip6, &s->dhcp_server, sizeof (ip6));
7655 vat_json_object_add_ip6 (node, "server_address", ip6);
7661 api_dhcp_proxy_dump (vat_main_t * vam)
7663 unformat_input_t *i = vam->input;
7664 vl_api_control_ping_t *mp_ping;
7665 vl_api_dhcp_proxy_dump_t *mp;
7669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7671 if (unformat (i, "ipv6"))
7675 clib_warning ("parse error '%U'", format_unformat_error, i);
7680 M (DHCP_PROXY_DUMP, mp);
7682 mp->is_ip6 = is_ipv6;
7685 /* Use a control ping for synchronization */
7686 M (CONTROL_PING, mp_ping);
7694 api_dhcp_proxy_set_vss (vat_main_t * vam)
7696 unformat_input_t *i = vam->input;
7697 vl_api_dhcp_proxy_set_vss_t *mp;
7708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7710 if (unformat (i, "tbl_id %d", &tbl_id))
7712 if (unformat (i, "fib_id %d", &fib_id))
7714 if (unformat (i, "oui %d", &oui))
7716 else if (unformat (i, "ipv6"))
7718 else if (unformat (i, "del"))
7722 clib_warning ("parse error '%U'", format_unformat_error, i);
7727 if (tbl_id_set == 0)
7729 errmsg ("missing tbl id");
7733 if (fib_id_set == 0)
7735 errmsg ("missing fib id");
7740 errmsg ("missing oui");
7744 M (DHCP_PROXY_SET_VSS, mp);
7745 mp->tbl_id = ntohl (tbl_id);
7746 mp->fib_id = ntohl (fib_id);
7747 mp->oui = ntohl (oui);
7748 mp->is_ipv6 = is_ipv6;
7749 mp->is_add = is_add;
7757 api_dhcp_client_config (vat_main_t * vam)
7759 unformat_input_t *i = vam->input;
7760 vl_api_dhcp_client_config_t *mp;
7762 u8 sw_if_index_set = 0;
7765 u8 disable_event = 0;
7768 /* Parse args required to build the message */
7769 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7771 if (unformat (i, "del"))
7774 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7775 sw_if_index_set = 1;
7776 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7777 sw_if_index_set = 1;
7778 else if (unformat (i, "hostname %s", &hostname))
7780 else if (unformat (i, "disable_event"))
7786 if (sw_if_index_set == 0)
7788 errmsg ("missing interface name or sw_if_index");
7792 if (vec_len (hostname) > 63)
7794 errmsg ("hostname too long");
7796 vec_add1 (hostname, 0);
7798 /* Construct the API message */
7799 M (DHCP_CLIENT_CONFIG, mp);
7801 mp->sw_if_index = ntohl (sw_if_index);
7802 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7803 vec_free (hostname);
7804 mp->is_add = is_add;
7805 mp->want_dhcp_event = disable_event ? 0 : 1;
7806 mp->pid = getpid ();
7811 /* Wait for a reply, return good/bad news */
7817 api_set_ip_flow_hash (vat_main_t * vam)
7819 unformat_input_t *i = vam->input;
7820 vl_api_set_ip_flow_hash_t *mp;
7832 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7834 if (unformat (i, "vrf %d", &vrf_id))
7836 else if (unformat (i, "ipv6"))
7838 else if (unformat (i, "src"))
7840 else if (unformat (i, "dst"))
7842 else if (unformat (i, "sport"))
7844 else if (unformat (i, "dport"))
7846 else if (unformat (i, "proto"))
7848 else if (unformat (i, "reverse"))
7853 clib_warning ("parse error '%U'", format_unformat_error, i);
7858 if (vrf_id_set == 0)
7860 errmsg ("missing vrf id");
7864 M (SET_IP_FLOW_HASH, mp);
7870 mp->reverse = reverse;
7871 mp->vrf_id = ntohl (vrf_id);
7872 mp->is_ipv6 = is_ipv6;
7880 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7882 unformat_input_t *i = vam->input;
7883 vl_api_sw_interface_ip6_enable_disable_t *mp;
7885 u8 sw_if_index_set = 0;
7889 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7891 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7892 sw_if_index_set = 1;
7893 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7894 sw_if_index_set = 1;
7895 else if (unformat (i, "enable"))
7897 else if (unformat (i, "disable"))
7901 clib_warning ("parse error '%U'", format_unformat_error, i);
7906 if (sw_if_index_set == 0)
7908 errmsg ("missing interface name or sw_if_index");
7912 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7914 mp->sw_if_index = ntohl (sw_if_index);
7915 mp->enable = enable;
7923 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7925 unformat_input_t *i = vam->input;
7926 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7928 u8 sw_if_index_set = 0;
7929 u8 v6_address_set = 0;
7930 ip6_address_t v6address;
7933 /* Parse args required to build the message */
7934 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7936 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7937 sw_if_index_set = 1;
7938 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7939 sw_if_index_set = 1;
7940 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7946 if (sw_if_index_set == 0)
7948 errmsg ("missing interface name or sw_if_index");
7951 if (!v6_address_set)
7953 errmsg ("no address set");
7957 /* Construct the API message */
7958 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
7960 mp->sw_if_index = ntohl (sw_if_index);
7961 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7966 /* Wait for a reply, return good/bad news */
7973 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7975 unformat_input_t *i = vam->input;
7976 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7978 u8 sw_if_index_set = 0;
7979 u32 address_length = 0;
7980 u8 v6_address_set = 0;
7981 ip6_address_t v6address;
7983 u8 no_advertise = 0;
7985 u8 no_autoconfig = 0;
7988 u32 val_lifetime = 0;
7989 u32 pref_lifetime = 0;
7992 /* Parse args required to build the message */
7993 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7995 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7996 sw_if_index_set = 1;
7997 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7998 sw_if_index_set = 1;
7999 else if (unformat (i, "%U/%d",
8000 unformat_ip6_address, &v6address, &address_length))
8002 else if (unformat (i, "val_life %d", &val_lifetime))
8004 else if (unformat (i, "pref_life %d", &pref_lifetime))
8006 else if (unformat (i, "def"))
8008 else if (unformat (i, "noadv"))
8010 else if (unformat (i, "offl"))
8012 else if (unformat (i, "noauto"))
8014 else if (unformat (i, "nolink"))
8016 else if (unformat (i, "isno"))
8020 clib_warning ("parse error '%U'", format_unformat_error, i);
8025 if (sw_if_index_set == 0)
8027 errmsg ("missing interface name or sw_if_index");
8030 if (!v6_address_set)
8032 errmsg ("no address set");
8036 /* Construct the API message */
8037 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8039 mp->sw_if_index = ntohl (sw_if_index);
8040 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8041 mp->address_length = address_length;
8042 mp->use_default = use_default;
8043 mp->no_advertise = no_advertise;
8044 mp->off_link = off_link;
8045 mp->no_autoconfig = no_autoconfig;
8046 mp->no_onlink = no_onlink;
8048 mp->val_lifetime = ntohl (val_lifetime);
8049 mp->pref_lifetime = ntohl (pref_lifetime);
8054 /* Wait for a reply, return good/bad news */
8060 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8062 unformat_input_t *i = vam->input;
8063 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8065 u8 sw_if_index_set = 0;
8070 u8 send_unicast = 0;
8073 u8 default_router = 0;
8074 u32 max_interval = 0;
8075 u32 min_interval = 0;
8077 u32 initial_count = 0;
8078 u32 initial_interval = 0;
8082 /* Parse args required to build the message */
8083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8085 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8086 sw_if_index_set = 1;
8087 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8088 sw_if_index_set = 1;
8089 else if (unformat (i, "maxint %d", &max_interval))
8091 else if (unformat (i, "minint %d", &min_interval))
8093 else if (unformat (i, "life %d", &lifetime))
8095 else if (unformat (i, "count %d", &initial_count))
8097 else if (unformat (i, "interval %d", &initial_interval))
8099 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8101 else if (unformat (i, "managed"))
8103 else if (unformat (i, "other"))
8105 else if (unformat (i, "ll"))
8107 else if (unformat (i, "send"))
8109 else if (unformat (i, "cease"))
8111 else if (unformat (i, "isno"))
8113 else if (unformat (i, "def"))
8117 clib_warning ("parse error '%U'", format_unformat_error, i);
8122 if (sw_if_index_set == 0)
8124 errmsg ("missing interface name or sw_if_index");
8128 /* Construct the API message */
8129 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8131 mp->sw_if_index = ntohl (sw_if_index);
8132 mp->max_interval = ntohl (max_interval);
8133 mp->min_interval = ntohl (min_interval);
8134 mp->lifetime = ntohl (lifetime);
8135 mp->initial_count = ntohl (initial_count);
8136 mp->initial_interval = ntohl (initial_interval);
8137 mp->suppress = suppress;
8138 mp->managed = managed;
8140 mp->ll_option = ll_option;
8141 mp->send_unicast = send_unicast;
8144 mp->default_router = default_router;
8149 /* Wait for a reply, return good/bad news */
8155 api_set_arp_neighbor_limit (vat_main_t * vam)
8157 unformat_input_t *i = vam->input;
8158 vl_api_set_arp_neighbor_limit_t *mp;
8164 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8166 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8168 else if (unformat (i, "ipv6"))
8172 clib_warning ("parse error '%U'", format_unformat_error, i);
8179 errmsg ("missing limit value");
8183 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8185 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8186 mp->is_ipv6 = is_ipv6;
8194 api_l2_patch_add_del (vat_main_t * vam)
8196 unformat_input_t *i = vam->input;
8197 vl_api_l2_patch_add_del_t *mp;
8199 u8 rx_sw_if_index_set = 0;
8201 u8 tx_sw_if_index_set = 0;
8205 /* Parse args required to build the message */
8206 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8208 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8209 rx_sw_if_index_set = 1;
8210 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8211 tx_sw_if_index_set = 1;
8212 else if (unformat (i, "rx"))
8214 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8216 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8218 rx_sw_if_index_set = 1;
8223 else if (unformat (i, "tx"))
8225 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8227 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8229 tx_sw_if_index_set = 1;
8234 else if (unformat (i, "del"))
8240 if (rx_sw_if_index_set == 0)
8242 errmsg ("missing rx interface name or rx_sw_if_index");
8246 if (tx_sw_if_index_set == 0)
8248 errmsg ("missing tx interface name or tx_sw_if_index");
8252 M (L2_PATCH_ADD_DEL, mp);
8254 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8255 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8256 mp->is_add = is_add;
8264 u8 localsid_addr[16];
8273 api_sr_localsid_add_del (vat_main_t * vam)
8275 unformat_input_t *i = vam->input;
8276 vl_api_sr_localsid_add_del_t *mp;
8279 ip6_address_t localsid;
8283 u32 fib_table = ~(u32) 0;
8284 ip6_address_t next_hop;
8286 bool nexthop_set = 0;
8290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8292 if (unformat (i, "del"))
8294 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8295 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8297 else if (unformat (i, "behavior %u", &behavior));
8298 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8299 else if (unformat (i, "fib-table %u", &fib_table));
8300 else if (unformat (i, "end.psp %u", &behavior));
8305 M (SR_LOCALSID_ADD_DEL, mp);
8307 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8309 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8310 mp->behavior = behavior;
8311 mp->sw_if_index = ntohl (sw_if_index);
8312 mp->fib_table = ntohl (fib_table);
8313 mp->end_psp = end_psp;
8314 mp->is_del = is_del;
8322 api_ioam_enable (vat_main_t * vam)
8324 unformat_input_t *input = vam->input;
8325 vl_api_ioam_enable_t *mp;
8327 int has_trace_option = 0;
8328 int has_pot_option = 0;
8329 int has_seqno_option = 0;
8330 int has_analyse_option = 0;
8333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8335 if (unformat (input, "trace"))
8336 has_trace_option = 1;
8337 else if (unformat (input, "pot"))
8339 else if (unformat (input, "seqno"))
8340 has_seqno_option = 1;
8341 else if (unformat (input, "analyse"))
8342 has_analyse_option = 1;
8346 M (IOAM_ENABLE, mp);
8347 mp->id = htons (id);
8348 mp->seqno = has_seqno_option;
8349 mp->analyse = has_analyse_option;
8350 mp->pot_enable = has_pot_option;
8351 mp->trace_enable = has_trace_option;
8360 api_ioam_disable (vat_main_t * vam)
8362 vl_api_ioam_disable_t *mp;
8365 M (IOAM_DISABLE, mp);
8371 #define foreach_tcp_proto_field \
8375 #define foreach_udp_proto_field \
8379 #define foreach_ip4_proto_field \
8391 u16 src_port, dst_port;
8394 #if VPP_API_TEST_BUILTIN == 0
8396 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8398 u8 **maskp = va_arg (*args, u8 **);
8400 u8 found_something = 0;
8403 #define _(a) u8 a=0;
8404 foreach_tcp_proto_field;
8407 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8410 #define _(a) else if (unformat (input, #a)) a=1;
8411 foreach_tcp_proto_field
8417 #define _(a) found_something += a;
8418 foreach_tcp_proto_field;
8421 if (found_something == 0)
8424 vec_validate (mask, sizeof (*tcp) - 1);
8426 tcp = (tcp_header_t *) mask;
8428 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8429 foreach_tcp_proto_field;
8437 unformat_udp_mask (unformat_input_t * input, va_list * args)
8439 u8 **maskp = va_arg (*args, u8 **);
8441 u8 found_something = 0;
8444 #define _(a) u8 a=0;
8445 foreach_udp_proto_field;
8448 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8451 #define _(a) else if (unformat (input, #a)) a=1;
8452 foreach_udp_proto_field
8458 #define _(a) found_something += a;
8459 foreach_udp_proto_field;
8462 if (found_something == 0)
8465 vec_validate (mask, sizeof (*udp) - 1);
8467 udp = (udp_header_t *) mask;
8469 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8470 foreach_udp_proto_field;
8478 unformat_l4_mask (unformat_input_t * input, va_list * args)
8480 u8 **maskp = va_arg (*args, u8 **);
8481 u16 src_port = 0, dst_port = 0;
8482 tcpudp_header_t *tcpudp;
8484 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8486 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8488 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8490 else if (unformat (input, "src_port"))
8492 else if (unformat (input, "dst_port"))
8498 if (!src_port && !dst_port)
8502 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8504 tcpudp = (tcpudp_header_t *) mask;
8505 tcpudp->src_port = src_port;
8506 tcpudp->dst_port = dst_port;
8514 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8516 u8 **maskp = va_arg (*args, u8 **);
8518 u8 found_something = 0;
8521 #define _(a) u8 a=0;
8522 foreach_ip4_proto_field;
8528 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8530 if (unformat (input, "version"))
8532 else if (unformat (input, "hdr_length"))
8534 else if (unformat (input, "src"))
8536 else if (unformat (input, "dst"))
8538 else if (unformat (input, "proto"))
8541 #define _(a) else if (unformat (input, #a)) a=1;
8542 foreach_ip4_proto_field
8548 #define _(a) found_something += a;
8549 foreach_ip4_proto_field;
8552 if (found_something == 0)
8555 vec_validate (mask, sizeof (*ip) - 1);
8557 ip = (ip4_header_t *) mask;
8559 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8560 foreach_ip4_proto_field;
8563 ip->ip_version_and_header_length = 0;
8566 ip->ip_version_and_header_length |= 0xF0;
8569 ip->ip_version_and_header_length |= 0x0F;
8575 #define foreach_ip6_proto_field \
8583 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8585 u8 **maskp = va_arg (*args, u8 **);
8587 u8 found_something = 0;
8589 u32 ip_version_traffic_class_and_flow_label;
8591 #define _(a) u8 a=0;
8592 foreach_ip6_proto_field;
8595 u8 traffic_class = 0;
8598 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8600 if (unformat (input, "version"))
8602 else if (unformat (input, "traffic-class"))
8604 else if (unformat (input, "flow-label"))
8606 else if (unformat (input, "src"))
8608 else if (unformat (input, "dst"))
8610 else if (unformat (input, "proto"))
8613 #define _(a) else if (unformat (input, #a)) a=1;
8614 foreach_ip6_proto_field
8620 #define _(a) found_something += a;
8621 foreach_ip6_proto_field;
8624 if (found_something == 0)
8627 vec_validate (mask, sizeof (*ip) - 1);
8629 ip = (ip6_header_t *) mask;
8631 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8632 foreach_ip6_proto_field;
8635 ip_version_traffic_class_and_flow_label = 0;
8638 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8641 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8644 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8646 ip->ip_version_traffic_class_and_flow_label =
8647 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8654 unformat_l3_mask (unformat_input_t * input, va_list * args)
8656 u8 **maskp = va_arg (*args, u8 **);
8658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8662 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8671 unformat_l2_mask (unformat_input_t * input, va_list * args)
8673 u8 **maskp = va_arg (*args, u8 **);
8688 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8690 if (unformat (input, "src"))
8692 else if (unformat (input, "dst"))
8694 else if (unformat (input, "proto"))
8696 else if (unformat (input, "tag1"))
8698 else if (unformat (input, "tag2"))
8700 else if (unformat (input, "ignore-tag1"))
8702 else if (unformat (input, "ignore-tag2"))
8704 else if (unformat (input, "cos1"))
8706 else if (unformat (input, "cos2"))
8708 else if (unformat (input, "dot1q"))
8710 else if (unformat (input, "dot1ad"))
8715 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8716 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8719 if (tag1 || ignore_tag1 || cos1 || dot1q)
8721 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8724 vec_validate (mask, len - 1);
8727 memset (mask, 0xff, 6);
8730 memset (mask + 6, 0xff, 6);
8734 /* inner vlan tag */
8743 mask[21] = mask[20] = 0xff;
8764 mask[16] = mask[17] = 0xff;
8774 mask[12] = mask[13] = 0xff;
8781 unformat_classify_mask (unformat_input_t * input, va_list * args)
8783 u8 **maskp = va_arg (*args, u8 **);
8784 u32 *skipp = va_arg (*args, u32 *);
8785 u32 *matchp = va_arg (*args, u32 *);
8793 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8795 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8797 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8799 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8801 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8815 if (mask || l2 || l3 || l4)
8819 /* "With a free Ethernet header in every package" */
8821 vec_validate (l2, 13);
8825 vec_append (mask, l3);
8830 vec_append (mask, l4);
8835 /* Scan forward looking for the first significant mask octet */
8836 for (i = 0; i < vec_len (mask); i++)
8840 /* compute (skip, match) params */
8841 *skipp = i / sizeof (u32x4);
8842 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8844 /* Pad mask to an even multiple of the vector size */
8845 while (vec_len (mask) % sizeof (u32x4))
8848 match = vec_len (mask) / sizeof (u32x4);
8850 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8852 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8853 if (*tmp || *(tmp + 1))
8858 clib_warning ("BUG: match 0");
8860 _vec_len (mask) = match * sizeof (u32x4);
8870 #endif /* VPP_API_TEST_BUILTIN */
8872 #define foreach_l2_next \
8874 _(ethernet, ETHERNET_INPUT) \
8879 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8881 u32 *miss_next_indexp = va_arg (*args, u32 *);
8886 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8890 if (unformat (input, "%d", &tmp))
8899 *miss_next_indexp = next_index;
8903 #define foreach_ip_next \
8909 api_unformat_ip_next_index (unformat_input_t * input, va_list * args)
8911 u32 *miss_next_indexp = va_arg (*args, u32 *);
8916 if (unformat (input, #n)) { next_index = IP_LOOKUP_NEXT_##N; goto out;}
8920 if (unformat (input, "%d", &tmp))
8929 *miss_next_indexp = next_index;
8933 #define foreach_acl_next \
8937 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
8939 u32 *miss_next_indexp = va_arg (*args, u32 *);
8944 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8948 if (unformat (input, "permit"))
8953 else if (unformat (input, "%d", &tmp))
8962 *miss_next_indexp = next_index;
8967 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8969 u32 *r = va_arg (*args, u32 *);
8971 if (unformat (input, "conform-color"))
8972 *r = POLICE_CONFORM;
8973 else if (unformat (input, "exceed-color"))
8982 api_classify_add_del_table (vat_main_t * vam)
8984 unformat_input_t *i = vam->input;
8985 vl_api_classify_add_del_table_t *mp;
8992 u32 table_index = ~0;
8993 u32 next_table_index = ~0;
8994 u32 miss_next_index = ~0;
8995 u32 memory_size = 32 << 20;
8997 u32 current_data_flag = 0;
8998 int current_data_offset = 0;
9001 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9003 if (unformat (i, "del"))
9005 else if (unformat (i, "del-chain"))
9010 else if (unformat (i, "buckets %d", &nbuckets))
9012 else if (unformat (i, "memory_size %d", &memory_size))
9014 else if (unformat (i, "skip %d", &skip))
9016 else if (unformat (i, "match %d", &match))
9018 else if (unformat (i, "table %d", &table_index))
9020 else if (unformat (i, "mask %U", unformat_classify_mask,
9021 &mask, &skip, &match))
9023 else if (unformat (i, "next-table %d", &next_table_index))
9025 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
9028 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9031 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9034 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9036 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9042 if (is_add && mask == 0)
9044 errmsg ("Mask required");
9048 if (is_add && skip == ~0)
9050 errmsg ("skip count required");
9054 if (is_add && match == ~0)
9056 errmsg ("match count required");
9060 if (!is_add && table_index == ~0)
9062 errmsg ("table index required for delete");
9066 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9068 mp->is_add = is_add;
9069 mp->del_chain = del_chain;
9070 mp->table_index = ntohl (table_index);
9071 mp->nbuckets = ntohl (nbuckets);
9072 mp->memory_size = ntohl (memory_size);
9073 mp->skip_n_vectors = ntohl (skip);
9074 mp->match_n_vectors = ntohl (match);
9075 mp->next_table_index = ntohl (next_table_index);
9076 mp->miss_next_index = ntohl (miss_next_index);
9077 mp->current_data_flag = ntohl (current_data_flag);
9078 mp->current_data_offset = ntohl (current_data_offset);
9079 clib_memcpy (mp->mask, mask, vec_len (mask));
9088 #if VPP_API_TEST_BUILTIN == 0
9090 unformat_l4_match (unformat_input_t * input, va_list * args)
9092 u8 **matchp = va_arg (*args, u8 **);
9094 u8 *proto_header = 0;
9100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9102 if (unformat (input, "src_port %d", &src_port))
9104 else if (unformat (input, "dst_port %d", &dst_port))
9110 h.src_port = clib_host_to_net_u16 (src_port);
9111 h.dst_port = clib_host_to_net_u16 (dst_port);
9112 vec_validate (proto_header, sizeof (h) - 1);
9113 memcpy (proto_header, &h, sizeof (h));
9115 *matchp = proto_header;
9121 unformat_ip4_match (unformat_input_t * input, va_list * args)
9123 u8 **matchp = va_arg (*args, u8 **);
9130 int src = 0, dst = 0;
9131 ip4_address_t src_val, dst_val;
9138 int fragment_id = 0;
9139 u32 fragment_id_val;
9145 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9147 if (unformat (input, "version %d", &version_val))
9149 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9151 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9153 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9155 else if (unformat (input, "proto %d", &proto_val))
9157 else if (unformat (input, "tos %d", &tos_val))
9159 else if (unformat (input, "length %d", &length_val))
9161 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9163 else if (unformat (input, "ttl %d", &ttl_val))
9165 else if (unformat (input, "checksum %d", &checksum_val))
9171 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9172 + ttl + checksum == 0)
9176 * Aligned because we use the real comparison functions
9178 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9180 ip = (ip4_header_t *) match;
9182 /* These are realistically matched in practice */
9184 ip->src_address.as_u32 = src_val.as_u32;
9187 ip->dst_address.as_u32 = dst_val.as_u32;
9190 ip->protocol = proto_val;
9193 /* These are not, but they're included for completeness */
9195 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9198 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9204 ip->length = clib_host_to_net_u16 (length_val);
9210 ip->checksum = clib_host_to_net_u16 (checksum_val);
9217 unformat_ip6_match (unformat_input_t * input, va_list * args)
9219 u8 **matchp = va_arg (*args, u8 **);
9224 u8 traffic_class = 0;
9225 u32 traffic_class_val = 0;
9228 int src = 0, dst = 0;
9229 ip6_address_t src_val, dst_val;
9232 int payload_length = 0;
9233 u32 payload_length_val;
9236 u32 ip_version_traffic_class_and_flow_label;
9238 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9240 if (unformat (input, "version %d", &version_val))
9242 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9244 else if (unformat (input, "flow_label %d", &flow_label_val))
9246 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9248 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9250 else if (unformat (input, "proto %d", &proto_val))
9252 else if (unformat (input, "payload_length %d", &payload_length_val))
9254 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9260 if (version + traffic_class + flow_label + src + dst + proto +
9261 payload_length + hop_limit == 0)
9265 * Aligned because we use the real comparison functions
9267 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9269 ip = (ip6_header_t *) match;
9272 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9275 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9278 ip->protocol = proto_val;
9280 ip_version_traffic_class_and_flow_label = 0;
9283 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9286 ip_version_traffic_class_and_flow_label |=
9287 (traffic_class_val & 0xFF) << 20;
9290 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9292 ip->ip_version_traffic_class_and_flow_label =
9293 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9296 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9299 ip->hop_limit = hop_limit_val;
9306 unformat_l3_match (unformat_input_t * input, va_list * args)
9308 u8 **matchp = va_arg (*args, u8 **);
9310 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9312 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9314 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9323 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9325 u8 *tagp = va_arg (*args, u8 *);
9328 if (unformat (input, "%d", &tag))
9330 tagp[0] = (tag >> 8) & 0x0F;
9331 tagp[1] = tag & 0xFF;
9339 unformat_l2_match (unformat_input_t * input, va_list * args)
9341 u8 **matchp = va_arg (*args, u8 **);
9361 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9363 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9366 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9368 else if (unformat (input, "proto %U",
9369 unformat_ethernet_type_host_byte_order, &proto_val))
9371 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9373 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9375 else if (unformat (input, "ignore-tag1"))
9377 else if (unformat (input, "ignore-tag2"))
9379 else if (unformat (input, "cos1 %d", &cos1_val))
9381 else if (unformat (input, "cos2 %d", &cos2_val))
9386 if ((src + dst + proto + tag1 + tag2 +
9387 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9390 if (tag1 || ignore_tag1 || cos1)
9392 if (tag2 || ignore_tag2 || cos2)
9395 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9398 clib_memcpy (match, dst_val, 6);
9401 clib_memcpy (match + 6, src_val, 6);
9405 /* inner vlan tag */
9406 match[19] = tag2_val[1];
9407 match[18] = tag2_val[0];
9409 match[18] |= (cos2_val & 0x7) << 5;
9412 match[21] = proto_val & 0xff;
9413 match[20] = proto_val >> 8;
9417 match[15] = tag1_val[1];
9418 match[14] = tag1_val[0];
9421 match[14] |= (cos1_val & 0x7) << 5;
9427 match[15] = tag1_val[1];
9428 match[14] = tag1_val[0];
9431 match[17] = proto_val & 0xff;
9432 match[16] = proto_val >> 8;
9435 match[14] |= (cos1_val & 0x7) << 5;
9441 match[18] |= (cos2_val & 0x7) << 5;
9443 match[14] |= (cos1_val & 0x7) << 5;
9446 match[13] = proto_val & 0xff;
9447 match[12] = proto_val >> 8;
9456 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9458 u8 **matchp = va_arg (*args, u8 **);
9459 u32 skip_n_vectors = va_arg (*args, u32);
9460 u32 match_n_vectors = va_arg (*args, u32);
9467 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9469 if (unformat (input, "hex %U", unformat_hex_string, &match))
9471 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9473 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9475 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9489 if (match || l2 || l3 || l4)
9493 /* "Win a free Ethernet header in every packet" */
9495 vec_validate_aligned (l2, 13, sizeof (u32x4));
9499 vec_append_aligned (match, l3, sizeof (u32x4));
9504 vec_append_aligned (match, l4, sizeof (u32x4));
9509 /* Make sure the vector is big enough even if key is all 0's */
9510 vec_validate_aligned
9511 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9514 /* Set size, include skipped vectors */
9515 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9526 api_classify_add_del_session (vat_main_t * vam)
9528 unformat_input_t *i = vam->input;
9529 vl_api_classify_add_del_session_t *mp;
9531 u32 table_index = ~0;
9532 u32 hit_next_index = ~0;
9533 u32 opaque_index = ~0;
9536 u32 skip_n_vectors = 0;
9537 u32 match_n_vectors = 0;
9543 * Warning: you have to supply skip_n and match_n
9544 * because the API client cant simply look at the classify
9548 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9550 if (unformat (i, "del"))
9552 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9555 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9558 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9561 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9563 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9565 else if (unformat (i, "opaque-index %d", &opaque_index))
9567 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9569 else if (unformat (i, "match_n %d", &match_n_vectors))
9571 else if (unformat (i, "match %U", api_unformat_classify_match,
9572 &match, skip_n_vectors, match_n_vectors))
9574 else if (unformat (i, "advance %d", &advance))
9576 else if (unformat (i, "table-index %d", &table_index))
9578 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9580 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9582 else if (unformat (i, "action %d", &action))
9584 else if (unformat (i, "metadata %d", &metadata))
9590 if (table_index == ~0)
9592 errmsg ("Table index required");
9596 if (is_add && match == 0)
9598 errmsg ("Match value required");
9602 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9604 mp->is_add = is_add;
9605 mp->table_index = ntohl (table_index);
9606 mp->hit_next_index = ntohl (hit_next_index);
9607 mp->opaque_index = ntohl (opaque_index);
9608 mp->advance = ntohl (advance);
9609 mp->action = action;
9610 mp->metadata = ntohl (metadata);
9611 clib_memcpy (mp->match, match, vec_len (match));
9620 api_classify_set_interface_ip_table (vat_main_t * vam)
9622 unformat_input_t *i = vam->input;
9623 vl_api_classify_set_interface_ip_table_t *mp;
9625 int sw_if_index_set;
9626 u32 table_index = ~0;
9630 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9632 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9633 sw_if_index_set = 1;
9634 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9635 sw_if_index_set = 1;
9636 else if (unformat (i, "table %d", &table_index))
9640 clib_warning ("parse error '%U'", format_unformat_error, i);
9645 if (sw_if_index_set == 0)
9647 errmsg ("missing interface name or sw_if_index");
9652 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9654 mp->sw_if_index = ntohl (sw_if_index);
9655 mp->table_index = ntohl (table_index);
9656 mp->is_ipv6 = is_ipv6;
9664 api_classify_set_interface_l2_tables (vat_main_t * vam)
9666 unformat_input_t *i = vam->input;
9667 vl_api_classify_set_interface_l2_tables_t *mp;
9669 int sw_if_index_set;
9670 u32 ip4_table_index = ~0;
9671 u32 ip6_table_index = ~0;
9672 u32 other_table_index = ~0;
9676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9678 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9679 sw_if_index_set = 1;
9680 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9681 sw_if_index_set = 1;
9682 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9684 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9686 else if (unformat (i, "other-table %d", &other_table_index))
9688 else if (unformat (i, "is-input %d", &is_input))
9692 clib_warning ("parse error '%U'", format_unformat_error, i);
9697 if (sw_if_index_set == 0)
9699 errmsg ("missing interface name or sw_if_index");
9704 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9706 mp->sw_if_index = ntohl (sw_if_index);
9707 mp->ip4_table_index = ntohl (ip4_table_index);
9708 mp->ip6_table_index = ntohl (ip6_table_index);
9709 mp->other_table_index = ntohl (other_table_index);
9710 mp->is_input = (u8) is_input;
9718 api_set_ipfix_exporter (vat_main_t * vam)
9720 unformat_input_t *i = vam->input;
9721 vl_api_set_ipfix_exporter_t *mp;
9722 ip4_address_t collector_address;
9723 u8 collector_address_set = 0;
9724 u32 collector_port = ~0;
9725 ip4_address_t src_address;
9726 u8 src_address_set = 0;
9729 u32 template_interval = ~0;
9730 u8 udp_checksum = 0;
9733 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9735 if (unformat (i, "collector_address %U", unformat_ip4_address,
9736 &collector_address))
9737 collector_address_set = 1;
9738 else if (unformat (i, "collector_port %d", &collector_port))
9740 else if (unformat (i, "src_address %U", unformat_ip4_address,
9742 src_address_set = 1;
9743 else if (unformat (i, "vrf_id %d", &vrf_id))
9745 else if (unformat (i, "path_mtu %d", &path_mtu))
9747 else if (unformat (i, "template_interval %d", &template_interval))
9749 else if (unformat (i, "udp_checksum"))
9755 if (collector_address_set == 0)
9757 errmsg ("collector_address required");
9761 if (src_address_set == 0)
9763 errmsg ("src_address required");
9767 M (SET_IPFIX_EXPORTER, mp);
9769 memcpy (mp->collector_address, collector_address.data,
9770 sizeof (collector_address.data));
9771 mp->collector_port = htons ((u16) collector_port);
9772 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9773 mp->vrf_id = htonl (vrf_id);
9774 mp->path_mtu = htonl (path_mtu);
9775 mp->template_interval = htonl (template_interval);
9776 mp->udp_checksum = udp_checksum;
9784 api_set_ipfix_classify_stream (vat_main_t * vam)
9786 unformat_input_t *i = vam->input;
9787 vl_api_set_ipfix_classify_stream_t *mp;
9789 u32 src_port = UDP_DST_PORT_ipfix;
9792 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9794 if (unformat (i, "domain %d", &domain_id))
9796 else if (unformat (i, "src_port %d", &src_port))
9800 errmsg ("unknown input `%U'", format_unformat_error, i);
9805 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9807 mp->domain_id = htonl (domain_id);
9808 mp->src_port = htons ((u16) src_port);
9816 api_ipfix_classify_table_add_del (vat_main_t * vam)
9818 unformat_input_t *i = vam->input;
9819 vl_api_ipfix_classify_table_add_del_t *mp;
9821 u32 classify_table_index = ~0;
9823 u8 transport_protocol = 255;
9826 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9828 if (unformat (i, "add"))
9830 else if (unformat (i, "del"))
9832 else if (unformat (i, "table %d", &classify_table_index))
9834 else if (unformat (i, "ip4"))
9836 else if (unformat (i, "ip6"))
9838 else if (unformat (i, "tcp"))
9839 transport_protocol = 6;
9840 else if (unformat (i, "udp"))
9841 transport_protocol = 17;
9844 errmsg ("unknown input `%U'", format_unformat_error, i);
9851 errmsg ("expecting: add|del");
9854 if (classify_table_index == ~0)
9856 errmsg ("classifier table not specified");
9859 if (ip_version == 0)
9861 errmsg ("IP version not specified");
9865 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
9867 mp->is_add = is_add;
9868 mp->table_id = htonl (classify_table_index);
9869 mp->ip_version = ip_version;
9870 mp->transport_protocol = transport_protocol;
9878 api_get_node_index (vat_main_t * vam)
9880 unformat_input_t *i = vam->input;
9881 vl_api_get_node_index_t *mp;
9885 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9887 if (unformat (i, "node %s", &name))
9894 errmsg ("node name required");
9897 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9899 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9903 M (GET_NODE_INDEX, mp);
9904 clib_memcpy (mp->node_name, name, vec_len (name));
9913 api_get_next_index (vat_main_t * vam)
9915 unformat_input_t *i = vam->input;
9916 vl_api_get_next_index_t *mp;
9917 u8 *node_name = 0, *next_node_name = 0;
9920 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9922 if (unformat (i, "node-name %s", &node_name))
9924 else if (unformat (i, "next-node-name %s", &next_node_name))
9930 errmsg ("node name required");
9933 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9935 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9939 if (next_node_name == 0)
9941 errmsg ("next node name required");
9944 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9946 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9950 M (GET_NEXT_INDEX, mp);
9951 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9952 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9953 vec_free (node_name);
9954 vec_free (next_node_name);
9962 api_add_node_next (vat_main_t * vam)
9964 unformat_input_t *i = vam->input;
9965 vl_api_add_node_next_t *mp;
9970 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9972 if (unformat (i, "node %s", &name))
9974 else if (unformat (i, "next %s", &next))
9981 errmsg ("node name required");
9984 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9986 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9991 errmsg ("next node required");
9994 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9996 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
10000 M (ADD_NODE_NEXT, mp);
10001 clib_memcpy (mp->node_name, name, vec_len (name));
10002 clib_memcpy (mp->next_name, next, vec_len (next));
10012 api_l2tpv3_create_tunnel (vat_main_t * vam)
10014 unformat_input_t *i = vam->input;
10015 ip6_address_t client_address, our_address;
10016 int client_address_set = 0;
10017 int our_address_set = 0;
10018 u32 local_session_id = 0;
10019 u32 remote_session_id = 0;
10020 u64 local_cookie = 0;
10021 u64 remote_cookie = 0;
10022 u8 l2_sublayer_present = 0;
10023 vl_api_l2tpv3_create_tunnel_t *mp;
10026 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10028 if (unformat (i, "client_address %U", unformat_ip6_address,
10030 client_address_set = 1;
10031 else if (unformat (i, "our_address %U", unformat_ip6_address,
10033 our_address_set = 1;
10034 else if (unformat (i, "local_session_id %d", &local_session_id))
10036 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10038 else if (unformat (i, "local_cookie %lld", &local_cookie))
10040 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10042 else if (unformat (i, "l2-sublayer-present"))
10043 l2_sublayer_present = 1;
10048 if (client_address_set == 0)
10050 errmsg ("client_address required");
10054 if (our_address_set == 0)
10056 errmsg ("our_address required");
10060 M (L2TPV3_CREATE_TUNNEL, mp);
10062 clib_memcpy (mp->client_address, client_address.as_u8,
10063 sizeof (mp->client_address));
10065 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10067 mp->local_session_id = ntohl (local_session_id);
10068 mp->remote_session_id = ntohl (remote_session_id);
10069 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10070 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10071 mp->l2_sublayer_present = l2_sublayer_present;
10080 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10082 unformat_input_t *i = vam->input;
10084 u8 sw_if_index_set = 0;
10085 u64 new_local_cookie = 0;
10086 u64 new_remote_cookie = 0;
10087 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10090 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10092 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10093 sw_if_index_set = 1;
10094 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10095 sw_if_index_set = 1;
10096 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10098 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10104 if (sw_if_index_set == 0)
10106 errmsg ("missing interface name or sw_if_index");
10110 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10112 mp->sw_if_index = ntohl (sw_if_index);
10113 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10114 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10122 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10124 unformat_input_t *i = vam->input;
10125 vl_api_l2tpv3_interface_enable_disable_t *mp;
10127 u8 sw_if_index_set = 0;
10128 u8 enable_disable = 1;
10131 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10133 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10134 sw_if_index_set = 1;
10135 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10136 sw_if_index_set = 1;
10137 else if (unformat (i, "enable"))
10138 enable_disable = 1;
10139 else if (unformat (i, "disable"))
10140 enable_disable = 0;
10145 if (sw_if_index_set == 0)
10147 errmsg ("missing interface name or sw_if_index");
10151 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10153 mp->sw_if_index = ntohl (sw_if_index);
10154 mp->enable_disable = enable_disable;
10162 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10164 unformat_input_t *i = vam->input;
10165 vl_api_l2tpv3_set_lookup_key_t *mp;
10169 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10171 if (unformat (i, "lookup_v6_src"))
10172 key = L2T_LOOKUP_SRC_ADDRESS;
10173 else if (unformat (i, "lookup_v6_dst"))
10174 key = L2T_LOOKUP_DST_ADDRESS;
10175 else if (unformat (i, "lookup_session_id"))
10176 key = L2T_LOOKUP_SESSION_ID;
10181 if (key == (u8) ~ 0)
10183 errmsg ("l2tp session lookup key unset");
10187 M (L2TPV3_SET_LOOKUP_KEY, mp);
10196 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10197 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10199 vat_main_t *vam = &vat_main;
10201 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10202 format_ip6_address, mp->our_address,
10203 format_ip6_address, mp->client_address,
10204 clib_net_to_host_u32 (mp->sw_if_index));
10207 " local cookies %016llx %016llx remote cookie %016llx",
10208 clib_net_to_host_u64 (mp->local_cookie[0]),
10209 clib_net_to_host_u64 (mp->local_cookie[1]),
10210 clib_net_to_host_u64 (mp->remote_cookie));
10212 print (vam->ofp, " local session-id %d remote session-id %d",
10213 clib_net_to_host_u32 (mp->local_session_id),
10214 clib_net_to_host_u32 (mp->remote_session_id));
10216 print (vam->ofp, " l2 specific sublayer %s\n",
10217 mp->l2_sublayer_present ? "preset" : "absent");
10221 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10222 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10224 vat_main_t *vam = &vat_main;
10225 vat_json_node_t *node = NULL;
10226 struct in6_addr addr;
10228 if (VAT_JSON_ARRAY != vam->json_tree.type)
10230 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10231 vat_json_init_array (&vam->json_tree);
10233 node = vat_json_array_add (&vam->json_tree);
10235 vat_json_init_object (node);
10237 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10238 vat_json_object_add_ip6 (node, "our_address", addr);
10239 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10240 vat_json_object_add_ip6 (node, "client_address", addr);
10242 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10243 vat_json_init_array (lc);
10244 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10245 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10246 vat_json_object_add_uint (node, "remote_cookie",
10247 clib_net_to_host_u64 (mp->remote_cookie));
10249 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10250 vat_json_object_add_uint (node, "local_session_id",
10251 clib_net_to_host_u32 (mp->local_session_id));
10252 vat_json_object_add_uint (node, "remote_session_id",
10253 clib_net_to_host_u32 (mp->remote_session_id));
10254 vat_json_object_add_string_copy (node, "l2_sublayer",
10255 mp->l2_sublayer_present ? (u8 *) "present"
10256 : (u8 *) "absent");
10260 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10262 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10263 vl_api_control_ping_t *mp_ping;
10266 /* Get list of l2tpv3-tunnel interfaces */
10267 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10270 /* Use a control ping for synchronization */
10271 M (CONTROL_PING, mp_ping);
10279 static void vl_api_sw_interface_tap_details_t_handler
10280 (vl_api_sw_interface_tap_details_t * mp)
10282 vat_main_t *vam = &vat_main;
10284 print (vam->ofp, "%-16s %d",
10285 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10288 static void vl_api_sw_interface_tap_details_t_handler_json
10289 (vl_api_sw_interface_tap_details_t * mp)
10291 vat_main_t *vam = &vat_main;
10292 vat_json_node_t *node = NULL;
10294 if (VAT_JSON_ARRAY != vam->json_tree.type)
10296 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10297 vat_json_init_array (&vam->json_tree);
10299 node = vat_json_array_add (&vam->json_tree);
10301 vat_json_init_object (node);
10302 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10303 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10307 api_sw_interface_tap_dump (vat_main_t * vam)
10309 vl_api_sw_interface_tap_dump_t *mp;
10310 vl_api_control_ping_t *mp_ping;
10313 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10314 /* Get list of tap interfaces */
10315 M (SW_INTERFACE_TAP_DUMP, mp);
10318 /* Use a control ping for synchronization */
10319 M (CONTROL_PING, mp_ping);
10326 static uword unformat_vxlan_decap_next
10327 (unformat_input_t * input, va_list * args)
10329 u32 *result = va_arg (*args, u32 *);
10332 if (unformat (input, "l2"))
10333 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10334 else if (unformat (input, "%d", &tmp))
10342 api_vxlan_add_del_tunnel (vat_main_t * vam)
10344 unformat_input_t *line_input = vam->input;
10345 vl_api_vxlan_add_del_tunnel_t *mp;
10346 ip46_address_t src, dst;
10348 u8 ipv4_set = 0, ipv6_set = 0;
10352 u32 mcast_sw_if_index = ~0;
10353 u32 encap_vrf_id = 0;
10354 u32 decap_next_index = ~0;
10358 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10359 memset (&src, 0, sizeof src);
10360 memset (&dst, 0, sizeof dst);
10362 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10364 if (unformat (line_input, "del"))
10367 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10373 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10379 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10385 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10390 else if (unformat (line_input, "group %U %U",
10391 unformat_ip4_address, &dst.ip4,
10392 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10394 grp_set = dst_set = 1;
10397 else if (unformat (line_input, "group %U",
10398 unformat_ip4_address, &dst.ip4))
10400 grp_set = dst_set = 1;
10403 else if (unformat (line_input, "group %U %U",
10404 unformat_ip6_address, &dst.ip6,
10405 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10407 grp_set = dst_set = 1;
10410 else if (unformat (line_input, "group %U",
10411 unformat_ip6_address, &dst.ip6))
10413 grp_set = dst_set = 1;
10417 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10419 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10421 else if (unformat (line_input, "decap-next %U",
10422 unformat_vxlan_decap_next, &decap_next_index))
10424 else if (unformat (line_input, "vni %d", &vni))
10428 errmsg ("parse error '%U'", format_unformat_error, line_input);
10435 errmsg ("tunnel src address not specified");
10440 errmsg ("tunnel dst address not specified");
10444 if (grp_set && !ip46_address_is_multicast (&dst))
10446 errmsg ("tunnel group address not multicast");
10449 if (grp_set && mcast_sw_if_index == ~0)
10451 errmsg ("tunnel nonexistent multicast device");
10454 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10456 errmsg ("tunnel dst address must be unicast");
10461 if (ipv4_set && ipv6_set)
10463 errmsg ("both IPv4 and IPv6 addresses specified");
10467 if ((vni == 0) || (vni >> 24))
10469 errmsg ("vni not specified or out of range");
10473 M (VXLAN_ADD_DEL_TUNNEL, mp);
10477 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10478 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10482 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10483 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10485 mp->encap_vrf_id = ntohl (encap_vrf_id);
10486 mp->decap_next_index = ntohl (decap_next_index);
10487 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10488 mp->vni = ntohl (vni);
10489 mp->is_add = is_add;
10490 mp->is_ipv6 = ipv6_set;
10497 static void vl_api_vxlan_tunnel_details_t_handler
10498 (vl_api_vxlan_tunnel_details_t * mp)
10500 vat_main_t *vam = &vat_main;
10501 ip46_address_t src, dst;
10503 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10504 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10506 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10507 ntohl (mp->sw_if_index),
10508 format_ip46_address, &src, IP46_TYPE_ANY,
10509 format_ip46_address, &dst, IP46_TYPE_ANY,
10510 ntohl (mp->encap_vrf_id),
10511 ntohl (mp->decap_next_index), ntohl (mp->vni),
10512 ntohl (mp->mcast_sw_if_index));
10515 static void vl_api_vxlan_tunnel_details_t_handler_json
10516 (vl_api_vxlan_tunnel_details_t * mp)
10518 vat_main_t *vam = &vat_main;
10519 vat_json_node_t *node = NULL;
10521 if (VAT_JSON_ARRAY != vam->json_tree.type)
10523 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10524 vat_json_init_array (&vam->json_tree);
10526 node = vat_json_array_add (&vam->json_tree);
10528 vat_json_init_object (node);
10529 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10532 struct in6_addr ip6;
10534 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10535 vat_json_object_add_ip6 (node, "src_address", ip6);
10536 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10537 vat_json_object_add_ip6 (node, "dst_address", ip6);
10541 struct in_addr ip4;
10543 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10544 vat_json_object_add_ip4 (node, "src_address", ip4);
10545 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10546 vat_json_object_add_ip4 (node, "dst_address", ip4);
10548 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10549 vat_json_object_add_uint (node, "decap_next_index",
10550 ntohl (mp->decap_next_index));
10551 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10552 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10553 vat_json_object_add_uint (node, "mcast_sw_if_index",
10554 ntohl (mp->mcast_sw_if_index));
10558 api_vxlan_tunnel_dump (vat_main_t * vam)
10560 unformat_input_t *i = vam->input;
10561 vl_api_vxlan_tunnel_dump_t *mp;
10562 vl_api_control_ping_t *mp_ping;
10564 u8 sw_if_index_set = 0;
10567 /* Parse args required to build the message */
10568 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10570 if (unformat (i, "sw_if_index %d", &sw_if_index))
10571 sw_if_index_set = 1;
10576 if (sw_if_index_set == 0)
10581 if (!vam->json_output)
10583 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10584 "sw_if_index", "src_address", "dst_address",
10585 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10588 /* Get list of vxlan-tunnel interfaces */
10589 M (VXLAN_TUNNEL_DUMP, mp);
10591 mp->sw_if_index = htonl (sw_if_index);
10595 /* Use a control ping for synchronization */
10596 M (CONTROL_PING, mp_ping);
10604 api_gre_add_del_tunnel (vat_main_t * vam)
10606 unformat_input_t *line_input = vam->input;
10607 vl_api_gre_add_del_tunnel_t *mp;
10608 ip4_address_t src4, dst4;
10613 u32 outer_fib_id = 0;
10616 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10618 if (unformat (line_input, "del"))
10620 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10622 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10624 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10626 else if (unformat (line_input, "teb"))
10630 errmsg ("parse error '%U'", format_unformat_error, line_input);
10637 errmsg ("tunnel src address not specified");
10642 errmsg ("tunnel dst address not specified");
10647 M (GRE_ADD_DEL_TUNNEL, mp);
10649 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10650 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10651 mp->outer_fib_id = ntohl (outer_fib_id);
10652 mp->is_add = is_add;
10660 static void vl_api_gre_tunnel_details_t_handler
10661 (vl_api_gre_tunnel_details_t * mp)
10663 vat_main_t *vam = &vat_main;
10665 print (vam->ofp, "%11d%15U%15U%6d%14d",
10666 ntohl (mp->sw_if_index),
10667 format_ip4_address, &mp->src_address,
10668 format_ip4_address, &mp->dst_address,
10669 mp->teb, ntohl (mp->outer_fib_id));
10672 static void vl_api_gre_tunnel_details_t_handler_json
10673 (vl_api_gre_tunnel_details_t * mp)
10675 vat_main_t *vam = &vat_main;
10676 vat_json_node_t *node = NULL;
10677 struct in_addr ip4;
10679 if (VAT_JSON_ARRAY != vam->json_tree.type)
10681 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10682 vat_json_init_array (&vam->json_tree);
10684 node = vat_json_array_add (&vam->json_tree);
10686 vat_json_init_object (node);
10687 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10688 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10689 vat_json_object_add_ip4 (node, "src_address", ip4);
10690 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10691 vat_json_object_add_ip4 (node, "dst_address", ip4);
10692 vat_json_object_add_uint (node, "teb", mp->teb);
10693 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10697 api_gre_tunnel_dump (vat_main_t * vam)
10699 unformat_input_t *i = vam->input;
10700 vl_api_gre_tunnel_dump_t *mp;
10701 vl_api_control_ping_t *mp_ping;
10703 u8 sw_if_index_set = 0;
10706 /* Parse args required to build the message */
10707 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10709 if (unformat (i, "sw_if_index %d", &sw_if_index))
10710 sw_if_index_set = 1;
10715 if (sw_if_index_set == 0)
10720 if (!vam->json_output)
10722 print (vam->ofp, "%11s%15s%15s%6s%14s",
10723 "sw_if_index", "src_address", "dst_address", "teb",
10727 /* Get list of gre-tunnel interfaces */
10728 M (GRE_TUNNEL_DUMP, mp);
10730 mp->sw_if_index = htonl (sw_if_index);
10734 /* Use a control ping for synchronization */
10735 M (CONTROL_PING, mp_ping);
10743 api_l2_fib_clear_table (vat_main_t * vam)
10745 // unformat_input_t * i = vam->input;
10746 vl_api_l2_fib_clear_table_t *mp;
10749 M (L2_FIB_CLEAR_TABLE, mp);
10757 api_l2_interface_efp_filter (vat_main_t * vam)
10759 unformat_input_t *i = vam->input;
10760 vl_api_l2_interface_efp_filter_t *mp;
10763 u8 sw_if_index_set = 0;
10766 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10768 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10769 sw_if_index_set = 1;
10770 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10771 sw_if_index_set = 1;
10772 else if (unformat (i, "enable"))
10774 else if (unformat (i, "disable"))
10778 clib_warning ("parse error '%U'", format_unformat_error, i);
10783 if (sw_if_index_set == 0)
10785 errmsg ("missing sw_if_index");
10789 M (L2_INTERFACE_EFP_FILTER, mp);
10791 mp->sw_if_index = ntohl (sw_if_index);
10792 mp->enable_disable = enable;
10799 #define foreach_vtr_op \
10800 _("disable", L2_VTR_DISABLED) \
10801 _("push-1", L2_VTR_PUSH_1) \
10802 _("push-2", L2_VTR_PUSH_2) \
10803 _("pop-1", L2_VTR_POP_1) \
10804 _("pop-2", L2_VTR_POP_2) \
10805 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10806 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10807 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10808 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10811 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10813 unformat_input_t *i = vam->input;
10814 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10816 u8 sw_if_index_set = 0;
10819 u32 push_dot1q = 1;
10824 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10826 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10827 sw_if_index_set = 1;
10828 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10829 sw_if_index_set = 1;
10830 else if (unformat (i, "vtr_op %d", &vtr_op))
10832 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10835 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10837 else if (unformat (i, "tag1 %d", &tag1))
10839 else if (unformat (i, "tag2 %d", &tag2))
10843 clib_warning ("parse error '%U'", format_unformat_error, i);
10848 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10850 errmsg ("missing vtr operation or sw_if_index");
10854 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
10855 mp->sw_if_index = ntohl (sw_if_index);
10856 mp->vtr_op = ntohl (vtr_op);
10857 mp->push_dot1q = ntohl (push_dot1q);
10858 mp->tag1 = ntohl (tag1);
10859 mp->tag2 = ntohl (tag2);
10867 api_create_vhost_user_if (vat_main_t * vam)
10869 unformat_input_t *i = vam->input;
10870 vl_api_create_vhost_user_if_t *mp;
10873 u8 file_name_set = 0;
10874 u32 custom_dev_instance = ~0;
10876 u8 use_custom_mac = 0;
10880 /* Shut up coverity */
10881 memset (hwaddr, 0, sizeof (hwaddr));
10883 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10885 if (unformat (i, "socket %s", &file_name))
10889 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10891 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10892 use_custom_mac = 1;
10893 else if (unformat (i, "server"))
10895 else if (unformat (i, "tag %s", &tag))
10901 if (file_name_set == 0)
10903 errmsg ("missing socket file name");
10907 if (vec_len (file_name) > 255)
10909 errmsg ("socket file name too long");
10912 vec_add1 (file_name, 0);
10914 M (CREATE_VHOST_USER_IF, mp);
10916 mp->is_server = is_server;
10917 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10918 vec_free (file_name);
10919 if (custom_dev_instance != ~0)
10922 mp->custom_dev_instance = ntohl (custom_dev_instance);
10924 mp->use_custom_mac = use_custom_mac;
10925 clib_memcpy (mp->mac_address, hwaddr, 6);
10927 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10936 api_modify_vhost_user_if (vat_main_t * vam)
10938 unformat_input_t *i = vam->input;
10939 vl_api_modify_vhost_user_if_t *mp;
10942 u8 file_name_set = 0;
10943 u32 custom_dev_instance = ~0;
10944 u8 sw_if_index_set = 0;
10945 u32 sw_if_index = (u32) ~ 0;
10948 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10950 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10951 sw_if_index_set = 1;
10952 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10953 sw_if_index_set = 1;
10954 else if (unformat (i, "socket %s", &file_name))
10958 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10960 else if (unformat (i, "server"))
10966 if (sw_if_index_set == 0)
10968 errmsg ("missing sw_if_index or interface name");
10972 if (file_name_set == 0)
10974 errmsg ("missing socket file name");
10978 if (vec_len (file_name) > 255)
10980 errmsg ("socket file name too long");
10983 vec_add1 (file_name, 0);
10985 M (MODIFY_VHOST_USER_IF, mp);
10987 mp->sw_if_index = ntohl (sw_if_index);
10988 mp->is_server = is_server;
10989 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10990 vec_free (file_name);
10991 if (custom_dev_instance != ~0)
10994 mp->custom_dev_instance = ntohl (custom_dev_instance);
11003 api_delete_vhost_user_if (vat_main_t * vam)
11005 unformat_input_t *i = vam->input;
11006 vl_api_delete_vhost_user_if_t *mp;
11007 u32 sw_if_index = ~0;
11008 u8 sw_if_index_set = 0;
11011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11013 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11014 sw_if_index_set = 1;
11015 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11016 sw_if_index_set = 1;
11021 if (sw_if_index_set == 0)
11023 errmsg ("missing sw_if_index or interface name");
11028 M (DELETE_VHOST_USER_IF, mp);
11030 mp->sw_if_index = ntohl (sw_if_index);
11037 static void vl_api_sw_interface_vhost_user_details_t_handler
11038 (vl_api_sw_interface_vhost_user_details_t * mp)
11040 vat_main_t *vam = &vat_main;
11042 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11043 (char *) mp->interface_name,
11044 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11045 clib_net_to_host_u64 (mp->features), mp->is_server,
11046 ntohl (mp->num_regions), (char *) mp->sock_filename);
11047 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11050 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11051 (vl_api_sw_interface_vhost_user_details_t * mp)
11053 vat_main_t *vam = &vat_main;
11054 vat_json_node_t *node = NULL;
11056 if (VAT_JSON_ARRAY != vam->json_tree.type)
11058 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11059 vat_json_init_array (&vam->json_tree);
11061 node = vat_json_array_add (&vam->json_tree);
11063 vat_json_init_object (node);
11064 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11065 vat_json_object_add_string_copy (node, "interface_name",
11066 mp->interface_name);
11067 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11068 ntohl (mp->virtio_net_hdr_sz));
11069 vat_json_object_add_uint (node, "features",
11070 clib_net_to_host_u64 (mp->features));
11071 vat_json_object_add_uint (node, "is_server", mp->is_server);
11072 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11073 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11074 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11078 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11080 vl_api_sw_interface_vhost_user_dump_t *mp;
11081 vl_api_control_ping_t *mp_ping;
11084 "Interface name idx hdr_sz features server regions filename");
11086 /* Get list of vhost-user interfaces */
11087 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11090 /* Use a control ping for synchronization */
11091 M (CONTROL_PING, mp_ping);
11099 api_show_version (vat_main_t * vam)
11101 vl_api_show_version_t *mp;
11104 M (SHOW_VERSION, mp);
11113 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11115 unformat_input_t *line_input = vam->input;
11116 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11117 ip4_address_t local4, remote4;
11118 ip6_address_t local6, remote6;
11120 u8 ipv4_set = 0, ipv6_set = 0;
11123 u32 encap_vrf_id = 0;
11124 u32 decap_vrf_id = 0;
11130 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11132 if (unformat (line_input, "del"))
11134 else if (unformat (line_input, "local %U",
11135 unformat_ip4_address, &local4))
11140 else if (unformat (line_input, "remote %U",
11141 unformat_ip4_address, &remote4))
11146 else if (unformat (line_input, "local %U",
11147 unformat_ip6_address, &local6))
11152 else if (unformat (line_input, "remote %U",
11153 unformat_ip6_address, &remote6))
11158 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11160 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11162 else if (unformat (line_input, "vni %d", &vni))
11164 else if (unformat (line_input, "next-ip4"))
11166 else if (unformat (line_input, "next-ip6"))
11168 else if (unformat (line_input, "next-ethernet"))
11170 else if (unformat (line_input, "next-nsh"))
11174 errmsg ("parse error '%U'", format_unformat_error, line_input);
11179 if (local_set == 0)
11181 errmsg ("tunnel local address not specified");
11184 if (remote_set == 0)
11186 errmsg ("tunnel remote address not specified");
11189 if (ipv4_set && ipv6_set)
11191 errmsg ("both IPv4 and IPv6 addresses specified");
11197 errmsg ("vni not specified");
11201 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11206 clib_memcpy (&mp->local, &local6, sizeof (local6));
11207 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11211 clib_memcpy (&mp->local, &local4, sizeof (local4));
11212 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11215 mp->encap_vrf_id = ntohl (encap_vrf_id);
11216 mp->decap_vrf_id = ntohl (decap_vrf_id);
11217 mp->protocol = protocol;
11218 mp->vni = ntohl (vni);
11219 mp->is_add = is_add;
11220 mp->is_ipv6 = ipv6_set;
11227 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11228 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11230 vat_main_t *vam = &vat_main;
11232 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11233 ntohl (mp->sw_if_index),
11234 format_ip46_address, &(mp->local[0]),
11235 format_ip46_address, &(mp->remote[0]),
11237 ntohl (mp->protocol),
11238 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11241 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11242 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11244 vat_main_t *vam = &vat_main;
11245 vat_json_node_t *node = NULL;
11246 struct in_addr ip4;
11247 struct in6_addr ip6;
11249 if (VAT_JSON_ARRAY != vam->json_tree.type)
11251 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11252 vat_json_init_array (&vam->json_tree);
11254 node = vat_json_array_add (&vam->json_tree);
11256 vat_json_init_object (node);
11257 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11260 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11261 vat_json_object_add_ip6 (node, "local", ip6);
11262 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11263 vat_json_object_add_ip6 (node, "remote", ip6);
11267 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11268 vat_json_object_add_ip4 (node, "local", ip4);
11269 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11270 vat_json_object_add_ip4 (node, "remote", ip4);
11272 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11273 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11274 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11275 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11276 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11280 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11282 unformat_input_t *i = vam->input;
11283 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11284 vl_api_control_ping_t *mp_ping;
11286 u8 sw_if_index_set = 0;
11289 /* Parse args required to build the message */
11290 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11292 if (unformat (i, "sw_if_index %d", &sw_if_index))
11293 sw_if_index_set = 1;
11298 if (sw_if_index_set == 0)
11303 if (!vam->json_output)
11305 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11306 "sw_if_index", "local", "remote", "vni",
11307 "protocol", "encap_vrf_id", "decap_vrf_id");
11310 /* Get list of vxlan-tunnel interfaces */
11311 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11313 mp->sw_if_index = htonl (sw_if_index);
11317 /* Use a control ping for synchronization */
11318 M (CONTROL_PING, mp_ping);
11326 format_l2_fib_mac_address (u8 * s, va_list * args)
11328 u8 *a = va_arg (*args, u8 *);
11330 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11331 a[2], a[3], a[4], a[5], a[6], a[7]);
11334 static void vl_api_l2_fib_table_entry_t_handler
11335 (vl_api_l2_fib_table_entry_t * mp)
11337 vat_main_t *vam = &vat_main;
11339 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11341 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11342 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11346 static void vl_api_l2_fib_table_entry_t_handler_json
11347 (vl_api_l2_fib_table_entry_t * mp)
11349 vat_main_t *vam = &vat_main;
11350 vat_json_node_t *node = NULL;
11352 if (VAT_JSON_ARRAY != vam->json_tree.type)
11354 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11355 vat_json_init_array (&vam->json_tree);
11357 node = vat_json_array_add (&vam->json_tree);
11359 vat_json_init_object (node);
11360 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11361 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11362 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11363 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11364 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11365 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11369 api_l2_fib_table_dump (vat_main_t * vam)
11371 unformat_input_t *i = vam->input;
11372 vl_api_l2_fib_table_dump_t *mp;
11373 vl_api_control_ping_t *mp_ping;
11378 /* Parse args required to build the message */
11379 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11381 if (unformat (i, "bd_id %d", &bd_id))
11387 if (bd_id_set == 0)
11389 errmsg ("missing bridge domain");
11393 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11395 /* Get list of l2 fib entries */
11396 M (L2_FIB_TABLE_DUMP, mp);
11398 mp->bd_id = ntohl (bd_id);
11401 /* Use a control ping for synchronization */
11402 M (CONTROL_PING, mp_ping);
11411 api_interface_name_renumber (vat_main_t * vam)
11413 unformat_input_t *line_input = vam->input;
11414 vl_api_interface_name_renumber_t *mp;
11415 u32 sw_if_index = ~0;
11416 u32 new_show_dev_instance = ~0;
11419 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11421 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11424 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11426 else if (unformat (line_input, "new_show_dev_instance %d",
11427 &new_show_dev_instance))
11433 if (sw_if_index == ~0)
11435 errmsg ("missing interface name or sw_if_index");
11439 if (new_show_dev_instance == ~0)
11441 errmsg ("missing new_show_dev_instance");
11445 M (INTERFACE_NAME_RENUMBER, mp);
11447 mp->sw_if_index = ntohl (sw_if_index);
11448 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11456 api_want_ip4_arp_events (vat_main_t * vam)
11458 unformat_input_t *line_input = vam->input;
11459 vl_api_want_ip4_arp_events_t *mp;
11460 ip4_address_t address;
11461 int address_set = 0;
11462 u32 enable_disable = 1;
11465 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11467 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11469 else if (unformat (line_input, "del"))
11470 enable_disable = 0;
11475 if (address_set == 0)
11477 errmsg ("missing addresses");
11481 M (WANT_IP4_ARP_EVENTS, mp);
11482 mp->enable_disable = enable_disable;
11483 mp->pid = getpid ();
11484 mp->address = address.as_u32;
11492 api_want_ip6_nd_events (vat_main_t * vam)
11494 unformat_input_t *line_input = vam->input;
11495 vl_api_want_ip6_nd_events_t *mp;
11496 ip6_address_t address;
11497 int address_set = 0;
11498 u32 enable_disable = 1;
11501 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11503 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11505 else if (unformat (line_input, "del"))
11506 enable_disable = 0;
11511 if (address_set == 0)
11513 errmsg ("missing addresses");
11517 M (WANT_IP6_ND_EVENTS, mp);
11518 mp->enable_disable = enable_disable;
11519 mp->pid = getpid ();
11520 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11528 api_input_acl_set_interface (vat_main_t * vam)
11530 unformat_input_t *i = vam->input;
11531 vl_api_input_acl_set_interface_t *mp;
11533 int sw_if_index_set;
11534 u32 ip4_table_index = ~0;
11535 u32 ip6_table_index = ~0;
11536 u32 l2_table_index = ~0;
11540 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11542 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11543 sw_if_index_set = 1;
11544 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11545 sw_if_index_set = 1;
11546 else if (unformat (i, "del"))
11548 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11550 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11552 else if (unformat (i, "l2-table %d", &l2_table_index))
11556 clib_warning ("parse error '%U'", format_unformat_error, i);
11561 if (sw_if_index_set == 0)
11563 errmsg ("missing interface name or sw_if_index");
11567 M (INPUT_ACL_SET_INTERFACE, mp);
11569 mp->sw_if_index = ntohl (sw_if_index);
11570 mp->ip4_table_index = ntohl (ip4_table_index);
11571 mp->ip6_table_index = ntohl (ip6_table_index);
11572 mp->l2_table_index = ntohl (l2_table_index);
11573 mp->is_add = is_add;
11581 api_ip_address_dump (vat_main_t * vam)
11583 unformat_input_t *i = vam->input;
11584 vl_api_ip_address_dump_t *mp;
11585 vl_api_control_ping_t *mp_ping;
11586 u32 sw_if_index = ~0;
11587 u8 sw_if_index_set = 0;
11592 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11594 if (unformat (i, "sw_if_index %d", &sw_if_index))
11595 sw_if_index_set = 1;
11597 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11598 sw_if_index_set = 1;
11599 else if (unformat (i, "ipv4"))
11601 else if (unformat (i, "ipv6"))
11607 if (ipv4_set && ipv6_set)
11609 errmsg ("ipv4 and ipv6 flags cannot be both set");
11613 if ((!ipv4_set) && (!ipv6_set))
11615 errmsg ("no ipv4 nor ipv6 flag set");
11619 if (sw_if_index_set == 0)
11621 errmsg ("missing interface name or sw_if_index");
11625 vam->current_sw_if_index = sw_if_index;
11626 vam->is_ipv6 = ipv6_set;
11628 M (IP_ADDRESS_DUMP, mp);
11629 mp->sw_if_index = ntohl (sw_if_index);
11630 mp->is_ipv6 = ipv6_set;
11633 /* Use a control ping for synchronization */
11634 M (CONTROL_PING, mp_ping);
11642 api_ip_dump (vat_main_t * vam)
11644 vl_api_ip_dump_t *mp;
11645 vl_api_control_ping_t *mp_ping;
11646 unformat_input_t *in = vam->input;
11653 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11655 if (unformat (in, "ipv4"))
11657 else if (unformat (in, "ipv6"))
11663 if (ipv4_set && ipv6_set)
11665 errmsg ("ipv4 and ipv6 flags cannot be both set");
11669 if ((!ipv4_set) && (!ipv6_set))
11671 errmsg ("no ipv4 nor ipv6 flag set");
11675 is_ipv6 = ipv6_set;
11676 vam->is_ipv6 = is_ipv6;
11678 /* free old data */
11679 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11681 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11683 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11686 mp->is_ipv6 = ipv6_set;
11689 /* Use a control ping for synchronization */
11690 M (CONTROL_PING, mp_ping);
11698 api_ipsec_spd_add_del (vat_main_t * vam)
11700 unformat_input_t *i = vam->input;
11701 vl_api_ipsec_spd_add_del_t *mp;
11706 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11708 if (unformat (i, "spd_id %d", &spd_id))
11710 else if (unformat (i, "del"))
11714 clib_warning ("parse error '%U'", format_unformat_error, i);
11720 errmsg ("spd_id must be set");
11724 M (IPSEC_SPD_ADD_DEL, mp);
11726 mp->spd_id = ntohl (spd_id);
11727 mp->is_add = is_add;
11735 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11737 unformat_input_t *i = vam->input;
11738 vl_api_ipsec_interface_add_del_spd_t *mp;
11740 u8 sw_if_index_set = 0;
11741 u32 spd_id = (u32) ~ 0;
11745 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11747 if (unformat (i, "del"))
11749 else if (unformat (i, "spd_id %d", &spd_id))
11752 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11753 sw_if_index_set = 1;
11754 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11755 sw_if_index_set = 1;
11758 clib_warning ("parse error '%U'", format_unformat_error, i);
11764 if (spd_id == (u32) ~ 0)
11766 errmsg ("spd_id must be set");
11770 if (sw_if_index_set == 0)
11772 errmsg ("missing interface name or sw_if_index");
11776 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11778 mp->spd_id = ntohl (spd_id);
11779 mp->sw_if_index = ntohl (sw_if_index);
11780 mp->is_add = is_add;
11788 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11790 unformat_input_t *i = vam->input;
11791 vl_api_ipsec_spd_add_del_entry_t *mp;
11792 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11793 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11795 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11796 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11797 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11798 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11801 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11802 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11803 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11804 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11805 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11806 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11808 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11810 if (unformat (i, "del"))
11812 if (unformat (i, "outbound"))
11814 if (unformat (i, "inbound"))
11816 else if (unformat (i, "spd_id %d", &spd_id))
11818 else if (unformat (i, "sa_id %d", &sa_id))
11820 else if (unformat (i, "priority %d", &priority))
11822 else if (unformat (i, "protocol %d", &protocol))
11824 else if (unformat (i, "lport_start %d", &lport_start))
11826 else if (unformat (i, "lport_stop %d", &lport_stop))
11828 else if (unformat (i, "rport_start %d", &rport_start))
11830 else if (unformat (i, "rport_stop %d", &rport_stop))
11834 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11840 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11847 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11853 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11860 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11866 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11873 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11879 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11885 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11887 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11889 clib_warning ("unsupported action: 'resolve'");
11895 clib_warning ("parse error '%U'", format_unformat_error, i);
11901 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
11903 mp->spd_id = ntohl (spd_id);
11904 mp->priority = ntohl (priority);
11905 mp->is_outbound = is_outbound;
11907 mp->is_ipv6 = is_ipv6;
11908 if (is_ipv6 || is_ip_any)
11910 clib_memcpy (mp->remote_address_start, &raddr6_start,
11911 sizeof (ip6_address_t));
11912 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11913 sizeof (ip6_address_t));
11914 clib_memcpy (mp->local_address_start, &laddr6_start,
11915 sizeof (ip6_address_t));
11916 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11917 sizeof (ip6_address_t));
11921 clib_memcpy (mp->remote_address_start, &raddr4_start,
11922 sizeof (ip4_address_t));
11923 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11924 sizeof (ip4_address_t));
11925 clib_memcpy (mp->local_address_start, &laddr4_start,
11926 sizeof (ip4_address_t));
11927 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11928 sizeof (ip4_address_t));
11930 mp->protocol = (u8) protocol;
11931 mp->local_port_start = ntohs ((u16) lport_start);
11932 mp->local_port_stop = ntohs ((u16) lport_stop);
11933 mp->remote_port_start = ntohs ((u16) rport_start);
11934 mp->remote_port_stop = ntohs ((u16) rport_stop);
11935 mp->policy = (u8) policy;
11936 mp->sa_id = ntohl (sa_id);
11937 mp->is_add = is_add;
11938 mp->is_ip_any = is_ip_any;
11945 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11947 unformat_input_t *i = vam->input;
11948 vl_api_ipsec_sad_add_del_entry_t *mp;
11949 u32 sad_id = 0, spi = 0;
11950 u8 *ck = 0, *ik = 0;
11953 u8 protocol = IPSEC_PROTOCOL_AH;
11954 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11955 u32 crypto_alg = 0, integ_alg = 0;
11956 ip4_address_t tun_src4;
11957 ip4_address_t tun_dst4;
11958 ip6_address_t tun_src6;
11959 ip6_address_t tun_dst6;
11962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11964 if (unformat (i, "del"))
11966 else if (unformat (i, "sad_id %d", &sad_id))
11968 else if (unformat (i, "spi %d", &spi))
11970 else if (unformat (i, "esp"))
11971 protocol = IPSEC_PROTOCOL_ESP;
11972 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11975 is_tunnel_ipv6 = 0;
11977 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11980 is_tunnel_ipv6 = 0;
11982 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11985 is_tunnel_ipv6 = 1;
11987 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11990 is_tunnel_ipv6 = 1;
11994 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11996 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11997 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11999 clib_warning ("unsupported crypto-alg: '%U'",
12000 format_ipsec_crypto_alg, crypto_alg);
12004 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12008 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
12010 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
12011 integ_alg >= IPSEC_INTEG_N_ALG)
12013 clib_warning ("unsupported integ-alg: '%U'",
12014 format_ipsec_integ_alg, integ_alg);
12018 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12022 clib_warning ("parse error '%U'", format_unformat_error, i);
12028 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12030 mp->sad_id = ntohl (sad_id);
12031 mp->is_add = is_add;
12032 mp->protocol = protocol;
12033 mp->spi = ntohl (spi);
12034 mp->is_tunnel = is_tunnel;
12035 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12036 mp->crypto_algorithm = crypto_alg;
12037 mp->integrity_algorithm = integ_alg;
12038 mp->crypto_key_length = vec_len (ck);
12039 mp->integrity_key_length = vec_len (ik);
12041 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12042 mp->crypto_key_length = sizeof (mp->crypto_key);
12044 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12045 mp->integrity_key_length = sizeof (mp->integrity_key);
12048 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12050 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12054 if (is_tunnel_ipv6)
12056 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12057 sizeof (ip6_address_t));
12058 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12059 sizeof (ip6_address_t));
12063 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12064 sizeof (ip4_address_t));
12065 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12066 sizeof (ip4_address_t));
12076 api_ipsec_sa_set_key (vat_main_t * vam)
12078 unformat_input_t *i = vam->input;
12079 vl_api_ipsec_sa_set_key_t *mp;
12081 u8 *ck = 0, *ik = 0;
12084 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12086 if (unformat (i, "sa_id %d", &sa_id))
12088 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12090 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12094 clib_warning ("parse error '%U'", format_unformat_error, i);
12099 M (IPSEC_SA_SET_KEY, mp);
12101 mp->sa_id = ntohl (sa_id);
12102 mp->crypto_key_length = vec_len (ck);
12103 mp->integrity_key_length = vec_len (ik);
12105 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12106 mp->crypto_key_length = sizeof (mp->crypto_key);
12108 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12109 mp->integrity_key_length = sizeof (mp->integrity_key);
12112 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12114 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12122 api_ikev2_profile_add_del (vat_main_t * vam)
12124 unformat_input_t *i = vam->input;
12125 vl_api_ikev2_profile_add_del_t *mp;
12130 const char *valid_chars = "a-zA-Z0-9_";
12132 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12134 if (unformat (i, "del"))
12136 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12137 vec_add1 (name, 0);
12140 errmsg ("parse error '%U'", format_unformat_error, i);
12145 if (!vec_len (name))
12147 errmsg ("profile name must be specified");
12151 if (vec_len (name) > 64)
12153 errmsg ("profile name too long");
12157 M (IKEV2_PROFILE_ADD_DEL, mp);
12159 clib_memcpy (mp->name, name, vec_len (name));
12160 mp->is_add = is_add;
12169 api_ikev2_profile_set_auth (vat_main_t * vam)
12171 unformat_input_t *i = vam->input;
12172 vl_api_ikev2_profile_set_auth_t *mp;
12175 u32 auth_method = 0;
12179 const char *valid_chars = "a-zA-Z0-9_";
12181 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12183 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12184 vec_add1 (name, 0);
12185 else if (unformat (i, "auth_method %U",
12186 unformat_ikev2_auth_method, &auth_method))
12188 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12190 else if (unformat (i, "auth_data %v", &data))
12194 errmsg ("parse error '%U'", format_unformat_error, i);
12199 if (!vec_len (name))
12201 errmsg ("profile name must be specified");
12205 if (vec_len (name) > 64)
12207 errmsg ("profile name too long");
12211 if (!vec_len (data))
12213 errmsg ("auth_data must be specified");
12219 errmsg ("auth_method must be specified");
12223 M (IKEV2_PROFILE_SET_AUTH, mp);
12225 mp->is_hex = is_hex;
12226 mp->auth_method = (u8) auth_method;
12227 mp->data_len = vec_len (data);
12228 clib_memcpy (mp->name, name, vec_len (name));
12229 clib_memcpy (mp->data, data, vec_len (data));
12239 api_ikev2_profile_set_id (vat_main_t * vam)
12241 unformat_input_t *i = vam->input;
12242 vl_api_ikev2_profile_set_id_t *mp;
12250 const char *valid_chars = "a-zA-Z0-9_";
12252 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12254 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12255 vec_add1 (name, 0);
12256 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12258 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12260 data = vec_new (u8, 4);
12261 clib_memcpy (data, ip4.as_u8, 4);
12263 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12265 else if (unformat (i, "id_data %v", &data))
12267 else if (unformat (i, "local"))
12269 else if (unformat (i, "remote"))
12273 errmsg ("parse error '%U'", format_unformat_error, i);
12278 if (!vec_len (name))
12280 errmsg ("profile name must be specified");
12284 if (vec_len (name) > 64)
12286 errmsg ("profile name too long");
12290 if (!vec_len (data))
12292 errmsg ("id_data must be specified");
12298 errmsg ("id_type must be specified");
12302 M (IKEV2_PROFILE_SET_ID, mp);
12304 mp->is_local = is_local;
12305 mp->id_type = (u8) id_type;
12306 mp->data_len = vec_len (data);
12307 clib_memcpy (mp->name, name, vec_len (name));
12308 clib_memcpy (mp->data, data, vec_len (data));
12318 api_ikev2_profile_set_ts (vat_main_t * vam)
12320 unformat_input_t *i = vam->input;
12321 vl_api_ikev2_profile_set_ts_t *mp;
12324 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12325 ip4_address_t start_addr, end_addr;
12327 const char *valid_chars = "a-zA-Z0-9_";
12330 start_addr.as_u32 = 0;
12331 end_addr.as_u32 = (u32) ~ 0;
12333 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12335 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12336 vec_add1 (name, 0);
12337 else if (unformat (i, "protocol %d", &proto))
12339 else if (unformat (i, "start_port %d", &start_port))
12341 else if (unformat (i, "end_port %d", &end_port))
12344 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12346 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12348 else if (unformat (i, "local"))
12350 else if (unformat (i, "remote"))
12354 errmsg ("parse error '%U'", format_unformat_error, i);
12359 if (!vec_len (name))
12361 errmsg ("profile name must be specified");
12365 if (vec_len (name) > 64)
12367 errmsg ("profile name too long");
12371 M (IKEV2_PROFILE_SET_TS, mp);
12373 mp->is_local = is_local;
12374 mp->proto = (u8) proto;
12375 mp->start_port = (u16) start_port;
12376 mp->end_port = (u16) end_port;
12377 mp->start_addr = start_addr.as_u32;
12378 mp->end_addr = end_addr.as_u32;
12379 clib_memcpy (mp->name, name, vec_len (name));
12388 api_ikev2_set_local_key (vat_main_t * vam)
12390 unformat_input_t *i = vam->input;
12391 vl_api_ikev2_set_local_key_t *mp;
12395 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12397 if (unformat (i, "file %v", &file))
12398 vec_add1 (file, 0);
12401 errmsg ("parse error '%U'", format_unformat_error, i);
12406 if (!vec_len (file))
12408 errmsg ("RSA key file must be specified");
12412 if (vec_len (file) > 256)
12414 errmsg ("file name too long");
12418 M (IKEV2_SET_LOCAL_KEY, mp);
12420 clib_memcpy (mp->key_file, file, vec_len (file));
12429 api_ikev2_set_responder (vat_main_t * vam)
12431 unformat_input_t *i = vam->input;
12432 vl_api_ikev2_set_responder_t *mp;
12435 u32 sw_if_index = ~0;
12436 ip4_address_t address;
12438 const char *valid_chars = "a-zA-Z0-9_";
12440 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12443 (i, "%U interface %d address %U", unformat_token, valid_chars,
12444 &name, &sw_if_index, unformat_ip4_address, &address))
12445 vec_add1 (name, 0);
12448 errmsg ("parse error '%U'", format_unformat_error, i);
12453 if (!vec_len (name))
12455 errmsg ("profile name must be specified");
12459 if (vec_len (name) > 64)
12461 errmsg ("profile name too long");
12465 M (IKEV2_SET_RESPONDER, mp);
12467 clib_memcpy (mp->name, name, vec_len (name));
12470 mp->sw_if_index = sw_if_index;
12471 clib_memcpy (mp->address, &address, sizeof (address));
12479 api_ikev2_set_ike_transforms (vat_main_t * vam)
12481 unformat_input_t *i = vam->input;
12482 vl_api_ikev2_set_ike_transforms_t *mp;
12485 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12487 const char *valid_chars = "a-zA-Z0-9_";
12489 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12491 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12492 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12493 vec_add1 (name, 0);
12496 errmsg ("parse error '%U'", format_unformat_error, i);
12501 if (!vec_len (name))
12503 errmsg ("profile name must be specified");
12507 if (vec_len (name) > 64)
12509 errmsg ("profile name too long");
12513 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12515 clib_memcpy (mp->name, name, vec_len (name));
12517 mp->crypto_alg = crypto_alg;
12518 mp->crypto_key_size = crypto_key_size;
12519 mp->integ_alg = integ_alg;
12520 mp->dh_group = dh_group;
12529 api_ikev2_set_esp_transforms (vat_main_t * vam)
12531 unformat_input_t *i = vam->input;
12532 vl_api_ikev2_set_esp_transforms_t *mp;
12535 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12537 const char *valid_chars = "a-zA-Z0-9_";
12539 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12541 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12542 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12543 vec_add1 (name, 0);
12546 errmsg ("parse error '%U'", format_unformat_error, i);
12551 if (!vec_len (name))
12553 errmsg ("profile name must be specified");
12557 if (vec_len (name) > 64)
12559 errmsg ("profile name too long");
12563 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12565 clib_memcpy (mp->name, name, vec_len (name));
12567 mp->crypto_alg = crypto_alg;
12568 mp->crypto_key_size = crypto_key_size;
12569 mp->integ_alg = integ_alg;
12570 mp->dh_group = dh_group;
12578 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12580 unformat_input_t *i = vam->input;
12581 vl_api_ikev2_set_sa_lifetime_t *mp;
12584 u64 lifetime, lifetime_maxdata;
12585 u32 lifetime_jitter, handover;
12587 const char *valid_chars = "a-zA-Z0-9_";
12589 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12591 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12592 &lifetime, &lifetime_jitter, &handover,
12593 &lifetime_maxdata))
12594 vec_add1 (name, 0);
12597 errmsg ("parse error '%U'", format_unformat_error, i);
12602 if (!vec_len (name))
12604 errmsg ("profile name must be specified");
12608 if (vec_len (name) > 64)
12610 errmsg ("profile name too long");
12614 M (IKEV2_SET_SA_LIFETIME, mp);
12616 clib_memcpy (mp->name, name, vec_len (name));
12618 mp->lifetime = lifetime;
12619 mp->lifetime_jitter = lifetime_jitter;
12620 mp->handover = handover;
12621 mp->lifetime_maxdata = lifetime_maxdata;
12629 api_ikev2_initiate_sa_init (vat_main_t * vam)
12631 unformat_input_t *i = vam->input;
12632 vl_api_ikev2_initiate_sa_init_t *mp;
12636 const char *valid_chars = "a-zA-Z0-9_";
12638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12640 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12641 vec_add1 (name, 0);
12644 errmsg ("parse error '%U'", format_unformat_error, i);
12649 if (!vec_len (name))
12651 errmsg ("profile name must be specified");
12655 if (vec_len (name) > 64)
12657 errmsg ("profile name too long");
12661 M (IKEV2_INITIATE_SA_INIT, mp);
12663 clib_memcpy (mp->name, name, vec_len (name));
12672 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12674 unformat_input_t *i = vam->input;
12675 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12680 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12682 if (unformat (i, "%lx", &ispi))
12686 errmsg ("parse error '%U'", format_unformat_error, i);
12691 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12701 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12703 unformat_input_t *i = vam->input;
12704 vl_api_ikev2_initiate_del_child_sa_t *mp;
12709 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12711 if (unformat (i, "%x", &ispi))
12715 errmsg ("parse error '%U'", format_unformat_error, i);
12720 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12730 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12732 unformat_input_t *i = vam->input;
12733 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12738 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12740 if (unformat (i, "%x", &ispi))
12744 errmsg ("parse error '%U'", format_unformat_error, i);
12749 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12762 api_map_add_domain (vat_main_t * vam)
12764 unformat_input_t *i = vam->input;
12765 vl_api_map_add_domain_t *mp;
12767 ip4_address_t ip4_prefix;
12768 ip6_address_t ip6_prefix;
12769 ip6_address_t ip6_src;
12770 u32 num_m_args = 0;
12771 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12772 0, psid_length = 0;
12773 u8 is_translation = 0;
12775 u32 ip6_src_len = 128;
12778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12780 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12781 &ip4_prefix, &ip4_prefix_len))
12783 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12784 &ip6_prefix, &ip6_prefix_len))
12788 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12791 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12793 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12795 else if (unformat (i, "psid-offset %d", &psid_offset))
12797 else if (unformat (i, "psid-len %d", &psid_length))
12799 else if (unformat (i, "mtu %d", &mtu))
12801 else if (unformat (i, "map-t"))
12802 is_translation = 1;
12805 clib_warning ("parse error '%U'", format_unformat_error, i);
12810 if (num_m_args < 3)
12812 errmsg ("mandatory argument(s) missing");
12816 /* Construct the API message */
12817 M (MAP_ADD_DOMAIN, mp);
12819 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12820 mp->ip4_prefix_len = ip4_prefix_len;
12822 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12823 mp->ip6_prefix_len = ip6_prefix_len;
12825 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12826 mp->ip6_src_prefix_len = ip6_src_len;
12828 mp->ea_bits_len = ea_bits_len;
12829 mp->psid_offset = psid_offset;
12830 mp->psid_length = psid_length;
12831 mp->is_translation = is_translation;
12832 mp->mtu = htons (mtu);
12837 /* Wait for a reply, return good/bad news */
12843 api_map_del_domain (vat_main_t * vam)
12845 unformat_input_t *i = vam->input;
12846 vl_api_map_del_domain_t *mp;
12848 u32 num_m_args = 0;
12852 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12854 if (unformat (i, "index %d", &index))
12858 clib_warning ("parse error '%U'", format_unformat_error, i);
12863 if (num_m_args != 1)
12865 errmsg ("mandatory argument(s) missing");
12869 /* Construct the API message */
12870 M (MAP_DEL_DOMAIN, mp);
12872 mp->index = ntohl (index);
12877 /* Wait for a reply, return good/bad news */
12883 api_map_add_del_rule (vat_main_t * vam)
12885 unformat_input_t *i = vam->input;
12886 vl_api_map_add_del_rule_t *mp;
12888 ip6_address_t ip6_dst;
12889 u32 num_m_args = 0, index, psid = 0;
12892 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12894 if (unformat (i, "index %d", &index))
12896 else if (unformat (i, "psid %d", &psid))
12898 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12900 else if (unformat (i, "del"))
12906 clib_warning ("parse error '%U'", format_unformat_error, i);
12911 /* Construct the API message */
12912 M (MAP_ADD_DEL_RULE, mp);
12914 mp->index = ntohl (index);
12915 mp->is_add = is_add;
12916 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12917 mp->psid = ntohs (psid);
12922 /* Wait for a reply, return good/bad news */
12928 api_map_domain_dump (vat_main_t * vam)
12930 vl_api_map_domain_dump_t *mp;
12931 vl_api_control_ping_t *mp_ping;
12934 /* Construct the API message */
12935 M (MAP_DOMAIN_DUMP, mp);
12940 /* Use a control ping for synchronization */
12941 M (CONTROL_PING, mp_ping);
12949 api_map_rule_dump (vat_main_t * vam)
12951 unformat_input_t *i = vam->input;
12952 vl_api_map_rule_dump_t *mp;
12953 vl_api_control_ping_t *mp_ping;
12954 u32 domain_index = ~0;
12957 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12959 if (unformat (i, "index %u", &domain_index))
12965 if (domain_index == ~0)
12967 clib_warning ("parse error: domain index expected");
12971 /* Construct the API message */
12972 M (MAP_RULE_DUMP, mp);
12974 mp->domain_index = htonl (domain_index);
12979 /* Use a control ping for synchronization */
12980 M (CONTROL_PING, mp_ping);
12987 static void vl_api_map_add_domain_reply_t_handler
12988 (vl_api_map_add_domain_reply_t * mp)
12990 vat_main_t *vam = &vat_main;
12991 i32 retval = ntohl (mp->retval);
12993 if (vam->async_mode)
12995 vam->async_errors += (retval < 0);
12999 vam->retval = retval;
13000 vam->result_ready = 1;
13004 static void vl_api_map_add_domain_reply_t_handler_json
13005 (vl_api_map_add_domain_reply_t * mp)
13007 vat_main_t *vam = &vat_main;
13008 vat_json_node_t node;
13010 vat_json_init_object (&node);
13011 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
13012 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
13014 vat_json_print (vam->ofp, &node);
13015 vat_json_free (&node);
13017 vam->retval = ntohl (mp->retval);
13018 vam->result_ready = 1;
13022 api_get_first_msg_id (vat_main_t * vam)
13024 vl_api_get_first_msg_id_t *mp;
13025 unformat_input_t *i = vam->input;
13030 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13032 if (unformat (i, "client %s", &name))
13040 errmsg ("missing client name");
13043 vec_add1 (name, 0);
13045 if (vec_len (name) > 63)
13047 errmsg ("client name too long");
13051 M (GET_FIRST_MSG_ID, mp);
13052 clib_memcpy (mp->name, name, vec_len (name));
13059 api_cop_interface_enable_disable (vat_main_t * vam)
13061 unformat_input_t *line_input = vam->input;
13062 vl_api_cop_interface_enable_disable_t *mp;
13063 u32 sw_if_index = ~0;
13064 u8 enable_disable = 1;
13067 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13069 if (unformat (line_input, "disable"))
13070 enable_disable = 0;
13071 if (unformat (line_input, "enable"))
13072 enable_disable = 1;
13073 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13074 vam, &sw_if_index))
13076 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13082 if (sw_if_index == ~0)
13084 errmsg ("missing interface name or sw_if_index");
13088 /* Construct the API message */
13089 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13090 mp->sw_if_index = ntohl (sw_if_index);
13091 mp->enable_disable = enable_disable;
13095 /* Wait for the reply */
13101 api_cop_whitelist_enable_disable (vat_main_t * vam)
13103 unformat_input_t *line_input = vam->input;
13104 vl_api_cop_whitelist_enable_disable_t *mp;
13105 u32 sw_if_index = ~0;
13106 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13110 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13112 if (unformat (line_input, "ip4"))
13114 else if (unformat (line_input, "ip6"))
13116 else if (unformat (line_input, "default"))
13118 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13119 vam, &sw_if_index))
13121 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13123 else if (unformat (line_input, "fib-id %d", &fib_id))
13129 if (sw_if_index == ~0)
13131 errmsg ("missing interface name or sw_if_index");
13135 /* Construct the API message */
13136 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13137 mp->sw_if_index = ntohl (sw_if_index);
13138 mp->fib_id = ntohl (fib_id);
13141 mp->default_cop = default_cop;
13145 /* Wait for the reply */
13151 api_get_node_graph (vat_main_t * vam)
13153 vl_api_get_node_graph_t *mp;
13156 M (GET_NODE_GRAPH, mp);
13160 /* Wait for the reply */
13166 /** Used for parsing LISP eids */
13167 typedef CLIB_PACKED(struct{
13168 u8 addr[16]; /**< eid address */
13169 u32 len; /**< prefix length if IP */
13170 u8 type; /**< type of eid */
13175 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13177 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13179 memset (a, 0, sizeof (a[0]));
13181 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13183 a->type = 0; /* ipv4 type */
13185 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13187 a->type = 1; /* ipv6 type */
13189 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13191 a->type = 2; /* mac type */
13198 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13207 lisp_eid_size_vat (u8 type)
13222 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13224 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13228 api_one_add_del_locator_set (vat_main_t * vam)
13230 unformat_input_t *input = vam->input;
13231 vl_api_one_add_del_locator_set_t *mp;
13233 u8 *locator_set_name = NULL;
13234 u8 locator_set_name_set = 0;
13235 vl_api_local_locator_t locator, *locators = 0;
13236 u32 sw_if_index, priority, weight;
13240 /* Parse args required to build the message */
13241 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13243 if (unformat (input, "del"))
13247 else if (unformat (input, "locator-set %s", &locator_set_name))
13249 locator_set_name_set = 1;
13251 else if (unformat (input, "sw_if_index %u p %u w %u",
13252 &sw_if_index, &priority, &weight))
13254 locator.sw_if_index = htonl (sw_if_index);
13255 locator.priority = priority;
13256 locator.weight = weight;
13257 vec_add1 (locators, locator);
13261 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13262 &sw_if_index, &priority, &weight))
13264 locator.sw_if_index = htonl (sw_if_index);
13265 locator.priority = priority;
13266 locator.weight = weight;
13267 vec_add1 (locators, locator);
13273 if (locator_set_name_set == 0)
13275 errmsg ("missing locator-set name");
13276 vec_free (locators);
13280 if (vec_len (locator_set_name) > 64)
13282 errmsg ("locator-set name too long");
13283 vec_free (locator_set_name);
13284 vec_free (locators);
13287 vec_add1 (locator_set_name, 0);
13289 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13291 /* Construct the API message */
13292 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13294 mp->is_add = is_add;
13295 clib_memcpy (mp->locator_set_name, locator_set_name,
13296 vec_len (locator_set_name));
13297 vec_free (locator_set_name);
13299 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13301 clib_memcpy (mp->locators, locators, data_len);
13302 vec_free (locators);
13307 /* Wait for a reply... */
13312 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13315 api_one_add_del_locator (vat_main_t * vam)
13317 unformat_input_t *input = vam->input;
13318 vl_api_one_add_del_locator_t *mp;
13319 u32 tmp_if_index = ~0;
13320 u32 sw_if_index = ~0;
13321 u8 sw_if_index_set = 0;
13322 u8 sw_if_index_if_name_set = 0;
13324 u8 priority_set = 0;
13328 u8 *locator_set_name = NULL;
13329 u8 locator_set_name_set = 0;
13332 /* Parse args required to build the message */
13333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13335 if (unformat (input, "del"))
13339 else if (unformat (input, "locator-set %s", &locator_set_name))
13341 locator_set_name_set = 1;
13343 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13346 sw_if_index_if_name_set = 1;
13347 sw_if_index = tmp_if_index;
13349 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13351 sw_if_index_set = 1;
13352 sw_if_index = tmp_if_index;
13354 else if (unformat (input, "p %d", &priority))
13358 else if (unformat (input, "w %d", &weight))
13366 if (locator_set_name_set == 0)
13368 errmsg ("missing locator-set name");
13372 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13374 errmsg ("missing sw_if_index");
13375 vec_free (locator_set_name);
13379 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13381 errmsg ("cannot use both params interface name and sw_if_index");
13382 vec_free (locator_set_name);
13386 if (priority_set == 0)
13388 errmsg ("missing locator-set priority");
13389 vec_free (locator_set_name);
13393 if (weight_set == 0)
13395 errmsg ("missing locator-set weight");
13396 vec_free (locator_set_name);
13400 if (vec_len (locator_set_name) > 64)
13402 errmsg ("locator-set name too long");
13403 vec_free (locator_set_name);
13406 vec_add1 (locator_set_name, 0);
13408 /* Construct the API message */
13409 M (ONE_ADD_DEL_LOCATOR, mp);
13411 mp->is_add = is_add;
13412 mp->sw_if_index = ntohl (sw_if_index);
13413 mp->priority = priority;
13414 mp->weight = weight;
13415 clib_memcpy (mp->locator_set_name, locator_set_name,
13416 vec_len (locator_set_name));
13417 vec_free (locator_set_name);
13422 /* Wait for a reply... */
13427 #define api_lisp_add_del_locator api_one_add_del_locator
13430 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13432 u32 *key_id = va_arg (*args, u32 *);
13435 if (unformat (input, "%s", &s))
13437 if (!strcmp ((char *) s, "sha1"))
13438 key_id[0] = HMAC_SHA_1_96;
13439 else if (!strcmp ((char *) s, "sha256"))
13440 key_id[0] = HMAC_SHA_256_128;
13443 clib_warning ("invalid key_id: '%s'", s);
13444 key_id[0] = HMAC_NO_KEY;
13455 api_one_add_del_local_eid (vat_main_t * vam)
13457 unformat_input_t *input = vam->input;
13458 vl_api_one_add_del_local_eid_t *mp;
13461 lisp_eid_vat_t _eid, *eid = &_eid;
13462 u8 *locator_set_name = 0;
13463 u8 locator_set_name_set = 0;
13469 /* Parse args required to build the message */
13470 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13472 if (unformat (input, "del"))
13476 else if (unformat (input, "vni %d", &vni))
13480 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13484 else if (unformat (input, "locator-set %s", &locator_set_name))
13486 locator_set_name_set = 1;
13488 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13490 else if (unformat (input, "secret-key %_%v%_", &key))
13496 if (locator_set_name_set == 0)
13498 errmsg ("missing locator-set name");
13504 errmsg ("EID address not set!");
13505 vec_free (locator_set_name);
13509 if (key && (0 == key_id))
13511 errmsg ("invalid key_id!");
13515 if (vec_len (key) > 64)
13517 errmsg ("key too long");
13522 if (vec_len (locator_set_name) > 64)
13524 errmsg ("locator-set name too long");
13525 vec_free (locator_set_name);
13528 vec_add1 (locator_set_name, 0);
13530 /* Construct the API message */
13531 M (ONE_ADD_DEL_LOCAL_EID, mp);
13533 mp->is_add = is_add;
13534 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13535 mp->eid_type = eid->type;
13536 mp->prefix_len = eid->len;
13537 mp->vni = clib_host_to_net_u32 (vni);
13538 mp->key_id = clib_host_to_net_u16 (key_id);
13539 clib_memcpy (mp->locator_set_name, locator_set_name,
13540 vec_len (locator_set_name));
13541 clib_memcpy (mp->key, key, vec_len (key));
13543 vec_free (locator_set_name);
13549 /* Wait for a reply... */
13554 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13557 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13559 u32 dp_table = 0, vni = 0;;
13560 unformat_input_t *input = vam->input;
13561 vl_api_gpe_add_del_fwd_entry_t *mp;
13563 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13564 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13565 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13566 u32 action = ~0, w;
13567 ip4_address_t rmt_rloc4, lcl_rloc4;
13568 ip6_address_t rmt_rloc6, lcl_rloc6;
13569 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13572 memset (&rloc, 0, sizeof (rloc));
13574 /* Parse args required to build the message */
13575 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13577 if (unformat (input, "del"))
13579 else if (unformat (input, "add"))
13581 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13585 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13589 else if (unformat (input, "vrf %d", &dp_table))
13591 else if (unformat (input, "bd %d", &dp_table))
13593 else if (unformat (input, "vni %d", &vni))
13595 else if (unformat (input, "w %d", &w))
13599 errmsg ("No RLOC configured for setting priority/weight!");
13602 curr_rloc->weight = w;
13604 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13605 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13609 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13611 vec_add1 (lcl_locs, rloc);
13613 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13614 vec_add1 (rmt_locs, rloc);
13615 /* weight saved in rmt loc */
13616 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13618 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13619 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13622 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13624 vec_add1 (lcl_locs, rloc);
13626 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13627 vec_add1 (rmt_locs, rloc);
13628 /* weight saved in rmt loc */
13629 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13631 else if (unformat (input, "action %d", &action))
13637 clib_warning ("parse error '%U'", format_unformat_error, input);
13644 errmsg ("remote eid addresses not set");
13648 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13650 errmsg ("eid types don't match");
13654 if (0 == rmt_locs && (u32) ~ 0 == action)
13656 errmsg ("action not set for negative mapping");
13660 /* Construct the API message */
13661 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13662 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13664 mp->is_add = is_add;
13665 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13666 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13667 mp->eid_type = rmt_eid->type;
13668 mp->dp_table = clib_host_to_net_u32 (dp_table);
13669 mp->vni = clib_host_to_net_u32 (vni);
13670 mp->rmt_len = rmt_eid->len;
13671 mp->lcl_len = lcl_eid->len;
13672 mp->action = action;
13674 if (0 != rmt_locs && 0 != lcl_locs)
13676 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13677 clib_memcpy (mp->locs, lcl_locs,
13678 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13680 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13681 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13682 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13684 vec_free (lcl_locs);
13685 vec_free (rmt_locs);
13690 /* Wait for a reply... */
13696 api_one_add_del_map_server (vat_main_t * vam)
13698 unformat_input_t *input = vam->input;
13699 vl_api_one_add_del_map_server_t *mp;
13703 ip4_address_t ipv4;
13704 ip6_address_t ipv6;
13707 /* Parse args required to build the message */
13708 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13710 if (unformat (input, "del"))
13714 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13718 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13726 if (ipv4_set && ipv6_set)
13728 errmsg ("both eid v4 and v6 addresses set");
13732 if (!ipv4_set && !ipv6_set)
13734 errmsg ("eid addresses not set");
13738 /* Construct the API message */
13739 M (ONE_ADD_DEL_MAP_SERVER, mp);
13741 mp->is_add = is_add;
13745 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13750 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13756 /* Wait for a reply... */
13761 #define api_lisp_add_del_map_server api_one_add_del_map_server
13764 api_one_add_del_map_resolver (vat_main_t * vam)
13766 unformat_input_t *input = vam->input;
13767 vl_api_one_add_del_map_resolver_t *mp;
13771 ip4_address_t ipv4;
13772 ip6_address_t ipv6;
13775 /* Parse args required to build the message */
13776 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13778 if (unformat (input, "del"))
13782 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13786 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13794 if (ipv4_set && ipv6_set)
13796 errmsg ("both eid v4 and v6 addresses set");
13800 if (!ipv4_set && !ipv6_set)
13802 errmsg ("eid addresses not set");
13806 /* Construct the API message */
13807 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13809 mp->is_add = is_add;
13813 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13818 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13824 /* Wait for a reply... */
13829 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
13832 api_lisp_gpe_enable_disable (vat_main_t * vam)
13834 unformat_input_t *input = vam->input;
13835 vl_api_gpe_enable_disable_t *mp;
13840 /* Parse args required to build the message */
13841 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13843 if (unformat (input, "enable"))
13848 else if (unformat (input, "disable"))
13859 errmsg ("Value not set");
13863 /* Construct the API message */
13864 M (GPE_ENABLE_DISABLE, mp);
13871 /* Wait for a reply... */
13877 api_one_rloc_probe_enable_disable (vat_main_t * vam)
13879 unformat_input_t *input = vam->input;
13880 vl_api_one_rloc_probe_enable_disable_t *mp;
13885 /* Parse args required to build the message */
13886 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13888 if (unformat (input, "enable"))
13893 else if (unformat (input, "disable"))
13901 errmsg ("Value not set");
13905 /* Construct the API message */
13906 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
13908 mp->is_enabled = is_en;
13913 /* Wait for a reply... */
13918 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
13921 api_one_map_register_enable_disable (vat_main_t * vam)
13923 unformat_input_t *input = vam->input;
13924 vl_api_one_map_register_enable_disable_t *mp;
13929 /* Parse args required to build the message */
13930 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13932 if (unformat (input, "enable"))
13937 else if (unformat (input, "disable"))
13945 errmsg ("Value not set");
13949 /* Construct the API message */
13950 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
13952 mp->is_enabled = is_en;
13957 /* Wait for a reply... */
13962 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
13965 api_one_enable_disable (vat_main_t * vam)
13967 unformat_input_t *input = vam->input;
13968 vl_api_one_enable_disable_t *mp;
13973 /* Parse args required to build the message */
13974 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13976 if (unformat (input, "enable"))
13981 else if (unformat (input, "disable"))
13991 errmsg ("Value not set");
13995 /* Construct the API message */
13996 M (ONE_ENABLE_DISABLE, mp);
14003 /* Wait for a reply... */
14008 #define api_lisp_enable_disable api_one_enable_disable
14011 api_show_one_map_register_state (vat_main_t * vam)
14013 vl_api_show_one_map_register_state_t *mp;
14016 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
14021 /* wait for reply */
14026 #define api_show_lisp_map_register_state api_show_one_map_register_state
14029 api_show_one_rloc_probe_state (vat_main_t * vam)
14031 vl_api_show_one_rloc_probe_state_t *mp;
14034 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14039 /* wait for reply */
14044 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14047 api_show_one_map_request_mode (vat_main_t * vam)
14049 vl_api_show_one_map_request_mode_t *mp;
14052 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14057 /* wait for reply */
14062 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14065 api_one_map_request_mode (vat_main_t * vam)
14067 unformat_input_t *input = vam->input;
14068 vl_api_one_map_request_mode_t *mp;
14072 /* Parse args required to build the message */
14073 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14075 if (unformat (input, "dst-only"))
14077 else if (unformat (input, "src-dst"))
14081 errmsg ("parse error '%U'", format_unformat_error, input);
14086 M (ONE_MAP_REQUEST_MODE, mp);
14093 /* wait for reply */
14098 #define api_lisp_map_request_mode api_one_map_request_mode
14101 * Enable/disable ONE proxy ITR.
14103 * @param vam vpp API test context
14104 * @return return code
14107 api_one_pitr_set_locator_set (vat_main_t * vam)
14109 u8 ls_name_set = 0;
14110 unformat_input_t *input = vam->input;
14111 vl_api_one_pitr_set_locator_set_t *mp;
14116 /* Parse args required to build the message */
14117 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14119 if (unformat (input, "del"))
14121 else if (unformat (input, "locator-set %s", &ls_name))
14125 errmsg ("parse error '%U'", format_unformat_error, input);
14132 errmsg ("locator-set name not set!");
14136 M (ONE_PITR_SET_LOCATOR_SET, mp);
14138 mp->is_add = is_add;
14139 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14140 vec_free (ls_name);
14145 /* wait for reply */
14150 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14153 api_show_one_pitr (vat_main_t * vam)
14155 vl_api_show_one_pitr_t *mp;
14158 if (!vam->json_output)
14160 print (vam->ofp, "%=20s", "lisp status:");
14163 M (SHOW_ONE_PITR, mp);
14167 /* Wait for a reply... */
14172 #define api_show_lisp_pitr api_show_one_pitr
14175 * Add/delete mapping between vni and vrf
14178 api_one_eid_table_add_del_map (vat_main_t * vam)
14180 unformat_input_t *input = vam->input;
14181 vl_api_one_eid_table_add_del_map_t *mp;
14182 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14183 u32 vni, vrf, bd_index;
14186 /* Parse args required to build the message */
14187 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14189 if (unformat (input, "del"))
14191 else if (unformat (input, "vrf %d", &vrf))
14193 else if (unformat (input, "bd_index %d", &bd_index))
14195 else if (unformat (input, "vni %d", &vni))
14201 if (!vni_set || (!vrf_set && !bd_index_set))
14203 errmsg ("missing arguments!");
14207 if (vrf_set && bd_index_set)
14209 errmsg ("error: both vrf and bd entered!");
14213 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14215 mp->is_add = is_add;
14216 mp->vni = htonl (vni);
14217 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14218 mp->is_l2 = bd_index_set;
14223 /* wait for reply */
14228 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14231 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14233 u32 *action = va_arg (*args, u32 *);
14236 if (unformat (input, "%s", &s))
14238 if (!strcmp ((char *) s, "no-action"))
14240 else if (!strcmp ((char *) s, "natively-forward"))
14242 else if (!strcmp ((char *) s, "send-map-request"))
14244 else if (!strcmp ((char *) s, "drop"))
14248 clib_warning ("invalid action: '%s'", s);
14260 * Add/del remote mapping to/from ONE control plane
14262 * @param vam vpp API test context
14263 * @return return code
14266 api_one_add_del_remote_mapping (vat_main_t * vam)
14268 unformat_input_t *input = vam->input;
14269 vl_api_one_add_del_remote_mapping_t *mp;
14271 lisp_eid_vat_t _eid, *eid = &_eid;
14272 lisp_eid_vat_t _seid, *seid = &_seid;
14273 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14274 u32 action = ~0, p, w, data_len;
14275 ip4_address_t rloc4;
14276 ip6_address_t rloc6;
14277 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14280 memset (&rloc, 0, sizeof (rloc));
14282 /* Parse args required to build the message */
14283 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14285 if (unformat (input, "del-all"))
14289 else if (unformat (input, "del"))
14293 else if (unformat (input, "add"))
14297 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14301 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14305 else if (unformat (input, "vni %d", &vni))
14309 else if (unformat (input, "p %d w %d", &p, &w))
14313 errmsg ("No RLOC configured for setting priority/weight!");
14316 curr_rloc->priority = p;
14317 curr_rloc->weight = w;
14319 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14322 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14323 vec_add1 (rlocs, rloc);
14324 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14326 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14329 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14330 vec_add1 (rlocs, rloc);
14331 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14333 else if (unformat (input, "action %U",
14334 unformat_negative_mapping_action, &action))
14340 clib_warning ("parse error '%U'", format_unformat_error, input);
14347 errmsg ("missing params!");
14351 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14353 errmsg ("no action set for negative map-reply!");
14357 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14359 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14360 mp->is_add = is_add;
14361 mp->vni = htonl (vni);
14362 mp->action = (u8) action;
14363 mp->is_src_dst = seid_set;
14364 mp->eid_len = eid->len;
14365 mp->seid_len = seid->len;
14366 mp->del_all = del_all;
14367 mp->eid_type = eid->type;
14368 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14369 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14371 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14372 clib_memcpy (mp->rlocs, rlocs, data_len);
14378 /* Wait for a reply... */
14383 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14386 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14387 * forwarding entries in data-plane accordingly.
14389 * @param vam vpp API test context
14390 * @return return code
14393 api_one_add_del_adjacency (vat_main_t * vam)
14395 unformat_input_t *input = vam->input;
14396 vl_api_one_add_del_adjacency_t *mp;
14398 ip4_address_t leid4, reid4;
14399 ip6_address_t leid6, reid6;
14400 u8 reid_mac[6] = { 0 };
14401 u8 leid_mac[6] = { 0 };
14402 u8 reid_type, leid_type;
14403 u32 leid_len = 0, reid_len = 0, len;
14407 leid_type = reid_type = (u8) ~ 0;
14409 /* Parse args required to build the message */
14410 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14412 if (unformat (input, "del"))
14416 else if (unformat (input, "add"))
14420 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14423 reid_type = 0; /* ipv4 */
14426 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14429 reid_type = 1; /* ipv6 */
14432 else if (unformat (input, "reid %U", unformat_ethernet_address,
14435 reid_type = 2; /* mac */
14437 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14440 leid_type = 0; /* ipv4 */
14443 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14446 leid_type = 1; /* ipv6 */
14449 else if (unformat (input, "leid %U", unformat_ethernet_address,
14452 leid_type = 2; /* mac */
14454 else if (unformat (input, "vni %d", &vni))
14460 errmsg ("parse error '%U'", format_unformat_error, input);
14465 if ((u8) ~ 0 == reid_type)
14467 errmsg ("missing params!");
14471 if (leid_type != reid_type)
14473 errmsg ("remote and local EIDs are of different types!");
14477 M (ONE_ADD_DEL_ADJACENCY, mp);
14478 mp->is_add = is_add;
14479 mp->vni = htonl (vni);
14480 mp->leid_len = leid_len;
14481 mp->reid_len = reid_len;
14482 mp->eid_type = reid_type;
14484 switch (mp->eid_type)
14487 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14488 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14491 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14492 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14495 clib_memcpy (mp->leid, leid_mac, 6);
14496 clib_memcpy (mp->reid, reid_mac, 6);
14499 errmsg ("unknown EID type %d!", mp->eid_type);
14506 /* Wait for a reply... */
14511 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14514 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14516 u32 *mode = va_arg (*args, u32 *);
14518 if (unformat (input, "lisp"))
14520 else if (unformat (input, "vxlan"))
14529 api_gpe_get_encap_mode (vat_main_t * vam)
14531 vl_api_gpe_get_encap_mode_t *mp;
14534 /* Construct the API message */
14535 M (GPE_GET_ENCAP_MODE, mp);
14540 /* Wait for a reply... */
14546 api_gpe_set_encap_mode (vat_main_t * vam)
14548 unformat_input_t *input = vam->input;
14549 vl_api_gpe_set_encap_mode_t *mp;
14553 /* Parse args required to build the message */
14554 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14556 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14562 /* Construct the API message */
14563 M (GPE_SET_ENCAP_MODE, mp);
14570 /* Wait for a reply... */
14576 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14578 unformat_input_t *input = vam->input;
14579 vl_api_gpe_add_del_iface_t *mp;
14580 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14581 u32 dp_table = 0, vni = 0;
14584 /* Parse args required to build the message */
14585 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14587 if (unformat (input, "up"))
14592 else if (unformat (input, "down"))
14597 else if (unformat (input, "table_id %d", &dp_table))
14601 else if (unformat (input, "bd_id %d", &dp_table))
14606 else if (unformat (input, "vni %d", &vni))
14614 if (action_set == 0)
14616 errmsg ("Action not set");
14619 if (dp_table_set == 0 || vni_set == 0)
14621 errmsg ("vni and dp_table must be set");
14625 /* Construct the API message */
14626 M (GPE_ADD_DEL_IFACE, mp);
14628 mp->is_add = is_add;
14629 mp->dp_table = dp_table;
14636 /* Wait for a reply... */
14642 * Add/del map request itr rlocs from ONE control plane and updates
14644 * @param vam vpp API test context
14645 * @return return code
14648 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14650 unformat_input_t *input = vam->input;
14651 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14652 u8 *locator_set_name = 0;
14653 u8 locator_set_name_set = 0;
14657 /* Parse args required to build the message */
14658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14660 if (unformat (input, "del"))
14664 else if (unformat (input, "%_%v%_", &locator_set_name))
14666 locator_set_name_set = 1;
14670 clib_warning ("parse error '%U'", format_unformat_error, input);
14675 if (is_add && !locator_set_name_set)
14677 errmsg ("itr-rloc is not set!");
14681 if (is_add && vec_len (locator_set_name) > 64)
14683 errmsg ("itr-rloc locator-set name too long");
14684 vec_free (locator_set_name);
14688 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14689 mp->is_add = is_add;
14692 clib_memcpy (mp->locator_set_name, locator_set_name,
14693 vec_len (locator_set_name));
14697 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14699 vec_free (locator_set_name);
14704 /* Wait for a reply... */
14709 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14712 api_one_locator_dump (vat_main_t * vam)
14714 unformat_input_t *input = vam->input;
14715 vl_api_one_locator_dump_t *mp;
14716 vl_api_control_ping_t *mp_ping;
14717 u8 is_index_set = 0, is_name_set = 0;
14722 /* Parse args required to build the message */
14723 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14725 if (unformat (input, "ls_name %_%v%_", &ls_name))
14729 else if (unformat (input, "ls_index %d", &ls_index))
14735 errmsg ("parse error '%U'", format_unformat_error, input);
14740 if (!is_index_set && !is_name_set)
14742 errmsg ("error: expected one of index or name!");
14746 if (is_index_set && is_name_set)
14748 errmsg ("error: only one param expected!");
14752 if (vec_len (ls_name) > 62)
14754 errmsg ("error: locator set name too long!");
14758 if (!vam->json_output)
14760 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14763 M (ONE_LOCATOR_DUMP, mp);
14764 mp->is_index_set = is_index_set;
14767 mp->ls_index = clib_host_to_net_u32 (ls_index);
14770 vec_add1 (ls_name, 0);
14771 strncpy ((char *) mp->ls_name, (char *) ls_name,
14772 sizeof (mp->ls_name) - 1);
14778 /* Use a control ping for synchronization */
14779 M (CONTROL_PING, mp_ping);
14782 /* Wait for a reply... */
14787 #define api_lisp_locator_dump api_one_locator_dump
14790 api_one_locator_set_dump (vat_main_t * vam)
14792 vl_api_one_locator_set_dump_t *mp;
14793 vl_api_control_ping_t *mp_ping;
14794 unformat_input_t *input = vam->input;
14798 /* Parse args required to build the message */
14799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14801 if (unformat (input, "local"))
14805 else if (unformat (input, "remote"))
14811 errmsg ("parse error '%U'", format_unformat_error, input);
14816 if (!vam->json_output)
14818 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14821 M (ONE_LOCATOR_SET_DUMP, mp);
14823 mp->filter = filter;
14828 /* Use a control ping for synchronization */
14829 M (CONTROL_PING, mp_ping);
14832 /* Wait for a reply... */
14837 #define api_lisp_locator_set_dump api_one_locator_set_dump
14840 api_one_eid_table_map_dump (vat_main_t * vam)
14844 unformat_input_t *input = vam->input;
14845 vl_api_one_eid_table_map_dump_t *mp;
14846 vl_api_control_ping_t *mp_ping;
14849 /* Parse args required to build the message */
14850 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14852 if (unformat (input, "l2"))
14857 else if (unformat (input, "l3"))
14864 errmsg ("parse error '%U'", format_unformat_error, input);
14871 errmsg ("expected one of 'l2' or 'l3' parameter!");
14875 if (!vam->json_output)
14877 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14880 M (ONE_EID_TABLE_MAP_DUMP, mp);
14886 /* Use a control ping for synchronization */
14887 M (CONTROL_PING, mp_ping);
14890 /* Wait for a reply... */
14895 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
14898 api_one_eid_table_vni_dump (vat_main_t * vam)
14900 vl_api_one_eid_table_vni_dump_t *mp;
14901 vl_api_control_ping_t *mp_ping;
14904 if (!vam->json_output)
14906 print (vam->ofp, "VNI");
14909 M (ONE_EID_TABLE_VNI_DUMP, mp);
14914 /* Use a control ping for synchronization */
14915 M (CONTROL_PING, mp_ping);
14918 /* Wait for a reply... */
14923 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
14926 api_one_eid_table_dump (vat_main_t * vam)
14928 unformat_input_t *i = vam->input;
14929 vl_api_one_eid_table_dump_t *mp;
14930 vl_api_control_ping_t *mp_ping;
14931 struct in_addr ip4;
14932 struct in6_addr ip6;
14934 u8 eid_type = ~0, eid_set = 0;
14935 u32 prefix_length = ~0, t, vni = 0;
14939 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14941 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14947 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14953 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14958 else if (unformat (i, "vni %d", &t))
14962 else if (unformat (i, "local"))
14966 else if (unformat (i, "remote"))
14972 errmsg ("parse error '%U'", format_unformat_error, i);
14977 if (!vam->json_output)
14979 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14980 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14983 M (ONE_EID_TABLE_DUMP, mp);
14985 mp->filter = filter;
14989 mp->vni = htonl (vni);
14990 mp->eid_type = eid_type;
14994 mp->prefix_length = prefix_length;
14995 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14998 mp->prefix_length = prefix_length;
14999 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
15002 clib_memcpy (mp->eid, mac, sizeof (mac));
15005 errmsg ("unknown EID type %d!", eid_type);
15013 /* Use a control ping for synchronization */
15014 M (CONTROL_PING, mp_ping);
15017 /* Wait for a reply... */
15022 #define api_lisp_eid_table_dump api_one_eid_table_dump
15025 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
15027 unformat_input_t *i = vam->input;
15028 vl_api_gpe_fwd_entries_get_t *mp;
15033 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15035 if (unformat (i, "vni %d", &vni))
15041 errmsg ("parse error '%U'", format_unformat_error, i);
15048 errmsg ("vni not set!");
15052 if (!vam->json_output)
15054 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15058 M (GPE_FWD_ENTRIES_GET, mp);
15059 mp->vni = clib_host_to_net_u32 (vni);
15064 /* Wait for a reply... */
15069 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15070 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15071 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15072 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15075 api_one_adjacencies_get (vat_main_t * vam)
15077 unformat_input_t *i = vam->input;
15078 vl_api_one_adjacencies_get_t *mp;
15083 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15085 if (unformat (i, "vni %d", &vni))
15091 errmsg ("parse error '%U'", format_unformat_error, i);
15098 errmsg ("vni not set!");
15102 if (!vam->json_output)
15104 print (vam->ofp, "%s %40s", "leid", "reid");
15107 M (ONE_ADJACENCIES_GET, mp);
15108 mp->vni = clib_host_to_net_u32 (vni);
15113 /* Wait for a reply... */
15118 #define api_lisp_adjacencies_get api_one_adjacencies_get
15121 api_one_map_server_dump (vat_main_t * vam)
15123 vl_api_one_map_server_dump_t *mp;
15124 vl_api_control_ping_t *mp_ping;
15127 if (!vam->json_output)
15129 print (vam->ofp, "%=20s", "Map server");
15132 M (ONE_MAP_SERVER_DUMP, mp);
15136 /* Use a control ping for synchronization */
15137 M (CONTROL_PING, mp_ping);
15140 /* Wait for a reply... */
15145 #define api_lisp_map_server_dump api_one_map_server_dump
15148 api_one_map_resolver_dump (vat_main_t * vam)
15150 vl_api_one_map_resolver_dump_t *mp;
15151 vl_api_control_ping_t *mp_ping;
15154 if (!vam->json_output)
15156 print (vam->ofp, "%=20s", "Map resolver");
15159 M (ONE_MAP_RESOLVER_DUMP, mp);
15163 /* Use a control ping for synchronization */
15164 M (CONTROL_PING, mp_ping);
15167 /* Wait for a reply... */
15172 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15175 api_show_one_status (vat_main_t * vam)
15177 vl_api_show_one_status_t *mp;
15180 if (!vam->json_output)
15182 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15185 M (SHOW_ONE_STATUS, mp);
15188 /* Wait for a reply... */
15193 #define api_show_lisp_status api_show_one_status
15196 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15198 vl_api_gpe_fwd_entry_path_dump_t *mp;
15199 vl_api_control_ping_t *mp_ping;
15200 unformat_input_t *i = vam->input;
15201 u32 fwd_entry_index = ~0;
15204 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15206 if (unformat (i, "index %d", &fwd_entry_index))
15212 if (~0 == fwd_entry_index)
15214 errmsg ("no index specified!");
15218 if (!vam->json_output)
15220 print (vam->ofp, "first line");
15223 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15227 /* Use a control ping for synchronization */
15228 M (CONTROL_PING, mp_ping);
15231 /* Wait for a reply... */
15237 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15239 vl_api_one_get_map_request_itr_rlocs_t *mp;
15242 if (!vam->json_output)
15244 print (vam->ofp, "%=20s", "itr-rlocs:");
15247 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15250 /* Wait for a reply... */
15255 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15258 api_af_packet_create (vat_main_t * vam)
15260 unformat_input_t *i = vam->input;
15261 vl_api_af_packet_create_t *mp;
15262 u8 *host_if_name = 0;
15264 u8 random_hw_addr = 1;
15267 memset (hw_addr, 0, sizeof (hw_addr));
15269 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15271 if (unformat (i, "name %s", &host_if_name))
15272 vec_add1 (host_if_name, 0);
15273 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15274 random_hw_addr = 0;
15279 if (!vec_len (host_if_name))
15281 errmsg ("host-interface name must be specified");
15285 if (vec_len (host_if_name) > 64)
15287 errmsg ("host-interface name too long");
15291 M (AF_PACKET_CREATE, mp);
15293 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15294 clib_memcpy (mp->hw_addr, hw_addr, 6);
15295 mp->use_random_hw_addr = random_hw_addr;
15296 vec_free (host_if_name);
15304 fprintf (vam->ofp ? vam->ofp : stderr,
15305 " new sw_if_index = %d\n", vam->sw_if_index);
15312 api_af_packet_delete (vat_main_t * vam)
15314 unformat_input_t *i = vam->input;
15315 vl_api_af_packet_delete_t *mp;
15316 u8 *host_if_name = 0;
15319 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15321 if (unformat (i, "name %s", &host_if_name))
15322 vec_add1 (host_if_name, 0);
15327 if (!vec_len (host_if_name))
15329 errmsg ("host-interface name must be specified");
15333 if (vec_len (host_if_name) > 64)
15335 errmsg ("host-interface name too long");
15339 M (AF_PACKET_DELETE, mp);
15341 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15342 vec_free (host_if_name);
15350 api_policer_add_del (vat_main_t * vam)
15352 unformat_input_t *i = vam->input;
15353 vl_api_policer_add_del_t *mp;
15363 u8 color_aware = 0;
15364 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15367 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15368 conform_action.dscp = 0;
15369 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15370 exceed_action.dscp = 0;
15371 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15372 violate_action.dscp = 0;
15374 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15376 if (unformat (i, "del"))
15378 else if (unformat (i, "name %s", &name))
15379 vec_add1 (name, 0);
15380 else if (unformat (i, "cir %u", &cir))
15382 else if (unformat (i, "eir %u", &eir))
15384 else if (unformat (i, "cb %u", &cb))
15386 else if (unformat (i, "eb %u", &eb))
15388 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15391 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15394 else if (unformat (i, "type %U", unformat_policer_type, &type))
15396 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15399 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15402 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15405 else if (unformat (i, "color-aware"))
15411 if (!vec_len (name))
15413 errmsg ("policer name must be specified");
15417 if (vec_len (name) > 64)
15419 errmsg ("policer name too long");
15423 M (POLICER_ADD_DEL, mp);
15425 clib_memcpy (mp->name, name, vec_len (name));
15427 mp->is_add = is_add;
15432 mp->rate_type = rate_type;
15433 mp->round_type = round_type;
15435 mp->conform_action_type = conform_action.action_type;
15436 mp->conform_dscp = conform_action.dscp;
15437 mp->exceed_action_type = exceed_action.action_type;
15438 mp->exceed_dscp = exceed_action.dscp;
15439 mp->violate_action_type = violate_action.action_type;
15440 mp->violate_dscp = violate_action.dscp;
15441 mp->color_aware = color_aware;
15449 api_policer_dump (vat_main_t * vam)
15451 unformat_input_t *i = vam->input;
15452 vl_api_policer_dump_t *mp;
15453 vl_api_control_ping_t *mp_ping;
15454 u8 *match_name = 0;
15455 u8 match_name_valid = 0;
15458 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15460 if (unformat (i, "name %s", &match_name))
15462 vec_add1 (match_name, 0);
15463 match_name_valid = 1;
15469 M (POLICER_DUMP, mp);
15470 mp->match_name_valid = match_name_valid;
15471 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15472 vec_free (match_name);
15476 /* Use a control ping for synchronization */
15477 M (CONTROL_PING, mp_ping);
15480 /* Wait for a reply... */
15486 api_policer_classify_set_interface (vat_main_t * vam)
15488 unformat_input_t *i = vam->input;
15489 vl_api_policer_classify_set_interface_t *mp;
15491 int sw_if_index_set;
15492 u32 ip4_table_index = ~0;
15493 u32 ip6_table_index = ~0;
15494 u32 l2_table_index = ~0;
15498 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15500 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15501 sw_if_index_set = 1;
15502 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15503 sw_if_index_set = 1;
15504 else if (unformat (i, "del"))
15506 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15508 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15510 else if (unformat (i, "l2-table %d", &l2_table_index))
15514 clib_warning ("parse error '%U'", format_unformat_error, i);
15519 if (sw_if_index_set == 0)
15521 errmsg ("missing interface name or sw_if_index");
15525 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15527 mp->sw_if_index = ntohl (sw_if_index);
15528 mp->ip4_table_index = ntohl (ip4_table_index);
15529 mp->ip6_table_index = ntohl (ip6_table_index);
15530 mp->l2_table_index = ntohl (l2_table_index);
15531 mp->is_add = is_add;
15539 api_policer_classify_dump (vat_main_t * vam)
15541 unformat_input_t *i = vam->input;
15542 vl_api_policer_classify_dump_t *mp;
15543 vl_api_control_ping_t *mp_ping;
15544 u8 type = POLICER_CLASSIFY_N_TABLES;
15547 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15551 errmsg ("classify table type must be specified");
15555 if (!vam->json_output)
15557 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15560 M (POLICER_CLASSIFY_DUMP, mp);
15565 /* Use a control ping for synchronization */
15566 M (CONTROL_PING, mp_ping);
15569 /* Wait for a reply... */
15575 api_netmap_create (vat_main_t * vam)
15577 unformat_input_t *i = vam->input;
15578 vl_api_netmap_create_t *mp;
15581 u8 random_hw_addr = 1;
15586 memset (hw_addr, 0, sizeof (hw_addr));
15588 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15590 if (unformat (i, "name %s", &if_name))
15591 vec_add1 (if_name, 0);
15592 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15593 random_hw_addr = 0;
15594 else if (unformat (i, "pipe"))
15596 else if (unformat (i, "master"))
15598 else if (unformat (i, "slave"))
15604 if (!vec_len (if_name))
15606 errmsg ("interface name must be specified");
15610 if (vec_len (if_name) > 64)
15612 errmsg ("interface name too long");
15616 M (NETMAP_CREATE, mp);
15618 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15619 clib_memcpy (mp->hw_addr, hw_addr, 6);
15620 mp->use_random_hw_addr = random_hw_addr;
15621 mp->is_pipe = is_pipe;
15622 mp->is_master = is_master;
15623 vec_free (if_name);
15631 api_netmap_delete (vat_main_t * vam)
15633 unformat_input_t *i = vam->input;
15634 vl_api_netmap_delete_t *mp;
15638 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15640 if (unformat (i, "name %s", &if_name))
15641 vec_add1 (if_name, 0);
15646 if (!vec_len (if_name))
15648 errmsg ("interface name must be specified");
15652 if (vec_len (if_name) > 64)
15654 errmsg ("interface name too long");
15658 M (NETMAP_DELETE, mp);
15660 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15661 vec_free (if_name);
15668 static void vl_api_mpls_tunnel_details_t_handler
15669 (vl_api_mpls_tunnel_details_t * mp)
15671 vat_main_t *vam = &vat_main;
15672 i32 len = mp->mt_next_hop_n_labels;
15675 print (vam->ofp, "[%d]: via %U %d labels ",
15677 format_ip4_address, mp->mt_next_hop,
15678 ntohl (mp->mt_next_hop_sw_if_index));
15679 for (i = 0; i < len; i++)
15681 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15683 print (vam->ofp, "");
15686 static void vl_api_mpls_tunnel_details_t_handler_json
15687 (vl_api_mpls_tunnel_details_t * mp)
15689 vat_main_t *vam = &vat_main;
15690 vat_json_node_t *node = NULL;
15691 struct in_addr ip4;
15693 i32 len = mp->mt_next_hop_n_labels;
15695 if (VAT_JSON_ARRAY != vam->json_tree.type)
15697 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15698 vat_json_init_array (&vam->json_tree);
15700 node = vat_json_array_add (&vam->json_tree);
15702 vat_json_init_object (node);
15703 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15704 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15705 vat_json_object_add_ip4 (node, "next_hop", ip4);
15706 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15707 ntohl (mp->mt_next_hop_sw_if_index));
15708 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15709 vat_json_object_add_uint (node, "label_count", len);
15710 for (i = 0; i < len; i++)
15712 vat_json_object_add_uint (node, "label",
15713 ntohl (mp->mt_next_hop_out_labels[i]));
15718 api_mpls_tunnel_dump (vat_main_t * vam)
15720 vl_api_mpls_tunnel_dump_t *mp;
15721 vl_api_control_ping_t *mp_ping;
15725 /* Parse args required to build the message */
15726 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15728 if (!unformat (vam->input, "tunnel_index %d", &index))
15735 print (vam->ofp, " tunnel_index %d", index);
15737 M (MPLS_TUNNEL_DUMP, mp);
15738 mp->tunnel_index = htonl (index);
15741 /* Use a control ping for synchronization */
15742 M (CONTROL_PING, mp_ping);
15749 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15750 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15753 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15755 vat_main_t *vam = &vat_main;
15756 int count = ntohl (mp->count);
15757 vl_api_fib_path2_t *fp;
15761 "table-id %d, label %u, ess_bit %u",
15762 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15764 for (i = 0; i < count; i++)
15766 if (fp->afi == IP46_TYPE_IP6)
15768 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15769 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15770 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15771 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15772 format_ip6_address, fp->next_hop);
15773 else if (fp->afi == IP46_TYPE_IP4)
15775 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15776 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15777 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15778 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15779 format_ip4_address, fp->next_hop);
15784 static void vl_api_mpls_fib_details_t_handler_json
15785 (vl_api_mpls_fib_details_t * mp)
15787 vat_main_t *vam = &vat_main;
15788 int count = ntohl (mp->count);
15789 vat_json_node_t *node = NULL;
15790 struct in_addr ip4;
15791 struct in6_addr ip6;
15792 vl_api_fib_path2_t *fp;
15795 if (VAT_JSON_ARRAY != vam->json_tree.type)
15797 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15798 vat_json_init_array (&vam->json_tree);
15800 node = vat_json_array_add (&vam->json_tree);
15802 vat_json_init_object (node);
15803 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15804 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15805 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15806 vat_json_object_add_uint (node, "path_count", count);
15808 for (i = 0; i < count; i++)
15810 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15811 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15812 vat_json_object_add_uint (node, "is_local", fp->is_local);
15813 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15814 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15815 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15816 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15817 if (fp->afi == IP46_TYPE_IP4)
15819 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15820 vat_json_object_add_ip4 (node, "next_hop", ip4);
15822 else if (fp->afi == IP46_TYPE_IP6)
15824 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15825 vat_json_object_add_ip6 (node, "next_hop", ip6);
15831 api_mpls_fib_dump (vat_main_t * vam)
15833 vl_api_mpls_fib_dump_t *mp;
15834 vl_api_control_ping_t *mp_ping;
15837 M (MPLS_FIB_DUMP, mp);
15840 /* Use a control ping for synchronization */
15841 M (CONTROL_PING, mp_ping);
15848 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15849 #define vl_api_ip_fib_details_t_print vl_noop_handler
15852 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15854 vat_main_t *vam = &vat_main;
15855 int count = ntohl (mp->count);
15856 vl_api_fib_path_t *fp;
15860 "table-id %d, prefix %U/%d",
15861 ntohl (mp->table_id), format_ip4_address, mp->address,
15862 mp->address_length);
15864 for (i = 0; i < count; i++)
15866 if (fp->afi == IP46_TYPE_IP6)
15868 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15869 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15870 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15871 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15872 format_ip6_address, fp->next_hop);
15873 else if (fp->afi == IP46_TYPE_IP4)
15875 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15876 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15877 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15878 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15879 format_ip4_address, fp->next_hop);
15884 static void vl_api_ip_fib_details_t_handler_json
15885 (vl_api_ip_fib_details_t * mp)
15887 vat_main_t *vam = &vat_main;
15888 int count = ntohl (mp->count);
15889 vat_json_node_t *node = NULL;
15890 struct in_addr ip4;
15891 struct in6_addr ip6;
15892 vl_api_fib_path_t *fp;
15895 if (VAT_JSON_ARRAY != vam->json_tree.type)
15897 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15898 vat_json_init_array (&vam->json_tree);
15900 node = vat_json_array_add (&vam->json_tree);
15902 vat_json_init_object (node);
15903 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15904 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15905 vat_json_object_add_ip4 (node, "prefix", ip4);
15906 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15907 vat_json_object_add_uint (node, "path_count", count);
15909 for (i = 0; i < count; i++)
15911 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15912 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15913 vat_json_object_add_uint (node, "is_local", fp->is_local);
15914 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15915 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15916 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15917 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15918 if (fp->afi == IP46_TYPE_IP4)
15920 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15921 vat_json_object_add_ip4 (node, "next_hop", ip4);
15923 else if (fp->afi == IP46_TYPE_IP6)
15925 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15926 vat_json_object_add_ip6 (node, "next_hop", ip6);
15932 api_ip_fib_dump (vat_main_t * vam)
15934 vl_api_ip_fib_dump_t *mp;
15935 vl_api_control_ping_t *mp_ping;
15938 M (IP_FIB_DUMP, mp);
15941 /* Use a control ping for synchronization */
15942 M (CONTROL_PING, mp_ping);
15950 api_ip_mfib_dump (vat_main_t * vam)
15952 vl_api_ip_mfib_dump_t *mp;
15953 vl_api_control_ping_t *mp_ping;
15956 M (IP_MFIB_DUMP, mp);
15959 /* Use a control ping for synchronization */
15960 M (CONTROL_PING, mp_ping);
15967 static void vl_api_ip_neighbor_details_t_handler
15968 (vl_api_ip_neighbor_details_t * mp)
15970 vat_main_t *vam = &vat_main;
15972 print (vam->ofp, "%c %U %U",
15973 (mp->is_static) ? 'S' : 'D',
15974 format_ethernet_address, &mp->mac_address,
15975 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15979 static void vl_api_ip_neighbor_details_t_handler_json
15980 (vl_api_ip_neighbor_details_t * mp)
15983 vat_main_t *vam = &vat_main;
15984 vat_json_node_t *node;
15985 struct in_addr ip4;
15986 struct in6_addr ip6;
15988 if (VAT_JSON_ARRAY != vam->json_tree.type)
15990 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15991 vat_json_init_array (&vam->json_tree);
15993 node = vat_json_array_add (&vam->json_tree);
15995 vat_json_init_object (node);
15996 vat_json_object_add_string_copy (node, "flag",
15997 (mp->is_static) ? (u8 *) "static" : (u8 *)
16000 vat_json_object_add_string_copy (node, "link_layer",
16001 format (0, "%U", format_ethernet_address,
16002 &mp->mac_address));
16006 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
16007 vat_json_object_add_ip6 (node, "ip_address", ip6);
16011 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
16012 vat_json_object_add_ip4 (node, "ip_address", ip4);
16017 api_ip_neighbor_dump (vat_main_t * vam)
16019 unformat_input_t *i = vam->input;
16020 vl_api_ip_neighbor_dump_t *mp;
16021 vl_api_control_ping_t *mp_ping;
16023 u32 sw_if_index = ~0;
16026 /* Parse args required to build the message */
16027 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16029 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16031 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16033 else if (unformat (i, "ip6"))
16039 if (sw_if_index == ~0)
16041 errmsg ("missing interface name or sw_if_index");
16045 M (IP_NEIGHBOR_DUMP, mp);
16046 mp->is_ipv6 = (u8) is_ipv6;
16047 mp->sw_if_index = ntohl (sw_if_index);
16050 /* Use a control ping for synchronization */
16051 M (CONTROL_PING, mp_ping);
16058 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16059 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16062 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16064 vat_main_t *vam = &vat_main;
16065 int count = ntohl (mp->count);
16066 vl_api_fib_path_t *fp;
16070 "table-id %d, prefix %U/%d",
16071 ntohl (mp->table_id), format_ip6_address, mp->address,
16072 mp->address_length);
16074 for (i = 0; i < count; i++)
16076 if (fp->afi == IP46_TYPE_IP6)
16078 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16079 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16080 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16081 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16082 format_ip6_address, fp->next_hop);
16083 else if (fp->afi == IP46_TYPE_IP4)
16085 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16086 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16087 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16088 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16089 format_ip4_address, fp->next_hop);
16094 static void vl_api_ip6_fib_details_t_handler_json
16095 (vl_api_ip6_fib_details_t * mp)
16097 vat_main_t *vam = &vat_main;
16098 int count = ntohl (mp->count);
16099 vat_json_node_t *node = NULL;
16100 struct in_addr ip4;
16101 struct in6_addr ip6;
16102 vl_api_fib_path_t *fp;
16105 if (VAT_JSON_ARRAY != vam->json_tree.type)
16107 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16108 vat_json_init_array (&vam->json_tree);
16110 node = vat_json_array_add (&vam->json_tree);
16112 vat_json_init_object (node);
16113 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16114 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16115 vat_json_object_add_ip6 (node, "prefix", ip6);
16116 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16117 vat_json_object_add_uint (node, "path_count", count);
16119 for (i = 0; i < count; i++)
16121 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16122 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16123 vat_json_object_add_uint (node, "is_local", fp->is_local);
16124 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16125 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16126 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16127 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16128 if (fp->afi == IP46_TYPE_IP4)
16130 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16131 vat_json_object_add_ip4 (node, "next_hop", ip4);
16133 else if (fp->afi == IP46_TYPE_IP6)
16135 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16136 vat_json_object_add_ip6 (node, "next_hop", ip6);
16142 api_ip6_fib_dump (vat_main_t * vam)
16144 vl_api_ip6_fib_dump_t *mp;
16145 vl_api_control_ping_t *mp_ping;
16148 M (IP6_FIB_DUMP, mp);
16151 /* Use a control ping for synchronization */
16152 M (CONTROL_PING, mp_ping);
16160 api_ip6_mfib_dump (vat_main_t * vam)
16162 vl_api_ip6_mfib_dump_t *mp;
16163 vl_api_control_ping_t *mp_ping;
16166 M (IP6_MFIB_DUMP, mp);
16169 /* Use a control ping for synchronization */
16170 M (CONTROL_PING, mp_ping);
16178 api_classify_table_ids (vat_main_t * vam)
16180 vl_api_classify_table_ids_t *mp;
16183 /* Construct the API message */
16184 M (CLASSIFY_TABLE_IDS, mp);
16193 api_classify_table_by_interface (vat_main_t * vam)
16195 unformat_input_t *input = vam->input;
16196 vl_api_classify_table_by_interface_t *mp;
16198 u32 sw_if_index = ~0;
16200 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16202 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16204 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16209 if (sw_if_index == ~0)
16211 errmsg ("missing interface name or sw_if_index");
16215 /* Construct the API message */
16216 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16218 mp->sw_if_index = ntohl (sw_if_index);
16226 api_classify_table_info (vat_main_t * vam)
16228 unformat_input_t *input = vam->input;
16229 vl_api_classify_table_info_t *mp;
16233 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16235 if (unformat (input, "table_id %d", &table_id))
16240 if (table_id == ~0)
16242 errmsg ("missing table id");
16246 /* Construct the API message */
16247 M (CLASSIFY_TABLE_INFO, mp);
16249 mp->table_id = ntohl (table_id);
16257 api_classify_session_dump (vat_main_t * vam)
16259 unformat_input_t *input = vam->input;
16260 vl_api_classify_session_dump_t *mp;
16261 vl_api_control_ping_t *mp_ping;
16265 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16267 if (unformat (input, "table_id %d", &table_id))
16272 if (table_id == ~0)
16274 errmsg ("missing table id");
16278 /* Construct the API message */
16279 M (CLASSIFY_SESSION_DUMP, mp);
16281 mp->table_id = ntohl (table_id);
16284 /* Use a control ping for synchronization */
16285 M (CONTROL_PING, mp_ping);
16293 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16295 vat_main_t *vam = &vat_main;
16297 print (vam->ofp, "collector_address %U, collector_port %d, "
16298 "src_address %U, vrf_id %d, path_mtu %u, "
16299 "template_interval %u, udp_checksum %d",
16300 format_ip4_address, mp->collector_address,
16301 ntohs (mp->collector_port),
16302 format_ip4_address, mp->src_address,
16303 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16304 ntohl (mp->template_interval), mp->udp_checksum);
16307 vam->result_ready = 1;
16311 vl_api_ipfix_exporter_details_t_handler_json
16312 (vl_api_ipfix_exporter_details_t * mp)
16314 vat_main_t *vam = &vat_main;
16315 vat_json_node_t node;
16316 struct in_addr collector_address;
16317 struct in_addr src_address;
16319 vat_json_init_object (&node);
16320 clib_memcpy (&collector_address, &mp->collector_address,
16321 sizeof (collector_address));
16322 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16323 vat_json_object_add_uint (&node, "collector_port",
16324 ntohs (mp->collector_port));
16325 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16326 vat_json_object_add_ip4 (&node, "src_address", src_address);
16327 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16328 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16329 vat_json_object_add_uint (&node, "template_interval",
16330 ntohl (mp->template_interval));
16331 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16333 vat_json_print (vam->ofp, &node);
16334 vat_json_free (&node);
16336 vam->result_ready = 1;
16340 api_ipfix_exporter_dump (vat_main_t * vam)
16342 vl_api_ipfix_exporter_dump_t *mp;
16345 /* Construct the API message */
16346 M (IPFIX_EXPORTER_DUMP, mp);
16355 api_ipfix_classify_stream_dump (vat_main_t * vam)
16357 vl_api_ipfix_classify_stream_dump_t *mp;
16360 /* Construct the API message */
16361 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16372 vl_api_ipfix_classify_stream_details_t_handler
16373 (vl_api_ipfix_classify_stream_details_t * mp)
16375 vat_main_t *vam = &vat_main;
16376 print (vam->ofp, "domain_id %d, src_port %d",
16377 ntohl (mp->domain_id), ntohs (mp->src_port));
16379 vam->result_ready = 1;
16383 vl_api_ipfix_classify_stream_details_t_handler_json
16384 (vl_api_ipfix_classify_stream_details_t * mp)
16386 vat_main_t *vam = &vat_main;
16387 vat_json_node_t node;
16389 vat_json_init_object (&node);
16390 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16391 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16393 vat_json_print (vam->ofp, &node);
16394 vat_json_free (&node);
16396 vam->result_ready = 1;
16400 api_ipfix_classify_table_dump (vat_main_t * vam)
16402 vl_api_ipfix_classify_table_dump_t *mp;
16403 vl_api_control_ping_t *mp_ping;
16406 if (!vam->json_output)
16408 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16409 "transport_protocol");
16412 /* Construct the API message */
16413 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16418 /* Use a control ping for synchronization */
16419 M (CONTROL_PING, mp_ping);
16427 vl_api_ipfix_classify_table_details_t_handler
16428 (vl_api_ipfix_classify_table_details_t * mp)
16430 vat_main_t *vam = &vat_main;
16431 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16432 mp->transport_protocol);
16436 vl_api_ipfix_classify_table_details_t_handler_json
16437 (vl_api_ipfix_classify_table_details_t * mp)
16439 vat_json_node_t *node = NULL;
16440 vat_main_t *vam = &vat_main;
16442 if (VAT_JSON_ARRAY != vam->json_tree.type)
16444 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16445 vat_json_init_array (&vam->json_tree);
16448 node = vat_json_array_add (&vam->json_tree);
16449 vat_json_init_object (node);
16451 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16452 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16453 vat_json_object_add_uint (node, "transport_protocol",
16454 mp->transport_protocol);
16458 api_sw_interface_span_enable_disable (vat_main_t * vam)
16460 unformat_input_t *i = vam->input;
16461 vl_api_sw_interface_span_enable_disable_t *mp;
16462 u32 src_sw_if_index = ~0;
16463 u32 dst_sw_if_index = ~0;
16467 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16470 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16472 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16476 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16478 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16480 else if (unformat (i, "disable"))
16482 else if (unformat (i, "rx"))
16484 else if (unformat (i, "tx"))
16486 else if (unformat (i, "both"))
16492 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16494 mp->sw_if_index_from = htonl (src_sw_if_index);
16495 mp->sw_if_index_to = htonl (dst_sw_if_index);
16504 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16507 vat_main_t *vam = &vat_main;
16508 u8 *sw_if_from_name = 0;
16509 u8 *sw_if_to_name = 0;
16510 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16511 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16512 char *states[] = { "none", "rx", "tx", "both" };
16516 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16518 if ((u32) p->value[0] == sw_if_index_from)
16520 sw_if_from_name = (u8 *)(p->key);
16524 if ((u32) p->value[0] == sw_if_index_to)
16526 sw_if_to_name = (u8 *)(p->key);
16527 if (sw_if_from_name)
16532 print (vam->ofp, "%20s => %20s (%s)",
16533 sw_if_from_name, sw_if_to_name, states[mp->state]);
16537 vl_api_sw_interface_span_details_t_handler_json
16538 (vl_api_sw_interface_span_details_t * mp)
16540 vat_main_t *vam = &vat_main;
16541 vat_json_node_t *node = NULL;
16542 u8 *sw_if_from_name = 0;
16543 u8 *sw_if_to_name = 0;
16544 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16545 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16549 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16551 if ((u32) p->value[0] == sw_if_index_from)
16553 sw_if_from_name = (u8 *)(p->key);
16557 if ((u32) p->value[0] == sw_if_index_to)
16559 sw_if_to_name = (u8 *)(p->key);
16560 if (sw_if_from_name)
16566 if (VAT_JSON_ARRAY != vam->json_tree.type)
16568 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16569 vat_json_init_array (&vam->json_tree);
16571 node = vat_json_array_add (&vam->json_tree);
16573 vat_json_init_object (node);
16574 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16575 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16576 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16577 if (0 != sw_if_to_name)
16579 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16581 vat_json_object_add_uint (node, "state", mp->state);
16585 api_sw_interface_span_dump (vat_main_t * vam)
16587 vl_api_sw_interface_span_dump_t *mp;
16588 vl_api_control_ping_t *mp_ping;
16591 M (SW_INTERFACE_SPAN_DUMP, mp);
16594 /* Use a control ping for synchronization */
16595 M (CONTROL_PING, mp_ping);
16603 api_pg_create_interface (vat_main_t * vam)
16605 unformat_input_t *input = vam->input;
16606 vl_api_pg_create_interface_t *mp;
16610 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16612 if (unformat (input, "if_id %d", &if_id))
16619 errmsg ("missing pg interface index");
16623 /* Construct the API message */
16624 M (PG_CREATE_INTERFACE, mp);
16626 mp->interface_id = ntohl (if_id);
16634 api_pg_capture (vat_main_t * vam)
16636 unformat_input_t *input = vam->input;
16637 vl_api_pg_capture_t *mp;
16642 u8 pcap_file_set = 0;
16645 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16647 if (unformat (input, "if_id %d", &if_id))
16649 else if (unformat (input, "pcap %s", &pcap_file))
16651 else if (unformat (input, "count %d", &count))
16653 else if (unformat (input, "disable"))
16660 errmsg ("missing pg interface index");
16663 if (pcap_file_set > 0)
16665 if (vec_len (pcap_file) > 255)
16667 errmsg ("pcap file name is too long");
16672 u32 name_len = vec_len (pcap_file);
16673 /* Construct the API message */
16674 M (PG_CAPTURE, mp);
16676 mp->interface_id = ntohl (if_id);
16677 mp->is_enabled = enable;
16678 mp->count = ntohl (count);
16679 mp->pcap_name_length = ntohl (name_len);
16680 if (pcap_file_set != 0)
16682 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16684 vec_free (pcap_file);
16692 api_pg_enable_disable (vat_main_t * vam)
16694 unformat_input_t *input = vam->input;
16695 vl_api_pg_enable_disable_t *mp;
16698 u8 stream_name_set = 0;
16699 u8 *stream_name = 0;
16701 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16703 if (unformat (input, "stream %s", &stream_name))
16704 stream_name_set = 1;
16705 else if (unformat (input, "disable"))
16711 if (stream_name_set > 0)
16713 if (vec_len (stream_name) > 255)
16715 errmsg ("stream name too long");
16720 u32 name_len = vec_len (stream_name);
16721 /* Construct the API message */
16722 M (PG_ENABLE_DISABLE, mp);
16724 mp->is_enabled = enable;
16725 if (stream_name_set != 0)
16727 mp->stream_name_length = ntohl (name_len);
16728 clib_memcpy (mp->stream_name, stream_name, name_len);
16730 vec_free (stream_name);
16738 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16740 unformat_input_t *input = vam->input;
16741 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16743 u16 *low_ports = 0;
16744 u16 *high_ports = 0;
16747 ip4_address_t ip4_addr;
16748 ip6_address_t ip6_addr;
16757 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16759 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16765 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16770 else if (unformat (input, "vrf %d", &vrf_id))
16772 else if (unformat (input, "del"))
16774 else if (unformat (input, "port %d", &tmp))
16776 if (tmp == 0 || tmp > 65535)
16778 errmsg ("port %d out of range", tmp);
16782 this_hi = this_low + 1;
16783 vec_add1 (low_ports, this_low);
16784 vec_add1 (high_ports, this_hi);
16786 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16788 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16790 errmsg ("incorrect range parameters");
16794 /* Note: in debug CLI +1 is added to high before
16795 passing to real fn that does "the work"
16796 (ip_source_and_port_range_check_add_del).
16797 This fn is a wrapper around the binary API fn a
16798 control plane will call, which expects this increment
16799 to have occurred. Hence letting the binary API control
16800 plane fn do the increment for consistency between VAT
16801 and other control planes.
16804 vec_add1 (low_ports, this_low);
16805 vec_add1 (high_ports, this_hi);
16811 if (prefix_set == 0)
16813 errmsg ("<address>/<mask> not specified");
16819 errmsg ("VRF ID required, not specified");
16826 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16830 if (vec_len (low_ports) == 0)
16832 errmsg ("At least one port or port range required");
16836 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16838 mp->is_add = is_add;
16843 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16848 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16851 mp->mask_length = length;
16852 mp->number_of_ranges = vec_len (low_ports);
16854 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16855 vec_free (low_ports);
16857 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16858 vec_free (high_ports);
16860 mp->vrf_id = ntohl (vrf_id);
16868 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16870 unformat_input_t *input = vam->input;
16871 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16872 u32 sw_if_index = ~0;
16874 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16875 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16879 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16881 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16883 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16885 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16887 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16889 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16891 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16893 else if (unformat (input, "del"))
16899 if (sw_if_index == ~0)
16901 errmsg ("Interface required but not specified");
16907 errmsg ("VRF ID required but not specified");
16911 if (tcp_out_vrf_id == 0
16912 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16915 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16919 /* Construct the API message */
16920 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
16922 mp->sw_if_index = ntohl (sw_if_index);
16923 mp->is_add = is_add;
16924 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16925 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16926 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16927 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16932 /* Wait for a reply... */
16938 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16940 unformat_input_t *i = vam->input;
16941 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16942 u32 local_sa_id = 0;
16943 u32 remote_sa_id = 0;
16944 ip4_address_t src_address;
16945 ip4_address_t dst_address;
16949 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16951 if (unformat (i, "local_sa %d", &local_sa_id))
16953 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16955 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16957 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16959 else if (unformat (i, "del"))
16963 clib_warning ("parse error '%U'", format_unformat_error, i);
16968 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
16970 mp->local_sa_id = ntohl (local_sa_id);
16971 mp->remote_sa_id = ntohl (remote_sa_id);
16972 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16973 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16974 mp->is_add = is_add;
16982 api_punt (vat_main_t * vam)
16984 unformat_input_t *i = vam->input;
16992 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16994 if (unformat (i, "ip %d", &ipv))
16996 else if (unformat (i, "protocol %d", &protocol))
16998 else if (unformat (i, "port %d", &port))
17000 else if (unformat (i, "del"))
17004 clib_warning ("parse error '%U'", format_unformat_error, i);
17011 mp->is_add = (u8) is_add;
17012 mp->ipv = (u8) ipv;
17013 mp->l4_protocol = (u8) protocol;
17014 mp->l4_port = htons ((u16) port);
17021 static void vl_api_ipsec_gre_tunnel_details_t_handler
17022 (vl_api_ipsec_gre_tunnel_details_t * mp)
17024 vat_main_t *vam = &vat_main;
17026 print (vam->ofp, "%11d%15U%15U%14d%14d",
17027 ntohl (mp->sw_if_index),
17028 format_ip4_address, &mp->src_address,
17029 format_ip4_address, &mp->dst_address,
17030 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17033 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17034 (vl_api_ipsec_gre_tunnel_details_t * mp)
17036 vat_main_t *vam = &vat_main;
17037 vat_json_node_t *node = NULL;
17038 struct in_addr ip4;
17040 if (VAT_JSON_ARRAY != vam->json_tree.type)
17042 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17043 vat_json_init_array (&vam->json_tree);
17045 node = vat_json_array_add (&vam->json_tree);
17047 vat_json_init_object (node);
17048 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17049 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17050 vat_json_object_add_ip4 (node, "src_address", ip4);
17051 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17052 vat_json_object_add_ip4 (node, "dst_address", ip4);
17053 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17054 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17058 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17060 unformat_input_t *i = vam->input;
17061 vl_api_ipsec_gre_tunnel_dump_t *mp;
17062 vl_api_control_ping_t *mp_ping;
17064 u8 sw_if_index_set = 0;
17067 /* Parse args required to build the message */
17068 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17070 if (unformat (i, "sw_if_index %d", &sw_if_index))
17071 sw_if_index_set = 1;
17076 if (sw_if_index_set == 0)
17081 if (!vam->json_output)
17083 print (vam->ofp, "%11s%15s%15s%14s%14s",
17084 "sw_if_index", "src_address", "dst_address",
17085 "local_sa_id", "remote_sa_id");
17088 /* Get list of gre-tunnel interfaces */
17089 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17091 mp->sw_if_index = htonl (sw_if_index);
17095 /* Use a control ping for synchronization */
17096 M (CONTROL_PING, mp_ping);
17104 api_delete_subif (vat_main_t * vam)
17106 unformat_input_t *i = vam->input;
17107 vl_api_delete_subif_t *mp;
17108 u32 sw_if_index = ~0;
17111 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17113 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17115 if (unformat (i, "sw_if_index %d", &sw_if_index))
17121 if (sw_if_index == ~0)
17123 errmsg ("missing sw_if_index");
17127 /* Construct the API message */
17128 M (DELETE_SUBIF, mp);
17129 mp->sw_if_index = ntohl (sw_if_index);
17136 #define foreach_pbb_vtr_op \
17137 _("disable", L2_VTR_DISABLED) \
17138 _("pop", L2_VTR_POP_2) \
17139 _("push", L2_VTR_PUSH_2)
17142 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17144 unformat_input_t *i = vam->input;
17145 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17146 u32 sw_if_index = ~0, vtr_op = ~0;
17147 u16 outer_tag = ~0;
17148 u8 dmac[6], smac[6];
17149 u8 dmac_set = 0, smac_set = 0;
17155 /* Shut up coverity */
17156 memset (dmac, 0, sizeof (dmac));
17157 memset (smac, 0, sizeof (smac));
17159 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17161 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17163 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17165 else if (unformat (i, "vtr_op %d", &vtr_op))
17167 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17170 else if (unformat (i, "translate_pbb_stag"))
17172 if (unformat (i, "%d", &tmp))
17174 vtr_op = L2_VTR_TRANSLATE_2_1;
17180 ("translate_pbb_stag operation requires outer tag definition");
17184 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17186 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17188 else if (unformat (i, "sid %d", &sid))
17190 else if (unformat (i, "vlanid %d", &tmp))
17194 clib_warning ("parse error '%U'", format_unformat_error, i);
17199 if ((sw_if_index == ~0) || (vtr_op == ~0))
17201 errmsg ("missing sw_if_index or vtr operation");
17204 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17205 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17208 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17212 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17213 mp->sw_if_index = ntohl (sw_if_index);
17214 mp->vtr_op = ntohl (vtr_op);
17215 mp->outer_tag = ntohs (outer_tag);
17216 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17217 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17218 mp->b_vlanid = ntohs (vlanid);
17219 mp->i_sid = ntohl (sid);
17227 api_flow_classify_set_interface (vat_main_t * vam)
17229 unformat_input_t *i = vam->input;
17230 vl_api_flow_classify_set_interface_t *mp;
17232 int sw_if_index_set;
17233 u32 ip4_table_index = ~0;
17234 u32 ip6_table_index = ~0;
17238 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17240 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17241 sw_if_index_set = 1;
17242 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17243 sw_if_index_set = 1;
17244 else if (unformat (i, "del"))
17246 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17248 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17252 clib_warning ("parse error '%U'", format_unformat_error, i);
17257 if (sw_if_index_set == 0)
17259 errmsg ("missing interface name or sw_if_index");
17263 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17265 mp->sw_if_index = ntohl (sw_if_index);
17266 mp->ip4_table_index = ntohl (ip4_table_index);
17267 mp->ip6_table_index = ntohl (ip6_table_index);
17268 mp->is_add = is_add;
17276 api_flow_classify_dump (vat_main_t * vam)
17278 unformat_input_t *i = vam->input;
17279 vl_api_flow_classify_dump_t *mp;
17280 vl_api_control_ping_t *mp_ping;
17281 u8 type = FLOW_CLASSIFY_N_TABLES;
17284 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17288 errmsg ("classify table type must be specified");
17292 if (!vam->json_output)
17294 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17297 M (FLOW_CLASSIFY_DUMP, mp);
17302 /* Use a control ping for synchronization */
17303 M (CONTROL_PING, mp_ping);
17306 /* Wait for a reply... */
17312 api_feature_enable_disable (vat_main_t * vam)
17314 unformat_input_t *i = vam->input;
17315 vl_api_feature_enable_disable_t *mp;
17317 u8 *feature_name = 0;
17318 u32 sw_if_index = ~0;
17322 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17324 if (unformat (i, "arc_name %s", &arc_name))
17326 else if (unformat (i, "feature_name %s", &feature_name))
17329 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17331 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17333 else if (unformat (i, "disable"))
17341 errmsg ("missing arc name");
17344 if (vec_len (arc_name) > 63)
17346 errmsg ("arc name too long");
17349 if (feature_name == 0)
17351 errmsg ("missing feature name");
17354 if (vec_len (feature_name) > 63)
17356 errmsg ("feature name too long");
17359 if (sw_if_index == ~0)
17361 errmsg ("missing interface name or sw_if_index");
17365 /* Construct the API message */
17366 M (FEATURE_ENABLE_DISABLE, mp);
17367 mp->sw_if_index = ntohl (sw_if_index);
17368 mp->enable = enable;
17369 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17370 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17371 vec_free (arc_name);
17372 vec_free (feature_name);
17380 api_sw_interface_tag_add_del (vat_main_t * vam)
17382 unformat_input_t *i = vam->input;
17383 vl_api_sw_interface_tag_add_del_t *mp;
17384 u32 sw_if_index = ~0;
17389 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17391 if (unformat (i, "tag %s", &tag))
17393 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17395 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17397 else if (unformat (i, "del"))
17403 if (sw_if_index == ~0)
17405 errmsg ("missing interface name or sw_if_index");
17409 if (enable && (tag == 0))
17411 errmsg ("no tag specified");
17415 /* Construct the API message */
17416 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17417 mp->sw_if_index = ntohl (sw_if_index);
17418 mp->is_add = enable;
17420 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17428 static void vl_api_l2_xconnect_details_t_handler
17429 (vl_api_l2_xconnect_details_t * mp)
17431 vat_main_t *vam = &vat_main;
17433 print (vam->ofp, "%15d%15d",
17434 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17437 static void vl_api_l2_xconnect_details_t_handler_json
17438 (vl_api_l2_xconnect_details_t * mp)
17440 vat_main_t *vam = &vat_main;
17441 vat_json_node_t *node = NULL;
17443 if (VAT_JSON_ARRAY != vam->json_tree.type)
17445 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17446 vat_json_init_array (&vam->json_tree);
17448 node = vat_json_array_add (&vam->json_tree);
17450 vat_json_init_object (node);
17451 vat_json_object_add_uint (node, "rx_sw_if_index",
17452 ntohl (mp->rx_sw_if_index));
17453 vat_json_object_add_uint (node, "tx_sw_if_index",
17454 ntohl (mp->tx_sw_if_index));
17458 api_l2_xconnect_dump (vat_main_t * vam)
17460 vl_api_l2_xconnect_dump_t *mp;
17461 vl_api_control_ping_t *mp_ping;
17464 if (!vam->json_output)
17466 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17469 M (L2_XCONNECT_DUMP, mp);
17473 /* Use a control ping for synchronization */
17474 M (CONTROL_PING, mp_ping);
17482 api_sw_interface_set_mtu (vat_main_t * vam)
17484 unformat_input_t *i = vam->input;
17485 vl_api_sw_interface_set_mtu_t *mp;
17486 u32 sw_if_index = ~0;
17490 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17492 if (unformat (i, "mtu %d", &mtu))
17494 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17496 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17502 if (sw_if_index == ~0)
17504 errmsg ("missing interface name or sw_if_index");
17510 errmsg ("no mtu specified");
17514 /* Construct the API message */
17515 M (SW_INTERFACE_SET_MTU, mp);
17516 mp->sw_if_index = ntohl (sw_if_index);
17517 mp->mtu = ntohs ((u16) mtu);
17526 q_or_quit (vat_main_t * vam)
17528 #if VPP_API_TEST_BUILTIN == 0
17529 longjmp (vam->jump_buf, 1);
17531 return 0; /* not so much */
17535 q (vat_main_t * vam)
17537 return q_or_quit (vam);
17541 quit (vat_main_t * vam)
17543 return q_or_quit (vam);
17547 comment (vat_main_t * vam)
17553 cmd_cmp (void *a1, void *a2)
17558 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17562 help (vat_main_t * vam)
17567 unformat_input_t *i = vam->input;
17570 if (unformat (i, "%s", &name))
17574 vec_add1 (name, 0);
17576 hs = hash_get_mem (vam->help_by_name, name);
17578 print (vam->ofp, "usage: %s %s", name, hs[0]);
17580 print (vam->ofp, "No such msg / command '%s'", name);
17585 print (vam->ofp, "Help is available for the following:");
17588 hash_foreach_pair (p, vam->function_by_name,
17590 vec_add1 (cmds, (u8 *)(p->key));
17594 vec_sort_with_function (cmds, cmd_cmp);
17596 for (j = 0; j < vec_len (cmds); j++)
17597 print (vam->ofp, "%s", cmds[j]);
17604 set (vat_main_t * vam)
17606 u8 *name = 0, *value = 0;
17607 unformat_input_t *i = vam->input;
17609 if (unformat (i, "%s", &name))
17611 /* The input buffer is a vector, not a string. */
17612 value = vec_dup (i->buffer);
17613 vec_delete (value, i->index, 0);
17614 /* Almost certainly has a trailing newline */
17615 if (value[vec_len (value) - 1] == '\n')
17616 value[vec_len (value) - 1] = 0;
17617 /* Make sure it's a proper string, one way or the other */
17618 vec_add1 (value, 0);
17619 (void) clib_macro_set_value (&vam->macro_main,
17620 (char *) name, (char *) value);
17623 errmsg ("usage: set <name> <value>");
17631 unset (vat_main_t * vam)
17635 if (unformat (vam->input, "%s", &name))
17636 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17637 errmsg ("unset: %s wasn't set", name);
17650 macro_sort_cmp (void *a1, void *a2)
17652 macro_sort_t *s1 = a1;
17653 macro_sort_t *s2 = a2;
17655 return strcmp ((char *) (s1->name), (char *) (s2->name));
17659 dump_macro_table (vat_main_t * vam)
17661 macro_sort_t *sort_me = 0, *sm;
17666 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17668 vec_add2 (sort_me, sm, 1);
17669 sm->name = (u8 *)(p->key);
17670 sm->value = (u8 *) (p->value[0]);
17674 vec_sort_with_function (sort_me, macro_sort_cmp);
17676 if (vec_len (sort_me))
17677 print (vam->ofp, "%-15s%s", "Name", "Value");
17679 print (vam->ofp, "The macro table is empty...");
17681 for (i = 0; i < vec_len (sort_me); i++)
17682 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17687 dump_node_table (vat_main_t * vam)
17690 vlib_node_t *node, *next_node;
17692 if (vec_len (vam->graph_nodes) == 0)
17694 print (vam->ofp, "Node table empty, issue get_node_graph...");
17698 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17700 node = vam->graph_nodes[i];
17701 print (vam->ofp, "[%d] %s", i, node->name);
17702 for (j = 0; j < vec_len (node->next_nodes); j++)
17704 if (node->next_nodes[j] != ~0)
17706 next_node = vam->graph_nodes[node->next_nodes[j]];
17707 print (vam->ofp, " [%d] %s", j, next_node->name);
17715 value_sort_cmp (void *a1, void *a2)
17717 name_sort_t *n1 = a1;
17718 name_sort_t *n2 = a2;
17720 if (n1->value < n2->value)
17722 if (n1->value > n2->value)
17729 dump_msg_api_table (vat_main_t * vam)
17731 api_main_t *am = &api_main;
17732 name_sort_t *nses = 0, *ns;
17737 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17739 vec_add2 (nses, ns, 1);
17740 ns->name = (u8 *)(hp->key);
17741 ns->value = (u32) hp->value[0];
17745 vec_sort_with_function (nses, value_sort_cmp);
17747 for (i = 0; i < vec_len (nses); i++)
17748 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17754 get_msg_id (vat_main_t * vam)
17759 if (unformat (vam->input, "%s", &name_and_crc))
17761 message_index = vl_api_get_msg_index (name_and_crc);
17762 if (message_index == ~0)
17764 print (vam->ofp, " '%s' not found", name_and_crc);
17767 print (vam->ofp, " '%s' has message index %d",
17768 name_and_crc, message_index);
17771 errmsg ("name_and_crc required...");
17776 search_node_table (vat_main_t * vam)
17778 unformat_input_t *line_input = vam->input;
17781 vlib_node_t *node, *next_node;
17784 if (vam->graph_node_index_by_name == 0)
17786 print (vam->ofp, "Node table empty, issue get_node_graph...");
17790 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17792 if (unformat (line_input, "%s", &node_to_find))
17794 vec_add1 (node_to_find, 0);
17795 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17798 print (vam->ofp, "%s not found...", node_to_find);
17801 node = vam->graph_nodes[p[0]];
17802 print (vam->ofp, "[%d] %s", p[0], node->name);
17803 for (j = 0; j < vec_len (node->next_nodes); j++)
17805 if (node->next_nodes[j] != ~0)
17807 next_node = vam->graph_nodes[node->next_nodes[j]];
17808 print (vam->ofp, " [%d] %s", j, next_node->name);
17815 clib_warning ("parse error '%U'", format_unformat_error,
17821 vec_free (node_to_find);
17830 script (vat_main_t * vam)
17832 #if (VPP_API_TEST_BUILTIN==0)
17834 char *save_current_file;
17835 unformat_input_t save_input;
17836 jmp_buf save_jump_buf;
17837 u32 save_line_number;
17839 FILE *new_fp, *save_ifp;
17841 if (unformat (vam->input, "%s", &s))
17843 new_fp = fopen ((char *) s, "r");
17846 errmsg ("Couldn't open script file %s", s);
17853 errmsg ("Missing script name");
17857 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17858 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17859 save_ifp = vam->ifp;
17860 save_line_number = vam->input_line_number;
17861 save_current_file = (char *) vam->current_file;
17863 vam->input_line_number = 0;
17865 vam->current_file = s;
17868 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17869 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17870 vam->ifp = save_ifp;
17871 vam->input_line_number = save_line_number;
17872 vam->current_file = (u8 *) save_current_file;
17877 clib_warning ("use the exec command...");
17883 echo (vat_main_t * vam)
17885 print (vam->ofp, "%v", vam->input->buffer);
17889 /* List of API message constructors, CLI names map to api_xxx */
17890 #define foreach_vpe_api_msg \
17891 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
17892 _(sw_interface_dump,"") \
17893 _(sw_interface_set_flags, \
17894 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17895 _(sw_interface_add_del_address, \
17896 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17897 _(sw_interface_set_table, \
17898 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17899 _(sw_interface_set_mpls_enable, \
17900 "<intfc> | sw_if_index [disable | dis]") \
17901 _(sw_interface_set_vpath, \
17902 "<intfc> | sw_if_index <id> enable | disable") \
17903 _(sw_interface_set_vxlan_bypass, \
17904 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
17905 _(sw_interface_set_l2_xconnect, \
17906 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17907 "enable | disable") \
17908 _(sw_interface_set_l2_bridge, \
17909 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17910 "[shg <split-horizon-group>] [bvi]\n" \
17911 "enable | disable") \
17912 _(bridge_domain_add_del, \
17913 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17914 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17916 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17918 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17920 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17922 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17924 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17926 "<vpp-if-name> | sw_if_index <id>") \
17927 _(sw_interface_tap_dump, "") \
17928 _(ip_add_del_route, \
17929 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17930 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17931 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17932 "[multipath] [count <n>]") \
17933 _(ip_mroute_add_del, \
17934 "<src> <grp>/<mask> [table-id <n>]\n" \
17935 "[<intfc> | sw_if_index <id>] [local] [del]") \
17936 _(mpls_route_add_del, \
17937 "<label> <eos> via <addr> [table-id <n>]\n" \
17938 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17939 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17940 "[multipath] [count <n>]") \
17941 _(mpls_ip_bind_unbind, \
17942 "<label> <addr/len>") \
17943 _(mpls_tunnel_add_del, \
17944 " via <addr> [table-id <n>]\n" \
17945 "sw_if_index <id>] [l2] [del]") \
17946 _(proxy_arp_add_del, \
17947 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17948 _(proxy_arp_intfc_enable_disable, \
17949 "<intfc> | sw_if_index <id> enable | disable") \
17950 _(sw_interface_set_unnumbered, \
17951 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17952 _(ip_neighbor_add_del, \
17953 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17954 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17955 _(reset_vrf, "vrf <id> [ipv6]") \
17956 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17957 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17958 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17959 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17960 "[outer_vlan_id_any][inner_vlan_id_any]") \
17961 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17962 _(reset_fib, "vrf <n> [ipv6]") \
17963 _(dhcp_proxy_config, \
17964 "svr <v46-address> src <v46-address>\n" \
17965 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
17966 _(dhcp_proxy_set_vss, \
17967 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17968 _(dhcp_proxy_dump, "ip6") \
17969 _(dhcp_client_config, \
17970 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17971 _(set_ip_flow_hash, \
17972 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17973 _(sw_interface_ip6_enable_disable, \
17974 "<intfc> | sw_if_index <id> enable | disable") \
17975 _(sw_interface_ip6_set_link_local_address, \
17976 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17977 _(sw_interface_ip6nd_ra_prefix, \
17978 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17979 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17980 "[nolink] [isno]") \
17981 _(sw_interface_ip6nd_ra_config, \
17982 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17983 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17984 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17985 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17986 _(l2_patch_add_del, \
17987 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17988 "enable | disable") \
17989 _(sr_localsid_add_del, \
17990 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
17991 "fib-table <num> (end.psp) sw_if_index <num>") \
17992 _(classify_add_del_table, \
17993 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17994 " [del] [del-chain] mask <mask-value>\n" \
17995 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17996 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17997 _(classify_add_del_session, \
17998 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17999 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
18000 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
18001 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
18002 _(classify_set_interface_ip_table, \
18003 "<intfc> | sw_if_index <nn> table <nn>") \
18004 _(classify_set_interface_l2_tables, \
18005 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18006 " [other-table <nn>]") \
18007 _(get_node_index, "node <node-name") \
18008 _(add_node_next, "node <node-name> next <next-node-name>") \
18009 _(l2tpv3_create_tunnel, \
18010 "client_address <ip6-addr> our_address <ip6-addr>\n" \
18011 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
18012 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
18013 _(l2tpv3_set_tunnel_cookies, \
18014 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
18015 "[new_remote_cookie <nn>]\n") \
18016 _(l2tpv3_interface_enable_disable, \
18017 "<intfc> | sw_if_index <nn> enable | disable") \
18018 _(l2tpv3_set_lookup_key, \
18019 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
18020 _(sw_if_l2tpv3_tunnel_dump, "") \
18021 _(vxlan_add_del_tunnel, \
18022 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
18023 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
18024 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
18025 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18026 _(gre_add_del_tunnel, \
18027 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
18028 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18029 _(l2_fib_clear_table, "") \
18030 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18031 _(l2_interface_vlan_tag_rewrite, \
18032 "<intfc> | sw_if_index <nn> \n" \
18033 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18034 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18035 _(create_vhost_user_if, \
18036 "socket <filename> [server] [renumber <dev_instance>] " \
18037 "[mac <mac_address>]") \
18038 _(modify_vhost_user_if, \
18039 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18040 "[server] [renumber <dev_instance>]") \
18041 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18042 _(sw_interface_vhost_user_dump, "") \
18043 _(show_version, "") \
18044 _(vxlan_gpe_add_del_tunnel, \
18045 "local <addr> remote <addr> vni <nn>\n" \
18046 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18047 "[next-ethernet] [next-nsh]\n") \
18048 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18049 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18050 _(interface_name_renumber, \
18051 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18052 _(input_acl_set_interface, \
18053 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18054 " [l2-table <nn>] [del]") \
18055 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18056 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18057 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18058 _(ip_dump, "ipv4 | ipv6") \
18059 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18060 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18062 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18063 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18064 " integ_alg <alg> integ_key <hex>") \
18065 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18066 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18067 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18068 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18069 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18070 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18071 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18072 "(auth_data 0x<data> | auth_data <data>)") \
18073 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18074 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18075 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18076 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18077 "(local|remote)") \
18078 _(ikev2_set_local_key, "file <absolute_file_path>") \
18079 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18080 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18081 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18082 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18083 _(ikev2_initiate_sa_init, "<profile_name>") \
18084 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18085 _(ikev2_initiate_del_child_sa, "<ispi>") \
18086 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18087 _(delete_loopback,"sw_if_index <nn>") \
18088 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18089 _(map_add_domain, \
18090 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18091 "ip6-src <ip6addr> " \
18092 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18093 _(map_del_domain, "index <n>") \
18094 _(map_add_del_rule, \
18095 "index <n> psid <n> dst <ip6addr> [del]") \
18096 _(map_domain_dump, "") \
18097 _(map_rule_dump, "index <map-domain>") \
18098 _(want_interface_events, "enable|disable") \
18099 _(want_stats,"enable|disable") \
18100 _(get_first_msg_id, "client <name>") \
18101 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18102 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18103 "fib-id <nn> [ip4][ip6][default]") \
18104 _(get_node_graph, " ") \
18105 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18106 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18107 _(ioam_disable, "") \
18108 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18109 " sw_if_index <sw_if_index> p <priority> " \
18110 "w <weight>] [del]") \
18111 _(one_add_del_locator, "locator-set <locator_name> " \
18112 "iface <intf> | sw_if_index <sw_if_index> " \
18113 "p <priority> w <weight> [del]") \
18114 _(one_add_del_local_eid,"vni <vni> eid " \
18115 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18116 "locator-set <locator_name> [del]" \
18117 "[key-id sha1|sha256 secret-key <secret-key>]")\
18118 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18119 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18120 _(one_enable_disable, "enable|disable") \
18121 _(one_map_register_enable_disable, "enable|disable") \
18122 _(one_rloc_probe_enable_disable, "enable|disable") \
18123 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18125 "rloc <locator> p <prio> " \
18126 "w <weight> [rloc <loc> ... ] " \
18127 "action <action> [del-all]") \
18128 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18130 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18131 _(one_map_request_mode, "src-dst|dst-only") \
18132 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18133 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18134 _(one_locator_set_dump, "[local | remote]") \
18135 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18136 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18137 "[local] | [remote]") \
18138 _(one_eid_table_vni_dump, "") \
18139 _(one_eid_table_map_dump, "l2|l3") \
18140 _(one_map_resolver_dump, "") \
18141 _(one_map_server_dump, "") \
18142 _(one_adjacencies_get, "vni <vni>") \
18143 _(show_one_rloc_probe_state, "") \
18144 _(show_one_map_register_state, "") \
18145 _(show_one_status, "") \
18146 _(one_get_map_request_itr_rlocs, "") \
18147 _(show_one_pitr, "") \
18148 _(show_one_map_request_mode, "") \
18149 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18150 " sw_if_index <sw_if_index> p <priority> " \
18151 "w <weight>] [del]") \
18152 _(lisp_add_del_locator, "locator-set <locator_name> " \
18153 "iface <intf> | sw_if_index <sw_if_index> " \
18154 "p <priority> w <weight> [del]") \
18155 _(lisp_add_del_local_eid,"vni <vni> eid " \
18156 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18157 "locator-set <locator_name> [del]" \
18158 "[key-id sha1|sha256 secret-key <secret-key>]") \
18159 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18160 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18161 _(lisp_enable_disable, "enable|disable") \
18162 _(lisp_map_register_enable_disable, "enable|disable") \
18163 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18164 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18166 "rloc <locator> p <prio> " \
18167 "w <weight> [rloc <loc> ... ] " \
18168 "action <action> [del-all]") \
18169 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18171 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18172 _(lisp_map_request_mode, "src-dst|dst-only") \
18173 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18174 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18175 _(lisp_locator_set_dump, "[local | remote]") \
18176 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18177 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18178 "[local] | [remote]") \
18179 _(lisp_eid_table_vni_dump, "") \
18180 _(lisp_eid_table_map_dump, "l2|l3") \
18181 _(lisp_map_resolver_dump, "") \
18182 _(lisp_map_server_dump, "") \
18183 _(lisp_adjacencies_get, "vni <vni>") \
18184 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18185 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18186 _(gpe_set_encap_mode, "lisp|vxlan") \
18187 _(gpe_get_encap_mode, "") \
18188 _(lisp_gpe_add_del_iface, "up|down") \
18189 _(lisp_gpe_enable_disable, "enable|disable") \
18190 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18191 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18192 _(show_lisp_rloc_probe_state, "") \
18193 _(show_lisp_map_register_state, "") \
18194 _(show_lisp_status, "") \
18195 _(lisp_get_map_request_itr_rlocs, "") \
18196 _(show_lisp_pitr, "") \
18197 _(show_lisp_map_request_mode, "") \
18198 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18199 _(af_packet_delete, "name <host interface name>") \
18200 _(policer_add_del, "name <policer name> <params> [del]") \
18201 _(policer_dump, "[name <policer name>]") \
18202 _(policer_classify_set_interface, \
18203 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18204 " [l2-table <nn>] [del]") \
18205 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18206 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18207 "[master|slave]") \
18208 _(netmap_delete, "name <interface name>") \
18209 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18210 _(mpls_fib_dump, "") \
18211 _(classify_table_ids, "") \
18212 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18213 _(classify_table_info, "table_id <nn>") \
18214 _(classify_session_dump, "table_id <nn>") \
18215 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18216 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18217 "[template_interval <nn>] [udp_checksum]") \
18218 _(ipfix_exporter_dump, "") \
18219 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18220 _(ipfix_classify_stream_dump, "") \
18221 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18222 _(ipfix_classify_table_dump, "") \
18223 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18224 _(sw_interface_span_dump, "") \
18225 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18226 _(pg_create_interface, "if_id <nn>") \
18227 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18228 _(pg_enable_disable, "[stream <id>] disable") \
18229 _(ip_source_and_port_range_check_add_del, \
18230 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18231 _(ip_source_and_port_range_check_interface_add_del, \
18232 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18233 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18234 _(ipsec_gre_add_del_tunnel, \
18235 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18236 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18237 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18238 _(l2_interface_pbb_tag_rewrite, \
18239 "<intfc> | sw_if_index <nn> \n" \
18240 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18241 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18242 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18243 _(flow_classify_set_interface, \
18244 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18245 _(flow_classify_dump, "type [ip4|ip6]") \
18246 _(ip_fib_dump, "") \
18247 _(ip_mfib_dump, "") \
18248 _(ip6_fib_dump, "") \
18249 _(ip6_mfib_dump, "") \
18250 _(feature_enable_disable, "arc_name <arc_name> " \
18251 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18252 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18254 _(l2_xconnect_dump, "") \
18255 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18256 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18257 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18259 /* List of command functions, CLI names map directly to functions */
18260 #define foreach_cli_function \
18261 _(comment, "usage: comment <ignore-rest-of-line>") \
18262 _(dump_interface_table, "usage: dump_interface_table") \
18263 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18264 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18265 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18266 _(dump_stats_table, "usage: dump_stats_table") \
18267 _(dump_macro_table, "usage: dump_macro_table ") \
18268 _(dump_node_table, "usage: dump_node_table") \
18269 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18270 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18271 _(echo, "usage: echo <message>") \
18272 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18273 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18274 _(help, "usage: help") \
18275 _(q, "usage: quit") \
18276 _(quit, "usage: quit") \
18277 _(search_node_table, "usage: search_node_table <name>...") \
18278 _(set, "usage: set <variable-name> <value>") \
18279 _(script, "usage: script <file-name>") \
18280 _(unset, "usage: unset <variable-name>")
18283 static void vl_api_##n##_t_handler_uni \
18284 (vl_api_##n##_t * mp) \
18286 vat_main_t * vam = &vat_main; \
18287 if (vam->json_output) { \
18288 vl_api_##n##_t_handler_json(mp); \
18290 vl_api_##n##_t_handler(mp); \
18293 foreach_vpe_api_reply_msg;
18294 #if VPP_API_TEST_BUILTIN == 0
18295 foreach_standalone_reply_msg;
18300 vat_api_hookup (vat_main_t * vam)
18303 vl_msg_api_set_handlers(VL_API_##N, #n, \
18304 vl_api_##n##_t_handler_uni, \
18306 vl_api_##n##_t_endian, \
18307 vl_api_##n##_t_print, \
18308 sizeof(vl_api_##n##_t), 1);
18309 foreach_vpe_api_reply_msg;
18310 #if VPP_API_TEST_BUILTIN == 0
18311 foreach_standalone_reply_msg;
18315 #if (VPP_API_TEST_BUILTIN==0)
18316 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18319 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18321 vam->function_by_name = hash_create_string (0, sizeof (uword));
18323 vam->help_by_name = hash_create_string (0, sizeof (uword));
18325 /* API messages we can send */
18326 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18327 foreach_vpe_api_msg;
18331 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18332 foreach_vpe_api_msg;
18335 /* CLI functions */
18336 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18337 foreach_cli_function;
18341 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18342 foreach_cli_function;
18346 #if VPP_API_TEST_BUILTIN
18347 static clib_error_t *
18348 vat_api_hookup_shim (vlib_main_t * vm)
18350 vat_api_hookup (&vat_main);
18354 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18358 * fd.io coding-style-patch-verification: ON
18361 * eval: (c-set-style "gnu")