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 errmsg ("arp %s event: address %U new mac %U sw_if_index %d",
1258 mp->mac_ip ? "mac/ip binding" : "address resolution",
1259 format_ip4_address, &mp->address,
1260 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1264 vl_api_ip4_arp_event_t_handler_json (vl_api_ip4_arp_event_t * mp)
1266 /* JSON output not supported */
1270 vl_api_ip6_nd_event_t_handler (vl_api_ip6_nd_event_t * mp)
1272 errmsg ("ip6 nd %s event: address %U new mac %U sw_if_index %d",
1273 mp->mac_ip ? "mac/ip binding" : "address resolution",
1274 format_ip6_address, mp->address,
1275 format_ethernet_address, mp->new_mac, mp->sw_if_index);
1279 vl_api_ip6_nd_event_t_handler_json (vl_api_ip6_nd_event_t * mp)
1281 /* JSON output not supported */
1285 * Special-case: build the bridge domain table, maintain
1286 * the next bd id vbl.
1288 static void vl_api_bridge_domain_details_t_handler
1289 (vl_api_bridge_domain_details_t * mp)
1291 vat_main_t *vam = &vat_main;
1292 u32 n_sw_ifs = ntohl (mp->n_sw_ifs);
1294 print (vam->ofp, "\n%-3s %-3s %-3s %-3s %-3s %-3s",
1295 " ID", "LRN", "FWD", "FLD", "BVI", "#IF");
1297 print (vam->ofp, "%3d %3d %3d %3d %3d %3d",
1298 ntohl (mp->bd_id), mp->learn, mp->forward,
1299 mp->flood, ntohl (mp->bvi_sw_if_index), n_sw_ifs);
1302 print (vam->ofp, "\n\n%s %s %s", "sw_if_index", "SHG", "Interface Name");
1305 static void vl_api_bridge_domain_details_t_handler_json
1306 (vl_api_bridge_domain_details_t * mp)
1308 vat_main_t *vam = &vat_main;
1309 vat_json_node_t *node, *array = NULL;
1311 if (VAT_JSON_ARRAY != vam->json_tree.type)
1313 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1314 vat_json_init_array (&vam->json_tree);
1316 node = vat_json_array_add (&vam->json_tree);
1318 vat_json_init_object (node);
1319 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1320 vat_json_object_add_uint (node, "flood", mp->flood);
1321 vat_json_object_add_uint (node, "forward", mp->forward);
1322 vat_json_object_add_uint (node, "learn", mp->learn);
1323 vat_json_object_add_uint (node, "bvi_sw_if_index",
1324 ntohl (mp->bvi_sw_if_index));
1325 vat_json_object_add_uint (node, "n_sw_ifs", ntohl (mp->n_sw_ifs));
1326 array = vat_json_object_add (node, "sw_if");
1327 vat_json_init_array (array);
1331 * Special-case: build the bridge domain sw if table.
1333 static void vl_api_bridge_domain_sw_if_details_t_handler
1334 (vl_api_bridge_domain_sw_if_details_t * mp)
1336 vat_main_t *vam = &vat_main;
1341 sw_if_index = ntohl (mp->sw_if_index);
1343 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
1345 if ((u32) p->value[0] == sw_if_index)
1347 sw_if_name = (u8 *)(p->key);
1353 print (vam->ofp, "%7d %3d %s", sw_if_index,
1354 mp->shg, sw_if_name ? (char *) sw_if_name :
1355 "sw_if_index not found!");
1358 static void vl_api_bridge_domain_sw_if_details_t_handler_json
1359 (vl_api_bridge_domain_sw_if_details_t * mp)
1361 vat_main_t *vam = &vat_main;
1362 vat_json_node_t *node = NULL;
1363 uword last_index = 0;
1365 ASSERT (VAT_JSON_ARRAY == vam->json_tree.type);
1366 ASSERT (vec_len (vam->json_tree.array) >= 1);
1367 last_index = vec_len (vam->json_tree.array) - 1;
1368 node = &vam->json_tree.array[last_index];
1369 node = vat_json_object_get_element (node, "sw_if");
1370 ASSERT (NULL != node);
1371 node = vat_json_array_add (node);
1373 vat_json_init_object (node);
1374 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
1375 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
1376 vat_json_object_add_uint (node, "shg", mp->shg);
1379 static void vl_api_control_ping_reply_t_handler
1380 (vl_api_control_ping_reply_t * mp)
1382 vat_main_t *vam = &vat_main;
1383 i32 retval = ntohl (mp->retval);
1384 if (vam->async_mode)
1386 vam->async_errors += (retval < 0);
1390 vam->retval = retval;
1391 vam->result_ready = 1;
1395 static void vl_api_control_ping_reply_t_handler_json
1396 (vl_api_control_ping_reply_t * mp)
1398 vat_main_t *vam = &vat_main;
1399 i32 retval = ntohl (mp->retval);
1401 if (VAT_JSON_NONE != vam->json_tree.type)
1403 vat_json_print (vam->ofp, &vam->json_tree);
1404 vat_json_free (&vam->json_tree);
1405 vam->json_tree.type = VAT_JSON_NONE;
1410 vat_json_init_array (&vam->json_tree);
1411 vat_json_print (vam->ofp, &vam->json_tree);
1412 vam->json_tree.type = VAT_JSON_NONE;
1415 vam->retval = retval;
1416 vam->result_ready = 1;
1420 vl_api_l2_flags_reply_t_handler (vl_api_l2_flags_reply_t * mp)
1422 vat_main_t *vam = &vat_main;
1423 i32 retval = ntohl (mp->retval);
1424 if (vam->async_mode)
1426 vam->async_errors += (retval < 0);
1430 vam->retval = retval;
1431 vam->result_ready = 1;
1435 static void vl_api_l2_flags_reply_t_handler_json
1436 (vl_api_l2_flags_reply_t * mp)
1438 vat_main_t *vam = &vat_main;
1439 vat_json_node_t node;
1441 vat_json_init_object (&node);
1442 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1443 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1444 ntohl (mp->resulting_feature_bitmap));
1446 vat_json_print (vam->ofp, &node);
1447 vat_json_free (&node);
1449 vam->retval = ntohl (mp->retval);
1450 vam->result_ready = 1;
1453 static void vl_api_bridge_flags_reply_t_handler
1454 (vl_api_bridge_flags_reply_t * mp)
1456 vat_main_t *vam = &vat_main;
1457 i32 retval = ntohl (mp->retval);
1458 if (vam->async_mode)
1460 vam->async_errors += (retval < 0);
1464 vam->retval = retval;
1465 vam->result_ready = 1;
1469 static void vl_api_bridge_flags_reply_t_handler_json
1470 (vl_api_bridge_flags_reply_t * mp)
1472 vat_main_t *vam = &vat_main;
1473 vat_json_node_t node;
1475 vat_json_init_object (&node);
1476 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1477 vat_json_object_add_uint (&node, "resulting_feature_bitmap",
1478 ntohl (mp->resulting_feature_bitmap));
1480 vat_json_print (vam->ofp, &node);
1481 vat_json_free (&node);
1483 vam->retval = ntohl (mp->retval);
1484 vam->result_ready = 1;
1487 static void vl_api_tap_connect_reply_t_handler
1488 (vl_api_tap_connect_reply_t * mp)
1490 vat_main_t *vam = &vat_main;
1491 i32 retval = ntohl (mp->retval);
1492 if (vam->async_mode)
1494 vam->async_errors += (retval < 0);
1498 vam->retval = retval;
1499 vam->sw_if_index = ntohl (mp->sw_if_index);
1500 vam->result_ready = 1;
1505 static void vl_api_tap_connect_reply_t_handler_json
1506 (vl_api_tap_connect_reply_t * mp)
1508 vat_main_t *vam = &vat_main;
1509 vat_json_node_t node;
1511 vat_json_init_object (&node);
1512 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1513 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1515 vat_json_print (vam->ofp, &node);
1516 vat_json_free (&node);
1518 vam->retval = ntohl (mp->retval);
1519 vam->result_ready = 1;
1524 vl_api_tap_modify_reply_t_handler (vl_api_tap_modify_reply_t * mp)
1526 vat_main_t *vam = &vat_main;
1527 i32 retval = ntohl (mp->retval);
1528 if (vam->async_mode)
1530 vam->async_errors += (retval < 0);
1534 vam->retval = retval;
1535 vam->sw_if_index = ntohl (mp->sw_if_index);
1536 vam->result_ready = 1;
1540 static void vl_api_tap_modify_reply_t_handler_json
1541 (vl_api_tap_modify_reply_t * mp)
1543 vat_main_t *vam = &vat_main;
1544 vat_json_node_t node;
1546 vat_json_init_object (&node);
1547 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1548 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1550 vat_json_print (vam->ofp, &node);
1551 vat_json_free (&node);
1553 vam->retval = ntohl (mp->retval);
1554 vam->result_ready = 1;
1558 vl_api_tap_delete_reply_t_handler (vl_api_tap_delete_reply_t * mp)
1560 vat_main_t *vam = &vat_main;
1561 i32 retval = ntohl (mp->retval);
1562 if (vam->async_mode)
1564 vam->async_errors += (retval < 0);
1568 vam->retval = retval;
1569 vam->result_ready = 1;
1573 static void vl_api_tap_delete_reply_t_handler_json
1574 (vl_api_tap_delete_reply_t * mp)
1576 vat_main_t *vam = &vat_main;
1577 vat_json_node_t node;
1579 vat_json_init_object (&node);
1580 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1582 vat_json_print (vam->ofp, &node);
1583 vat_json_free (&node);
1585 vam->retval = ntohl (mp->retval);
1586 vam->result_ready = 1;
1589 static void vl_api_mpls_tunnel_add_del_reply_t_handler
1590 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1592 vat_main_t *vam = &vat_main;
1593 i32 retval = ntohl (mp->retval);
1594 if (vam->async_mode)
1596 vam->async_errors += (retval < 0);
1600 vam->retval = retval;
1601 vam->result_ready = 1;
1605 static void vl_api_mpls_tunnel_add_del_reply_t_handler_json
1606 (vl_api_mpls_tunnel_add_del_reply_t * mp)
1608 vat_main_t *vam = &vat_main;
1609 vat_json_node_t node;
1611 vat_json_init_object (&node);
1612 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1613 vat_json_object_add_uint (&node, "tunnel_sw_if_index",
1614 ntohl (mp->sw_if_index));
1616 vat_json_print (vam->ofp, &node);
1617 vat_json_free (&node);
1619 vam->retval = ntohl (mp->retval);
1620 vam->result_ready = 1;
1623 static void vl_api_l2tpv3_create_tunnel_reply_t_handler
1624 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1626 vat_main_t *vam = &vat_main;
1627 i32 retval = ntohl (mp->retval);
1628 if (vam->async_mode)
1630 vam->async_errors += (retval < 0);
1634 vam->retval = retval;
1635 vam->sw_if_index = ntohl (mp->sw_if_index);
1636 vam->result_ready = 1;
1640 static void vl_api_l2tpv3_create_tunnel_reply_t_handler_json
1641 (vl_api_l2tpv3_create_tunnel_reply_t * mp)
1643 vat_main_t *vam = &vat_main;
1644 vat_json_node_t node;
1646 vat_json_init_object (&node);
1647 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1648 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1650 vat_json_print (vam->ofp, &node);
1651 vat_json_free (&node);
1653 vam->retval = ntohl (mp->retval);
1654 vam->result_ready = 1;
1658 static void vl_api_one_add_del_locator_set_reply_t_handler
1659 (vl_api_one_add_del_locator_set_reply_t * mp)
1661 vat_main_t *vam = &vat_main;
1662 i32 retval = ntohl (mp->retval);
1663 if (vam->async_mode)
1665 vam->async_errors += (retval < 0);
1669 vam->retval = retval;
1670 vam->result_ready = 1;
1674 static void vl_api_one_add_del_locator_set_reply_t_handler_json
1675 (vl_api_one_add_del_locator_set_reply_t * mp)
1677 vat_main_t *vam = &vat_main;
1678 vat_json_node_t node;
1680 vat_json_init_object (&node);
1681 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1682 vat_json_object_add_uint (&node, "locator_set_index", ntohl (mp->ls_index));
1684 vat_json_print (vam->ofp, &node);
1685 vat_json_free (&node);
1687 vam->retval = ntohl (mp->retval);
1688 vam->result_ready = 1;
1691 static void vl_api_vxlan_add_del_tunnel_reply_t_handler
1692 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1694 vat_main_t *vam = &vat_main;
1695 i32 retval = ntohl (mp->retval);
1696 if (vam->async_mode)
1698 vam->async_errors += (retval < 0);
1702 vam->retval = retval;
1703 vam->sw_if_index = ntohl (mp->sw_if_index);
1704 vam->result_ready = 1;
1708 static void vl_api_vxlan_add_del_tunnel_reply_t_handler_json
1709 (vl_api_vxlan_add_del_tunnel_reply_t * mp)
1711 vat_main_t *vam = &vat_main;
1712 vat_json_node_t node;
1714 vat_json_init_object (&node);
1715 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1716 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1718 vat_json_print (vam->ofp, &node);
1719 vat_json_free (&node);
1721 vam->retval = ntohl (mp->retval);
1722 vam->result_ready = 1;
1725 static void vl_api_gre_add_del_tunnel_reply_t_handler
1726 (vl_api_gre_add_del_tunnel_reply_t * mp)
1728 vat_main_t *vam = &vat_main;
1729 i32 retval = ntohl (mp->retval);
1730 if (vam->async_mode)
1732 vam->async_errors += (retval < 0);
1736 vam->retval = retval;
1737 vam->sw_if_index = ntohl (mp->sw_if_index);
1738 vam->result_ready = 1;
1742 static void vl_api_gre_add_del_tunnel_reply_t_handler_json
1743 (vl_api_gre_add_del_tunnel_reply_t * mp)
1745 vat_main_t *vam = &vat_main;
1746 vat_json_node_t node;
1748 vat_json_init_object (&node);
1749 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1750 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1752 vat_json_print (vam->ofp, &node);
1753 vat_json_free (&node);
1755 vam->retval = ntohl (mp->retval);
1756 vam->result_ready = 1;
1759 static void vl_api_create_vhost_user_if_reply_t_handler
1760 (vl_api_create_vhost_user_if_reply_t * mp)
1762 vat_main_t *vam = &vat_main;
1763 i32 retval = ntohl (mp->retval);
1764 if (vam->async_mode)
1766 vam->async_errors += (retval < 0);
1770 vam->retval = retval;
1771 vam->sw_if_index = ntohl (mp->sw_if_index);
1772 vam->result_ready = 1;
1776 static void vl_api_create_vhost_user_if_reply_t_handler_json
1777 (vl_api_create_vhost_user_if_reply_t * mp)
1779 vat_main_t *vam = &vat_main;
1780 vat_json_node_t node;
1782 vat_json_init_object (&node);
1783 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
1784 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
1786 vat_json_print (vam->ofp, &node);
1787 vat_json_free (&node);
1789 vam->retval = ntohl (mp->retval);
1790 vam->result_ready = 1;
1793 static void vl_api_ip_address_details_t_handler
1794 (vl_api_ip_address_details_t * mp)
1796 vat_main_t *vam = &vat_main;
1797 static ip_address_details_t empty_ip_address_details = { {0} };
1798 ip_address_details_t *address = NULL;
1799 ip_details_t *current_ip_details = NULL;
1800 ip_details_t *details = NULL;
1802 details = vam->ip_details_by_sw_if_index[vam->is_ipv6];
1804 if (!details || vam->current_sw_if_index >= vec_len (details)
1805 || !details[vam->current_sw_if_index].present)
1807 errmsg ("ip address details arrived but not stored");
1808 errmsg ("ip_dump should be called first");
1812 current_ip_details = vec_elt_at_index (details, vam->current_sw_if_index);
1814 #define addresses (current_ip_details->addr)
1816 vec_validate_init_empty (addresses, vec_len (addresses),
1817 empty_ip_address_details);
1819 address = vec_elt_at_index (addresses, vec_len (addresses) - 1);
1821 clib_memcpy (&address->ip, &mp->ip, sizeof (address->ip));
1822 address->prefix_length = mp->prefix_length;
1826 static void vl_api_ip_address_details_t_handler_json
1827 (vl_api_ip_address_details_t * mp)
1829 vat_main_t *vam = &vat_main;
1830 vat_json_node_t *node = NULL;
1831 struct in6_addr ip6;
1834 if (VAT_JSON_ARRAY != vam->json_tree.type)
1836 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1837 vat_json_init_array (&vam->json_tree);
1839 node = vat_json_array_add (&vam->json_tree);
1841 vat_json_init_object (node);
1844 clib_memcpy (&ip6, mp->ip, sizeof (ip6));
1845 vat_json_object_add_ip6 (node, "ip", ip6);
1849 clib_memcpy (&ip4, mp->ip, sizeof (ip4));
1850 vat_json_object_add_ip4 (node, "ip", ip4);
1852 vat_json_object_add_uint (node, "prefix_length", mp->prefix_length);
1856 vl_api_ip_details_t_handler (vl_api_ip_details_t * mp)
1858 vat_main_t *vam = &vat_main;
1859 static ip_details_t empty_ip_details = { 0 };
1860 ip_details_t *ip = NULL;
1861 u32 sw_if_index = ~0;
1863 sw_if_index = ntohl (mp->sw_if_index);
1865 vec_validate_init_empty (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1866 sw_if_index, empty_ip_details);
1868 ip = vec_elt_at_index (vam->ip_details_by_sw_if_index[vam->is_ipv6],
1875 vl_api_ip_details_t_handler_json (vl_api_ip_details_t * mp)
1877 vat_main_t *vam = &vat_main;
1879 if (VAT_JSON_ARRAY != vam->json_tree.type)
1881 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1882 vat_json_init_array (&vam->json_tree);
1884 vat_json_array_add_uint (&vam->json_tree,
1885 clib_net_to_host_u32 (mp->sw_if_index));
1888 static void vl_api_map_domain_details_t_handler_json
1889 (vl_api_map_domain_details_t * mp)
1891 vat_json_node_t *node = NULL;
1892 vat_main_t *vam = &vat_main;
1893 struct in6_addr ip6;
1896 if (VAT_JSON_ARRAY != vam->json_tree.type)
1898 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1899 vat_json_init_array (&vam->json_tree);
1902 node = vat_json_array_add (&vam->json_tree);
1903 vat_json_init_object (node);
1905 vat_json_object_add_uint (node, "domain_index",
1906 clib_net_to_host_u32 (mp->domain_index));
1907 clib_memcpy (&ip6, mp->ip6_prefix, sizeof (ip6));
1908 vat_json_object_add_ip6 (node, "ip6_prefix", ip6);
1909 clib_memcpy (&ip4, mp->ip4_prefix, sizeof (ip4));
1910 vat_json_object_add_ip4 (node, "ip4_prefix", ip4);
1911 clib_memcpy (&ip6, mp->ip6_src, sizeof (ip6));
1912 vat_json_object_add_ip6 (node, "ip6_src", ip6);
1913 vat_json_object_add_int (node, "ip6_prefix_len", mp->ip6_prefix_len);
1914 vat_json_object_add_int (node, "ip4_prefix_len", mp->ip4_prefix_len);
1915 vat_json_object_add_int (node, "ip6_src_len", mp->ip6_src_len);
1916 vat_json_object_add_int (node, "ea_bits_len", mp->ea_bits_len);
1917 vat_json_object_add_int (node, "psid_offset", mp->psid_offset);
1918 vat_json_object_add_int (node, "psid_length", mp->psid_length);
1919 vat_json_object_add_uint (node, "flags", mp->flags);
1920 vat_json_object_add_uint (node, "mtu", clib_net_to_host_u16 (mp->mtu));
1921 vat_json_object_add_int (node, "is_translation", mp->is_translation);
1924 static void vl_api_map_domain_details_t_handler
1925 (vl_api_map_domain_details_t * mp)
1927 vat_main_t *vam = &vat_main;
1929 if (mp->is_translation)
1932 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U/%d (ip6-src) index: %u",
1933 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1934 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1935 format_ip6_address, mp->ip6_src, mp->ip6_src_len,
1936 clib_net_to_host_u32 (mp->domain_index));
1941 "* %U/%d (ipv4-prefix) %U/%d (ipv6-prefix) %U (ip6-src) index: %u",
1942 format_ip4_address, mp->ip4_prefix, mp->ip4_prefix_len,
1943 format_ip6_address, mp->ip6_prefix, mp->ip6_prefix_len,
1944 format_ip6_address, mp->ip6_src,
1945 clib_net_to_host_u32 (mp->domain_index));
1947 print (vam->ofp, " ea-len %d psid-offset %d psid-len %d mtu %d %s",
1948 mp->ea_bits_len, mp->psid_offset, mp->psid_length, mp->mtu,
1949 mp->is_translation ? "map-t" : "");
1952 static void vl_api_map_rule_details_t_handler_json
1953 (vl_api_map_rule_details_t * mp)
1955 struct in6_addr ip6;
1956 vat_json_node_t *node = NULL;
1957 vat_main_t *vam = &vat_main;
1959 if (VAT_JSON_ARRAY != vam->json_tree.type)
1961 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
1962 vat_json_init_array (&vam->json_tree);
1965 node = vat_json_array_add (&vam->json_tree);
1966 vat_json_init_object (node);
1968 vat_json_object_add_uint (node, "psid", clib_net_to_host_u16 (mp->psid));
1969 clib_memcpy (&ip6, mp->ip6_dst, sizeof (ip6));
1970 vat_json_object_add_ip6 (node, "ip6_dst", ip6);
1974 vl_api_map_rule_details_t_handler (vl_api_map_rule_details_t * mp)
1976 vat_main_t *vam = &vat_main;
1977 print (vam->ofp, " %d (psid) %U (ip6-dst)",
1978 clib_net_to_host_u16 (mp->psid), format_ip6_address, mp->ip6_dst);
1982 vl_api_dhcp_compl_event_t_handler (vl_api_dhcp_compl_event_t * mp)
1984 errmsg ("DHCP compl event: pid %d %s hostname %s host_addr %U "
1985 "router_addr %U host_mac %U",
1986 mp->pid, mp->is_ipv6 ? "ipv6" : "ipv4", mp->hostname,
1987 format_ip4_address, &mp->host_address,
1988 format_ip4_address, &mp->router_address,
1989 format_ethernet_address, mp->host_mac);
1992 static void vl_api_dhcp_compl_event_t_handler_json
1993 (vl_api_dhcp_compl_event_t * mp)
1995 /* JSON output not supported */
1999 set_simple_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2002 vat_main_t *vam = &vat_main;
2003 static u64 default_counter = 0;
2005 vec_validate_init_empty (vam->simple_interface_counters, vnet_counter_type,
2007 vec_validate_init_empty (vam->simple_interface_counters[vnet_counter_type],
2008 sw_if_index, default_counter);
2009 vam->simple_interface_counters[vnet_counter_type][sw_if_index] = counter;
2013 set_combined_interface_counter (u8 vnet_counter_type, u32 sw_if_index,
2014 interface_counter_t counter)
2016 vat_main_t *vam = &vat_main;
2017 static interface_counter_t default_counter = { 0, };
2019 vec_validate_init_empty (vam->combined_interface_counters,
2020 vnet_counter_type, NULL);
2021 vec_validate_init_empty (vam->combined_interface_counters
2022 [vnet_counter_type], sw_if_index, default_counter);
2023 vam->combined_interface_counters[vnet_counter_type][sw_if_index] = counter;
2026 static void vl_api_vnet_interface_counters_t_handler
2027 (vl_api_vnet_interface_counters_t * mp)
2032 static void vl_api_vnet_interface_counters_t_handler_json
2033 (vl_api_vnet_interface_counters_t * mp)
2035 interface_counter_t counter;
2040 u32 first_sw_if_index;
2043 count = ntohl (mp->count);
2044 first_sw_if_index = ntohl (mp->first_sw_if_index);
2046 if (!mp->is_combined)
2048 v_packets = (u64 *) & mp->data;
2049 for (i = 0; i < count; i++)
2052 clib_net_to_host_u64 (clib_mem_unaligned (v_packets, u64));
2053 set_simple_interface_counter (mp->vnet_counter_type,
2054 first_sw_if_index + i, packets);
2060 v = (vlib_counter_t *) & mp->data;
2061 for (i = 0; i < count; i++)
2064 clib_net_to_host_u64 (clib_mem_unaligned (&v->packets, u64));
2066 clib_net_to_host_u64 (clib_mem_unaligned (&v->bytes, u64));
2067 set_combined_interface_counter (mp->vnet_counter_type,
2068 first_sw_if_index + i, counter);
2075 ip4_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2077 vat_main_t *vam = &vat_main;
2080 for (i = 0; i < vec_len (vam->ip4_fib_counters_vrf_id_by_index); i++)
2082 if (vam->ip4_fib_counters_vrf_id_by_index[i] == vrf_id)
2091 ip6_fib_counters_get_vrf_index_by_vrf_id (u32 vrf_id)
2093 vat_main_t *vam = &vat_main;
2096 for (i = 0; i < vec_len (vam->ip6_fib_counters_vrf_id_by_index); i++)
2098 if (vam->ip6_fib_counters_vrf_id_by_index[i] == vrf_id)
2106 static void vl_api_vnet_ip4_fib_counters_t_handler
2107 (vl_api_vnet_ip4_fib_counters_t * mp)
2112 static void vl_api_vnet_ip4_fib_counters_t_handler_json
2113 (vl_api_vnet_ip4_fib_counters_t * mp)
2115 vat_main_t *vam = &vat_main;
2116 vl_api_ip4_fib_counter_t *v;
2117 ip4_fib_counter_t *counter;
2124 vrf_id = ntohl (mp->vrf_id);
2125 vrf_index = ip4_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2126 if (~0 == vrf_index)
2128 vrf_index = vec_len (vam->ip4_fib_counters_vrf_id_by_index);
2129 vec_validate (vam->ip4_fib_counters_vrf_id_by_index, vrf_index);
2130 vam->ip4_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2131 vec_validate (vam->ip4_fib_counters, vrf_index);
2132 vam->ip4_fib_counters[vrf_index] = NULL;
2135 vec_free (vam->ip4_fib_counters[vrf_index]);
2136 v = (vl_api_ip4_fib_counter_t *) & mp->c;
2137 count = ntohl (mp->count);
2138 for (i = 0; i < count; i++)
2140 vec_validate (vam->ip4_fib_counters[vrf_index], i);
2141 counter = &vam->ip4_fib_counters[vrf_index][i];
2142 clib_memcpy (&ip4, &v->address, sizeof (ip4));
2143 counter->address = ip4;
2144 counter->address_length = v->address_length;
2145 counter->packets = clib_net_to_host_u64 (v->packets);
2146 counter->bytes = clib_net_to_host_u64 (v->bytes);
2151 static void vl_api_vnet_ip4_nbr_counters_t_handler
2152 (vl_api_vnet_ip4_nbr_counters_t * mp)
2157 static void vl_api_vnet_ip4_nbr_counters_t_handler_json
2158 (vl_api_vnet_ip4_nbr_counters_t * mp)
2160 vat_main_t *vam = &vat_main;
2161 vl_api_ip4_nbr_counter_t *v;
2162 ip4_nbr_counter_t *counter;
2167 sw_if_index = ntohl (mp->sw_if_index);
2168 count = ntohl (mp->count);
2169 vec_validate (vam->ip4_nbr_counters, sw_if_index);
2172 vec_free (vam->ip4_nbr_counters[sw_if_index]);
2174 v = (vl_api_ip4_nbr_counter_t *) & mp->c;
2175 for (i = 0; i < count; i++)
2177 vec_validate (vam->ip4_nbr_counters[sw_if_index], i);
2178 counter = &vam->ip4_nbr_counters[sw_if_index][i];
2179 counter->address.s_addr = v->address;
2180 counter->packets = clib_net_to_host_u64 (v->packets);
2181 counter->bytes = clib_net_to_host_u64 (v->bytes);
2182 counter->linkt = v->link_type;
2187 static void vl_api_vnet_ip6_fib_counters_t_handler
2188 (vl_api_vnet_ip6_fib_counters_t * mp)
2193 static void vl_api_vnet_ip6_fib_counters_t_handler_json
2194 (vl_api_vnet_ip6_fib_counters_t * mp)
2196 vat_main_t *vam = &vat_main;
2197 vl_api_ip6_fib_counter_t *v;
2198 ip6_fib_counter_t *counter;
2199 struct in6_addr ip6;
2205 vrf_id = ntohl (mp->vrf_id);
2206 vrf_index = ip6_fib_counters_get_vrf_index_by_vrf_id (vrf_id);
2207 if (~0 == vrf_index)
2209 vrf_index = vec_len (vam->ip6_fib_counters_vrf_id_by_index);
2210 vec_validate (vam->ip6_fib_counters_vrf_id_by_index, vrf_index);
2211 vam->ip6_fib_counters_vrf_id_by_index[vrf_index] = vrf_id;
2212 vec_validate (vam->ip6_fib_counters, vrf_index);
2213 vam->ip6_fib_counters[vrf_index] = NULL;
2216 vec_free (vam->ip6_fib_counters[vrf_index]);
2217 v = (vl_api_ip6_fib_counter_t *) & mp->c;
2218 count = ntohl (mp->count);
2219 for (i = 0; i < count; i++)
2221 vec_validate (vam->ip6_fib_counters[vrf_index], i);
2222 counter = &vam->ip6_fib_counters[vrf_index][i];
2223 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2224 counter->address = ip6;
2225 counter->address_length = v->address_length;
2226 counter->packets = clib_net_to_host_u64 (v->packets);
2227 counter->bytes = clib_net_to_host_u64 (v->bytes);
2232 static void vl_api_vnet_ip6_nbr_counters_t_handler
2233 (vl_api_vnet_ip6_nbr_counters_t * mp)
2238 static void vl_api_vnet_ip6_nbr_counters_t_handler_json
2239 (vl_api_vnet_ip6_nbr_counters_t * mp)
2241 vat_main_t *vam = &vat_main;
2242 vl_api_ip6_nbr_counter_t *v;
2243 ip6_nbr_counter_t *counter;
2244 struct in6_addr ip6;
2249 sw_if_index = ntohl (mp->sw_if_index);
2250 count = ntohl (mp->count);
2251 vec_validate (vam->ip6_nbr_counters, sw_if_index);
2254 vec_free (vam->ip6_nbr_counters[sw_if_index]);
2256 v = (vl_api_ip6_nbr_counter_t *) & mp->c;
2257 for (i = 0; i < count; i++)
2259 vec_validate (vam->ip6_nbr_counters[sw_if_index], i);
2260 counter = &vam->ip6_nbr_counters[sw_if_index][i];
2261 clib_memcpy (&ip6, &v->address, sizeof (ip6));
2262 counter->address = ip6;
2263 counter->packets = clib_net_to_host_u64 (v->packets);
2264 counter->bytes = clib_net_to_host_u64 (v->bytes);
2269 static void vl_api_get_first_msg_id_reply_t_handler
2270 (vl_api_get_first_msg_id_reply_t * mp)
2272 vat_main_t *vam = &vat_main;
2273 i32 retval = ntohl (mp->retval);
2275 if (vam->async_mode)
2277 vam->async_errors += (retval < 0);
2281 vam->retval = retval;
2282 vam->result_ready = 1;
2286 errmsg ("first message id %d", ntohs (mp->first_msg_id));
2290 static void vl_api_get_first_msg_id_reply_t_handler_json
2291 (vl_api_get_first_msg_id_reply_t * mp)
2293 vat_main_t *vam = &vat_main;
2294 vat_json_node_t node;
2296 vat_json_init_object (&node);
2297 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2298 vat_json_object_add_uint (&node, "first_msg_id",
2299 (uint) ntohs (mp->first_msg_id));
2301 vat_json_print (vam->ofp, &node);
2302 vat_json_free (&node);
2304 vam->retval = ntohl (mp->retval);
2305 vam->result_ready = 1;
2308 static void vl_api_get_node_graph_reply_t_handler
2309 (vl_api_get_node_graph_reply_t * mp)
2311 vat_main_t *vam = &vat_main;
2312 api_main_t *am = &api_main;
2313 i32 retval = ntohl (mp->retval);
2314 u8 *pvt_copy, *reply;
2319 if (vam->async_mode)
2321 vam->async_errors += (retval < 0);
2325 vam->retval = retval;
2326 vam->result_ready = 1;
2329 /* "Should never happen..." */
2333 reply = (u8 *) (mp->reply_in_shmem);
2334 pvt_copy = vec_dup (reply);
2336 /* Toss the shared-memory original... */
2337 pthread_mutex_lock (&am->vlib_rp->mutex);
2338 oldheap = svm_push_data_heap (am->vlib_rp);
2342 svm_pop_heap (oldheap);
2343 pthread_mutex_unlock (&am->vlib_rp->mutex);
2345 if (vam->graph_nodes)
2347 hash_free (vam->graph_node_index_by_name);
2349 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2351 node = vam->graph_nodes[i];
2352 vec_free (node->name);
2353 vec_free (node->next_nodes);
2356 vec_free (vam->graph_nodes);
2359 vam->graph_node_index_by_name = hash_create_string (0, sizeof (uword));
2360 vam->graph_nodes = vlib_node_unserialize (pvt_copy);
2361 vec_free (pvt_copy);
2363 for (i = 0; i < vec_len (vam->graph_nodes); i++)
2365 node = vam->graph_nodes[i];
2366 hash_set_mem (vam->graph_node_index_by_name, node->name, i);
2370 static void vl_api_get_node_graph_reply_t_handler_json
2371 (vl_api_get_node_graph_reply_t * mp)
2373 vat_main_t *vam = &vat_main;
2374 api_main_t *am = &api_main;
2376 vat_json_node_t node;
2379 /* $$$$ make this real? */
2380 vat_json_init_object (&node);
2381 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
2382 vat_json_object_add_uint (&node, "reply_in_shmem", mp->reply_in_shmem);
2384 reply = (u8 *) (mp->reply_in_shmem);
2386 /* Toss the shared-memory original... */
2387 pthread_mutex_lock (&am->vlib_rp->mutex);
2388 oldheap = svm_push_data_heap (am->vlib_rp);
2392 svm_pop_heap (oldheap);
2393 pthread_mutex_unlock (&am->vlib_rp->mutex);
2395 vat_json_print (vam->ofp, &node);
2396 vat_json_free (&node);
2398 vam->retval = ntohl (mp->retval);
2399 vam->result_ready = 1;
2403 vl_api_one_locator_details_t_handler (vl_api_one_locator_details_t * mp)
2405 vat_main_t *vam = &vat_main;
2410 s = format (s, "%=16d%=16d%=16d",
2411 ntohl (mp->sw_if_index), mp->priority, mp->weight);
2415 s = format (s, "%=16U%=16d%=16d",
2416 mp->is_ipv6 ? format_ip6_address :
2418 mp->ip_address, mp->priority, mp->weight);
2421 print (vam->ofp, "%v", s);
2426 vl_api_one_locator_details_t_handler_json (vl_api_one_locator_details_t * mp)
2428 vat_main_t *vam = &vat_main;
2429 vat_json_node_t *node = NULL;
2430 struct in6_addr ip6;
2433 if (VAT_JSON_ARRAY != vam->json_tree.type)
2435 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2436 vat_json_init_array (&vam->json_tree);
2438 node = vat_json_array_add (&vam->json_tree);
2439 vat_json_init_object (node);
2441 vat_json_object_add_uint (node, "local", mp->local ? 1 : 0);
2442 vat_json_object_add_uint (node, "priority", mp->priority);
2443 vat_json_object_add_uint (node, "weight", mp->weight);
2446 vat_json_object_add_uint (node, "sw_if_index",
2447 clib_net_to_host_u32 (mp->sw_if_index));
2452 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
2453 vat_json_object_add_ip6 (node, "address", ip6);
2457 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
2458 vat_json_object_add_ip4 (node, "address", ip4);
2464 vl_api_one_locator_set_details_t_handler (vl_api_one_locator_set_details_t *
2467 vat_main_t *vam = &vat_main;
2470 ls_name = format (0, "%s", mp->ls_name);
2472 print (vam->ofp, "%=10d%=15v", clib_net_to_host_u32 (mp->ls_index),
2478 vl_api_one_locator_set_details_t_handler_json
2479 (vl_api_one_locator_set_details_t * mp)
2481 vat_main_t *vam = &vat_main;
2482 vat_json_node_t *node = 0;
2485 ls_name = format (0, "%s", mp->ls_name);
2486 vec_add1 (ls_name, 0);
2488 if (VAT_JSON_ARRAY != vam->json_tree.type)
2490 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2491 vat_json_init_array (&vam->json_tree);
2493 node = vat_json_array_add (&vam->json_tree);
2495 vat_json_init_object (node);
2496 vat_json_object_add_string_copy (node, "ls_name", ls_name);
2497 vat_json_object_add_uint (node, "ls_index",
2498 clib_net_to_host_u32 (mp->ls_index));
2503 format_lisp_flat_eid (u8 * s, va_list * args)
2505 u32 type = va_arg (*args, u32);
2506 u8 *eid = va_arg (*args, u8 *);
2507 u32 eid_len = va_arg (*args, u32);
2512 return format (s, "%U/%d", format_ip4_address, eid, eid_len);
2514 return format (s, "%U/%d", format_ip6_address, eid, eid_len);
2516 return format (s, "%U", format_ethernet_address, eid);
2522 format_lisp_eid_vat (u8 * s, va_list * args)
2524 u32 type = va_arg (*args, u32);
2525 u8 *eid = va_arg (*args, u8 *);
2526 u32 eid_len = va_arg (*args, u32);
2527 u8 *seid = va_arg (*args, u8 *);
2528 u32 seid_len = va_arg (*args, u32);
2529 u32 is_src_dst = va_arg (*args, u32);
2532 s = format (s, "%U|", format_lisp_flat_eid, type, seid, seid_len);
2534 s = format (s, "%U", format_lisp_flat_eid, type, eid, eid_len);
2540 vl_api_one_eid_table_details_t_handler (vl_api_one_eid_table_details_t * mp)
2542 vat_main_t *vam = &vat_main;
2543 u8 *s = 0, *eid = 0;
2545 if (~0 == mp->locator_set_index)
2546 s = format (0, "action: %d", mp->action);
2548 s = format (0, "%d", clib_net_to_host_u32 (mp->locator_set_index));
2550 eid = format (0, "%U", format_lisp_eid_vat,
2554 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2557 print (vam->ofp, "[%d] %-35s%-20s%-30s%-20d%-20d%-10d%-20s",
2558 clib_net_to_host_u32 (mp->vni),
2560 mp->is_local ? "local" : "remote",
2561 s, clib_net_to_host_u32 (mp->ttl), mp->authoritative,
2562 clib_net_to_host_u16 (mp->key_id), mp->key);
2569 vl_api_one_eid_table_details_t_handler_json (vl_api_one_eid_table_details_t
2572 vat_main_t *vam = &vat_main;
2573 vat_json_node_t *node = 0;
2576 if (VAT_JSON_ARRAY != vam->json_tree.type)
2578 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2579 vat_json_init_array (&vam->json_tree);
2581 node = vat_json_array_add (&vam->json_tree);
2583 vat_json_init_object (node);
2584 if (~0 == mp->locator_set_index)
2585 vat_json_object_add_uint (node, "action", mp->action);
2587 vat_json_object_add_uint (node, "locator_set_index",
2588 clib_net_to_host_u32 (mp->locator_set_index));
2590 vat_json_object_add_uint (node, "is_local", mp->is_local ? 1 : 0);
2591 eid = format (0, "%U", format_lisp_eid_vat,
2595 mp->seid, mp->seid_prefix_len, mp->is_src_dst);
2597 vat_json_object_add_string_copy (node, "eid", eid);
2598 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2599 vat_json_object_add_uint (node, "ttl", clib_net_to_host_u32 (mp->ttl));
2600 vat_json_object_add_uint (node, "authoritative", (mp->authoritative));
2604 vat_json_object_add_uint (node, "key_id",
2605 clib_net_to_host_u16 (mp->key_id));
2606 vat_json_object_add_string_copy (node, "key", mp->key);
2612 vl_api_one_eid_table_map_details_t_handler
2613 (vl_api_one_eid_table_map_details_t * mp)
2615 vat_main_t *vam = &vat_main;
2617 u8 *line = format (0, "%=10d%=10d",
2618 clib_net_to_host_u32 (mp->vni),
2619 clib_net_to_host_u32 (mp->dp_table));
2620 print (vam->ofp, "%v", line);
2625 vl_api_one_eid_table_map_details_t_handler_json
2626 (vl_api_one_eid_table_map_details_t * mp)
2628 vat_main_t *vam = &vat_main;
2629 vat_json_node_t *node = NULL;
2631 if (VAT_JSON_ARRAY != vam->json_tree.type)
2633 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2634 vat_json_init_array (&vam->json_tree);
2636 node = vat_json_array_add (&vam->json_tree);
2637 vat_json_init_object (node);
2638 vat_json_object_add_uint (node, "dp_table",
2639 clib_net_to_host_u32 (mp->dp_table));
2640 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2644 vl_api_one_eid_table_vni_details_t_handler
2645 (vl_api_one_eid_table_vni_details_t * mp)
2647 vat_main_t *vam = &vat_main;
2649 u8 *line = format (0, "%d", clib_net_to_host_u32 (mp->vni));
2650 print (vam->ofp, "%v", line);
2655 vl_api_one_eid_table_vni_details_t_handler_json
2656 (vl_api_one_eid_table_vni_details_t * mp)
2658 vat_main_t *vam = &vat_main;
2659 vat_json_node_t *node = NULL;
2661 if (VAT_JSON_ARRAY != vam->json_tree.type)
2663 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2664 vat_json_init_array (&vam->json_tree);
2666 node = vat_json_array_add (&vam->json_tree);
2667 vat_json_init_object (node);
2668 vat_json_object_add_uint (node, "vni", clib_net_to_host_u32 (mp->vni));
2672 vl_api_show_one_map_register_state_reply_t_handler
2673 (vl_api_show_one_map_register_state_reply_t * mp)
2675 vat_main_t *vam = &vat_main;
2676 int retval = clib_net_to_host_u32 (mp->retval);
2678 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2680 vam->retval = retval;
2681 vam->result_ready = 1;
2685 vl_api_show_one_map_register_state_reply_t_handler_json
2686 (vl_api_show_one_map_register_state_reply_t * mp)
2688 vat_main_t *vam = &vat_main;
2689 vat_json_node_t _node, *node = &_node;
2690 int retval = clib_net_to_host_u32 (mp->retval);
2692 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2694 vat_json_init_object (node);
2695 vat_json_object_add_string_copy (node, "state", s);
2697 vat_json_print (vam->ofp, node);
2698 vat_json_free (node);
2700 vam->retval = retval;
2701 vam->result_ready = 1;
2706 vl_api_show_one_rloc_probe_state_reply_t_handler
2707 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2709 vat_main_t *vam = &vat_main;
2710 int retval = clib_net_to_host_u32 (mp->retval);
2715 print (vam->ofp, "%s", mp->is_enabled ? "enabled" : "disabled");
2717 vam->retval = retval;
2718 vam->result_ready = 1;
2722 vl_api_show_one_rloc_probe_state_reply_t_handler_json
2723 (vl_api_show_one_rloc_probe_state_reply_t * mp)
2725 vat_main_t *vam = &vat_main;
2726 vat_json_node_t _node, *node = &_node;
2727 int retval = clib_net_to_host_u32 (mp->retval);
2729 u8 *s = format (0, "%s", mp->is_enabled ? "enabled" : "disabled");
2730 vat_json_init_object (node);
2731 vat_json_object_add_string_copy (node, "state", s);
2733 vat_json_print (vam->ofp, node);
2734 vat_json_free (node);
2736 vam->retval = retval;
2737 vam->result_ready = 1;
2742 api_gpe_fwd_entry_net_to_host (vl_api_gpe_fwd_entry_t * e)
2744 e->dp_table = clib_net_to_host_u32 (e->dp_table);
2745 e->fwd_entry_index = clib_net_to_host_u32 (e->fwd_entry_index);
2749 gpe_fwd_entries_get_reply_t_net_to_host
2750 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2754 mp->count = clib_net_to_host_u32 (mp->count);
2755 for (i = 0; i < mp->count; i++)
2757 api_gpe_fwd_entry_net_to_host (&mp->entries[i]);
2762 format_gpe_encap_mode (u8 * s, va_list * args)
2764 u32 mode = va_arg (*args, u32);
2769 return format (s, "lisp");
2771 return format (s, "vxlan");
2777 vl_api_gpe_get_encap_mode_reply_t_handler
2778 (vl_api_gpe_get_encap_mode_reply_t * mp)
2780 vat_main_t *vam = &vat_main;
2782 print (vam->ofp, "gpe mode: %U", format_gpe_encap_mode, mp->encap_mode);
2783 vam->retval = ntohl (mp->retval);
2784 vam->result_ready = 1;
2788 vl_api_gpe_get_encap_mode_reply_t_handler_json
2789 (vl_api_gpe_get_encap_mode_reply_t * mp)
2791 vat_main_t *vam = &vat_main;
2792 vat_json_node_t node;
2794 u8 *encap_mode = format (0, "%U", format_gpe_encap_mode, mp->encap_mode);
2795 vec_add1 (encap_mode, 0);
2797 vat_json_init_object (&node);
2798 vat_json_object_add_string_copy (&node, "gpe_mode", encap_mode);
2800 vec_free (encap_mode);
2801 vat_json_print (vam->ofp, &node);
2802 vat_json_free (&node);
2804 vam->retval = ntohl (mp->retval);
2805 vam->result_ready = 1;
2809 vl_api_gpe_fwd_entry_path_details_t_handler
2810 (vl_api_gpe_fwd_entry_path_details_t * mp)
2812 vat_main_t *vam = &vat_main;
2813 u8 *(*format_ip_address_fcn) (u8 *, va_list *) = 0;
2815 if (mp->lcl_loc.is_ip4)
2816 format_ip_address_fcn = format_ip4_address;
2818 format_ip_address_fcn = format_ip6_address;
2820 print (vam->ofp, "w:%d %30U %30U", mp->rmt_loc.weight,
2821 format_ip_address_fcn, &mp->lcl_loc,
2822 format_ip_address_fcn, &mp->rmt_loc);
2826 lisp_fill_locator_node (vat_json_node_t * n, vl_api_gpe_locator_t * loc)
2828 struct in6_addr ip6;
2833 clib_memcpy (&ip4, loc->addr, sizeof (ip4));
2834 vat_json_object_add_ip4 (n, "address", ip4);
2838 clib_memcpy (&ip6, loc->addr, sizeof (ip6));
2839 vat_json_object_add_ip6 (n, "address", ip6);
2841 vat_json_object_add_uint (n, "weight", loc->weight);
2845 vl_api_gpe_fwd_entry_path_details_t_handler_json
2846 (vl_api_gpe_fwd_entry_path_details_t * mp)
2848 vat_main_t *vam = &vat_main;
2849 vat_json_node_t *node = NULL;
2850 vat_json_node_t *loc_node;
2852 if (VAT_JSON_ARRAY != vam->json_tree.type)
2854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
2855 vat_json_init_array (&vam->json_tree);
2857 node = vat_json_array_add (&vam->json_tree);
2858 vat_json_init_object (node);
2860 loc_node = vat_json_object_add (node, "local_locator");
2861 vat_json_init_object (loc_node);
2862 lisp_fill_locator_node (loc_node, &mp->lcl_loc);
2864 loc_node = vat_json_object_add (node, "remote_locator");
2865 vat_json_init_object (loc_node);
2866 lisp_fill_locator_node (loc_node, &mp->rmt_loc);
2870 vl_api_gpe_fwd_entries_get_reply_t_handler
2871 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2873 vat_main_t *vam = &vat_main;
2875 int retval = clib_net_to_host_u32 (mp->retval);
2876 vl_api_gpe_fwd_entry_t *e;
2881 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2883 for (i = 0; i < mp->count; i++)
2885 e = &mp->entries[i];
2886 print (vam->ofp, "%10d %10d %U %40U", e->fwd_entry_index, e->dp_table,
2887 format_lisp_flat_eid, e->eid_type, e->leid, e->leid_prefix_len,
2888 format_lisp_flat_eid, e->eid_type, e->reid, e->reid_prefix_len);
2892 vam->retval = retval;
2893 vam->result_ready = 1;
2897 vl_api_gpe_fwd_entries_get_reply_t_handler_json
2898 (vl_api_gpe_fwd_entries_get_reply_t * mp)
2901 vat_main_t *vam = &vat_main;
2902 vat_json_node_t *e = 0, root;
2904 int retval = clib_net_to_host_u32 (mp->retval);
2905 vl_api_gpe_fwd_entry_t *fwd;
2910 gpe_fwd_entries_get_reply_t_net_to_host (mp);
2911 vat_json_init_array (&root);
2913 for (i = 0; i < mp->count; i++)
2915 e = vat_json_array_add (&root);
2916 fwd = &mp->entries[i];
2918 vat_json_init_object (e);
2919 vat_json_object_add_int (e, "fwd_entry_index", fwd->fwd_entry_index);
2920 vat_json_object_add_int (e, "dp_table", fwd->dp_table);
2922 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->leid,
2923 fwd->leid_prefix_len);
2925 vat_json_object_add_string_copy (e, "leid", s);
2928 s = format (0, "%U", format_lisp_flat_eid, fwd->eid_type, fwd->reid,
2929 fwd->reid_prefix_len);
2931 vat_json_object_add_string_copy (e, "reid", s);
2935 vat_json_print (vam->ofp, &root);
2936 vat_json_free (&root);
2939 vam->retval = retval;
2940 vam->result_ready = 1;
2944 vl_api_one_adjacencies_get_reply_t_handler
2945 (vl_api_one_adjacencies_get_reply_t * mp)
2947 vat_main_t *vam = &vat_main;
2949 int retval = clib_net_to_host_u32 (mp->retval);
2950 vl_api_one_adjacency_t *a;
2955 n = clib_net_to_host_u32 (mp->count);
2957 for (i = 0; i < n; i++)
2959 a = &mp->adjacencies[i];
2960 print (vam->ofp, "%U %40U",
2961 format_lisp_flat_eid, a->eid_type, a->leid, a->leid_prefix_len,
2962 format_lisp_flat_eid, a->eid_type, a->reid, a->reid_prefix_len);
2966 vam->retval = retval;
2967 vam->result_ready = 1;
2971 vl_api_one_adjacencies_get_reply_t_handler_json
2972 (vl_api_one_adjacencies_get_reply_t * mp)
2975 vat_main_t *vam = &vat_main;
2976 vat_json_node_t *e = 0, root;
2978 int retval = clib_net_to_host_u32 (mp->retval);
2979 vl_api_one_adjacency_t *a;
2984 n = clib_net_to_host_u32 (mp->count);
2985 vat_json_init_array (&root);
2987 for (i = 0; i < n; i++)
2989 e = vat_json_array_add (&root);
2990 a = &mp->adjacencies[i];
2992 vat_json_init_object (e);
2993 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->leid,
2994 a->leid_prefix_len);
2996 vat_json_object_add_string_copy (e, "leid", s);
2999 s = format (0, "%U", format_lisp_flat_eid, a->eid_type, a->reid,
3000 a->reid_prefix_len);
3002 vat_json_object_add_string_copy (e, "reid", s);
3006 vat_json_print (vam->ofp, &root);
3007 vat_json_free (&root);
3010 vam->retval = retval;
3011 vam->result_ready = 1;
3015 vl_api_one_map_server_details_t_handler (vl_api_one_map_server_details_t * mp)
3017 vat_main_t *vam = &vat_main;
3019 print (vam->ofp, "%=20U",
3020 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3025 vl_api_one_map_server_details_t_handler_json
3026 (vl_api_one_map_server_details_t * mp)
3028 vat_main_t *vam = &vat_main;
3029 vat_json_node_t *node = NULL;
3030 struct in6_addr ip6;
3033 if (VAT_JSON_ARRAY != vam->json_tree.type)
3035 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3036 vat_json_init_array (&vam->json_tree);
3038 node = vat_json_array_add (&vam->json_tree);
3040 vat_json_init_object (node);
3043 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3044 vat_json_object_add_ip6 (node, "map-server", ip6);
3048 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3049 vat_json_object_add_ip4 (node, "map-server", ip4);
3054 vl_api_one_map_resolver_details_t_handler (vl_api_one_map_resolver_details_t
3057 vat_main_t *vam = &vat_main;
3059 print (vam->ofp, "%=20U",
3060 mp->is_ipv6 ? format_ip6_address : format_ip4_address,
3065 vl_api_one_map_resolver_details_t_handler_json
3066 (vl_api_one_map_resolver_details_t * mp)
3068 vat_main_t *vam = &vat_main;
3069 vat_json_node_t *node = NULL;
3070 struct in6_addr ip6;
3073 if (VAT_JSON_ARRAY != vam->json_tree.type)
3075 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3076 vat_json_init_array (&vam->json_tree);
3078 node = vat_json_array_add (&vam->json_tree);
3080 vat_json_init_object (node);
3083 clib_memcpy (&ip6, mp->ip_address, sizeof (ip6));
3084 vat_json_object_add_ip6 (node, "map resolver", ip6);
3088 clib_memcpy (&ip4, mp->ip_address, sizeof (ip4));
3089 vat_json_object_add_ip4 (node, "map resolver", ip4);
3094 vl_api_show_one_status_reply_t_handler (vl_api_show_one_status_reply_t * mp)
3096 vat_main_t *vam = &vat_main;
3097 i32 retval = ntohl (mp->retval);
3101 print (vam->ofp, "feature: %s\ngpe: %s",
3102 mp->feature_status ? "enabled" : "disabled",
3103 mp->gpe_status ? "enabled" : "disabled");
3106 vam->retval = retval;
3107 vam->result_ready = 1;
3111 vl_api_show_one_status_reply_t_handler_json
3112 (vl_api_show_one_status_reply_t * mp)
3114 vat_main_t *vam = &vat_main;
3115 vat_json_node_t node;
3116 u8 *gpe_status = NULL;
3117 u8 *feature_status = NULL;
3119 gpe_status = format (0, "%s", mp->gpe_status ? "enabled" : "disabled");
3120 feature_status = format (0, "%s",
3121 mp->feature_status ? "enabled" : "disabled");
3122 vec_add1 (gpe_status, 0);
3123 vec_add1 (feature_status, 0);
3125 vat_json_init_object (&node);
3126 vat_json_object_add_string_copy (&node, "gpe_status", gpe_status);
3127 vat_json_object_add_string_copy (&node, "feature_status", feature_status);
3129 vec_free (gpe_status);
3130 vec_free (feature_status);
3132 vat_json_print (vam->ofp, &node);
3133 vat_json_free (&node);
3135 vam->retval = ntohl (mp->retval);
3136 vam->result_ready = 1;
3140 vl_api_one_get_map_request_itr_rlocs_reply_t_handler
3141 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3143 vat_main_t *vam = &vat_main;
3144 i32 retval = ntohl (mp->retval);
3148 print (vam->ofp, "%=20s", mp->locator_set_name);
3151 vam->retval = retval;
3152 vam->result_ready = 1;
3156 vl_api_one_get_map_request_itr_rlocs_reply_t_handler_json
3157 (vl_api_one_get_map_request_itr_rlocs_reply_t * mp)
3159 vat_main_t *vam = &vat_main;
3160 vat_json_node_t *node = NULL;
3162 if (VAT_JSON_ARRAY != vam->json_tree.type)
3164 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3165 vat_json_init_array (&vam->json_tree);
3167 node = vat_json_array_add (&vam->json_tree);
3169 vat_json_init_object (node);
3170 vat_json_object_add_string_copy (node, "itr-rlocs", mp->locator_set_name);
3172 vat_json_print (vam->ofp, node);
3173 vat_json_free (node);
3175 vam->retval = ntohl (mp->retval);
3176 vam->result_ready = 1;
3180 format_lisp_map_request_mode (u8 * s, va_list * args)
3182 u32 mode = va_arg (*args, u32);
3187 return format (0, "dst-only");
3189 return format (0, "src-dst");
3195 vl_api_show_one_map_request_mode_reply_t_handler
3196 (vl_api_show_one_map_request_mode_reply_t * mp)
3198 vat_main_t *vam = &vat_main;
3199 i32 retval = ntohl (mp->retval);
3203 u32 mode = mp->mode;
3204 print (vam->ofp, "map_request_mode: %U",
3205 format_lisp_map_request_mode, mode);
3208 vam->retval = retval;
3209 vam->result_ready = 1;
3213 vl_api_show_one_map_request_mode_reply_t_handler_json
3214 (vl_api_show_one_map_request_mode_reply_t * mp)
3216 vat_main_t *vam = &vat_main;
3217 vat_json_node_t node;
3222 s = format (0, "%U", format_lisp_map_request_mode, mode);
3225 vat_json_init_object (&node);
3226 vat_json_object_add_string_copy (&node, "map_request_mode", s);
3227 vat_json_print (vam->ofp, &node);
3228 vat_json_free (&node);
3231 vam->retval = ntohl (mp->retval);
3232 vam->result_ready = 1;
3236 vl_api_show_one_pitr_reply_t_handler (vl_api_show_one_pitr_reply_t * mp)
3238 vat_main_t *vam = &vat_main;
3239 i32 retval = ntohl (mp->retval);
3243 print (vam->ofp, "%-20s%-16s",
3244 mp->status ? "enabled" : "disabled",
3245 mp->status ? (char *) mp->locator_set_name : "");
3248 vam->retval = retval;
3249 vam->result_ready = 1;
3253 vl_api_show_one_pitr_reply_t_handler_json (vl_api_show_one_pitr_reply_t * mp)
3255 vat_main_t *vam = &vat_main;
3256 vat_json_node_t node;
3259 status = format (0, "%s", mp->status ? "enabled" : "disabled");
3260 vec_add1 (status, 0);
3262 vat_json_init_object (&node);
3263 vat_json_object_add_string_copy (&node, "status", status);
3266 vat_json_object_add_string_copy (&node, "locator_set",
3267 mp->locator_set_name);
3272 vat_json_print (vam->ofp, &node);
3273 vat_json_free (&node);
3275 vam->retval = ntohl (mp->retval);
3276 vam->result_ready = 1;
3280 format_policer_type (u8 * s, va_list * va)
3282 u32 i = va_arg (*va, u32);
3284 if (i == SSE2_QOS_POLICER_TYPE_1R2C)
3285 s = format (s, "1r2c");
3286 else if (i == SSE2_QOS_POLICER_TYPE_1R3C_RFC_2697)
3287 s = format (s, "1r3c");
3288 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_2698)
3289 s = format (s, "2r3c-2698");
3290 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_4115)
3291 s = format (s, "2r3c-4115");
3292 else if (i == SSE2_QOS_POLICER_TYPE_2R3C_RFC_MEF5CF1)
3293 s = format (s, "2r3c-mef5cf1");
3295 s = format (s, "ILLEGAL");
3300 format_policer_rate_type (u8 * s, va_list * va)
3302 u32 i = va_arg (*va, u32);
3304 if (i == SSE2_QOS_RATE_KBPS)
3305 s = format (s, "kbps");
3306 else if (i == SSE2_QOS_RATE_PPS)
3307 s = format (s, "pps");
3309 s = format (s, "ILLEGAL");
3314 format_policer_round_type (u8 * s, va_list * va)
3316 u32 i = va_arg (*va, u32);
3318 if (i == SSE2_QOS_ROUND_TO_CLOSEST)
3319 s = format (s, "closest");
3320 else if (i == SSE2_QOS_ROUND_TO_UP)
3321 s = format (s, "up");
3322 else if (i == SSE2_QOS_ROUND_TO_DOWN)
3323 s = format (s, "down");
3325 s = format (s, "ILLEGAL");
3330 format_policer_action_type (u8 * s, va_list * va)
3332 u32 i = va_arg (*va, u32);
3334 if (i == SSE2_QOS_ACTION_DROP)
3335 s = format (s, "drop");
3336 else if (i == SSE2_QOS_ACTION_TRANSMIT)
3337 s = format (s, "transmit");
3338 else if (i == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3339 s = format (s, "mark-and-transmit");
3341 s = format (s, "ILLEGAL");
3346 format_dscp (u8 * s, va_list * va)
3348 u32 i = va_arg (*va, u32);
3353 #define _(v,f,str) case VNET_DSCP_##f: t = str; break;
3357 return format (s, "ILLEGAL");
3359 s = format (s, "%s", t);
3364 vl_api_policer_details_t_handler (vl_api_policer_details_t * mp)
3366 vat_main_t *vam = &vat_main;
3367 u8 *conform_dscp_str, *exceed_dscp_str, *violate_dscp_str;
3369 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3370 conform_dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3372 conform_dscp_str = format (0, "");
3374 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3375 exceed_dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3377 exceed_dscp_str = format (0, "");
3379 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3380 violate_dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3382 violate_dscp_str = format (0, "");
3384 print (vam->ofp, "Name \"%s\", type %U, cir %u, eir %u, cb %u, eb %u, "
3385 "rate type %U, round type %U, %s rate, %s color-aware, "
3386 "cir %u tok/period, pir %u tok/period, scale %u, cur lim %u, "
3387 "cur bkt %u, ext lim %u, ext bkt %u, last update %llu"
3388 "conform action %U%s, exceed action %U%s, violate action %U%s",
3390 format_policer_type, mp->type,
3393 clib_net_to_host_u64 (mp->cb),
3394 clib_net_to_host_u64 (mp->eb),
3395 format_policer_rate_type, mp->rate_type,
3396 format_policer_round_type, mp->round_type,
3397 mp->single_rate ? "single" : "dual",
3398 mp->color_aware ? "is" : "not",
3399 ntohl (mp->cir_tokens_per_period),
3400 ntohl (mp->pir_tokens_per_period),
3402 ntohl (mp->current_limit),
3403 ntohl (mp->current_bucket),
3404 ntohl (mp->extended_limit),
3405 ntohl (mp->extended_bucket),
3406 clib_net_to_host_u64 (mp->last_update_time),
3407 format_policer_action_type, mp->conform_action_type,
3409 format_policer_action_type, mp->exceed_action_type,
3411 format_policer_action_type, mp->violate_action_type,
3414 vec_free (conform_dscp_str);
3415 vec_free (exceed_dscp_str);
3416 vec_free (violate_dscp_str);
3419 static void vl_api_policer_details_t_handler_json
3420 (vl_api_policer_details_t * mp)
3422 vat_main_t *vam = &vat_main;
3423 vat_json_node_t *node;
3424 u8 *rate_type_str, *round_type_str, *type_str;
3425 u8 *conform_action_str, *exceed_action_str, *violate_action_str;
3427 rate_type_str = format (0, "%U", format_policer_rate_type, mp->rate_type);
3429 format (0, "%U", format_policer_round_type, mp->round_type);
3430 type_str = format (0, "%U", format_policer_type, mp->type);
3431 conform_action_str = format (0, "%U", format_policer_action_type,
3432 mp->conform_action_type);
3433 exceed_action_str = format (0, "%U", format_policer_action_type,
3434 mp->exceed_action_type);
3435 violate_action_str = format (0, "%U", format_policer_action_type,
3436 mp->violate_action_type);
3438 if (VAT_JSON_ARRAY != vam->json_tree.type)
3440 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3441 vat_json_init_array (&vam->json_tree);
3443 node = vat_json_array_add (&vam->json_tree);
3445 vat_json_init_object (node);
3446 vat_json_object_add_string_copy (node, "name", mp->name);
3447 vat_json_object_add_uint (node, "cir", ntohl (mp->cir));
3448 vat_json_object_add_uint (node, "eir", ntohl (mp->eir));
3449 vat_json_object_add_uint (node, "cb", ntohl (mp->cb));
3450 vat_json_object_add_uint (node, "eb", ntohl (mp->eb));
3451 vat_json_object_add_string_copy (node, "rate_type", rate_type_str);
3452 vat_json_object_add_string_copy (node, "round_type", round_type_str);
3453 vat_json_object_add_string_copy (node, "type", type_str);
3454 vat_json_object_add_uint (node, "single_rate", mp->single_rate);
3455 vat_json_object_add_uint (node, "color_aware", mp->color_aware);
3456 vat_json_object_add_uint (node, "scale", ntohl (mp->scale));
3457 vat_json_object_add_uint (node, "cir_tokens_per_period",
3458 ntohl (mp->cir_tokens_per_period));
3459 vat_json_object_add_uint (node, "eir_tokens_per_period",
3460 ntohl (mp->pir_tokens_per_period));
3461 vat_json_object_add_uint (node, "current_limit", ntohl (mp->current_limit));
3462 vat_json_object_add_uint (node, "current_bucket",
3463 ntohl (mp->current_bucket));
3464 vat_json_object_add_uint (node, "extended_limit",
3465 ntohl (mp->extended_limit));
3466 vat_json_object_add_uint (node, "extended_bucket",
3467 ntohl (mp->extended_bucket));
3468 vat_json_object_add_uint (node, "last_update_time",
3469 ntohl (mp->last_update_time));
3470 vat_json_object_add_string_copy (node, "conform_action",
3471 conform_action_str);
3472 if (mp->conform_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3474 u8 *dscp_str = format (0, "%U", format_dscp, mp->conform_dscp);
3475 vat_json_object_add_string_copy (node, "conform_dscp", dscp_str);
3476 vec_free (dscp_str);
3478 vat_json_object_add_string_copy (node, "exceed_action", exceed_action_str);
3479 if (mp->exceed_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3481 u8 *dscp_str = format (0, "%U", format_dscp, mp->exceed_dscp);
3482 vat_json_object_add_string_copy (node, "exceed_dscp", dscp_str);
3483 vec_free (dscp_str);
3485 vat_json_object_add_string_copy (node, "violate_action",
3486 violate_action_str);
3487 if (mp->violate_action_type == SSE2_QOS_ACTION_MARK_AND_TRANSMIT)
3489 u8 *dscp_str = format (0, "%U", format_dscp, mp->violate_dscp);
3490 vat_json_object_add_string_copy (node, "violate_dscp", dscp_str);
3491 vec_free (dscp_str);
3494 vec_free (rate_type_str);
3495 vec_free (round_type_str);
3496 vec_free (type_str);
3497 vec_free (conform_action_str);
3498 vec_free (exceed_action_str);
3499 vec_free (violate_action_str);
3503 vl_api_classify_table_ids_reply_t_handler (vl_api_classify_table_ids_reply_t *
3506 vat_main_t *vam = &vat_main;
3507 int i, count = ntohl (mp->count);
3510 print (vam->ofp, "classify table ids (%d) : ", count);
3511 for (i = 0; i < count; i++)
3513 print (vam->ofp, "%d", ntohl (mp->ids[i]));
3514 print (vam->ofp, (i < count - 1) ? "," : "");
3516 vam->retval = ntohl (mp->retval);
3517 vam->result_ready = 1;
3521 vl_api_classify_table_ids_reply_t_handler_json
3522 (vl_api_classify_table_ids_reply_t * mp)
3524 vat_main_t *vam = &vat_main;
3525 int i, count = ntohl (mp->count);
3529 vat_json_node_t node;
3531 vat_json_init_object (&node);
3532 for (i = 0; i < count; i++)
3534 vat_json_object_add_uint (&node, "table_id", ntohl (mp->ids[i]));
3536 vat_json_print (vam->ofp, &node);
3537 vat_json_free (&node);
3539 vam->retval = ntohl (mp->retval);
3540 vam->result_ready = 1;
3544 vl_api_classify_table_by_interface_reply_t_handler
3545 (vl_api_classify_table_by_interface_reply_t * mp)
3547 vat_main_t *vam = &vat_main;
3550 table_id = ntohl (mp->l2_table_id);
3552 print (vam->ofp, "l2 table id : %d", table_id);
3554 print (vam->ofp, "l2 table id : No input ACL tables configured");
3555 table_id = ntohl (mp->ip4_table_id);
3557 print (vam->ofp, "ip4 table id : %d", table_id);
3559 print (vam->ofp, "ip4 table id : No input ACL tables configured");
3560 table_id = ntohl (mp->ip6_table_id);
3562 print (vam->ofp, "ip6 table id : %d", table_id);
3564 print (vam->ofp, "ip6 table id : No input ACL tables configured");
3565 vam->retval = ntohl (mp->retval);
3566 vam->result_ready = 1;
3570 vl_api_classify_table_by_interface_reply_t_handler_json
3571 (vl_api_classify_table_by_interface_reply_t * mp)
3573 vat_main_t *vam = &vat_main;
3574 vat_json_node_t node;
3576 vat_json_init_object (&node);
3578 vat_json_object_add_int (&node, "l2_table_id", ntohl (mp->l2_table_id));
3579 vat_json_object_add_int (&node, "ip4_table_id", ntohl (mp->ip4_table_id));
3580 vat_json_object_add_int (&node, "ip6_table_id", ntohl (mp->ip6_table_id));
3582 vat_json_print (vam->ofp, &node);
3583 vat_json_free (&node);
3585 vam->retval = ntohl (mp->retval);
3586 vam->result_ready = 1;
3589 static void vl_api_policer_add_del_reply_t_handler
3590 (vl_api_policer_add_del_reply_t * mp)
3592 vat_main_t *vam = &vat_main;
3593 i32 retval = ntohl (mp->retval);
3594 if (vam->async_mode)
3596 vam->async_errors += (retval < 0);
3600 vam->retval = retval;
3601 vam->result_ready = 1;
3602 if (retval == 0 && mp->policer_index != 0xFFFFFFFF)
3604 * Note: this is just barely thread-safe, depends on
3605 * the main thread spinning waiting for an answer...
3607 errmsg ("policer index %d", ntohl (mp->policer_index));
3611 static void vl_api_policer_add_del_reply_t_handler_json
3612 (vl_api_policer_add_del_reply_t * mp)
3614 vat_main_t *vam = &vat_main;
3615 vat_json_node_t node;
3617 vat_json_init_object (&node);
3618 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3619 vat_json_object_add_uint (&node, "policer_index",
3620 ntohl (mp->policer_index));
3622 vat_json_print (vam->ofp, &node);
3623 vat_json_free (&node);
3625 vam->retval = ntohl (mp->retval);
3626 vam->result_ready = 1;
3629 /* Format hex dump. */
3631 format_hex_bytes (u8 * s, va_list * va)
3633 u8 *bytes = va_arg (*va, u8 *);
3634 int n_bytes = va_arg (*va, int);
3637 /* Print short or long form depending on byte count. */
3638 uword short_form = n_bytes <= 32;
3639 uword indent = format_get_indent (s);
3644 for (i = 0; i < n_bytes; i++)
3646 if (!short_form && (i % 32) == 0)
3647 s = format (s, "%08x: ", i);
3648 s = format (s, "%02x", bytes[i]);
3649 if (!short_form && ((i + 1) % 32) == 0 && (i + 1) < n_bytes)
3650 s = format (s, "\n%U", format_white_space, indent);
3657 vl_api_classify_table_info_reply_t_handler (vl_api_classify_table_info_reply_t
3660 vat_main_t *vam = &vat_main;
3661 i32 retval = ntohl (mp->retval);
3664 print (vam->ofp, "classify table info :");
3665 print (vam->ofp, "sessions: %d nexttbl: %d nextnode: %d",
3666 ntohl (mp->active_sessions), ntohl (mp->next_table_index),
3667 ntohl (mp->miss_next_index));
3668 print (vam->ofp, "nbuckets: %d skip: %d match: %d",
3669 ntohl (mp->nbuckets), ntohl (mp->skip_n_vectors),
3670 ntohl (mp->match_n_vectors));
3671 print (vam->ofp, "mask: %U", format_hex_bytes, mp->mask,
3672 ntohl (mp->mask_length));
3674 vam->retval = retval;
3675 vam->result_ready = 1;
3679 vl_api_classify_table_info_reply_t_handler_json
3680 (vl_api_classify_table_info_reply_t * mp)
3682 vat_main_t *vam = &vat_main;
3683 vat_json_node_t node;
3685 i32 retval = ntohl (mp->retval);
3688 vat_json_init_object (&node);
3690 vat_json_object_add_int (&node, "sessions",
3691 ntohl (mp->active_sessions));
3692 vat_json_object_add_int (&node, "nexttbl",
3693 ntohl (mp->next_table_index));
3694 vat_json_object_add_int (&node, "nextnode",
3695 ntohl (mp->miss_next_index));
3696 vat_json_object_add_int (&node, "nbuckets", ntohl (mp->nbuckets));
3697 vat_json_object_add_int (&node, "skip", ntohl (mp->skip_n_vectors));
3698 vat_json_object_add_int (&node, "match", ntohl (mp->match_n_vectors));
3699 u8 *s = format (0, "%U%c", format_hex_bytes, mp->mask,
3700 ntohl (mp->mask_length), 0);
3701 vat_json_object_add_string_copy (&node, "mask", s);
3703 vat_json_print (vam->ofp, &node);
3704 vat_json_free (&node);
3706 vam->retval = ntohl (mp->retval);
3707 vam->result_ready = 1;
3711 vl_api_classify_session_details_t_handler (vl_api_classify_session_details_t *
3714 vat_main_t *vam = &vat_main;
3716 print (vam->ofp, "next_index: %d advance: %d opaque: %d ",
3717 ntohl (mp->hit_next_index), ntohl (mp->advance),
3718 ntohl (mp->opaque_index));
3719 print (vam->ofp, "mask: %U", format_hex_bytes, mp->match,
3720 ntohl (mp->match_length));
3724 vl_api_classify_session_details_t_handler_json
3725 (vl_api_classify_session_details_t * mp)
3727 vat_main_t *vam = &vat_main;
3728 vat_json_node_t *node = NULL;
3730 if (VAT_JSON_ARRAY != vam->json_tree.type)
3732 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3733 vat_json_init_array (&vam->json_tree);
3735 node = vat_json_array_add (&vam->json_tree);
3737 vat_json_init_object (node);
3738 vat_json_object_add_int (node, "next_index", ntohl (mp->hit_next_index));
3739 vat_json_object_add_int (node, "advance", ntohl (mp->advance));
3740 vat_json_object_add_int (node, "opaque", ntohl (mp->opaque_index));
3742 format (0, "%U%c", format_hex_bytes, mp->match, ntohl (mp->match_length),
3744 vat_json_object_add_string_copy (node, "match", s);
3747 static void vl_api_pg_create_interface_reply_t_handler
3748 (vl_api_pg_create_interface_reply_t * mp)
3750 vat_main_t *vam = &vat_main;
3752 vam->retval = ntohl (mp->retval);
3753 vam->result_ready = 1;
3756 static void vl_api_pg_create_interface_reply_t_handler_json
3757 (vl_api_pg_create_interface_reply_t * mp)
3759 vat_main_t *vam = &vat_main;
3760 vat_json_node_t node;
3762 i32 retval = ntohl (mp->retval);
3765 vat_json_init_object (&node);
3767 vat_json_object_add_int (&node, "sw_if_index", ntohl (mp->sw_if_index));
3769 vat_json_print (vam->ofp, &node);
3770 vat_json_free (&node);
3772 vam->retval = ntohl (mp->retval);
3773 vam->result_ready = 1;
3776 static void vl_api_policer_classify_details_t_handler
3777 (vl_api_policer_classify_details_t * mp)
3779 vat_main_t *vam = &vat_main;
3781 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3782 ntohl (mp->table_index));
3785 static void vl_api_policer_classify_details_t_handler_json
3786 (vl_api_policer_classify_details_t * mp)
3788 vat_main_t *vam = &vat_main;
3789 vat_json_node_t *node;
3791 if (VAT_JSON_ARRAY != vam->json_tree.type)
3793 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3794 vat_json_init_array (&vam->json_tree);
3796 node = vat_json_array_add (&vam->json_tree);
3798 vat_json_init_object (node);
3799 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3800 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3803 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler
3804 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3806 vat_main_t *vam = &vat_main;
3807 i32 retval = ntohl (mp->retval);
3808 if (vam->async_mode)
3810 vam->async_errors += (retval < 0);
3814 vam->retval = retval;
3815 vam->sw_if_index = ntohl (mp->sw_if_index);
3816 vam->result_ready = 1;
3820 static void vl_api_ipsec_gre_add_del_tunnel_reply_t_handler_json
3821 (vl_api_ipsec_gre_add_del_tunnel_reply_t * mp)
3823 vat_main_t *vam = &vat_main;
3824 vat_json_node_t node;
3826 vat_json_init_object (&node);
3827 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
3828 vat_json_object_add_uint (&node, "sw_if_index", ntohl (mp->sw_if_index));
3830 vat_json_print (vam->ofp, &node);
3831 vat_json_free (&node);
3833 vam->retval = ntohl (mp->retval);
3834 vam->result_ready = 1;
3837 static void vl_api_flow_classify_details_t_handler
3838 (vl_api_flow_classify_details_t * mp)
3840 vat_main_t *vam = &vat_main;
3842 print (vam->ofp, "%10d%20d", ntohl (mp->sw_if_index),
3843 ntohl (mp->table_index));
3846 static void vl_api_flow_classify_details_t_handler_json
3847 (vl_api_flow_classify_details_t * mp)
3849 vat_main_t *vam = &vat_main;
3850 vat_json_node_t *node;
3852 if (VAT_JSON_ARRAY != vam->json_tree.type)
3854 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
3855 vat_json_init_array (&vam->json_tree);
3857 node = vat_json_array_add (&vam->json_tree);
3859 vat_json_init_object (node);
3860 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
3861 vat_json_object_add_uint (node, "table_index", ntohl (mp->table_index));
3866 #define vl_api_vnet_ip4_fib_counters_t_endian vl_noop_handler
3867 #define vl_api_vnet_ip4_fib_counters_t_print vl_noop_handler
3868 #define vl_api_vnet_ip6_fib_counters_t_endian vl_noop_handler
3869 #define vl_api_vnet_ip6_fib_counters_t_print vl_noop_handler
3870 #define vl_api_vnet_ip4_nbr_counters_t_endian vl_noop_handler
3871 #define vl_api_vnet_ip4_nbr_counters_t_print vl_noop_handler
3872 #define vl_api_vnet_ip6_nbr_counters_t_endian vl_noop_handler
3873 #define vl_api_vnet_ip6_nbr_counters_t_print vl_noop_handler
3874 #define vl_api_one_adjacencies_get_reply_t_endian vl_noop_handler
3875 #define vl_api_one_adjacencies_get_reply_t_print vl_noop_handler
3878 * Generate boilerplate reply handlers, which
3879 * dig the return value out of the xxx_reply_t API message,
3880 * stick it into vam->retval, and set vam->result_ready
3882 * Could also do this by pointing N message decode slots at
3883 * a single function, but that could break in subtle ways.
3886 #define foreach_standard_reply_retval_handler \
3887 _(sw_interface_set_flags_reply) \
3888 _(sw_interface_add_del_address_reply) \
3889 _(sw_interface_set_table_reply) \
3890 _(sw_interface_set_mpls_enable_reply) \
3891 _(sw_interface_set_vpath_reply) \
3892 _(sw_interface_set_vxlan_bypass_reply) \
3893 _(sw_interface_set_l2_bridge_reply) \
3894 _(bridge_domain_add_del_reply) \
3895 _(sw_interface_set_l2_xconnect_reply) \
3896 _(l2fib_add_del_reply) \
3897 _(ip_add_del_route_reply) \
3898 _(ip_mroute_add_del_reply) \
3899 _(mpls_route_add_del_reply) \
3900 _(mpls_ip_bind_unbind_reply) \
3901 _(proxy_arp_add_del_reply) \
3902 _(proxy_arp_intfc_enable_disable_reply) \
3903 _(sw_interface_set_unnumbered_reply) \
3904 _(ip_neighbor_add_del_reply) \
3905 _(reset_vrf_reply) \
3906 _(oam_add_del_reply) \
3907 _(reset_fib_reply) \
3908 _(dhcp_proxy_config_reply) \
3909 _(dhcp_proxy_set_vss_reply) \
3910 _(dhcp_client_config_reply) \
3911 _(set_ip_flow_hash_reply) \
3912 _(sw_interface_ip6_enable_disable_reply) \
3913 _(sw_interface_ip6_set_link_local_address_reply) \
3914 _(sw_interface_ip6nd_ra_prefix_reply) \
3915 _(sw_interface_ip6nd_ra_config_reply) \
3916 _(set_arp_neighbor_limit_reply) \
3917 _(l2_patch_add_del_reply) \
3918 _(sr_policy_add_reply) \
3919 _(sr_policy_mod_reply) \
3920 _(sr_policy_del_reply) \
3921 _(sr_localsid_add_del_reply) \
3922 _(sr_steering_add_del_reply) \
3923 _(classify_add_del_session_reply) \
3924 _(classify_set_interface_ip_table_reply) \
3925 _(classify_set_interface_l2_tables_reply) \
3926 _(l2tpv3_set_tunnel_cookies_reply) \
3927 _(l2tpv3_interface_enable_disable_reply) \
3928 _(l2tpv3_set_lookup_key_reply) \
3929 _(l2_fib_clear_table_reply) \
3930 _(l2_interface_efp_filter_reply) \
3931 _(l2_interface_vlan_tag_rewrite_reply) \
3932 _(modify_vhost_user_if_reply) \
3933 _(delete_vhost_user_if_reply) \
3934 _(want_ip4_arp_events_reply) \
3935 _(want_ip6_nd_events_reply) \
3936 _(input_acl_set_interface_reply) \
3937 _(ipsec_spd_add_del_reply) \
3938 _(ipsec_interface_add_del_spd_reply) \
3939 _(ipsec_spd_add_del_entry_reply) \
3940 _(ipsec_sad_add_del_entry_reply) \
3941 _(ipsec_sa_set_key_reply) \
3942 _(ikev2_profile_add_del_reply) \
3943 _(ikev2_profile_set_auth_reply) \
3944 _(ikev2_profile_set_id_reply) \
3945 _(ikev2_profile_set_ts_reply) \
3946 _(ikev2_set_local_key_reply) \
3947 _(ikev2_set_responder_reply) \
3948 _(ikev2_set_ike_transforms_reply) \
3949 _(ikev2_set_esp_transforms_reply) \
3950 _(ikev2_set_sa_lifetime_reply) \
3951 _(ikev2_initiate_sa_init_reply) \
3952 _(ikev2_initiate_del_ike_sa_reply) \
3953 _(ikev2_initiate_del_child_sa_reply) \
3954 _(ikev2_initiate_rekey_child_sa_reply) \
3955 _(delete_loopback_reply) \
3956 _(bd_ip_mac_add_del_reply) \
3957 _(map_del_domain_reply) \
3958 _(map_add_del_rule_reply) \
3959 _(want_interface_events_reply) \
3960 _(want_stats_reply) \
3961 _(cop_interface_enable_disable_reply) \
3962 _(cop_whitelist_enable_disable_reply) \
3963 _(sw_interface_clear_stats_reply) \
3964 _(ioam_enable_reply) \
3965 _(ioam_disable_reply) \
3966 _(one_add_del_locator_reply) \
3967 _(one_add_del_local_eid_reply) \
3968 _(one_add_del_remote_mapping_reply) \
3969 _(one_add_del_adjacency_reply) \
3970 _(one_add_del_map_resolver_reply) \
3971 _(one_add_del_map_server_reply) \
3972 _(one_enable_disable_reply) \
3973 _(one_rloc_probe_enable_disable_reply) \
3974 _(one_map_register_enable_disable_reply) \
3975 _(one_pitr_set_locator_set_reply) \
3976 _(one_map_request_mode_reply) \
3977 _(one_add_del_map_request_itr_rlocs_reply) \
3978 _(one_eid_table_add_del_map_reply) \
3979 _(gpe_add_del_fwd_entry_reply) \
3980 _(gpe_enable_disable_reply) \
3981 _(gpe_set_encap_mode_reply) \
3982 _(gpe_add_del_iface_reply) \
3983 _(vxlan_gpe_add_del_tunnel_reply) \
3984 _(af_packet_delete_reply) \
3985 _(policer_classify_set_interface_reply) \
3986 _(netmap_create_reply) \
3987 _(netmap_delete_reply) \
3988 _(set_ipfix_exporter_reply) \
3989 _(set_ipfix_classify_stream_reply) \
3990 _(ipfix_classify_table_add_del_reply) \
3991 _(flow_classify_set_interface_reply) \
3992 _(sw_interface_span_enable_disable_reply) \
3993 _(pg_capture_reply) \
3994 _(pg_enable_disable_reply) \
3995 _(ip_source_and_port_range_check_add_del_reply) \
3996 _(ip_source_and_port_range_check_interface_add_del_reply)\
3997 _(delete_subif_reply) \
3998 _(l2_interface_pbb_tag_rewrite_reply) \
4000 _(feature_enable_disable_reply) \
4001 _(sw_interface_tag_add_del_reply) \
4002 _(sw_interface_set_mtu_reply)
4005 static void vl_api_##n##_t_handler \
4006 (vl_api_##n##_t * mp) \
4008 vat_main_t * vam = &vat_main; \
4009 i32 retval = ntohl(mp->retval); \
4010 if (vam->async_mode) { \
4011 vam->async_errors += (retval < 0); \
4013 vam->retval = retval; \
4014 vam->result_ready = 1; \
4017 foreach_standard_reply_retval_handler;
4021 static void vl_api_##n##_t_handler_json \
4022 (vl_api_##n##_t * mp) \
4024 vat_main_t * vam = &vat_main; \
4025 vat_json_node_t node; \
4026 vat_json_init_object(&node); \
4027 vat_json_object_add_int(&node, "retval", ntohl(mp->retval)); \
4028 vat_json_print(vam->ofp, &node); \
4029 vam->retval = ntohl(mp->retval); \
4030 vam->result_ready = 1; \
4032 foreach_standard_reply_retval_handler;
4036 * Table of message reply handlers, must include boilerplate handlers
4040 #define foreach_vpe_api_reply_msg \
4041 _(CREATE_LOOPBACK_REPLY, create_loopback_reply) \
4042 _(CREATE_LOOPBACK_INSTANCE_REPLY, create_loopback_instance_reply) \
4043 _(SW_INTERFACE_DETAILS, sw_interface_details) \
4044 _(SW_INTERFACE_SET_FLAGS_REPLY, sw_interface_set_flags_reply) \
4045 _(CONTROL_PING_REPLY, control_ping_reply) \
4046 _(CLI_REPLY, cli_reply) \
4047 _(CLI_INBAND_REPLY, cli_inband_reply) \
4048 _(SW_INTERFACE_ADD_DEL_ADDRESS_REPLY, \
4049 sw_interface_add_del_address_reply) \
4050 _(SW_INTERFACE_SET_TABLE_REPLY, sw_interface_set_table_reply) \
4051 _(SW_INTERFACE_SET_MPLS_ENABLE_REPLY, sw_interface_set_mpls_enable_reply) \
4052 _(SW_INTERFACE_SET_VPATH_REPLY, sw_interface_set_vpath_reply) \
4053 _(SW_INTERFACE_SET_VXLAN_BYPASS_REPLY, sw_interface_set_vxlan_bypass_reply) \
4054 _(SW_INTERFACE_SET_L2_XCONNECT_REPLY, \
4055 sw_interface_set_l2_xconnect_reply) \
4056 _(SW_INTERFACE_SET_L2_BRIDGE_REPLY, \
4057 sw_interface_set_l2_bridge_reply) \
4058 _(BRIDGE_DOMAIN_ADD_DEL_REPLY, bridge_domain_add_del_reply) \
4059 _(BRIDGE_DOMAIN_DETAILS, bridge_domain_details) \
4060 _(BRIDGE_DOMAIN_SW_IF_DETAILS, bridge_domain_sw_if_details) \
4061 _(L2FIB_ADD_DEL_REPLY, l2fib_add_del_reply) \
4062 _(L2_FLAGS_REPLY, l2_flags_reply) \
4063 _(BRIDGE_FLAGS_REPLY, bridge_flags_reply) \
4064 _(TAP_CONNECT_REPLY, tap_connect_reply) \
4065 _(TAP_MODIFY_REPLY, tap_modify_reply) \
4066 _(TAP_DELETE_REPLY, tap_delete_reply) \
4067 _(SW_INTERFACE_TAP_DETAILS, sw_interface_tap_details) \
4068 _(IP_ADD_DEL_ROUTE_REPLY, ip_add_del_route_reply) \
4069 _(IP_MROUTE_ADD_DEL_REPLY, ip_mroute_add_del_reply) \
4070 _(MPLS_ROUTE_ADD_DEL_REPLY, mpls_route_add_del_reply) \
4071 _(MPLS_IP_BIND_UNBIND_REPLY, mpls_ip_bind_unbind_reply) \
4072 _(PROXY_ARP_ADD_DEL_REPLY, proxy_arp_add_del_reply) \
4073 _(PROXY_ARP_INTFC_ENABLE_DISABLE_REPLY, \
4074 proxy_arp_intfc_enable_disable_reply) \
4075 _(MPLS_TUNNEL_ADD_DEL_REPLY, mpls_tunnel_add_del_reply) \
4076 _(SW_INTERFACE_SET_UNNUMBERED_REPLY, \
4077 sw_interface_set_unnumbered_reply) \
4078 _(IP_NEIGHBOR_ADD_DEL_REPLY, ip_neighbor_add_del_reply) \
4079 _(RESET_VRF_REPLY, reset_vrf_reply) \
4080 _(CREATE_VLAN_SUBIF_REPLY, create_vlan_subif_reply) \
4081 _(CREATE_SUBIF_REPLY, create_subif_reply) \
4082 _(OAM_ADD_DEL_REPLY, oam_add_del_reply) \
4083 _(RESET_FIB_REPLY, reset_fib_reply) \
4084 _(DHCP_PROXY_CONFIG_REPLY, dhcp_proxy_config_reply) \
4085 _(DHCP_PROXY_SET_VSS_REPLY, dhcp_proxy_set_vss_reply) \
4086 _(DHCP_PROXY_DETAILS, dhcp_proxy_details) \
4087 _(DHCP_CLIENT_CONFIG_REPLY, dhcp_client_config_reply) \
4088 _(SET_IP_FLOW_HASH_REPLY, set_ip_flow_hash_reply) \
4089 _(SW_INTERFACE_IP6_ENABLE_DISABLE_REPLY, \
4090 sw_interface_ip6_enable_disable_reply) \
4091 _(SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS_REPLY, \
4092 sw_interface_ip6_set_link_local_address_reply) \
4093 _(SW_INTERFACE_IP6ND_RA_PREFIX_REPLY, \
4094 sw_interface_ip6nd_ra_prefix_reply) \
4095 _(SW_INTERFACE_IP6ND_RA_CONFIG_REPLY, \
4096 sw_interface_ip6nd_ra_config_reply) \
4097 _(SET_ARP_NEIGHBOR_LIMIT_REPLY, set_arp_neighbor_limit_reply) \
4098 _(L2_PATCH_ADD_DEL_REPLY, l2_patch_add_del_reply) \
4099 _(SR_POLICY_ADD_REPLY, sr_policy_add_reply) \
4100 _(SR_POLICY_MOD_REPLY, sr_policy_mod_reply) \
4101 _(SR_POLICY_DEL_REPLY, sr_policy_del_reply) \
4102 _(SR_LOCALSID_ADD_DEL_REPLY, sr_localsid_add_del_reply) \
4103 _(SR_STEERING_ADD_DEL_REPLY, sr_steering_add_del_reply) \
4104 _(CLASSIFY_ADD_DEL_TABLE_REPLY, classify_add_del_table_reply) \
4105 _(CLASSIFY_ADD_DEL_SESSION_REPLY, classify_add_del_session_reply) \
4106 _(CLASSIFY_SET_INTERFACE_IP_TABLE_REPLY, \
4107 classify_set_interface_ip_table_reply) \
4108 _(CLASSIFY_SET_INTERFACE_L2_TABLES_REPLY, \
4109 classify_set_interface_l2_tables_reply) \
4110 _(GET_NODE_INDEX_REPLY, get_node_index_reply) \
4111 _(ADD_NODE_NEXT_REPLY, add_node_next_reply) \
4112 _(L2TPV3_CREATE_TUNNEL_REPLY, l2tpv3_create_tunnel_reply) \
4113 _(L2TPV3_SET_TUNNEL_COOKIES_REPLY, l2tpv3_set_tunnel_cookies_reply) \
4114 _(L2TPV3_INTERFACE_ENABLE_DISABLE_REPLY, \
4115 l2tpv3_interface_enable_disable_reply) \
4116 _(L2TPV3_SET_LOOKUP_KEY_REPLY, l2tpv3_set_lookup_key_reply) \
4117 _(SW_IF_L2TPV3_TUNNEL_DETAILS, sw_if_l2tpv3_tunnel_details) \
4118 _(VXLAN_ADD_DEL_TUNNEL_REPLY, vxlan_add_del_tunnel_reply) \
4119 _(VXLAN_TUNNEL_DETAILS, vxlan_tunnel_details) \
4120 _(GRE_ADD_DEL_TUNNEL_REPLY, gre_add_del_tunnel_reply) \
4121 _(GRE_TUNNEL_DETAILS, gre_tunnel_details) \
4122 _(L2_FIB_CLEAR_TABLE_REPLY, l2_fib_clear_table_reply) \
4123 _(L2_INTERFACE_EFP_FILTER_REPLY, l2_interface_efp_filter_reply) \
4124 _(L2_INTERFACE_VLAN_TAG_REWRITE_REPLY, l2_interface_vlan_tag_rewrite_reply) \
4125 _(SW_INTERFACE_VHOST_USER_DETAILS, sw_interface_vhost_user_details) \
4126 _(CREATE_VHOST_USER_IF_REPLY, create_vhost_user_if_reply) \
4127 _(MODIFY_VHOST_USER_IF_REPLY, modify_vhost_user_if_reply) \
4128 _(DELETE_VHOST_USER_IF_REPLY, delete_vhost_user_if_reply) \
4129 _(SHOW_VERSION_REPLY, show_version_reply) \
4130 _(L2_FIB_TABLE_ENTRY, l2_fib_table_entry) \
4131 _(VXLAN_GPE_ADD_DEL_TUNNEL_REPLY, vxlan_gpe_add_del_tunnel_reply) \
4132 _(VXLAN_GPE_TUNNEL_DETAILS, vxlan_gpe_tunnel_details) \
4133 _(INTERFACE_NAME_RENUMBER_REPLY, interface_name_renumber_reply) \
4134 _(WANT_IP4_ARP_EVENTS_REPLY, want_ip4_arp_events_reply) \
4135 _(IP4_ARP_EVENT, ip4_arp_event) \
4136 _(WANT_IP6_ND_EVENTS_REPLY, want_ip6_nd_events_reply) \
4137 _(IP6_ND_EVENT, ip6_nd_event) \
4138 _(INPUT_ACL_SET_INTERFACE_REPLY, input_acl_set_interface_reply) \
4139 _(IP_ADDRESS_DETAILS, ip_address_details) \
4140 _(IP_DETAILS, ip_details) \
4141 _(IPSEC_SPD_ADD_DEL_REPLY, ipsec_spd_add_del_reply) \
4142 _(IPSEC_INTERFACE_ADD_DEL_SPD_REPLY, ipsec_interface_add_del_spd_reply) \
4143 _(IPSEC_SPD_ADD_DEL_ENTRY_REPLY, ipsec_spd_add_del_entry_reply) \
4144 _(IPSEC_SAD_ADD_DEL_ENTRY_REPLY, ipsec_sad_add_del_entry_reply) \
4145 _(IPSEC_SA_SET_KEY_REPLY, ipsec_sa_set_key_reply) \
4146 _(IKEV2_PROFILE_ADD_DEL_REPLY, ikev2_profile_add_del_reply) \
4147 _(IKEV2_PROFILE_SET_AUTH_REPLY, ikev2_profile_set_auth_reply) \
4148 _(IKEV2_PROFILE_SET_ID_REPLY, ikev2_profile_set_id_reply) \
4149 _(IKEV2_PROFILE_SET_TS_REPLY, ikev2_profile_set_ts_reply) \
4150 _(IKEV2_SET_LOCAL_KEY_REPLY, ikev2_set_local_key_reply) \
4151 _(IKEV2_SET_RESPONDER_REPLY, ikev2_set_responder_reply) \
4152 _(IKEV2_SET_IKE_TRANSFORMS_REPLY, ikev2_set_ike_transforms_reply) \
4153 _(IKEV2_SET_ESP_TRANSFORMS_REPLY, ikev2_set_esp_transforms_reply) \
4154 _(IKEV2_SET_SA_LIFETIME_REPLY, ikev2_set_sa_lifetime_reply) \
4155 _(IKEV2_INITIATE_SA_INIT_REPLY, ikev2_initiate_sa_init_reply) \
4156 _(IKEV2_INITIATE_DEL_IKE_SA_REPLY, ikev2_initiate_del_ike_sa_reply) \
4157 _(IKEV2_INITIATE_DEL_CHILD_SA_REPLY, ikev2_initiate_del_child_sa_reply) \
4158 _(IKEV2_INITIATE_REKEY_CHILD_SA_REPLY, ikev2_initiate_rekey_child_sa_reply) \
4159 _(DELETE_LOOPBACK_REPLY, delete_loopback_reply) \
4160 _(BD_IP_MAC_ADD_DEL_REPLY, bd_ip_mac_add_del_reply) \
4161 _(DHCP_COMPL_EVENT, dhcp_compl_event) \
4162 _(MAP_ADD_DOMAIN_REPLY, map_add_domain_reply) \
4163 _(MAP_DEL_DOMAIN_REPLY, map_del_domain_reply) \
4164 _(MAP_ADD_DEL_RULE_REPLY, map_add_del_rule_reply) \
4165 _(MAP_DOMAIN_DETAILS, map_domain_details) \
4166 _(MAP_RULE_DETAILS, map_rule_details) \
4167 _(WANT_INTERFACE_EVENTS_REPLY, want_interface_events_reply) \
4168 _(WANT_STATS_REPLY, want_stats_reply) \
4169 _(GET_FIRST_MSG_ID_REPLY, get_first_msg_id_reply) \
4170 _(COP_INTERFACE_ENABLE_DISABLE_REPLY, cop_interface_enable_disable_reply) \
4171 _(COP_WHITELIST_ENABLE_DISABLE_REPLY, cop_whitelist_enable_disable_reply) \
4172 _(GET_NODE_GRAPH_REPLY, get_node_graph_reply) \
4173 _(SW_INTERFACE_CLEAR_STATS_REPLY, sw_interface_clear_stats_reply) \
4174 _(IOAM_ENABLE_REPLY, ioam_enable_reply) \
4175 _(IOAM_DISABLE_REPLY, ioam_disable_reply) \
4176 _(ONE_ADD_DEL_LOCATOR_SET_REPLY, one_add_del_locator_set_reply) \
4177 _(ONE_ADD_DEL_LOCATOR_REPLY, one_add_del_locator_reply) \
4178 _(ONE_ADD_DEL_LOCAL_EID_REPLY, one_add_del_local_eid_reply) \
4179 _(ONE_ADD_DEL_REMOTE_MAPPING_REPLY, one_add_del_remote_mapping_reply) \
4180 _(ONE_ADD_DEL_ADJACENCY_REPLY, one_add_del_adjacency_reply) \
4181 _(ONE_ADD_DEL_MAP_RESOLVER_REPLY, one_add_del_map_resolver_reply) \
4182 _(ONE_ADD_DEL_MAP_SERVER_REPLY, one_add_del_map_server_reply) \
4183 _(ONE_ENABLE_DISABLE_REPLY, one_enable_disable_reply) \
4184 _(ONE_MAP_REGISTER_ENABLE_DISABLE_REPLY, \
4185 one_map_register_enable_disable_reply) \
4186 _(ONE_RLOC_PROBE_ENABLE_DISABLE_REPLY, \
4187 one_rloc_probe_enable_disable_reply) \
4188 _(ONE_PITR_SET_LOCATOR_SET_REPLY, one_pitr_set_locator_set_reply) \
4189 _(ONE_MAP_REQUEST_MODE_REPLY, one_map_request_mode_reply) \
4190 _(ONE_EID_TABLE_ADD_DEL_MAP_REPLY, one_eid_table_add_del_map_reply) \
4191 _(ONE_LOCATOR_SET_DETAILS, one_locator_set_details) \
4192 _(ONE_LOCATOR_DETAILS, one_locator_details) \
4193 _(ONE_EID_TABLE_DETAILS, one_eid_table_details) \
4194 _(ONE_EID_TABLE_MAP_DETAILS, one_eid_table_map_details) \
4195 _(ONE_EID_TABLE_VNI_DETAILS, one_eid_table_vni_details) \
4196 _(ONE_MAP_RESOLVER_DETAILS, one_map_resolver_details) \
4197 _(ONE_MAP_SERVER_DETAILS, one_map_server_details) \
4198 _(ONE_ADJACENCIES_GET_REPLY, one_adjacencies_get_reply) \
4199 _(GPE_SET_ENCAP_MODE_REPLY, gpe_set_encap_mode_reply) \
4200 _(GPE_GET_ENCAP_MODE_REPLY, gpe_get_encap_mode_reply) \
4201 _(GPE_ADD_DEL_IFACE_REPLY, gpe_add_del_iface_reply) \
4202 _(GPE_ENABLE_DISABLE_REPLY, gpe_enable_disable_reply) \
4203 _(GPE_ADD_DEL_FWD_ENTRY_REPLY, gpe_add_del_fwd_entry_reply) \
4204 _(GPE_FWD_ENTRIES_GET_REPLY, gpe_fwd_entries_get_reply) \
4205 _(GPE_FWD_ENTRY_PATH_DETAILS, \
4206 gpe_fwd_entry_path_details) \
4207 _(SHOW_ONE_STATUS_REPLY, show_one_status_reply) \
4208 _(ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS_REPLY, \
4209 one_add_del_map_request_itr_rlocs_reply) \
4210 _(ONE_GET_MAP_REQUEST_ITR_RLOCS_REPLY, \
4211 one_get_map_request_itr_rlocs_reply) \
4212 _(SHOW_ONE_PITR_REPLY, show_one_pitr_reply) \
4213 _(SHOW_ONE_MAP_REQUEST_MODE_REPLY, show_one_map_request_mode_reply) \
4214 _(SHOW_ONE_RLOC_PROBE_STATE_REPLY, show_one_rloc_probe_state_reply) \
4215 _(SHOW_ONE_MAP_REGISTER_STATE_REPLY, \
4216 show_one_map_register_state_reply) \
4217 _(AF_PACKET_CREATE_REPLY, af_packet_create_reply) \
4218 _(AF_PACKET_DELETE_REPLY, af_packet_delete_reply) \
4219 _(POLICER_ADD_DEL_REPLY, policer_add_del_reply) \
4220 _(POLICER_DETAILS, policer_details) \
4221 _(POLICER_CLASSIFY_SET_INTERFACE_REPLY, policer_classify_set_interface_reply) \
4222 _(POLICER_CLASSIFY_DETAILS, policer_classify_details) \
4223 _(NETMAP_CREATE_REPLY, netmap_create_reply) \
4224 _(NETMAP_DELETE_REPLY, netmap_delete_reply) \
4225 _(MPLS_TUNNEL_DETAILS, mpls_tunnel_details) \
4226 _(MPLS_FIB_DETAILS, mpls_fib_details) \
4227 _(CLASSIFY_TABLE_IDS_REPLY, classify_table_ids_reply) \
4228 _(CLASSIFY_TABLE_BY_INTERFACE_REPLY, classify_table_by_interface_reply) \
4229 _(CLASSIFY_TABLE_INFO_REPLY, classify_table_info_reply) \
4230 _(CLASSIFY_SESSION_DETAILS, classify_session_details) \
4231 _(SET_IPFIX_EXPORTER_REPLY, set_ipfix_exporter_reply) \
4232 _(IPFIX_EXPORTER_DETAILS, ipfix_exporter_details) \
4233 _(SET_IPFIX_CLASSIFY_STREAM_REPLY, set_ipfix_classify_stream_reply) \
4234 _(IPFIX_CLASSIFY_STREAM_DETAILS, ipfix_classify_stream_details) \
4235 _(IPFIX_CLASSIFY_TABLE_ADD_DEL_REPLY, ipfix_classify_table_add_del_reply) \
4236 _(IPFIX_CLASSIFY_TABLE_DETAILS, ipfix_classify_table_details) \
4237 _(FLOW_CLASSIFY_SET_INTERFACE_REPLY, flow_classify_set_interface_reply) \
4238 _(FLOW_CLASSIFY_DETAILS, flow_classify_details) \
4239 _(SW_INTERFACE_SPAN_ENABLE_DISABLE_REPLY, sw_interface_span_enable_disable_reply) \
4240 _(SW_INTERFACE_SPAN_DETAILS, sw_interface_span_details) \
4241 _(GET_NEXT_INDEX_REPLY, get_next_index_reply) \
4242 _(PG_CREATE_INTERFACE_REPLY, pg_create_interface_reply) \
4243 _(PG_CAPTURE_REPLY, pg_capture_reply) \
4244 _(PG_ENABLE_DISABLE_REPLY, pg_enable_disable_reply) \
4245 _(IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL_REPLY, \
4246 ip_source_and_port_range_check_add_del_reply) \
4247 _(IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL_REPLY, \
4248 ip_source_and_port_range_check_interface_add_del_reply) \
4249 _(IPSEC_GRE_ADD_DEL_TUNNEL_REPLY, ipsec_gre_add_del_tunnel_reply) \
4250 _(IPSEC_GRE_TUNNEL_DETAILS, ipsec_gre_tunnel_details) \
4251 _(DELETE_SUBIF_REPLY, delete_subif_reply) \
4252 _(L2_INTERFACE_PBB_TAG_REWRITE_REPLY, l2_interface_pbb_tag_rewrite_reply) \
4253 _(PUNT_REPLY, punt_reply) \
4254 _(IP_FIB_DETAILS, ip_fib_details) \
4255 _(IP6_FIB_DETAILS, ip6_fib_details) \
4256 _(FEATURE_ENABLE_DISABLE_REPLY, feature_enable_disable_reply) \
4257 _(SW_INTERFACE_TAG_ADD_DEL_REPLY, sw_interface_tag_add_del_reply) \
4258 _(L2_XCONNECT_DETAILS, l2_xconnect_details) \
4259 _(SW_INTERFACE_SET_MTU_REPLY, sw_interface_set_mtu_reply) \
4260 _(IP_NEIGHBOR_DETAILS, ip_neighbor_details) \
4261 _(SW_INTERFACE_GET_TABLE_REPLY, sw_interface_get_table_reply)
4263 #define foreach_standalone_reply_msg \
4264 _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
4265 _(VNET_INTERFACE_COUNTERS, vnet_interface_counters) \
4266 _(VNET_IP4_FIB_COUNTERS, vnet_ip4_fib_counters) \
4267 _(VNET_IP6_FIB_COUNTERS, vnet_ip6_fib_counters) \
4268 _(VNET_IP4_NBR_COUNTERS, vnet_ip4_nbr_counters) \
4269 _(VNET_IP6_NBR_COUNTERS, vnet_ip6_nbr_counters)
4278 #define STR_VTR_OP_CASE(op) \
4279 case L2_VTR_ ## op: \
4283 str_vtr_op (u32 vtr_op)
4287 STR_VTR_OP_CASE (DISABLED);
4288 STR_VTR_OP_CASE (PUSH_1);
4289 STR_VTR_OP_CASE (PUSH_2);
4290 STR_VTR_OP_CASE (POP_1);
4291 STR_VTR_OP_CASE (POP_2);
4292 STR_VTR_OP_CASE (TRANSLATE_1_1);
4293 STR_VTR_OP_CASE (TRANSLATE_1_2);
4294 STR_VTR_OP_CASE (TRANSLATE_2_1);
4295 STR_VTR_OP_CASE (TRANSLATE_2_2);
4302 dump_sub_interface_table (vat_main_t * vam)
4304 const sw_interface_subif_t *sub = NULL;
4306 if (vam->json_output)
4309 ("JSON output supported only for VPE API calls and dump_stats_table");
4314 "%-30s%-12s%-11s%-7s%-5s%-9s%-9s%-6s%-8s%-10s%-10s",
4315 "Interface", "sw_if_index",
4316 "sub id", "dot1ad", "tags", "outer id",
4317 "inner id", "exact", "default", "outer any", "inner any");
4319 vec_foreach (sub, vam->sw_if_subif_table)
4322 "%-30s%-12d%-11d%-7s%-5d%-9d%-9d%-6d%-8d%-10d%-10d",
4323 sub->interface_name,
4325 sub->sub_id, sub->sub_dot1ad ? "dot1ad" : "dot1q",
4326 sub->sub_number_of_tags, sub->sub_outer_vlan_id,
4327 sub->sub_inner_vlan_id, sub->sub_exact_match, sub->sub_default,
4328 sub->sub_outer_vlan_id_any, sub->sub_inner_vlan_id_any);
4329 if (sub->vtr_op != L2_VTR_DISABLED)
4332 " vlan-tag-rewrite - op: %-14s [ dot1q: %d "
4333 "tag1: %d tag2: %d ]",
4334 str_vtr_op (sub->vtr_op), sub->vtr_push_dot1q,
4335 sub->vtr_tag1, sub->vtr_tag2);
4343 name_sort_cmp (void *a1, void *a2)
4345 name_sort_t *n1 = a1;
4346 name_sort_t *n2 = a2;
4348 return strcmp ((char *) n1->name, (char *) n2->name);
4352 dump_interface_table (vat_main_t * vam)
4355 name_sort_t *nses = 0, *ns;
4357 if (vam->json_output)
4360 ("JSON output supported only for VPE API calls and dump_stats_table");
4365 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4367 vec_add2 (nses, ns, 1);
4368 ns->name = (u8 *)(p->key);
4369 ns->value = (u32) p->value[0];
4373 vec_sort_with_function (nses, name_sort_cmp);
4375 print (vam->ofp, "%-25s%-15s", "Interface", "sw_if_index");
4376 vec_foreach (ns, nses)
4378 print (vam->ofp, "%-25s%-15d", ns->name, ns->value);
4385 dump_ip_table (vat_main_t * vam, int is_ipv6)
4387 const ip_details_t *det = NULL;
4388 const ip_address_details_t *address = NULL;
4391 print (vam->ofp, "%-12s", "sw_if_index");
4393 vec_foreach (det, vam->ip_details_by_sw_if_index[is_ipv6])
4400 print (vam->ofp, "%-12d", i);
4401 print (vam->ofp, " %-30s%-13s", "Address", "Prefix length");
4406 vec_foreach (address, det->addr)
4410 is_ipv6 ? format_ip6_address : format_ip4_address,
4411 address->ip, address->prefix_length);
4419 dump_ipv4_table (vat_main_t * vam)
4421 if (vam->json_output)
4424 ("JSON output supported only for VPE API calls and dump_stats_table");
4428 return dump_ip_table (vam, 0);
4432 dump_ipv6_table (vat_main_t * vam)
4434 if (vam->json_output)
4437 ("JSON output supported only for VPE API calls and dump_stats_table");
4441 return dump_ip_table (vam, 1);
4445 counter_type_to_str (u8 counter_type, u8 is_combined)
4449 switch (counter_type)
4451 case VNET_INTERFACE_COUNTER_DROP:
4453 case VNET_INTERFACE_COUNTER_PUNT:
4455 case VNET_INTERFACE_COUNTER_IP4:
4457 case VNET_INTERFACE_COUNTER_IP6:
4459 case VNET_INTERFACE_COUNTER_RX_NO_BUF:
4461 case VNET_INTERFACE_COUNTER_RX_MISS:
4463 case VNET_INTERFACE_COUNTER_RX_ERROR:
4465 case VNET_INTERFACE_COUNTER_TX_ERROR:
4468 return "INVALID-COUNTER-TYPE";
4473 switch (counter_type)
4475 case VNET_INTERFACE_COUNTER_RX:
4477 case VNET_INTERFACE_COUNTER_TX:
4480 return "INVALID-COUNTER-TYPE";
4486 dump_stats_table (vat_main_t * vam)
4488 vat_json_node_t node;
4489 vat_json_node_t *msg_array;
4490 vat_json_node_t *msg;
4491 vat_json_node_t *counter_array;
4492 vat_json_node_t *counter;
4493 interface_counter_t c;
4495 ip4_fib_counter_t *c4;
4496 ip6_fib_counter_t *c6;
4497 ip4_nbr_counter_t *n4;
4498 ip6_nbr_counter_t *n6;
4501 if (!vam->json_output)
4503 clib_warning ("dump_stats_table supported only in JSON format");
4507 vat_json_init_object (&node);
4509 /* interface counters */
4510 msg_array = vat_json_object_add (&node, "interface_counters");
4511 vat_json_init_array (msg_array);
4512 for (i = 0; i < vec_len (vam->simple_interface_counters); i++)
4514 msg = vat_json_array_add (msg_array);
4515 vat_json_init_object (msg);
4516 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4517 (u8 *) counter_type_to_str (i, 0));
4518 vat_json_object_add_int (msg, "is_combined", 0);
4519 counter_array = vat_json_object_add (msg, "data");
4520 vat_json_init_array (counter_array);
4521 for (j = 0; j < vec_len (vam->simple_interface_counters[i]); j++)
4523 packets = vam->simple_interface_counters[i][j];
4524 vat_json_array_add_uint (counter_array, packets);
4527 for (i = 0; i < vec_len (vam->combined_interface_counters); i++)
4529 msg = vat_json_array_add (msg_array);
4530 vat_json_init_object (msg);
4531 vat_json_object_add_string_copy (msg, "vnet_counter_type",
4532 (u8 *) counter_type_to_str (i, 1));
4533 vat_json_object_add_int (msg, "is_combined", 1);
4534 counter_array = vat_json_object_add (msg, "data");
4535 vat_json_init_array (counter_array);
4536 for (j = 0; j < vec_len (vam->combined_interface_counters[i]); j++)
4538 c = vam->combined_interface_counters[i][j];
4539 counter = vat_json_array_add (counter_array);
4540 vat_json_init_object (counter);
4541 vat_json_object_add_uint (counter, "packets", c.packets);
4542 vat_json_object_add_uint (counter, "bytes", c.bytes);
4546 /* ip4 fib counters */
4547 msg_array = vat_json_object_add (&node, "ip4_fib_counters");
4548 vat_json_init_array (msg_array);
4549 for (i = 0; i < vec_len (vam->ip4_fib_counters); i++)
4551 msg = vat_json_array_add (msg_array);
4552 vat_json_init_object (msg);
4553 vat_json_object_add_uint (msg, "vrf_id",
4554 vam->ip4_fib_counters_vrf_id_by_index[i]);
4555 counter_array = vat_json_object_add (msg, "c");
4556 vat_json_init_array (counter_array);
4557 for (j = 0; j < vec_len (vam->ip4_fib_counters[i]); j++)
4559 counter = vat_json_array_add (counter_array);
4560 vat_json_init_object (counter);
4561 c4 = &vam->ip4_fib_counters[i][j];
4562 vat_json_object_add_ip4 (counter, "address", c4->address);
4563 vat_json_object_add_uint (counter, "address_length",
4564 c4->address_length);
4565 vat_json_object_add_uint (counter, "packets", c4->packets);
4566 vat_json_object_add_uint (counter, "bytes", c4->bytes);
4570 /* ip6 fib counters */
4571 msg_array = vat_json_object_add (&node, "ip6_fib_counters");
4572 vat_json_init_array (msg_array);
4573 for (i = 0; i < vec_len (vam->ip6_fib_counters); i++)
4575 msg = vat_json_array_add (msg_array);
4576 vat_json_init_object (msg);
4577 vat_json_object_add_uint (msg, "vrf_id",
4578 vam->ip6_fib_counters_vrf_id_by_index[i]);
4579 counter_array = vat_json_object_add (msg, "c");
4580 vat_json_init_array (counter_array);
4581 for (j = 0; j < vec_len (vam->ip6_fib_counters[i]); j++)
4583 counter = vat_json_array_add (counter_array);
4584 vat_json_init_object (counter);
4585 c6 = &vam->ip6_fib_counters[i][j];
4586 vat_json_object_add_ip6 (counter, "address", c6->address);
4587 vat_json_object_add_uint (counter, "address_length",
4588 c6->address_length);
4589 vat_json_object_add_uint (counter, "packets", c6->packets);
4590 vat_json_object_add_uint (counter, "bytes", c6->bytes);
4594 /* ip4 nbr counters */
4595 msg_array = vat_json_object_add (&node, "ip4_nbr_counters");
4596 vat_json_init_array (msg_array);
4597 for (i = 0; i < vec_len (vam->ip4_nbr_counters); i++)
4599 msg = vat_json_array_add (msg_array);
4600 vat_json_init_object (msg);
4601 vat_json_object_add_uint (msg, "sw_if_index", i);
4602 counter_array = vat_json_object_add (msg, "c");
4603 vat_json_init_array (counter_array);
4604 for (j = 0; j < vec_len (vam->ip4_nbr_counters[i]); j++)
4606 counter = vat_json_array_add (counter_array);
4607 vat_json_init_object (counter);
4608 n4 = &vam->ip4_nbr_counters[i][j];
4609 vat_json_object_add_ip4 (counter, "address", n4->address);
4610 vat_json_object_add_uint (counter, "link-type", n4->linkt);
4611 vat_json_object_add_uint (counter, "packets", n4->packets);
4612 vat_json_object_add_uint (counter, "bytes", n4->bytes);
4616 /* ip6 nbr counters */
4617 msg_array = vat_json_object_add (&node, "ip6_nbr_counters");
4618 vat_json_init_array (msg_array);
4619 for (i = 0; i < vec_len (vam->ip6_nbr_counters); i++)
4621 msg = vat_json_array_add (msg_array);
4622 vat_json_init_object (msg);
4623 vat_json_object_add_uint (msg, "sw_if_index", i);
4624 counter_array = vat_json_object_add (msg, "c");
4625 vat_json_init_array (counter_array);
4626 for (j = 0; j < vec_len (vam->ip6_nbr_counters[i]); j++)
4628 counter = vat_json_array_add (counter_array);
4629 vat_json_init_object (counter);
4630 n6 = &vam->ip6_nbr_counters[i][j];
4631 vat_json_object_add_ip6 (counter, "address", n6->address);
4632 vat_json_object_add_uint (counter, "packets", n6->packets);
4633 vat_json_object_add_uint (counter, "bytes", n6->bytes);
4637 vat_json_print (vam->ofp, &node);
4638 vat_json_free (&node);
4644 exec (vat_main_t * vam)
4646 api_main_t *am = &api_main;
4647 vl_api_cli_request_t *mp;
4651 unformat_input_t *i = vam->input;
4653 if (vec_len (i->buffer) == 0)
4656 if (vam->exec_mode == 0 && unformat (i, "mode"))
4661 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4668 M (CLI_REQUEST, mp);
4671 * Copy cmd into shared memory.
4672 * In order for the CLI command to work, it
4673 * must be a vector ending in \n, not a C-string ending
4676 pthread_mutex_lock (&am->vlib_rp->mutex);
4677 oldheap = svm_push_data_heap (am->vlib_rp);
4679 vec_validate (cmd, vec_len (vam->input->buffer) - 1);
4680 clib_memcpy (cmd, vam->input->buffer, vec_len (vam->input->buffer));
4682 svm_pop_heap (oldheap);
4683 pthread_mutex_unlock (&am->vlib_rp->mutex);
4685 mp->cmd_in_shmem = (u64) cmd;
4687 timeout = vat_time_now (vam) + 10.0;
4689 while (vat_time_now (vam) < timeout)
4691 if (vam->result_ready == 1)
4694 if (vam->shmem_result != NULL)
4695 print (vam->ofp, "%s", vam->shmem_result);
4696 pthread_mutex_lock (&am->vlib_rp->mutex);
4697 oldheap = svm_push_data_heap (am->vlib_rp);
4699 free_me = (u8 *) vam->shmem_result;
4702 svm_pop_heap (oldheap);
4703 pthread_mutex_unlock (&am->vlib_rp->mutex);
4711 * Future replacement of exec() that passes CLI buffers directly in
4712 * the API messages instead of an additional shared memory area.
4715 exec_inband (vat_main_t * vam)
4717 vl_api_cli_inband_t *mp;
4718 unformat_input_t *i = vam->input;
4721 if (vec_len (i->buffer) == 0)
4724 if (vam->exec_mode == 0 && unformat (i, "mode"))
4729 if (vam->exec_mode == 1 && (unformat (i, "exit") || unformat (i, "quit")))
4736 * In order for the CLI command to work, it
4737 * must be a vector ending in \n, not a C-string ending
4740 u32 len = vec_len (vam->input->buffer);
4741 M2 (CLI_INBAND, mp, len);
4742 clib_memcpy (mp->cmd, vam->input->buffer, len);
4743 mp->length = htonl (len);
4746 W2 (ret, print (vam->ofp, "%s", vam->cmd_reply));
4751 api_create_loopback (vat_main_t * vam)
4753 unformat_input_t *i = vam->input;
4754 vl_api_create_loopback_t *mp;
4755 vl_api_create_loopback_instance_t *mp_lbi;
4758 u8 is_specified = 0;
4759 u32 user_instance = 0;
4762 memset (mac_address, 0, sizeof (mac_address));
4764 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4766 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
4768 if (unformat (i, "instance %d", &user_instance))
4776 M (CREATE_LOOPBACK_INSTANCE, mp_lbi);
4777 mp_lbi->is_specified = is_specified;
4779 mp_lbi->user_instance = htonl (user_instance);
4781 clib_memcpy (mp_lbi->mac_address, mac_address, sizeof (mac_address));
4786 /* Construct the API message */
4787 M (CREATE_LOOPBACK, mp);
4789 clib_memcpy (mp->mac_address, mac_address, sizeof (mac_address));
4798 api_delete_loopback (vat_main_t * vam)
4800 unformat_input_t *i = vam->input;
4801 vl_api_delete_loopback_t *mp;
4802 u32 sw_if_index = ~0;
4805 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4807 if (unformat (i, "sw_if_index %d", &sw_if_index))
4813 if (sw_if_index == ~0)
4815 errmsg ("missing sw_if_index");
4819 /* Construct the API message */
4820 M (DELETE_LOOPBACK, mp);
4821 mp->sw_if_index = ntohl (sw_if_index);
4829 api_want_stats (vat_main_t * vam)
4831 unformat_input_t *i = vam->input;
4832 vl_api_want_stats_t *mp;
4836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4838 if (unformat (i, "enable"))
4840 else if (unformat (i, "disable"))
4848 errmsg ("missing enable|disable");
4853 mp->enable_disable = enable;
4861 api_want_interface_events (vat_main_t * vam)
4863 unformat_input_t *i = vam->input;
4864 vl_api_want_interface_events_t *mp;
4868 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
4870 if (unformat (i, "enable"))
4872 else if (unformat (i, "disable"))
4880 errmsg ("missing enable|disable");
4884 M (WANT_INTERFACE_EVENTS, mp);
4885 mp->enable_disable = enable;
4887 vam->interface_event_display = enable;
4895 /* Note: non-static, called once to set up the initial intfc table */
4897 api_sw_interface_dump (vat_main_t * vam)
4899 vl_api_sw_interface_dump_t *mp;
4900 vl_api_control_ping_t *mp_ping;
4902 name_sort_t *nses = 0, *ns;
4903 sw_interface_subif_t *sub = NULL;
4906 /* Toss the old name table */
4908 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
4910 vec_add2 (nses, ns, 1);
4911 ns->name = (u8 *)(p->key);
4912 ns->value = (u32) p->value[0];
4916 hash_free (vam->sw_if_index_by_interface_name);
4918 vec_foreach (ns, nses) vec_free (ns->name);
4922 vec_foreach (sub, vam->sw_if_subif_table)
4924 vec_free (sub->interface_name);
4926 vec_free (vam->sw_if_subif_table);
4928 /* recreate the interface name hash table */
4929 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
4931 /* Get list of ethernets */
4932 M (SW_INTERFACE_DUMP, mp);
4933 mp->name_filter_valid = 1;
4934 strncpy ((char *) mp->name_filter, "Ether", sizeof (mp->name_filter) - 1);
4937 /* and local / loopback interfaces */
4938 M (SW_INTERFACE_DUMP, mp);
4939 mp->name_filter_valid = 1;
4940 strncpy ((char *) mp->name_filter, "lo", sizeof (mp->name_filter) - 1);
4943 /* and packet-generator interfaces */
4944 M (SW_INTERFACE_DUMP, mp);
4945 mp->name_filter_valid = 1;
4946 strncpy ((char *) mp->name_filter, "pg", sizeof (mp->name_filter) - 1);
4949 /* and vxlan-gpe tunnel interfaces */
4950 M (SW_INTERFACE_DUMP, mp);
4951 mp->name_filter_valid = 1;
4952 strncpy ((char *) mp->name_filter, "vxlan_gpe",
4953 sizeof (mp->name_filter) - 1);
4956 /* and vxlan tunnel interfaces */
4957 M (SW_INTERFACE_DUMP, mp);
4958 mp->name_filter_valid = 1;
4959 strncpy ((char *) mp->name_filter, "vxlan", sizeof (mp->name_filter) - 1);
4962 /* and host (af_packet) interfaces */
4963 M (SW_INTERFACE_DUMP, mp);
4964 mp->name_filter_valid = 1;
4965 strncpy ((char *) mp->name_filter, "host", sizeof (mp->name_filter) - 1);
4968 /* and l2tpv3 tunnel interfaces */
4969 M (SW_INTERFACE_DUMP, mp);
4970 mp->name_filter_valid = 1;
4971 strncpy ((char *) mp->name_filter, "l2tpv3_tunnel",
4972 sizeof (mp->name_filter) - 1);
4975 /* and GRE tunnel interfaces */
4976 M (SW_INTERFACE_DUMP, mp);
4977 mp->name_filter_valid = 1;
4978 strncpy ((char *) mp->name_filter, "gre", sizeof (mp->name_filter) - 1);
4981 /* and LISP-GPE interfaces */
4982 M (SW_INTERFACE_DUMP, mp);
4983 mp->name_filter_valid = 1;
4984 strncpy ((char *) mp->name_filter, "lisp_gpe",
4985 sizeof (mp->name_filter) - 1);
4988 /* and IPSEC tunnel interfaces */
4989 M (SW_INTERFACE_DUMP, mp);
4990 mp->name_filter_valid = 1;
4991 strncpy ((char *) mp->name_filter, "ipsec", sizeof (mp->name_filter) - 1);
4994 /* Use a control ping for synchronization */
4995 M (CONTROL_PING, mp_ping);
5003 api_sw_interface_set_flags (vat_main_t * vam)
5005 unformat_input_t *i = vam->input;
5006 vl_api_sw_interface_set_flags_t *mp;
5008 u8 sw_if_index_set = 0;
5009 u8 admin_up = 0, link_up = 0;
5012 /* Parse args required to build the message */
5013 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5015 if (unformat (i, "admin-up"))
5017 else if (unformat (i, "admin-down"))
5019 else if (unformat (i, "link-up"))
5021 else if (unformat (i, "link-down"))
5024 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5025 sw_if_index_set = 1;
5026 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5027 sw_if_index_set = 1;
5032 if (sw_if_index_set == 0)
5034 errmsg ("missing interface name or sw_if_index");
5038 /* Construct the API message */
5039 M (SW_INTERFACE_SET_FLAGS, mp);
5040 mp->sw_if_index = ntohl (sw_if_index);
5041 mp->admin_up_down = admin_up;
5042 mp->link_up_down = link_up;
5047 /* Wait for a reply, return the good/bad news... */
5053 api_sw_interface_clear_stats (vat_main_t * vam)
5055 unformat_input_t *i = vam->input;
5056 vl_api_sw_interface_clear_stats_t *mp;
5058 u8 sw_if_index_set = 0;
5061 /* Parse args required to build the message */
5062 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5064 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5065 sw_if_index_set = 1;
5066 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5067 sw_if_index_set = 1;
5072 /* Construct the API message */
5073 M (SW_INTERFACE_CLEAR_STATS, mp);
5075 if (sw_if_index_set == 1)
5076 mp->sw_if_index = ntohl (sw_if_index);
5078 mp->sw_if_index = ~0;
5083 /* Wait for a reply, return the good/bad news... */
5089 api_sw_interface_add_del_address (vat_main_t * vam)
5091 unformat_input_t *i = vam->input;
5092 vl_api_sw_interface_add_del_address_t *mp;
5094 u8 sw_if_index_set = 0;
5095 u8 is_add = 1, del_all = 0;
5096 u32 address_length = 0;
5097 u8 v4_address_set = 0;
5098 u8 v6_address_set = 0;
5099 ip4_address_t v4address;
5100 ip6_address_t v6address;
5103 /* Parse args required to build the message */
5104 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5106 if (unformat (i, "del-all"))
5108 else if (unformat (i, "del"))
5111 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5112 sw_if_index_set = 1;
5113 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5114 sw_if_index_set = 1;
5115 else if (unformat (i, "%U/%d",
5116 unformat_ip4_address, &v4address, &address_length))
5118 else if (unformat (i, "%U/%d",
5119 unformat_ip6_address, &v6address, &address_length))
5125 if (sw_if_index_set == 0)
5127 errmsg ("missing interface name or sw_if_index");
5130 if (v4_address_set && v6_address_set)
5132 errmsg ("both v4 and v6 addresses set");
5135 if (!v4_address_set && !v6_address_set && !del_all)
5137 errmsg ("no addresses set");
5141 /* Construct the API message */
5142 M (SW_INTERFACE_ADD_DEL_ADDRESS, mp);
5144 mp->sw_if_index = ntohl (sw_if_index);
5145 mp->is_add = is_add;
5146 mp->del_all = del_all;
5150 clib_memcpy (mp->address, &v6address, sizeof (v6address));
5154 clib_memcpy (mp->address, &v4address, sizeof (v4address));
5156 mp->address_length = address_length;
5161 /* Wait for a reply, return good/bad news */
5167 api_sw_interface_set_mpls_enable (vat_main_t * vam)
5169 unformat_input_t *i = vam->input;
5170 vl_api_sw_interface_set_mpls_enable_t *mp;
5172 u8 sw_if_index_set = 0;
5176 /* Parse args required to build the message */
5177 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5179 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5180 sw_if_index_set = 1;
5181 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5182 sw_if_index_set = 1;
5183 else if (unformat (i, "disable"))
5185 else if (unformat (i, "dis"))
5191 if (sw_if_index_set == 0)
5193 errmsg ("missing interface name or sw_if_index");
5197 /* Construct the API message */
5198 M (SW_INTERFACE_SET_MPLS_ENABLE, mp);
5200 mp->sw_if_index = ntohl (sw_if_index);
5201 mp->enable = enable;
5206 /* Wait for a reply... */
5212 api_sw_interface_set_table (vat_main_t * vam)
5214 unformat_input_t *i = vam->input;
5215 vl_api_sw_interface_set_table_t *mp;
5216 u32 sw_if_index, vrf_id = 0;
5217 u8 sw_if_index_set = 0;
5221 /* Parse args required to build the message */
5222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5224 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5225 sw_if_index_set = 1;
5226 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5227 sw_if_index_set = 1;
5228 else if (unformat (i, "vrf %d", &vrf_id))
5230 else if (unformat (i, "ipv6"))
5236 if (sw_if_index_set == 0)
5238 errmsg ("missing interface name or sw_if_index");
5242 /* Construct the API message */
5243 M (SW_INTERFACE_SET_TABLE, mp);
5245 mp->sw_if_index = ntohl (sw_if_index);
5246 mp->is_ipv6 = is_ipv6;
5247 mp->vrf_id = ntohl (vrf_id);
5252 /* Wait for a reply... */
5257 static void vl_api_sw_interface_get_table_reply_t_handler
5258 (vl_api_sw_interface_get_table_reply_t * mp)
5260 vat_main_t *vam = &vat_main;
5262 print (vam->ofp, "%d", ntohl (mp->vrf_id));
5264 vam->retval = ntohl (mp->retval);
5265 vam->result_ready = 1;
5269 static void vl_api_sw_interface_get_table_reply_t_handler_json
5270 (vl_api_sw_interface_get_table_reply_t * mp)
5272 vat_main_t *vam = &vat_main;
5273 vat_json_node_t node;
5275 vat_json_init_object (&node);
5276 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
5277 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
5279 vat_json_print (vam->ofp, &node);
5280 vat_json_free (&node);
5282 vam->retval = ntohl (mp->retval);
5283 vam->result_ready = 1;
5287 api_sw_interface_get_table (vat_main_t * vam)
5289 unformat_input_t *i = vam->input;
5290 vl_api_sw_interface_get_table_t *mp;
5292 u8 sw_if_index_set = 0;
5296 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5298 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5299 sw_if_index_set = 1;
5300 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5301 sw_if_index_set = 1;
5302 else if (unformat (i, "ipv6"))
5308 if (sw_if_index_set == 0)
5310 errmsg ("missing interface name or sw_if_index");
5314 M (SW_INTERFACE_GET_TABLE, mp);
5315 mp->sw_if_index = htonl (sw_if_index);
5316 mp->is_ipv6 = is_ipv6;
5324 api_sw_interface_set_vpath (vat_main_t * vam)
5326 unformat_input_t *i = vam->input;
5327 vl_api_sw_interface_set_vpath_t *mp;
5328 u32 sw_if_index = 0;
5329 u8 sw_if_index_set = 0;
5333 /* Parse args required to build the message */
5334 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5336 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5337 sw_if_index_set = 1;
5338 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5339 sw_if_index_set = 1;
5340 else if (unformat (i, "enable"))
5342 else if (unformat (i, "disable"))
5348 if (sw_if_index_set == 0)
5350 errmsg ("missing interface name or sw_if_index");
5354 /* Construct the API message */
5355 M (SW_INTERFACE_SET_VPATH, mp);
5357 mp->sw_if_index = ntohl (sw_if_index);
5358 mp->enable = is_enable;
5363 /* Wait for a reply... */
5369 api_sw_interface_set_vxlan_bypass (vat_main_t * vam)
5371 unformat_input_t *i = vam->input;
5372 vl_api_sw_interface_set_vxlan_bypass_t *mp;
5373 u32 sw_if_index = 0;
5374 u8 sw_if_index_set = 0;
5379 /* Parse args required to build the message */
5380 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5382 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5383 sw_if_index_set = 1;
5384 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5385 sw_if_index_set = 1;
5386 else if (unformat (i, "enable"))
5388 else if (unformat (i, "disable"))
5390 else if (unformat (i, "ip4"))
5392 else if (unformat (i, "ip6"))
5398 if (sw_if_index_set == 0)
5400 errmsg ("missing interface name or sw_if_index");
5404 /* Construct the API message */
5405 M (SW_INTERFACE_SET_VXLAN_BYPASS, mp);
5407 mp->sw_if_index = ntohl (sw_if_index);
5408 mp->enable = is_enable;
5409 mp->is_ipv6 = is_ipv6;
5414 /* Wait for a reply... */
5420 api_sw_interface_set_l2_xconnect (vat_main_t * vam)
5422 unformat_input_t *i = vam->input;
5423 vl_api_sw_interface_set_l2_xconnect_t *mp;
5425 u8 rx_sw_if_index_set = 0;
5427 u8 tx_sw_if_index_set = 0;
5431 /* Parse args required to build the message */
5432 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5434 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
5435 rx_sw_if_index_set = 1;
5436 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
5437 tx_sw_if_index_set = 1;
5438 else if (unformat (i, "rx"))
5440 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5442 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5444 rx_sw_if_index_set = 1;
5449 else if (unformat (i, "tx"))
5451 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5453 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
5455 tx_sw_if_index_set = 1;
5460 else if (unformat (i, "enable"))
5462 else if (unformat (i, "disable"))
5468 if (rx_sw_if_index_set == 0)
5470 errmsg ("missing rx interface name or rx_sw_if_index");
5474 if (enable && (tx_sw_if_index_set == 0))
5476 errmsg ("missing tx interface name or tx_sw_if_index");
5480 M (SW_INTERFACE_SET_L2_XCONNECT, mp);
5482 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5483 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
5484 mp->enable = enable;
5492 api_sw_interface_set_l2_bridge (vat_main_t * vam)
5494 unformat_input_t *i = vam->input;
5495 vl_api_sw_interface_set_l2_bridge_t *mp;
5497 u8 rx_sw_if_index_set = 0;
5505 /* Parse args required to build the message */
5506 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5508 if (unformat (i, "sw_if_index %d", &rx_sw_if_index))
5509 rx_sw_if_index_set = 1;
5510 else if (unformat (i, "bd_id %d", &bd_id))
5514 (i, "%U", api_unformat_sw_if_index, vam, &rx_sw_if_index))
5515 rx_sw_if_index_set = 1;
5516 else if (unformat (i, "shg %d", &shg))
5518 else if (unformat (i, "bvi"))
5520 else if (unformat (i, "enable"))
5522 else if (unformat (i, "disable"))
5528 if (rx_sw_if_index_set == 0)
5530 errmsg ("missing rx interface name or sw_if_index");
5534 if (enable && (bd_id_set == 0))
5536 errmsg ("missing bridge domain");
5540 M (SW_INTERFACE_SET_L2_BRIDGE, mp);
5542 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
5543 mp->bd_id = ntohl (bd_id);
5546 mp->enable = enable;
5554 api_bridge_domain_dump (vat_main_t * vam)
5556 unformat_input_t *i = vam->input;
5557 vl_api_bridge_domain_dump_t *mp;
5558 vl_api_control_ping_t *mp_ping;
5562 /* Parse args required to build the message */
5563 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5565 if (unformat (i, "bd_id %d", &bd_id))
5571 M (BRIDGE_DOMAIN_DUMP, mp);
5572 mp->bd_id = ntohl (bd_id);
5575 /* Use a control ping for synchronization */
5576 M (CONTROL_PING, mp_ping);
5584 api_bridge_domain_add_del (vat_main_t * vam)
5586 unformat_input_t *i = vam->input;
5587 vl_api_bridge_domain_add_del_t *mp;
5590 u32 flood = 1, forward = 1, learn = 1, uu_flood = 1, arp_term = 0;
5594 /* Parse args required to build the message */
5595 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5597 if (unformat (i, "bd_id %d", &bd_id))
5599 else if (unformat (i, "flood %d", &flood))
5601 else if (unformat (i, "uu-flood %d", &uu_flood))
5603 else if (unformat (i, "forward %d", &forward))
5605 else if (unformat (i, "learn %d", &learn))
5607 else if (unformat (i, "arp-term %d", &arp_term))
5609 else if (unformat (i, "mac-age %d", &mac_age))
5611 else if (unformat (i, "del"))
5614 flood = uu_flood = forward = learn = 0;
5622 errmsg ("missing bridge domain");
5628 errmsg ("mac age must be less than 256 ");
5632 M (BRIDGE_DOMAIN_ADD_DEL, mp);
5634 mp->bd_id = ntohl (bd_id);
5636 mp->uu_flood = uu_flood;
5637 mp->forward = forward;
5639 mp->arp_term = arp_term;
5640 mp->is_add = is_add;
5641 mp->mac_age = (u8) mac_age;
5649 api_l2fib_add_del (vat_main_t * vam)
5651 unformat_input_t *i = vam->input;
5652 vl_api_l2fib_add_del_t *mp;
5658 u32 sw_if_index = ~0;
5659 u8 sw_if_index_set = 0;
5668 /* Parse args required to build the message */
5669 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5671 if (unformat (i, "mac %U", unformat_ethernet_address, &mac))
5673 else if (unformat (i, "bd_id %d", &bd_id))
5675 else if (unformat (i, "sw_if_index %d", &sw_if_index))
5676 sw_if_index_set = 1;
5677 else if (unformat (i, "sw_if"))
5679 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5682 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5683 sw_if_index_set = 1;
5688 else if (unformat (i, "static"))
5690 else if (unformat (i, "filter"))
5695 else if (unformat (i, "bvi"))
5700 else if (unformat (i, "del"))
5702 else if (unformat (i, "count %d", &count))
5710 errmsg ("missing mac address");
5716 errmsg ("missing bridge domain");
5720 if (is_add && sw_if_index_set == 0 && filter_mac == 0)
5722 errmsg ("missing interface name or sw_if_index");
5728 /* Turn on async mode */
5729 vam->async_mode = 1;
5730 vam->async_errors = 0;
5731 before = vat_time_now (vam);
5734 for (j = 0; j < count; j++)
5736 M (L2FIB_ADD_DEL, mp);
5739 mp->bd_id = ntohl (bd_id);
5740 mp->is_add = is_add;
5744 mp->sw_if_index = ntohl (sw_if_index);
5745 mp->static_mac = static_mac;
5746 mp->filter_mac = filter_mac;
5747 mp->bvi_mac = bvi_mac;
5749 increment_mac_address (&mac);
5756 vl_api_control_ping_t *mp_ping;
5759 /* Shut off async mode */
5760 vam->async_mode = 0;
5762 M (CONTROL_PING, mp_ping);
5765 timeout = vat_time_now (vam) + 1.0;
5766 while (vat_time_now (vam) < timeout)
5767 if (vam->result_ready == 1)
5772 if (vam->retval == -99)
5775 if (vam->async_errors > 0)
5777 errmsg ("%d asynchronous errors", vam->async_errors);
5780 vam->async_errors = 0;
5781 after = vat_time_now (vam);
5783 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
5784 count, after - before, count / (after - before));
5790 /* Wait for a reply... */
5794 /* Return the good/bad news */
5795 return (vam->retval);
5799 api_l2_flags (vat_main_t * vam)
5801 unformat_input_t *i = vam->input;
5802 vl_api_l2_flags_t *mp;
5804 u32 feature_bitmap = 0;
5805 u8 sw_if_index_set = 0;
5808 /* Parse args required to build the message */
5809 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5811 if (unformat (i, "sw_if_index %d", &sw_if_index))
5812 sw_if_index_set = 1;
5813 else if (unformat (i, "sw_if"))
5815 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5818 (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
5819 sw_if_index_set = 1;
5824 else if (unformat (i, "learn"))
5825 feature_bitmap |= L2INPUT_FEAT_LEARN;
5826 else if (unformat (i, "forward"))
5827 feature_bitmap |= L2INPUT_FEAT_FWD;
5828 else if (unformat (i, "flood"))
5829 feature_bitmap |= L2INPUT_FEAT_FLOOD;
5830 else if (unformat (i, "uu-flood"))
5831 feature_bitmap |= L2INPUT_FEAT_UU_FLOOD;
5836 if (sw_if_index_set == 0)
5838 errmsg ("missing interface name or sw_if_index");
5844 mp->sw_if_index = ntohl (sw_if_index);
5845 mp->feature_bitmap = ntohl (feature_bitmap);
5853 api_bridge_flags (vat_main_t * vam)
5855 unformat_input_t *i = vam->input;
5856 vl_api_bridge_flags_t *mp;
5863 /* Parse args required to build the message */
5864 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5866 if (unformat (i, "bd_id %d", &bd_id))
5868 else if (unformat (i, "learn"))
5870 else if (unformat (i, "forward"))
5872 else if (unformat (i, "flood"))
5874 else if (unformat (i, "uu-flood"))
5875 flags |= L2_UU_FLOOD;
5876 else if (unformat (i, "arp-term"))
5877 flags |= L2_ARP_TERM;
5878 else if (unformat (i, "off"))
5880 else if (unformat (i, "disable"))
5888 errmsg ("missing bridge domain");
5892 M (BRIDGE_FLAGS, mp);
5894 mp->bd_id = ntohl (bd_id);
5895 mp->feature_bitmap = ntohl (flags);
5896 mp->is_set = is_set;
5904 api_bd_ip_mac_add_del (vat_main_t * vam)
5906 unformat_input_t *i = vam->input;
5907 vl_api_bd_ip_mac_add_del_t *mp;
5914 ip4_address_t v4addr;
5915 ip6_address_t v6addr;
5920 /* Parse args required to build the message */
5921 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
5923 if (unformat (i, "bd_id %d", &bd_id))
5927 else if (unformat (i, "%U", unformat_ip4_address, &v4addr))
5931 else if (unformat (i, "%U", unformat_ip6_address, &v6addr))
5936 else if (unformat (i, "%U", unformat_ethernet_address, macaddr))
5940 else if (unformat (i, "del"))
5948 errmsg ("missing bridge domain");
5951 else if (ip_set == 0)
5953 errmsg ("missing IP address");
5956 else if (mac_set == 0)
5958 errmsg ("missing MAC address");
5962 M (BD_IP_MAC_ADD_DEL, mp);
5964 mp->bd_id = ntohl (bd_id);
5965 mp->is_ipv6 = is_ipv6;
5966 mp->is_add = is_add;
5968 clib_memcpy (mp->ip_address, &v6addr, sizeof (v6addr));
5970 clib_memcpy (mp->ip_address, &v4addr, sizeof (v4addr));
5971 clib_memcpy (mp->mac_address, macaddr, 6);
5978 api_tap_connect (vat_main_t * vam)
5980 unformat_input_t *i = vam->input;
5981 vl_api_tap_connect_t *mp;
5987 ip4_address_t ip4_address;
5989 int ip4_address_set = 0;
5990 ip6_address_t ip6_address;
5992 int ip6_address_set = 0;
5995 memset (mac_address, 0, sizeof (mac_address));
5997 /* Parse args required to build the message */
5998 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6000 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6004 else if (unformat (i, "random-mac"))
6006 else if (unformat (i, "tapname %s", &tap_name))
6008 else if (unformat (i, "tag %s", &tag))
6010 else if (unformat (i, "address %U/%d",
6011 unformat_ip4_address, &ip4_address, &ip4_mask_width))
6012 ip4_address_set = 1;
6013 else if (unformat (i, "address %U/%d",
6014 unformat_ip6_address, &ip6_address, &ip6_mask_width))
6015 ip6_address_set = 1;
6022 errmsg ("missing tap name");
6025 if (vec_len (tap_name) > 63)
6027 errmsg ("tap name too long");
6030 vec_add1 (tap_name, 0);
6032 if (vec_len (tag) > 63)
6034 errmsg ("tag too long");
6038 /* Construct the API message */
6039 M (TAP_CONNECT, mp);
6041 mp->use_random_mac = random_mac;
6042 clib_memcpy (mp->mac_address, mac_address, 6);
6043 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6045 clib_memcpy (mp->tag, tag, vec_len (tag));
6047 if (ip4_address_set)
6049 mp->ip4_address_set = 1;
6050 clib_memcpy (mp->ip4_address, &ip4_address, sizeof (mp->ip4_address));
6051 mp->ip4_mask_width = ip4_mask_width;
6053 if (ip6_address_set)
6055 mp->ip6_address_set = 1;
6056 clib_memcpy (mp->ip6_address, &ip6_address, sizeof (mp->ip6_address));
6057 mp->ip6_mask_width = ip6_mask_width;
6060 vec_free (tap_name);
6066 /* Wait for a reply... */
6072 api_tap_modify (vat_main_t * vam)
6074 unformat_input_t *i = vam->input;
6075 vl_api_tap_modify_t *mp;
6080 u32 sw_if_index = ~0;
6081 u8 sw_if_index_set = 0;
6084 memset (mac_address, 0, sizeof (mac_address));
6086 /* Parse args required to build the message */
6087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6090 sw_if_index_set = 1;
6091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6092 sw_if_index_set = 1;
6093 else if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
6097 else if (unformat (i, "random-mac"))
6099 else if (unformat (i, "tapname %s", &tap_name))
6105 if (sw_if_index_set == 0)
6107 errmsg ("missing vpp interface name");
6112 errmsg ("missing tap name");
6115 if (vec_len (tap_name) > 63)
6117 errmsg ("tap name too long");
6119 vec_add1 (tap_name, 0);
6121 /* Construct the API message */
6124 mp->use_random_mac = random_mac;
6125 mp->sw_if_index = ntohl (sw_if_index);
6126 clib_memcpy (mp->mac_address, mac_address, 6);
6127 clib_memcpy (mp->tap_name, tap_name, vec_len (tap_name));
6128 vec_free (tap_name);
6133 /* Wait for a reply... */
6139 api_tap_delete (vat_main_t * vam)
6141 unformat_input_t *i = vam->input;
6142 vl_api_tap_delete_t *mp;
6143 u32 sw_if_index = ~0;
6144 u8 sw_if_index_set = 0;
6147 /* Parse args required to build the message */
6148 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6150 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6151 sw_if_index_set = 1;
6152 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6153 sw_if_index_set = 1;
6158 if (sw_if_index_set == 0)
6160 errmsg ("missing vpp interface name");
6164 /* Construct the API message */
6167 mp->sw_if_index = ntohl (sw_if_index);
6172 /* Wait for a reply... */
6178 api_ip_add_del_route (vat_main_t * vam)
6180 unformat_input_t *i = vam->input;
6181 vl_api_ip_add_del_route_t *mp;
6182 u32 sw_if_index = ~0, vrf_id = 0;
6184 u8 is_local = 0, is_drop = 0;
6185 u8 is_unreach = 0, is_prohibit = 0;
6186 u8 create_vrf_if_needed = 0;
6188 u32 next_hop_weight = 1;
6190 u8 is_multipath = 0;
6192 u8 address_length_set = 0;
6193 u32 next_hop_table_id = 0;
6194 u32 resolve_attempts = 0;
6195 u32 dst_address_length = 0;
6196 u8 next_hop_set = 0;
6197 ip4_address_t v4_dst_address, v4_next_hop_address;
6198 ip6_address_t v6_dst_address, v6_next_hop_address;
6202 u32 random_add_del = 0;
6203 u32 *random_vector = 0;
6205 u32 random_seed = 0xdeaddabe;
6206 u32 classify_table_index = ~0;
6208 u8 resolve_host = 0, resolve_attached = 0;
6209 mpls_label_t *next_hop_out_label_stack = NULL;
6210 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6211 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6213 /* Parse args required to build the message */
6214 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6216 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6218 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6220 else if (unformat (i, "%U", unformat_ip4_address, &v4_dst_address))
6225 else if (unformat (i, "%U", unformat_ip6_address, &v6_dst_address))
6230 else if (unformat (i, "/%d", &dst_address_length))
6232 address_length_set = 1;
6235 else if (is_ipv6 == 0 && unformat (i, "via %U", unformat_ip4_address,
6236 &v4_next_hop_address))
6240 else if (is_ipv6 == 1 && unformat (i, "via %U", unformat_ip6_address,
6241 &v6_next_hop_address))
6245 else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
6247 else if (unformat (i, "weight %d", &next_hop_weight))
6249 else if (unformat (i, "drop"))
6253 else if (unformat (i, "null-send-unreach"))
6257 else if (unformat (i, "null-send-prohibit"))
6261 else if (unformat (i, "local"))
6265 else if (unformat (i, "classify %d", &classify_table_index))
6269 else if (unformat (i, "del"))
6271 else if (unformat (i, "add"))
6273 else if (unformat (i, "not-last"))
6275 else if (unformat (i, "resolve-via-host"))
6277 else if (unformat (i, "resolve-via-attached"))
6278 resolve_attached = 1;
6279 else if (unformat (i, "multipath"))
6281 else if (unformat (i, "vrf %d", &vrf_id))
6283 else if (unformat (i, "create-vrf"))
6284 create_vrf_if_needed = 1;
6285 else if (unformat (i, "count %d", &count))
6287 else if (unformat (i, "lookup-in-vrf %d", &next_hop_table_id))
6289 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6291 else if (unformat (i, "out-label %d", &next_hop_out_label))
6292 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6293 else if (unformat (i, "via-label %d", &next_hop_via_label))
6295 else if (unformat (i, "random"))
6297 else if (unformat (i, "seed %d", &random_seed))
6301 clib_warning ("parse error '%U'", format_unformat_error, i);
6306 if (!next_hop_set && !is_drop && !is_local &&
6307 !is_classify && !is_unreach && !is_prohibit &&
6308 MPLS_LABEL_INVALID == next_hop_via_label)
6311 ("next hop / local / drop / unreach / prohibit / classify not set");
6315 if (next_hop_set && MPLS_LABEL_INVALID != next_hop_via_label)
6317 errmsg ("next hop and next-hop via label set");
6320 if (address_set == 0)
6322 errmsg ("missing addresses");
6326 if (address_length_set == 0)
6328 errmsg ("missing address length");
6332 /* Generate a pile of unique, random routes */
6335 u32 this_random_address;
6336 random_hash = hash_create (count, sizeof (uword));
6338 hash_set (random_hash, v4_next_hop_address.as_u32, 1);
6339 for (j = 0; j <= count; j++)
6343 this_random_address = random_u32 (&random_seed);
6344 this_random_address =
6345 clib_host_to_net_u32 (this_random_address);
6347 while (hash_get (random_hash, this_random_address));
6348 vec_add1 (random_vector, this_random_address);
6349 hash_set (random_hash, this_random_address, 1);
6351 hash_free (random_hash);
6352 v4_dst_address.as_u32 = random_vector[0];
6357 /* Turn on async mode */
6358 vam->async_mode = 1;
6359 vam->async_errors = 0;
6360 before = vat_time_now (vam);
6363 for (j = 0; j < count; j++)
6365 /* Construct the API message */
6366 M2 (IP_ADD_DEL_ROUTE, mp,
6367 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6369 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6370 mp->table_id = ntohl (vrf_id);
6371 mp->create_vrf_if_needed = create_vrf_if_needed;
6373 mp->is_add = is_add;
6374 mp->is_drop = is_drop;
6375 mp->is_unreach = is_unreach;
6376 mp->is_prohibit = is_prohibit;
6377 mp->is_ipv6 = is_ipv6;
6378 mp->is_local = is_local;
6379 mp->is_classify = is_classify;
6380 mp->is_multipath = is_multipath;
6381 mp->is_resolve_host = resolve_host;
6382 mp->is_resolve_attached = resolve_attached;
6383 mp->not_last = not_last;
6384 mp->next_hop_weight = next_hop_weight;
6385 mp->dst_address_length = dst_address_length;
6386 mp->next_hop_table_id = ntohl (next_hop_table_id);
6387 mp->classify_table_index = ntohl (classify_table_index);
6388 mp->next_hop_via_label = ntohl (next_hop_via_label);
6389 mp->next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6390 if (0 != mp->next_hop_n_out_labels)
6392 memcpy (mp->next_hop_out_label_stack,
6393 next_hop_out_label_stack,
6394 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6395 vec_free (next_hop_out_label_stack);
6400 clib_memcpy (mp->dst_address, &v6_dst_address,
6401 sizeof (v6_dst_address));
6403 clib_memcpy (mp->next_hop_address, &v6_next_hop_address,
6404 sizeof (v6_next_hop_address));
6405 increment_v6_address (&v6_dst_address);
6409 clib_memcpy (mp->dst_address, &v4_dst_address,
6410 sizeof (v4_dst_address));
6412 clib_memcpy (mp->next_hop_address, &v4_next_hop_address,
6413 sizeof (v4_next_hop_address));
6415 v4_dst_address.as_u32 = random_vector[j + 1];
6417 increment_v4_address (&v4_dst_address);
6421 /* If we receive SIGTERM, stop now... */
6426 /* When testing multiple add/del ops, use a control-ping to sync */
6429 vl_api_control_ping_t *mp_ping;
6433 /* Shut off async mode */
6434 vam->async_mode = 0;
6436 M (CONTROL_PING, mp_ping);
6439 timeout = vat_time_now (vam) + 1.0;
6440 while (vat_time_now (vam) < timeout)
6441 if (vam->result_ready == 1)
6446 if (vam->retval == -99)
6449 if (vam->async_errors > 0)
6451 errmsg ("%d asynchronous errors", vam->async_errors);
6454 vam->async_errors = 0;
6455 after = vat_time_now (vam);
6457 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6461 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6462 count, after - before, count / (after - before));
6468 /* Wait for a reply... */
6473 /* Return the good/bad news */
6474 return (vam->retval);
6478 api_ip_mroute_add_del (vat_main_t * vam)
6480 unformat_input_t *i = vam->input;
6481 vl_api_ip_mroute_add_del_t *mp;
6482 u32 sw_if_index = ~0, vrf_id = 0;
6485 u8 create_vrf_if_needed = 0;
6488 u32 grp_address_length = 0;
6489 ip4_address_t v4_grp_address, v4_src_address;
6490 ip6_address_t v6_grp_address, v6_src_address;
6491 mfib_itf_flags_t iflags = 0;
6492 mfib_entry_flags_t eflags = 0;
6495 /* Parse args required to build the message */
6496 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6498 if (unformat (i, "sw_if_index %d", &sw_if_index))
6500 else if (unformat (i, "%U %U",
6501 unformat_ip4_address, &v4_src_address,
6502 unformat_ip4_address, &v4_grp_address))
6504 grp_address_length = 64;
6508 else if (unformat (i, "%U %U",
6509 unformat_ip6_address, &v6_src_address,
6510 unformat_ip6_address, &v6_grp_address))
6512 grp_address_length = 256;
6516 else if (unformat (i, "%U", unformat_ip4_address, &v4_grp_address))
6518 memset (&v4_src_address, 0, sizeof (v4_src_address));
6519 grp_address_length = 32;
6523 else if (unformat (i, "%U", unformat_ip6_address, &v6_grp_address))
6525 memset (&v6_src_address, 0, sizeof (v6_src_address));
6526 grp_address_length = 128;
6530 else if (unformat (i, "/%d", &grp_address_length))
6532 else if (unformat (i, "local"))
6536 else if (unformat (i, "del"))
6538 else if (unformat (i, "add"))
6540 else if (unformat (i, "vrf %d", &vrf_id))
6542 else if (unformat (i, "create-vrf"))
6543 create_vrf_if_needed = 1;
6544 else if (unformat (i, "%U", unformat_mfib_itf_flags, &iflags))
6546 else if (unformat (i, "%U", unformat_mfib_entry_flags, &eflags))
6550 clib_warning ("parse error '%U'", format_unformat_error, i);
6555 if (address_set == 0)
6557 errmsg ("missing addresses\n");
6561 /* Construct the API message */
6562 M (IP_MROUTE_ADD_DEL, mp);
6564 mp->next_hop_sw_if_index = ntohl (sw_if_index);
6565 mp->table_id = ntohl (vrf_id);
6566 mp->create_vrf_if_needed = create_vrf_if_needed;
6568 mp->is_add = is_add;
6569 mp->is_ipv6 = is_ipv6;
6570 mp->is_local = is_local;
6571 mp->itf_flags = ntohl (iflags);
6572 mp->entry_flags = ntohl (eflags);
6573 mp->grp_address_length = grp_address_length;
6574 mp->grp_address_length = ntohs (mp->grp_address_length);
6578 clib_memcpy (mp->grp_address, &v6_grp_address, sizeof (v6_grp_address));
6579 clib_memcpy (mp->src_address, &v6_src_address, sizeof (v6_src_address));
6583 clib_memcpy (mp->grp_address, &v4_grp_address, sizeof (v4_grp_address));
6584 clib_memcpy (mp->src_address, &v4_src_address, sizeof (v4_src_address));
6590 /* Wait for a reply... */
6596 api_mpls_route_add_del (vat_main_t * vam)
6598 unformat_input_t *i = vam->input;
6599 vl_api_mpls_route_add_del_t *mp;
6600 u32 sw_if_index = ~0, table_id = 0;
6601 u8 create_table_if_needed = 0;
6603 u32 next_hop_weight = 1;
6604 u8 is_multipath = 0;
6605 u32 next_hop_table_id = 0;
6606 u8 next_hop_set = 0;
6607 ip4_address_t v4_next_hop_address = {
6610 ip6_address_t v6_next_hop_address = { {0} };
6614 u32 classify_table_index = ~0;
6616 u8 resolve_host = 0, resolve_attached = 0;
6617 mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
6618 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
6619 mpls_label_t *next_hop_out_label_stack = NULL;
6620 mpls_label_t local_label = MPLS_LABEL_INVALID;
6622 u8 next_hop_proto_is_ip4 = 1;
6624 /* Parse args required to build the message */
6625 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6627 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6629 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6631 else if (unformat (i, "%d", &local_label))
6633 else if (unformat (i, "eos"))
6635 else if (unformat (i, "non-eos"))
6637 else if (unformat (i, "via %U", unformat_ip4_address,
6638 &v4_next_hop_address))
6641 next_hop_proto_is_ip4 = 1;
6643 else if (unformat (i, "via %U", unformat_ip6_address,
6644 &v6_next_hop_address))
6647 next_hop_proto_is_ip4 = 0;
6649 else if (unformat (i, "weight %d", &next_hop_weight))
6651 else if (unformat (i, "create-table"))
6652 create_table_if_needed = 1;
6653 else if (unformat (i, "classify %d", &classify_table_index))
6657 else if (unformat (i, "del"))
6659 else if (unformat (i, "add"))
6661 else if (unformat (i, "resolve-via-host"))
6663 else if (unformat (i, "resolve-via-attached"))
6664 resolve_attached = 1;
6665 else if (unformat (i, "multipath"))
6667 else if (unformat (i, "count %d", &count))
6669 else if (unformat (i, "lookup-in-ip4-table %d", &next_hop_table_id))
6672 next_hop_proto_is_ip4 = 1;
6674 else if (unformat (i, "lookup-in-ip6-table %d", &next_hop_table_id))
6677 next_hop_proto_is_ip4 = 0;
6679 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
6681 else if (unformat (i, "via-label %d", &next_hop_via_label))
6683 else if (unformat (i, "out-label %d", &next_hop_out_label))
6684 vec_add1 (next_hop_out_label_stack, ntohl (next_hop_out_label));
6687 clib_warning ("parse error '%U'", format_unformat_error, i);
6692 if (!next_hop_set && !is_classify)
6694 errmsg ("next hop / classify not set");
6698 if (MPLS_LABEL_INVALID == local_label)
6700 errmsg ("missing label");
6706 /* Turn on async mode */
6707 vam->async_mode = 1;
6708 vam->async_errors = 0;
6709 before = vat_time_now (vam);
6712 for (j = 0; j < count; j++)
6714 /* Construct the API message */
6715 M2 (MPLS_ROUTE_ADD_DEL, mp,
6716 sizeof (mpls_label_t) * vec_len (next_hop_out_label_stack));
6718 mp->mr_next_hop_sw_if_index = ntohl (sw_if_index);
6719 mp->mr_table_id = ntohl (table_id);
6720 mp->mr_create_table_if_needed = create_table_if_needed;
6722 mp->mr_is_add = is_add;
6723 mp->mr_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
6724 mp->mr_is_classify = is_classify;
6725 mp->mr_is_multipath = is_multipath;
6726 mp->mr_is_resolve_host = resolve_host;
6727 mp->mr_is_resolve_attached = resolve_attached;
6728 mp->mr_next_hop_weight = next_hop_weight;
6729 mp->mr_next_hop_table_id = ntohl (next_hop_table_id);
6730 mp->mr_classify_table_index = ntohl (classify_table_index);
6731 mp->mr_next_hop_via_label = ntohl (next_hop_via_label);
6732 mp->mr_label = ntohl (local_label);
6733 mp->mr_eos = is_eos;
6735 mp->mr_next_hop_n_out_labels = vec_len (next_hop_out_label_stack);
6736 if (0 != mp->mr_next_hop_n_out_labels)
6738 memcpy (mp->mr_next_hop_out_label_stack,
6739 next_hop_out_label_stack,
6740 vec_len (next_hop_out_label_stack) * sizeof (mpls_label_t));
6741 vec_free (next_hop_out_label_stack);
6746 if (next_hop_proto_is_ip4)
6748 clib_memcpy (mp->mr_next_hop,
6749 &v4_next_hop_address,
6750 sizeof (v4_next_hop_address));
6754 clib_memcpy (mp->mr_next_hop,
6755 &v6_next_hop_address,
6756 sizeof (v6_next_hop_address));
6763 /* If we receive SIGTERM, stop now... */
6768 /* When testing multiple add/del ops, use a control-ping to sync */
6771 vl_api_control_ping_t *mp_ping;
6775 /* Shut off async mode */
6776 vam->async_mode = 0;
6778 M (CONTROL_PING, mp_ping);
6781 timeout = vat_time_now (vam) + 1.0;
6782 while (vat_time_now (vam) < timeout)
6783 if (vam->result_ready == 1)
6788 if (vam->retval == -99)
6791 if (vam->async_errors > 0)
6793 errmsg ("%d asynchronous errors", vam->async_errors);
6796 vam->async_errors = 0;
6797 after = vat_time_now (vam);
6799 /* slim chance, but we might have eaten SIGTERM on the first iteration */
6803 print (vam->ofp, "%d routes in %.6f secs, %.2f routes/sec",
6804 count, after - before, count / (after - before));
6810 /* Wait for a reply... */
6815 /* Return the good/bad news */
6816 return (vam->retval);
6820 api_mpls_ip_bind_unbind (vat_main_t * vam)
6822 unformat_input_t *i = vam->input;
6823 vl_api_mpls_ip_bind_unbind_t *mp;
6824 u32 ip_table_id = 0;
6825 u8 create_table_if_needed = 0;
6828 ip4_address_t v4_address;
6829 ip6_address_t v6_address;
6832 mpls_label_t local_label = MPLS_LABEL_INVALID;
6835 /* Parse args required to build the message */
6836 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6838 if (unformat (i, "%U/%d", unformat_ip4_address,
6839 &v4_address, &address_length))
6844 else if (unformat (i, "%U/%d", unformat_ip6_address,
6845 &v6_address, &address_length))
6850 else if (unformat (i, "%d", &local_label))
6852 else if (unformat (i, "create-table"))
6853 create_table_if_needed = 1;
6854 else if (unformat (i, "table-id %d", &ip_table_id))
6856 else if (unformat (i, "unbind"))
6858 else if (unformat (i, "bind"))
6862 clib_warning ("parse error '%U'", format_unformat_error, i);
6869 errmsg ("IP addres not set");
6873 if (MPLS_LABEL_INVALID == local_label)
6875 errmsg ("missing label");
6879 /* Construct the API message */
6880 M (MPLS_IP_BIND_UNBIND, mp);
6882 mp->mb_create_table_if_needed = create_table_if_needed;
6883 mp->mb_is_bind = is_bind;
6884 mp->mb_is_ip4 = is_ip4;
6885 mp->mb_ip_table_id = ntohl (ip_table_id);
6886 mp->mb_mpls_table_id = 0;
6887 mp->mb_label = ntohl (local_label);
6888 mp->mb_address_length = address_length;
6891 clib_memcpy (mp->mb_address, &v4_address, sizeof (v4_address));
6893 clib_memcpy (mp->mb_address, &v6_address, sizeof (v6_address));
6898 /* Wait for a reply... */
6904 api_proxy_arp_add_del (vat_main_t * vam)
6906 unformat_input_t *i = vam->input;
6907 vl_api_proxy_arp_add_del_t *mp;
6910 ip4_address_t lo, hi;
6914 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6916 if (unformat (i, "vrf %d", &vrf_id))
6918 else if (unformat (i, "%U - %U", unformat_ip4_address, &lo,
6919 unformat_ip4_address, &hi))
6921 else if (unformat (i, "del"))
6925 clib_warning ("parse error '%U'", format_unformat_error, i);
6932 errmsg ("address range not set");
6936 M (PROXY_ARP_ADD_DEL, mp);
6938 mp->vrf_id = ntohl (vrf_id);
6939 mp->is_add = is_add;
6940 clib_memcpy (mp->low_address, &lo, sizeof (mp->low_address));
6941 clib_memcpy (mp->hi_address, &hi, sizeof (mp->hi_address));
6949 api_proxy_arp_intfc_enable_disable (vat_main_t * vam)
6951 unformat_input_t *i = vam->input;
6952 vl_api_proxy_arp_intfc_enable_disable_t *mp;
6955 u8 sw_if_index_set = 0;
6958 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
6960 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
6961 sw_if_index_set = 1;
6962 else if (unformat (i, "sw_if_index %d", &sw_if_index))
6963 sw_if_index_set = 1;
6964 else if (unformat (i, "enable"))
6966 else if (unformat (i, "disable"))
6970 clib_warning ("parse error '%U'", format_unformat_error, i);
6975 if (sw_if_index_set == 0)
6977 errmsg ("missing interface name or sw_if_index");
6981 M (PROXY_ARP_INTFC_ENABLE_DISABLE, mp);
6983 mp->sw_if_index = ntohl (sw_if_index);
6984 mp->enable_disable = enable;
6992 api_mpls_tunnel_add_del (vat_main_t * vam)
6994 unformat_input_t *i = vam->input;
6995 vl_api_mpls_tunnel_add_del_t *mp;
6999 u32 sw_if_index = ~0;
7000 u32 next_hop_sw_if_index = ~0;
7001 u32 next_hop_proto_is_ip4 = 1;
7003 u32 next_hop_table_id = 0;
7004 ip4_address_t v4_next_hop_address = {
7007 ip6_address_t v6_next_hop_address = { {0} };
7008 mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID, *labels = NULL;
7011 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7013 if (unformat (i, "add"))
7015 else if (unformat (i, "del sw_if_index %d", &sw_if_index))
7017 else if (unformat (i, "sw_if_index %d", &next_hop_sw_if_index))
7019 else if (unformat (i, "via %U",
7020 unformat_ip4_address, &v4_next_hop_address))
7022 next_hop_proto_is_ip4 = 1;
7024 else if (unformat (i, "via %U",
7025 unformat_ip6_address, &v6_next_hop_address))
7027 next_hop_proto_is_ip4 = 0;
7029 else if (unformat (i, "l2-only"))
7031 else if (unformat (i, "next-hop-table %d", &next_hop_table_id))
7033 else if (unformat (i, "out-label %d", &next_hop_out_label))
7034 vec_add1 (labels, ntohl (next_hop_out_label));
7037 clib_warning ("parse error '%U'", format_unformat_error, i);
7042 M2 (MPLS_TUNNEL_ADD_DEL, mp, sizeof (mpls_label_t) * vec_len (labels));
7044 mp->mt_next_hop_sw_if_index = ntohl (next_hop_sw_if_index);
7045 mp->mt_sw_if_index = ntohl (sw_if_index);
7046 mp->mt_is_add = is_add;
7047 mp->mt_l2_only = l2_only;
7048 mp->mt_next_hop_table_id = ntohl (next_hop_table_id);
7049 mp->mt_next_hop_proto_is_ip4 = next_hop_proto_is_ip4;
7051 mp->mt_next_hop_n_out_labels = vec_len (labels);
7053 if (0 != mp->mt_next_hop_n_out_labels)
7055 clib_memcpy (mp->mt_next_hop_out_label_stack, labels,
7056 sizeof (mpls_label_t) * mp->mt_next_hop_n_out_labels);
7060 if (next_hop_proto_is_ip4)
7062 clib_memcpy (mp->mt_next_hop,
7063 &v4_next_hop_address, sizeof (v4_next_hop_address));
7067 clib_memcpy (mp->mt_next_hop,
7068 &v6_next_hop_address, sizeof (v6_next_hop_address));
7077 api_sw_interface_set_unnumbered (vat_main_t * vam)
7079 unformat_input_t *i = vam->input;
7080 vl_api_sw_interface_set_unnumbered_t *mp;
7082 u32 unnum_sw_index = ~0;
7084 u8 sw_if_index_set = 0;
7087 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7089 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7090 sw_if_index_set = 1;
7091 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7092 sw_if_index_set = 1;
7093 else if (unformat (i, "unnum_if_index %d", &unnum_sw_index))
7095 else if (unformat (i, "del"))
7099 clib_warning ("parse error '%U'", format_unformat_error, i);
7104 if (sw_if_index_set == 0)
7106 errmsg ("missing interface name or sw_if_index");
7110 M (SW_INTERFACE_SET_UNNUMBERED, mp);
7112 mp->sw_if_index = ntohl (sw_if_index);
7113 mp->unnumbered_sw_if_index = ntohl (unnum_sw_index);
7114 mp->is_add = is_add;
7122 api_ip_neighbor_add_del (vat_main_t * vam)
7124 unformat_input_t *i = vam->input;
7125 vl_api_ip_neighbor_add_del_t *mp;
7127 u8 sw_if_index_set = 0;
7132 u8 v4_address_set = 0;
7133 u8 v6_address_set = 0;
7134 ip4_address_t v4address;
7135 ip6_address_t v6address;
7138 memset (mac_address, 0, sizeof (mac_address));
7140 /* Parse args required to build the message */
7141 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7143 if (unformat (i, "mac %U", unformat_ethernet_address, mac_address))
7147 else if (unformat (i, "del"))
7150 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7151 sw_if_index_set = 1;
7152 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7153 sw_if_index_set = 1;
7154 else if (unformat (i, "is_static"))
7156 else if (unformat (i, "dst %U", unformat_ip4_address, &v4address))
7158 else if (unformat (i, "dst %U", unformat_ip6_address, &v6address))
7162 clib_warning ("parse error '%U'", format_unformat_error, i);
7167 if (sw_if_index_set == 0)
7169 errmsg ("missing interface name or sw_if_index");
7172 if (v4_address_set && v6_address_set)
7174 errmsg ("both v4 and v6 addresses set");
7177 if (!v4_address_set && !v6_address_set)
7179 errmsg ("no address set");
7183 /* Construct the API message */
7184 M (IP_NEIGHBOR_ADD_DEL, mp);
7186 mp->sw_if_index = ntohl (sw_if_index);
7187 mp->is_add = is_add;
7188 mp->is_static = is_static;
7190 clib_memcpy (mp->mac_address, mac_address, 6);
7194 clib_memcpy (mp->dst_address, &v6address, sizeof (v6address));
7198 /* mp->is_ipv6 = 0; via memset in M macro above */
7199 clib_memcpy (mp->dst_address, &v4address, sizeof (v4address));
7205 /* Wait for a reply, return good/bad news */
7211 api_reset_vrf (vat_main_t * vam)
7213 unformat_input_t *i = vam->input;
7214 vl_api_reset_vrf_t *mp;
7220 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7222 if (unformat (i, "vrf %d", &vrf_id))
7224 else if (unformat (i, "ipv6"))
7228 clib_warning ("parse error '%U'", format_unformat_error, i);
7233 if (vrf_id_set == 0)
7235 errmsg ("missing vrf id");
7241 mp->vrf_id = ntohl (vrf_id);
7242 mp->is_ipv6 = is_ipv6;
7250 api_create_vlan_subif (vat_main_t * vam)
7252 unformat_input_t *i = vam->input;
7253 vl_api_create_vlan_subif_t *mp;
7255 u8 sw_if_index_set = 0;
7260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7262 if (unformat (i, "sw_if_index %d", &sw_if_index))
7263 sw_if_index_set = 1;
7265 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7266 sw_if_index_set = 1;
7267 else if (unformat (i, "vlan %d", &vlan_id))
7271 clib_warning ("parse error '%U'", format_unformat_error, i);
7276 if (sw_if_index_set == 0)
7278 errmsg ("missing interface name or sw_if_index");
7282 if (vlan_id_set == 0)
7284 errmsg ("missing vlan_id");
7287 M (CREATE_VLAN_SUBIF, mp);
7289 mp->sw_if_index = ntohl (sw_if_index);
7290 mp->vlan_id = ntohl (vlan_id);
7297 #define foreach_create_subif_bit \
7304 _(outer_vlan_id_any) \
7305 _(inner_vlan_id_any)
7308 api_create_subif (vat_main_t * vam)
7310 unformat_input_t *i = vam->input;
7311 vl_api_create_subif_t *mp;
7313 u8 sw_if_index_set = 0;
7320 u32 exact_match = 0;
7321 u32 default_sub = 0;
7322 u32 outer_vlan_id_any = 0;
7323 u32 inner_vlan_id_any = 0;
7325 u16 outer_vlan_id = 0;
7326 u16 inner_vlan_id = 0;
7329 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7331 if (unformat (i, "sw_if_index %d", &sw_if_index))
7332 sw_if_index_set = 1;
7334 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7335 sw_if_index_set = 1;
7336 else if (unformat (i, "sub_id %d", &sub_id))
7338 else if (unformat (i, "outer_vlan_id %d", &tmp))
7339 outer_vlan_id = tmp;
7340 else if (unformat (i, "inner_vlan_id %d", &tmp))
7341 inner_vlan_id = tmp;
7343 #define _(a) else if (unformat (i, #a)) a = 1 ;
7344 foreach_create_subif_bit
7348 clib_warning ("parse error '%U'", format_unformat_error, i);
7353 if (sw_if_index_set == 0)
7355 errmsg ("missing interface name or sw_if_index");
7359 if (sub_id_set == 0)
7361 errmsg ("missing sub_id");
7364 M (CREATE_SUBIF, mp);
7366 mp->sw_if_index = ntohl (sw_if_index);
7367 mp->sub_id = ntohl (sub_id);
7369 #define _(a) mp->a = a;
7370 foreach_create_subif_bit;
7373 mp->outer_vlan_id = ntohs (outer_vlan_id);
7374 mp->inner_vlan_id = ntohs (inner_vlan_id);
7382 api_oam_add_del (vat_main_t * vam)
7384 unformat_input_t *i = vam->input;
7385 vl_api_oam_add_del_t *mp;
7388 ip4_address_t src, dst;
7393 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7395 if (unformat (i, "vrf %d", &vrf_id))
7397 else if (unformat (i, "src %U", unformat_ip4_address, &src))
7399 else if (unformat (i, "dst %U", unformat_ip4_address, &dst))
7401 else if (unformat (i, "del"))
7405 clib_warning ("parse error '%U'", format_unformat_error, i);
7412 errmsg ("missing src addr");
7418 errmsg ("missing dst addr");
7422 M (OAM_ADD_DEL, mp);
7424 mp->vrf_id = ntohl (vrf_id);
7425 mp->is_add = is_add;
7426 clib_memcpy (mp->src_address, &src, sizeof (mp->src_address));
7427 clib_memcpy (mp->dst_address, &dst, sizeof (mp->dst_address));
7435 api_reset_fib (vat_main_t * vam)
7437 unformat_input_t *i = vam->input;
7438 vl_api_reset_fib_t *mp;
7444 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7446 if (unformat (i, "vrf %d", &vrf_id))
7448 else if (unformat (i, "ipv6"))
7452 clib_warning ("parse error '%U'", format_unformat_error, i);
7457 if (vrf_id_set == 0)
7459 errmsg ("missing vrf id");
7465 mp->vrf_id = ntohl (vrf_id);
7466 mp->is_ipv6 = is_ipv6;
7474 api_dhcp_proxy_config (vat_main_t * vam)
7476 unformat_input_t *i = vam->input;
7477 vl_api_dhcp_proxy_config_t *mp;
7479 u32 server_vrf_id = 0;
7481 u8 v4_address_set = 0;
7482 u8 v6_address_set = 0;
7483 ip4_address_t v4address;
7484 ip6_address_t v6address;
7485 u8 v4_src_address_set = 0;
7486 u8 v6_src_address_set = 0;
7487 ip4_address_t v4srcaddress;
7488 ip6_address_t v6srcaddress;
7491 /* Parse args required to build the message */
7492 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7494 if (unformat (i, "del"))
7496 else if (unformat (i, "rx_vrf_id %d", &rx_vrf_id))
7498 else if (unformat (i, "server_vrf_id %d", &server_vrf_id))
7500 else if (unformat (i, "svr %U", unformat_ip4_address, &v4address))
7502 else if (unformat (i, "svr %U", unformat_ip6_address, &v6address))
7504 else if (unformat (i, "src %U", unformat_ip4_address, &v4srcaddress))
7505 v4_src_address_set = 1;
7506 else if (unformat (i, "src %U", unformat_ip6_address, &v6srcaddress))
7507 v6_src_address_set = 1;
7512 if (v4_address_set && v6_address_set)
7514 errmsg ("both v4 and v6 server addresses set");
7517 if (!v4_address_set && !v6_address_set)
7519 errmsg ("no server addresses set");
7523 if (v4_src_address_set && v6_src_address_set)
7525 errmsg ("both v4 and v6 src addresses set");
7528 if (!v4_src_address_set && !v6_src_address_set)
7530 errmsg ("no src addresses set");
7534 if (!(v4_src_address_set && v4_address_set) &&
7535 !(v6_src_address_set && v6_address_set))
7537 errmsg ("no matching server and src addresses set");
7541 /* Construct the API message */
7542 M (DHCP_PROXY_CONFIG, mp);
7544 mp->is_add = is_add;
7545 mp->rx_vrf_id = ntohl (rx_vrf_id);
7546 mp->server_vrf_id = ntohl (server_vrf_id);
7550 clib_memcpy (mp->dhcp_server, &v6address, sizeof (v6address));
7551 clib_memcpy (mp->dhcp_src_address, &v6srcaddress, sizeof (v6address));
7555 clib_memcpy (mp->dhcp_server, &v4address, sizeof (v4address));
7556 clib_memcpy (mp->dhcp_src_address, &v4srcaddress, sizeof (v4address));
7562 /* Wait for a reply, return good/bad news */
7567 #define vl_api_dhcp_proxy_details_t_endian vl_noop_handler
7568 #define vl_api_dhcp_proxy_details_t_print vl_noop_handler
7571 vl_api_dhcp_proxy_details_t_handler (vl_api_dhcp_proxy_details_t * mp)
7573 vat_main_t *vam = &vat_main;
7577 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7578 ntohl (mp->rx_vrf_id),
7579 ntohl (mp->server_vrf_id),
7580 format_ip6_address, mp->dhcp_server,
7581 format_ip6_address, mp->dhcp_src_address,
7582 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7585 "RX Table-ID %d, Server Table-ID %d, Server Address %U, Source Address %U, VSS FIB-ID %d, VSS OUI %d",
7586 ntohl (mp->rx_vrf_id),
7587 ntohl (mp->server_vrf_id),
7588 format_ip4_address, mp->dhcp_server,
7589 format_ip4_address, mp->dhcp_src_address,
7590 ntohl (mp->vss_oui), ntohl (mp->vss_fib_id));
7593 static void vl_api_dhcp_proxy_details_t_handler_json
7594 (vl_api_dhcp_proxy_details_t * mp)
7596 vat_main_t *vam = &vat_main;
7597 vat_json_node_t *node = NULL;
7599 struct in6_addr ip6;
7601 if (VAT_JSON_ARRAY != vam->json_tree.type)
7603 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
7604 vat_json_init_array (&vam->json_tree);
7606 node = vat_json_array_add (&vam->json_tree);
7608 vat_json_init_object (node);
7609 vat_json_object_add_uint (node, "rx-table-id", ntohl (mp->rx_vrf_id));
7610 vat_json_object_add_uint (node, "server-table-id",
7611 ntohl (mp->server_vrf_id));
7614 clib_memcpy (&ip6, &mp->dhcp_server, sizeof (ip6));
7615 vat_json_object_add_ip6 (node, "server_address", ip6);
7616 clib_memcpy (&ip6, &mp->dhcp_src_address, sizeof (ip6));
7617 vat_json_object_add_ip6 (node, "src_address", ip6);
7621 clib_memcpy (&ip4, &mp->dhcp_server, sizeof (ip4));
7622 vat_json_object_add_ip4 (node, "server_address", ip4);
7623 clib_memcpy (&ip4, &mp->dhcp_src_address, sizeof (ip4));
7624 vat_json_object_add_ip4 (node, "src_address", ip4);
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 api_dhcp_proxy_dump (vat_main_t * vam)
7633 unformat_input_t *i = vam->input;
7634 vl_api_control_ping_t *mp_ping;
7635 vl_api_dhcp_proxy_dump_t *mp;
7639 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7641 if (unformat (i, "ipv6"))
7645 clib_warning ("parse error '%U'", format_unformat_error, i);
7650 M (DHCP_PROXY_DUMP, mp);
7652 mp->is_ip6 = is_ipv6;
7655 /* Use a control ping for synchronization */
7656 M (CONTROL_PING, mp_ping);
7664 api_dhcp_proxy_set_vss (vat_main_t * vam)
7666 unformat_input_t *i = vam->input;
7667 vl_api_dhcp_proxy_set_vss_t *mp;
7678 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7680 if (unformat (i, "tbl_id %d", &tbl_id))
7682 if (unformat (i, "fib_id %d", &fib_id))
7684 if (unformat (i, "oui %d", &oui))
7686 else if (unformat (i, "ipv6"))
7688 else if (unformat (i, "del"))
7692 clib_warning ("parse error '%U'", format_unformat_error, i);
7697 if (tbl_id_set == 0)
7699 errmsg ("missing tbl id");
7703 if (fib_id_set == 0)
7705 errmsg ("missing fib id");
7710 errmsg ("missing oui");
7714 M (DHCP_PROXY_SET_VSS, mp);
7715 mp->tbl_id = ntohl (tbl_id);
7716 mp->fib_id = ntohl (fib_id);
7717 mp->oui = ntohl (oui);
7718 mp->is_ipv6 = is_ipv6;
7719 mp->is_add = is_add;
7727 api_dhcp_client_config (vat_main_t * vam)
7729 unformat_input_t *i = vam->input;
7730 vl_api_dhcp_client_config_t *mp;
7732 u8 sw_if_index_set = 0;
7735 u8 disable_event = 0;
7738 /* Parse args required to build the message */
7739 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7741 if (unformat (i, "del"))
7744 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7745 sw_if_index_set = 1;
7746 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7747 sw_if_index_set = 1;
7748 else if (unformat (i, "hostname %s", &hostname))
7750 else if (unformat (i, "disable_event"))
7756 if (sw_if_index_set == 0)
7758 errmsg ("missing interface name or sw_if_index");
7762 if (vec_len (hostname) > 63)
7764 errmsg ("hostname too long");
7766 vec_add1 (hostname, 0);
7768 /* Construct the API message */
7769 M (DHCP_CLIENT_CONFIG, mp);
7771 mp->sw_if_index = ntohl (sw_if_index);
7772 clib_memcpy (mp->hostname, hostname, vec_len (hostname));
7773 vec_free (hostname);
7774 mp->is_add = is_add;
7775 mp->want_dhcp_event = disable_event ? 0 : 1;
7776 mp->pid = getpid ();
7781 /* Wait for a reply, return good/bad news */
7787 api_set_ip_flow_hash (vat_main_t * vam)
7789 unformat_input_t *i = vam->input;
7790 vl_api_set_ip_flow_hash_t *mp;
7802 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7804 if (unformat (i, "vrf %d", &vrf_id))
7806 else if (unformat (i, "ipv6"))
7808 else if (unformat (i, "src"))
7810 else if (unformat (i, "dst"))
7812 else if (unformat (i, "sport"))
7814 else if (unformat (i, "dport"))
7816 else if (unformat (i, "proto"))
7818 else if (unformat (i, "reverse"))
7823 clib_warning ("parse error '%U'", format_unformat_error, i);
7828 if (vrf_id_set == 0)
7830 errmsg ("missing vrf id");
7834 M (SET_IP_FLOW_HASH, mp);
7840 mp->reverse = reverse;
7841 mp->vrf_id = ntohl (vrf_id);
7842 mp->is_ipv6 = is_ipv6;
7850 api_sw_interface_ip6_enable_disable (vat_main_t * vam)
7852 unformat_input_t *i = vam->input;
7853 vl_api_sw_interface_ip6_enable_disable_t *mp;
7855 u8 sw_if_index_set = 0;
7859 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7861 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7862 sw_if_index_set = 1;
7863 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7864 sw_if_index_set = 1;
7865 else if (unformat (i, "enable"))
7867 else if (unformat (i, "disable"))
7871 clib_warning ("parse error '%U'", format_unformat_error, i);
7876 if (sw_if_index_set == 0)
7878 errmsg ("missing interface name or sw_if_index");
7882 M (SW_INTERFACE_IP6_ENABLE_DISABLE, mp);
7884 mp->sw_if_index = ntohl (sw_if_index);
7885 mp->enable = enable;
7893 api_sw_interface_ip6_set_link_local_address (vat_main_t * vam)
7895 unformat_input_t *i = vam->input;
7896 vl_api_sw_interface_ip6_set_link_local_address_t *mp;
7898 u8 sw_if_index_set = 0;
7899 u8 v6_address_set = 0;
7900 ip6_address_t v6address;
7903 /* Parse args required to build the message */
7904 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7906 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7907 sw_if_index_set = 1;
7908 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7909 sw_if_index_set = 1;
7910 else if (unformat (i, "%U", unformat_ip6_address, &v6address))
7916 if (sw_if_index_set == 0)
7918 errmsg ("missing interface name or sw_if_index");
7921 if (!v6_address_set)
7923 errmsg ("no address set");
7927 /* Construct the API message */
7928 M (SW_INTERFACE_IP6_SET_LINK_LOCAL_ADDRESS, mp);
7930 mp->sw_if_index = ntohl (sw_if_index);
7931 clib_memcpy (mp->address, &v6address, sizeof (v6address));
7936 /* Wait for a reply, return good/bad news */
7943 api_sw_interface_ip6nd_ra_prefix (vat_main_t * vam)
7945 unformat_input_t *i = vam->input;
7946 vl_api_sw_interface_ip6nd_ra_prefix_t *mp;
7948 u8 sw_if_index_set = 0;
7949 u32 address_length = 0;
7950 u8 v6_address_set = 0;
7951 ip6_address_t v6address;
7953 u8 no_advertise = 0;
7955 u8 no_autoconfig = 0;
7958 u32 val_lifetime = 0;
7959 u32 pref_lifetime = 0;
7962 /* Parse args required to build the message */
7963 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
7965 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
7966 sw_if_index_set = 1;
7967 else if (unformat (i, "sw_if_index %d", &sw_if_index))
7968 sw_if_index_set = 1;
7969 else if (unformat (i, "%U/%d",
7970 unformat_ip6_address, &v6address, &address_length))
7972 else if (unformat (i, "val_life %d", &val_lifetime))
7974 else if (unformat (i, "pref_life %d", &pref_lifetime))
7976 else if (unformat (i, "def"))
7978 else if (unformat (i, "noadv"))
7980 else if (unformat (i, "offl"))
7982 else if (unformat (i, "noauto"))
7984 else if (unformat (i, "nolink"))
7986 else if (unformat (i, "isno"))
7990 clib_warning ("parse error '%U'", format_unformat_error, i);
7995 if (sw_if_index_set == 0)
7997 errmsg ("missing interface name or sw_if_index");
8000 if (!v6_address_set)
8002 errmsg ("no address set");
8006 /* Construct the API message */
8007 M (SW_INTERFACE_IP6ND_RA_PREFIX, mp);
8009 mp->sw_if_index = ntohl (sw_if_index);
8010 clib_memcpy (mp->address, &v6address, sizeof (v6address));
8011 mp->address_length = address_length;
8012 mp->use_default = use_default;
8013 mp->no_advertise = no_advertise;
8014 mp->off_link = off_link;
8015 mp->no_autoconfig = no_autoconfig;
8016 mp->no_onlink = no_onlink;
8018 mp->val_lifetime = ntohl (val_lifetime);
8019 mp->pref_lifetime = ntohl (pref_lifetime);
8024 /* Wait for a reply, return good/bad news */
8030 api_sw_interface_ip6nd_ra_config (vat_main_t * vam)
8032 unformat_input_t *i = vam->input;
8033 vl_api_sw_interface_ip6nd_ra_config_t *mp;
8035 u8 sw_if_index_set = 0;
8040 u8 send_unicast = 0;
8043 u8 default_router = 0;
8044 u32 max_interval = 0;
8045 u32 min_interval = 0;
8047 u32 initial_count = 0;
8048 u32 initial_interval = 0;
8052 /* Parse args required to build the message */
8053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8055 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
8056 sw_if_index_set = 1;
8057 else if (unformat (i, "sw_if_index %d", &sw_if_index))
8058 sw_if_index_set = 1;
8059 else if (unformat (i, "maxint %d", &max_interval))
8061 else if (unformat (i, "minint %d", &min_interval))
8063 else if (unformat (i, "life %d", &lifetime))
8065 else if (unformat (i, "count %d", &initial_count))
8067 else if (unformat (i, "interval %d", &initial_interval))
8069 else if (unformat (i, "suppress") || unformat (i, "surpress"))
8071 else if (unformat (i, "managed"))
8073 else if (unformat (i, "other"))
8075 else if (unformat (i, "ll"))
8077 else if (unformat (i, "send"))
8079 else if (unformat (i, "cease"))
8081 else if (unformat (i, "isno"))
8083 else if (unformat (i, "def"))
8087 clib_warning ("parse error '%U'", format_unformat_error, i);
8092 if (sw_if_index_set == 0)
8094 errmsg ("missing interface name or sw_if_index");
8098 /* Construct the API message */
8099 M (SW_INTERFACE_IP6ND_RA_CONFIG, mp);
8101 mp->sw_if_index = ntohl (sw_if_index);
8102 mp->max_interval = ntohl (max_interval);
8103 mp->min_interval = ntohl (min_interval);
8104 mp->lifetime = ntohl (lifetime);
8105 mp->initial_count = ntohl (initial_count);
8106 mp->initial_interval = ntohl (initial_interval);
8107 mp->suppress = suppress;
8108 mp->managed = managed;
8110 mp->ll_option = ll_option;
8111 mp->send_unicast = send_unicast;
8114 mp->default_router = default_router;
8119 /* Wait for a reply, return good/bad news */
8125 api_set_arp_neighbor_limit (vat_main_t * vam)
8127 unformat_input_t *i = vam->input;
8128 vl_api_set_arp_neighbor_limit_t *mp;
8134 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8136 if (unformat (i, "arp_nbr_limit %d", &arp_nbr_limit))
8138 else if (unformat (i, "ipv6"))
8142 clib_warning ("parse error '%U'", format_unformat_error, i);
8149 errmsg ("missing limit value");
8153 M (SET_ARP_NEIGHBOR_LIMIT, mp);
8155 mp->arp_neighbor_limit = ntohl (arp_nbr_limit);
8156 mp->is_ipv6 = is_ipv6;
8164 api_l2_patch_add_del (vat_main_t * vam)
8166 unformat_input_t *i = vam->input;
8167 vl_api_l2_patch_add_del_t *mp;
8169 u8 rx_sw_if_index_set = 0;
8171 u8 tx_sw_if_index_set = 0;
8175 /* Parse args required to build the message */
8176 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8178 if (unformat (i, "rx_sw_if_index %d", &rx_sw_if_index))
8179 rx_sw_if_index_set = 1;
8180 else if (unformat (i, "tx_sw_if_index %d", &tx_sw_if_index))
8181 tx_sw_if_index_set = 1;
8182 else if (unformat (i, "rx"))
8184 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8186 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8188 rx_sw_if_index_set = 1;
8193 else if (unformat (i, "tx"))
8195 if (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8197 if (unformat (i, "%U", api_unformat_sw_if_index, vam,
8199 tx_sw_if_index_set = 1;
8204 else if (unformat (i, "del"))
8210 if (rx_sw_if_index_set == 0)
8212 errmsg ("missing rx interface name or rx_sw_if_index");
8216 if (tx_sw_if_index_set == 0)
8218 errmsg ("missing tx interface name or tx_sw_if_index");
8222 M (L2_PATCH_ADD_DEL, mp);
8224 mp->rx_sw_if_index = ntohl (rx_sw_if_index);
8225 mp->tx_sw_if_index = ntohl (tx_sw_if_index);
8226 mp->is_add = is_add;
8234 u8 localsid_addr[16];
8243 api_sr_localsid_add_del (vat_main_t * vam)
8245 unformat_input_t *i = vam->input;
8246 vl_api_sr_localsid_add_del_t *mp;
8249 ip6_address_t localsid;
8253 u32 fib_table = ~(u32) 0;
8254 ip6_address_t next_hop;
8256 bool nexthop_set = 0;
8260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8262 if (unformat (i, "del"))
8264 else if (unformat (i, "address %U", unformat_ip6_address, &localsid));
8265 else if (unformat (i, "next-hop %U", unformat_ip6_address, &next_hop))
8267 else if (unformat (i, "behavior %u", &behavior));
8268 else if (unformat (i, "sw_if_index %u", &sw_if_index));
8269 else if (unformat (i, "fib-table %u", &fib_table));
8270 else if (unformat (i, "end.psp %u", &behavior));
8275 M (SR_LOCALSID_ADD_DEL, mp);
8277 clib_memcpy (mp->localsid_addr, &localsid, sizeof (mp->localsid_addr));
8279 clib_memcpy (mp->nh_addr, &next_hop, sizeof (mp->nh_addr));
8280 mp->behavior = behavior;
8281 mp->sw_if_index = ntohl (sw_if_index);
8282 mp->fib_table = ntohl (fib_table);
8283 mp->end_psp = end_psp;
8284 mp->is_del = is_del;
8292 api_ioam_enable (vat_main_t * vam)
8294 unformat_input_t *input = vam->input;
8295 vl_api_ioam_enable_t *mp;
8297 int has_trace_option = 0;
8298 int has_pot_option = 0;
8299 int has_seqno_option = 0;
8300 int has_analyse_option = 0;
8303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8305 if (unformat (input, "trace"))
8306 has_trace_option = 1;
8307 else if (unformat (input, "pot"))
8309 else if (unformat (input, "seqno"))
8310 has_seqno_option = 1;
8311 else if (unformat (input, "analyse"))
8312 has_analyse_option = 1;
8316 M (IOAM_ENABLE, mp);
8317 mp->id = htons (id);
8318 mp->seqno = has_seqno_option;
8319 mp->analyse = has_analyse_option;
8320 mp->pot_enable = has_pot_option;
8321 mp->trace_enable = has_trace_option;
8330 api_ioam_disable (vat_main_t * vam)
8332 vl_api_ioam_disable_t *mp;
8335 M (IOAM_DISABLE, mp);
8341 #define foreach_tcp_proto_field \
8345 #define foreach_udp_proto_field \
8349 #define foreach_ip4_proto_field \
8361 u16 src_port, dst_port;
8364 #if VPP_API_TEST_BUILTIN == 0
8366 unformat_tcp_mask (unformat_input_t * input, va_list * args)
8368 u8 **maskp = va_arg (*args, u8 **);
8370 u8 found_something = 0;
8373 #define _(a) u8 a=0;
8374 foreach_tcp_proto_field;
8377 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8380 #define _(a) else if (unformat (input, #a)) a=1;
8381 foreach_tcp_proto_field
8387 #define _(a) found_something += a;
8388 foreach_tcp_proto_field;
8391 if (found_something == 0)
8394 vec_validate (mask, sizeof (*tcp) - 1);
8396 tcp = (tcp_header_t *) mask;
8398 #define _(a) if (a) memset (&tcp->a, 0xff, sizeof (tcp->a));
8399 foreach_tcp_proto_field;
8407 unformat_udp_mask (unformat_input_t * input, va_list * args)
8409 u8 **maskp = va_arg (*args, u8 **);
8411 u8 found_something = 0;
8414 #define _(a) u8 a=0;
8415 foreach_udp_proto_field;
8418 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8421 #define _(a) else if (unformat (input, #a)) a=1;
8422 foreach_udp_proto_field
8428 #define _(a) found_something += a;
8429 foreach_udp_proto_field;
8432 if (found_something == 0)
8435 vec_validate (mask, sizeof (*udp) - 1);
8437 udp = (udp_header_t *) mask;
8439 #define _(a) if (a) memset (&udp->a, 0xff, sizeof (udp->a));
8440 foreach_udp_proto_field;
8448 unformat_l4_mask (unformat_input_t * input, va_list * args)
8450 u8 **maskp = va_arg (*args, u8 **);
8451 u16 src_port = 0, dst_port = 0;
8452 tcpudp_header_t *tcpudp;
8454 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8456 if (unformat (input, "tcp %U", unformat_tcp_mask, maskp))
8458 else if (unformat (input, "udp %U", unformat_udp_mask, maskp))
8460 else if (unformat (input, "src_port"))
8462 else if (unformat (input, "dst_port"))
8468 if (!src_port && !dst_port)
8472 vec_validate (mask, sizeof (tcpudp_header_t) - 1);
8474 tcpudp = (tcpudp_header_t *) mask;
8475 tcpudp->src_port = src_port;
8476 tcpudp->dst_port = dst_port;
8484 unformat_ip4_mask (unformat_input_t * input, va_list * args)
8486 u8 **maskp = va_arg (*args, u8 **);
8488 u8 found_something = 0;
8491 #define _(a) u8 a=0;
8492 foreach_ip4_proto_field;
8498 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8500 if (unformat (input, "version"))
8502 else if (unformat (input, "hdr_length"))
8504 else if (unformat (input, "src"))
8506 else if (unformat (input, "dst"))
8508 else if (unformat (input, "proto"))
8511 #define _(a) else if (unformat (input, #a)) a=1;
8512 foreach_ip4_proto_field
8518 #define _(a) found_something += a;
8519 foreach_ip4_proto_field;
8522 if (found_something == 0)
8525 vec_validate (mask, sizeof (*ip) - 1);
8527 ip = (ip4_header_t *) mask;
8529 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8530 foreach_ip4_proto_field;
8533 ip->ip_version_and_header_length = 0;
8536 ip->ip_version_and_header_length |= 0xF0;
8539 ip->ip_version_and_header_length |= 0x0F;
8545 #define foreach_ip6_proto_field \
8553 unformat_ip6_mask (unformat_input_t * input, va_list * args)
8555 u8 **maskp = va_arg (*args, u8 **);
8557 u8 found_something = 0;
8559 u32 ip_version_traffic_class_and_flow_label;
8561 #define _(a) u8 a=0;
8562 foreach_ip6_proto_field;
8565 u8 traffic_class = 0;
8568 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8570 if (unformat (input, "version"))
8572 else if (unformat (input, "traffic-class"))
8574 else if (unformat (input, "flow-label"))
8576 else if (unformat (input, "src"))
8578 else if (unformat (input, "dst"))
8580 else if (unformat (input, "proto"))
8583 #define _(a) else if (unformat (input, #a)) a=1;
8584 foreach_ip6_proto_field
8590 #define _(a) found_something += a;
8591 foreach_ip6_proto_field;
8594 if (found_something == 0)
8597 vec_validate (mask, sizeof (*ip) - 1);
8599 ip = (ip6_header_t *) mask;
8601 #define _(a) if (a) memset (&ip->a, 0xff, sizeof (ip->a));
8602 foreach_ip6_proto_field;
8605 ip_version_traffic_class_and_flow_label = 0;
8608 ip_version_traffic_class_and_flow_label |= 0xF0000000;
8611 ip_version_traffic_class_and_flow_label |= 0x0FF00000;
8614 ip_version_traffic_class_and_flow_label |= 0x000FFFFF;
8616 ip->ip_version_traffic_class_and_flow_label =
8617 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
8624 unformat_l3_mask (unformat_input_t * input, va_list * args)
8626 u8 **maskp = va_arg (*args, u8 **);
8628 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8630 if (unformat (input, "ip4 %U", unformat_ip4_mask, maskp))
8632 else if (unformat (input, "ip6 %U", unformat_ip6_mask, maskp))
8641 unformat_l2_mask (unformat_input_t * input, va_list * args)
8643 u8 **maskp = va_arg (*args, u8 **);
8658 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8660 if (unformat (input, "src"))
8662 else if (unformat (input, "dst"))
8664 else if (unformat (input, "proto"))
8666 else if (unformat (input, "tag1"))
8668 else if (unformat (input, "tag2"))
8670 else if (unformat (input, "ignore-tag1"))
8672 else if (unformat (input, "ignore-tag2"))
8674 else if (unformat (input, "cos1"))
8676 else if (unformat (input, "cos2"))
8678 else if (unformat (input, "dot1q"))
8680 else if (unformat (input, "dot1ad"))
8685 if ((src + dst + proto + tag1 + tag2 + dot1q + dot1ad +
8686 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
8689 if (tag1 || ignore_tag1 || cos1 || dot1q)
8691 if (tag2 || ignore_tag2 || cos2 || dot1ad)
8694 vec_validate (mask, len - 1);
8697 memset (mask, 0xff, 6);
8700 memset (mask + 6, 0xff, 6);
8704 /* inner vlan tag */
8713 mask[21] = mask[20] = 0xff;
8734 mask[16] = mask[17] = 0xff;
8744 mask[12] = mask[13] = 0xff;
8751 unformat_classify_mask (unformat_input_t * input, va_list * args)
8753 u8 **maskp = va_arg (*args, u8 **);
8754 u32 *skipp = va_arg (*args, u32 *);
8755 u32 *matchp = va_arg (*args, u32 *);
8763 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
8765 if (unformat (input, "hex %U", unformat_hex_string, &mask))
8767 else if (unformat (input, "l2 %U", unformat_l2_mask, &l2))
8769 else if (unformat (input, "l3 %U", unformat_l3_mask, &l3))
8771 else if (unformat (input, "l4 %U", unformat_l4_mask, &l4))
8785 if (mask || l2 || l3 || l4)
8789 /* "With a free Ethernet header in every package" */
8791 vec_validate (l2, 13);
8795 vec_append (mask, l3);
8800 vec_append (mask, l4);
8805 /* Scan forward looking for the first significant mask octet */
8806 for (i = 0; i < vec_len (mask); i++)
8810 /* compute (skip, match) params */
8811 *skipp = i / sizeof (u32x4);
8812 vec_delete (mask, *skipp * sizeof (u32x4), 0);
8814 /* Pad mask to an even multiple of the vector size */
8815 while (vec_len (mask) % sizeof (u32x4))
8818 match = vec_len (mask) / sizeof (u32x4);
8820 for (i = match * sizeof (u32x4); i > 0; i -= sizeof (u32x4))
8822 u64 *tmp = (u64 *) (mask + (i - sizeof (u32x4)));
8823 if (*tmp || *(tmp + 1))
8828 clib_warning ("BUG: match 0");
8830 _vec_len (mask) = match * sizeof (u32x4);
8840 #endif /* VPP_API_TEST_BUILTIN */
8842 #define foreach_l2_next \
8844 _(ethernet, ETHERNET_INPUT) \
8849 unformat_l2_next_index (unformat_input_t * input, va_list * args)
8851 u32 *miss_next_indexp = va_arg (*args, u32 *);
8856 if (unformat (input, #n)) { next_index = L2_INPUT_CLASSIFY_NEXT_##N; goto out;}
8860 if (unformat (input, "%d", &tmp))
8869 *miss_next_indexp = next_index;
8873 #define foreach_ip_next \
8879 api_unformat_ip_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 = IP_LOOKUP_NEXT_##N; goto out;}
8890 if (unformat (input, "%d", &tmp))
8899 *miss_next_indexp = next_index;
8903 #define foreach_acl_next \
8907 api_unformat_acl_next_index (unformat_input_t * input, va_list * args)
8909 u32 *miss_next_indexp = va_arg (*args, u32 *);
8914 if (unformat (input, #n)) { next_index = ACL_NEXT_INDEX_##N; goto out;}
8918 if (unformat (input, "permit"))
8923 else if (unformat (input, "%d", &tmp))
8932 *miss_next_indexp = next_index;
8937 unformat_policer_precolor (unformat_input_t * input, va_list * args)
8939 u32 *r = va_arg (*args, u32 *);
8941 if (unformat (input, "conform-color"))
8942 *r = POLICE_CONFORM;
8943 else if (unformat (input, "exceed-color"))
8952 api_classify_add_del_table (vat_main_t * vam)
8954 unformat_input_t *i = vam->input;
8955 vl_api_classify_add_del_table_t *mp;
8962 u32 table_index = ~0;
8963 u32 next_table_index = ~0;
8964 u32 miss_next_index = ~0;
8965 u32 memory_size = 32 << 20;
8967 u32 current_data_flag = 0;
8968 int current_data_offset = 0;
8971 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
8973 if (unformat (i, "del"))
8975 else if (unformat (i, "del-chain"))
8980 else if (unformat (i, "buckets %d", &nbuckets))
8982 else if (unformat (i, "memory_size %d", &memory_size))
8984 else if (unformat (i, "skip %d", &skip))
8986 else if (unformat (i, "match %d", &match))
8988 else if (unformat (i, "table %d", &table_index))
8990 else if (unformat (i, "mask %U", unformat_classify_mask,
8991 &mask, &skip, &match))
8993 else if (unformat (i, "next-table %d", &next_table_index))
8995 else if (unformat (i, "miss-next %U", api_unformat_ip_next_index,
8998 else if (unformat (i, "l2-miss-next %U", unformat_l2_next_index,
9001 else if (unformat (i, "acl-miss-next %U", api_unformat_acl_next_index,
9004 else if (unformat (i, "current-data-flag %d", ¤t_data_flag))
9006 else if (unformat (i, "current-data-offset %d", ¤t_data_offset))
9012 if (is_add && mask == 0)
9014 errmsg ("Mask required");
9018 if (is_add && skip == ~0)
9020 errmsg ("skip count required");
9024 if (is_add && match == ~0)
9026 errmsg ("match count required");
9030 if (!is_add && table_index == ~0)
9032 errmsg ("table index required for delete");
9036 M2 (CLASSIFY_ADD_DEL_TABLE, mp, vec_len (mask));
9038 mp->is_add = is_add;
9039 mp->del_chain = del_chain;
9040 mp->table_index = ntohl (table_index);
9041 mp->nbuckets = ntohl (nbuckets);
9042 mp->memory_size = ntohl (memory_size);
9043 mp->skip_n_vectors = ntohl (skip);
9044 mp->match_n_vectors = ntohl (match);
9045 mp->next_table_index = ntohl (next_table_index);
9046 mp->miss_next_index = ntohl (miss_next_index);
9047 mp->current_data_flag = ntohl (current_data_flag);
9048 mp->current_data_offset = ntohl (current_data_offset);
9049 clib_memcpy (mp->mask, mask, vec_len (mask));
9058 #if VPP_API_TEST_BUILTIN == 0
9060 unformat_l4_match (unformat_input_t * input, va_list * args)
9062 u8 **matchp = va_arg (*args, u8 **);
9064 u8 *proto_header = 0;
9070 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9072 if (unformat (input, "src_port %d", &src_port))
9074 else if (unformat (input, "dst_port %d", &dst_port))
9080 h.src_port = clib_host_to_net_u16 (src_port);
9081 h.dst_port = clib_host_to_net_u16 (dst_port);
9082 vec_validate (proto_header, sizeof (h) - 1);
9083 memcpy (proto_header, &h, sizeof (h));
9085 *matchp = proto_header;
9091 unformat_ip4_match (unformat_input_t * input, va_list * args)
9093 u8 **matchp = va_arg (*args, u8 **);
9100 int src = 0, dst = 0;
9101 ip4_address_t src_val, dst_val;
9108 int fragment_id = 0;
9109 u32 fragment_id_val;
9115 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9117 if (unformat (input, "version %d", &version_val))
9119 else if (unformat (input, "hdr_length %d", &hdr_length_val))
9121 else if (unformat (input, "src %U", unformat_ip4_address, &src_val))
9123 else if (unformat (input, "dst %U", unformat_ip4_address, &dst_val))
9125 else if (unformat (input, "proto %d", &proto_val))
9127 else if (unformat (input, "tos %d", &tos_val))
9129 else if (unformat (input, "length %d", &length_val))
9131 else if (unformat (input, "fragment_id %d", &fragment_id_val))
9133 else if (unformat (input, "ttl %d", &ttl_val))
9135 else if (unformat (input, "checksum %d", &checksum_val))
9141 if (version + hdr_length + src + dst + proto + tos + length + fragment_id
9142 + ttl + checksum == 0)
9146 * Aligned because we use the real comparison functions
9148 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9150 ip = (ip4_header_t *) match;
9152 /* These are realistically matched in practice */
9154 ip->src_address.as_u32 = src_val.as_u32;
9157 ip->dst_address.as_u32 = dst_val.as_u32;
9160 ip->protocol = proto_val;
9163 /* These are not, but they're included for completeness */
9165 ip->ip_version_and_header_length |= (version_val & 0xF) << 4;
9168 ip->ip_version_and_header_length |= (hdr_length_val & 0xF);
9174 ip->length = clib_host_to_net_u16 (length_val);
9180 ip->checksum = clib_host_to_net_u16 (checksum_val);
9187 unformat_ip6_match (unformat_input_t * input, va_list * args)
9189 u8 **matchp = va_arg (*args, u8 **);
9194 u8 traffic_class = 0;
9195 u32 traffic_class_val = 0;
9198 int src = 0, dst = 0;
9199 ip6_address_t src_val, dst_val;
9202 int payload_length = 0;
9203 u32 payload_length_val;
9206 u32 ip_version_traffic_class_and_flow_label;
9208 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9210 if (unformat (input, "version %d", &version_val))
9212 else if (unformat (input, "traffic_class %d", &traffic_class_val))
9214 else if (unformat (input, "flow_label %d", &flow_label_val))
9216 else if (unformat (input, "src %U", unformat_ip6_address, &src_val))
9218 else if (unformat (input, "dst %U", unformat_ip6_address, &dst_val))
9220 else if (unformat (input, "proto %d", &proto_val))
9222 else if (unformat (input, "payload_length %d", &payload_length_val))
9224 else if (unformat (input, "hop_limit %d", &hop_limit_val))
9230 if (version + traffic_class + flow_label + src + dst + proto +
9231 payload_length + hop_limit == 0)
9235 * Aligned because we use the real comparison functions
9237 vec_validate_aligned (match, sizeof (*ip) - 1, sizeof (u32x4));
9239 ip = (ip6_header_t *) match;
9242 clib_memcpy (&ip->src_address, &src_val, sizeof (ip->src_address));
9245 clib_memcpy (&ip->dst_address, &dst_val, sizeof (ip->dst_address));
9248 ip->protocol = proto_val;
9250 ip_version_traffic_class_and_flow_label = 0;
9253 ip_version_traffic_class_and_flow_label |= (version_val & 0xF) << 28;
9256 ip_version_traffic_class_and_flow_label |=
9257 (traffic_class_val & 0xFF) << 20;
9260 ip_version_traffic_class_and_flow_label |= (flow_label_val & 0xFFFFF);
9262 ip->ip_version_traffic_class_and_flow_label =
9263 clib_host_to_net_u32 (ip_version_traffic_class_and_flow_label);
9266 ip->payload_length = clib_host_to_net_u16 (payload_length_val);
9269 ip->hop_limit = hop_limit_val;
9276 unformat_l3_match (unformat_input_t * input, va_list * args)
9278 u8 **matchp = va_arg (*args, u8 **);
9280 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9282 if (unformat (input, "ip4 %U", unformat_ip4_match, matchp))
9284 else if (unformat (input, "ip6 %U", unformat_ip6_match, matchp))
9293 unformat_vlan_tag (unformat_input_t * input, va_list * args)
9295 u8 *tagp = va_arg (*args, u8 *);
9298 if (unformat (input, "%d", &tag))
9300 tagp[0] = (tag >> 8) & 0x0F;
9301 tagp[1] = tag & 0xFF;
9309 unformat_l2_match (unformat_input_t * input, va_list * args)
9311 u8 **matchp = va_arg (*args, u8 **);
9331 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9333 if (unformat (input, "src %U", unformat_ethernet_address, &src_val))
9336 if (unformat (input, "dst %U", unformat_ethernet_address, &dst_val))
9338 else if (unformat (input, "proto %U",
9339 unformat_ethernet_type_host_byte_order, &proto_val))
9341 else if (unformat (input, "tag1 %U", unformat_vlan_tag, tag1_val))
9343 else if (unformat (input, "tag2 %U", unformat_vlan_tag, tag2_val))
9345 else if (unformat (input, "ignore-tag1"))
9347 else if (unformat (input, "ignore-tag2"))
9349 else if (unformat (input, "cos1 %d", &cos1_val))
9351 else if (unformat (input, "cos2 %d", &cos2_val))
9356 if ((src + dst + proto + tag1 + tag2 +
9357 ignore_tag1 + ignore_tag2 + cos1 + cos2) == 0)
9360 if (tag1 || ignore_tag1 || cos1)
9362 if (tag2 || ignore_tag2 || cos2)
9365 vec_validate_aligned (match, len - 1, sizeof (u32x4));
9368 clib_memcpy (match, dst_val, 6);
9371 clib_memcpy (match + 6, src_val, 6);
9375 /* inner vlan tag */
9376 match[19] = tag2_val[1];
9377 match[18] = tag2_val[0];
9379 match[18] |= (cos2_val & 0x7) << 5;
9382 match[21] = proto_val & 0xff;
9383 match[20] = proto_val >> 8;
9387 match[15] = tag1_val[1];
9388 match[14] = tag1_val[0];
9391 match[14] |= (cos1_val & 0x7) << 5;
9397 match[15] = tag1_val[1];
9398 match[14] = tag1_val[0];
9401 match[17] = proto_val & 0xff;
9402 match[16] = proto_val >> 8;
9405 match[14] |= (cos1_val & 0x7) << 5;
9411 match[18] |= (cos2_val & 0x7) << 5;
9413 match[14] |= (cos1_val & 0x7) << 5;
9416 match[13] = proto_val & 0xff;
9417 match[12] = proto_val >> 8;
9426 api_unformat_classify_match (unformat_input_t * input, va_list * args)
9428 u8 **matchp = va_arg (*args, u8 **);
9429 u32 skip_n_vectors = va_arg (*args, u32);
9430 u32 match_n_vectors = va_arg (*args, u32);
9437 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
9439 if (unformat (input, "hex %U", unformat_hex_string, &match))
9441 else if (unformat (input, "l2 %U", unformat_l2_match, &l2))
9443 else if (unformat (input, "l3 %U", unformat_l3_match, &l3))
9445 else if (unformat (input, "l4 %U", unformat_l4_match, &l4))
9459 if (match || l2 || l3 || l4)
9463 /* "Win a free Ethernet header in every packet" */
9465 vec_validate_aligned (l2, 13, sizeof (u32x4));
9469 vec_append_aligned (match, l3, sizeof (u32x4));
9474 vec_append_aligned (match, l4, sizeof (u32x4));
9479 /* Make sure the vector is big enough even if key is all 0's */
9480 vec_validate_aligned
9481 (match, ((match_n_vectors + skip_n_vectors) * sizeof (u32x4)) - 1,
9484 /* Set size, include skipped vectors */
9485 _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
9496 api_classify_add_del_session (vat_main_t * vam)
9498 unformat_input_t *i = vam->input;
9499 vl_api_classify_add_del_session_t *mp;
9501 u32 table_index = ~0;
9502 u32 hit_next_index = ~0;
9503 u32 opaque_index = ~0;
9506 u32 skip_n_vectors = 0;
9507 u32 match_n_vectors = 0;
9513 * Warning: you have to supply skip_n and match_n
9514 * because the API client cant simply look at the classify
9518 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9520 if (unformat (i, "del"))
9522 else if (unformat (i, "hit-next %U", api_unformat_ip_next_index,
9525 else if (unformat (i, "l2-hit-next %U", unformat_l2_next_index,
9528 else if (unformat (i, "acl-hit-next %U", api_unformat_acl_next_index,
9531 else if (unformat (i, "policer-hit-next %d", &hit_next_index))
9533 else if (unformat (i, "%U", unformat_policer_precolor, &opaque_index))
9535 else if (unformat (i, "opaque-index %d", &opaque_index))
9537 else if (unformat (i, "skip_n %d", &skip_n_vectors))
9539 else if (unformat (i, "match_n %d", &match_n_vectors))
9541 else if (unformat (i, "match %U", api_unformat_classify_match,
9542 &match, skip_n_vectors, match_n_vectors))
9544 else if (unformat (i, "advance %d", &advance))
9546 else if (unformat (i, "table-index %d", &table_index))
9548 else if (unformat (i, "action set-ip4-fib-id %d", &metadata))
9550 else if (unformat (i, "action set-ip6-fib-id %d", &metadata))
9552 else if (unformat (i, "action %d", &action))
9554 else if (unformat (i, "metadata %d", &metadata))
9560 if (table_index == ~0)
9562 errmsg ("Table index required");
9566 if (is_add && match == 0)
9568 errmsg ("Match value required");
9572 M2 (CLASSIFY_ADD_DEL_SESSION, mp, vec_len (match));
9574 mp->is_add = is_add;
9575 mp->table_index = ntohl (table_index);
9576 mp->hit_next_index = ntohl (hit_next_index);
9577 mp->opaque_index = ntohl (opaque_index);
9578 mp->advance = ntohl (advance);
9579 mp->action = action;
9580 mp->metadata = ntohl (metadata);
9581 clib_memcpy (mp->match, match, vec_len (match));
9590 api_classify_set_interface_ip_table (vat_main_t * vam)
9592 unformat_input_t *i = vam->input;
9593 vl_api_classify_set_interface_ip_table_t *mp;
9595 int sw_if_index_set;
9596 u32 table_index = ~0;
9600 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9602 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9603 sw_if_index_set = 1;
9604 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9605 sw_if_index_set = 1;
9606 else if (unformat (i, "table %d", &table_index))
9610 clib_warning ("parse error '%U'", format_unformat_error, i);
9615 if (sw_if_index_set == 0)
9617 errmsg ("missing interface name or sw_if_index");
9622 M (CLASSIFY_SET_INTERFACE_IP_TABLE, mp);
9624 mp->sw_if_index = ntohl (sw_if_index);
9625 mp->table_index = ntohl (table_index);
9626 mp->is_ipv6 = is_ipv6;
9634 api_classify_set_interface_l2_tables (vat_main_t * vam)
9636 unformat_input_t *i = vam->input;
9637 vl_api_classify_set_interface_l2_tables_t *mp;
9639 int sw_if_index_set;
9640 u32 ip4_table_index = ~0;
9641 u32 ip6_table_index = ~0;
9642 u32 other_table_index = ~0;
9646 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9648 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
9649 sw_if_index_set = 1;
9650 else if (unformat (i, "sw_if_index %d", &sw_if_index))
9651 sw_if_index_set = 1;
9652 else if (unformat (i, "ip4-table %d", &ip4_table_index))
9654 else if (unformat (i, "ip6-table %d", &ip6_table_index))
9656 else if (unformat (i, "other-table %d", &other_table_index))
9658 else if (unformat (i, "is-input %d", &is_input))
9662 clib_warning ("parse error '%U'", format_unformat_error, i);
9667 if (sw_if_index_set == 0)
9669 errmsg ("missing interface name or sw_if_index");
9674 M (CLASSIFY_SET_INTERFACE_L2_TABLES, mp);
9676 mp->sw_if_index = ntohl (sw_if_index);
9677 mp->ip4_table_index = ntohl (ip4_table_index);
9678 mp->ip6_table_index = ntohl (ip6_table_index);
9679 mp->other_table_index = ntohl (other_table_index);
9680 mp->is_input = (u8) is_input;
9688 api_set_ipfix_exporter (vat_main_t * vam)
9690 unformat_input_t *i = vam->input;
9691 vl_api_set_ipfix_exporter_t *mp;
9692 ip4_address_t collector_address;
9693 u8 collector_address_set = 0;
9694 u32 collector_port = ~0;
9695 ip4_address_t src_address;
9696 u8 src_address_set = 0;
9699 u32 template_interval = ~0;
9700 u8 udp_checksum = 0;
9703 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9705 if (unformat (i, "collector_address %U", unformat_ip4_address,
9706 &collector_address))
9707 collector_address_set = 1;
9708 else if (unformat (i, "collector_port %d", &collector_port))
9710 else if (unformat (i, "src_address %U", unformat_ip4_address,
9712 src_address_set = 1;
9713 else if (unformat (i, "vrf_id %d", &vrf_id))
9715 else if (unformat (i, "path_mtu %d", &path_mtu))
9717 else if (unformat (i, "template_interval %d", &template_interval))
9719 else if (unformat (i, "udp_checksum"))
9725 if (collector_address_set == 0)
9727 errmsg ("collector_address required");
9731 if (src_address_set == 0)
9733 errmsg ("src_address required");
9737 M (SET_IPFIX_EXPORTER, mp);
9739 memcpy (mp->collector_address, collector_address.data,
9740 sizeof (collector_address.data));
9741 mp->collector_port = htons ((u16) collector_port);
9742 memcpy (mp->src_address, src_address.data, sizeof (src_address.data));
9743 mp->vrf_id = htonl (vrf_id);
9744 mp->path_mtu = htonl (path_mtu);
9745 mp->template_interval = htonl (template_interval);
9746 mp->udp_checksum = udp_checksum;
9754 api_set_ipfix_classify_stream (vat_main_t * vam)
9756 unformat_input_t *i = vam->input;
9757 vl_api_set_ipfix_classify_stream_t *mp;
9759 u32 src_port = UDP_DST_PORT_ipfix;
9762 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9764 if (unformat (i, "domain %d", &domain_id))
9766 else if (unformat (i, "src_port %d", &src_port))
9770 errmsg ("unknown input `%U'", format_unformat_error, i);
9775 M (SET_IPFIX_CLASSIFY_STREAM, mp);
9777 mp->domain_id = htonl (domain_id);
9778 mp->src_port = htons ((u16) src_port);
9786 api_ipfix_classify_table_add_del (vat_main_t * vam)
9788 unformat_input_t *i = vam->input;
9789 vl_api_ipfix_classify_table_add_del_t *mp;
9791 u32 classify_table_index = ~0;
9793 u8 transport_protocol = 255;
9796 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9798 if (unformat (i, "add"))
9800 else if (unformat (i, "del"))
9802 else if (unformat (i, "table %d", &classify_table_index))
9804 else if (unformat (i, "ip4"))
9806 else if (unformat (i, "ip6"))
9808 else if (unformat (i, "tcp"))
9809 transport_protocol = 6;
9810 else if (unformat (i, "udp"))
9811 transport_protocol = 17;
9814 errmsg ("unknown input `%U'", format_unformat_error, i);
9821 errmsg ("expecting: add|del");
9824 if (classify_table_index == ~0)
9826 errmsg ("classifier table not specified");
9829 if (ip_version == 0)
9831 errmsg ("IP version not specified");
9835 M (IPFIX_CLASSIFY_TABLE_ADD_DEL, mp);
9837 mp->is_add = is_add;
9838 mp->table_id = htonl (classify_table_index);
9839 mp->ip_version = ip_version;
9840 mp->transport_protocol = transport_protocol;
9848 api_get_node_index (vat_main_t * vam)
9850 unformat_input_t *i = vam->input;
9851 vl_api_get_node_index_t *mp;
9855 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9857 if (unformat (i, "node %s", &name))
9864 errmsg ("node name required");
9867 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9869 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9873 M (GET_NODE_INDEX, mp);
9874 clib_memcpy (mp->node_name, name, vec_len (name));
9883 api_get_next_index (vat_main_t * vam)
9885 unformat_input_t *i = vam->input;
9886 vl_api_get_next_index_t *mp;
9887 u8 *node_name = 0, *next_node_name = 0;
9890 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9892 if (unformat (i, "node-name %s", &node_name))
9894 else if (unformat (i, "next-node-name %s", &next_node_name))
9900 errmsg ("node name required");
9903 if (vec_len (node_name) >= ARRAY_LEN (mp->node_name))
9905 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9909 if (next_node_name == 0)
9911 errmsg ("next node name required");
9914 if (vec_len (next_node_name) >= ARRAY_LEN (mp->next_name))
9916 errmsg ("next node name too long, max %d", ARRAY_LEN (mp->next_name));
9920 M (GET_NEXT_INDEX, mp);
9921 clib_memcpy (mp->node_name, node_name, vec_len (node_name));
9922 clib_memcpy (mp->next_name, next_node_name, vec_len (next_node_name));
9923 vec_free (node_name);
9924 vec_free (next_node_name);
9932 api_add_node_next (vat_main_t * vam)
9934 unformat_input_t *i = vam->input;
9935 vl_api_add_node_next_t *mp;
9940 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9942 if (unformat (i, "node %s", &name))
9944 else if (unformat (i, "next %s", &next))
9951 errmsg ("node name required");
9954 if (vec_len (name) >= ARRAY_LEN (mp->node_name))
9956 errmsg ("node name too long, max %d", ARRAY_LEN (mp->node_name));
9961 errmsg ("next node required");
9964 if (vec_len (next) >= ARRAY_LEN (mp->next_name))
9966 errmsg ("next name too long, max %d", ARRAY_LEN (mp->next_name));
9970 M (ADD_NODE_NEXT, mp);
9971 clib_memcpy (mp->node_name, name, vec_len (name));
9972 clib_memcpy (mp->next_name, next, vec_len (next));
9982 api_l2tpv3_create_tunnel (vat_main_t * vam)
9984 unformat_input_t *i = vam->input;
9985 ip6_address_t client_address, our_address;
9986 int client_address_set = 0;
9987 int our_address_set = 0;
9988 u32 local_session_id = 0;
9989 u32 remote_session_id = 0;
9990 u64 local_cookie = 0;
9991 u64 remote_cookie = 0;
9992 u8 l2_sublayer_present = 0;
9993 vl_api_l2tpv3_create_tunnel_t *mp;
9996 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
9998 if (unformat (i, "client_address %U", unformat_ip6_address,
10000 client_address_set = 1;
10001 else if (unformat (i, "our_address %U", unformat_ip6_address,
10003 our_address_set = 1;
10004 else if (unformat (i, "local_session_id %d", &local_session_id))
10006 else if (unformat (i, "remote_session_id %d", &remote_session_id))
10008 else if (unformat (i, "local_cookie %lld", &local_cookie))
10010 else if (unformat (i, "remote_cookie %lld", &remote_cookie))
10012 else if (unformat (i, "l2-sublayer-present"))
10013 l2_sublayer_present = 1;
10018 if (client_address_set == 0)
10020 errmsg ("client_address required");
10024 if (our_address_set == 0)
10026 errmsg ("our_address required");
10030 M (L2TPV3_CREATE_TUNNEL, mp);
10032 clib_memcpy (mp->client_address, client_address.as_u8,
10033 sizeof (mp->client_address));
10035 clib_memcpy (mp->our_address, our_address.as_u8, sizeof (mp->our_address));
10037 mp->local_session_id = ntohl (local_session_id);
10038 mp->remote_session_id = ntohl (remote_session_id);
10039 mp->local_cookie = clib_host_to_net_u64 (local_cookie);
10040 mp->remote_cookie = clib_host_to_net_u64 (remote_cookie);
10041 mp->l2_sublayer_present = l2_sublayer_present;
10050 api_l2tpv3_set_tunnel_cookies (vat_main_t * vam)
10052 unformat_input_t *i = vam->input;
10054 u8 sw_if_index_set = 0;
10055 u64 new_local_cookie = 0;
10056 u64 new_remote_cookie = 0;
10057 vl_api_l2tpv3_set_tunnel_cookies_t *mp;
10060 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10062 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10063 sw_if_index_set = 1;
10064 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10065 sw_if_index_set = 1;
10066 else if (unformat (i, "new_local_cookie %lld", &new_local_cookie))
10068 else if (unformat (i, "new_remote_cookie %lld", &new_remote_cookie))
10074 if (sw_if_index_set == 0)
10076 errmsg ("missing interface name or sw_if_index");
10080 M (L2TPV3_SET_TUNNEL_COOKIES, mp);
10082 mp->sw_if_index = ntohl (sw_if_index);
10083 mp->new_local_cookie = clib_host_to_net_u64 (new_local_cookie);
10084 mp->new_remote_cookie = clib_host_to_net_u64 (new_remote_cookie);
10092 api_l2tpv3_interface_enable_disable (vat_main_t * vam)
10094 unformat_input_t *i = vam->input;
10095 vl_api_l2tpv3_interface_enable_disable_t *mp;
10097 u8 sw_if_index_set = 0;
10098 u8 enable_disable = 1;
10101 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10103 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10104 sw_if_index_set = 1;
10105 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10106 sw_if_index_set = 1;
10107 else if (unformat (i, "enable"))
10108 enable_disable = 1;
10109 else if (unformat (i, "disable"))
10110 enable_disable = 0;
10115 if (sw_if_index_set == 0)
10117 errmsg ("missing interface name or sw_if_index");
10121 M (L2TPV3_INTERFACE_ENABLE_DISABLE, mp);
10123 mp->sw_if_index = ntohl (sw_if_index);
10124 mp->enable_disable = enable_disable;
10132 api_l2tpv3_set_lookup_key (vat_main_t * vam)
10134 unformat_input_t *i = vam->input;
10135 vl_api_l2tpv3_set_lookup_key_t *mp;
10139 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10141 if (unformat (i, "lookup_v6_src"))
10142 key = L2T_LOOKUP_SRC_ADDRESS;
10143 else if (unformat (i, "lookup_v6_dst"))
10144 key = L2T_LOOKUP_DST_ADDRESS;
10145 else if (unformat (i, "lookup_session_id"))
10146 key = L2T_LOOKUP_SESSION_ID;
10151 if (key == (u8) ~ 0)
10153 errmsg ("l2tp session lookup key unset");
10157 M (L2TPV3_SET_LOOKUP_KEY, mp);
10166 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler
10167 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10169 vat_main_t *vam = &vat_main;
10171 print (vam->ofp, "* %U (our) %U (client) (sw_if_index %d)",
10172 format_ip6_address, mp->our_address,
10173 format_ip6_address, mp->client_address,
10174 clib_net_to_host_u32 (mp->sw_if_index));
10177 " local cookies %016llx %016llx remote cookie %016llx",
10178 clib_net_to_host_u64 (mp->local_cookie[0]),
10179 clib_net_to_host_u64 (mp->local_cookie[1]),
10180 clib_net_to_host_u64 (mp->remote_cookie));
10182 print (vam->ofp, " local session-id %d remote session-id %d",
10183 clib_net_to_host_u32 (mp->local_session_id),
10184 clib_net_to_host_u32 (mp->remote_session_id));
10186 print (vam->ofp, " l2 specific sublayer %s\n",
10187 mp->l2_sublayer_present ? "preset" : "absent");
10191 static void vl_api_sw_if_l2tpv3_tunnel_details_t_handler_json
10192 (vl_api_sw_if_l2tpv3_tunnel_details_t * mp)
10194 vat_main_t *vam = &vat_main;
10195 vat_json_node_t *node = NULL;
10196 struct in6_addr addr;
10198 if (VAT_JSON_ARRAY != vam->json_tree.type)
10200 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10201 vat_json_init_array (&vam->json_tree);
10203 node = vat_json_array_add (&vam->json_tree);
10205 vat_json_init_object (node);
10207 clib_memcpy (&addr, mp->our_address, sizeof (addr));
10208 vat_json_object_add_ip6 (node, "our_address", addr);
10209 clib_memcpy (&addr, mp->client_address, sizeof (addr));
10210 vat_json_object_add_ip6 (node, "client_address", addr);
10212 vat_json_node_t *lc = vat_json_object_add (node, "local_cookie");
10213 vat_json_init_array (lc);
10214 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[0]));
10215 vat_json_array_add_uint (lc, clib_net_to_host_u64 (mp->local_cookie[1]));
10216 vat_json_object_add_uint (node, "remote_cookie",
10217 clib_net_to_host_u64 (mp->remote_cookie));
10219 printf ("local id: %u", clib_net_to_host_u32 (mp->local_session_id));
10220 vat_json_object_add_uint (node, "local_session_id",
10221 clib_net_to_host_u32 (mp->local_session_id));
10222 vat_json_object_add_uint (node, "remote_session_id",
10223 clib_net_to_host_u32 (mp->remote_session_id));
10224 vat_json_object_add_string_copy (node, "l2_sublayer",
10225 mp->l2_sublayer_present ? (u8 *) "present"
10226 : (u8 *) "absent");
10230 api_sw_if_l2tpv3_tunnel_dump (vat_main_t * vam)
10232 vl_api_sw_if_l2tpv3_tunnel_dump_t *mp;
10233 vl_api_control_ping_t *mp_ping;
10236 /* Get list of l2tpv3-tunnel interfaces */
10237 M (SW_IF_L2TPV3_TUNNEL_DUMP, mp);
10240 /* Use a control ping for synchronization */
10241 M (CONTROL_PING, mp_ping);
10249 static void vl_api_sw_interface_tap_details_t_handler
10250 (vl_api_sw_interface_tap_details_t * mp)
10252 vat_main_t *vam = &vat_main;
10254 print (vam->ofp, "%-16s %d",
10255 mp->dev_name, clib_net_to_host_u32 (mp->sw_if_index));
10258 static void vl_api_sw_interface_tap_details_t_handler_json
10259 (vl_api_sw_interface_tap_details_t * mp)
10261 vat_main_t *vam = &vat_main;
10262 vat_json_node_t *node = NULL;
10264 if (VAT_JSON_ARRAY != vam->json_tree.type)
10266 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10267 vat_json_init_array (&vam->json_tree);
10269 node = vat_json_array_add (&vam->json_tree);
10271 vat_json_init_object (node);
10272 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10273 vat_json_object_add_string_copy (node, "dev_name", mp->dev_name);
10277 api_sw_interface_tap_dump (vat_main_t * vam)
10279 vl_api_sw_interface_tap_dump_t *mp;
10280 vl_api_control_ping_t *mp_ping;
10283 print (vam->ofp, "\n%-16s %s", "dev_name", "sw_if_index");
10284 /* Get list of tap interfaces */
10285 M (SW_INTERFACE_TAP_DUMP, mp);
10288 /* Use a control ping for synchronization */
10289 M (CONTROL_PING, mp_ping);
10296 static uword unformat_vxlan_decap_next
10297 (unformat_input_t * input, va_list * args)
10299 u32 *result = va_arg (*args, u32 *);
10302 if (unformat (input, "l2"))
10303 *result = VXLAN_INPUT_NEXT_L2_INPUT;
10304 else if (unformat (input, "%d", &tmp))
10312 api_vxlan_add_del_tunnel (vat_main_t * vam)
10314 unformat_input_t *line_input = vam->input;
10315 vl_api_vxlan_add_del_tunnel_t *mp;
10316 ip46_address_t src, dst;
10318 u8 ipv4_set = 0, ipv6_set = 0;
10322 u32 mcast_sw_if_index = ~0;
10323 u32 encap_vrf_id = 0;
10324 u32 decap_next_index = ~0;
10328 /* Can't "universally zero init" (={0}) due to GCC bug 53119 */
10329 memset (&src, 0, sizeof src);
10330 memset (&dst, 0, sizeof dst);
10332 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10334 if (unformat (line_input, "del"))
10337 if (unformat (line_input, "src %U", unformat_ip4_address, &src.ip4))
10343 if (unformat (line_input, "dst %U", unformat_ip4_address, &dst.ip4))
10349 if (unformat (line_input, "src %U", unformat_ip6_address, &src.ip6))
10355 if (unformat (line_input, "dst %U", unformat_ip6_address, &dst.ip6))
10360 else if (unformat (line_input, "group %U %U",
10361 unformat_ip4_address, &dst.ip4,
10362 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10364 grp_set = dst_set = 1;
10367 else if (unformat (line_input, "group %U",
10368 unformat_ip4_address, &dst.ip4))
10370 grp_set = dst_set = 1;
10373 else if (unformat (line_input, "group %U %U",
10374 unformat_ip6_address, &dst.ip6,
10375 api_unformat_sw_if_index, vam, &mcast_sw_if_index))
10377 grp_set = dst_set = 1;
10380 else if (unformat (line_input, "group %U",
10381 unformat_ip6_address, &dst.ip6))
10383 grp_set = dst_set = 1;
10387 if (unformat (line_input, "mcast_sw_if_index %u", &mcast_sw_if_index))
10389 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
10391 else if (unformat (line_input, "decap-next %U",
10392 unformat_vxlan_decap_next, &decap_next_index))
10394 else if (unformat (line_input, "vni %d", &vni))
10398 errmsg ("parse error '%U'", format_unformat_error, line_input);
10405 errmsg ("tunnel src address not specified");
10410 errmsg ("tunnel dst address not specified");
10414 if (grp_set && !ip46_address_is_multicast (&dst))
10416 errmsg ("tunnel group address not multicast");
10419 if (grp_set && mcast_sw_if_index == ~0)
10421 errmsg ("tunnel nonexistent multicast device");
10424 if (grp_set == 0 && ip46_address_is_multicast (&dst))
10426 errmsg ("tunnel dst address must be unicast");
10431 if (ipv4_set && ipv6_set)
10433 errmsg ("both IPv4 and IPv6 addresses specified");
10437 if ((vni == 0) || (vni >> 24))
10439 errmsg ("vni not specified or out of range");
10443 M (VXLAN_ADD_DEL_TUNNEL, mp);
10447 clib_memcpy (mp->src_address, &src.ip6, sizeof (src.ip6));
10448 clib_memcpy (mp->dst_address, &dst.ip6, sizeof (dst.ip6));
10452 clib_memcpy (mp->src_address, &src.ip4, sizeof (src.ip4));
10453 clib_memcpy (mp->dst_address, &dst.ip4, sizeof (dst.ip4));
10455 mp->encap_vrf_id = ntohl (encap_vrf_id);
10456 mp->decap_next_index = ntohl (decap_next_index);
10457 mp->mcast_sw_if_index = ntohl (mcast_sw_if_index);
10458 mp->vni = ntohl (vni);
10459 mp->is_add = is_add;
10460 mp->is_ipv6 = ipv6_set;
10467 static void vl_api_vxlan_tunnel_details_t_handler
10468 (vl_api_vxlan_tunnel_details_t * mp)
10470 vat_main_t *vam = &vat_main;
10471 ip46_address_t src, dst;
10473 ip46_from_addr_buf (mp->is_ipv6, mp->src_address, &src);
10474 ip46_from_addr_buf (mp->is_ipv6, mp->dst_address, &dst);
10476 print (vam->ofp, "%11d%24U%24U%14d%18d%13d%19d",
10477 ntohl (mp->sw_if_index),
10478 format_ip46_address, &src, IP46_TYPE_ANY,
10479 format_ip46_address, &dst, IP46_TYPE_ANY,
10480 ntohl (mp->encap_vrf_id),
10481 ntohl (mp->decap_next_index), ntohl (mp->vni),
10482 ntohl (mp->mcast_sw_if_index));
10485 static void vl_api_vxlan_tunnel_details_t_handler_json
10486 (vl_api_vxlan_tunnel_details_t * mp)
10488 vat_main_t *vam = &vat_main;
10489 vat_json_node_t *node = NULL;
10491 if (VAT_JSON_ARRAY != vam->json_tree.type)
10493 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10494 vat_json_init_array (&vam->json_tree);
10496 node = vat_json_array_add (&vam->json_tree);
10498 vat_json_init_object (node);
10499 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10502 struct in6_addr ip6;
10504 clib_memcpy (&ip6, mp->src_address, sizeof (ip6));
10505 vat_json_object_add_ip6 (node, "src_address", ip6);
10506 clib_memcpy (&ip6, mp->dst_address, sizeof (ip6));
10507 vat_json_object_add_ip6 (node, "dst_address", ip6);
10511 struct in_addr ip4;
10513 clib_memcpy (&ip4, mp->src_address, sizeof (ip4));
10514 vat_json_object_add_ip4 (node, "src_address", ip4);
10515 clib_memcpy (&ip4, mp->dst_address, sizeof (ip4));
10516 vat_json_object_add_ip4 (node, "dst_address", ip4);
10518 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
10519 vat_json_object_add_uint (node, "decap_next_index",
10520 ntohl (mp->decap_next_index));
10521 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
10522 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
10523 vat_json_object_add_uint (node, "mcast_sw_if_index",
10524 ntohl (mp->mcast_sw_if_index));
10528 api_vxlan_tunnel_dump (vat_main_t * vam)
10530 unformat_input_t *i = vam->input;
10531 vl_api_vxlan_tunnel_dump_t *mp;
10532 vl_api_control_ping_t *mp_ping;
10534 u8 sw_if_index_set = 0;
10537 /* Parse args required to build the message */
10538 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10540 if (unformat (i, "sw_if_index %d", &sw_if_index))
10541 sw_if_index_set = 1;
10546 if (sw_if_index_set == 0)
10551 if (!vam->json_output)
10553 print (vam->ofp, "%11s%24s%24s%14s%18s%13s%19s",
10554 "sw_if_index", "src_address", "dst_address",
10555 "encap_vrf_id", "decap_next_index", "vni", "mcast_sw_if_index");
10558 /* Get list of vxlan-tunnel interfaces */
10559 M (VXLAN_TUNNEL_DUMP, mp);
10561 mp->sw_if_index = htonl (sw_if_index);
10565 /* Use a control ping for synchronization */
10566 M (CONTROL_PING, mp_ping);
10574 api_gre_add_del_tunnel (vat_main_t * vam)
10576 unformat_input_t *line_input = vam->input;
10577 vl_api_gre_add_del_tunnel_t *mp;
10578 ip4_address_t src4, dst4;
10583 u32 outer_fib_id = 0;
10586 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
10588 if (unformat (line_input, "del"))
10590 else if (unformat (line_input, "src %U", unformat_ip4_address, &src4))
10592 else if (unformat (line_input, "dst %U", unformat_ip4_address, &dst4))
10594 else if (unformat (line_input, "outer-fib-id %d", &outer_fib_id))
10596 else if (unformat (line_input, "teb"))
10600 errmsg ("parse error '%U'", format_unformat_error, line_input);
10607 errmsg ("tunnel src address not specified");
10612 errmsg ("tunnel dst address not specified");
10617 M (GRE_ADD_DEL_TUNNEL, mp);
10619 clib_memcpy (&mp->src_address, &src4, sizeof (src4));
10620 clib_memcpy (&mp->dst_address, &dst4, sizeof (dst4));
10621 mp->outer_fib_id = ntohl (outer_fib_id);
10622 mp->is_add = is_add;
10630 static void vl_api_gre_tunnel_details_t_handler
10631 (vl_api_gre_tunnel_details_t * mp)
10633 vat_main_t *vam = &vat_main;
10635 print (vam->ofp, "%11d%15U%15U%6d%14d",
10636 ntohl (mp->sw_if_index),
10637 format_ip4_address, &mp->src_address,
10638 format_ip4_address, &mp->dst_address,
10639 mp->teb, ntohl (mp->outer_fib_id));
10642 static void vl_api_gre_tunnel_details_t_handler_json
10643 (vl_api_gre_tunnel_details_t * mp)
10645 vat_main_t *vam = &vat_main;
10646 vat_json_node_t *node = NULL;
10647 struct in_addr ip4;
10649 if (VAT_JSON_ARRAY != vam->json_tree.type)
10651 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
10652 vat_json_init_array (&vam->json_tree);
10654 node = vat_json_array_add (&vam->json_tree);
10656 vat_json_init_object (node);
10657 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
10658 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
10659 vat_json_object_add_ip4 (node, "src_address", ip4);
10660 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
10661 vat_json_object_add_ip4 (node, "dst_address", ip4);
10662 vat_json_object_add_uint (node, "teb", mp->teb);
10663 vat_json_object_add_uint (node, "outer_fib_id", ntohl (mp->outer_fib_id));
10667 api_gre_tunnel_dump (vat_main_t * vam)
10669 unformat_input_t *i = vam->input;
10670 vl_api_gre_tunnel_dump_t *mp;
10671 vl_api_control_ping_t *mp_ping;
10673 u8 sw_if_index_set = 0;
10676 /* Parse args required to build the message */
10677 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10679 if (unformat (i, "sw_if_index %d", &sw_if_index))
10680 sw_if_index_set = 1;
10685 if (sw_if_index_set == 0)
10690 if (!vam->json_output)
10692 print (vam->ofp, "%11s%15s%15s%6s%14s",
10693 "sw_if_index", "src_address", "dst_address", "teb",
10697 /* Get list of gre-tunnel interfaces */
10698 M (GRE_TUNNEL_DUMP, mp);
10700 mp->sw_if_index = htonl (sw_if_index);
10704 /* Use a control ping for synchronization */
10705 M (CONTROL_PING, mp_ping);
10713 api_l2_fib_clear_table (vat_main_t * vam)
10715 // unformat_input_t * i = vam->input;
10716 vl_api_l2_fib_clear_table_t *mp;
10719 M (L2_FIB_CLEAR_TABLE, mp);
10727 api_l2_interface_efp_filter (vat_main_t * vam)
10729 unformat_input_t *i = vam->input;
10730 vl_api_l2_interface_efp_filter_t *mp;
10733 u8 sw_if_index_set = 0;
10736 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10738 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10739 sw_if_index_set = 1;
10740 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10741 sw_if_index_set = 1;
10742 else if (unformat (i, "enable"))
10744 else if (unformat (i, "disable"))
10748 clib_warning ("parse error '%U'", format_unformat_error, i);
10753 if (sw_if_index_set == 0)
10755 errmsg ("missing sw_if_index");
10759 M (L2_INTERFACE_EFP_FILTER, mp);
10761 mp->sw_if_index = ntohl (sw_if_index);
10762 mp->enable_disable = enable;
10769 #define foreach_vtr_op \
10770 _("disable", L2_VTR_DISABLED) \
10771 _("push-1", L2_VTR_PUSH_1) \
10772 _("push-2", L2_VTR_PUSH_2) \
10773 _("pop-1", L2_VTR_POP_1) \
10774 _("pop-2", L2_VTR_POP_2) \
10775 _("translate-1-1", L2_VTR_TRANSLATE_1_1) \
10776 _("translate-1-2", L2_VTR_TRANSLATE_1_2) \
10777 _("translate-2-1", L2_VTR_TRANSLATE_2_1) \
10778 _("translate-2-2", L2_VTR_TRANSLATE_2_2)
10781 api_l2_interface_vlan_tag_rewrite (vat_main_t * vam)
10783 unformat_input_t *i = vam->input;
10784 vl_api_l2_interface_vlan_tag_rewrite_t *mp;
10786 u8 sw_if_index_set = 0;
10789 u32 push_dot1q = 1;
10794 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10796 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10797 sw_if_index_set = 1;
10798 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10799 sw_if_index_set = 1;
10800 else if (unformat (i, "vtr_op %d", &vtr_op))
10802 #define _(n,v) else if (unformat(i, n)) {vtr_op = v; vtr_op_set = 1;}
10805 else if (unformat (i, "push_dot1q %d", &push_dot1q))
10807 else if (unformat (i, "tag1 %d", &tag1))
10809 else if (unformat (i, "tag2 %d", &tag2))
10813 clib_warning ("parse error '%U'", format_unformat_error, i);
10818 if ((sw_if_index_set == 0) || (vtr_op_set == 0))
10820 errmsg ("missing vtr operation or sw_if_index");
10824 M (L2_INTERFACE_VLAN_TAG_REWRITE, mp);
10825 mp->sw_if_index = ntohl (sw_if_index);
10826 mp->vtr_op = ntohl (vtr_op);
10827 mp->push_dot1q = ntohl (push_dot1q);
10828 mp->tag1 = ntohl (tag1);
10829 mp->tag2 = ntohl (tag2);
10837 api_create_vhost_user_if (vat_main_t * vam)
10839 unformat_input_t *i = vam->input;
10840 vl_api_create_vhost_user_if_t *mp;
10843 u8 file_name_set = 0;
10844 u32 custom_dev_instance = ~0;
10846 u8 use_custom_mac = 0;
10850 /* Shut up coverity */
10851 memset (hwaddr, 0, sizeof (hwaddr));
10853 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10855 if (unformat (i, "socket %s", &file_name))
10859 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10861 else if (unformat (i, "mac %U", unformat_ethernet_address, hwaddr))
10862 use_custom_mac = 1;
10863 else if (unformat (i, "server"))
10865 else if (unformat (i, "tag %s", &tag))
10871 if (file_name_set == 0)
10873 errmsg ("missing socket file name");
10877 if (vec_len (file_name) > 255)
10879 errmsg ("socket file name too long");
10882 vec_add1 (file_name, 0);
10884 M (CREATE_VHOST_USER_IF, mp);
10886 mp->is_server = is_server;
10887 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10888 vec_free (file_name);
10889 if (custom_dev_instance != ~0)
10892 mp->custom_dev_instance = ntohl (custom_dev_instance);
10894 mp->use_custom_mac = use_custom_mac;
10895 clib_memcpy (mp->mac_address, hwaddr, 6);
10897 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
10906 api_modify_vhost_user_if (vat_main_t * vam)
10908 unformat_input_t *i = vam->input;
10909 vl_api_modify_vhost_user_if_t *mp;
10912 u8 file_name_set = 0;
10913 u32 custom_dev_instance = ~0;
10914 u8 sw_if_index_set = 0;
10915 u32 sw_if_index = (u32) ~ 0;
10918 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10920 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10921 sw_if_index_set = 1;
10922 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10923 sw_if_index_set = 1;
10924 else if (unformat (i, "socket %s", &file_name))
10928 else if (unformat (i, "renumber %" PRIu32, &custom_dev_instance))
10930 else if (unformat (i, "server"))
10936 if (sw_if_index_set == 0)
10938 errmsg ("missing sw_if_index or interface name");
10942 if (file_name_set == 0)
10944 errmsg ("missing socket file name");
10948 if (vec_len (file_name) > 255)
10950 errmsg ("socket file name too long");
10953 vec_add1 (file_name, 0);
10955 M (MODIFY_VHOST_USER_IF, mp);
10957 mp->sw_if_index = ntohl (sw_if_index);
10958 mp->is_server = is_server;
10959 clib_memcpy (mp->sock_filename, file_name, vec_len (file_name));
10960 vec_free (file_name);
10961 if (custom_dev_instance != ~0)
10964 mp->custom_dev_instance = ntohl (custom_dev_instance);
10973 api_delete_vhost_user_if (vat_main_t * vam)
10975 unformat_input_t *i = vam->input;
10976 vl_api_delete_vhost_user_if_t *mp;
10977 u32 sw_if_index = ~0;
10978 u8 sw_if_index_set = 0;
10981 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
10983 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
10984 sw_if_index_set = 1;
10985 else if (unformat (i, "sw_if_index %d", &sw_if_index))
10986 sw_if_index_set = 1;
10991 if (sw_if_index_set == 0)
10993 errmsg ("missing sw_if_index or interface name");
10998 M (DELETE_VHOST_USER_IF, mp);
11000 mp->sw_if_index = ntohl (sw_if_index);
11007 static void vl_api_sw_interface_vhost_user_details_t_handler
11008 (vl_api_sw_interface_vhost_user_details_t * mp)
11010 vat_main_t *vam = &vat_main;
11012 print (vam->ofp, "%-25s %3" PRIu32 " %6" PRIu32 " %8x %6d %7d %s",
11013 (char *) mp->interface_name,
11014 ntohl (mp->sw_if_index), ntohl (mp->virtio_net_hdr_sz),
11015 clib_net_to_host_u64 (mp->features), mp->is_server,
11016 ntohl (mp->num_regions), (char *) mp->sock_filename);
11017 print (vam->ofp, " Status: '%s'", strerror (ntohl (mp->sock_errno)));
11020 static void vl_api_sw_interface_vhost_user_details_t_handler_json
11021 (vl_api_sw_interface_vhost_user_details_t * mp)
11023 vat_main_t *vam = &vat_main;
11024 vat_json_node_t *node = NULL;
11026 if (VAT_JSON_ARRAY != vam->json_tree.type)
11028 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11029 vat_json_init_array (&vam->json_tree);
11031 node = vat_json_array_add (&vam->json_tree);
11033 vat_json_init_object (node);
11034 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11035 vat_json_object_add_string_copy (node, "interface_name",
11036 mp->interface_name);
11037 vat_json_object_add_uint (node, "virtio_net_hdr_sz",
11038 ntohl (mp->virtio_net_hdr_sz));
11039 vat_json_object_add_uint (node, "features",
11040 clib_net_to_host_u64 (mp->features));
11041 vat_json_object_add_uint (node, "is_server", mp->is_server);
11042 vat_json_object_add_string_copy (node, "sock_filename", mp->sock_filename);
11043 vat_json_object_add_uint (node, "num_regions", ntohl (mp->num_regions));
11044 vat_json_object_add_uint (node, "sock_errno", ntohl (mp->sock_errno));
11048 api_sw_interface_vhost_user_dump (vat_main_t * vam)
11050 vl_api_sw_interface_vhost_user_dump_t *mp;
11051 vl_api_control_ping_t *mp_ping;
11054 "Interface name idx hdr_sz features server regions filename");
11056 /* Get list of vhost-user interfaces */
11057 M (SW_INTERFACE_VHOST_USER_DUMP, mp);
11060 /* Use a control ping for synchronization */
11061 M (CONTROL_PING, mp_ping);
11069 api_show_version (vat_main_t * vam)
11071 vl_api_show_version_t *mp;
11074 M (SHOW_VERSION, mp);
11083 api_vxlan_gpe_add_del_tunnel (vat_main_t * vam)
11085 unformat_input_t *line_input = vam->input;
11086 vl_api_vxlan_gpe_add_del_tunnel_t *mp;
11087 ip4_address_t local4, remote4;
11088 ip6_address_t local6, remote6;
11090 u8 ipv4_set = 0, ipv6_set = 0;
11093 u32 encap_vrf_id = 0;
11094 u32 decap_vrf_id = 0;
11100 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11102 if (unformat (line_input, "del"))
11104 else if (unformat (line_input, "local %U",
11105 unformat_ip4_address, &local4))
11110 else if (unformat (line_input, "remote %U",
11111 unformat_ip4_address, &remote4))
11116 else if (unformat (line_input, "local %U",
11117 unformat_ip6_address, &local6))
11122 else if (unformat (line_input, "remote %U",
11123 unformat_ip6_address, &remote6))
11128 else if (unformat (line_input, "encap-vrf-id %d", &encap_vrf_id))
11130 else if (unformat (line_input, "decap-vrf-id %d", &decap_vrf_id))
11132 else if (unformat (line_input, "vni %d", &vni))
11134 else if (unformat (line_input, "next-ip4"))
11136 else if (unformat (line_input, "next-ip6"))
11138 else if (unformat (line_input, "next-ethernet"))
11140 else if (unformat (line_input, "next-nsh"))
11144 errmsg ("parse error '%U'", format_unformat_error, line_input);
11149 if (local_set == 0)
11151 errmsg ("tunnel local address not specified");
11154 if (remote_set == 0)
11156 errmsg ("tunnel remote address not specified");
11159 if (ipv4_set && ipv6_set)
11161 errmsg ("both IPv4 and IPv6 addresses specified");
11167 errmsg ("vni not specified");
11171 M (VXLAN_GPE_ADD_DEL_TUNNEL, mp);
11176 clib_memcpy (&mp->local, &local6, sizeof (local6));
11177 clib_memcpy (&mp->remote, &remote6, sizeof (remote6));
11181 clib_memcpy (&mp->local, &local4, sizeof (local4));
11182 clib_memcpy (&mp->remote, &remote4, sizeof (remote4));
11185 mp->encap_vrf_id = ntohl (encap_vrf_id);
11186 mp->decap_vrf_id = ntohl (decap_vrf_id);
11187 mp->protocol = protocol;
11188 mp->vni = ntohl (vni);
11189 mp->is_add = is_add;
11190 mp->is_ipv6 = ipv6_set;
11197 static void vl_api_vxlan_gpe_tunnel_details_t_handler
11198 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11200 vat_main_t *vam = &vat_main;
11202 print (vam->ofp, "%11d%24U%24U%13d%12d%14d%14d",
11203 ntohl (mp->sw_if_index),
11204 format_ip46_address, &(mp->local[0]),
11205 format_ip46_address, &(mp->remote[0]),
11207 ntohl (mp->protocol),
11208 ntohl (mp->encap_vrf_id), ntohl (mp->decap_vrf_id));
11211 static void vl_api_vxlan_gpe_tunnel_details_t_handler_json
11212 (vl_api_vxlan_gpe_tunnel_details_t * mp)
11214 vat_main_t *vam = &vat_main;
11215 vat_json_node_t *node = NULL;
11216 struct in_addr ip4;
11217 struct in6_addr ip6;
11219 if (VAT_JSON_ARRAY != vam->json_tree.type)
11221 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11222 vat_json_init_array (&vam->json_tree);
11224 node = vat_json_array_add (&vam->json_tree);
11226 vat_json_init_object (node);
11227 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11230 clib_memcpy (&ip6, &(mp->local[0]), sizeof (ip6));
11231 vat_json_object_add_ip6 (node, "local", ip6);
11232 clib_memcpy (&ip6, &(mp->remote[0]), sizeof (ip6));
11233 vat_json_object_add_ip6 (node, "remote", ip6);
11237 clib_memcpy (&ip4, &(mp->local[0]), sizeof (ip4));
11238 vat_json_object_add_ip4 (node, "local", ip4);
11239 clib_memcpy (&ip4, &(mp->remote[0]), sizeof (ip4));
11240 vat_json_object_add_ip4 (node, "remote", ip4);
11242 vat_json_object_add_uint (node, "vni", ntohl (mp->vni));
11243 vat_json_object_add_uint (node, "protocol", ntohl (mp->protocol));
11244 vat_json_object_add_uint (node, "encap_vrf_id", ntohl (mp->encap_vrf_id));
11245 vat_json_object_add_uint (node, "decap_vrf_id", ntohl (mp->decap_vrf_id));
11246 vat_json_object_add_uint (node, "is_ipv6", mp->is_ipv6 ? 1 : 0);
11250 api_vxlan_gpe_tunnel_dump (vat_main_t * vam)
11252 unformat_input_t *i = vam->input;
11253 vl_api_vxlan_gpe_tunnel_dump_t *mp;
11254 vl_api_control_ping_t *mp_ping;
11256 u8 sw_if_index_set = 0;
11259 /* Parse args required to build the message */
11260 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11262 if (unformat (i, "sw_if_index %d", &sw_if_index))
11263 sw_if_index_set = 1;
11268 if (sw_if_index_set == 0)
11273 if (!vam->json_output)
11275 print (vam->ofp, "%11s%24s%24s%13s%15s%14s%14s",
11276 "sw_if_index", "local", "remote", "vni",
11277 "protocol", "encap_vrf_id", "decap_vrf_id");
11280 /* Get list of vxlan-tunnel interfaces */
11281 M (VXLAN_GPE_TUNNEL_DUMP, mp);
11283 mp->sw_if_index = htonl (sw_if_index);
11287 /* Use a control ping for synchronization */
11288 M (CONTROL_PING, mp_ping);
11296 format_l2_fib_mac_address (u8 * s, va_list * args)
11298 u8 *a = va_arg (*args, u8 *);
11300 return format (s, "%02x:%02x:%02x:%02x:%02x:%02x",
11301 a[2], a[3], a[4], a[5], a[6], a[7]);
11304 static void vl_api_l2_fib_table_entry_t_handler
11305 (vl_api_l2_fib_table_entry_t * mp)
11307 vat_main_t *vam = &vat_main;
11309 print (vam->ofp, "%3" PRIu32 " %U %3" PRIu32
11311 ntohl (mp->bd_id), format_l2_fib_mac_address, &mp->mac,
11312 ntohl (mp->sw_if_index), mp->static_mac, mp->filter_mac,
11316 static void vl_api_l2_fib_table_entry_t_handler_json
11317 (vl_api_l2_fib_table_entry_t * mp)
11319 vat_main_t *vam = &vat_main;
11320 vat_json_node_t *node = NULL;
11322 if (VAT_JSON_ARRAY != vam->json_tree.type)
11324 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
11325 vat_json_init_array (&vam->json_tree);
11327 node = vat_json_array_add (&vam->json_tree);
11329 vat_json_init_object (node);
11330 vat_json_object_add_uint (node, "bd_id", ntohl (mp->bd_id));
11331 vat_json_object_add_uint (node, "mac", clib_net_to_host_u64 (mp->mac));
11332 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
11333 vat_json_object_add_uint (node, "static_mac", mp->static_mac);
11334 vat_json_object_add_uint (node, "filter_mac", mp->filter_mac);
11335 vat_json_object_add_uint (node, "bvi_mac", mp->bvi_mac);
11339 api_l2_fib_table_dump (vat_main_t * vam)
11341 unformat_input_t *i = vam->input;
11342 vl_api_l2_fib_table_dump_t *mp;
11343 vl_api_control_ping_t *mp_ping;
11348 /* Parse args required to build the message */
11349 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11351 if (unformat (i, "bd_id %d", &bd_id))
11357 if (bd_id_set == 0)
11359 errmsg ("missing bridge domain");
11363 print (vam->ofp, "BD-ID Mac Address sw-ndx Static Filter BVI");
11365 /* Get list of l2 fib entries */
11366 M (L2_FIB_TABLE_DUMP, mp);
11368 mp->bd_id = ntohl (bd_id);
11371 /* Use a control ping for synchronization */
11372 M (CONTROL_PING, mp_ping);
11381 api_interface_name_renumber (vat_main_t * vam)
11383 unformat_input_t *line_input = vam->input;
11384 vl_api_interface_name_renumber_t *mp;
11385 u32 sw_if_index = ~0;
11386 u32 new_show_dev_instance = ~0;
11389 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11391 if (unformat (line_input, "%U", api_unformat_sw_if_index, vam,
11394 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
11396 else if (unformat (line_input, "new_show_dev_instance %d",
11397 &new_show_dev_instance))
11403 if (sw_if_index == ~0)
11405 errmsg ("missing interface name or sw_if_index");
11409 if (new_show_dev_instance == ~0)
11411 errmsg ("missing new_show_dev_instance");
11415 M (INTERFACE_NAME_RENUMBER, mp);
11417 mp->sw_if_index = ntohl (sw_if_index);
11418 mp->new_show_dev_instance = ntohl (new_show_dev_instance);
11426 api_want_ip4_arp_events (vat_main_t * vam)
11428 unformat_input_t *line_input = vam->input;
11429 vl_api_want_ip4_arp_events_t *mp;
11430 ip4_address_t address;
11431 int address_set = 0;
11432 u32 enable_disable = 1;
11435 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11437 if (unformat (line_input, "address %U", unformat_ip4_address, &address))
11439 else if (unformat (line_input, "del"))
11440 enable_disable = 0;
11445 if (address_set == 0)
11447 errmsg ("missing addresses");
11451 M (WANT_IP4_ARP_EVENTS, mp);
11452 mp->enable_disable = enable_disable;
11453 mp->pid = getpid ();
11454 mp->address = address.as_u32;
11462 api_want_ip6_nd_events (vat_main_t * vam)
11464 unformat_input_t *line_input = vam->input;
11465 vl_api_want_ip6_nd_events_t *mp;
11466 ip6_address_t address;
11467 int address_set = 0;
11468 u32 enable_disable = 1;
11471 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
11473 if (unformat (line_input, "address %U", unformat_ip6_address, &address))
11475 else if (unformat (line_input, "del"))
11476 enable_disable = 0;
11481 if (address_set == 0)
11483 errmsg ("missing addresses");
11487 M (WANT_IP6_ND_EVENTS, mp);
11488 mp->enable_disable = enable_disable;
11489 mp->pid = getpid ();
11490 clib_memcpy (mp->address, &address, sizeof (ip6_address_t));
11498 api_input_acl_set_interface (vat_main_t * vam)
11500 unformat_input_t *i = vam->input;
11501 vl_api_input_acl_set_interface_t *mp;
11503 int sw_if_index_set;
11504 u32 ip4_table_index = ~0;
11505 u32 ip6_table_index = ~0;
11506 u32 l2_table_index = ~0;
11510 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11512 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11513 sw_if_index_set = 1;
11514 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11515 sw_if_index_set = 1;
11516 else if (unformat (i, "del"))
11518 else if (unformat (i, "ip4-table %d", &ip4_table_index))
11520 else if (unformat (i, "ip6-table %d", &ip6_table_index))
11522 else if (unformat (i, "l2-table %d", &l2_table_index))
11526 clib_warning ("parse error '%U'", format_unformat_error, i);
11531 if (sw_if_index_set == 0)
11533 errmsg ("missing interface name or sw_if_index");
11537 M (INPUT_ACL_SET_INTERFACE, mp);
11539 mp->sw_if_index = ntohl (sw_if_index);
11540 mp->ip4_table_index = ntohl (ip4_table_index);
11541 mp->ip6_table_index = ntohl (ip6_table_index);
11542 mp->l2_table_index = ntohl (l2_table_index);
11543 mp->is_add = is_add;
11551 api_ip_address_dump (vat_main_t * vam)
11553 unformat_input_t *i = vam->input;
11554 vl_api_ip_address_dump_t *mp;
11555 vl_api_control_ping_t *mp_ping;
11556 u32 sw_if_index = ~0;
11557 u8 sw_if_index_set = 0;
11562 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11564 if (unformat (i, "sw_if_index %d", &sw_if_index))
11565 sw_if_index_set = 1;
11567 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11568 sw_if_index_set = 1;
11569 else if (unformat (i, "ipv4"))
11571 else if (unformat (i, "ipv6"))
11577 if (ipv4_set && ipv6_set)
11579 errmsg ("ipv4 and ipv6 flags cannot be both set");
11583 if ((!ipv4_set) && (!ipv6_set))
11585 errmsg ("no ipv4 nor ipv6 flag set");
11589 if (sw_if_index_set == 0)
11591 errmsg ("missing interface name or sw_if_index");
11595 vam->current_sw_if_index = sw_if_index;
11596 vam->is_ipv6 = ipv6_set;
11598 M (IP_ADDRESS_DUMP, mp);
11599 mp->sw_if_index = ntohl (sw_if_index);
11600 mp->is_ipv6 = ipv6_set;
11603 /* Use a control ping for synchronization */
11604 M (CONTROL_PING, mp_ping);
11612 api_ip_dump (vat_main_t * vam)
11614 vl_api_ip_dump_t *mp;
11615 vl_api_control_ping_t *mp_ping;
11616 unformat_input_t *in = vam->input;
11623 while (unformat_check_input (in) != UNFORMAT_END_OF_INPUT)
11625 if (unformat (in, "ipv4"))
11627 else if (unformat (in, "ipv6"))
11633 if (ipv4_set && ipv6_set)
11635 errmsg ("ipv4 and ipv6 flags cannot be both set");
11639 if ((!ipv4_set) && (!ipv6_set))
11641 errmsg ("no ipv4 nor ipv6 flag set");
11645 is_ipv6 = ipv6_set;
11646 vam->is_ipv6 = is_ipv6;
11648 /* free old data */
11649 for (i = 0; i < vec_len (vam->ip_details_by_sw_if_index[is_ipv6]); i++)
11651 vec_free (vam->ip_details_by_sw_if_index[is_ipv6][i].addr);
11653 vec_free (vam->ip_details_by_sw_if_index[is_ipv6]);
11656 mp->is_ipv6 = ipv6_set;
11659 /* Use a control ping for synchronization */
11660 M (CONTROL_PING, mp_ping);
11668 api_ipsec_spd_add_del (vat_main_t * vam)
11670 unformat_input_t *i = vam->input;
11671 vl_api_ipsec_spd_add_del_t *mp;
11676 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11678 if (unformat (i, "spd_id %d", &spd_id))
11680 else if (unformat (i, "del"))
11684 clib_warning ("parse error '%U'", format_unformat_error, i);
11690 errmsg ("spd_id must be set");
11694 M (IPSEC_SPD_ADD_DEL, mp);
11696 mp->spd_id = ntohl (spd_id);
11697 mp->is_add = is_add;
11705 api_ipsec_interface_add_del_spd (vat_main_t * vam)
11707 unformat_input_t *i = vam->input;
11708 vl_api_ipsec_interface_add_del_spd_t *mp;
11710 u8 sw_if_index_set = 0;
11711 u32 spd_id = (u32) ~ 0;
11715 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11717 if (unformat (i, "del"))
11719 else if (unformat (i, "spd_id %d", &spd_id))
11722 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
11723 sw_if_index_set = 1;
11724 else if (unformat (i, "sw_if_index %d", &sw_if_index))
11725 sw_if_index_set = 1;
11728 clib_warning ("parse error '%U'", format_unformat_error, i);
11734 if (spd_id == (u32) ~ 0)
11736 errmsg ("spd_id must be set");
11740 if (sw_if_index_set == 0)
11742 errmsg ("missing interface name or sw_if_index");
11746 M (IPSEC_INTERFACE_ADD_DEL_SPD, mp);
11748 mp->spd_id = ntohl (spd_id);
11749 mp->sw_if_index = ntohl (sw_if_index);
11750 mp->is_add = is_add;
11758 api_ipsec_spd_add_del_entry (vat_main_t * vam)
11760 unformat_input_t *i = vam->input;
11761 vl_api_ipsec_spd_add_del_entry_t *mp;
11762 u8 is_add = 1, is_outbound = 0, is_ipv6 = 0, is_ip_any = 1;
11763 u32 spd_id = 0, sa_id = 0, protocol = 0, policy = 0;
11765 u32 rport_start = 0, rport_stop = (u32) ~ 0;
11766 u32 lport_start = 0, lport_stop = (u32) ~ 0;
11767 ip4_address_t laddr4_start, laddr4_stop, raddr4_start, raddr4_stop;
11768 ip6_address_t laddr6_start, laddr6_stop, raddr6_start, raddr6_stop;
11771 laddr4_start.as_u32 = raddr4_start.as_u32 = 0;
11772 laddr4_stop.as_u32 = raddr4_stop.as_u32 = (u32) ~ 0;
11773 laddr6_start.as_u64[0] = raddr6_start.as_u64[0] = 0;
11774 laddr6_start.as_u64[1] = raddr6_start.as_u64[1] = 0;
11775 laddr6_stop.as_u64[0] = raddr6_stop.as_u64[0] = (u64) ~ 0;
11776 laddr6_stop.as_u64[1] = raddr6_stop.as_u64[1] = (u64) ~ 0;
11778 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11780 if (unformat (i, "del"))
11782 if (unformat (i, "outbound"))
11784 if (unformat (i, "inbound"))
11786 else if (unformat (i, "spd_id %d", &spd_id))
11788 else if (unformat (i, "sa_id %d", &sa_id))
11790 else if (unformat (i, "priority %d", &priority))
11792 else if (unformat (i, "protocol %d", &protocol))
11794 else if (unformat (i, "lport_start %d", &lport_start))
11796 else if (unformat (i, "lport_stop %d", &lport_stop))
11798 else if (unformat (i, "rport_start %d", &rport_start))
11800 else if (unformat (i, "rport_stop %d", &rport_stop))
11804 (i, "laddr_start %U", unformat_ip4_address, &laddr4_start))
11810 if (unformat (i, "laddr_stop %U", unformat_ip4_address, &laddr4_stop))
11817 (i, "raddr_start %U", unformat_ip4_address, &raddr4_start))
11823 if (unformat (i, "raddr_stop %U", unformat_ip4_address, &raddr4_stop))
11830 (i, "laddr_start %U", unformat_ip6_address, &laddr6_start))
11836 if (unformat (i, "laddr_stop %U", unformat_ip6_address, &laddr6_stop))
11843 (i, "raddr_start %U", unformat_ip6_address, &raddr6_start))
11849 if (unformat (i, "raddr_stop %U", unformat_ip6_address, &raddr6_stop))
11855 if (unformat (i, "action %U", unformat_ipsec_policy_action, &policy))
11857 if (policy == IPSEC_POLICY_ACTION_RESOLVE)
11859 clib_warning ("unsupported action: 'resolve'");
11865 clib_warning ("parse error '%U'", format_unformat_error, i);
11871 M (IPSEC_SPD_ADD_DEL_ENTRY, mp);
11873 mp->spd_id = ntohl (spd_id);
11874 mp->priority = ntohl (priority);
11875 mp->is_outbound = is_outbound;
11877 mp->is_ipv6 = is_ipv6;
11878 if (is_ipv6 || is_ip_any)
11880 clib_memcpy (mp->remote_address_start, &raddr6_start,
11881 sizeof (ip6_address_t));
11882 clib_memcpy (mp->remote_address_stop, &raddr6_stop,
11883 sizeof (ip6_address_t));
11884 clib_memcpy (mp->local_address_start, &laddr6_start,
11885 sizeof (ip6_address_t));
11886 clib_memcpy (mp->local_address_stop, &laddr6_stop,
11887 sizeof (ip6_address_t));
11891 clib_memcpy (mp->remote_address_start, &raddr4_start,
11892 sizeof (ip4_address_t));
11893 clib_memcpy (mp->remote_address_stop, &raddr4_stop,
11894 sizeof (ip4_address_t));
11895 clib_memcpy (mp->local_address_start, &laddr4_start,
11896 sizeof (ip4_address_t));
11897 clib_memcpy (mp->local_address_stop, &laddr4_stop,
11898 sizeof (ip4_address_t));
11900 mp->protocol = (u8) protocol;
11901 mp->local_port_start = ntohs ((u16) lport_start);
11902 mp->local_port_stop = ntohs ((u16) lport_stop);
11903 mp->remote_port_start = ntohs ((u16) rport_start);
11904 mp->remote_port_stop = ntohs ((u16) rport_stop);
11905 mp->policy = (u8) policy;
11906 mp->sa_id = ntohl (sa_id);
11907 mp->is_add = is_add;
11908 mp->is_ip_any = is_ip_any;
11915 api_ipsec_sad_add_del_entry (vat_main_t * vam)
11917 unformat_input_t *i = vam->input;
11918 vl_api_ipsec_sad_add_del_entry_t *mp;
11919 u32 sad_id = 0, spi = 0;
11920 u8 *ck = 0, *ik = 0;
11923 u8 protocol = IPSEC_PROTOCOL_AH;
11924 u8 is_tunnel = 0, is_tunnel_ipv6 = 0;
11925 u32 crypto_alg = 0, integ_alg = 0;
11926 ip4_address_t tun_src4;
11927 ip4_address_t tun_dst4;
11928 ip6_address_t tun_src6;
11929 ip6_address_t tun_dst6;
11932 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
11934 if (unformat (i, "del"))
11936 else if (unformat (i, "sad_id %d", &sad_id))
11938 else if (unformat (i, "spi %d", &spi))
11940 else if (unformat (i, "esp"))
11941 protocol = IPSEC_PROTOCOL_ESP;
11942 else if (unformat (i, "tunnel_src %U", unformat_ip4_address, &tun_src4))
11945 is_tunnel_ipv6 = 0;
11947 else if (unformat (i, "tunnel_dst %U", unformat_ip4_address, &tun_dst4))
11950 is_tunnel_ipv6 = 0;
11952 else if (unformat (i, "tunnel_src %U", unformat_ip6_address, &tun_src6))
11955 is_tunnel_ipv6 = 1;
11957 else if (unformat (i, "tunnel_dst %U", unformat_ip6_address, &tun_dst6))
11960 is_tunnel_ipv6 = 1;
11964 (i, "crypto_alg %U", unformat_ipsec_crypto_alg, &crypto_alg))
11966 if (crypto_alg < IPSEC_CRYPTO_ALG_AES_CBC_128 ||
11967 crypto_alg >= IPSEC_CRYPTO_N_ALG)
11969 clib_warning ("unsupported crypto-alg: '%U'",
11970 format_ipsec_crypto_alg, crypto_alg);
11974 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
11978 (i, "integ_alg %U", unformat_ipsec_integ_alg, &integ_alg))
11980 if (integ_alg < IPSEC_INTEG_ALG_SHA1_96 ||
11981 integ_alg >= IPSEC_INTEG_N_ALG)
11983 clib_warning ("unsupported integ-alg: '%U'",
11984 format_ipsec_integ_alg, integ_alg);
11988 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
11992 clib_warning ("parse error '%U'", format_unformat_error, i);
11998 M (IPSEC_SAD_ADD_DEL_ENTRY, mp);
12000 mp->sad_id = ntohl (sad_id);
12001 mp->is_add = is_add;
12002 mp->protocol = protocol;
12003 mp->spi = ntohl (spi);
12004 mp->is_tunnel = is_tunnel;
12005 mp->is_tunnel_ipv6 = is_tunnel_ipv6;
12006 mp->crypto_algorithm = crypto_alg;
12007 mp->integrity_algorithm = integ_alg;
12008 mp->crypto_key_length = vec_len (ck);
12009 mp->integrity_key_length = vec_len (ik);
12011 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12012 mp->crypto_key_length = sizeof (mp->crypto_key);
12014 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12015 mp->integrity_key_length = sizeof (mp->integrity_key);
12018 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12020 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12024 if (is_tunnel_ipv6)
12026 clib_memcpy (mp->tunnel_src_address, &tun_src6,
12027 sizeof (ip6_address_t));
12028 clib_memcpy (mp->tunnel_dst_address, &tun_dst6,
12029 sizeof (ip6_address_t));
12033 clib_memcpy (mp->tunnel_src_address, &tun_src4,
12034 sizeof (ip4_address_t));
12035 clib_memcpy (mp->tunnel_dst_address, &tun_dst4,
12036 sizeof (ip4_address_t));
12046 api_ipsec_sa_set_key (vat_main_t * vam)
12048 unformat_input_t *i = vam->input;
12049 vl_api_ipsec_sa_set_key_t *mp;
12051 u8 *ck = 0, *ik = 0;
12054 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12056 if (unformat (i, "sa_id %d", &sa_id))
12058 else if (unformat (i, "crypto_key %U", unformat_hex_string, &ck))
12060 else if (unformat (i, "integ_key %U", unformat_hex_string, &ik))
12064 clib_warning ("parse error '%U'", format_unformat_error, i);
12069 M (IPSEC_SA_SET_KEY, mp);
12071 mp->sa_id = ntohl (sa_id);
12072 mp->crypto_key_length = vec_len (ck);
12073 mp->integrity_key_length = vec_len (ik);
12075 if (mp->crypto_key_length > sizeof (mp->crypto_key))
12076 mp->crypto_key_length = sizeof (mp->crypto_key);
12078 if (mp->integrity_key_length > sizeof (mp->integrity_key))
12079 mp->integrity_key_length = sizeof (mp->integrity_key);
12082 clib_memcpy (mp->crypto_key, ck, mp->crypto_key_length);
12084 clib_memcpy (mp->integrity_key, ik, mp->integrity_key_length);
12092 api_ikev2_profile_add_del (vat_main_t * vam)
12094 unformat_input_t *i = vam->input;
12095 vl_api_ikev2_profile_add_del_t *mp;
12100 const char *valid_chars = "a-zA-Z0-9_";
12102 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12104 if (unformat (i, "del"))
12106 else if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12107 vec_add1 (name, 0);
12110 errmsg ("parse error '%U'", format_unformat_error, i);
12115 if (!vec_len (name))
12117 errmsg ("profile name must be specified");
12121 if (vec_len (name) > 64)
12123 errmsg ("profile name too long");
12127 M (IKEV2_PROFILE_ADD_DEL, mp);
12129 clib_memcpy (mp->name, name, vec_len (name));
12130 mp->is_add = is_add;
12139 api_ikev2_profile_set_auth (vat_main_t * vam)
12141 unformat_input_t *i = vam->input;
12142 vl_api_ikev2_profile_set_auth_t *mp;
12145 u32 auth_method = 0;
12149 const char *valid_chars = "a-zA-Z0-9_";
12151 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12153 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12154 vec_add1 (name, 0);
12155 else if (unformat (i, "auth_method %U",
12156 unformat_ikev2_auth_method, &auth_method))
12158 else if (unformat (i, "auth_data 0x%U", unformat_hex_string, &data))
12160 else if (unformat (i, "auth_data %v", &data))
12164 errmsg ("parse error '%U'", format_unformat_error, i);
12169 if (!vec_len (name))
12171 errmsg ("profile name must be specified");
12175 if (vec_len (name) > 64)
12177 errmsg ("profile name too long");
12181 if (!vec_len (data))
12183 errmsg ("auth_data must be specified");
12189 errmsg ("auth_method must be specified");
12193 M (IKEV2_PROFILE_SET_AUTH, mp);
12195 mp->is_hex = is_hex;
12196 mp->auth_method = (u8) auth_method;
12197 mp->data_len = vec_len (data);
12198 clib_memcpy (mp->name, name, vec_len (name));
12199 clib_memcpy (mp->data, data, vec_len (data));
12209 api_ikev2_profile_set_id (vat_main_t * vam)
12211 unformat_input_t *i = vam->input;
12212 vl_api_ikev2_profile_set_id_t *mp;
12220 const char *valid_chars = "a-zA-Z0-9_";
12222 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12224 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12225 vec_add1 (name, 0);
12226 else if (unformat (i, "id_type %U", unformat_ikev2_id_type, &id_type))
12228 else if (unformat (i, "id_data %U", unformat_ip4_address, &ip4))
12230 data = vec_new (u8, 4);
12231 clib_memcpy (data, ip4.as_u8, 4);
12233 else if (unformat (i, "id_data 0x%U", unformat_hex_string, &data))
12235 else if (unformat (i, "id_data %v", &data))
12237 else if (unformat (i, "local"))
12239 else if (unformat (i, "remote"))
12243 errmsg ("parse error '%U'", format_unformat_error, i);
12248 if (!vec_len (name))
12250 errmsg ("profile name must be specified");
12254 if (vec_len (name) > 64)
12256 errmsg ("profile name too long");
12260 if (!vec_len (data))
12262 errmsg ("id_data must be specified");
12268 errmsg ("id_type must be specified");
12272 M (IKEV2_PROFILE_SET_ID, mp);
12274 mp->is_local = is_local;
12275 mp->id_type = (u8) id_type;
12276 mp->data_len = vec_len (data);
12277 clib_memcpy (mp->name, name, vec_len (name));
12278 clib_memcpy (mp->data, data, vec_len (data));
12288 api_ikev2_profile_set_ts (vat_main_t * vam)
12290 unformat_input_t *i = vam->input;
12291 vl_api_ikev2_profile_set_ts_t *mp;
12294 u32 proto = 0, start_port = 0, end_port = (u32) ~ 0;
12295 ip4_address_t start_addr, end_addr;
12297 const char *valid_chars = "a-zA-Z0-9_";
12300 start_addr.as_u32 = 0;
12301 end_addr.as_u32 = (u32) ~ 0;
12303 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12305 if (unformat (i, "name %U", unformat_token, valid_chars, &name))
12306 vec_add1 (name, 0);
12307 else if (unformat (i, "protocol %d", &proto))
12309 else if (unformat (i, "start_port %d", &start_port))
12311 else if (unformat (i, "end_port %d", &end_port))
12314 if (unformat (i, "start_addr %U", unformat_ip4_address, &start_addr))
12316 else if (unformat (i, "end_addr %U", unformat_ip4_address, &end_addr))
12318 else if (unformat (i, "local"))
12320 else if (unformat (i, "remote"))
12324 errmsg ("parse error '%U'", format_unformat_error, i);
12329 if (!vec_len (name))
12331 errmsg ("profile name must be specified");
12335 if (vec_len (name) > 64)
12337 errmsg ("profile name too long");
12341 M (IKEV2_PROFILE_SET_TS, mp);
12343 mp->is_local = is_local;
12344 mp->proto = (u8) proto;
12345 mp->start_port = (u16) start_port;
12346 mp->end_port = (u16) end_port;
12347 mp->start_addr = start_addr.as_u32;
12348 mp->end_addr = end_addr.as_u32;
12349 clib_memcpy (mp->name, name, vec_len (name));
12358 api_ikev2_set_local_key (vat_main_t * vam)
12360 unformat_input_t *i = vam->input;
12361 vl_api_ikev2_set_local_key_t *mp;
12365 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12367 if (unformat (i, "file %v", &file))
12368 vec_add1 (file, 0);
12371 errmsg ("parse error '%U'", format_unformat_error, i);
12376 if (!vec_len (file))
12378 errmsg ("RSA key file must be specified");
12382 if (vec_len (file) > 256)
12384 errmsg ("file name too long");
12388 M (IKEV2_SET_LOCAL_KEY, mp);
12390 clib_memcpy (mp->key_file, file, vec_len (file));
12399 api_ikev2_set_responder (vat_main_t * vam)
12401 unformat_input_t *i = vam->input;
12402 vl_api_ikev2_set_responder_t *mp;
12405 u32 sw_if_index = ~0;
12406 ip4_address_t address;
12408 const char *valid_chars = "a-zA-Z0-9_";
12410 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12413 (i, "%U interface %d address %U", unformat_token, valid_chars,
12414 &name, &sw_if_index, unformat_ip4_address, &address))
12415 vec_add1 (name, 0);
12418 errmsg ("parse error '%U'", format_unformat_error, i);
12423 if (!vec_len (name))
12425 errmsg ("profile name must be specified");
12429 if (vec_len (name) > 64)
12431 errmsg ("profile name too long");
12435 M (IKEV2_SET_RESPONDER, mp);
12437 clib_memcpy (mp->name, name, vec_len (name));
12440 mp->sw_if_index = sw_if_index;
12441 clib_memcpy (mp->address, &address, sizeof (address));
12449 api_ikev2_set_ike_transforms (vat_main_t * vam)
12451 unformat_input_t *i = vam->input;
12452 vl_api_ikev2_set_ike_transforms_t *mp;
12455 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12457 const char *valid_chars = "a-zA-Z0-9_";
12459 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12461 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12462 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12463 vec_add1 (name, 0);
12466 errmsg ("parse error '%U'", format_unformat_error, i);
12471 if (!vec_len (name))
12473 errmsg ("profile name must be specified");
12477 if (vec_len (name) > 64)
12479 errmsg ("profile name too long");
12483 M (IKEV2_SET_IKE_TRANSFORMS, mp);
12485 clib_memcpy (mp->name, name, vec_len (name));
12487 mp->crypto_alg = crypto_alg;
12488 mp->crypto_key_size = crypto_key_size;
12489 mp->integ_alg = integ_alg;
12490 mp->dh_group = dh_group;
12499 api_ikev2_set_esp_transforms (vat_main_t * vam)
12501 unformat_input_t *i = vam->input;
12502 vl_api_ikev2_set_esp_transforms_t *mp;
12505 u32 crypto_alg, crypto_key_size, integ_alg, dh_group;
12507 const char *valid_chars = "a-zA-Z0-9_";
12509 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12511 if (unformat (i, "%U %d %d %d %d", unformat_token, valid_chars, &name,
12512 &crypto_alg, &crypto_key_size, &integ_alg, &dh_group))
12513 vec_add1 (name, 0);
12516 errmsg ("parse error '%U'", format_unformat_error, i);
12521 if (!vec_len (name))
12523 errmsg ("profile name must be specified");
12527 if (vec_len (name) > 64)
12529 errmsg ("profile name too long");
12533 M (IKEV2_SET_ESP_TRANSFORMS, mp);
12535 clib_memcpy (mp->name, name, vec_len (name));
12537 mp->crypto_alg = crypto_alg;
12538 mp->crypto_key_size = crypto_key_size;
12539 mp->integ_alg = integ_alg;
12540 mp->dh_group = dh_group;
12548 api_ikev2_set_sa_lifetime (vat_main_t * vam)
12550 unformat_input_t *i = vam->input;
12551 vl_api_ikev2_set_sa_lifetime_t *mp;
12554 u64 lifetime, lifetime_maxdata;
12555 u32 lifetime_jitter, handover;
12557 const char *valid_chars = "a-zA-Z0-9_";
12559 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12561 if (unformat (i, "%U %lu %u %u %lu", unformat_token, valid_chars, &name,
12562 &lifetime, &lifetime_jitter, &handover,
12563 &lifetime_maxdata))
12564 vec_add1 (name, 0);
12567 errmsg ("parse error '%U'", format_unformat_error, i);
12572 if (!vec_len (name))
12574 errmsg ("profile name must be specified");
12578 if (vec_len (name) > 64)
12580 errmsg ("profile name too long");
12584 M (IKEV2_SET_SA_LIFETIME, mp);
12586 clib_memcpy (mp->name, name, vec_len (name));
12588 mp->lifetime = lifetime;
12589 mp->lifetime_jitter = lifetime_jitter;
12590 mp->handover = handover;
12591 mp->lifetime_maxdata = lifetime_maxdata;
12599 api_ikev2_initiate_sa_init (vat_main_t * vam)
12601 unformat_input_t *i = vam->input;
12602 vl_api_ikev2_initiate_sa_init_t *mp;
12606 const char *valid_chars = "a-zA-Z0-9_";
12608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12610 if (unformat (i, "%U", unformat_token, valid_chars, &name))
12611 vec_add1 (name, 0);
12614 errmsg ("parse error '%U'", format_unformat_error, i);
12619 if (!vec_len (name))
12621 errmsg ("profile name must be specified");
12625 if (vec_len (name) > 64)
12627 errmsg ("profile name too long");
12631 M (IKEV2_INITIATE_SA_INIT, mp);
12633 clib_memcpy (mp->name, name, vec_len (name));
12642 api_ikev2_initiate_del_ike_sa (vat_main_t * vam)
12644 unformat_input_t *i = vam->input;
12645 vl_api_ikev2_initiate_del_ike_sa_t *mp;
12650 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12652 if (unformat (i, "%lx", &ispi))
12656 errmsg ("parse error '%U'", format_unformat_error, i);
12661 M (IKEV2_INITIATE_DEL_IKE_SA, mp);
12671 api_ikev2_initiate_del_child_sa (vat_main_t * vam)
12673 unformat_input_t *i = vam->input;
12674 vl_api_ikev2_initiate_del_child_sa_t *mp;
12679 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12681 if (unformat (i, "%x", &ispi))
12685 errmsg ("parse error '%U'", format_unformat_error, i);
12690 M (IKEV2_INITIATE_DEL_CHILD_SA, mp);
12700 api_ikev2_initiate_rekey_child_sa (vat_main_t * vam)
12702 unformat_input_t *i = vam->input;
12703 vl_api_ikev2_initiate_rekey_child_sa_t *mp;
12708 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12710 if (unformat (i, "%x", &ispi))
12714 errmsg ("parse error '%U'", format_unformat_error, i);
12719 M (IKEV2_INITIATE_REKEY_CHILD_SA, mp);
12732 api_map_add_domain (vat_main_t * vam)
12734 unformat_input_t *i = vam->input;
12735 vl_api_map_add_domain_t *mp;
12737 ip4_address_t ip4_prefix;
12738 ip6_address_t ip6_prefix;
12739 ip6_address_t ip6_src;
12740 u32 num_m_args = 0;
12741 u32 ip6_prefix_len = 0, ip4_prefix_len = 0, ea_bits_len = 0, psid_offset =
12742 0, psid_length = 0;
12743 u8 is_translation = 0;
12745 u32 ip6_src_len = 128;
12748 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12750 if (unformat (i, "ip4-pfx %U/%d", unformat_ip4_address,
12751 &ip4_prefix, &ip4_prefix_len))
12753 else if (unformat (i, "ip6-pfx %U/%d", unformat_ip6_address,
12754 &ip6_prefix, &ip6_prefix_len))
12758 (i, "ip6-src %U/%d", unformat_ip6_address, &ip6_src,
12761 else if (unformat (i, "ip6-src %U", unformat_ip6_address, &ip6_src))
12763 else if (unformat (i, "ea-bits-len %d", &ea_bits_len))
12765 else if (unformat (i, "psid-offset %d", &psid_offset))
12767 else if (unformat (i, "psid-len %d", &psid_length))
12769 else if (unformat (i, "mtu %d", &mtu))
12771 else if (unformat (i, "map-t"))
12772 is_translation = 1;
12775 clib_warning ("parse error '%U'", format_unformat_error, i);
12780 if (num_m_args < 3)
12782 errmsg ("mandatory argument(s) missing");
12786 /* Construct the API message */
12787 M (MAP_ADD_DOMAIN, mp);
12789 clib_memcpy (mp->ip4_prefix, &ip4_prefix, sizeof (ip4_prefix));
12790 mp->ip4_prefix_len = ip4_prefix_len;
12792 clib_memcpy (mp->ip6_prefix, &ip6_prefix, sizeof (ip6_prefix));
12793 mp->ip6_prefix_len = ip6_prefix_len;
12795 clib_memcpy (mp->ip6_src, &ip6_src, sizeof (ip6_src));
12796 mp->ip6_src_prefix_len = ip6_src_len;
12798 mp->ea_bits_len = ea_bits_len;
12799 mp->psid_offset = psid_offset;
12800 mp->psid_length = psid_length;
12801 mp->is_translation = is_translation;
12802 mp->mtu = htons (mtu);
12807 /* Wait for a reply, return good/bad news */
12813 api_map_del_domain (vat_main_t * vam)
12815 unformat_input_t *i = vam->input;
12816 vl_api_map_del_domain_t *mp;
12818 u32 num_m_args = 0;
12822 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12824 if (unformat (i, "index %d", &index))
12828 clib_warning ("parse error '%U'", format_unformat_error, i);
12833 if (num_m_args != 1)
12835 errmsg ("mandatory argument(s) missing");
12839 /* Construct the API message */
12840 M (MAP_DEL_DOMAIN, mp);
12842 mp->index = ntohl (index);
12847 /* Wait for a reply, return good/bad news */
12853 api_map_add_del_rule (vat_main_t * vam)
12855 unformat_input_t *i = vam->input;
12856 vl_api_map_add_del_rule_t *mp;
12858 ip6_address_t ip6_dst;
12859 u32 num_m_args = 0, index, psid = 0;
12862 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12864 if (unformat (i, "index %d", &index))
12866 else if (unformat (i, "psid %d", &psid))
12868 else if (unformat (i, "dst %U", unformat_ip6_address, &ip6_dst))
12870 else if (unformat (i, "del"))
12876 clib_warning ("parse error '%U'", format_unformat_error, i);
12881 /* Construct the API message */
12882 M (MAP_ADD_DEL_RULE, mp);
12884 mp->index = ntohl (index);
12885 mp->is_add = is_add;
12886 clib_memcpy (mp->ip6_dst, &ip6_dst, sizeof (ip6_dst));
12887 mp->psid = ntohs (psid);
12892 /* Wait for a reply, return good/bad news */
12898 api_map_domain_dump (vat_main_t * vam)
12900 vl_api_map_domain_dump_t *mp;
12901 vl_api_control_ping_t *mp_ping;
12904 /* Construct the API message */
12905 M (MAP_DOMAIN_DUMP, mp);
12910 /* Use a control ping for synchronization */
12911 M (CONTROL_PING, mp_ping);
12919 api_map_rule_dump (vat_main_t * vam)
12921 unformat_input_t *i = vam->input;
12922 vl_api_map_rule_dump_t *mp;
12923 vl_api_control_ping_t *mp_ping;
12924 u32 domain_index = ~0;
12927 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
12929 if (unformat (i, "index %u", &domain_index))
12935 if (domain_index == ~0)
12937 clib_warning ("parse error: domain index expected");
12941 /* Construct the API message */
12942 M (MAP_RULE_DUMP, mp);
12944 mp->domain_index = htonl (domain_index);
12949 /* Use a control ping for synchronization */
12950 M (CONTROL_PING, mp_ping);
12957 static void vl_api_map_add_domain_reply_t_handler
12958 (vl_api_map_add_domain_reply_t * mp)
12960 vat_main_t *vam = &vat_main;
12961 i32 retval = ntohl (mp->retval);
12963 if (vam->async_mode)
12965 vam->async_errors += (retval < 0);
12969 vam->retval = retval;
12970 vam->result_ready = 1;
12974 static void vl_api_map_add_domain_reply_t_handler_json
12975 (vl_api_map_add_domain_reply_t * mp)
12977 vat_main_t *vam = &vat_main;
12978 vat_json_node_t node;
12980 vat_json_init_object (&node);
12981 vat_json_object_add_int (&node, "retval", ntohl (mp->retval));
12982 vat_json_object_add_uint (&node, "index", ntohl (mp->index));
12984 vat_json_print (vam->ofp, &node);
12985 vat_json_free (&node);
12987 vam->retval = ntohl (mp->retval);
12988 vam->result_ready = 1;
12992 api_get_first_msg_id (vat_main_t * vam)
12994 vl_api_get_first_msg_id_t *mp;
12995 unformat_input_t *i = vam->input;
13000 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
13002 if (unformat (i, "client %s", &name))
13010 errmsg ("missing client name");
13013 vec_add1 (name, 0);
13015 if (vec_len (name) > 63)
13017 errmsg ("client name too long");
13021 M (GET_FIRST_MSG_ID, mp);
13022 clib_memcpy (mp->name, name, vec_len (name));
13029 api_cop_interface_enable_disable (vat_main_t * vam)
13031 unformat_input_t *line_input = vam->input;
13032 vl_api_cop_interface_enable_disable_t *mp;
13033 u32 sw_if_index = ~0;
13034 u8 enable_disable = 1;
13037 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13039 if (unformat (line_input, "disable"))
13040 enable_disable = 0;
13041 if (unformat (line_input, "enable"))
13042 enable_disable = 1;
13043 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13044 vam, &sw_if_index))
13046 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13052 if (sw_if_index == ~0)
13054 errmsg ("missing interface name or sw_if_index");
13058 /* Construct the API message */
13059 M (COP_INTERFACE_ENABLE_DISABLE, mp);
13060 mp->sw_if_index = ntohl (sw_if_index);
13061 mp->enable_disable = enable_disable;
13065 /* Wait for the reply */
13071 api_cop_whitelist_enable_disable (vat_main_t * vam)
13073 unformat_input_t *line_input = vam->input;
13074 vl_api_cop_whitelist_enable_disable_t *mp;
13075 u32 sw_if_index = ~0;
13076 u8 ip4 = 0, ip6 = 0, default_cop = 0;
13080 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
13082 if (unformat (line_input, "ip4"))
13084 else if (unformat (line_input, "ip6"))
13086 else if (unformat (line_input, "default"))
13088 else if (unformat (line_input, "%U", api_unformat_sw_if_index,
13089 vam, &sw_if_index))
13091 else if (unformat (line_input, "sw_if_index %d", &sw_if_index))
13093 else if (unformat (line_input, "fib-id %d", &fib_id))
13099 if (sw_if_index == ~0)
13101 errmsg ("missing interface name or sw_if_index");
13105 /* Construct the API message */
13106 M (COP_WHITELIST_ENABLE_DISABLE, mp);
13107 mp->sw_if_index = ntohl (sw_if_index);
13108 mp->fib_id = ntohl (fib_id);
13111 mp->default_cop = default_cop;
13115 /* Wait for the reply */
13121 api_get_node_graph (vat_main_t * vam)
13123 vl_api_get_node_graph_t *mp;
13126 M (GET_NODE_GRAPH, mp);
13130 /* Wait for the reply */
13136 /** Used for parsing LISP eids */
13137 typedef CLIB_PACKED(struct{
13138 u8 addr[16]; /**< eid address */
13139 u32 len; /**< prefix length if IP */
13140 u8 type; /**< type of eid */
13145 unformat_lisp_eid_vat (unformat_input_t * input, va_list * args)
13147 lisp_eid_vat_t *a = va_arg (*args, lisp_eid_vat_t *);
13149 memset (a, 0, sizeof (a[0]));
13151 if (unformat (input, "%U/%d", unformat_ip4_address, a->addr, &a->len))
13153 a->type = 0; /* ipv4 type */
13155 else if (unformat (input, "%U/%d", unformat_ip6_address, a->addr, &a->len))
13157 a->type = 1; /* ipv6 type */
13159 else if (unformat (input, "%U", unformat_ethernet_address, a->addr))
13161 a->type = 2; /* mac type */
13168 if ((a->type == 0 && a->len > 32) || (a->type == 1 && a->len > 128))
13177 lisp_eid_size_vat (u8 type)
13192 lisp_eid_put_vat (u8 * dst, u8 eid[16], u8 type)
13194 clib_memcpy (dst, eid, lisp_eid_size_vat (type));
13198 api_one_add_del_locator_set (vat_main_t * vam)
13200 unformat_input_t *input = vam->input;
13201 vl_api_one_add_del_locator_set_t *mp;
13203 u8 *locator_set_name = NULL;
13204 u8 locator_set_name_set = 0;
13205 vl_api_local_locator_t locator, *locators = 0;
13206 u32 sw_if_index, priority, weight;
13210 /* Parse args required to build the message */
13211 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13213 if (unformat (input, "del"))
13217 else if (unformat (input, "locator-set %s", &locator_set_name))
13219 locator_set_name_set = 1;
13221 else if (unformat (input, "sw_if_index %u p %u w %u",
13222 &sw_if_index, &priority, &weight))
13224 locator.sw_if_index = htonl (sw_if_index);
13225 locator.priority = priority;
13226 locator.weight = weight;
13227 vec_add1 (locators, locator);
13231 (input, "iface %U p %u w %u", api_unformat_sw_if_index, vam,
13232 &sw_if_index, &priority, &weight))
13234 locator.sw_if_index = htonl (sw_if_index);
13235 locator.priority = priority;
13236 locator.weight = weight;
13237 vec_add1 (locators, locator);
13243 if (locator_set_name_set == 0)
13245 errmsg ("missing locator-set name");
13246 vec_free (locators);
13250 if (vec_len (locator_set_name) > 64)
13252 errmsg ("locator-set name too long");
13253 vec_free (locator_set_name);
13254 vec_free (locators);
13257 vec_add1 (locator_set_name, 0);
13259 data_len = sizeof (vl_api_local_locator_t) * vec_len (locators);
13261 /* Construct the API message */
13262 M2 (ONE_ADD_DEL_LOCATOR_SET, mp, data_len);
13264 mp->is_add = is_add;
13265 clib_memcpy (mp->locator_set_name, locator_set_name,
13266 vec_len (locator_set_name));
13267 vec_free (locator_set_name);
13269 mp->locator_num = clib_host_to_net_u32 (vec_len (locators));
13271 clib_memcpy (mp->locators, locators, data_len);
13272 vec_free (locators);
13277 /* Wait for a reply... */
13282 #define api_lisp_add_del_locator_set api_one_add_del_locator_set
13285 api_one_add_del_locator (vat_main_t * vam)
13287 unformat_input_t *input = vam->input;
13288 vl_api_one_add_del_locator_t *mp;
13289 u32 tmp_if_index = ~0;
13290 u32 sw_if_index = ~0;
13291 u8 sw_if_index_set = 0;
13292 u8 sw_if_index_if_name_set = 0;
13294 u8 priority_set = 0;
13298 u8 *locator_set_name = NULL;
13299 u8 locator_set_name_set = 0;
13302 /* Parse args required to build the message */
13303 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13305 if (unformat (input, "del"))
13309 else if (unformat (input, "locator-set %s", &locator_set_name))
13311 locator_set_name_set = 1;
13313 else if (unformat (input, "iface %U", api_unformat_sw_if_index, vam,
13316 sw_if_index_if_name_set = 1;
13317 sw_if_index = tmp_if_index;
13319 else if (unformat (input, "sw_if_index %d", &tmp_if_index))
13321 sw_if_index_set = 1;
13322 sw_if_index = tmp_if_index;
13324 else if (unformat (input, "p %d", &priority))
13328 else if (unformat (input, "w %d", &weight))
13336 if (locator_set_name_set == 0)
13338 errmsg ("missing locator-set name");
13342 if (sw_if_index_set == 0 && sw_if_index_if_name_set == 0)
13344 errmsg ("missing sw_if_index");
13345 vec_free (locator_set_name);
13349 if (sw_if_index_set != 0 && sw_if_index_if_name_set != 0)
13351 errmsg ("cannot use both params interface name and sw_if_index");
13352 vec_free (locator_set_name);
13356 if (priority_set == 0)
13358 errmsg ("missing locator-set priority");
13359 vec_free (locator_set_name);
13363 if (weight_set == 0)
13365 errmsg ("missing locator-set weight");
13366 vec_free (locator_set_name);
13370 if (vec_len (locator_set_name) > 64)
13372 errmsg ("locator-set name too long");
13373 vec_free (locator_set_name);
13376 vec_add1 (locator_set_name, 0);
13378 /* Construct the API message */
13379 M (ONE_ADD_DEL_LOCATOR, mp);
13381 mp->is_add = is_add;
13382 mp->sw_if_index = ntohl (sw_if_index);
13383 mp->priority = priority;
13384 mp->weight = weight;
13385 clib_memcpy (mp->locator_set_name, locator_set_name,
13386 vec_len (locator_set_name));
13387 vec_free (locator_set_name);
13392 /* Wait for a reply... */
13397 #define api_lisp_add_del_locator api_one_add_del_locator
13400 unformat_hmac_key_id (unformat_input_t * input, va_list * args)
13402 u32 *key_id = va_arg (*args, u32 *);
13405 if (unformat (input, "%s", &s))
13407 if (!strcmp ((char *) s, "sha1"))
13408 key_id[0] = HMAC_SHA_1_96;
13409 else if (!strcmp ((char *) s, "sha256"))
13410 key_id[0] = HMAC_SHA_256_128;
13413 clib_warning ("invalid key_id: '%s'", s);
13414 key_id[0] = HMAC_NO_KEY;
13425 api_one_add_del_local_eid (vat_main_t * vam)
13427 unformat_input_t *input = vam->input;
13428 vl_api_one_add_del_local_eid_t *mp;
13431 lisp_eid_vat_t _eid, *eid = &_eid;
13432 u8 *locator_set_name = 0;
13433 u8 locator_set_name_set = 0;
13439 /* Parse args required to build the message */
13440 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13442 if (unformat (input, "del"))
13446 else if (unformat (input, "vni %d", &vni))
13450 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
13454 else if (unformat (input, "locator-set %s", &locator_set_name))
13456 locator_set_name_set = 1;
13458 else if (unformat (input, "key-id %U", unformat_hmac_key_id, &key_id))
13460 else if (unformat (input, "secret-key %_%v%_", &key))
13466 if (locator_set_name_set == 0)
13468 errmsg ("missing locator-set name");
13474 errmsg ("EID address not set!");
13475 vec_free (locator_set_name);
13479 if (key && (0 == key_id))
13481 errmsg ("invalid key_id!");
13485 if (vec_len (key) > 64)
13487 errmsg ("key too long");
13492 if (vec_len (locator_set_name) > 64)
13494 errmsg ("locator-set name too long");
13495 vec_free (locator_set_name);
13498 vec_add1 (locator_set_name, 0);
13500 /* Construct the API message */
13501 M (ONE_ADD_DEL_LOCAL_EID, mp);
13503 mp->is_add = is_add;
13504 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
13505 mp->eid_type = eid->type;
13506 mp->prefix_len = eid->len;
13507 mp->vni = clib_host_to_net_u32 (vni);
13508 mp->key_id = clib_host_to_net_u16 (key_id);
13509 clib_memcpy (mp->locator_set_name, locator_set_name,
13510 vec_len (locator_set_name));
13511 clib_memcpy (mp->key, key, vec_len (key));
13513 vec_free (locator_set_name);
13519 /* Wait for a reply... */
13524 #define api_lisp_add_del_local_eid api_one_add_del_local_eid
13527 api_lisp_gpe_add_del_fwd_entry (vat_main_t * vam)
13529 u32 dp_table = 0, vni = 0;;
13530 unformat_input_t *input = vam->input;
13531 vl_api_gpe_add_del_fwd_entry_t *mp;
13533 lisp_eid_vat_t _rmt_eid, *rmt_eid = &_rmt_eid;
13534 lisp_eid_vat_t _lcl_eid, *lcl_eid = &_lcl_eid;
13535 u8 rmt_eid_set = 0, lcl_eid_set = 0;
13536 u32 action = ~0, w;
13537 ip4_address_t rmt_rloc4, lcl_rloc4;
13538 ip6_address_t rmt_rloc6, lcl_rloc6;
13539 vl_api_gpe_locator_t *rmt_locs = 0, *lcl_locs = 0, rloc, *curr_rloc = 0;
13542 memset (&rloc, 0, sizeof (rloc));
13544 /* Parse args required to build the message */
13545 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13547 if (unformat (input, "del"))
13549 else if (unformat (input, "add"))
13551 else if (unformat (input, "reid %U", unformat_lisp_eid_vat, rmt_eid))
13555 else if (unformat (input, "leid %U", unformat_lisp_eid_vat, lcl_eid))
13559 else if (unformat (input, "vrf %d", &dp_table))
13561 else if (unformat (input, "bd %d", &dp_table))
13563 else if (unformat (input, "vni %d", &vni))
13565 else if (unformat (input, "w %d", &w))
13569 errmsg ("No RLOC configured for setting priority/weight!");
13572 curr_rloc->weight = w;
13574 else if (unformat (input, "loc-pair %U %U", unformat_ip4_address,
13575 &lcl_rloc4, unformat_ip4_address, &rmt_rloc4))
13579 clib_memcpy (&rloc.addr, &lcl_rloc4, sizeof (lcl_rloc4));
13581 vec_add1 (lcl_locs, rloc);
13583 clib_memcpy (&rloc.addr, &rmt_rloc4, sizeof (rmt_rloc4));
13584 vec_add1 (rmt_locs, rloc);
13585 /* weight saved in rmt loc */
13586 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13588 else if (unformat (input, "loc-pair %U %U", unformat_ip6_address,
13589 &lcl_rloc6, unformat_ip6_address, &rmt_rloc6))
13592 clib_memcpy (&rloc.addr, &lcl_rloc6, sizeof (lcl_rloc6));
13594 vec_add1 (lcl_locs, rloc);
13596 clib_memcpy (&rloc.addr, &rmt_rloc6, sizeof (rmt_rloc6));
13597 vec_add1 (rmt_locs, rloc);
13598 /* weight saved in rmt loc */
13599 curr_rloc = &rmt_locs[vec_len (rmt_locs) - 1];
13601 else if (unformat (input, "action %d", &action))
13607 clib_warning ("parse error '%U'", format_unformat_error, input);
13614 errmsg ("remote eid addresses not set");
13618 if (lcl_eid_set && rmt_eid->type != lcl_eid->type)
13620 errmsg ("eid types don't match");
13624 if (0 == rmt_locs && (u32) ~ 0 == action)
13626 errmsg ("action not set for negative mapping");
13630 /* Construct the API message */
13631 M2 (GPE_ADD_DEL_FWD_ENTRY, mp,
13632 sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs) * 2);
13634 mp->is_add = is_add;
13635 lisp_eid_put_vat (mp->rmt_eid, rmt_eid->addr, rmt_eid->type);
13636 lisp_eid_put_vat (mp->lcl_eid, lcl_eid->addr, lcl_eid->type);
13637 mp->eid_type = rmt_eid->type;
13638 mp->dp_table = clib_host_to_net_u32 (dp_table);
13639 mp->vni = clib_host_to_net_u32 (vni);
13640 mp->rmt_len = rmt_eid->len;
13641 mp->lcl_len = lcl_eid->len;
13642 mp->action = action;
13644 if (0 != rmt_locs && 0 != lcl_locs)
13646 mp->loc_num = clib_host_to_net_u32 (vec_len (rmt_locs) * 2);
13647 clib_memcpy (mp->locs, lcl_locs,
13648 (sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs)));
13650 u32 offset = sizeof (vl_api_gpe_locator_t) * vec_len (lcl_locs);
13651 clib_memcpy (((u8 *) mp->locs) + offset, rmt_locs,
13652 (sizeof (vl_api_gpe_locator_t) * vec_len (rmt_locs)));
13654 vec_free (lcl_locs);
13655 vec_free (rmt_locs);
13660 /* Wait for a reply... */
13666 api_one_add_del_map_server (vat_main_t * vam)
13668 unformat_input_t *input = vam->input;
13669 vl_api_one_add_del_map_server_t *mp;
13673 ip4_address_t ipv4;
13674 ip6_address_t ipv6;
13677 /* Parse args required to build the message */
13678 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13680 if (unformat (input, "del"))
13684 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13688 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13696 if (ipv4_set && ipv6_set)
13698 errmsg ("both eid v4 and v6 addresses set");
13702 if (!ipv4_set && !ipv6_set)
13704 errmsg ("eid addresses not set");
13708 /* Construct the API message */
13709 M (ONE_ADD_DEL_MAP_SERVER, mp);
13711 mp->is_add = is_add;
13715 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13720 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13726 /* Wait for a reply... */
13731 #define api_lisp_add_del_map_server api_one_add_del_map_server
13734 api_one_add_del_map_resolver (vat_main_t * vam)
13736 unformat_input_t *input = vam->input;
13737 vl_api_one_add_del_map_resolver_t *mp;
13741 ip4_address_t ipv4;
13742 ip6_address_t ipv6;
13745 /* Parse args required to build the message */
13746 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13748 if (unformat (input, "del"))
13752 else if (unformat (input, "%U", unformat_ip4_address, &ipv4))
13756 else if (unformat (input, "%U", unformat_ip6_address, &ipv6))
13764 if (ipv4_set && ipv6_set)
13766 errmsg ("both eid v4 and v6 addresses set");
13770 if (!ipv4_set && !ipv6_set)
13772 errmsg ("eid addresses not set");
13776 /* Construct the API message */
13777 M (ONE_ADD_DEL_MAP_RESOLVER, mp);
13779 mp->is_add = is_add;
13783 clib_memcpy (mp->ip_address, &ipv6, sizeof (ipv6));
13788 clib_memcpy (mp->ip_address, &ipv4, sizeof (ipv4));
13794 /* Wait for a reply... */
13799 #define api_lisp_add_del_map_resolver api_one_add_del_map_resolver
13802 api_lisp_gpe_enable_disable (vat_main_t * vam)
13804 unformat_input_t *input = vam->input;
13805 vl_api_gpe_enable_disable_t *mp;
13810 /* Parse args required to build the message */
13811 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13813 if (unformat (input, "enable"))
13818 else if (unformat (input, "disable"))
13829 errmsg ("Value not set");
13833 /* Construct the API message */
13834 M (GPE_ENABLE_DISABLE, mp);
13841 /* Wait for a reply... */
13847 api_one_rloc_probe_enable_disable (vat_main_t * vam)
13849 unformat_input_t *input = vam->input;
13850 vl_api_one_rloc_probe_enable_disable_t *mp;
13855 /* Parse args required to build the message */
13856 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13858 if (unformat (input, "enable"))
13863 else if (unformat (input, "disable"))
13871 errmsg ("Value not set");
13875 /* Construct the API message */
13876 M (ONE_RLOC_PROBE_ENABLE_DISABLE, mp);
13878 mp->is_enabled = is_en;
13883 /* Wait for a reply... */
13888 #define api_lisp_rloc_probe_enable_disable api_one_rloc_probe_enable_disable
13891 api_one_map_register_enable_disable (vat_main_t * vam)
13893 unformat_input_t *input = vam->input;
13894 vl_api_one_map_register_enable_disable_t *mp;
13899 /* Parse args required to build the message */
13900 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13902 if (unformat (input, "enable"))
13907 else if (unformat (input, "disable"))
13915 errmsg ("Value not set");
13919 /* Construct the API message */
13920 M (ONE_MAP_REGISTER_ENABLE_DISABLE, mp);
13922 mp->is_enabled = is_en;
13927 /* Wait for a reply... */
13932 #define api_lisp_map_register_enable_disable api_one_map_register_enable_disable
13935 api_one_enable_disable (vat_main_t * vam)
13937 unformat_input_t *input = vam->input;
13938 vl_api_one_enable_disable_t *mp;
13943 /* Parse args required to build the message */
13944 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
13946 if (unformat (input, "enable"))
13951 else if (unformat (input, "disable"))
13961 errmsg ("Value not set");
13965 /* Construct the API message */
13966 M (ONE_ENABLE_DISABLE, mp);
13973 /* Wait for a reply... */
13978 #define api_lisp_enable_disable api_one_enable_disable
13981 api_show_one_map_register_state (vat_main_t * vam)
13983 vl_api_show_one_map_register_state_t *mp;
13986 M (SHOW_ONE_MAP_REGISTER_STATE, mp);
13991 /* wait for reply */
13996 #define api_show_lisp_map_register_state api_show_one_map_register_state
13999 api_show_one_rloc_probe_state (vat_main_t * vam)
14001 vl_api_show_one_rloc_probe_state_t *mp;
14004 M (SHOW_ONE_RLOC_PROBE_STATE, mp);
14009 /* wait for reply */
14014 #define api_show_lisp_rloc_probe_state api_show_one_rloc_probe_state
14017 api_show_one_map_request_mode (vat_main_t * vam)
14019 vl_api_show_one_map_request_mode_t *mp;
14022 M (SHOW_ONE_MAP_REQUEST_MODE, mp);
14027 /* wait for reply */
14032 #define api_show_lisp_map_request_mode api_show_one_map_request_mode
14035 api_one_map_request_mode (vat_main_t * vam)
14037 unformat_input_t *input = vam->input;
14038 vl_api_one_map_request_mode_t *mp;
14042 /* Parse args required to build the message */
14043 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14045 if (unformat (input, "dst-only"))
14047 else if (unformat (input, "src-dst"))
14051 errmsg ("parse error '%U'", format_unformat_error, input);
14056 M (ONE_MAP_REQUEST_MODE, mp);
14063 /* wait for reply */
14068 #define api_lisp_map_request_mode api_one_map_request_mode
14071 * Enable/disable ONE proxy ITR.
14073 * @param vam vpp API test context
14074 * @return return code
14077 api_one_pitr_set_locator_set (vat_main_t * vam)
14079 u8 ls_name_set = 0;
14080 unformat_input_t *input = vam->input;
14081 vl_api_one_pitr_set_locator_set_t *mp;
14086 /* Parse args required to build the message */
14087 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14089 if (unformat (input, "del"))
14091 else if (unformat (input, "locator-set %s", &ls_name))
14095 errmsg ("parse error '%U'", format_unformat_error, input);
14102 errmsg ("locator-set name not set!");
14106 M (ONE_PITR_SET_LOCATOR_SET, mp);
14108 mp->is_add = is_add;
14109 clib_memcpy (mp->ls_name, ls_name, vec_len (ls_name));
14110 vec_free (ls_name);
14115 /* wait for reply */
14120 #define api_lisp_pitr_set_locator_set api_one_pitr_set_locator_set
14123 api_show_one_pitr (vat_main_t * vam)
14125 vl_api_show_one_pitr_t *mp;
14128 if (!vam->json_output)
14130 print (vam->ofp, "%=20s", "lisp status:");
14133 M (SHOW_ONE_PITR, mp);
14137 /* Wait for a reply... */
14142 #define api_show_lisp_pitr api_show_one_pitr
14145 * Add/delete mapping between vni and vrf
14148 api_one_eid_table_add_del_map (vat_main_t * vam)
14150 unformat_input_t *input = vam->input;
14151 vl_api_one_eid_table_add_del_map_t *mp;
14152 u8 is_add = 1, vni_set = 0, vrf_set = 0, bd_index_set = 0;
14153 u32 vni, vrf, bd_index;
14156 /* Parse args required to build the message */
14157 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14159 if (unformat (input, "del"))
14161 else if (unformat (input, "vrf %d", &vrf))
14163 else if (unformat (input, "bd_index %d", &bd_index))
14165 else if (unformat (input, "vni %d", &vni))
14171 if (!vni_set || (!vrf_set && !bd_index_set))
14173 errmsg ("missing arguments!");
14177 if (vrf_set && bd_index_set)
14179 errmsg ("error: both vrf and bd entered!");
14183 M (ONE_EID_TABLE_ADD_DEL_MAP, mp);
14185 mp->is_add = is_add;
14186 mp->vni = htonl (vni);
14187 mp->dp_table = vrf_set ? htonl (vrf) : htonl (bd_index);
14188 mp->is_l2 = bd_index_set;
14193 /* wait for reply */
14198 #define api_lisp_eid_table_add_del_map api_one_eid_table_add_del_map
14201 unformat_negative_mapping_action (unformat_input_t * input, va_list * args)
14203 u32 *action = va_arg (*args, u32 *);
14206 if (unformat (input, "%s", &s))
14208 if (!strcmp ((char *) s, "no-action"))
14210 else if (!strcmp ((char *) s, "natively-forward"))
14212 else if (!strcmp ((char *) s, "send-map-request"))
14214 else if (!strcmp ((char *) s, "drop"))
14218 clib_warning ("invalid action: '%s'", s);
14230 * Add/del remote mapping to/from ONE control plane
14232 * @param vam vpp API test context
14233 * @return return code
14236 api_one_add_del_remote_mapping (vat_main_t * vam)
14238 unformat_input_t *input = vam->input;
14239 vl_api_one_add_del_remote_mapping_t *mp;
14241 lisp_eid_vat_t _eid, *eid = &_eid;
14242 lisp_eid_vat_t _seid, *seid = &_seid;
14243 u8 is_add = 1, del_all = 0, eid_set = 0, seid_set = 0;
14244 u32 action = ~0, p, w, data_len;
14245 ip4_address_t rloc4;
14246 ip6_address_t rloc6;
14247 vl_api_remote_locator_t *rlocs = 0, rloc, *curr_rloc = 0;
14250 memset (&rloc, 0, sizeof (rloc));
14252 /* Parse args required to build the message */
14253 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14255 if (unformat (input, "del-all"))
14259 else if (unformat (input, "del"))
14263 else if (unformat (input, "add"))
14267 else if (unformat (input, "eid %U", unformat_lisp_eid_vat, eid))
14271 else if (unformat (input, "seid %U", unformat_lisp_eid_vat, seid))
14275 else if (unformat (input, "vni %d", &vni))
14279 else if (unformat (input, "p %d w %d", &p, &w))
14283 errmsg ("No RLOC configured for setting priority/weight!");
14286 curr_rloc->priority = p;
14287 curr_rloc->weight = w;
14289 else if (unformat (input, "rloc %U", unformat_ip4_address, &rloc4))
14292 clib_memcpy (&rloc.addr, &rloc4, sizeof (rloc4));
14293 vec_add1 (rlocs, rloc);
14294 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14296 else if (unformat (input, "rloc %U", unformat_ip6_address, &rloc6))
14299 clib_memcpy (&rloc.addr, &rloc6, sizeof (rloc6));
14300 vec_add1 (rlocs, rloc);
14301 curr_rloc = &rlocs[vec_len (rlocs) - 1];
14303 else if (unformat (input, "action %U",
14304 unformat_negative_mapping_action, &action))
14310 clib_warning ("parse error '%U'", format_unformat_error, input);
14317 errmsg ("missing params!");
14321 if (is_add && (~0 == action) && 0 == vec_len (rlocs))
14323 errmsg ("no action set for negative map-reply!");
14327 data_len = vec_len (rlocs) * sizeof (vl_api_remote_locator_t);
14329 M2 (ONE_ADD_DEL_REMOTE_MAPPING, mp, data_len);
14330 mp->is_add = is_add;
14331 mp->vni = htonl (vni);
14332 mp->action = (u8) action;
14333 mp->is_src_dst = seid_set;
14334 mp->eid_len = eid->len;
14335 mp->seid_len = seid->len;
14336 mp->del_all = del_all;
14337 mp->eid_type = eid->type;
14338 lisp_eid_put_vat (mp->eid, eid->addr, eid->type);
14339 lisp_eid_put_vat (mp->seid, seid->addr, seid->type);
14341 mp->rloc_num = clib_host_to_net_u32 (vec_len (rlocs));
14342 clib_memcpy (mp->rlocs, rlocs, data_len);
14348 /* Wait for a reply... */
14353 #define api_lisp_add_del_remote_mapping api_one_add_del_remote_mapping
14356 * Add/del ONE adjacency. Saves mapping in ONE control plane and updates
14357 * forwarding entries in data-plane accordingly.
14359 * @param vam vpp API test context
14360 * @return return code
14363 api_one_add_del_adjacency (vat_main_t * vam)
14365 unformat_input_t *input = vam->input;
14366 vl_api_one_add_del_adjacency_t *mp;
14368 ip4_address_t leid4, reid4;
14369 ip6_address_t leid6, reid6;
14370 u8 reid_mac[6] = { 0 };
14371 u8 leid_mac[6] = { 0 };
14372 u8 reid_type, leid_type;
14373 u32 leid_len = 0, reid_len = 0, len;
14377 leid_type = reid_type = (u8) ~ 0;
14379 /* Parse args required to build the message */
14380 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14382 if (unformat (input, "del"))
14386 else if (unformat (input, "add"))
14390 else if (unformat (input, "reid %U/%d", unformat_ip4_address,
14393 reid_type = 0; /* ipv4 */
14396 else if (unformat (input, "reid %U/%d", unformat_ip6_address,
14399 reid_type = 1; /* ipv6 */
14402 else if (unformat (input, "reid %U", unformat_ethernet_address,
14405 reid_type = 2; /* mac */
14407 else if (unformat (input, "leid %U/%d", unformat_ip4_address,
14410 leid_type = 0; /* ipv4 */
14413 else if (unformat (input, "leid %U/%d", unformat_ip6_address,
14416 leid_type = 1; /* ipv6 */
14419 else if (unformat (input, "leid %U", unformat_ethernet_address,
14422 leid_type = 2; /* mac */
14424 else if (unformat (input, "vni %d", &vni))
14430 errmsg ("parse error '%U'", format_unformat_error, input);
14435 if ((u8) ~ 0 == reid_type)
14437 errmsg ("missing params!");
14441 if (leid_type != reid_type)
14443 errmsg ("remote and local EIDs are of different types!");
14447 M (ONE_ADD_DEL_ADJACENCY, mp);
14448 mp->is_add = is_add;
14449 mp->vni = htonl (vni);
14450 mp->leid_len = leid_len;
14451 mp->reid_len = reid_len;
14452 mp->eid_type = reid_type;
14454 switch (mp->eid_type)
14457 clib_memcpy (mp->leid, &leid4, sizeof (leid4));
14458 clib_memcpy (mp->reid, &reid4, sizeof (reid4));
14461 clib_memcpy (mp->leid, &leid6, sizeof (leid6));
14462 clib_memcpy (mp->reid, &reid6, sizeof (reid6));
14465 clib_memcpy (mp->leid, leid_mac, 6);
14466 clib_memcpy (mp->reid, reid_mac, 6);
14469 errmsg ("unknown EID type %d!", mp->eid_type);
14476 /* Wait for a reply... */
14481 #define api_lisp_add_del_adjacency api_one_add_del_adjacency
14484 unformat_gpe_encap_mode (unformat_input_t * input, va_list * args)
14486 u32 *mode = va_arg (*args, u32 *);
14488 if (unformat (input, "lisp"))
14490 else if (unformat (input, "vxlan"))
14499 api_gpe_get_encap_mode (vat_main_t * vam)
14501 vl_api_gpe_get_encap_mode_t *mp;
14504 /* Construct the API message */
14505 M (GPE_GET_ENCAP_MODE, mp);
14510 /* Wait for a reply... */
14516 api_gpe_set_encap_mode (vat_main_t * vam)
14518 unformat_input_t *input = vam->input;
14519 vl_api_gpe_set_encap_mode_t *mp;
14523 /* Parse args required to build the message */
14524 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14526 if (unformat (input, "%U", unformat_gpe_encap_mode, &mode))
14532 /* Construct the API message */
14533 M (GPE_SET_ENCAP_MODE, mp);
14540 /* Wait for a reply... */
14546 api_lisp_gpe_add_del_iface (vat_main_t * vam)
14548 unformat_input_t *input = vam->input;
14549 vl_api_gpe_add_del_iface_t *mp;
14550 u8 action_set = 0, is_add = 1, is_l2 = 0, dp_table_set = 0, vni_set = 0;
14551 u32 dp_table = 0, vni = 0;
14554 /* Parse args required to build the message */
14555 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14557 if (unformat (input, "up"))
14562 else if (unformat (input, "down"))
14567 else if (unformat (input, "table_id %d", &dp_table))
14571 else if (unformat (input, "bd_id %d", &dp_table))
14576 else if (unformat (input, "vni %d", &vni))
14584 if (action_set == 0)
14586 errmsg ("Action not set");
14589 if (dp_table_set == 0 || vni_set == 0)
14591 errmsg ("vni and dp_table must be set");
14595 /* Construct the API message */
14596 M (GPE_ADD_DEL_IFACE, mp);
14598 mp->is_add = is_add;
14599 mp->dp_table = dp_table;
14606 /* Wait for a reply... */
14612 * Add/del map request itr rlocs from ONE control plane and updates
14614 * @param vam vpp API test context
14615 * @return return code
14618 api_one_add_del_map_request_itr_rlocs (vat_main_t * vam)
14620 unformat_input_t *input = vam->input;
14621 vl_api_one_add_del_map_request_itr_rlocs_t *mp;
14622 u8 *locator_set_name = 0;
14623 u8 locator_set_name_set = 0;
14627 /* Parse args required to build the message */
14628 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14630 if (unformat (input, "del"))
14634 else if (unformat (input, "%_%v%_", &locator_set_name))
14636 locator_set_name_set = 1;
14640 clib_warning ("parse error '%U'", format_unformat_error, input);
14645 if (is_add && !locator_set_name_set)
14647 errmsg ("itr-rloc is not set!");
14651 if (is_add && vec_len (locator_set_name) > 64)
14653 errmsg ("itr-rloc locator-set name too long");
14654 vec_free (locator_set_name);
14658 M (ONE_ADD_DEL_MAP_REQUEST_ITR_RLOCS, mp);
14659 mp->is_add = is_add;
14662 clib_memcpy (mp->locator_set_name, locator_set_name,
14663 vec_len (locator_set_name));
14667 memset (mp->locator_set_name, 0, sizeof (mp->locator_set_name));
14669 vec_free (locator_set_name);
14674 /* Wait for a reply... */
14679 #define api_lisp_add_del_map_request_itr_rlocs api_one_add_del_map_request_itr_rlocs
14682 api_one_locator_dump (vat_main_t * vam)
14684 unformat_input_t *input = vam->input;
14685 vl_api_one_locator_dump_t *mp;
14686 vl_api_control_ping_t *mp_ping;
14687 u8 is_index_set = 0, is_name_set = 0;
14692 /* Parse args required to build the message */
14693 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14695 if (unformat (input, "ls_name %_%v%_", &ls_name))
14699 else if (unformat (input, "ls_index %d", &ls_index))
14705 errmsg ("parse error '%U'", format_unformat_error, input);
14710 if (!is_index_set && !is_name_set)
14712 errmsg ("error: expected one of index or name!");
14716 if (is_index_set && is_name_set)
14718 errmsg ("error: only one param expected!");
14722 if (vec_len (ls_name) > 62)
14724 errmsg ("error: locator set name too long!");
14728 if (!vam->json_output)
14730 print (vam->ofp, "%=16s%=16s%=16s", "locator", "priority", "weight");
14733 M (ONE_LOCATOR_DUMP, mp);
14734 mp->is_index_set = is_index_set;
14737 mp->ls_index = clib_host_to_net_u32 (ls_index);
14740 vec_add1 (ls_name, 0);
14741 strncpy ((char *) mp->ls_name, (char *) ls_name,
14742 sizeof (mp->ls_name) - 1);
14748 /* Use a control ping for synchronization */
14749 M (CONTROL_PING, mp_ping);
14752 /* Wait for a reply... */
14757 #define api_lisp_locator_dump api_one_locator_dump
14760 api_one_locator_set_dump (vat_main_t * vam)
14762 vl_api_one_locator_set_dump_t *mp;
14763 vl_api_control_ping_t *mp_ping;
14764 unformat_input_t *input = vam->input;
14768 /* Parse args required to build the message */
14769 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14771 if (unformat (input, "local"))
14775 else if (unformat (input, "remote"))
14781 errmsg ("parse error '%U'", format_unformat_error, input);
14786 if (!vam->json_output)
14788 print (vam->ofp, "%=10s%=15s", "ls_index", "ls_name");
14791 M (ONE_LOCATOR_SET_DUMP, mp);
14793 mp->filter = filter;
14798 /* Use a control ping for synchronization */
14799 M (CONTROL_PING, mp_ping);
14802 /* Wait for a reply... */
14807 #define api_lisp_locator_set_dump api_one_locator_set_dump
14810 api_one_eid_table_map_dump (vat_main_t * vam)
14814 unformat_input_t *input = vam->input;
14815 vl_api_one_eid_table_map_dump_t *mp;
14816 vl_api_control_ping_t *mp_ping;
14819 /* Parse args required to build the message */
14820 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
14822 if (unformat (input, "l2"))
14827 else if (unformat (input, "l3"))
14834 errmsg ("parse error '%U'", format_unformat_error, input);
14841 errmsg ("expected one of 'l2' or 'l3' parameter!");
14845 if (!vam->json_output)
14847 print (vam->ofp, "%=10s%=10s", "VNI", is_l2 ? "BD" : "VRF");
14850 M (ONE_EID_TABLE_MAP_DUMP, mp);
14856 /* Use a control ping for synchronization */
14857 M (CONTROL_PING, mp_ping);
14860 /* Wait for a reply... */
14865 #define api_lisp_eid_table_map_dump api_one_eid_table_map_dump
14868 api_one_eid_table_vni_dump (vat_main_t * vam)
14870 vl_api_one_eid_table_vni_dump_t *mp;
14871 vl_api_control_ping_t *mp_ping;
14874 if (!vam->json_output)
14876 print (vam->ofp, "VNI");
14879 M (ONE_EID_TABLE_VNI_DUMP, mp);
14884 /* Use a control ping for synchronization */
14885 M (CONTROL_PING, mp_ping);
14888 /* Wait for a reply... */
14893 #define api_lisp_eid_table_vni_dump api_one_eid_table_vni_dump
14896 api_one_eid_table_dump (vat_main_t * vam)
14898 unformat_input_t *i = vam->input;
14899 vl_api_one_eid_table_dump_t *mp;
14900 vl_api_control_ping_t *mp_ping;
14901 struct in_addr ip4;
14902 struct in6_addr ip6;
14904 u8 eid_type = ~0, eid_set = 0;
14905 u32 prefix_length = ~0, t, vni = 0;
14909 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
14911 if (unformat (i, "eid %U/%d", unformat_ip4_address, &ip4, &t))
14917 else if (unformat (i, "eid %U/%d", unformat_ip6_address, &ip6, &t))
14923 else if (unformat (i, "eid %U", unformat_ethernet_address, mac))
14928 else if (unformat (i, "vni %d", &t))
14932 else if (unformat (i, "local"))
14936 else if (unformat (i, "remote"))
14942 errmsg ("parse error '%U'", format_unformat_error, i);
14947 if (!vam->json_output)
14949 print (vam->ofp, "%-35s%-20s%-30s%-20s%-20s%-10s%-20s", "EID",
14950 "type", "ls_index", "ttl", "authoritative", "key_id", "key");
14953 M (ONE_EID_TABLE_DUMP, mp);
14955 mp->filter = filter;
14959 mp->vni = htonl (vni);
14960 mp->eid_type = eid_type;
14964 mp->prefix_length = prefix_length;
14965 clib_memcpy (mp->eid, &ip4, sizeof (ip4));
14968 mp->prefix_length = prefix_length;
14969 clib_memcpy (mp->eid, &ip6, sizeof (ip6));
14972 clib_memcpy (mp->eid, mac, sizeof (mac));
14975 errmsg ("unknown EID type %d!", eid_type);
14983 /* Use a control ping for synchronization */
14984 M (CONTROL_PING, mp_ping);
14987 /* Wait for a reply... */
14992 #define api_lisp_eid_table_dump api_one_eid_table_dump
14995 api_lisp_gpe_fwd_entries_get (vat_main_t * vam)
14997 unformat_input_t *i = vam->input;
14998 vl_api_gpe_fwd_entries_get_t *mp;
15003 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15005 if (unformat (i, "vni %d", &vni))
15011 errmsg ("parse error '%U'", format_unformat_error, i);
15018 errmsg ("vni not set!");
15022 if (!vam->json_output)
15024 print (vam->ofp, "%10s %10s %s %40s", "fwd_index", "dp_table",
15028 M (GPE_FWD_ENTRIES_GET, mp);
15029 mp->vni = clib_host_to_net_u32 (vni);
15034 /* Wait for a reply... */
15039 #define vl_api_gpe_fwd_entries_get_reply_t_endian vl_noop_handler
15040 #define vl_api_gpe_fwd_entries_get_reply_t_print vl_noop_handler
15041 #define vl_api_gpe_fwd_entry_path_details_t_endian vl_noop_handler
15042 #define vl_api_gpe_fwd_entry_path_details_t_print vl_noop_handler
15045 api_one_adjacencies_get (vat_main_t * vam)
15047 unformat_input_t *i = vam->input;
15048 vl_api_one_adjacencies_get_t *mp;
15053 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15055 if (unformat (i, "vni %d", &vni))
15061 errmsg ("parse error '%U'", format_unformat_error, i);
15068 errmsg ("vni not set!");
15072 if (!vam->json_output)
15074 print (vam->ofp, "%s %40s", "leid", "reid");
15077 M (ONE_ADJACENCIES_GET, mp);
15078 mp->vni = clib_host_to_net_u32 (vni);
15083 /* Wait for a reply... */
15088 #define api_lisp_adjacencies_get api_one_adjacencies_get
15091 api_one_map_server_dump (vat_main_t * vam)
15093 vl_api_one_map_server_dump_t *mp;
15094 vl_api_control_ping_t *mp_ping;
15097 if (!vam->json_output)
15099 print (vam->ofp, "%=20s", "Map server");
15102 M (ONE_MAP_SERVER_DUMP, mp);
15106 /* Use a control ping for synchronization */
15107 M (CONTROL_PING, mp_ping);
15110 /* Wait for a reply... */
15115 #define api_lisp_map_server_dump api_one_map_server_dump
15118 api_one_map_resolver_dump (vat_main_t * vam)
15120 vl_api_one_map_resolver_dump_t *mp;
15121 vl_api_control_ping_t *mp_ping;
15124 if (!vam->json_output)
15126 print (vam->ofp, "%=20s", "Map resolver");
15129 M (ONE_MAP_RESOLVER_DUMP, mp);
15133 /* Use a control ping for synchronization */
15134 M (CONTROL_PING, mp_ping);
15137 /* Wait for a reply... */
15142 #define api_lisp_map_resolver_dump api_one_map_resolver_dump
15145 api_show_one_status (vat_main_t * vam)
15147 vl_api_show_one_status_t *mp;
15150 if (!vam->json_output)
15152 print (vam->ofp, "%-20s%-16s", "ONE status", "locator-set");
15155 M (SHOW_ONE_STATUS, mp);
15158 /* Wait for a reply... */
15163 #define api_show_lisp_status api_show_one_status
15166 api_lisp_gpe_fwd_entry_path_dump (vat_main_t * vam)
15168 vl_api_gpe_fwd_entry_path_dump_t *mp;
15169 vl_api_control_ping_t *mp_ping;
15170 unformat_input_t *i = vam->input;
15171 u32 fwd_entry_index = ~0;
15174 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15176 if (unformat (i, "index %d", &fwd_entry_index))
15182 if (~0 == fwd_entry_index)
15184 errmsg ("no index specified!");
15188 if (!vam->json_output)
15190 print (vam->ofp, "first line");
15193 M (GPE_FWD_ENTRY_PATH_DUMP, mp);
15197 /* Use a control ping for synchronization */
15198 M (CONTROL_PING, mp_ping);
15201 /* Wait for a reply... */
15207 api_one_get_map_request_itr_rlocs (vat_main_t * vam)
15209 vl_api_one_get_map_request_itr_rlocs_t *mp;
15212 if (!vam->json_output)
15214 print (vam->ofp, "%=20s", "itr-rlocs:");
15217 M (ONE_GET_MAP_REQUEST_ITR_RLOCS, mp);
15220 /* Wait for a reply... */
15225 #define api_lisp_get_map_request_itr_rlocs api_one_get_map_request_itr_rlocs
15228 api_af_packet_create (vat_main_t * vam)
15230 unformat_input_t *i = vam->input;
15231 vl_api_af_packet_create_t *mp;
15232 u8 *host_if_name = 0;
15234 u8 random_hw_addr = 1;
15237 memset (hw_addr, 0, sizeof (hw_addr));
15239 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15241 if (unformat (i, "name %s", &host_if_name))
15242 vec_add1 (host_if_name, 0);
15243 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15244 random_hw_addr = 0;
15249 if (!vec_len (host_if_name))
15251 errmsg ("host-interface name must be specified");
15255 if (vec_len (host_if_name) > 64)
15257 errmsg ("host-interface name too long");
15261 M (AF_PACKET_CREATE, mp);
15263 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15264 clib_memcpy (mp->hw_addr, hw_addr, 6);
15265 mp->use_random_hw_addr = random_hw_addr;
15266 vec_free (host_if_name);
15274 fprintf (vam->ofp ? vam->ofp : stderr,
15275 " new sw_if_index = %d\n", vam->sw_if_index);
15282 api_af_packet_delete (vat_main_t * vam)
15284 unformat_input_t *i = vam->input;
15285 vl_api_af_packet_delete_t *mp;
15286 u8 *host_if_name = 0;
15289 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15291 if (unformat (i, "name %s", &host_if_name))
15292 vec_add1 (host_if_name, 0);
15297 if (!vec_len (host_if_name))
15299 errmsg ("host-interface name must be specified");
15303 if (vec_len (host_if_name) > 64)
15305 errmsg ("host-interface name too long");
15309 M (AF_PACKET_DELETE, mp);
15311 clib_memcpy (mp->host_if_name, host_if_name, vec_len (host_if_name));
15312 vec_free (host_if_name);
15320 api_policer_add_del (vat_main_t * vam)
15322 unformat_input_t *i = vam->input;
15323 vl_api_policer_add_del_t *mp;
15333 u8 color_aware = 0;
15334 sse2_qos_pol_action_params_st conform_action, exceed_action, violate_action;
15337 conform_action.action_type = SSE2_QOS_ACTION_TRANSMIT;
15338 conform_action.dscp = 0;
15339 exceed_action.action_type = SSE2_QOS_ACTION_MARK_AND_TRANSMIT;
15340 exceed_action.dscp = 0;
15341 violate_action.action_type = SSE2_QOS_ACTION_DROP;
15342 violate_action.dscp = 0;
15344 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15346 if (unformat (i, "del"))
15348 else if (unformat (i, "name %s", &name))
15349 vec_add1 (name, 0);
15350 else if (unformat (i, "cir %u", &cir))
15352 else if (unformat (i, "eir %u", &eir))
15354 else if (unformat (i, "cb %u", &cb))
15356 else if (unformat (i, "eb %u", &eb))
15358 else if (unformat (i, "rate_type %U", unformat_policer_rate_type,
15361 else if (unformat (i, "round_type %U", unformat_policer_round_type,
15364 else if (unformat (i, "type %U", unformat_policer_type, &type))
15366 else if (unformat (i, "conform_action %U", unformat_policer_action_type,
15369 else if (unformat (i, "exceed_action %U", unformat_policer_action_type,
15372 else if (unformat (i, "violate_action %U", unformat_policer_action_type,
15375 else if (unformat (i, "color-aware"))
15381 if (!vec_len (name))
15383 errmsg ("policer name must be specified");
15387 if (vec_len (name) > 64)
15389 errmsg ("policer name too long");
15393 M (POLICER_ADD_DEL, mp);
15395 clib_memcpy (mp->name, name, vec_len (name));
15397 mp->is_add = is_add;
15402 mp->rate_type = rate_type;
15403 mp->round_type = round_type;
15405 mp->conform_action_type = conform_action.action_type;
15406 mp->conform_dscp = conform_action.dscp;
15407 mp->exceed_action_type = exceed_action.action_type;
15408 mp->exceed_dscp = exceed_action.dscp;
15409 mp->violate_action_type = violate_action.action_type;
15410 mp->violate_dscp = violate_action.dscp;
15411 mp->color_aware = color_aware;
15419 api_policer_dump (vat_main_t * vam)
15421 unformat_input_t *i = vam->input;
15422 vl_api_policer_dump_t *mp;
15423 vl_api_control_ping_t *mp_ping;
15424 u8 *match_name = 0;
15425 u8 match_name_valid = 0;
15428 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15430 if (unformat (i, "name %s", &match_name))
15432 vec_add1 (match_name, 0);
15433 match_name_valid = 1;
15439 M (POLICER_DUMP, mp);
15440 mp->match_name_valid = match_name_valid;
15441 clib_memcpy (mp->match_name, match_name, vec_len (match_name));
15442 vec_free (match_name);
15446 /* Use a control ping for synchronization */
15447 M (CONTROL_PING, mp_ping);
15450 /* Wait for a reply... */
15456 api_policer_classify_set_interface (vat_main_t * vam)
15458 unformat_input_t *i = vam->input;
15459 vl_api_policer_classify_set_interface_t *mp;
15461 int sw_if_index_set;
15462 u32 ip4_table_index = ~0;
15463 u32 ip6_table_index = ~0;
15464 u32 l2_table_index = ~0;
15468 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15470 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
15471 sw_if_index_set = 1;
15472 else if (unformat (i, "sw_if_index %d", &sw_if_index))
15473 sw_if_index_set = 1;
15474 else if (unformat (i, "del"))
15476 else if (unformat (i, "ip4-table %d", &ip4_table_index))
15478 else if (unformat (i, "ip6-table %d", &ip6_table_index))
15480 else if (unformat (i, "l2-table %d", &l2_table_index))
15484 clib_warning ("parse error '%U'", format_unformat_error, i);
15489 if (sw_if_index_set == 0)
15491 errmsg ("missing interface name or sw_if_index");
15495 M (POLICER_CLASSIFY_SET_INTERFACE, mp);
15497 mp->sw_if_index = ntohl (sw_if_index);
15498 mp->ip4_table_index = ntohl (ip4_table_index);
15499 mp->ip6_table_index = ntohl (ip6_table_index);
15500 mp->l2_table_index = ntohl (l2_table_index);
15501 mp->is_add = is_add;
15509 api_policer_classify_dump (vat_main_t * vam)
15511 unformat_input_t *i = vam->input;
15512 vl_api_policer_classify_dump_t *mp;
15513 vl_api_control_ping_t *mp_ping;
15514 u8 type = POLICER_CLASSIFY_N_TABLES;
15517 if (unformat (i, "type %U", unformat_policer_classify_table_type, &type))
15521 errmsg ("classify table type must be specified");
15525 if (!vam->json_output)
15527 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
15530 M (POLICER_CLASSIFY_DUMP, mp);
15535 /* Use a control ping for synchronization */
15536 M (CONTROL_PING, mp_ping);
15539 /* Wait for a reply... */
15545 api_netmap_create (vat_main_t * vam)
15547 unformat_input_t *i = vam->input;
15548 vl_api_netmap_create_t *mp;
15551 u8 random_hw_addr = 1;
15556 memset (hw_addr, 0, sizeof (hw_addr));
15558 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15560 if (unformat (i, "name %s", &if_name))
15561 vec_add1 (if_name, 0);
15562 else if (unformat (i, "hw_addr %U", unformat_ethernet_address, hw_addr))
15563 random_hw_addr = 0;
15564 else if (unformat (i, "pipe"))
15566 else if (unformat (i, "master"))
15568 else if (unformat (i, "slave"))
15574 if (!vec_len (if_name))
15576 errmsg ("interface name must be specified");
15580 if (vec_len (if_name) > 64)
15582 errmsg ("interface name too long");
15586 M (NETMAP_CREATE, mp);
15588 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15589 clib_memcpy (mp->hw_addr, hw_addr, 6);
15590 mp->use_random_hw_addr = random_hw_addr;
15591 mp->is_pipe = is_pipe;
15592 mp->is_master = is_master;
15593 vec_free (if_name);
15601 api_netmap_delete (vat_main_t * vam)
15603 unformat_input_t *i = vam->input;
15604 vl_api_netmap_delete_t *mp;
15608 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15610 if (unformat (i, "name %s", &if_name))
15611 vec_add1 (if_name, 0);
15616 if (!vec_len (if_name))
15618 errmsg ("interface name must be specified");
15622 if (vec_len (if_name) > 64)
15624 errmsg ("interface name too long");
15628 M (NETMAP_DELETE, mp);
15630 clib_memcpy (mp->netmap_if_name, if_name, vec_len (if_name));
15631 vec_free (if_name);
15638 static void vl_api_mpls_tunnel_details_t_handler
15639 (vl_api_mpls_tunnel_details_t * mp)
15641 vat_main_t *vam = &vat_main;
15642 i32 len = mp->mt_next_hop_n_labels;
15645 print (vam->ofp, "[%d]: via %U %d labels ",
15647 format_ip4_address, mp->mt_next_hop,
15648 ntohl (mp->mt_next_hop_sw_if_index));
15649 for (i = 0; i < len; i++)
15651 print (vam->ofp, "%u ", ntohl (mp->mt_next_hop_out_labels[i]));
15653 print (vam->ofp, "");
15656 static void vl_api_mpls_tunnel_details_t_handler_json
15657 (vl_api_mpls_tunnel_details_t * mp)
15659 vat_main_t *vam = &vat_main;
15660 vat_json_node_t *node = NULL;
15661 struct in_addr ip4;
15663 i32 len = mp->mt_next_hop_n_labels;
15665 if (VAT_JSON_ARRAY != vam->json_tree.type)
15667 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15668 vat_json_init_array (&vam->json_tree);
15670 node = vat_json_array_add (&vam->json_tree);
15672 vat_json_init_object (node);
15673 vat_json_object_add_uint (node, "tunnel_index", ntohl (mp->tunnel_index));
15674 clib_memcpy (&ip4, &(mp->mt_next_hop), sizeof (ip4));
15675 vat_json_object_add_ip4 (node, "next_hop", ip4);
15676 vat_json_object_add_uint (node, "next_hop_sw_if_index",
15677 ntohl (mp->mt_next_hop_sw_if_index));
15678 vat_json_object_add_uint (node, "l2_only", ntohl (mp->mt_l2_only));
15679 vat_json_object_add_uint (node, "label_count", len);
15680 for (i = 0; i < len; i++)
15682 vat_json_object_add_uint (node, "label",
15683 ntohl (mp->mt_next_hop_out_labels[i]));
15688 api_mpls_tunnel_dump (vat_main_t * vam)
15690 vl_api_mpls_tunnel_dump_t *mp;
15691 vl_api_control_ping_t *mp_ping;
15695 /* Parse args required to build the message */
15696 while (unformat_check_input (vam->input) != UNFORMAT_END_OF_INPUT)
15698 if (!unformat (vam->input, "tunnel_index %d", &index))
15705 print (vam->ofp, " tunnel_index %d", index);
15707 M (MPLS_TUNNEL_DUMP, mp);
15708 mp->tunnel_index = htonl (index);
15711 /* Use a control ping for synchronization */
15712 M (CONTROL_PING, mp_ping);
15719 #define vl_api_mpls_fib_details_t_endian vl_noop_handler
15720 #define vl_api_mpls_fib_details_t_print vl_noop_handler
15723 vl_api_mpls_fib_details_t_handler (vl_api_mpls_fib_details_t * mp)
15725 vat_main_t *vam = &vat_main;
15726 int count = ntohl (mp->count);
15727 vl_api_fib_path2_t *fp;
15731 "table-id %d, label %u, ess_bit %u",
15732 ntohl (mp->table_id), ntohl (mp->label), mp->eos_bit);
15734 for (i = 0; i < count; i++)
15736 if (fp->afi == IP46_TYPE_IP6)
15738 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15739 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15740 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15741 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15742 format_ip6_address, fp->next_hop);
15743 else if (fp->afi == IP46_TYPE_IP4)
15745 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15746 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15747 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15748 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15749 format_ip4_address, fp->next_hop);
15754 static void vl_api_mpls_fib_details_t_handler_json
15755 (vl_api_mpls_fib_details_t * mp)
15757 vat_main_t *vam = &vat_main;
15758 int count = ntohl (mp->count);
15759 vat_json_node_t *node = NULL;
15760 struct in_addr ip4;
15761 struct in6_addr ip6;
15762 vl_api_fib_path2_t *fp;
15765 if (VAT_JSON_ARRAY != vam->json_tree.type)
15767 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15768 vat_json_init_array (&vam->json_tree);
15770 node = vat_json_array_add (&vam->json_tree);
15772 vat_json_init_object (node);
15773 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15774 vat_json_object_add_uint (node, "s_bit", mp->eos_bit);
15775 vat_json_object_add_uint (node, "label", ntohl (mp->label));
15776 vat_json_object_add_uint (node, "path_count", count);
15778 for (i = 0; i < count; i++)
15780 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15781 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15782 vat_json_object_add_uint (node, "is_local", fp->is_local);
15783 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15784 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15785 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15786 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15787 if (fp->afi == IP46_TYPE_IP4)
15789 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15790 vat_json_object_add_ip4 (node, "next_hop", ip4);
15792 else if (fp->afi == IP46_TYPE_IP6)
15794 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15795 vat_json_object_add_ip6 (node, "next_hop", ip6);
15801 api_mpls_fib_dump (vat_main_t * vam)
15803 vl_api_mpls_fib_dump_t *mp;
15804 vl_api_control_ping_t *mp_ping;
15807 M (MPLS_FIB_DUMP, mp);
15810 /* Use a control ping for synchronization */
15811 M (CONTROL_PING, mp_ping);
15818 #define vl_api_ip_fib_details_t_endian vl_noop_handler
15819 #define vl_api_ip_fib_details_t_print vl_noop_handler
15822 vl_api_ip_fib_details_t_handler (vl_api_ip_fib_details_t * mp)
15824 vat_main_t *vam = &vat_main;
15825 int count = ntohl (mp->count);
15826 vl_api_fib_path_t *fp;
15830 "table-id %d, prefix %U/%d",
15831 ntohl (mp->table_id), format_ip4_address, mp->address,
15832 mp->address_length);
15834 for (i = 0; i < count; i++)
15836 if (fp->afi == IP46_TYPE_IP6)
15838 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15839 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15840 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15841 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15842 format_ip6_address, fp->next_hop);
15843 else if (fp->afi == IP46_TYPE_IP4)
15845 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
15846 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
15847 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
15848 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
15849 format_ip4_address, fp->next_hop);
15854 static void vl_api_ip_fib_details_t_handler_json
15855 (vl_api_ip_fib_details_t * mp)
15857 vat_main_t *vam = &vat_main;
15858 int count = ntohl (mp->count);
15859 vat_json_node_t *node = NULL;
15860 struct in_addr ip4;
15861 struct in6_addr ip6;
15862 vl_api_fib_path_t *fp;
15865 if (VAT_JSON_ARRAY != vam->json_tree.type)
15867 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15868 vat_json_init_array (&vam->json_tree);
15870 node = vat_json_array_add (&vam->json_tree);
15872 vat_json_init_object (node);
15873 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
15874 clib_memcpy (&ip4, &mp->address, sizeof (ip4));
15875 vat_json_object_add_ip4 (node, "prefix", ip4);
15876 vat_json_object_add_uint (node, "mask_length", mp->address_length);
15877 vat_json_object_add_uint (node, "path_count", count);
15879 for (i = 0; i < count; i++)
15881 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
15882 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
15883 vat_json_object_add_uint (node, "is_local", fp->is_local);
15884 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
15885 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
15886 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
15887 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
15888 if (fp->afi == IP46_TYPE_IP4)
15890 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
15891 vat_json_object_add_ip4 (node, "next_hop", ip4);
15893 else if (fp->afi == IP46_TYPE_IP6)
15895 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
15896 vat_json_object_add_ip6 (node, "next_hop", ip6);
15902 api_ip_fib_dump (vat_main_t * vam)
15904 vl_api_ip_fib_dump_t *mp;
15905 vl_api_control_ping_t *mp_ping;
15908 M (IP_FIB_DUMP, mp);
15911 /* Use a control ping for synchronization */
15912 M (CONTROL_PING, mp_ping);
15920 api_ip_mfib_dump (vat_main_t * vam)
15922 vl_api_ip_mfib_dump_t *mp;
15923 vl_api_control_ping_t *mp_ping;
15926 M (IP_MFIB_DUMP, mp);
15929 /* Use a control ping for synchronization */
15930 M (CONTROL_PING, mp_ping);
15937 static void vl_api_ip_neighbor_details_t_handler
15938 (vl_api_ip_neighbor_details_t * mp)
15940 vat_main_t *vam = &vat_main;
15942 print (vam->ofp, "%c %U %U",
15943 (mp->is_static) ? 'S' : 'D',
15944 format_ethernet_address, &mp->mac_address,
15945 (mp->is_ipv6) ? format_ip6_address : format_ip4_address,
15949 static void vl_api_ip_neighbor_details_t_handler_json
15950 (vl_api_ip_neighbor_details_t * mp)
15953 vat_main_t *vam = &vat_main;
15954 vat_json_node_t *node;
15955 struct in_addr ip4;
15956 struct in6_addr ip6;
15958 if (VAT_JSON_ARRAY != vam->json_tree.type)
15960 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
15961 vat_json_init_array (&vam->json_tree);
15963 node = vat_json_array_add (&vam->json_tree);
15965 vat_json_init_object (node);
15966 vat_json_object_add_string_copy (node, "flag",
15967 (mp->is_static) ? (u8 *) "static" : (u8 *)
15970 vat_json_object_add_string_copy (node, "link_layer",
15971 format (0, "%U", format_ethernet_address,
15972 &mp->mac_address));
15976 clib_memcpy (&ip6, &mp->ip_address, sizeof (ip6));
15977 vat_json_object_add_ip6 (node, "ip_address", ip6);
15981 clib_memcpy (&ip4, &mp->ip_address, sizeof (ip4));
15982 vat_json_object_add_ip4 (node, "ip_address", ip4);
15987 api_ip_neighbor_dump (vat_main_t * vam)
15989 unformat_input_t *i = vam->input;
15990 vl_api_ip_neighbor_dump_t *mp;
15991 vl_api_control_ping_t *mp_ping;
15993 u32 sw_if_index = ~0;
15996 /* Parse args required to build the message */
15997 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
15999 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16001 else if (unformat (i, "sw_if_index %d", &sw_if_index))
16003 else if (unformat (i, "ip6"))
16009 if (sw_if_index == ~0)
16011 errmsg ("missing interface name or sw_if_index");
16015 M (IP_NEIGHBOR_DUMP, mp);
16016 mp->is_ipv6 = (u8) is_ipv6;
16017 mp->sw_if_index = ntohl (sw_if_index);
16020 /* Use a control ping for synchronization */
16021 M (CONTROL_PING, mp_ping);
16028 #define vl_api_ip6_fib_details_t_endian vl_noop_handler
16029 #define vl_api_ip6_fib_details_t_print vl_noop_handler
16032 vl_api_ip6_fib_details_t_handler (vl_api_ip6_fib_details_t * mp)
16034 vat_main_t *vam = &vat_main;
16035 int count = ntohl (mp->count);
16036 vl_api_fib_path_t *fp;
16040 "table-id %d, prefix %U/%d",
16041 ntohl (mp->table_id), format_ip6_address, mp->address,
16042 mp->address_length);
16044 for (i = 0; i < count; i++)
16046 if (fp->afi == IP46_TYPE_IP6)
16048 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16049 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16050 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16051 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16052 format_ip6_address, fp->next_hop);
16053 else if (fp->afi == IP46_TYPE_IP4)
16055 " weight %d, sw_if_index %d, is_local %d, is_drop %d, "
16056 "is_unreach %d, is_prohitbit %d, afi %d, next_hop %U",
16057 ntohl (fp->weight), ntohl (fp->sw_if_index), fp->is_local,
16058 fp->is_drop, fp->is_unreach, fp->is_prohibit, fp->afi,
16059 format_ip4_address, fp->next_hop);
16064 static void vl_api_ip6_fib_details_t_handler_json
16065 (vl_api_ip6_fib_details_t * mp)
16067 vat_main_t *vam = &vat_main;
16068 int count = ntohl (mp->count);
16069 vat_json_node_t *node = NULL;
16070 struct in_addr ip4;
16071 struct in6_addr ip6;
16072 vl_api_fib_path_t *fp;
16075 if (VAT_JSON_ARRAY != vam->json_tree.type)
16077 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16078 vat_json_init_array (&vam->json_tree);
16080 node = vat_json_array_add (&vam->json_tree);
16082 vat_json_init_object (node);
16083 vat_json_object_add_uint (node, "table", ntohl (mp->table_id));
16084 clib_memcpy (&ip6, &mp->address, sizeof (ip6));
16085 vat_json_object_add_ip6 (node, "prefix", ip6);
16086 vat_json_object_add_uint (node, "mask_length", mp->address_length);
16087 vat_json_object_add_uint (node, "path_count", count);
16089 for (i = 0; i < count; i++)
16091 vat_json_object_add_uint (node, "weight", ntohl (fp->weight));
16092 vat_json_object_add_uint (node, "sw_if_index", ntohl (fp->sw_if_index));
16093 vat_json_object_add_uint (node, "is_local", fp->is_local);
16094 vat_json_object_add_uint (node, "is_drop", fp->is_drop);
16095 vat_json_object_add_uint (node, "is_unreach", fp->is_unreach);
16096 vat_json_object_add_uint (node, "is_prohibit", fp->is_prohibit);
16097 vat_json_object_add_uint (node, "next_hop_afi", fp->afi);
16098 if (fp->afi == IP46_TYPE_IP4)
16100 clib_memcpy (&ip4, &fp->next_hop, sizeof (ip4));
16101 vat_json_object_add_ip4 (node, "next_hop", ip4);
16103 else if (fp->afi == IP46_TYPE_IP6)
16105 clib_memcpy (&ip6, &fp->next_hop, sizeof (ip6));
16106 vat_json_object_add_ip6 (node, "next_hop", ip6);
16112 api_ip6_fib_dump (vat_main_t * vam)
16114 vl_api_ip6_fib_dump_t *mp;
16115 vl_api_control_ping_t *mp_ping;
16118 M (IP6_FIB_DUMP, mp);
16121 /* Use a control ping for synchronization */
16122 M (CONTROL_PING, mp_ping);
16130 api_ip6_mfib_dump (vat_main_t * vam)
16132 vl_api_ip6_mfib_dump_t *mp;
16133 vl_api_control_ping_t *mp_ping;
16136 M (IP6_MFIB_DUMP, mp);
16139 /* Use a control ping for synchronization */
16140 M (CONTROL_PING, mp_ping);
16148 api_classify_table_ids (vat_main_t * vam)
16150 vl_api_classify_table_ids_t *mp;
16153 /* Construct the API message */
16154 M (CLASSIFY_TABLE_IDS, mp);
16163 api_classify_table_by_interface (vat_main_t * vam)
16165 unformat_input_t *input = vam->input;
16166 vl_api_classify_table_by_interface_t *mp;
16168 u32 sw_if_index = ~0;
16170 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16172 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16174 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16179 if (sw_if_index == ~0)
16181 errmsg ("missing interface name or sw_if_index");
16185 /* Construct the API message */
16186 M (CLASSIFY_TABLE_BY_INTERFACE, mp);
16188 mp->sw_if_index = ntohl (sw_if_index);
16196 api_classify_table_info (vat_main_t * vam)
16198 unformat_input_t *input = vam->input;
16199 vl_api_classify_table_info_t *mp;
16203 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16205 if (unformat (input, "table_id %d", &table_id))
16210 if (table_id == ~0)
16212 errmsg ("missing table id");
16216 /* Construct the API message */
16217 M (CLASSIFY_TABLE_INFO, mp);
16219 mp->table_id = ntohl (table_id);
16227 api_classify_session_dump (vat_main_t * vam)
16229 unformat_input_t *input = vam->input;
16230 vl_api_classify_session_dump_t *mp;
16231 vl_api_control_ping_t *mp_ping;
16235 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16237 if (unformat (input, "table_id %d", &table_id))
16242 if (table_id == ~0)
16244 errmsg ("missing table id");
16248 /* Construct the API message */
16249 M (CLASSIFY_SESSION_DUMP, mp);
16251 mp->table_id = ntohl (table_id);
16254 /* Use a control ping for synchronization */
16255 M (CONTROL_PING, mp_ping);
16263 vl_api_ipfix_exporter_details_t_handler (vl_api_ipfix_exporter_details_t * mp)
16265 vat_main_t *vam = &vat_main;
16267 print (vam->ofp, "collector_address %U, collector_port %d, "
16268 "src_address %U, vrf_id %d, path_mtu %u, "
16269 "template_interval %u, udp_checksum %d",
16270 format_ip4_address, mp->collector_address,
16271 ntohs (mp->collector_port),
16272 format_ip4_address, mp->src_address,
16273 ntohl (mp->vrf_id), ntohl (mp->path_mtu),
16274 ntohl (mp->template_interval), mp->udp_checksum);
16277 vam->result_ready = 1;
16281 vl_api_ipfix_exporter_details_t_handler_json
16282 (vl_api_ipfix_exporter_details_t * mp)
16284 vat_main_t *vam = &vat_main;
16285 vat_json_node_t node;
16286 struct in_addr collector_address;
16287 struct in_addr src_address;
16289 vat_json_init_object (&node);
16290 clib_memcpy (&collector_address, &mp->collector_address,
16291 sizeof (collector_address));
16292 vat_json_object_add_ip4 (&node, "collector_address", collector_address);
16293 vat_json_object_add_uint (&node, "collector_port",
16294 ntohs (mp->collector_port));
16295 clib_memcpy (&src_address, &mp->src_address, sizeof (src_address));
16296 vat_json_object_add_ip4 (&node, "src_address", src_address);
16297 vat_json_object_add_int (&node, "vrf_id", ntohl (mp->vrf_id));
16298 vat_json_object_add_uint (&node, "path_mtu", ntohl (mp->path_mtu));
16299 vat_json_object_add_uint (&node, "template_interval",
16300 ntohl (mp->template_interval));
16301 vat_json_object_add_int (&node, "udp_checksum", mp->udp_checksum);
16303 vat_json_print (vam->ofp, &node);
16304 vat_json_free (&node);
16306 vam->result_ready = 1;
16310 api_ipfix_exporter_dump (vat_main_t * vam)
16312 vl_api_ipfix_exporter_dump_t *mp;
16315 /* Construct the API message */
16316 M (IPFIX_EXPORTER_DUMP, mp);
16325 api_ipfix_classify_stream_dump (vat_main_t * vam)
16327 vl_api_ipfix_classify_stream_dump_t *mp;
16330 /* Construct the API message */
16331 M (IPFIX_CLASSIFY_STREAM_DUMP, mp);
16342 vl_api_ipfix_classify_stream_details_t_handler
16343 (vl_api_ipfix_classify_stream_details_t * mp)
16345 vat_main_t *vam = &vat_main;
16346 print (vam->ofp, "domain_id %d, src_port %d",
16347 ntohl (mp->domain_id), ntohs (mp->src_port));
16349 vam->result_ready = 1;
16353 vl_api_ipfix_classify_stream_details_t_handler_json
16354 (vl_api_ipfix_classify_stream_details_t * mp)
16356 vat_main_t *vam = &vat_main;
16357 vat_json_node_t node;
16359 vat_json_init_object (&node);
16360 vat_json_object_add_uint (&node, "domain_id", ntohl (mp->domain_id));
16361 vat_json_object_add_uint (&node, "src_port", ntohs (mp->src_port));
16363 vat_json_print (vam->ofp, &node);
16364 vat_json_free (&node);
16366 vam->result_ready = 1;
16370 api_ipfix_classify_table_dump (vat_main_t * vam)
16372 vl_api_ipfix_classify_table_dump_t *mp;
16373 vl_api_control_ping_t *mp_ping;
16376 if (!vam->json_output)
16378 print (vam->ofp, "%15s%15s%20s", "table_id", "ip_version",
16379 "transport_protocol");
16382 /* Construct the API message */
16383 M (IPFIX_CLASSIFY_TABLE_DUMP, mp);
16388 /* Use a control ping for synchronization */
16389 M (CONTROL_PING, mp_ping);
16397 vl_api_ipfix_classify_table_details_t_handler
16398 (vl_api_ipfix_classify_table_details_t * mp)
16400 vat_main_t *vam = &vat_main;
16401 print (vam->ofp, "%15d%15d%20d", ntohl (mp->table_id), mp->ip_version,
16402 mp->transport_protocol);
16406 vl_api_ipfix_classify_table_details_t_handler_json
16407 (vl_api_ipfix_classify_table_details_t * mp)
16409 vat_json_node_t *node = NULL;
16410 vat_main_t *vam = &vat_main;
16412 if (VAT_JSON_ARRAY != vam->json_tree.type)
16414 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16415 vat_json_init_array (&vam->json_tree);
16418 node = vat_json_array_add (&vam->json_tree);
16419 vat_json_init_object (node);
16421 vat_json_object_add_uint (node, "table_id", ntohl (mp->table_id));
16422 vat_json_object_add_uint (node, "ip_version", mp->ip_version);
16423 vat_json_object_add_uint (node, "transport_protocol",
16424 mp->transport_protocol);
16428 api_sw_interface_span_enable_disable (vat_main_t * vam)
16430 unformat_input_t *i = vam->input;
16431 vl_api_sw_interface_span_enable_disable_t *mp;
16432 u32 src_sw_if_index = ~0;
16433 u32 dst_sw_if_index = ~0;
16437 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16440 (i, "src %U", api_unformat_sw_if_index, vam, &src_sw_if_index))
16442 else if (unformat (i, "src_sw_if_index %d", &src_sw_if_index))
16446 (i, "dst %U", api_unformat_sw_if_index, vam, &dst_sw_if_index))
16448 else if (unformat (i, "dst_sw_if_index %d", &dst_sw_if_index))
16450 else if (unformat (i, "disable"))
16452 else if (unformat (i, "rx"))
16454 else if (unformat (i, "tx"))
16456 else if (unformat (i, "both"))
16462 M (SW_INTERFACE_SPAN_ENABLE_DISABLE, mp);
16464 mp->sw_if_index_from = htonl (src_sw_if_index);
16465 mp->sw_if_index_to = htonl (dst_sw_if_index);
16474 vl_api_sw_interface_span_details_t_handler (vl_api_sw_interface_span_details_t
16477 vat_main_t *vam = &vat_main;
16478 u8 *sw_if_from_name = 0;
16479 u8 *sw_if_to_name = 0;
16480 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16481 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16482 char *states[] = { "none", "rx", "tx", "both" };
16486 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16488 if ((u32) p->value[0] == sw_if_index_from)
16490 sw_if_from_name = (u8 *)(p->key);
16494 if ((u32) p->value[0] == sw_if_index_to)
16496 sw_if_to_name = (u8 *)(p->key);
16497 if (sw_if_from_name)
16502 print (vam->ofp, "%20s => %20s (%s)",
16503 sw_if_from_name, sw_if_to_name, states[mp->state]);
16507 vl_api_sw_interface_span_details_t_handler_json
16508 (vl_api_sw_interface_span_details_t * mp)
16510 vat_main_t *vam = &vat_main;
16511 vat_json_node_t *node = NULL;
16512 u8 *sw_if_from_name = 0;
16513 u8 *sw_if_to_name = 0;
16514 u32 sw_if_index_from = ntohl (mp->sw_if_index_from);
16515 u32 sw_if_index_to = ntohl (mp->sw_if_index_to);
16519 hash_foreach_pair (p, vam->sw_if_index_by_interface_name,
16521 if ((u32) p->value[0] == sw_if_index_from)
16523 sw_if_from_name = (u8 *)(p->key);
16527 if ((u32) p->value[0] == sw_if_index_to)
16529 sw_if_to_name = (u8 *)(p->key);
16530 if (sw_if_from_name)
16536 if (VAT_JSON_ARRAY != vam->json_tree.type)
16538 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
16539 vat_json_init_array (&vam->json_tree);
16541 node = vat_json_array_add (&vam->json_tree);
16543 vat_json_init_object (node);
16544 vat_json_object_add_uint (node, "src-if-index", sw_if_index_from);
16545 vat_json_object_add_string_copy (node, "src-if-name", sw_if_from_name);
16546 vat_json_object_add_uint (node, "dst-if-index", sw_if_index_to);
16547 if (0 != sw_if_to_name)
16549 vat_json_object_add_string_copy (node, "dst-if-name", sw_if_to_name);
16551 vat_json_object_add_uint (node, "state", mp->state);
16555 api_sw_interface_span_dump (vat_main_t * vam)
16557 vl_api_sw_interface_span_dump_t *mp;
16558 vl_api_control_ping_t *mp_ping;
16561 M (SW_INTERFACE_SPAN_DUMP, mp);
16564 /* Use a control ping for synchronization */
16565 M (CONTROL_PING, mp_ping);
16573 api_pg_create_interface (vat_main_t * vam)
16575 unformat_input_t *input = vam->input;
16576 vl_api_pg_create_interface_t *mp;
16580 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16582 if (unformat (input, "if_id %d", &if_id))
16589 errmsg ("missing pg interface index");
16593 /* Construct the API message */
16594 M (PG_CREATE_INTERFACE, mp);
16596 mp->interface_id = ntohl (if_id);
16604 api_pg_capture (vat_main_t * vam)
16606 unformat_input_t *input = vam->input;
16607 vl_api_pg_capture_t *mp;
16612 u8 pcap_file_set = 0;
16615 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16617 if (unformat (input, "if_id %d", &if_id))
16619 else if (unformat (input, "pcap %s", &pcap_file))
16621 else if (unformat (input, "count %d", &count))
16623 else if (unformat (input, "disable"))
16630 errmsg ("missing pg interface index");
16633 if (pcap_file_set > 0)
16635 if (vec_len (pcap_file) > 255)
16637 errmsg ("pcap file name is too long");
16642 u32 name_len = vec_len (pcap_file);
16643 /* Construct the API message */
16644 M (PG_CAPTURE, mp);
16646 mp->interface_id = ntohl (if_id);
16647 mp->is_enabled = enable;
16648 mp->count = ntohl (count);
16649 mp->pcap_name_length = ntohl (name_len);
16650 if (pcap_file_set != 0)
16652 clib_memcpy (mp->pcap_file_name, pcap_file, name_len);
16654 vec_free (pcap_file);
16662 api_pg_enable_disable (vat_main_t * vam)
16664 unformat_input_t *input = vam->input;
16665 vl_api_pg_enable_disable_t *mp;
16668 u8 stream_name_set = 0;
16669 u8 *stream_name = 0;
16671 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16673 if (unformat (input, "stream %s", &stream_name))
16674 stream_name_set = 1;
16675 else if (unformat (input, "disable"))
16681 if (stream_name_set > 0)
16683 if (vec_len (stream_name) > 255)
16685 errmsg ("stream name too long");
16690 u32 name_len = vec_len (stream_name);
16691 /* Construct the API message */
16692 M (PG_ENABLE_DISABLE, mp);
16694 mp->is_enabled = enable;
16695 if (stream_name_set != 0)
16697 mp->stream_name_length = ntohl (name_len);
16698 clib_memcpy (mp->stream_name, stream_name, name_len);
16700 vec_free (stream_name);
16708 api_ip_source_and_port_range_check_add_del (vat_main_t * vam)
16710 unformat_input_t *input = vam->input;
16711 vl_api_ip_source_and_port_range_check_add_del_t *mp;
16713 u16 *low_ports = 0;
16714 u16 *high_ports = 0;
16717 ip4_address_t ip4_addr;
16718 ip6_address_t ip6_addr;
16727 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16729 if (unformat (input, "%U/%d", unformat_ip4_address, &ip4_addr, &length))
16735 (input, "%U/%d", unformat_ip6_address, &ip6_addr, &length))
16740 else if (unformat (input, "vrf %d", &vrf_id))
16742 else if (unformat (input, "del"))
16744 else if (unformat (input, "port %d", &tmp))
16746 if (tmp == 0 || tmp > 65535)
16748 errmsg ("port %d out of range", tmp);
16752 this_hi = this_low + 1;
16753 vec_add1 (low_ports, this_low);
16754 vec_add1 (high_ports, this_hi);
16756 else if (unformat (input, "range %d - %d", &tmp, &tmp2))
16758 if ((tmp > tmp2) || (tmp == 0) || (tmp2 > 65535))
16760 errmsg ("incorrect range parameters");
16764 /* Note: in debug CLI +1 is added to high before
16765 passing to real fn that does "the work"
16766 (ip_source_and_port_range_check_add_del).
16767 This fn is a wrapper around the binary API fn a
16768 control plane will call, which expects this increment
16769 to have occurred. Hence letting the binary API control
16770 plane fn do the increment for consistency between VAT
16771 and other control planes.
16774 vec_add1 (low_ports, this_low);
16775 vec_add1 (high_ports, this_hi);
16781 if (prefix_set == 0)
16783 errmsg ("<address>/<mask> not specified");
16789 errmsg ("VRF ID required, not specified");
16796 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16800 if (vec_len (low_ports) == 0)
16802 errmsg ("At least one port or port range required");
16806 M (IP_SOURCE_AND_PORT_RANGE_CHECK_ADD_DEL, mp);
16808 mp->is_add = is_add;
16813 clib_memcpy (mp->address, &ip6_addr, sizeof (ip6_addr));
16818 clib_memcpy (mp->address, &ip4_addr, sizeof (ip4_addr));
16821 mp->mask_length = length;
16822 mp->number_of_ranges = vec_len (low_ports);
16824 clib_memcpy (mp->low_ports, low_ports, vec_len (low_ports));
16825 vec_free (low_ports);
16827 clib_memcpy (mp->high_ports, high_ports, vec_len (high_ports));
16828 vec_free (high_ports);
16830 mp->vrf_id = ntohl (vrf_id);
16838 api_ip_source_and_port_range_check_interface_add_del (vat_main_t * vam)
16840 unformat_input_t *input = vam->input;
16841 vl_api_ip_source_and_port_range_check_interface_add_del_t *mp;
16842 u32 sw_if_index = ~0;
16844 u32 tcp_out_vrf_id = ~0, udp_out_vrf_id = ~0;
16845 u32 tcp_in_vrf_id = ~0, udp_in_vrf_id = ~0;
16849 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
16851 if (unformat (input, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
16853 else if (unformat (input, "sw_if_index %d", &sw_if_index))
16855 else if (unformat (input, "tcp-out-vrf %d", &tcp_out_vrf_id))
16857 else if (unformat (input, "udp-out-vrf %d", &udp_out_vrf_id))
16859 else if (unformat (input, "tcp-in-vrf %d", &tcp_in_vrf_id))
16861 else if (unformat (input, "udp-in-vrf %d", &udp_in_vrf_id))
16863 else if (unformat (input, "del"))
16869 if (sw_if_index == ~0)
16871 errmsg ("Interface required but not specified");
16877 errmsg ("VRF ID required but not specified");
16881 if (tcp_out_vrf_id == 0
16882 || udp_out_vrf_id == 0 || tcp_in_vrf_id == 0 || udp_in_vrf_id == 0)
16885 ("VRF ID should not be default. Should be distinct VRF for this purpose.");
16889 /* Construct the API message */
16890 M (IP_SOURCE_AND_PORT_RANGE_CHECK_INTERFACE_ADD_DEL, mp);
16892 mp->sw_if_index = ntohl (sw_if_index);
16893 mp->is_add = is_add;
16894 mp->tcp_out_vrf_id = ntohl (tcp_out_vrf_id);
16895 mp->udp_out_vrf_id = ntohl (udp_out_vrf_id);
16896 mp->tcp_in_vrf_id = ntohl (tcp_in_vrf_id);
16897 mp->udp_in_vrf_id = ntohl (udp_in_vrf_id);
16902 /* Wait for a reply... */
16908 api_ipsec_gre_add_del_tunnel (vat_main_t * vam)
16910 unformat_input_t *i = vam->input;
16911 vl_api_ipsec_gre_add_del_tunnel_t *mp;
16912 u32 local_sa_id = 0;
16913 u32 remote_sa_id = 0;
16914 ip4_address_t src_address;
16915 ip4_address_t dst_address;
16919 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16921 if (unformat (i, "local_sa %d", &local_sa_id))
16923 else if (unformat (i, "remote_sa %d", &remote_sa_id))
16925 else if (unformat (i, "src %U", unformat_ip4_address, &src_address))
16927 else if (unformat (i, "dst %U", unformat_ip4_address, &dst_address))
16929 else if (unformat (i, "del"))
16933 clib_warning ("parse error '%U'", format_unformat_error, i);
16938 M (IPSEC_GRE_ADD_DEL_TUNNEL, mp);
16940 mp->local_sa_id = ntohl (local_sa_id);
16941 mp->remote_sa_id = ntohl (remote_sa_id);
16942 clib_memcpy (mp->src_address, &src_address, sizeof (src_address));
16943 clib_memcpy (mp->dst_address, &dst_address, sizeof (dst_address));
16944 mp->is_add = is_add;
16952 api_punt (vat_main_t * vam)
16954 unformat_input_t *i = vam->input;
16962 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
16964 if (unformat (i, "ip %d", &ipv))
16966 else if (unformat (i, "protocol %d", &protocol))
16968 else if (unformat (i, "port %d", &port))
16970 else if (unformat (i, "del"))
16974 clib_warning ("parse error '%U'", format_unformat_error, i);
16981 mp->is_add = (u8) is_add;
16982 mp->ipv = (u8) ipv;
16983 mp->l4_protocol = (u8) protocol;
16984 mp->l4_port = htons ((u16) port);
16991 static void vl_api_ipsec_gre_tunnel_details_t_handler
16992 (vl_api_ipsec_gre_tunnel_details_t * mp)
16994 vat_main_t *vam = &vat_main;
16996 print (vam->ofp, "%11d%15U%15U%14d%14d",
16997 ntohl (mp->sw_if_index),
16998 format_ip4_address, &mp->src_address,
16999 format_ip4_address, &mp->dst_address,
17000 ntohl (mp->local_sa_id), ntohl (mp->remote_sa_id));
17003 static void vl_api_ipsec_gre_tunnel_details_t_handler_json
17004 (vl_api_ipsec_gre_tunnel_details_t * mp)
17006 vat_main_t *vam = &vat_main;
17007 vat_json_node_t *node = NULL;
17008 struct in_addr ip4;
17010 if (VAT_JSON_ARRAY != vam->json_tree.type)
17012 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17013 vat_json_init_array (&vam->json_tree);
17015 node = vat_json_array_add (&vam->json_tree);
17017 vat_json_init_object (node);
17018 vat_json_object_add_uint (node, "sw_if_index", ntohl (mp->sw_if_index));
17019 clib_memcpy (&ip4, &mp->src_address, sizeof (ip4));
17020 vat_json_object_add_ip4 (node, "src_address", ip4);
17021 clib_memcpy (&ip4, &mp->dst_address, sizeof (ip4));
17022 vat_json_object_add_ip4 (node, "dst_address", ip4);
17023 vat_json_object_add_uint (node, "local_sa_id", ntohl (mp->local_sa_id));
17024 vat_json_object_add_uint (node, "remote_sa_id", ntohl (mp->remote_sa_id));
17028 api_ipsec_gre_tunnel_dump (vat_main_t * vam)
17030 unformat_input_t *i = vam->input;
17031 vl_api_ipsec_gre_tunnel_dump_t *mp;
17032 vl_api_control_ping_t *mp_ping;
17034 u8 sw_if_index_set = 0;
17037 /* Parse args required to build the message */
17038 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17040 if (unformat (i, "sw_if_index %d", &sw_if_index))
17041 sw_if_index_set = 1;
17046 if (sw_if_index_set == 0)
17051 if (!vam->json_output)
17053 print (vam->ofp, "%11s%15s%15s%14s%14s",
17054 "sw_if_index", "src_address", "dst_address",
17055 "local_sa_id", "remote_sa_id");
17058 /* Get list of gre-tunnel interfaces */
17059 M (IPSEC_GRE_TUNNEL_DUMP, mp);
17061 mp->sw_if_index = htonl (sw_if_index);
17065 /* Use a control ping for synchronization */
17066 M (CONTROL_PING, mp_ping);
17074 api_delete_subif (vat_main_t * vam)
17076 unformat_input_t *i = vam->input;
17077 vl_api_delete_subif_t *mp;
17078 u32 sw_if_index = ~0;
17081 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17083 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17085 if (unformat (i, "sw_if_index %d", &sw_if_index))
17091 if (sw_if_index == ~0)
17093 errmsg ("missing sw_if_index");
17097 /* Construct the API message */
17098 M (DELETE_SUBIF, mp);
17099 mp->sw_if_index = ntohl (sw_if_index);
17106 #define foreach_pbb_vtr_op \
17107 _("disable", L2_VTR_DISABLED) \
17108 _("pop", L2_VTR_POP_2) \
17109 _("push", L2_VTR_PUSH_2)
17112 api_l2_interface_pbb_tag_rewrite (vat_main_t * vam)
17114 unformat_input_t *i = vam->input;
17115 vl_api_l2_interface_pbb_tag_rewrite_t *mp;
17116 u32 sw_if_index = ~0, vtr_op = ~0;
17117 u16 outer_tag = ~0;
17118 u8 dmac[6], smac[6];
17119 u8 dmac_set = 0, smac_set = 0;
17125 /* Shut up coverity */
17126 memset (dmac, 0, sizeof (dmac));
17127 memset (smac, 0, sizeof (smac));
17129 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17131 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17133 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17135 else if (unformat (i, "vtr_op %d", &vtr_op))
17137 #define _(n,v) else if (unformat(i, n)) {vtr_op = v;}
17140 else if (unformat (i, "translate_pbb_stag"))
17142 if (unformat (i, "%d", &tmp))
17144 vtr_op = L2_VTR_TRANSLATE_2_1;
17150 ("translate_pbb_stag operation requires outer tag definition");
17154 else if (unformat (i, "dmac %U", unformat_ethernet_address, dmac))
17156 else if (unformat (i, "smac %U", unformat_ethernet_address, smac))
17158 else if (unformat (i, "sid %d", &sid))
17160 else if (unformat (i, "vlanid %d", &tmp))
17164 clib_warning ("parse error '%U'", format_unformat_error, i);
17169 if ((sw_if_index == ~0) || (vtr_op == ~0))
17171 errmsg ("missing sw_if_index or vtr operation");
17174 if (((vtr_op == L2_VTR_PUSH_2) || (vtr_op == L2_VTR_TRANSLATE_2_2))
17175 && ((dmac_set == 0) || (smac_set == 0) || (sid == ~0)))
17178 ("push and translate_qinq operations require dmac, smac, sid and optionally vlanid");
17182 M (L2_INTERFACE_PBB_TAG_REWRITE, mp);
17183 mp->sw_if_index = ntohl (sw_if_index);
17184 mp->vtr_op = ntohl (vtr_op);
17185 mp->outer_tag = ntohs (outer_tag);
17186 clib_memcpy (mp->b_dmac, dmac, sizeof (dmac));
17187 clib_memcpy (mp->b_smac, smac, sizeof (smac));
17188 mp->b_vlanid = ntohs (vlanid);
17189 mp->i_sid = ntohl (sid);
17197 api_flow_classify_set_interface (vat_main_t * vam)
17199 unformat_input_t *i = vam->input;
17200 vl_api_flow_classify_set_interface_t *mp;
17202 int sw_if_index_set;
17203 u32 ip4_table_index = ~0;
17204 u32 ip6_table_index = ~0;
17208 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17210 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17211 sw_if_index_set = 1;
17212 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17213 sw_if_index_set = 1;
17214 else if (unformat (i, "del"))
17216 else if (unformat (i, "ip4-table %d", &ip4_table_index))
17218 else if (unformat (i, "ip6-table %d", &ip6_table_index))
17222 clib_warning ("parse error '%U'", format_unformat_error, i);
17227 if (sw_if_index_set == 0)
17229 errmsg ("missing interface name or sw_if_index");
17233 M (FLOW_CLASSIFY_SET_INTERFACE, mp);
17235 mp->sw_if_index = ntohl (sw_if_index);
17236 mp->ip4_table_index = ntohl (ip4_table_index);
17237 mp->ip6_table_index = ntohl (ip6_table_index);
17238 mp->is_add = is_add;
17246 api_flow_classify_dump (vat_main_t * vam)
17248 unformat_input_t *i = vam->input;
17249 vl_api_flow_classify_dump_t *mp;
17250 vl_api_control_ping_t *mp_ping;
17251 u8 type = FLOW_CLASSIFY_N_TABLES;
17254 if (unformat (i, "type %U", unformat_flow_classify_table_type, &type))
17258 errmsg ("classify table type must be specified");
17262 if (!vam->json_output)
17264 print (vam->ofp, "%10s%20s", "Intfc idx", "Classify table");
17267 M (FLOW_CLASSIFY_DUMP, mp);
17272 /* Use a control ping for synchronization */
17273 M (CONTROL_PING, mp_ping);
17276 /* Wait for a reply... */
17282 api_feature_enable_disable (vat_main_t * vam)
17284 unformat_input_t *i = vam->input;
17285 vl_api_feature_enable_disable_t *mp;
17287 u8 *feature_name = 0;
17288 u32 sw_if_index = ~0;
17292 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17294 if (unformat (i, "arc_name %s", &arc_name))
17296 else if (unformat (i, "feature_name %s", &feature_name))
17299 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17301 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17303 else if (unformat (i, "disable"))
17311 errmsg ("missing arc name");
17314 if (vec_len (arc_name) > 63)
17316 errmsg ("arc name too long");
17319 if (feature_name == 0)
17321 errmsg ("missing feature name");
17324 if (vec_len (feature_name) > 63)
17326 errmsg ("feature name too long");
17329 if (sw_if_index == ~0)
17331 errmsg ("missing interface name or sw_if_index");
17335 /* Construct the API message */
17336 M (FEATURE_ENABLE_DISABLE, mp);
17337 mp->sw_if_index = ntohl (sw_if_index);
17338 mp->enable = enable;
17339 clib_memcpy (mp->arc_name, arc_name, vec_len (arc_name));
17340 clib_memcpy (mp->feature_name, feature_name, vec_len (feature_name));
17341 vec_free (arc_name);
17342 vec_free (feature_name);
17350 api_sw_interface_tag_add_del (vat_main_t * vam)
17352 unformat_input_t *i = vam->input;
17353 vl_api_sw_interface_tag_add_del_t *mp;
17354 u32 sw_if_index = ~0;
17359 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17361 if (unformat (i, "tag %s", &tag))
17363 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17365 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17367 else if (unformat (i, "del"))
17373 if (sw_if_index == ~0)
17375 errmsg ("missing interface name or sw_if_index");
17379 if (enable && (tag == 0))
17381 errmsg ("no tag specified");
17385 /* Construct the API message */
17386 M (SW_INTERFACE_TAG_ADD_DEL, mp);
17387 mp->sw_if_index = ntohl (sw_if_index);
17388 mp->is_add = enable;
17390 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
17398 static void vl_api_l2_xconnect_details_t_handler
17399 (vl_api_l2_xconnect_details_t * mp)
17401 vat_main_t *vam = &vat_main;
17403 print (vam->ofp, "%15d%15d",
17404 ntohl (mp->rx_sw_if_index), ntohl (mp->tx_sw_if_index));
17407 static void vl_api_l2_xconnect_details_t_handler_json
17408 (vl_api_l2_xconnect_details_t * mp)
17410 vat_main_t *vam = &vat_main;
17411 vat_json_node_t *node = NULL;
17413 if (VAT_JSON_ARRAY != vam->json_tree.type)
17415 ASSERT (VAT_JSON_NONE == vam->json_tree.type);
17416 vat_json_init_array (&vam->json_tree);
17418 node = vat_json_array_add (&vam->json_tree);
17420 vat_json_init_object (node);
17421 vat_json_object_add_uint (node, "rx_sw_if_index",
17422 ntohl (mp->rx_sw_if_index));
17423 vat_json_object_add_uint (node, "tx_sw_if_index",
17424 ntohl (mp->tx_sw_if_index));
17428 api_l2_xconnect_dump (vat_main_t * vam)
17430 vl_api_l2_xconnect_dump_t *mp;
17431 vl_api_control_ping_t *mp_ping;
17434 if (!vam->json_output)
17436 print (vam->ofp, "%15s%15s", "rx_sw_if_index", "tx_sw_if_index");
17439 M (L2_XCONNECT_DUMP, mp);
17443 /* Use a control ping for synchronization */
17444 M (CONTROL_PING, mp_ping);
17452 api_sw_interface_set_mtu (vat_main_t * vam)
17454 unformat_input_t *i = vam->input;
17455 vl_api_sw_interface_set_mtu_t *mp;
17456 u32 sw_if_index = ~0;
17460 while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
17462 if (unformat (i, "mtu %d", &mtu))
17464 if (unformat (i, "%U", api_unformat_sw_if_index, vam, &sw_if_index))
17466 else if (unformat (i, "sw_if_index %d", &sw_if_index))
17472 if (sw_if_index == ~0)
17474 errmsg ("missing interface name or sw_if_index");
17480 errmsg ("no mtu specified");
17484 /* Construct the API message */
17485 M (SW_INTERFACE_SET_MTU, mp);
17486 mp->sw_if_index = ntohl (sw_if_index);
17487 mp->mtu = ntohs ((u16) mtu);
17496 q_or_quit (vat_main_t * vam)
17498 #if VPP_API_TEST_BUILTIN == 0
17499 longjmp (vam->jump_buf, 1);
17501 return 0; /* not so much */
17505 q (vat_main_t * vam)
17507 return q_or_quit (vam);
17511 quit (vat_main_t * vam)
17513 return q_or_quit (vam);
17517 comment (vat_main_t * vam)
17523 cmd_cmp (void *a1, void *a2)
17528 return strcmp ((char *) (c1[0]), (char *) (c2[0]));
17532 help (vat_main_t * vam)
17537 unformat_input_t *i = vam->input;
17540 if (unformat (i, "%s", &name))
17544 vec_add1 (name, 0);
17546 hs = hash_get_mem (vam->help_by_name, name);
17548 print (vam->ofp, "usage: %s %s", name, hs[0]);
17550 print (vam->ofp, "No such msg / command '%s'", name);
17555 print (vam->ofp, "Help is available for the following:");
17558 hash_foreach_pair (p, vam->function_by_name,
17560 vec_add1 (cmds, (u8 *)(p->key));
17564 vec_sort_with_function (cmds, cmd_cmp);
17566 for (j = 0; j < vec_len (cmds); j++)
17567 print (vam->ofp, "%s", cmds[j]);
17574 set (vat_main_t * vam)
17576 u8 *name = 0, *value = 0;
17577 unformat_input_t *i = vam->input;
17579 if (unformat (i, "%s", &name))
17581 /* The input buffer is a vector, not a string. */
17582 value = vec_dup (i->buffer);
17583 vec_delete (value, i->index, 0);
17584 /* Almost certainly has a trailing newline */
17585 if (value[vec_len (value) - 1] == '\n')
17586 value[vec_len (value) - 1] = 0;
17587 /* Make sure it's a proper string, one way or the other */
17588 vec_add1 (value, 0);
17589 (void) clib_macro_set_value (&vam->macro_main,
17590 (char *) name, (char *) value);
17593 errmsg ("usage: set <name> <value>");
17601 unset (vat_main_t * vam)
17605 if (unformat (vam->input, "%s", &name))
17606 if (clib_macro_unset (&vam->macro_main, (char *) name) == 1)
17607 errmsg ("unset: %s wasn't set", name);
17620 macro_sort_cmp (void *a1, void *a2)
17622 macro_sort_t *s1 = a1;
17623 macro_sort_t *s2 = a2;
17625 return strcmp ((char *) (s1->name), (char *) (s2->name));
17629 dump_macro_table (vat_main_t * vam)
17631 macro_sort_t *sort_me = 0, *sm;
17636 hash_foreach_pair (p, vam->macro_main.the_value_table_hash,
17638 vec_add2 (sort_me, sm, 1);
17639 sm->name = (u8 *)(p->key);
17640 sm->value = (u8 *) (p->value[0]);
17644 vec_sort_with_function (sort_me, macro_sort_cmp);
17646 if (vec_len (sort_me))
17647 print (vam->ofp, "%-15s%s", "Name", "Value");
17649 print (vam->ofp, "The macro table is empty...");
17651 for (i = 0; i < vec_len (sort_me); i++)
17652 print (vam->ofp, "%-15s%s", sort_me[i].name, sort_me[i].value);
17657 dump_node_table (vat_main_t * vam)
17660 vlib_node_t *node, *next_node;
17662 if (vec_len (vam->graph_nodes) == 0)
17664 print (vam->ofp, "Node table empty, issue get_node_graph...");
17668 for (i = 0; i < vec_len (vam->graph_nodes); i++)
17670 node = vam->graph_nodes[i];
17671 print (vam->ofp, "[%d] %s", i, node->name);
17672 for (j = 0; j < vec_len (node->next_nodes); j++)
17674 if (node->next_nodes[j] != ~0)
17676 next_node = vam->graph_nodes[node->next_nodes[j]];
17677 print (vam->ofp, " [%d] %s", j, next_node->name);
17685 value_sort_cmp (void *a1, void *a2)
17687 name_sort_t *n1 = a1;
17688 name_sort_t *n2 = a2;
17690 if (n1->value < n2->value)
17692 if (n1->value > n2->value)
17699 dump_msg_api_table (vat_main_t * vam)
17701 api_main_t *am = &api_main;
17702 name_sort_t *nses = 0, *ns;
17707 hash_foreach_pair (hp, am->msg_index_by_name_and_crc,
17709 vec_add2 (nses, ns, 1);
17710 ns->name = (u8 *)(hp->key);
17711 ns->value = (u32) hp->value[0];
17715 vec_sort_with_function (nses, value_sort_cmp);
17717 for (i = 0; i < vec_len (nses); i++)
17718 print (vam->ofp, " [%d]: %s", nses[i].value, nses[i].name);
17724 get_msg_id (vat_main_t * vam)
17729 if (unformat (vam->input, "%s", &name_and_crc))
17731 message_index = vl_api_get_msg_index (name_and_crc);
17732 if (message_index == ~0)
17734 print (vam->ofp, " '%s' not found", name_and_crc);
17737 print (vam->ofp, " '%s' has message index %d",
17738 name_and_crc, message_index);
17741 errmsg ("name_and_crc required...");
17746 search_node_table (vat_main_t * vam)
17748 unformat_input_t *line_input = vam->input;
17751 vlib_node_t *node, *next_node;
17754 if (vam->graph_node_index_by_name == 0)
17756 print (vam->ofp, "Node table empty, issue get_node_graph...");
17760 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
17762 if (unformat (line_input, "%s", &node_to_find))
17764 vec_add1 (node_to_find, 0);
17765 p = hash_get_mem (vam->graph_node_index_by_name, node_to_find);
17768 print (vam->ofp, "%s not found...", node_to_find);
17771 node = vam->graph_nodes[p[0]];
17772 print (vam->ofp, "[%d] %s", p[0], node->name);
17773 for (j = 0; j < vec_len (node->next_nodes); j++)
17775 if (node->next_nodes[j] != ~0)
17777 next_node = vam->graph_nodes[node->next_nodes[j]];
17778 print (vam->ofp, " [%d] %s", j, next_node->name);
17785 clib_warning ("parse error '%U'", format_unformat_error,
17791 vec_free (node_to_find);
17800 script (vat_main_t * vam)
17802 #if (VPP_API_TEST_BUILTIN==0)
17804 char *save_current_file;
17805 unformat_input_t save_input;
17806 jmp_buf save_jump_buf;
17807 u32 save_line_number;
17809 FILE *new_fp, *save_ifp;
17811 if (unformat (vam->input, "%s", &s))
17813 new_fp = fopen ((char *) s, "r");
17816 errmsg ("Couldn't open script file %s", s);
17823 errmsg ("Missing script name");
17827 clib_memcpy (&save_input, &vam->input, sizeof (save_input));
17828 clib_memcpy (&save_jump_buf, &vam->jump_buf, sizeof (save_jump_buf));
17829 save_ifp = vam->ifp;
17830 save_line_number = vam->input_line_number;
17831 save_current_file = (char *) vam->current_file;
17833 vam->input_line_number = 0;
17835 vam->current_file = s;
17838 clib_memcpy (&vam->input, &save_input, sizeof (vam->input));
17839 clib_memcpy (&vam->jump_buf, &save_jump_buf, sizeof (save_jump_buf));
17840 vam->ifp = save_ifp;
17841 vam->input_line_number = save_line_number;
17842 vam->current_file = (u8 *) save_current_file;
17847 clib_warning ("use the exec command...");
17853 echo (vat_main_t * vam)
17855 print (vam->ofp, "%v", vam->input->buffer);
17859 /* List of API message constructors, CLI names map to api_xxx */
17860 #define foreach_vpe_api_msg \
17861 _(create_loopback,"[mac <mac-addr>] [instance <instance>]") \
17862 _(sw_interface_dump,"") \
17863 _(sw_interface_set_flags, \
17864 "<intfc> | sw_if_index <id> admin-up | admin-down link-up | link down") \
17865 _(sw_interface_add_del_address, \
17866 "<intfc> | sw_if_index <id> <ip4-address> | <ip6-address> [del] [del-all] ") \
17867 _(sw_interface_set_table, \
17868 "<intfc> | sw_if_index <id> vrf <table-id> [ipv6]") \
17869 _(sw_interface_set_mpls_enable, \
17870 "<intfc> | sw_if_index [disable | dis]") \
17871 _(sw_interface_set_vpath, \
17872 "<intfc> | sw_if_index <id> enable | disable") \
17873 _(sw_interface_set_vxlan_bypass, \
17874 "<intfc> | sw_if_index <id> [ip4 | ip6] [enable | disable]") \
17875 _(sw_interface_set_l2_xconnect, \
17876 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17877 "enable | disable") \
17878 _(sw_interface_set_l2_bridge, \
17879 "<intfc> | sw_if_index <id> bd_id <bridge-domain-id>\n" \
17880 "[shg <split-horizon-group>] [bvi]\n" \
17881 "enable | disable") \
17882 _(bridge_domain_add_del, \
17883 "bd_id <bridge-domain-id> [flood 1|0] [uu-flood 1|0] [forward 1|0] [learn 1|0] [arp-term 1|0] [del]\n") \
17884 _(bridge_domain_dump, "[bd_id <bridge-domain-id>]\n") \
17886 "mac <mac-addr> bd_id <bridge-domain-id> [del] | sw_if <intfc> | sw_if_index <id> [static] [filter] [bvi] [count <nn>]\n") \
17888 "sw_if <intfc> | sw_if_index <id> [learn] [forward] [uu-flood] [flood]\n") \
17890 "bd_id <bridge-domain-id> [learn] [forward] [uu-flood] [flood] [arp-term] [disable]\n") \
17892 "tapname <name> mac <mac-addr> | random-mac [tag <string>]") \
17894 "<vpp-if-name> | sw_if_index <id> tapname <name> mac <mac-addr> | random-mac") \
17896 "<vpp-if-name> | sw_if_index <id>") \
17897 _(sw_interface_tap_dump, "") \
17898 _(ip_add_del_route, \
17899 "<addr>/<mask> via <addr> [table-id <n>]\n" \
17900 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17901 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17902 "[multipath] [count <n>]") \
17903 _(ip_mroute_add_del, \
17904 "<src> <grp>/<mask> [table-id <n>]\n" \
17905 "[<intfc> | sw_if_index <id>] [local] [del]") \
17906 _(mpls_route_add_del, \
17907 "<label> <eos> via <addr> [table-id <n>]\n" \
17908 "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n" \
17909 "[weight <n>] [drop] [local] [classify <n>] [del]\n" \
17910 "[multipath] [count <n>]") \
17911 _(mpls_ip_bind_unbind, \
17912 "<label> <addr/len>") \
17913 _(mpls_tunnel_add_del, \
17914 " via <addr> [table-id <n>]\n" \
17915 "sw_if_index <id>] [l2] [del]") \
17916 _(proxy_arp_add_del, \
17917 "<lo-ip4-addr> - <hi-ip4-addr> [vrf <n>] [del]") \
17918 _(proxy_arp_intfc_enable_disable, \
17919 "<intfc> | sw_if_index <id> enable | disable") \
17920 _(sw_interface_set_unnumbered, \
17921 "<intfc> | sw_if_index <id> unnum_if_index <id> [del]") \
17922 _(ip_neighbor_add_del, \
17923 "(<intfc> | sw_if_index <id>) dst <ip46-address> " \
17924 "[mac <mac-addr>] [vrf <vrf-id>] [is_static] [del]") \
17925 _(reset_vrf, "vrf <id> [ipv6]") \
17926 _(create_vlan_subif, "<intfc> | sw_if_index <id> vlan <n>") \
17927 _(create_subif, "<intfc> | sw_if_index <id> sub_id <n>\n" \
17928 "[outer_vlan_id <n>][inner_vlan_id <n>]\n" \
17929 "[no_tags][one_tag][two_tags][dot1ad][exact_match][default_sub]\n" \
17930 "[outer_vlan_id_any][inner_vlan_id_any]") \
17931 _(oam_add_del, "src <ip4-address> dst <ip4-address> [vrf <n>] [del]") \
17932 _(reset_fib, "vrf <n> [ipv6]") \
17933 _(dhcp_proxy_config, \
17934 "svr <v46-address> src <v46-address>\n" \
17935 "rx_vrf_id <nn> server_vrf_id <nn> [del]") \
17936 _(dhcp_proxy_set_vss, \
17937 "tbl_id <n> fib_id <n> oui <n> [ipv6] [del]") \
17938 _(dhcp_proxy_dump, "ip6") \
17939 _(dhcp_client_config, \
17940 "<intfc> | sw_if_index <id> [hostname <name>] [disable_event] [del]") \
17941 _(set_ip_flow_hash, \
17942 "vrf <n> [src] [dst] [sport] [dport] [proto] [reverse] [ipv6]") \
17943 _(sw_interface_ip6_enable_disable, \
17944 "<intfc> | sw_if_index <id> enable | disable") \
17945 _(sw_interface_ip6_set_link_local_address, \
17946 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>") \
17947 _(sw_interface_ip6nd_ra_prefix, \
17948 "<intfc> | sw_if_index <id> <ip6-address>/<mask-width>\n" \
17949 "val_life <n> pref_life <n> [def] [noadv] [offl] [noauto]\n" \
17950 "[nolink] [isno]") \
17951 _(sw_interface_ip6nd_ra_config, \
17952 "<intfc> | sw_if_index <id> [maxint <n>] [minint <n>]\n" \
17953 "[life <n>] [count <n>] [interval <n>] [suppress]\n" \
17954 "[managed] [other] [ll] [send] [cease] [isno] [def]") \
17955 _(set_arp_neighbor_limit, "arp_nbr_limit <n> [ipv6]") \
17956 _(l2_patch_add_del, \
17957 "rx <intfc> | rx_sw_if_index <id> tx <intfc> | tx_sw_if_index <id>\n" \
17958 "enable | disable") \
17959 _(sr_localsid_add_del, \
17960 "(del) address <addr> next_hop <addr> behavior <beh>\n" \
17961 "fib-table <num> (end.psp) sw_if_index <num>") \
17962 _(classify_add_del_table, \
17963 "buckets <nn> [skip <n>] [match <n>] [memory_size <nn-bytes>]\n" \
17964 " [del] [del-chain] mask <mask-value>\n" \
17965 " [l2-miss-next | miss-next | acl-miss-next] <name|nn>\n" \
17966 " [current-data-flag <n>] [current-data-offset <nn>] [table <nn>]") \
17967 _(classify_add_del_session, \
17968 "[hit-next|l2-hit-next|acl-hit-next|policer-hit-next] <name|nn>\n" \
17969 " table-index <nn> skip_n <nn> match_n <nn> match [hex] [l2]\n" \
17970 " [l3 [ip4|ip6]] [action set-ip4-fib-id <nn>]\n" \
17971 " [action set-ip6-fib-id <nn> | action <n> metadata <nn>] [del]") \
17972 _(classify_set_interface_ip_table, \
17973 "<intfc> | sw_if_index <nn> table <nn>") \
17974 _(classify_set_interface_l2_tables, \
17975 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
17976 " [other-table <nn>]") \
17977 _(get_node_index, "node <node-name") \
17978 _(add_node_next, "node <node-name> next <next-node-name>") \
17979 _(l2tpv3_create_tunnel, \
17980 "client_address <ip6-addr> our_address <ip6-addr>\n" \
17981 "[local_session_id <nn>][remote_session_id <nn>][local_cookie <nn>]\n" \
17982 "[remote_cookie <nn>]\n[l2-sublayer-preset]\n") \
17983 _(l2tpv3_set_tunnel_cookies, \
17984 "<intfc> | sw_if_index <nn> [new_local_cookie <nn>]\n" \
17985 "[new_remote_cookie <nn>]\n") \
17986 _(l2tpv3_interface_enable_disable, \
17987 "<intfc> | sw_if_index <nn> enable | disable") \
17988 _(l2tpv3_set_lookup_key, \
17989 "lookup_v6_src | lookup_v6_dst | lookup_session_id") \
17990 _(sw_if_l2tpv3_tunnel_dump, "") \
17991 _(vxlan_add_del_tunnel, \
17992 "src <ip-addr> { dst <ip-addr> | group <mcast-ip-addr>\n" \
17993 "{ <intfc> | mcast_sw_if_index <nn> } }\n" \
17994 "vni <vni> [encap-vrf-id <nn>] [decap-next <l2|nn>] [del]") \
17995 _(vxlan_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17996 _(gre_add_del_tunnel, \
17997 "src <ip4-addr> dst <ip4-addr> [outer-fib-id <nn>] [teb] [del]\n") \
17998 _(gre_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
17999 _(l2_fib_clear_table, "") \
18000 _(l2_interface_efp_filter, "sw_if_index <nn> enable | disable") \
18001 _(l2_interface_vlan_tag_rewrite, \
18002 "<intfc> | sw_if_index <nn> \n" \
18003 "[disable][push-[1|2]][pop-[1|2]][translate-1-[1|2]] \n" \
18004 "[translate-2-[1|2]] [push_dot1q 0] tag1 <nn> tag2 <nn>") \
18005 _(create_vhost_user_if, \
18006 "socket <filename> [server] [renumber <dev_instance>] " \
18007 "[mac <mac_address>]") \
18008 _(modify_vhost_user_if, \
18009 "<intfc> | sw_if_index <nn> socket <filename>\n" \
18010 "[server] [renumber <dev_instance>]") \
18011 _(delete_vhost_user_if, "<intfc> | sw_if_index <nn>") \
18012 _(sw_interface_vhost_user_dump, "") \
18013 _(show_version, "") \
18014 _(vxlan_gpe_add_del_tunnel, \
18015 "local <addr> remote <addr> vni <nn>\n" \
18016 "[encap-vrf-id <nn>] [decap-vrf-id <nn>] [next-ip4][next-ip6]" \
18017 "[next-ethernet] [next-nsh]\n") \
18018 _(vxlan_gpe_tunnel_dump, "[<intfc> | sw_if_index <nn>]") \
18019 _(l2_fib_table_dump, "bd_id <bridge-domain-id>") \
18020 _(interface_name_renumber, \
18021 "<intfc> | sw_if_index <nn> new_show_dev_instance <nn>") \
18022 _(input_acl_set_interface, \
18023 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18024 " [l2-table <nn>] [del]") \
18025 _(want_ip4_arp_events, "address <ip4-address> [del]") \
18026 _(want_ip6_nd_events, "address <ip6-address> [del]") \
18027 _(ip_address_dump, "(ipv4 | ipv6) (<intfc> | sw_if_index <id>)") \
18028 _(ip_dump, "ipv4 | ipv6") \
18029 _(ipsec_spd_add_del, "spd_id <n> [del]") \
18030 _(ipsec_interface_add_del_spd, "(<intfc> | sw_if_index <id>)\n" \
18032 _(ipsec_sad_add_del_entry, "sad_id <n> spi <n> crypto_alg <alg>\n" \
18033 " crypto_key <hex> tunnel_src <ip4|ip6> tunnel_dst <ip4|ip6>\n" \
18034 " integ_alg <alg> integ_key <hex>") \
18035 _(ipsec_spd_add_del_entry, "spd_id <n> priority <n> action <action>\n" \
18036 " (inbound|outbound) [sa_id <n>] laddr_start <ip4|ip6>\n" \
18037 " laddr_stop <ip4|ip6> raddr_start <ip4|ip6> raddr_stop <ip4|ip6>\n" \
18038 " [lport_start <n> lport_stop <n>] [rport_start <n> rport_stop <n>]" ) \
18039 _(ipsec_sa_set_key, "sa_id <n> crypto_key <hex> integ_key <hex>") \
18040 _(ikev2_profile_add_del, "name <profile_name> [del]") \
18041 _(ikev2_profile_set_auth, "name <profile_name> auth_method <method>\n" \
18042 "(auth_data 0x<data> | auth_data <data>)") \
18043 _(ikev2_profile_set_id, "name <profile_name> id_type <type>\n" \
18044 "(id_data 0x<data> | id_data <data>) (local|remote)") \
18045 _(ikev2_profile_set_ts, "name <profile_name> protocol <proto>\n" \
18046 "start_port <port> end_port <port> start_addr <ip4> end_addr <ip4>\n" \
18047 "(local|remote)") \
18048 _(ikev2_set_local_key, "file <absolute_file_path>") \
18049 _(ikev2_set_responder, "<profile_name> interface <interface> address <addr>") \
18050 _(ikev2_set_ike_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18051 _(ikev2_set_esp_transforms, "<profile_name> <crypto alg> <key size> <integrity alg> <DH group>") \
18052 _(ikev2_set_sa_lifetime, "<profile_name> <seconds> <jitter> <handover> <max bytes>") \
18053 _(ikev2_initiate_sa_init, "<profile_name>") \
18054 _(ikev2_initiate_del_ike_sa, "<ispi>") \
18055 _(ikev2_initiate_del_child_sa, "<ispi>") \
18056 _(ikev2_initiate_rekey_child_sa, "<ispi>") \
18057 _(delete_loopback,"sw_if_index <nn>") \
18058 _(bd_ip_mac_add_del, "bd_id <bridge-domain-id> <ip4/6-addr> <mac-addr> [del]") \
18059 _(map_add_domain, \
18060 "ip4-pfx <ip4pfx> ip6-pfx <ip6pfx> " \
18061 "ip6-src <ip6addr> " \
18062 "ea-bits-len <n> psid-offset <n> psid-len <n>") \
18063 _(map_del_domain, "index <n>") \
18064 _(map_add_del_rule, \
18065 "index <n> psid <n> dst <ip6addr> [del]") \
18066 _(map_domain_dump, "") \
18067 _(map_rule_dump, "index <map-domain>") \
18068 _(want_interface_events, "enable|disable") \
18069 _(want_stats,"enable|disable") \
18070 _(get_first_msg_id, "client <name>") \
18071 _(cop_interface_enable_disable, "<intfc> | sw_if_index <nn> [disable]") \
18072 _(cop_whitelist_enable_disable, "<intfc> | sw_if_index <nn>\n" \
18073 "fib-id <nn> [ip4][ip6][default]") \
18074 _(get_node_graph, " ") \
18075 _(sw_interface_clear_stats,"<intfc> | sw_if_index <nn>") \
18076 _(ioam_enable, "[trace] [pow] [ppc <encap|decap>]") \
18077 _(ioam_disable, "") \
18078 _(one_add_del_locator_set, "locator-set <locator_name> [iface <intf> |" \
18079 " sw_if_index <sw_if_index> p <priority> " \
18080 "w <weight>] [del]") \
18081 _(one_add_del_locator, "locator-set <locator_name> " \
18082 "iface <intf> | sw_if_index <sw_if_index> " \
18083 "p <priority> w <weight> [del]") \
18084 _(one_add_del_local_eid,"vni <vni> eid " \
18085 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18086 "locator-set <locator_name> [del]" \
18087 "[key-id sha1|sha256 secret-key <secret-key>]")\
18088 _(one_add_del_map_resolver, "<ip4|6-addr> [del]") \
18089 _(one_add_del_map_server, "<ip4|6-addr> [del]") \
18090 _(one_enable_disable, "enable|disable") \
18091 _(one_map_register_enable_disable, "enable|disable") \
18092 _(one_rloc_probe_enable_disable, "enable|disable") \
18093 _(one_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18095 "rloc <locator> p <prio> " \
18096 "w <weight> [rloc <loc> ... ] " \
18097 "action <action> [del-all]") \
18098 _(one_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18100 _(one_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18101 _(one_map_request_mode, "src-dst|dst-only") \
18102 _(one_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18103 _(one_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18104 _(one_locator_set_dump, "[local | remote]") \
18105 _(one_locator_dump, "ls_index <index> | ls_name <name>") \
18106 _(one_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18107 "[local] | [remote]") \
18108 _(one_eid_table_vni_dump, "") \
18109 _(one_eid_table_map_dump, "l2|l3") \
18110 _(one_map_resolver_dump, "") \
18111 _(one_map_server_dump, "") \
18112 _(one_adjacencies_get, "vni <vni>") \
18113 _(show_one_rloc_probe_state, "") \
18114 _(show_one_map_register_state, "") \
18115 _(show_one_status, "") \
18116 _(one_get_map_request_itr_rlocs, "") \
18117 _(show_one_pitr, "") \
18118 _(show_one_map_request_mode, "") \
18119 _(lisp_add_del_locator_set, "locator-set <locator_name> [iface <intf> |"\
18120 " sw_if_index <sw_if_index> p <priority> " \
18121 "w <weight>] [del]") \
18122 _(lisp_add_del_locator, "locator-set <locator_name> " \
18123 "iface <intf> | sw_if_index <sw_if_index> " \
18124 "p <priority> w <weight> [del]") \
18125 _(lisp_add_del_local_eid,"vni <vni> eid " \
18126 "<ipv4|ipv6>/<prefix> | <L2 address> " \
18127 "locator-set <locator_name> [del]" \
18128 "[key-id sha1|sha256 secret-key <secret-key>]") \
18129 _(lisp_add_del_map_resolver, "<ip4|6-addr> [del]") \
18130 _(lisp_add_del_map_server, "<ip4|6-addr> [del]") \
18131 _(lisp_enable_disable, "enable|disable") \
18132 _(lisp_map_register_enable_disable, "enable|disable") \
18133 _(lisp_rloc_probe_enable_disable, "enable|disable") \
18134 _(lisp_add_del_remote_mapping, "add|del vni <vni> eid <dest-eid> " \
18136 "rloc <locator> p <prio> " \
18137 "w <weight> [rloc <loc> ... ] " \
18138 "action <action> [del-all]") \
18139 _(lisp_add_del_adjacency, "add|del vni <vni> reid <remote-eid> leid " \
18141 _(lisp_pitr_set_locator_set, "locator-set <loc-set-name> | del") \
18142 _(lisp_map_request_mode, "src-dst|dst-only") \
18143 _(lisp_add_del_map_request_itr_rlocs, "<loc-set-name> [del]") \
18144 _(lisp_eid_table_add_del_map, "[del] vni <vni> vrf <vrf>") \
18145 _(lisp_locator_set_dump, "[local | remote]") \
18146 _(lisp_locator_dump, "ls_index <index> | ls_name <name>") \
18147 _(lisp_eid_table_dump, "[eid <ipv4|ipv6>/<prefix> | <mac>] [vni] " \
18148 "[local] | [remote]") \
18149 _(lisp_eid_table_vni_dump, "") \
18150 _(lisp_eid_table_map_dump, "l2|l3") \
18151 _(lisp_map_resolver_dump, "") \
18152 _(lisp_map_server_dump, "") \
18153 _(lisp_adjacencies_get, "vni <vni>") \
18154 _(lisp_gpe_fwd_entries_get, "vni <vni>") \
18155 _(lisp_gpe_fwd_entry_path_dump, "index <fwd_entry_index>") \
18156 _(gpe_set_encap_mode, "lisp|vxlan") \
18157 _(gpe_get_encap_mode, "") \
18158 _(lisp_gpe_add_del_iface, "up|down") \
18159 _(lisp_gpe_enable_disable, "enable|disable") \
18160 _(lisp_gpe_add_del_fwd_entry, "reid <eid> [leid <eid>] vni <vni>" \
18161 "vrf/bd <dp_table> loc-pair <lcl_loc> <rmt_loc> w <weight>... [del]") \
18162 _(show_lisp_rloc_probe_state, "") \
18163 _(show_lisp_map_register_state, "") \
18164 _(show_lisp_status, "") \
18165 _(lisp_get_map_request_itr_rlocs, "") \
18166 _(show_lisp_pitr, "") \
18167 _(show_lisp_map_request_mode, "") \
18168 _(af_packet_create, "name <host interface name> [hw_addr <mac>]") \
18169 _(af_packet_delete, "name <host interface name>") \
18170 _(policer_add_del, "name <policer name> <params> [del]") \
18171 _(policer_dump, "[name <policer name>]") \
18172 _(policer_classify_set_interface, \
18173 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>]\n" \
18174 " [l2-table <nn>] [del]") \
18175 _(policer_classify_dump, "type [ip4|ip6|l2]") \
18176 _(netmap_create, "name <interface name> [hw-addr <mac>] [pipe] " \
18177 "[master|slave]") \
18178 _(netmap_delete, "name <interface name>") \
18179 _(mpls_tunnel_dump, "tunnel_index <tunnel-id>") \
18180 _(mpls_fib_dump, "") \
18181 _(classify_table_ids, "") \
18182 _(classify_table_by_interface, "sw_if_index <sw_if_index>") \
18183 _(classify_table_info, "table_id <nn>") \
18184 _(classify_session_dump, "table_id <nn>") \
18185 _(set_ipfix_exporter, "collector_address <ip4> [collector_port <nn>] " \
18186 "src_address <ip4> [vrf_id <nn>] [path_mtu <nn>] " \
18187 "[template_interval <nn>] [udp_checksum]") \
18188 _(ipfix_exporter_dump, "") \
18189 _(set_ipfix_classify_stream, "[domain <domain-id>] [src_port <src-port>]") \
18190 _(ipfix_classify_stream_dump, "") \
18191 _(ipfix_classify_table_add_del, "table <table-index> ip4|ip6 [tcp|udp]") \
18192 _(ipfix_classify_table_dump, "") \
18193 _(sw_interface_span_enable_disable, "[src <intfc> | src_sw_if_index <id>] [disable | [[dst <intfc> | dst_sw_if_index <id>] [both|rx|tx]]]") \
18194 _(sw_interface_span_dump, "") \
18195 _(get_next_index, "node-name <node-name> next-node-name <node-name>") \
18196 _(pg_create_interface, "if_id <nn>") \
18197 _(pg_capture, "if_id <nnn> pcap <file_name> count <nnn> [disable]") \
18198 _(pg_enable_disable, "[stream <id>] disable") \
18199 _(ip_source_and_port_range_check_add_del, \
18200 "<ip-addr>/<mask> range <nn>-<nn> vrf <id>") \
18201 _(ip_source_and_port_range_check_interface_add_del, \
18202 "<intf> | sw_if_index <nn> [tcp-out-vrf <id>] [tcp-in-vrf <id>]" \
18203 "[udp-in-vrf <id>] [udp-out-vrf <id>]") \
18204 _(ipsec_gre_add_del_tunnel, \
18205 "src <addr> dst <addr> local_sa <sa-id> remote_sa <sa-id> [del]") \
18206 _(ipsec_gre_tunnel_dump, "[sw_if_index <nn>]") \
18207 _(delete_subif,"<intfc> | sw_if_index <nn>") \
18208 _(l2_interface_pbb_tag_rewrite, \
18209 "<intfc> | sw_if_index <nn> \n" \
18210 "[disable | push | pop | translate_pbb_stag <outer_tag>] \n" \
18211 "dmac <mac> smac <mac> sid <nn> [vlanid <nn>]") \
18212 _(punt, "protocol <l4-protocol> [ip <ver>] [port <l4-port>] [del]") \
18213 _(flow_classify_set_interface, \
18214 "<intfc> | sw_if_index <nn> [ip4-table <nn>] [ip6-table <nn>] [del]") \
18215 _(flow_classify_dump, "type [ip4|ip6]") \
18216 _(ip_fib_dump, "") \
18217 _(ip_mfib_dump, "") \
18218 _(ip6_fib_dump, "") \
18219 _(ip6_mfib_dump, "") \
18220 _(feature_enable_disable, "arc_name <arc_name> " \
18221 "feature_name <feature_name> <intfc> | sw_if_index <nn> [disable]") \
18222 _(sw_interface_tag_add_del, "<intfc> | sw_if_index <nn> tag <text>" \
18224 _(l2_xconnect_dump, "") \
18225 _(sw_interface_set_mtu, "<intfc> | sw_if_index <nn> mtu <nn>") \
18226 _(ip_neighbor_dump, "[ip6] <intfc> | sw_if_index <nn>") \
18227 _(sw_interface_get_table, "<intfc> | sw_if_index <id> [ipv6]")
18229 /* List of command functions, CLI names map directly to functions */
18230 #define foreach_cli_function \
18231 _(comment, "usage: comment <ignore-rest-of-line>") \
18232 _(dump_interface_table, "usage: dump_interface_table") \
18233 _(dump_sub_interface_table, "usage: dump_sub_interface_table") \
18234 _(dump_ipv4_table, "usage: dump_ipv4_table") \
18235 _(dump_ipv6_table, "usage: dump_ipv6_table") \
18236 _(dump_stats_table, "usage: dump_stats_table") \
18237 _(dump_macro_table, "usage: dump_macro_table ") \
18238 _(dump_node_table, "usage: dump_node_table") \
18239 _(dump_msg_api_table, "usage: dump_msg_api_table") \
18240 _(get_msg_id, "usage: get_msg_id name_and_crc") \
18241 _(echo, "usage: echo <message>") \
18242 _(exec, "usage: exec <vpe-debug-CLI-command>") \
18243 _(exec_inband, "usage: exec_inband <vpe-debug-CLI-command>") \
18244 _(help, "usage: help") \
18245 _(q, "usage: quit") \
18246 _(quit, "usage: quit") \
18247 _(search_node_table, "usage: search_node_table <name>...") \
18248 _(set, "usage: set <variable-name> <value>") \
18249 _(script, "usage: script <file-name>") \
18250 _(unset, "usage: unset <variable-name>")
18253 static void vl_api_##n##_t_handler_uni \
18254 (vl_api_##n##_t * mp) \
18256 vat_main_t * vam = &vat_main; \
18257 if (vam->json_output) { \
18258 vl_api_##n##_t_handler_json(mp); \
18260 vl_api_##n##_t_handler(mp); \
18263 foreach_vpe_api_reply_msg;
18264 #if VPP_API_TEST_BUILTIN == 0
18265 foreach_standalone_reply_msg;
18270 vat_api_hookup (vat_main_t * vam)
18273 vl_msg_api_set_handlers(VL_API_##N, #n, \
18274 vl_api_##n##_t_handler_uni, \
18276 vl_api_##n##_t_endian, \
18277 vl_api_##n##_t_print, \
18278 sizeof(vl_api_##n##_t), 1);
18279 foreach_vpe_api_reply_msg;
18280 #if VPP_API_TEST_BUILTIN == 0
18281 foreach_standalone_reply_msg;
18285 #if (VPP_API_TEST_BUILTIN==0)
18286 vl_msg_api_set_first_available_msg_id (VL_MSG_FIRST_AVAILABLE);
18289 vam->sw_if_index_by_interface_name = hash_create_string (0, sizeof (uword));
18291 vam->function_by_name = hash_create_string (0, sizeof (uword));
18293 vam->help_by_name = hash_create_string (0, sizeof (uword));
18295 /* API messages we can send */
18296 #define _(n,h) hash_set_mem (vam->function_by_name, #n, api_##n);
18297 foreach_vpe_api_msg;
18301 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18302 foreach_vpe_api_msg;
18305 /* CLI functions */
18306 #define _(n,h) hash_set_mem (vam->function_by_name, #n, n);
18307 foreach_cli_function;
18311 #define _(n,h) hash_set_mem (vam->help_by_name, #n, h);
18312 foreach_cli_function;
18316 #if VPP_API_TEST_BUILTIN
18317 static clib_error_t *
18318 vat_api_hookup_shim (vlib_main_t * vm)
18320 vat_api_hookup (&vat_main);
18324 VLIB_API_INIT_FUNCTION (vat_api_hookup_shim);
18328 * fd.io coding-style-patch-verification: ON
18331 * eval: (c-set-style "gnu")